Skip to content

Commit de8da14

Browse files
committed
1.0.1
fix fabric loader crash by directly invoking mixin extras bootstrap before mixin is initialised (closes #9) refactor SodiumOptionStorage add more screenshots to README.md make sodium options a bit clearer to people who don't know what Cull Less Leaves is (modpacks) javadoc for some sodium compat mixins optimize imports
1 parent da73396 commit de8da14

13 files changed

Lines changed: 59 additions & 26 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,20 @@ Cull Less Leaves is an improved version of [Cull Leaves](https://www.curseforge.
44
Instead of leaving just the outer layer of leaves, Cull Less Leaves also renders a certain amount
55
of layers defined in the config.
66

7+
**[Works best with Sodium](https://modrinth.com/mod/sodium)**
8+
79
Less Culling
810

911
![less culling](https://i.imgur.com/GjYFjJV.png)
1012

1113
Fast Culling (identical to original cull leaves mod)
1214

1315
![fast culling](https://i.imgur.com/5SPxxYy.png)
16+
17+
Sodium Configuration
18+
19+
![sodium config](https://i.imgur.com/JE0uJ99.png)
20+
21+
Mod Menu Configuration
22+
23+
![mod menu config](https://i.imgur.com/RYNVj3b.png)

build.gradle.kts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import com.modrinth.minotaur.dependencies.Dependency
1+
import com.modrinth.minotaur.dependencies.ModDependency
22

33
plugins {
44
java
@@ -14,7 +14,7 @@ plugins {
1414
}
1515

1616
group = "dev.isxander"
17-
version = "1.0.0"
17+
version = "1.0.1"
1818

1919
repositories {
2020
mavenCentral()
@@ -101,10 +101,10 @@ if (modrinthId.isNotEmpty()) {
101101
loaders.set(listOf("fabric", "quilt"))
102102
changelog.set(changelogText)
103103
syncBodyFrom.set(file("README.md").readText())
104-
// dependencies.set(listOf(
105-
// Dependency("cloth-config", "required"),
106-
// Dependency("modmenu", "optional")
107-
// ))
104+
dependencies.set(listOf(
105+
ModDependency("cloth-config", "required"),
106+
ModDependency("modmenu", "optional")
107+
))
108108
}
109109
}
110110

changelogs/1.0.1.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- fix fabric loader crash when using other mods with mixin extras
2+
- make sodium options a bit clearer to people who don't know what Cull Less Leaves is (modpacks)
3+
- estonian translation - [Madis0](https://github.com/isXander/CullLessLeaves/pull/6)
4+
- russian translation - [RozeFound](https://github.com/isXander/CullLessLeaves/pull/5)

src/main/java/dev/isxander/culllessleaves/CullLessLeaves.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
package dev.isxander.culllessleaves;
22

3+
import com.llamalad7.mixinextras.MixinExtrasBootstrap;
34
import dev.isxander.culllessleaves.compat.Compat;
45
import dev.isxander.culllessleaves.config.CullLessLeavesConfig;
56
import me.shedaniel.autoconfig.AutoConfig;
67
import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer;
78
import net.fabricmc.api.ClientModInitializer;
9+
import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint;
810
import net.minecraft.block.LeavesBlock;
911
import net.minecraft.util.math.BlockPos;
1012
import net.minecraft.util.math.Direction;
1113
import net.minecraft.world.BlockView;
1214

13-
public class CullLessLeaves implements ClientModInitializer {
15+
public class CullLessLeaves implements ClientModInitializer, PreLaunchEntrypoint {
1416
@Override
1517
public void onInitializeClient() {
1618
AutoConfig.register(CullLessLeavesConfig.class, Toml4jConfigSerializer::new);
1719
}
1820

21+
@Override
22+
public void onPreLaunch() {
23+
MixinExtrasBootstrap.init();
24+
}
25+
1926
public static CullLessLeavesConfig getConfig() {
2027
return AutoConfig.getConfigHolder(CullLessLeavesConfig.class).getConfig();
2128
}

src/main/java/dev/isxander/culllessleaves/compat/SodiumCompat.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@
88
import net.minecraft.client.MinecraftClient;
99

1010
public class SodiumCompat {
11-
public static boolean isFancyLeaves() {
12-
return SodiumClientMod.options().quality.leavesQuality.isFancy(MinecraftClient.getInstance().options.graphicsMode);
13-
}
14-
15-
public static class CullLeavesOptionStorage implements OptionStorage<CullLessLeavesConfig> {
16-
public static final CullLeavesOptionStorage INSTANCE = new CullLeavesOptionStorage();
17-
11+
private static final OptionStorage<CullLessLeavesConfig> OPTION_STORAGE = new OptionStorage<CullLessLeavesConfig>() {
1812
@Override
1913
public CullLessLeavesConfig getData() {
2014
return CullLessLeaves.getConfig();
@@ -24,5 +18,13 @@ public CullLessLeavesConfig getData() {
2418
public void save() {
2519
AutoConfig.getConfigHolder(CullLessLeavesConfig.class).save();
2620
}
21+
};
22+
23+
public static boolean isFancyLeaves() {
24+
return SodiumClientMod.options().quality.leavesQuality.isFancy(MinecraftClient.getInstance().options.graphicsMode);
25+
}
26+
27+
public static OptionStorage<CullLessLeavesConfig> getOptionStorage() {
28+
return OPTION_STORAGE;
2729
}
2830
}

src/main/java/dev/isxander/culllessleaves/mixins/BlockMixin.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
44
import dev.isxander.culllessleaves.CullLessLeaves;
5-
import dev.isxander.culllessleaves.compat.Compat;
65
import net.minecraft.block.*;
76
import net.minecraft.util.math.BlockPos;
87
import net.minecraft.util.math.Direction;

src/main/java/dev/isxander/culllessleaves/mixins/sodiumcompat/BlockOcclusionCacheMixin.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
@Pseudo
1616
@Mixin(BlockOcclusionCache.class)
1717
public class BlockOcclusionCacheMixin {
18+
/**
19+
* Sodium caches if the sides are visible which reimplements
20+
* vanilla code that this mod uses.
21+
*/
1822
@ModifyExpressionValue(method = "shouldDrawSide", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isSideInvisible(Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/Direction;)Z"))
1923
private boolean shouldCullSide(boolean isSideInvisible, BlockState state, BlockView view, BlockPos pos, Direction facing) {
2024
if (!(state.getBlock() instanceof LeavesBlock) || !CullLessLeaves.getConfig().enabled)

src/main/java/dev/isxander/culllessleaves/mixins/sodiumcompat/LeavesBlockMixin.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ public LeavesBlockMixin(Settings settings) {
1212
super(settings);
1313
}
1414

15+
/**
16+
* sodium implements custom logic for
17+
* culling leaves when set to fast
18+
*
19+
* this mixin simply reverts to vanilla behaviour
20+
* @see me.jellysquid.mods.sodium.mixin.features.render_layer.leaves.MixinLeavesBlock
21+
*/
1522
@Override
1623
@SuppressWarnings("deprecation")
1724
public boolean isSideInvisible(BlockState state, BlockState stateFrom, Direction direction) {

src/main/java/dev/isxander/culllessleaves/mixins/sodiumcompat/SodiumGameOptionPagesMixin.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
package dev.isxander.culllessleaves.mixins.sodiumcompat;
22

3-
import dev.isxander.culllessleaves.CullLessLeaves;
43
import dev.isxander.culllessleaves.compat.SodiumCompat;
54
import me.jellysquid.mods.sodium.client.gui.SodiumGameOptionPages;
65
import me.jellysquid.mods.sodium.client.gui.options.*;
76
import me.jellysquid.mods.sodium.client.gui.options.control.ControlValueFormatter;
87
import me.jellysquid.mods.sodium.client.gui.options.control.SliderControl;
98
import me.jellysquid.mods.sodium.client.gui.options.control.TickBoxControl;
10-
import me.jellysquid.mods.sodium.client.gui.options.storage.SodiumOptionsStorage;
119
import net.minecraft.text.TranslatableText;
12-
import org.spongepowered.asm.mixin.Final;
1310
import org.spongepowered.asm.mixin.Mixin;
1411
import org.spongepowered.asm.mixin.Pseudo;
1512
import org.spongepowered.asm.mixin.injection.At;
@@ -23,16 +20,16 @@ public class SodiumGameOptionPagesMixin {
2320
@ModifyVariable(method = "performance", at = @At(value = "INVOKE", target = "Lcom/google/common/collect/ImmutableList;copyOf(Ljava/util/Collection;)Lcom/google/common/collect/ImmutableList;"))
2421
private static List<OptionGroup> addLeavesCulling(List<OptionGroup> groups) {
2522
groups.add(OptionGroup.createBuilder()
26-
.add(OptionImpl.createBuilder(boolean.class, SodiumCompat.CullLeavesOptionStorage.INSTANCE)
27-
.setName(new TranslatableText("text.autoconfig.cull-less-leaves.title"))
28-
.setTooltip(new TranslatableText("text.cull-less-leaves.description"))
23+
.add(OptionImpl.createBuilder(boolean.class, SodiumCompat.getOptionStorage())
24+
.setName(new TranslatableText("text.cull-less-leaves.sodium.option.enabled"))
25+
.setTooltip(new TranslatableText("text.cull-less-leaves.sodium.option.enabled.description"))
2926
.setControl(TickBoxControl::new)
3027
.setBinding((opts, value) -> opts.enabled = value, opts -> opts.enabled)
3128
.setImpact(OptionImpact.MEDIUM)
3229
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
3330
.build()
3431
)
35-
.add(OptionImpl.createBuilder(int.class, SodiumCompat.CullLeavesOptionStorage.INSTANCE)
32+
.add(OptionImpl.createBuilder(int.class, SodiumCompat.getOptionStorage())
3633
.setName(new TranslatableText("text.cull-less-leaves.sodium.option.depth"))
3734
.setTooltip(new TranslatableText("text.autoconfig.cull-less-leaves.option.depth.@Tooltip"))
3835
.setControl(o -> new SliderControl(o, 1, 4, 1, ControlValueFormatter.number()))

src/main/resources/assets/cull-less-leaves/lang/en_us.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"text.autoconfig.cull-less-leaves.option.enabled": "Enabled",
44
"text.autoconfig.cull-less-leaves.option.depth": "Depth",
55
"text.autoconfig.cull-less-leaves.option.depth.@Tooltip": "Amount of layers of leaves before the inside of the leaves is culled.\n1 = Fastest but least good-looking.\n2 = Recommended.\n4 = Slowest but most good-looking.",
6-
"text.cull-less-leaves.description": "Enables Cull Less Leaves mod.",
6+
"text.cull-less-leaves.sodium.option.enabled": "Cull Leaves",
7+
"text.cull-less-leaves.sodium.option.enabled.description": "Enables Cull Less Leaves mod.",
78
"text.cull-less-leaves.sodium.option.depth": "Cull Leaves Depth"
89
}

0 commit comments

Comments
 (0)