mirror of
https://github.com/TeamMidnightDust/CullLeaves.git
synced 2025-12-16 14:15:10 +01:00
Compare commits
54 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b4ecdc4e9 | ||
|
|
0d191e2888 | ||
|
|
eef6c2aca0 | ||
|
|
c0cdc982e7 | ||
|
|
796c2f246b | ||
|
|
e8b62d24e1 | ||
|
|
766693070a | ||
|
|
57613f465d | ||
|
|
6c399af13a | ||
|
|
13a6710ee1 | ||
|
|
b8d2e6b4ab | ||
|
|
5a3f687ae6 | ||
|
|
c555df0f4d | ||
|
|
4afbe3d740 | ||
|
|
3ac34a6f9b | ||
|
|
1ad05aa6bf | ||
|
|
3e24b1ac0a | ||
|
|
849e089ff2 | ||
|
|
f3fb019bca | ||
|
|
41a4ddf633 | ||
|
|
1877e7d65d | ||
|
|
2f89a3a0db | ||
|
|
41efe55ea6 | ||
|
|
6c3f8f369e | ||
|
|
a293fdaeb3 | ||
|
|
5177f4897f | ||
|
|
74f2efbc88 | ||
|
|
054f6f35e4 | ||
|
|
e4fbd0a8f5 | ||
|
|
61e167198a | ||
|
|
4f70a32bee | ||
|
|
a979e760c7 | ||
|
|
d2b8a9dda5 | ||
|
|
87fb2c8ed7 | ||
|
|
26fefced39 | ||
|
|
6babf21877 | ||
|
|
5f0cc2f27a | ||
|
|
07ae6f47c0 | ||
|
|
2edfac7537 | ||
|
|
24f654fd67 | ||
|
|
8f2fdb6574 | ||
|
|
54e6d69456 | ||
|
|
9e5ff1cb94 | ||
|
|
102f0798b1 | ||
|
|
f74a3a1524 | ||
|
|
3cfcc46321 | ||
|
|
d5b1196751 | ||
|
|
887303f27f | ||
|
|
57a675b038 | ||
|
|
b9f0eeaacb | ||
|
|
e13f28af5c | ||
|
|
b0953e80fe | ||
|
|
8c6b995c46 | ||
|
|
2179c3eb05 |
33
.gitignore
vendored
Executable file → Normal file
33
.gitignore
vendored
Executable file → Normal file
@@ -1,25 +1,20 @@
|
|||||||
# gradle
|
|
||||||
|
|
||||||
.gradle/
|
|
||||||
out/
|
|
||||||
classes/
|
|
||||||
build/
|
build/
|
||||||
|
|
||||||
# idea
|
|
||||||
|
|
||||||
.idea/
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
*.ipr
|
||||||
|
run/
|
||||||
*.iws
|
*.iws
|
||||||
|
out/
|
||||||
# vscode
|
*.iml
|
||||||
|
.gradle/
|
||||||
.settings/
|
output/
|
||||||
.vscode/
|
|
||||||
bin/
|
bin/
|
||||||
|
libs/
|
||||||
|
.architectury-transformer/
|
||||||
|
|
||||||
.classpath
|
.classpath
|
||||||
.project
|
.project
|
||||||
|
.idea/
|
||||||
# fabric
|
classes/
|
||||||
|
.metadata
|
||||||
run/
|
.vscode
|
||||||
|
.settings
|
||||||
|
*.launch
|
||||||
135
build.gradle
Executable file → Normal file
135
build.gradle
Executable file → Normal file
@@ -1,85 +1,76 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '0.8-SNAPSHOT'
|
id "architectury-plugin" version "3.4-SNAPSHOT"
|
||||||
id 'maven-publish'
|
id "dev.architectury.loom" version "1.10-SNAPSHOT" apply false
|
||||||
|
id "me.shedaniel.unified-publishing" version "0.1.+" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_16
|
architectury {
|
||||||
targetCompatibility = JavaVersion.VERSION_16
|
injectInjectables = false
|
||||||
|
minecraft = rootProject.minecraft_version
|
||||||
archivesBaseName = project.archives_base_name
|
|
||||||
version = project.mod_version
|
|
||||||
group = project.maven_group
|
|
||||||
|
|
||||||
minecraft {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven { url "https://maven.terraformersmc.com/releases" }
|
maven {
|
||||||
maven { url "https://jitpack.io" }
|
url = "https://api.modrinth.com/maven"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
subprojects {
|
||||||
//to change the versions see the gradle.properties file
|
apply plugin: "dev.architectury.loom"
|
||||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
|
||||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
|
||||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
|
||||||
|
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
loom {
|
||||||
|
}
|
||||||
modImplementation ("com.terraformersmc:modmenu:${project.mod_menu_version}")
|
|
||||||
|
dependencies {
|
||||||
|
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
|
||||||
|
// The following line declares the mojmap mappings, you may use other mappings as well
|
||||||
|
//mappings loom.officialMojangMappings()
|
||||||
|
// The following line declares the yarn mappings you may select this one as well.
|
||||||
|
mappings loom.layered {
|
||||||
|
it.mappings("net.fabricmc:yarn:$rootProject.yarn_mappings:v2")
|
||||||
|
it.mappings("dev.architectury:yarn-mappings-patch-neoforge:$rootProject.yarn_mappings_patch_neoforge_version")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
allprojects {
|
||||||
inputs.property "version", project.version
|
apply plugin: "java"
|
||||||
|
apply plugin: "architectury-plugin"
|
||||||
|
apply plugin: "maven-publish"
|
||||||
|
|
||||||
filesMatching("fabric.mod.json") {
|
archivesBaseName = rootProject.archives_base_name
|
||||||
expand "version": project.version
|
version = rootProject.mod_version
|
||||||
}
|
group = rootProject.maven_group
|
||||||
}
|
|
||||||
|
repositories {
|
||||||
tasks.withType(JavaCompile).configureEach {
|
// Add repositories to retrieve artifacts from in here.
|
||||||
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
// You should only use this when depending on other mods because
|
||||||
// this fixes some edge cases with special characters not displaying correctly
|
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||||
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
||||||
// If Javadoc is generated, this must be specified in that task too.
|
// for more information about repositories.
|
||||||
it.options.encoding = "UTF-8"
|
}
|
||||||
|
|
||||||
// Minecraft 1.17 (21w19a) upwards uses Java 16.
|
tasks.withType(JavaCompile).configureEach {
|
||||||
it.options.release = 16
|
options.encoding = "UTF-8"
|
||||||
}
|
options.release = 21
|
||||||
|
}
|
||||||
java {
|
ext {
|
||||||
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
releaseChangelog = {
|
||||||
// if it is present.
|
def changes = new StringBuilder()
|
||||||
// If you remove this line, sources will not be generated.
|
changes << "## CullLeaves v$project.version for $project.minecraft_version\n[View the changelog](https://www.github.com/TeamMidnightDust/CullLeaves/commits/)"
|
||||||
withSourcesJar()
|
def proc = "git log --max-count=200 --pretty=format:%s".execute()
|
||||||
}
|
proc.in.eachLine { line ->
|
||||||
|
def processedLine = line.toString()
|
||||||
jar {
|
if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) {
|
||||||
from("LICENSE") {
|
changes << "\n- ${processedLine.capitalize()}"
|
||||||
rename { "${it}_${project.archivesBaseName}"}
|
}
|
||||||
}
|
}
|
||||||
}
|
proc.waitFor()
|
||||||
|
return changes.toString()
|
||||||
// configure the maven publication
|
}
|
||||||
publishing {
|
}
|
||||||
publications {
|
|
||||||
mavenJava(MavenPublication) {
|
java {
|
||||||
// add all the jars that should be included when publishing to maven
|
withSourcesJar()
|
||||||
artifact(remapJar) {
|
}
|
||||||
builtBy remapJar
|
|
||||||
}
|
|
||||||
artifact(sourcesJar) {
|
|
||||||
builtBy remapSourcesJar
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
|
||||||
repositories {
|
|
||||||
// Add repositories to publish to here.
|
|
||||||
// Notice: This block does NOT have the same function as the block in the top level.
|
|
||||||
// The repositories here will be used for publishing your artifact, not for
|
|
||||||
// retrieving dependencies.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
17
common/build.gradle
Normal file
17
common/build.gradle
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
architectury {
|
||||||
|
injectInjectables = false
|
||||||
|
common(rootProject.enabled_platforms.split(","))
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven { url "https://api.modrinth.com/maven" }
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
|
||||||
|
// Do NOT use other classes from fabric loader
|
||||||
|
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||||
|
modCompileOnlyApi "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-fabric"
|
||||||
|
// Remove the next line if you don't want to depend on the API
|
||||||
|
//modApi "dev.architectury:architectury:${rootProject.architectury_version}"
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package eu.midnightdust.cullleaves;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.LeavesBlock;
|
||||||
|
import net.minecraft.block.MangroveRootsBlock;
|
||||||
|
import net.minecraft.resource.ResourceManager;
|
||||||
|
import net.minecraft.resource.SynchronousResourceReloader;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.world.BlockView;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class CullLeavesClient {
|
||||||
|
public static final String MOD_ID = "cullleaves";
|
||||||
|
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||||
|
|
||||||
|
public static boolean forceLeafCulling = false;
|
||||||
|
public static boolean forceHideInnerLeaves = false;
|
||||||
|
|
||||||
|
public static boolean shouldHideBlock(BlockView world, BlockPos pos) {
|
||||||
|
if (CullLeavesClient.forceHideInnerLeaves) {
|
||||||
|
boolean shouldForceCull = true;
|
||||||
|
for (Direction dir : Direction.values()) {
|
||||||
|
BlockState otherState = world.getBlockState(pos.offset(dir));
|
||||||
|
if (!(otherState.getBlock() instanceof LeavesBlock) &&
|
||||||
|
!otherState.isSideSolidFullSquare(world, pos, dir.getOpposite())) {
|
||||||
|
shouldForceCull = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return shouldForceCull;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public static boolean isLeafSideInvisible(BlockState neighborState) {
|
||||||
|
if (CullLeavesConfig.enabled || CullLeavesClient.forceLeafCulling) {
|
||||||
|
return neighborState.getBlock() instanceof LeavesBlock;
|
||||||
|
}
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
public static boolean isRootSideInvisible(BlockState neighborState) {
|
||||||
|
if (CullLeavesConfig.cullRoots) {
|
||||||
|
return neighborState.getBlock() instanceof MangroveRootsBlock;
|
||||||
|
}
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ReloadListener implements SynchronousResourceReloader {
|
||||||
|
public static final ReloadListener INSTANCE = new ReloadListener();
|
||||||
|
|
||||||
|
private ReloadListener() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reload(ResourceManager manager) {
|
||||||
|
CullLeavesClient.forceLeafCulling = false;
|
||||||
|
CullLeavesClient.forceHideInnerLeaves = false;
|
||||||
|
manager.findResources("options", path -> path.toString().startsWith("cullleaves") && path.toString().endsWith("options.json")).forEach((id, resource) -> {
|
||||||
|
try {
|
||||||
|
JsonObject json = JsonParser.parseReader(resource.getReader()).getAsJsonObject();
|
||||||
|
if (json.has("forceLeafCulling")) {
|
||||||
|
CullLeavesClient.forceLeafCulling = json.get("forceLeafCulling").getAsBoolean();
|
||||||
|
LOGGER.info("Forcing leaf culling as requested by resourcepack");
|
||||||
|
}
|
||||||
|
if (json.has("forceHideInnerLeaves")) {
|
||||||
|
CullLeavesClient.forceHideInnerLeaves = json.get("forceHideInnerLeaves").getAsBoolean();
|
||||||
|
LOGGER.info("Not rendering inner leaves as requested by resourcepack");
|
||||||
|
}
|
||||||
|
} catch (IOException e) { throw new RuntimeException(e); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package eu.midnightdust.cullleaves;
|
||||||
|
|
||||||
|
import eu.midnightdust.lib.util.PlatformFunctions;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||||
|
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class CullLeavesMixinPlugin implements IMixinConfigPlugin {
|
||||||
|
private String mixinPackage;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad(String mixinPackage) {
|
||||||
|
this.mixinPackage = mixinPackage + ".";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
||||||
|
final String mixinName = mixinClassName.substring(this.mixinPackage.length());
|
||||||
|
|
||||||
|
if (mixinName.indexOf('.') < 0) return true;
|
||||||
|
return PlatformFunctions.isModLoaded(mixinName.substring(0, mixinName.indexOf('.')));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public List<String> getMixins() { return null; }
|
||||||
|
@Override public String getRefMapperConfig() { return null; }
|
||||||
|
@Override public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {}
|
||||||
|
@Override public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {}
|
||||||
|
@Override public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {}
|
||||||
|
}
|
||||||
18
common/src/main/java/eu/midnightdust/cullleaves/config/CullLeavesConfig.java
Executable file
18
common/src/main/java/eu/midnightdust/cullleaves/config/CullLeavesConfig.java
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
package eu.midnightdust.cullleaves.config;
|
||||||
|
|
||||||
|
import eu.midnightdust.lib.config.MidnightConfig;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
|
||||||
|
public class CullLeavesConfig extends MidnightConfig {
|
||||||
|
@Entry // Enable/Disable the mod. Requires Chunk Reload (F3 + A).
|
||||||
|
public static boolean enabled = true;
|
||||||
|
@Entry // Enable/Disable culling on Mangrove Roots.
|
||||||
|
public static boolean cullRoots = true;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeChanges(String modid) {
|
||||||
|
var client = MinecraftClient.getInstance();
|
||||||
|
if (client.world != null) client.worldRenderer.reload();
|
||||||
|
super.writeChanges(modid);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package eu.midnightdust.cullleaves.mixin;
|
||||||
|
|
||||||
|
import eu.midnightdust.cullleaves.CullLeavesClient;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.LeavesBlock;
|
||||||
|
import net.minecraft.client.render.VertexConsumer;
|
||||||
|
import net.minecraft.client.render.block.BlockModelRenderer;
|
||||||
|
import net.minecraft.client.render.model.BlockModelPart;
|
||||||
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.BlockRenderView;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mixin(BlockModelRenderer.class)
|
||||||
|
public class MixinBlockModelRenderer {
|
||||||
|
@Inject(at = @At("HEAD"), method = "render(Lnet/minecraft/world/BlockRenderView;Ljava/util/List;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;ZI)V", cancellable = true)
|
||||||
|
private void cullleaves$cancelRendering(BlockRenderView world, List<BlockModelPart> parts, BlockState state, BlockPos pos, MatrixStack matrices, VertexConsumer vertexConsumer, boolean cull, int overlay, CallbackInfo ci) {
|
||||||
|
if (state.getBlock() instanceof LeavesBlock &&
|
||||||
|
CullLeavesClient.shouldHideBlock(world, pos)) ci.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package eu.midnightdust.cullleaves.mixin;
|
package eu.midnightdust.cullleaves.mixin;
|
||||||
|
|
||||||
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
import eu.midnightdust.cullleaves.CullLeavesClient;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
@@ -9,20 +9,16 @@ import net.minecraft.block.LeavesBlock;
|
|||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
@Mixin(LeavesBlock.class)
|
@Mixin(value = LeavesBlock.class, priority = 1900)
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class MixinLeavesBlock extends Block {
|
public abstract class MixinLeavesBlock extends Block {
|
||||||
|
|
||||||
public MixinLeavesBlock(Settings settings) {
|
public MixinLeavesBlock(Settings settings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public boolean isSideInvisible(BlockState state, BlockState neighborState, Direction offset) {
|
public boolean isSideInvisible(BlockState state, BlockState neighborState, Direction offset) {
|
||||||
if (CullLeavesConfig.enabled) {
|
return CullLeavesClient.isLeafSideInvisible(neighborState);
|
||||||
return neighborState.getBlock() instanceof LeavesBlock;
|
|
||||||
}
|
|
||||||
else return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package eu.midnightdust.cullleaves.mixin;
|
||||||
|
|
||||||
|
import eu.midnightdust.cullleaves.CullLeavesClient;
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.block.*;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
|
@Mixin(value = MangroveRootsBlock.class, priority = 1900)
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public abstract class MixinMangroveRootsBlock extends Block {
|
||||||
|
|
||||||
|
public MixinMangroveRootsBlock(Settings settings) {
|
||||||
|
super(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSideInvisible(BlockState state, BlockState neighborState, Direction offset) {
|
||||||
|
return CullLeavesClient.isRootSideInvisible(neighborState);
|
||||||
|
}
|
||||||
|
}
|
||||||
2
common/src/main/resources/architectury.common.json
Normal file
2
common/src/main/resources/architectury.common.json
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
{
|
||||||
|
}
|
||||||
BIN
common/src/main/resources/assets/cullleaves/icon.png
Normal file
BIN
common/src/main/resources/assets/cullleaves/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.2 KiB |
9
common/src/main/resources/assets/cullleaves/lang/de_de.json
Executable file
9
common/src/main/resources/assets/cullleaves/lang/de_de.json
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"cullleaves.midnightconfig.title":"Cull Leaves Konfiguration",
|
||||||
|
"cullleaves.midnightconfig.enabled.tooltip":"Aktiviert Culling bei Blättern, was zu besserer Performance führt.\n§cNach dem Ändern dieser Option müssen alle Chunks neugeladen werden (F3 + A)",
|
||||||
|
"cullleaves.midnightconfig.enabled.tooltip.sodium":"Aktiviert Culling bei Blättern, was zu besserer Performance führt.",
|
||||||
|
"cullleaves.midnightconfig.enabled":"Aktiviere Culling von Blättern",
|
||||||
|
"cullleaves.midnightconfig.cullRoots.tooltip":"Aktiviert Culling von Mangrovenwurzeln.\n§cNach dem Ändern dieser Option müssen alle Chunks neugeladen werden (F3 + A)",
|
||||||
|
"cullleaves.midnightconfig.cullRoots.tooltip.sodium":"Aktiviert Culling von Mangrovenwurzeln.",
|
||||||
|
"cullleaves.midnightconfig.cullRoots":"Culling von Mangrovenwurzeln"
|
||||||
|
}
|
||||||
9
common/src/main/resources/assets/cullleaves/lang/en_us.json
Executable file
9
common/src/main/resources/assets/cullleaves/lang/en_us.json
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"cullleaves.midnightconfig.title":"Cull Leaves Config",
|
||||||
|
"cullleaves.midnightconfig.enabled.tooltip":"Enables culling for leaves, providing a nice performance boost.\n§cAfter changing this setting you have to reload all chunks (F3 + A)",
|
||||||
|
"cullleaves.midnightconfig.enabled.tooltip.sodium":"Enables culling for leaves, providing a nice performance boost",
|
||||||
|
"cullleaves.midnightconfig.enabled":"Enable Leaf Culling",
|
||||||
|
"cullleaves.midnightconfig.cullRoots.tooltip":"Enables culling for mangrove roots.\n§cAfter changing this setting you have to reload all chunks (F3 + A)",
|
||||||
|
"cullleaves.midnightconfig.cullRoots.tooltip.sodium":"Enables culling for mangrove roots.",
|
||||||
|
"cullleaves.midnightconfig.cullRoots":"Enable Mangrove Root Culling"
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"cullleaves.midnightconfig.title": "Konfigurasi Cull Leaves",
|
||||||
|
"cullleaves.midnightconfig.enabled.tooltip": "Mendayakan penyorokan daun yang memberikan peningkatan prestasi yang bagus\n§cSelepas menukar tetapan ini, anda perlu memuat semula semua cebisan (F3 + A)",
|
||||||
|
"cullleaves.midnightconfig.enabled.tooltip.sodium": "Mendayakan penyorokan daun yang memberikan peningkatan prestasi yang bagus",
|
||||||
|
"cullleaves.midnightconfig.enabled": "Dayakan Penyorokan Daun",
|
||||||
|
"cullleaves.midnightconfig.cullRoots.tooltip": "Mendayakan penyorokan akar bakau.\n§cSelepas menukar tetapan ini, anda perlu memuat semula semua cebisan (F3 + A)",
|
||||||
|
"cullleaves.midnightconfig.cullRoots.tooltip.sodium": "Mendayakan penyorokan akar bakau.",
|
||||||
|
"cullleaves.midnightconfig.cullRoots": "Dayakan Penyorokan Akar Bakau"
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"cullleaves.midnightconfig.title":"Definições do Cull Leaves",
|
||||||
|
"cullleaves.midnightconfig.enabled.tooltip":"Recarregue os chunks (F3 + A) ao alterar essa opção",
|
||||||
|
"cullleaves.midnightconfig.enabled":"Ativado Cull Leaves"
|
||||||
|
}
|
||||||
10
common/src/main/resources/assets/cullleaves/lang/ru_ru.json
Normal file
10
common/src/main/resources/assets/cullleaves/lang/ru_ru.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"cullleaves.midnightconfig.title": "Настройки отбраковки листьев",
|
||||||
|
"cullleaves.midnightconfig.enabled.tooltip": "Включает отбраковку листьев, что значительно повышает производительность.\n§cПосле изменения этого параметра вам необходимо перезагрузить все чанки (F3 + A)",
|
||||||
|
"cullleaves.midnightconfig.enabled.tooltip.sodium": "Включает отбраковку листьев, что значительно повышает производительность",
|
||||||
|
"cullleaves.midnightconfig.enabled": "Включить отбраковку листьев",
|
||||||
|
"cullleaves.midnightconfig.cullRoots.tooltip": "Включает отбраковку мангровых корней.\n§cПосле изменения этого параметра вам необходимо перезагрузить все чанки (F3 + A)",
|
||||||
|
"cullleaves.midnightconfig.cullRoots.tooltip.sodium": "Включает отбраковку мангровых корней.",
|
||||||
|
"cullleaves.midnightconfig.cullRoots": "Включить отбраковку мангровых корней",
|
||||||
|
"cullleaves.resourcepack.name": "§2Делает листья идентичными 'умным листьям' в OptiFine"
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"cullleaves.midnightconfig.title":"Конфігурація Cull Leaves",
|
||||||
|
"cullleaves.midnightconfig.enabled.tooltip":"Вмикає вибраковування листя, забезпечуючи хороше підвищення продуктивності.\n§cПісля зміни цього параметра ви повинні перезавантажити всі чанки (F3 + A)",
|
||||||
|
"cullleaves.midnightconfig.enabled.tooltip.sodium":"Вмикає вибраковування листя, забезпечуючи хороше підвищення продуктивності",
|
||||||
|
"cullleaves.midnightconfig.enabled":"Увімкнути вибраковування листя",
|
||||||
|
"cullleaves.midnightconfig.sodiumBlockFaceCullingFix.tooltip": "Виправляє пакети ресурсів, які використовують мерехтіння вибраковування листя при використанні Sodium.\nЙмовірно, ви хочете, щоб це було ввімкнено.",
|
||||||
|
"cullleaves.midnightconfig.sodiumBlockFaceCullingFix": "Виправити для мода Sodium вибраковування сторін блоку для листя"
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"cullleaves.midnightconfig.title":"Cấu hình Cull Leaves",
|
||||||
|
"cullleaves.midnightconfig.enabled.tooltip":"Cho phép loại bỏ các lá, giúp tăng hiệu suất tốt.\n§cSau khi thay đổi cài đặt này, bạn phải tải lại tất cả các chunk (F3 + A)",
|
||||||
|
"cullleaves.midnightconfig.enabled.tooltip.sodium":"Cho phép loại bỏ lá, giúp tăng hiệu suất tốt",
|
||||||
|
"cullleaves.midnightconfig.enabled":"Kích hoạt loại bỏ lá",
|
||||||
|
"cullleaves.midnightconfig.sodiumBlockFaceCullingFix.tooltip": "Sửa các gói tài nguyên sử dụng loại bỏ lá nhấp nháy khi sử dụng Sodium.\nBạn có thể muốn kích hoạt tính năng này.",
|
||||||
|
"cullleaves.midnightconfig.sodiumBlockFaceCullingFix": "Khắc phục hiện tượng loại bỏ mặt khối của Sodium trên lá"
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"cullleaves.midnightconfig.title":"Cull Leaves 选项",
|
||||||
|
"cullleaves.midnightconfig.enabled.tooltip":"剔除树叶,提升性能\n§c更改此选项后须要重新加载全部区块(F3 + A)",
|
||||||
|
"cullleaves.midnightconfig.enabled.tooltip.sodium":"剔除树叶,提升性能",
|
||||||
|
"cullleaves.midnightconfig.enabled":"启用树叶剔除",
|
||||||
|
"cullleaves.midnightconfig.cullRoots.tooltip":"启用红树根剔除\n§c更改此选项后须要重新加载全部区块(F3 + A)",
|
||||||
|
"cullleaves.midnightconfig.cullRoots.tooltip.sodium":"启用红树根剔除",
|
||||||
|
"cullleaves.midnightconfig.cullRoots":"启用红树根剔除"
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"cullleaves.midnightconfig.title":"Cull Leaves 設定",
|
||||||
|
"cullleaves.midnightconfig.enabled.tooltip":"在樹葉上啟用剃除,獲得良好的效能提升。\n§c更改此設定後,您需要重新載入所有區塊(F3 + A)",
|
||||||
|
"cullleaves.midnightconfig.enabled.tooltip.sodium":"啟用樹葉剔除,獲得良好的效能提升",
|
||||||
|
"cullleaves.midnightconfig.enabled":"啟用樹葉剔除",
|
||||||
|
"cullleaves.midnightconfig.sodiumBlockFaceCullingFix.tooltip": "修復使用 Sodium 的資源包在使用葉子剔除時閃爍的問題。\n您可能想要將此功能啟用。",
|
||||||
|
"cullleaves.midnightconfig.sodiumBlockFaceCullingFix": "修復 Sodium 在葉子上的啟用方塊表面剔除"
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"cullleaves.midnightconfig.title": "کونفيݢوراسي Cull Leaves",
|
||||||
|
"cullleaves.midnightconfig.enabled.tooltip": "منداياکن ڤڽوروقن داٴون يڠ ممبريکن ڤنيڠکتن ڤريستاسي يڠ باݢوس\n§cسلڤس منوکر تتڤن اين⹁ اندا ڤرلو مموات سمولا سموا چبيسن (F3 + A)",
|
||||||
|
"cullleaves.midnightconfig.enabled.tooltip.sodium": "منداياکن ڤڽوروقن داٴون يڠ ممبريکن ڤنيڠکتن ڤريستاسي يڠ باݢوس",
|
||||||
|
"cullleaves.midnightconfig.enabled": "داياکن ڤڽوروقن داٴون",
|
||||||
|
"cullleaves.midnightconfig.cullRoots.tooltip": "منداياکن ڤڽوروقن اکر باکاو.\n§cسلڤس منوکر تتڤن اين⹁ اندا ڤرلو مموات سمولا سموا چبيسن (F3 + A)",
|
||||||
|
"cullleaves.midnightconfig.cullRoots.tooltip.sodium": "منداياکن ڤڽوروقن اکر باکاو.",
|
||||||
|
"cullleaves.midnightconfig.cullRoots": "داياکن ڤڽوروقن اکر باکاو"
|
||||||
|
}
|
||||||
14
common/src/main/resources/cullleaves.mixins.json
Normal file
14
common/src/main/resources/cullleaves.mixins.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"package": "eu.midnightdust.cullleaves.mixin",
|
||||||
|
"compatibilityLevel": "JAVA_17",
|
||||||
|
"minVersion": "0.8",
|
||||||
|
"client": [
|
||||||
|
"MixinBlockModelRenderer",
|
||||||
|
"MixinLeavesBlock",
|
||||||
|
"MixinMangroveRootsBlock"
|
||||||
|
],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"forceLeafCulling": true
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:block/leaves_notint",
|
||||||
|
"textures": {
|
||||||
|
"all": "minecraft:block/azalea_leaves"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:block/leaves_notint",
|
||||||
|
"textures": {
|
||||||
|
"all": "minecraft:block/flowering_azalea_leaves"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
{
|
||||||
|
"credit": "made by Motschen",
|
||||||
|
"parent": "block/block",
|
||||||
|
"textures": {
|
||||||
|
"particle": "#all"
|
||||||
|
},
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"name": "main",
|
||||||
|
"from": [0, 0, 0],
|
||||||
|
"to": [16, 16, 16],
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "north"},
|
||||||
|
"east": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "east"},
|
||||||
|
"south": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "south"},
|
||||||
|
"west": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "west"},
|
||||||
|
"up": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "up"},
|
||||||
|
"down": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "down"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bottom",
|
||||||
|
"from": [0, 0.01, 0],
|
||||||
|
"to": [16, 0.01, 16],
|
||||||
|
"faces": {
|
||||||
|
"up": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "down"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "west",
|
||||||
|
"from": [0.01, 0, 0],
|
||||||
|
"to": [0.01, 16, 16],
|
||||||
|
"faces": {
|
||||||
|
"east": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "west"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "north",
|
||||||
|
"from": [0, 0, 0.01],
|
||||||
|
"to": [16, 16, 0.01],
|
||||||
|
"faces": {
|
||||||
|
"south": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "north"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "east",
|
||||||
|
"from": [15.99, 0, 0],
|
||||||
|
"to": [15.99, 16, 16],
|
||||||
|
"rotation": {"angle": 0, "axis": "y", "origin": [23, 8, 8]},
|
||||||
|
"faces": {
|
||||||
|
"west": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "east"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "south",
|
||||||
|
"from": [0, 0, 15.99],
|
||||||
|
"to": [16, 16, 15.99],
|
||||||
|
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 23]},
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "south"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "up",
|
||||||
|
"from": [0, 15.99, 0],
|
||||||
|
"to": [16, 15.99, 16],
|
||||||
|
"rotation": {"angle": 0, "axis": "y", "origin": [8, 23, 8]},
|
||||||
|
"faces": {
|
||||||
|
"down": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "up"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
The MIT License
|
The MIT License
|
||||||
Copyright © 2020 Motschen
|
Copyright © 2022 Motschen
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
10
common/src/main/resources/resourcepacks/smartleaves/pack.mcmeta
Executable file
10
common/src/main/resources/resourcepacks/smartleaves/pack.mcmeta
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"pack": {
|
||||||
|
"pack_format": 15,
|
||||||
|
"supported_formats": [15, 99],
|
||||||
|
"description": {
|
||||||
|
"translate": "cullleaves.resourcepack.name",
|
||||||
|
"fallback": "§2Makes leaves look identical to OptiFine's smart leaves"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
common/src/main/resources/resourcepacks/smartleaves/pack.png
Normal file
BIN
common/src/main/resources/resourcepacks/smartleaves/pack.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
16
fabric-like/build.gradle
Normal file
16
fabric-like/build.gradle
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
architectury {
|
||||||
|
injectInjectables = false
|
||||||
|
common(rootProject.enabled_platforms.split(","))
|
||||||
|
}
|
||||||
|
|
||||||
|
loom {
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||||
|
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
|
||||||
|
// Remove the next line if you don't want to depend on the API
|
||||||
|
//modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"
|
||||||
|
|
||||||
|
compileOnly(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||||
|
}
|
||||||
111
fabric/build.gradle
Normal file
111
fabric/build.gradle
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
plugins {
|
||||||
|
id "com.github.johnrengelman.shadow" version "7.1.2"
|
||||||
|
id "me.shedaniel.unified-publishing"
|
||||||
|
}
|
||||||
|
|
||||||
|
architectury {
|
||||||
|
injectInjectables = false
|
||||||
|
platformSetupLoomIde()
|
||||||
|
fabric()
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven { url "https://api.modrinth.com/maven" }
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
common
|
||||||
|
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
||||||
|
compileClasspath.extendsFrom common
|
||||||
|
runtimeClasspath.extendsFrom common
|
||||||
|
developmentFabric.extendsFrom common
|
||||||
|
archivesBaseName = rootProject.archives_base_name + "-fabric"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||||
|
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
|
||||||
|
// Remove the next line if you don't want to depend on the API
|
||||||
|
//modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"
|
||||||
|
modImplementation include ("maven.modrinth:midnightlib:${rootProject.midnightlib_version}-fabric")
|
||||||
|
modImplementation "maven.modrinth:sodium:${rootProject.sodium_version}-fabric"
|
||||||
|
|
||||||
|
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||||
|
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
|
||||||
|
common(project(path: ":fabric-like", configuration: "namedElements")) { transitive false }
|
||||||
|
shadowCommon(project(path: ":fabric-like", configuration: "transformProductionFabric")) { transitive false }
|
||||||
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
inputs.property "version", project.version
|
||||||
|
|
||||||
|
filesMatching("fabric.mod.json") {
|
||||||
|
expand "version": project.version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
shadowJar {
|
||||||
|
exclude "architectury.common.json"
|
||||||
|
|
||||||
|
configurations = [project.configurations.shadowCommon]
|
||||||
|
archiveClassifier = "dev-shadow"
|
||||||
|
}
|
||||||
|
|
||||||
|
remapJar {
|
||||||
|
injectAccessWidener = true
|
||||||
|
input.set shadowJar.archiveFile
|
||||||
|
dependsOn shadowJar
|
||||||
|
}
|
||||||
|
|
||||||
|
sourcesJar {
|
||||||
|
def commonSources = project(":common").sourcesJar
|
||||||
|
dependsOn commonSources
|
||||||
|
from commonSources.archiveFile.map { zipTree(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
components.java {
|
||||||
|
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
||||||
|
skip()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unifiedPublishing {
|
||||||
|
project {
|
||||||
|
displayName = "CullLeaves v$project.version - Fabric $project.minecraft_version"
|
||||||
|
releaseType = "$project.release_type"
|
||||||
|
changelog = releaseChangelog()
|
||||||
|
gameVersions = []
|
||||||
|
gameLoaders = ["fabric","quilt"]
|
||||||
|
mainPublication remapJar
|
||||||
|
relations {
|
||||||
|
depends {
|
||||||
|
curseforge = "fabric-api"
|
||||||
|
modrinth = "fabric-api"
|
||||||
|
}
|
||||||
|
includes {
|
||||||
|
curseforge = "midnightlib"
|
||||||
|
modrinth = "midnightlib"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN")
|
||||||
|
if (CURSEFORGE_TOKEN != null) {
|
||||||
|
curseforge {
|
||||||
|
token = CURSEFORGE_TOKEN
|
||||||
|
id = rootProject.curseforge_id
|
||||||
|
gameVersions.addAll "Java 17", project.minecraft_version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN")
|
||||||
|
if (MODRINTH_TOKEN != null) {
|
||||||
|
modrinth {
|
||||||
|
token = MODRINTH_TOKEN
|
||||||
|
id = rootProject.modrinth_id
|
||||||
|
version = "$project.version-$project.name"
|
||||||
|
gameVersions.addAll project.minecraft_version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package eu.midnightdust.cullleaves.fabric;
|
||||||
|
|
||||||
|
import eu.midnightdust.cullleaves.CullLeavesClient;
|
||||||
|
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
||||||
|
import eu.midnightdust.lib.config.MidnightConfig;
|
||||||
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
|
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
||||||
|
import net.fabricmc.fabric.api.resource.ResourcePackActivationType;
|
||||||
|
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
|
||||||
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
import net.minecraft.resource.ResourceManager;
|
||||||
|
import net.minecraft.resource.ResourceType;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
public class CullLeavesClientFabric implements ClientModInitializer {
|
||||||
|
@Override
|
||||||
|
public void onInitializeClient() {
|
||||||
|
MidnightConfig.init(CullLeavesClient.MOD_ID, CullLeavesConfig.class);
|
||||||
|
FabricLoader.getInstance().getModContainer("cullleaves").ifPresent(modContainer -> {
|
||||||
|
ResourceManagerHelper.registerBuiltinResourcePack(Identifier.of(CullLeavesClient.MOD_ID,"smartleaves"), modContainer, ResourcePackActivationType.NORMAL);
|
||||||
|
});
|
||||||
|
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(new SimpleSynchronousResourceReloadListener() {
|
||||||
|
@Override
|
||||||
|
public Identifier getFabricId() {
|
||||||
|
return Identifier.of(CullLeavesClient.MOD_ID, "resourcepack_options");
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void reload(ResourceManager manager) {
|
||||||
|
CullLeavesClient.ReloadListener.INSTANCE.reload(manager);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package eu.midnightdust.cullleaves.fabric.mixin.sodium;
|
||||||
|
|
||||||
|
import eu.midnightdust.cullleaves.CullLeavesClient;
|
||||||
|
import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer;
|
||||||
|
import net.caffeinemc.mods.sodium.client.render.frapi.render.AbstractBlockRenderContext;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.LeavesBlock;
|
||||||
|
import net.minecraft.client.render.model.BlockStateModel;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(BlockRenderer.class)
|
||||||
|
public abstract class MixinBlockRenderer extends AbstractBlockRenderContext {
|
||||||
|
@Inject(at = @At("HEAD"), method = "renderModel", cancellable = true)
|
||||||
|
public void cullleaves$cancelRendering(BlockStateModel model, BlockState state, BlockPos pos, BlockPos origin, CallbackInfo ci) {
|
||||||
|
if (state.getBlock() instanceof LeavesBlock && CullLeavesClient.shouldHideBlock(this.level, pos))
|
||||||
|
ci.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package eu.midnightdust.cullleaves.fabric.mixin.sodium;
|
||||||
|
|
||||||
|
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
||||||
|
import net.caffeinemc.mods.sodium.client.gui.options.OptionFlag;
|
||||||
|
import net.caffeinemc.mods.sodium.client.gui.options.OptionGroup;
|
||||||
|
import net.caffeinemc.mods.sodium.client.gui.options.OptionImpact;
|
||||||
|
import net.caffeinemc.mods.sodium.client.gui.options.OptionImpl;
|
||||||
|
import net.caffeinemc.mods.sodium.client.gui.options.control.TickBoxControl;
|
||||||
|
import net.caffeinemc.mods.sodium.client.gui.options.storage.SodiumOptionsStorage;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mixin(value = net.caffeinemc.mods.sodium.client.gui.SodiumGameOptionPages.class, remap = false)
|
||||||
|
public class MixinSodiumGameOptionPages {
|
||||||
|
|
||||||
|
@Shadow @Final private static SodiumOptionsStorage sodiumOpts;
|
||||||
|
|
||||||
|
@ModifyVariable(method = "performance", at = @At(value = "INVOKE", target = "Lcom/google/common/collect/ImmutableList;copyOf(Ljava/util/Collection;)Lcom/google/common/collect/ImmutableList;"))
|
||||||
|
private static List<OptionGroup> cullleaves$addCullLeavesOption(List<OptionGroup> groups) {
|
||||||
|
groups.add(OptionGroup.createBuilder()
|
||||||
|
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||||
|
.setName(Text.translatable("cullleaves.midnightconfig.enabled"))
|
||||||
|
.setTooltip(Text.translatable("cullleaves.midnightconfig.enabled.tooltip.sodium"))
|
||||||
|
.setControl(TickBoxControl::new)
|
||||||
|
.setBinding((opts, value) -> {
|
||||||
|
CullLeavesConfig.enabled = value;
|
||||||
|
CullLeavesConfig.write("cullleaves");
|
||||||
|
}, opts -> CullLeavesConfig.enabled)
|
||||||
|
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||||
|
.setImpact(OptionImpact.MEDIUM)
|
||||||
|
.build()
|
||||||
|
).add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||||
|
.setName(Text.translatable("cullleaves.midnightconfig.cullRoots"))
|
||||||
|
.setTooltip(Text.translatable("cullleaves.midnightconfig.cullRoots.tooltip.sodium"))
|
||||||
|
.setControl(TickBoxControl::new)
|
||||||
|
.setBinding((opts, value) -> {
|
||||||
|
CullLeavesConfig.cullRoots = value;
|
||||||
|
CullLeavesConfig.write("cullleaves");
|
||||||
|
}, opts -> CullLeavesConfig.cullRoots)
|
||||||
|
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||||
|
.setImpact(OptionImpact.MEDIUM)
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
}
|
||||||
14
fabric/src/main/resources/cullleaves-fabric.mixins.json
Normal file
14
fabric/src/main/resources/cullleaves-fabric.mixins.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"package": "eu.midnightdust.cullleaves.fabric.mixin",
|
||||||
|
"plugin": "eu.midnightdust.cullleaves.CullLeavesMixinPlugin",
|
||||||
|
"compatibilityLevel": "JAVA_17",
|
||||||
|
"minVersion": "0.8",
|
||||||
|
"client": [
|
||||||
|
"sodium.MixinBlockRenderer",
|
||||||
|
"sodium.MixinSodiumGameOptionPages"
|
||||||
|
],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
17
src/main/resources/fabric.mod.json → fabric/src/main/resources/fabric.mod.json
Executable file → Normal file
17
src/main/resources/fabric.mod.json → fabric/src/main/resources/fabric.mod.json
Executable file → Normal file
@@ -21,19 +21,20 @@
|
|||||||
"environment": "client",
|
"environment": "client",
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"client": [
|
"client": [
|
||||||
"eu.midnightdust.cullleaves.CullLeavesClient"
|
"eu.midnightdust.cullleaves.fabric.CullLeavesClientFabric"
|
||||||
],
|
|
||||||
"modmenu": [
|
|
||||||
"eu.midnightdust.cullleaves.config.ModMenuIntegration"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabric-resource-loader-v0": "*",
|
"midnightlib": "*",
|
||||||
"minecraft": ">=1.16"
|
"minecraft": ">=1.21"
|
||||||
|
},
|
||||||
|
"breaks": {
|
||||||
|
"sodium": "<0.6.0"
|
||||||
},
|
},
|
||||||
|
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"cullleaves.mixins.json"
|
"cullleaves.mixins.json",
|
||||||
|
"cullleaves-fabric.mixins.json"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
36
gradle.properties
Executable file → Normal file
36
gradle.properties
Executable file → Normal file
@@ -1,18 +1,24 @@
|
|||||||
# Done to increase the memory available to gradle.
|
org.gradle.jvmargs=-Xmx4096M
|
||||||
org.gradle.jvmargs=-Xmx1G
|
|
||||||
|
|
||||||
# Fabric Properties
|
minecraft_version=1.21.6
|
||||||
# check these on https://fabricmc.net/use
|
yarn_mappings=1.21.6+build.1
|
||||||
minecraft_version=1.17-rc1
|
enabled_platforms=fabric,neoforge
|
||||||
yarn_mappings=1.17-rc1+build.5
|
|
||||||
loader_version=0.11.3
|
|
||||||
|
|
||||||
# Mod Properties
|
archives_base_name=cullleaves
|
||||||
mod_version = 2.2.0
|
mod_version=4.0.5
|
||||||
maven_group = eu.midnightdust
|
maven_group=eu.midnightdust
|
||||||
archives_base_name = cullleaves
|
release_type=release
|
||||||
|
curseforge_id=423254
|
||||||
|
modrinth_id=GNxdLCoP
|
||||||
|
|
||||||
# Dependencies
|
midnightlib_version=1.7.4+1.21.6
|
||||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
sodium_version=mc1.21.6-0.6.13
|
||||||
fabric_version=0.34.8+1.17
|
|
||||||
mod_menu_version = 2.0.0-beta.7
|
fabric_loader_version=0.16.14
|
||||||
|
fabric_api_version=0.127.0+1.21.6
|
||||||
|
|
||||||
|
neoforge_version=21.6.0-beta
|
||||||
|
yarn_mappings_patch_neoforge_version = 1.21+build.4
|
||||||
|
|
||||||
|
quilt_loader_version=0.18.9
|
||||||
|
quilt_fabric_api_version=7.0.6+0.85.0-1.20.1
|
||||||
|
|||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Executable file → Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Executable file → Normal file
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
Executable file → Normal file
3
gradle/wrapper/gradle-wrapper.properties
vendored
Executable file → Normal file
@@ -1,5 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
285
gradlew
vendored
285
gradlew
vendored
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright 2015 the original author or authors.
|
# Copyright © 2015-2021 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -17,67 +17,101 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
#
|
||||||
## Gradle start up script for UN*X
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
##
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
# Resolve links: $0 may be a link
|
|
||||||
PRG="$0"
|
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
|
||||||
ls=`ls -ld "$PRG"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
PRG="$link"
|
|
||||||
else
|
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
# Resolve links: $0 may be a link
|
||||||
APP_BASE_NAME=`basename "$0"`
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD=maximum
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "`uname`" in
|
case "$( uname )" in #(
|
||||||
CYGWIN* )
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
cygwin=true
|
Darwin* ) darwin=true ;; #(
|
||||||
;;
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
Darwin* )
|
NONSTOP* ) nonstop=true ;;
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
NONSTOP* )
|
|
||||||
nonstop=true
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
@@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
else
|
else
|
||||||
JAVACMD="$JAVA_HOME/bin/java"
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
@@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD="java"
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
@@ -106,80 +140,105 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
case $MAX_FD in #(
|
||||||
if [ $? -eq 0 ] ; then
|
max*)
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
# shellcheck disable=SC3045
|
||||||
fi
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
ulimit -n $MAX_FD
|
warn "Could not query maximum file descriptor limit"
|
||||||
if [ $? -ne 0 ] ; then
|
esac
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
case $MAX_FD in #(
|
||||||
fi
|
'' | soft) :;; #(
|
||||||
else
|
*)
|
||||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
fi
|
# shellcheck disable=SC3045
|
||||||
fi
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
# For Darwin, add options to specify how the application appears in the dock
|
|
||||||
if $darwin; then
|
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
|
||||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
||||||
SEP=""
|
|
||||||
for dir in $ROOTDIRSRAW ; do
|
|
||||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
||||||
SEP="|"
|
|
||||||
done
|
|
||||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
|
||||||
# Add a user-defined pattern to the cygpath arguments
|
|
||||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
|
||||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
|
||||||
fi
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
i=0
|
|
||||||
for arg in "$@" ; do
|
|
||||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
|
||||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
|
||||||
|
|
||||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
|
||||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
|
||||||
else
|
|
||||||
eval `echo args$i`="\"$arg\""
|
|
||||||
fi
|
|
||||||
i=`expr $i + 1`
|
|
||||||
done
|
|
||||||
case $i in
|
|
||||||
0) set -- ;;
|
|
||||||
1) set -- "$args0" ;;
|
|
||||||
2) set -- "$args0" "$args1" ;;
|
|
||||||
3) set -- "$args0" "$args1" "$args2" ;;
|
|
||||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
|
||||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
|
||||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
|
||||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
|
||||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
|
||||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Escape application args
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
save () {
|
# * args from the command line
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
# * the main class name
|
||||||
echo " "
|
# * -classpath
|
||||||
}
|
# * -D...appname settings
|
||||||
APP_ARGS=`save "$@"`
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command;
|
||||||
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||||
|
# shell script including quotes and variable substitutions, so put them in
|
||||||
|
# double quotes to make sure that they get re-expanded; and
|
||||||
|
# * put everything else in single quotes, so that it's not re-expanded.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|||||||
181
gradlew.bat
vendored
Executable file → Normal file
181
gradlew.bat
vendored
Executable file → Normal file
@@ -1,89 +1,92 @@
|
|||||||
@rem
|
@rem
|
||||||
@rem Copyright 2015 the original author or authors.
|
@rem Copyright 2015 the original author or authors.
|
||||||
@rem
|
@rem
|
||||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@rem you may not use this file except in compliance with the License.
|
@rem you may not use this file except in compliance with the License.
|
||||||
@rem You may obtain a copy of the License at
|
@rem You may obtain a copy of the License at
|
||||||
@rem
|
@rem
|
||||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
@rem
|
@rem
|
||||||
@rem Unless required by applicable law or agreed to in writing, software
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@rem
|
@rem
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
|
|
||||||
@rem Set local scope for the variables with windows NT shell
|
@rem Set local scope for the variables with windows NT shell
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
set APP_BASE_NAME=%~n0
|
@rem This is normally unused
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
|
||||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
@rem Find java.exe
|
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
set JAVA_EXE=java.exe
|
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
set JAVA_EXE=java.exe
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
echo.
|
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo.
|
||||||
echo.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo.
|
||||||
echo location of your Java installation.
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
goto fail
|
|
||||||
|
goto fail
|
||||||
:findJavaFromJavaHome
|
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
:findJavaFromJavaHome
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
if exist "%JAVA_EXE%" goto execute
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
echo.
|
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo.
|
||||||
echo.
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo.
|
||||||
echo location of your Java installation.
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
goto fail
|
|
||||||
|
goto fail
|
||||||
:execute
|
|
||||||
@rem Setup the command line
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
@rem Execute Gradle
|
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
:end
|
|
||||||
@rem End local scope for the variables with windows NT shell
|
:end
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
:fail
|
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
:fail
|
||||||
rem the _cmd.exe /c_ return code!
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
rem the _cmd.exe /c_ return code!
|
||||||
exit /b 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
:mainEnd
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:omega
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
|
|||||||
118
neoforge/build.gradle
Normal file
118
neoforge/build.gradle
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
plugins {
|
||||||
|
id "com.github.johnrengelman.shadow" version "7.1.2"
|
||||||
|
id "me.shedaniel.unified-publishing"
|
||||||
|
}
|
||||||
|
|
||||||
|
architectury {
|
||||||
|
injectInjectables = false
|
||||||
|
platformSetupLoomIde()
|
||||||
|
neoForge()
|
||||||
|
}
|
||||||
|
|
||||||
|
loom {}
|
||||||
|
repositories {
|
||||||
|
maven { url "https://api.modrinth.com/maven" }
|
||||||
|
maven { url "https://maven.neoforged.net/releases" }
|
||||||
|
maven { url "https://maven.pkg.github.com/ims212/ForgifiedFabricAPI"
|
||||||
|
credentials {
|
||||||
|
username = "IMS212"
|
||||||
|
// Read only token
|
||||||
|
password = "ghp_" + "DEuGv0Z56vnSOYKLCXdsS9svK4nb9K39C1Hn"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maven{ url "https://maven.su5ed.dev/releases" }
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
common
|
||||||
|
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
||||||
|
compileClasspath.extendsFrom common
|
||||||
|
runtimeClasspath.extendsFrom common
|
||||||
|
developmentForge.extendsFrom common
|
||||||
|
archivesBaseName = rootProject.archives_base_name + "-neoforge"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}"
|
||||||
|
// Remove the next line if you don't want to depend on the API
|
||||||
|
//modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}"
|
||||||
|
modImplementation "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-neoforge"
|
||||||
|
modImplementation "maven.modrinth:sodium:${rootProject.sodium_version}-neoforge"
|
||||||
|
//include "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-forge"
|
||||||
|
|
||||||
|
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||||
|
shadowCommon(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive = false }
|
||||||
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
inputs.property "version", project.version
|
||||||
|
|
||||||
|
filesMatching("META-INF/neoforge.mods.toml") {
|
||||||
|
expand "version": project.version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
shadowJar {
|
||||||
|
exclude "fabric.mod.json"
|
||||||
|
exclude "architectury.common.json"
|
||||||
|
|
||||||
|
configurations = [project.configurations.shadowCommon]
|
||||||
|
archiveClassifier = "dev-shadow"
|
||||||
|
}
|
||||||
|
|
||||||
|
remapJar {
|
||||||
|
input.set shadowJar.archiveFile
|
||||||
|
dependsOn shadowJar
|
||||||
|
}
|
||||||
|
|
||||||
|
sourcesJar {
|
||||||
|
def commonSources = project(":common").sourcesJar
|
||||||
|
dependsOn commonSources
|
||||||
|
from commonSources.archiveFile.map { zipTree(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
components.java {
|
||||||
|
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
||||||
|
skip()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unifiedPublishing {
|
||||||
|
project {
|
||||||
|
displayName = "CullLeaves v$project.version - NeoForge $project.minecraft_version"
|
||||||
|
releaseType = "$project.release_type"
|
||||||
|
changelog = releaseChangelog()
|
||||||
|
gameVersions = []
|
||||||
|
gameLoaders = ["neoforge"]
|
||||||
|
|
||||||
|
mainPublication remapJar
|
||||||
|
|
||||||
|
relations {
|
||||||
|
depends {
|
||||||
|
curseforge = "midnightlib"
|
||||||
|
modrinth = "midnightlib"
|
||||||
|
}
|
||||||
|
includes {}
|
||||||
|
}
|
||||||
|
|
||||||
|
var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN")
|
||||||
|
if (CURSEFORGE_TOKEN != null) {
|
||||||
|
curseforge {
|
||||||
|
token = CURSEFORGE_TOKEN
|
||||||
|
id = rootProject.curseforge_id
|
||||||
|
gameVersions.addAll "Java 17", project.minecraft_version
|
||||||
|
releaseType = "alpha"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN")
|
||||||
|
if (MODRINTH_TOKEN != null) {
|
||||||
|
modrinth {
|
||||||
|
token = MODRINTH_TOKEN
|
||||||
|
id = rootProject.modrinth_id
|
||||||
|
version = "$project.version-$project.name"
|
||||||
|
gameVersions.addAll project.minecraft_version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1
neoforge/gradle.properties
Normal file
1
neoforge/gradle.properties
Normal file
@@ -0,0 +1 @@
|
|||||||
|
loom.platform=neoforge
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package eu.midnightdust.cullleaves.neoforge;
|
||||||
|
|
||||||
|
import eu.midnightdust.cullleaves.CullLeavesClient;
|
||||||
|
import net.minecraft.resource.*;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
|
import net.neoforged.fml.ModList;
|
||||||
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
|
import net.neoforged.neoforge.client.event.AddClientReloadListenersEvent;
|
||||||
|
import net.neoforged.neoforge.event.AddPackFindersEvent;
|
||||||
|
import net.neoforged.neoforgespi.locating.IModFile;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@EventBusSubscriber(modid = CullLeavesClient.MOD_ID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||||
|
public class CullLeavesClientEvents {
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void addPackFinders(AddPackFindersEvent event) {
|
||||||
|
if (event.getPackType() == ResourceType.CLIENT_RESOURCES) {
|
||||||
|
registerResourcePack(event, Identifier.of(CullLeavesClient.MOD_ID, "smartleaves"), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static void registerResourcePack(AddPackFindersEvent event, Identifier id, boolean alwaysEnabled) {
|
||||||
|
event.addRepositorySource(((profileAdder) -> {
|
||||||
|
IModFile file = ModList.get().getModFileById(id.getNamespace()).getFile();
|
||||||
|
try {
|
||||||
|
ResourcePackProfile.PackFactory pack = new DirectoryResourcePack.DirectoryBackedFactory(file.findResource("resourcepacks/" + id.getPath()));
|
||||||
|
ResourcePackInfo info = new ResourcePackInfo(id.toString(), Text.of(id.getNamespace()+"/"+id.getPath()), ResourcePackSource.BUILTIN, Optional.empty());
|
||||||
|
ResourcePackProfile packProfile = ResourcePackProfile.create(info, pack, ResourceType.CLIENT_RESOURCES, new ResourcePackPosition(alwaysEnabled, ResourcePackProfile.InsertionPosition.TOP, false));
|
||||||
|
if (packProfile != null) {
|
||||||
|
profileAdder.accept(packProfile);
|
||||||
|
}
|
||||||
|
} catch (NullPointerException e) {e.fillInStackTrace();}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onResourceReload(AddClientReloadListenersEvent event) {
|
||||||
|
event.addListener(Identifier.of(CullLeavesClient.MOD_ID, "resourcepack_options"), CullLeavesClient.ReloadListener.INSTANCE);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package eu.midnightdust.cullleaves.neoforge;
|
||||||
|
|
||||||
|
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
||||||
|
import eu.midnightdust.lib.config.MidnightConfig;
|
||||||
|
import net.neoforged.fml.common.Mod;
|
||||||
|
|
||||||
|
@Mod("cullleaves")
|
||||||
|
public class CullLeavesClientForge {
|
||||||
|
public CullLeavesClientForge() {
|
||||||
|
MidnightConfig.init("cullleaves", CullLeavesConfig.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package eu.midnightdust.cullleaves.neoforge.mixin.sodium;
|
||||||
|
|
||||||
|
import eu.midnightdust.cullleaves.CullLeavesClient;
|
||||||
|
import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.LeavesBlock;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.render.model.BlockStateModel;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(BlockRenderer.class)
|
||||||
|
public abstract class MixinBlockRenderer {
|
||||||
|
// Unfortunately, we cannot use the level view from AbstractBlockRenderContext on NeoForge because of method conflicts
|
||||||
|
@Unique private static final MinecraftClient cullleaves$client = MinecraftClient.getInstance();
|
||||||
|
|
||||||
|
@Inject(at = @At("HEAD"), method = "renderModel", cancellable = true)
|
||||||
|
public void cullleaves$cancelRendering(BlockStateModel model, BlockState state, BlockPos pos, BlockPos origin, CallbackInfo ci) {
|
||||||
|
if (CullLeavesClient.forceHideInnerLeaves && state.getBlock() instanceof LeavesBlock && CullLeavesClient.shouldHideBlock(cullleaves$client.world, pos))
|
||||||
|
ci.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package eu.midnightdust.cullleaves.neoforge.mixin.sodium;
|
||||||
|
|
||||||
|
import eu.midnightdust.cullleaves.CullLeavesClient;
|
||||||
|
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
||||||
|
import net.caffeinemc.mods.sodium.client.gui.SodiumGameOptionPages;
|
||||||
|
import net.caffeinemc.mods.sodium.client.gui.options.OptionFlag;
|
||||||
|
import net.caffeinemc.mods.sodium.client.gui.options.OptionGroup;
|
||||||
|
import net.caffeinemc.mods.sodium.client.gui.options.OptionImpact;
|
||||||
|
import net.caffeinemc.mods.sodium.client.gui.options.OptionImpl;
|
||||||
|
import net.caffeinemc.mods.sodium.client.gui.options.control.TickBoxControl;
|
||||||
|
import net.caffeinemc.mods.sodium.client.gui.options.storage.SodiumOptionsStorage;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mixin(value = SodiumGameOptionPages.class, remap = false)
|
||||||
|
public class MixinSodiumGameOptionPages {
|
||||||
|
|
||||||
|
@Shadow @Final private static SodiumOptionsStorage sodiumOpts;
|
||||||
|
|
||||||
|
@ModifyVariable(method = "performance", at = @At(value = "INVOKE", target = "Lcom/google/common/collect/ImmutableList;copyOf(Ljava/util/Collection;)Lcom/google/common/collect/ImmutableList;"))
|
||||||
|
private static List<OptionGroup> cullleaves$addCullLeavesOption(List<OptionGroup> groups) {
|
||||||
|
groups.add(OptionGroup.createBuilder()
|
||||||
|
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||||
|
.setName(Text.translatable("cullleaves.midnightconfig.enabled"))
|
||||||
|
.setTooltip(Text.translatable("cullleaves.midnightconfig.enabled.tooltip.sodium"))
|
||||||
|
.setControl(TickBoxControl::new)
|
||||||
|
.setBinding((opts, value) -> {
|
||||||
|
CullLeavesConfig.enabled = value;
|
||||||
|
CullLeavesConfig.write(CullLeavesClient.MOD_ID);
|
||||||
|
}, opts -> CullLeavesConfig.enabled)
|
||||||
|
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||||
|
.setImpact(OptionImpact.MEDIUM)
|
||||||
|
.build()
|
||||||
|
).add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||||
|
.setName(Text.translatable("cullleaves.midnightconfig.cullRoots"))
|
||||||
|
.setTooltip(Text.translatable("cullleaves.midnightconfig.cullRoots.tooltip.sodium"))
|
||||||
|
.setControl(TickBoxControl::new)
|
||||||
|
.setBinding((opts, value) -> {
|
||||||
|
CullLeavesConfig.cullRoots = value;
|
||||||
|
CullLeavesConfig.write(CullLeavesClient.MOD_ID);
|
||||||
|
}, opts -> CullLeavesConfig.cullRoots)
|
||||||
|
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||||
|
.setImpact(OptionImpact.MEDIUM)
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
}
|
||||||
41
neoforge/src/main/resources/META-INF/neoforge.mods.toml
Normal file
41
neoforge/src/main/resources/META-INF/neoforge.mods.toml
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
modLoader = "javafml"
|
||||||
|
loaderVersion = "[1,)"
|
||||||
|
#issueTrackerURL = ""
|
||||||
|
license = "MIT License"
|
||||||
|
|
||||||
|
[[mods]]
|
||||||
|
modId = "cullleaves"
|
||||||
|
version = "${version}"
|
||||||
|
displayName = "CullLeaves"
|
||||||
|
authors = "Motschen, TeamMidnightDust"
|
||||||
|
description = '''
|
||||||
|
Adds culling to leaf blocks, providing a huge performance boost over vanilla.
|
||||||
|
'''
|
||||||
|
logoFile = "icon.png"
|
||||||
|
|
||||||
|
[[mixins]]
|
||||||
|
config = "cullleaves.mixins.json"
|
||||||
|
|
||||||
|
[[mixins]]
|
||||||
|
config = "cullleaves-neoforge.mixins.json"
|
||||||
|
|
||||||
|
[[dependencies.cullleaves]]
|
||||||
|
modId = "neoforge"
|
||||||
|
required = true
|
||||||
|
versionRange = "[20.3,)"
|
||||||
|
ordering = "NONE"
|
||||||
|
side = "CLIENT"
|
||||||
|
|
||||||
|
[[dependencies.cullleaves]]
|
||||||
|
modId = "minecraft"
|
||||||
|
required = true
|
||||||
|
versionRange = "[1.21,)"
|
||||||
|
ordering = "NONE"
|
||||||
|
side = "CLIENT"
|
||||||
|
|
||||||
|
[[dependencies.cullleaves]]
|
||||||
|
modId = "midnightlib"
|
||||||
|
required = true
|
||||||
|
versionRange = "[1.0.0,)"
|
||||||
|
ordering = "AFTER"
|
||||||
|
side = "CLIENT"
|
||||||
13
neoforge/src/main/resources/cullleaves-neoforge.mixins.json
Normal file
13
neoforge/src/main/resources/cullleaves-neoforge.mixins.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"package": "eu.midnightdust.cullleaves.neoforge.mixin",
|
||||||
|
"compatibilityLevel": "JAVA_17",
|
||||||
|
"minVersion": "0.8",
|
||||||
|
"client": [
|
||||||
|
"sodium.MixinBlockRenderer",
|
||||||
|
"sodium.MixinSodiumGameOptionPages"
|
||||||
|
],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
neoforge/src/main/resources/icon.png
Normal file
BIN
neoforge/src/main/resources/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.2 KiB |
6
neoforge/src/main/resources/pack.mcmeta
Normal file
6
neoforge/src/main/resources/pack.mcmeta
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"pack": {
|
||||||
|
"description": "CullLeaves",
|
||||||
|
"pack_format": 9
|
||||||
|
}
|
||||||
|
}
|
||||||
97
quilt/build.gradle
Normal file
97
quilt/build.gradle
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
plugins {
|
||||||
|
id "com.github.johnrengelman.shadow" version "7.1.2"
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven { url "https://maven.quiltmc.org/repository/release/" }
|
||||||
|
maven { url "https://api.modrinth.com/maven" }
|
||||||
|
}
|
||||||
|
|
||||||
|
architectury {
|
||||||
|
injectInjectables = false
|
||||||
|
platformSetupLoomIde()
|
||||||
|
loader("quilt")
|
||||||
|
}
|
||||||
|
|
||||||
|
loom {
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
common
|
||||||
|
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
||||||
|
compileClasspath.extendsFrom common
|
||||||
|
runtimeClasspath.extendsFrom common
|
||||||
|
developmentQuilt.extendsFrom common
|
||||||
|
archivesBaseName = rootProject.archives_base_name + "-quilt"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
modImplementation "org.quiltmc:quilt-loader:${rootProject.quilt_loader_version}"
|
||||||
|
modApi "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.quilt_fabric_api_version}"
|
||||||
|
// Remove the next few lines if you don't want to depend on the API
|
||||||
|
//modApi("dev.architectury:architectury-fabric:${rootProject.architectury_version}") {
|
||||||
|
// // We must not pull Fabric Loader from Architectury Fabric
|
||||||
|
// exclude group: "net.fabricmc"
|
||||||
|
// exclude group: "net.fabricmc.fabric-api"
|
||||||
|
//}
|
||||||
|
modImplementation "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-quilt"
|
||||||
|
include "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-quilt"
|
||||||
|
|
||||||
|
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||||
|
shadowCommon(project(path: ":common", configuration: "transformProductionQuilt")) { transitive false }
|
||||||
|
common(project(path: ":fabric-like", configuration: "namedElements")) { transitive false }
|
||||||
|
shadowCommon(project(path: ":fabric-like", configuration: "transformProductionQuilt")) { transitive false }
|
||||||
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
inputs.property "group", rootProject.maven_group
|
||||||
|
inputs.property "version", project.version
|
||||||
|
|
||||||
|
filesMatching("quilt.mod.json") {
|
||||||
|
expand "group": rootProject.maven_group,
|
||||||
|
"version": project.version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
shadowJar {
|
||||||
|
exclude "architectury.common.json"
|
||||||
|
|
||||||
|
configurations = [project.configurations.shadowCommon]
|
||||||
|
classifier "dev-shadow"
|
||||||
|
}
|
||||||
|
|
||||||
|
remapJar {
|
||||||
|
input.set shadowJar.archiveFile
|
||||||
|
dependsOn shadowJar
|
||||||
|
classifier null
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
classifier "dev"
|
||||||
|
}
|
||||||
|
|
||||||
|
sourcesJar {
|
||||||
|
def commonSources = project(":common").sourcesJar
|
||||||
|
dependsOn commonSources
|
||||||
|
from commonSources.archiveFile.map { zipTree(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
components.java {
|
||||||
|
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
||||||
|
skip()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
mavenQuilt(MavenPublication) {
|
||||||
|
artifactId = rootProject.archives_base_name + "-" + project.name
|
||||||
|
from components.java
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||||
|
repositories {
|
||||||
|
// Add repositories to publish to here.
|
||||||
|
}
|
||||||
|
}
|
||||||
1
quilt/gradle.properties
Normal file
1
quilt/gradle.properties
Normal file
@@ -0,0 +1 @@
|
|||||||
|
loom.platform=quilt
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package eu.midnightdust.cullleaves.quilt;
|
||||||
|
|
||||||
|
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
||||||
|
import eu.midnightdust.lib.config.MidnightConfig;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import org.quiltmc.loader.api.ModContainer;
|
||||||
|
import org.quiltmc.qsl.base.api.entrypoint.client.ClientModInitializer;
|
||||||
|
import org.quiltmc.qsl.resource.loader.api.ResourceLoader;
|
||||||
|
import org.quiltmc.qsl.resource.loader.api.ResourcePackActivationType;
|
||||||
|
|
||||||
|
public class CullLeavesClientQuilt implements ClientModInitializer {
|
||||||
|
@Override
|
||||||
|
public void onInitializeClient(ModContainer mod) {
|
||||||
|
MidnightConfig.init("cullleaves", CullLeavesConfig.class);
|
||||||
|
ResourceLoader.registerBuiltinResourcePack(new Identifier("cullleaves:smartleaves"), mod, ResourcePackActivationType.NORMAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
53
quilt/src/main/resources/quilt.mod.json
Normal file
53
quilt/src/main/resources/quilt.mod.json
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
{
|
||||||
|
"schema_version": 1,
|
||||||
|
"quilt_loader": {
|
||||||
|
"group": "${group}",
|
||||||
|
"id": "cullleaves",
|
||||||
|
"version": "${version}",
|
||||||
|
"intermediate_mappings": "net.fabricmc:intermediary",
|
||||||
|
"entrypoints": {
|
||||||
|
"client_init": [
|
||||||
|
"eu.midnightdust.cullleaves.quilt.CullLeavesClientQuilt"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"depends": [
|
||||||
|
{
|
||||||
|
"id": "quilt_loader",
|
||||||
|
"version": "*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "quilt_base",
|
||||||
|
"version": "*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "midnightlib",
|
||||||
|
"version": "*"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"breaks": [
|
||||||
|
{
|
||||||
|
"id": "sodium",
|
||||||
|
"versions": "<0.4.9"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"name": "Cull Leaves (Quilt)",
|
||||||
|
"description": "Adds culling to leaf blocks, providing a huge performance boost over vanilla.",
|
||||||
|
"contributors": {
|
||||||
|
"Motschen": "Author",
|
||||||
|
"TeamMidnightDust": "Mascot"
|
||||||
|
},
|
||||||
|
"environment": "client",
|
||||||
|
"contact": {
|
||||||
|
"email": "mail@midnightdust.eu",
|
||||||
|
"homepage": "https://modrinth.com/mod/cullleaves",
|
||||||
|
"issues": "https://github.com/TeamMidnightDust/CullLeaves/issues",
|
||||||
|
"sources": "https://github.com/TeamMidnightDust/CullLeaves"
|
||||||
|
},
|
||||||
|
"icon": "assets/cullleaves/icon.png"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mixin": [
|
||||||
|
"cullleaves.mixins.json"
|
||||||
|
]
|
||||||
|
}
|
||||||
16
settings.gradle
Executable file → Normal file
16
settings.gradle
Executable file → Normal file
@@ -1,10 +1,16 @@
|
|||||||
pluginManagement {
|
pluginManagement {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
maven { url "https://maven.fabricmc.net/" }
|
||||||
maven {
|
maven { url "https://maven.architectury.dev/" }
|
||||||
name = 'Fabric'
|
maven { url "https://maven.neoforged.net/releases" }
|
||||||
url = 'https://maven.fabricmc.net/'
|
|
||||||
}
|
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
include("common")
|
||||||
|
include("fabric-like")
|
||||||
|
include("fabric")
|
||||||
|
//include("quilt")
|
||||||
|
include("neoforge")
|
||||||
|
|
||||||
|
rootProject.name = "cullleaves"
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
package eu.midnightdust.cullleaves;
|
|
||||||
|
|
||||||
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
|
||||||
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
|
||||||
import net.fabricmc.fabric.api.resource.ResourcePackActivationType;
|
|
||||||
import net.fabricmc.loader.ModContainer;
|
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
|
|
||||||
public class CullLeavesClient implements ClientModInitializer {
|
|
||||||
|
|
||||||
public void onInitializeClient() {
|
|
||||||
CullLeavesConfig.init("cullleaves", CullLeavesConfig.class);
|
|
||||||
|
|
||||||
FabricLoader.getInstance().getModContainer("cullleaves").ifPresent(modContainer -> {
|
|
||||||
ResourceManagerHelper.registerBuiltinResourcePack(new Identifier("cullleaves:smartleaves"), modContainer, ResourcePackActivationType.DEFAULT_ENABLED);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package eu.midnightdust.cullleaves.config;
|
|
||||||
|
|
||||||
import eu.midnightdust.lib.config.MidnightConfig;
|
|
||||||
|
|
||||||
public class CullLeavesConfig extends MidnightConfig {
|
|
||||||
@Entry // Enable/Disable the mod. Requires Chunk Reload (F3 + A).
|
|
||||||
public static boolean enabled = true;
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package eu.midnightdust.cullleaves.config;
|
|
||||||
|
|
||||||
import io.github.prospector.modmenu.api.ConfigScreenFactory;
|
|
||||||
import io.github.prospector.modmenu.api.ModMenuApi;
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public class ModMenuIntegration implements ModMenuApi {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
|
||||||
return parent -> CullLeavesConfig.getScreen(parent, "cullleaves");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,376 +0,0 @@
|
|||||||
package eu.midnightdust.lib.config;
|
|
||||||
|
|
||||||
import com.google.gson.ExclusionStrategy;
|
|
||||||
import com.google.gson.FieldAttributes;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
|
||||||
import net.minecraft.client.font.TextRenderer;
|
|
||||||
import net.minecraft.client.gui.DrawableHelper;
|
|
||||||
import net.minecraft.client.gui.Element;
|
|
||||||
import net.minecraft.client.gui.Selectable;
|
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
|
||||||
import net.minecraft.client.gui.screen.ScreenTexts;
|
|
||||||
import net.minecraft.client.gui.widget.*;
|
|
||||||
import net.minecraft.client.resource.language.I18n;
|
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
|
||||||
import net.minecraft.text.*;
|
|
||||||
import net.minecraft.util.Formatting;
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.function.BiFunction;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
// MidnightConfig v1.0.2
|
|
||||||
// Single class config library - feel free to copy!
|
|
||||||
// Changelog:
|
|
||||||
// - 1.0.2:
|
|
||||||
// - Update to 21w20a
|
|
||||||
// - 1.0.1:
|
|
||||||
// - Fixed buttons not working in fullscreen
|
|
||||||
// - 1.0.0:
|
|
||||||
// - The config screen no longer shows the entries of all instances of MidnightConfig
|
|
||||||
// - Compatible with servers!
|
|
||||||
// - Scrollable!
|
|
||||||
// - Comment support!
|
|
||||||
// - Fresh New Design
|
|
||||||
|
|
||||||
/** Based on https://github.com/Minenash/TinyConfig
|
|
||||||
* Credits to Minenash */
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public class MidnightConfig {
|
|
||||||
public static boolean useTooltipForTitle = true; // Render title as tooltip or as simple text
|
|
||||||
|
|
||||||
private static final Pattern INTEGER_ONLY = Pattern.compile("(-?[0-9]*)");
|
|
||||||
private static final Pattern DECIMAL_ONLY = Pattern.compile("-?([\\d]+\\.?[\\d]*|[\\d]*\\.?[\\d]+|\\.)");
|
|
||||||
|
|
||||||
private static final List<EntryInfo> entries = new ArrayList<>();
|
|
||||||
|
|
||||||
protected static class EntryInfo {
|
|
||||||
Field field;
|
|
||||||
Object widget;
|
|
||||||
int width;
|
|
||||||
Map.Entry<TextFieldWidget,Text> error;
|
|
||||||
Object defaultValue;
|
|
||||||
Object value;
|
|
||||||
String tempValue;
|
|
||||||
boolean inLimits = true;
|
|
||||||
String id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Map<String,Class<?>> configClass = new HashMap<>();
|
|
||||||
private static Path path;
|
|
||||||
|
|
||||||
private static final Gson gson = new GsonBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT).excludeFieldsWithModifiers(Modifier.PRIVATE).addSerializationExclusionStrategy(new HiddenAnnotationExclusionStrategy()).setPrettyPrinting().create();
|
|
||||||
|
|
||||||
public static void init(String modid, Class<?> config) {
|
|
||||||
path = FabricLoader.getInstance().getConfigDir().resolve(modid + ".json");
|
|
||||||
configClass.put(modid, config);
|
|
||||||
|
|
||||||
for (Field field : config.getFields()) {
|
|
||||||
EntryInfo info = new EntryInfo();
|
|
||||||
if (field.isAnnotationPresent(Entry.class) || field.isAnnotationPresent(Comment.class))
|
|
||||||
try {
|
|
||||||
initClient(modid, field, info);
|
|
||||||
} catch (Exception e) {continue;}
|
|
||||||
if (field.isAnnotationPresent(Entry.class))
|
|
||||||
try {
|
|
||||||
info.defaultValue = field.get(null);
|
|
||||||
} catch (IllegalAccessException ignored) {}
|
|
||||||
}
|
|
||||||
try { gson.fromJson(Files.newBufferedReader(path), config); }
|
|
||||||
catch (Exception e) { write(modid); }
|
|
||||||
|
|
||||||
for (EntryInfo info : entries) {
|
|
||||||
if (info.field.isAnnotationPresent(Entry.class))
|
|
||||||
try {
|
|
||||||
info.value = info.field.get(null);
|
|
||||||
info.tempValue = info.value.toString();
|
|
||||||
} catch (IllegalAccessException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public static void initClient(String modid, Field field, EntryInfo info) {
|
|
||||||
Class<?> type = field.getType();
|
|
||||||
Entry e = field.getAnnotation(Entry.class);
|
|
||||||
info.width = e != null ? e.width() : 0;
|
|
||||||
info.field = field;
|
|
||||||
info.id = modid;
|
|
||||||
|
|
||||||
if (e != null)
|
|
||||||
if (type == int.class) textField(info, Integer::parseInt, INTEGER_ONLY, e.min(), e.max(), true);
|
|
||||||
else if (type == double.class) textField(info, Double::parseDouble, DECIMAL_ONLY, e.min(), e.max(),false);
|
|
||||||
else if (type == String.class) textField(info, String::length, null, Math.min(e.min(),0), Math.max(e.max(),1),true);
|
|
||||||
else if (type == boolean.class) {
|
|
||||||
Function<Object,Text> func = value -> new LiteralText((Boolean) value ? "True" : "False").formatted((Boolean) value ? Formatting.GREEN : Formatting.RED);
|
|
||||||
info.widget = new AbstractMap.SimpleEntry<ButtonWidget.PressAction, Function<Object, Text>>(button -> {
|
|
||||||
info.value = !(Boolean) info.value;
|
|
||||||
button.setMessage(func.apply(info.value));
|
|
||||||
}, func);
|
|
||||||
} else if (type.isEnum()) {
|
|
||||||
List<?> values = Arrays.asList(field.getType().getEnumConstants());
|
|
||||||
Function<Object,Text> func = value -> new TranslatableText(modid + ".midnightconfig." + "enum." + type.getSimpleName() + "." + info.value.toString());
|
|
||||||
info.widget = new AbstractMap.SimpleEntry<ButtonWidget.PressAction, Function<Object,Text>>( button -> {
|
|
||||||
int index = values.indexOf(info.value) + 1;
|
|
||||||
info.value = values.get(index >= values.size()? 0 : index);
|
|
||||||
button.setMessage(func.apply(info.value));
|
|
||||||
}, func);
|
|
||||||
}
|
|
||||||
entries.add(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void textField(EntryInfo info, Function<String,Number> f, Pattern pattern, double min, double max, boolean cast) {
|
|
||||||
boolean isNumber = pattern != null;
|
|
||||||
info.widget = (BiFunction<TextFieldWidget, ButtonWidget, Predicate<String>>) (t, b) -> s -> {
|
|
||||||
s = s.trim();
|
|
||||||
if (!(s.isEmpty() || !isNumber || pattern.matcher(s).matches())) return false;
|
|
||||||
|
|
||||||
Number value = 0;
|
|
||||||
boolean inLimits = false;
|
|
||||||
System.out.println(((isNumber ^ s.isEmpty())));
|
|
||||||
System.out.println(!s.equals("-") && !s.equals("."));
|
|
||||||
info.error = null;
|
|
||||||
if (!(isNumber && s.isEmpty()) && !s.equals("-") && !s.equals(".")) {
|
|
||||||
value = f.apply(s);
|
|
||||||
inLimits = value.doubleValue() >= min && value.doubleValue() <= max;
|
|
||||||
info.error = inLimits? null : new AbstractMap.SimpleEntry<>(t, new LiteralText(value.doubleValue() < min ?
|
|
||||||
"§cMinimum " + (isNumber? "value" : "length") + (cast? " is " + (int)min : " is " + min) :
|
|
||||||
"§cMaximum " + (isNumber? "value" : "length") + (cast? " is " + (int)max : " is " + max)));
|
|
||||||
}
|
|
||||||
|
|
||||||
info.tempValue = s;
|
|
||||||
t.setEditableColor(inLimits? 0xFFFFFFFF : 0xFFFF7777);
|
|
||||||
info.inLimits = inLimits;
|
|
||||||
b.active = entries.stream().allMatch(e -> e.inLimits);
|
|
||||||
|
|
||||||
if (inLimits)
|
|
||||||
info.value = isNumber? value : s;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void write(String modid) {
|
|
||||||
path = FabricLoader.getInstance().getConfigDir().resolve(modid + ".json");
|
|
||||||
try {
|
|
||||||
if (!Files.exists(path)) Files.createFile(path);
|
|
||||||
Files.write(path, gson.toJson(configClass.get(modid).getDeclaredConstructor().newInstance()).getBytes());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public static Screen getScreen(Screen parent, String modid) {
|
|
||||||
return new TinyConfigScreen(parent, modid);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
private static class TinyConfigScreen extends Screen {
|
|
||||||
|
|
||||||
protected TinyConfigScreen(Screen parent, String modid) {
|
|
||||||
super(new TranslatableText(modid + ".midnightconfig." + "title"));
|
|
||||||
this.parent = parent;
|
|
||||||
this.modid = modid;
|
|
||||||
this.translationPrefix = modid + ".midnightconfig.";
|
|
||||||
}
|
|
||||||
private final String translationPrefix;
|
|
||||||
private final Screen parent;
|
|
||||||
private final String modid;
|
|
||||||
private MidnightConfigListWidget list;
|
|
||||||
|
|
||||||
// Real Time config update //
|
|
||||||
@Override
|
|
||||||
public void tick() {
|
|
||||||
for (EntryInfo info : entries)
|
|
||||||
try { info.field.set(null, info.value); }
|
|
||||||
catch (IllegalAccessException ignored) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void init() {
|
|
||||||
super.init();
|
|
||||||
|
|
||||||
this.addDrawableChild(new ButtonWidget(this.width / 2 - 154, this.height - 28, 150, 20, ScreenTexts.CANCEL, button -> {
|
|
||||||
try { gson.fromJson(Files.newBufferedReader(path), configClass.get(modid)); }
|
|
||||||
catch (Exception e) { write(modid); }
|
|
||||||
|
|
||||||
for (EntryInfo info : entries) {
|
|
||||||
if (info.field.isAnnotationPresent(Entry.class)) {
|
|
||||||
try {
|
|
||||||
info.value = info.field.get(null);
|
|
||||||
info.tempValue = info.value.toString();
|
|
||||||
} catch (IllegalAccessException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Objects.requireNonNull(client).openScreen(parent);
|
|
||||||
}));
|
|
||||||
|
|
||||||
ButtonWidget done = this.addDrawableChild(new ButtonWidget(this.width / 2 + 4, this.height - 28, 150, 20, ScreenTexts.DONE, (button) -> {
|
|
||||||
for (EntryInfo info : entries)
|
|
||||||
if (info.id.equals(modid)) {
|
|
||||||
try {
|
|
||||||
info.field.set(null, info.value);
|
|
||||||
} catch (IllegalAccessException ignored) {}
|
|
||||||
}
|
|
||||||
write(modid);
|
|
||||||
Objects.requireNonNull(client).openScreen(parent);
|
|
||||||
}));
|
|
||||||
|
|
||||||
this.list = new MidnightConfigListWidget(this.client, this.width, this.height, 32, this.height - 32, 25);
|
|
||||||
this.addSelectableChild(this.list);
|
|
||||||
for (EntryInfo info : entries) {
|
|
||||||
if (info.id.equals(modid)) {
|
|
||||||
TranslatableText name = new TranslatableText(translationPrefix + info.field.getName());
|
|
||||||
ButtonWidget resetButton = new ButtonWidget(width - 155, 0, 40, 20, new LiteralText("Reset").formatted(Formatting.RED), (button -> {
|
|
||||||
info.value = info.defaultValue;
|
|
||||||
info.tempValue = info.value.toString();
|
|
||||||
double scrollAmount = list.getScrollAmount();
|
|
||||||
Objects.requireNonNull(client).openScreen(this);
|
|
||||||
list.setScrollAmount(scrollAmount);
|
|
||||||
}));
|
|
||||||
|
|
||||||
if (info.widget instanceof Map.Entry) {
|
|
||||||
Map.Entry<ButtonWidget.PressAction, Function<Object, Text>> widget = (Map.Entry<ButtonWidget.PressAction, Function<Object, Text>>) info.widget;
|
|
||||||
if (info.field.getType().isEnum()) widget.setValue(value -> new TranslatableText(translationPrefix + "enum." + info.field.getType().getSimpleName() + "." + info.value.toString()));
|
|
||||||
this.list.addButton(new ButtonWidget(width - 110, 0, info.width, 20, widget.getValue().apply(info.value), widget.getKey()),resetButton,name);
|
|
||||||
} else if (info.widget != null) {
|
|
||||||
TextFieldWidget widget = new TextFieldWidget(textRenderer, width - 110, 0, info.width, 20, null);
|
|
||||||
|
|
||||||
widget.setText(info.tempValue);
|
|
||||||
Predicate<String> processor = ((BiFunction<TextFieldWidget, ButtonWidget, Predicate<String>>) info.widget).apply(widget, done);
|
|
||||||
widget.setTextPredicate(processor);
|
|
||||||
this.list.addButton(widget, resetButton, name);
|
|
||||||
} else {
|
|
||||||
ButtonWidget dummy = new ButtonWidget(-10, 0, 0, 0, Text.of(""), null);
|
|
||||||
this.list.addButton(dummy,dummy,name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
|
||||||
this.renderBackground(matrices);
|
|
||||||
this.list.render(matrices, mouseX, mouseY, delta);
|
|
||||||
|
|
||||||
int stringWidth = (int) (title.getString().length() * 2.75f);
|
|
||||||
if (useTooltipForTitle) renderTooltip(matrices, title, width/2 - stringWidth, 27);
|
|
||||||
else drawCenteredText(matrices, textRenderer, title, width / 2, 15, 0xFFFFFF);
|
|
||||||
|
|
||||||
for (EntryInfo info : entries) {
|
|
||||||
if (info.id.equals(modid)) {
|
|
||||||
if (list.getHoveredButton(mouseX,mouseY).isPresent()) {
|
|
||||||
ClickableWidget buttonWidget = list.getHoveredButton(mouseX,mouseY).get();
|
|
||||||
Text text = ButtonEntry.buttonsWithText.get(buttonWidget);
|
|
||||||
TranslatableText name = new TranslatableText(this.translationPrefix + info.field.getName());
|
|
||||||
String key = translationPrefix + info.field.getName() + ".tooltip";
|
|
||||||
|
|
||||||
if (info.error != null && text.equals(name)) renderTooltip(matrices, info.error.getValue(), mouseX, mouseY);
|
|
||||||
else if (I18n.hasTranslation(key) && text.equals(name)) {
|
|
||||||
List<Text> list = new ArrayList<>();
|
|
||||||
for (String str : I18n.translate(key).split("\n"))
|
|
||||||
list.add(new LiteralText(str));
|
|
||||||
renderTooltip(matrices, list, mouseX, mouseY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
super.render(matrices,mouseX,mouseY,delta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public static class MidnightConfigListWidget extends ElementListWidget<MidnightConfig.ButtonEntry> {
|
|
||||||
TextRenderer textRenderer;
|
|
||||||
|
|
||||||
public MidnightConfigListWidget(MinecraftClient minecraftClient, int i, int j, int k, int l, int m) {
|
|
||||||
super(minecraftClient, i, j, k, l, m);
|
|
||||||
this.centerListVertically = false;
|
|
||||||
textRenderer = minecraftClient.textRenderer;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public int getScrollbarPositionX() { return this.width -7; }
|
|
||||||
|
|
||||||
public void addButton(ClickableWidget button, ClickableWidget resetButton, Text text) {
|
|
||||||
this.addEntry(ButtonEntry.create(button, text, resetButton));
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public int getRowWidth() { return 10000; }
|
|
||||||
public Optional<ClickableWidget> getHoveredButton(double mouseX, double mouseY) {
|
|
||||||
for (ButtonEntry buttonEntry : this.children()) {
|
|
||||||
for (ClickableWidget ClickableWidget : buttonEntry.buttons) {
|
|
||||||
if (ClickableWidget.isMouseOver(mouseX, mouseY)) {
|
|
||||||
return Optional.of(ClickableWidget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static class ButtonEntry extends ElementListWidget.Entry<ButtonEntry> {
|
|
||||||
private static final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
|
|
||||||
private final List<ClickableWidget> buttons = new ArrayList<>();
|
|
||||||
private final List<ClickableWidget> resetButtons = new ArrayList<>();
|
|
||||||
private final List<Text> texts = new ArrayList<>();
|
|
||||||
private final List<ClickableWidget> buttonsWithResetButtons = new ArrayList<>();
|
|
||||||
public static final Map<ClickableWidget, Text> buttonsWithText = new HashMap<>();
|
|
||||||
|
|
||||||
private ButtonEntry(ClickableWidget button, Text text, ClickableWidget resetButton) {
|
|
||||||
buttonsWithText.put(button,text);
|
|
||||||
this.buttons.add(button);
|
|
||||||
this.resetButtons.add(resetButton);
|
|
||||||
this.texts.add(text);
|
|
||||||
this.buttonsWithResetButtons.add(button);
|
|
||||||
this.buttonsWithResetButtons.add(resetButton);
|
|
||||||
}
|
|
||||||
public static ButtonEntry create(ClickableWidget button, Text text, ClickableWidget resetButton) {
|
|
||||||
return new ButtonEntry(button, text, resetButton);
|
|
||||||
}
|
|
||||||
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
|
|
||||||
this.buttons.forEach(button -> {
|
|
||||||
button.y = y;
|
|
||||||
button.render(matrices, mouseX, mouseY, tickDelta);
|
|
||||||
});
|
|
||||||
this.texts.forEach(text -> DrawableHelper.drawTextWithShadow(matrices,textRenderer, text,12,y+5,0xFFFFFF));
|
|
||||||
this.resetButtons.forEach((button) -> {
|
|
||||||
button.y = y;
|
|
||||||
button.render(matrices, mouseX, mouseY, tickDelta);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
public List<? extends Element> children() {
|
|
||||||
return buttonsWithResetButtons;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<? extends Selectable> method_37025() {
|
|
||||||
return buttonsWithResetButtons;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.FIELD)
|
|
||||||
public @interface Entry {
|
|
||||||
int width() default 100;
|
|
||||||
double min() default Double.MIN_NORMAL;
|
|
||||||
double max() default Double.MAX_VALUE;
|
|
||||||
}
|
|
||||||
@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface Comment {}
|
|
||||||
|
|
||||||
public static class HiddenAnnotationExclusionStrategy implements ExclusionStrategy {
|
|
||||||
public boolean shouldSkipClass(Class<?> clazz) { return false; }
|
|
||||||
public boolean shouldSkipField(FieldAttributes fieldAttributes) {
|
|
||||||
return fieldAttributes.getAnnotation(Entry.class) == null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB |
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"cullleaves.midnightconfig.title":"Cull Leaves Config",
|
|
||||||
"cullleaves.midnightconfig.enabled.tooltip":"After changing this setting you have to reload all chunks (F3 + A)",
|
|
||||||
"cullleaves.midnightconfig.enabled":"Enabled"
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"required": true,
|
|
||||||
"package": "eu.midnightdust.cullleaves.mixin",
|
|
||||||
"compatibilityLevel": "JAVA_8",
|
|
||||||
"client": [
|
|
||||||
"MixinLeavesBlock"
|
|
||||||
],
|
|
||||||
"injectors": {
|
|
||||||
"defaultRequire": 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"pack": {
|
|
||||||
"pack_format": 7,
|
|
||||||
"description": "§2Makes leaves look identical to optifine's smart leaves"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 8.3 KiB |
Reference in New Issue
Block a user