diff --git a/build.gradle b/build.gradle index 99490be..c0e4cd7 100644 --- a/build.gradle +++ b/build.gradle @@ -24,6 +24,18 @@ dependencies { modCompile "net.fabricmc:fabric-loader:${project.loader_version}" modCompile "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + + modImplementation ("me.sargunvohra.mcmods:autoconfig1u:${project.auto_config_version}"){ + exclude module: "fabric-api" + } + modImplementation ("me.shedaniel.cloth:config-2:${project.cloth_config_version}"){ + exclude module: "fabric-api" + } + modImplementation ("io.github.prospector:modmenu:${project.mod_menu_version}"){ + exclude module: "fabric-api" + } + include "me.sargunvohra.mcmods:autoconfig1u:${project.auto_config_version}" + include "me.shedaniel.cloth:config-2:${project.cloth_config_version}" } processResources { diff --git a/gradle.properties b/gradle.properties index 9beffcd..0d48300 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,10 +8,14 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.10.8 # Mod Properties - mod_version = 1.0.0 + mod_version = 2.0.0 maven_group = eu.midnightdust archives_base_name = cullleaves # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.26.1+1.16 \ No newline at end of file + fabric_version=0.26.1+1.16 + + auto_config_version = 3.3.1 + cloth_config_version = 4.8.3 + mod_menu_version = 1.14.6+build.31 \ No newline at end of file diff --git a/src/main/java/eu/midnightdust/cullleaves/CullLeavesClient.java b/src/main/java/eu/midnightdust/cullleaves/CullLeavesClient.java new file mode 100644 index 0000000..6fc7979 --- /dev/null +++ b/src/main/java/eu/midnightdust/cullleaves/CullLeavesClient.java @@ -0,0 +1,22 @@ +package eu.midnightdust.cullleaves; + +import eu.midnightdust.cullleaves.config.CullLeavesConfig; +import me.sargunvohra.mcmods.autoconfig1u.AutoConfig; +import me.sargunvohra.mcmods.autoconfig1u.serializer.JanksonConfigSerializer; +import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.fabric.api.resource.ResourceManagerHelper; +import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.util.Identifier; + +public class CullLeavesClient implements ClientModInitializer { + public static CullLeavesConfig CL_CONFIG; + + public void onInitializeClient() { + AutoConfig.register(CullLeavesConfig.class, JanksonConfigSerializer::new); + CL_CONFIG = AutoConfig.getConfigHolder(CullLeavesConfig.class).getConfig(); + + FabricLoader.getInstance().getModContainer("cullleaves").ifPresent(modContainer -> { + ResourceManagerHelper.registerBuiltinResourcePack(new Identifier("cullleaves:smartleaves"), "resourcepacks/smartleaves", modContainer, true); + }); + } +} diff --git a/src/main/java/eu/midnightdust/cullleaves/config/CullLeavesConfig.java b/src/main/java/eu/midnightdust/cullleaves/config/CullLeavesConfig.java new file mode 100644 index 0000000..a0db0d4 --- /dev/null +++ b/src/main/java/eu/midnightdust/cullleaves/config/CullLeavesConfig.java @@ -0,0 +1,14 @@ +package eu.midnightdust.cullleaves.config; + +import me.sargunvohra.mcmods.autoconfig1u.ConfigData; +import me.sargunvohra.mcmods.autoconfig1u.annotation.Config; +import me.sargunvohra.mcmods.autoconfig1u.annotation.ConfigEntry; +import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.Comment; +import net.minecraft.client.render.entity.PlayerModelPart; + +@Config(name = "cullleaves") +public class CullLeavesConfig implements ConfigData { + + @ConfigEntry.Gui.PrefixText // Enable/Disable the mod. Requires Chunk Reload (F3 + A). + public boolean enabled = true; +} diff --git a/src/main/java/eu/midnightdust/cullleaves/config/ModMenuIntegration.java b/src/main/java/eu/midnightdust/cullleaves/config/ModMenuIntegration.java new file mode 100644 index 0000000..5742114 --- /dev/null +++ b/src/main/java/eu/midnightdust/cullleaves/config/ModMenuIntegration.java @@ -0,0 +1,16 @@ +package eu.midnightdust.cullleaves.config; + +import io.github.prospector.modmenu.api.ConfigScreenFactory; +import io.github.prospector.modmenu.api.ModMenuApi; +import me.sargunvohra.mcmods.autoconfig1u.AutoConfig; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +@Environment(EnvType.CLIENT) +public class ModMenuIntegration implements ModMenuApi { + + @Override + public ConfigScreenFactory getModConfigScreenFactory() { + return parent -> AutoConfig.getConfigScreen(CullLeavesConfig.class, parent).get(); + } +} \ No newline at end of file diff --git a/src/main/java/eu/midnightdust/cullleaves/mixin/MixinLeavesBlock.java b/src/main/java/eu/midnightdust/cullleaves/mixin/MixinLeavesBlock.java index e965d42..fd53cb8 100644 --- a/src/main/java/eu/midnightdust/cullleaves/mixin/MixinLeavesBlock.java +++ b/src/main/java/eu/midnightdust/cullleaves/mixin/MixinLeavesBlock.java @@ -1,5 +1,6 @@ package eu.midnightdust.cullleaves.mixin; +import eu.midnightdust.cullleaves.CullLeavesClient; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.block.Block; @@ -19,6 +20,9 @@ public MixinLeavesBlock(Settings settings) { @Override @SuppressWarnings("deprecation") public boolean isSideInvisible(BlockState state, BlockState neighborState, Direction offset) { - return neighborState.getBlock() instanceof LeavesBlock; + if (CullLeavesClient.CL_CONFIG.enabled) { + return neighborState.getBlock() instanceof LeavesBlock; + } + else return false; } } \ No newline at end of file diff --git a/src/main/resources/assets/cullleaves/lang/en_us.json b/src/main/resources/assets/cullleaves/lang/en_us.json new file mode 100644 index 0000000..eac7e9b --- /dev/null +++ b/src/main/resources/assets/cullleaves/lang/en_us.json @@ -0,0 +1,5 @@ +{ + "text.autoconfig.cullleaves.title":"Cull Leaves Config", + "text.autoconfig.cullleaves.option.enabled.@PrefixText":"After changing this setting you have to reload all chunks (F3 + A)", + "text.autoconfig.cullleaves.option.enabled":"Enabled" +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index fe47b99..625b6d1 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -19,6 +19,19 @@ "icon": "assets/cullleaves/icon.png", "environment": "client", + "entrypoints": { + "client": [ + "eu.midnightdust.cullleaves.CullLeavesClient" + ], + "modmenu": [ + "eu.midnightdust.cullleaves.config.ModMenuIntegration" + ] + }, + + "depends": { + "fabric-resource-loader-v0": "*", + "minecraft": ">=1.16" + }, "mixins": [ "cullleaves.mixins.json" diff --git a/src/main/resources/resourcepacks/smartleaves/assets/minecraft/models/block/leaves.json b/src/main/resources/resourcepacks/smartleaves/assets/minecraft/models/block/leaves.json new file mode 100644 index 0000000..aa7c3f9 --- /dev/null +++ b/src/main/resources/resourcepacks/smartleaves/assets/minecraft/models/block/leaves.json @@ -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", "tintindex": 0}, + "east": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "east", "tintindex": 0}, + "south": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "south", "tintindex": 0}, + "west": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "west", "tintindex": 0}, + "up": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "up", "tintindex": 0}, + "down": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "down", "tintindex": 0} + } + }, + { + "name": "bottom", + "from": [0, 0, 0], + "to": [16, 0, 16], + "faces": { + "up": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "down", "tintindex": 0} + } + }, + { + "name": "west", + "from": [0, 0, 0], + "to": [0, 16, 16], + "faces": { + "east": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "west", "tintindex": 0} + } + }, + { + "name": "north", + "from": [0, 0, 0], + "to": [16, 16, 0], + "faces": { + "south": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "north", "tintindex": 0} + } + }, + { + "name": "east", + "from": [16, 0, 0], + "to": [16, 16, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [23, 8, 8]}, + "faces": { + "west": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "east", "tintindex": 0} + } + }, + { + "name": "south", + "from": [0, 0, 16], + "to": [16, 16, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 23]}, + "faces": { + "north": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "south", "tintindex": 0} + } + }, + { + "name": "up", + "from": [0, 16, 0], + "to": [16, 16, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 23, 8]}, + "faces": { + "down": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "up", "tintindex": 0} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/resourcepacks/smartleaves/license.txt b/src/main/resources/resourcepacks/smartleaves/license.txt new file mode 100644 index 0000000..4f67261 --- /dev/null +++ b/src/main/resources/resourcepacks/smartleaves/license.txt @@ -0,0 +1,10 @@ +The MIT License +Copyright © 2020 Motschen + +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, +and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/src/main/resources/resourcepacks/smartleaves/pack.mcmeta b/src/main/resources/resourcepacks/smartleaves/pack.mcmeta new file mode 100644 index 0000000..9ebbcf5 --- /dev/null +++ b/src/main/resources/resourcepacks/smartleaves/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "pack_format": 6, + "description": "§2Makes the leaves look identical to the optifine smart leaves effect" + } +} diff --git a/src/main/resources/resourcepacks/smartleaves/pack.png b/src/main/resources/resourcepacks/smartleaves/pack.png new file mode 100644 index 0000000..17b7e2a Binary files /dev/null and b/src/main/resources/resourcepacks/smartleaves/pack.png differ