mirror of
https://github.com/TeamMidnightDust/CullLeaves.git
synced 2025-12-15 22:15:08 +01:00
CullLeaves 3.0.0 - Forge support & better Sodium compatibility
- Now utilizes the Architectury build system to provide support for Fabric, native Quilt and even Forge (No Architectury API needed!) - Update to MidnightLib 1.0.0 - Better Sodium/Rubidium support: - Fix resourcepacks utilizing leaf culling flickering when using Sodium (Fixes #15) - Integrate Leaf Culling toggle into Sodium options screen
This commit is contained in:
@@ -14,9 +14,10 @@ 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"
|
||||
modCompileOnlyApi "maven.modrinth:sodium:${rootProject.sodium_version}"
|
||||
|
||||
// Remove the next line if you don't want to depend on the API
|
||||
modApi "dev.architectury:architectury:${rootProject.architectury_version}"
|
||||
//modApi "dev.architectury:architectury:${rootProject.architectury_version}"
|
||||
}
|
||||
|
||||
publishing {
|
||||
|
||||
@@ -5,4 +5,6 @@ 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;
|
||||
@Entry // Fixes resourcepacks utilizing leaf culling flickering when using Sodium
|
||||
public static boolean sodiumBlockFaceCullingFix = true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package eu.midnightdust.cullleaves.mixin;
|
||||
|
||||
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
||||
import me.jellysquid.mods.sodium.client.gl.device.RenderDevice;
|
||||
import me.jellysquid.mods.sodium.client.gl.util.ElementRange;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.type.ChunkVertexType;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.*;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
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.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(value = RegionChunkRenderer.class, remap = false)
|
||||
public abstract class MixinRegionChunkRenderer extends ShaderChunkRenderer {
|
||||
@Shadow @Final private boolean isBlockFaceCullingEnabled;
|
||||
@Shadow protected abstract void addDrawCall(ElementRange part, long baseIndexPointer, int baseVertexIndex);
|
||||
@Unique private boolean doFix = false;
|
||||
|
||||
public MixinRegionChunkRenderer(RenderDevice device, ChunkVertexType vertexType) {
|
||||
super(device, vertexType);
|
||||
}
|
||||
|
||||
@Inject(method = "buildDrawBatches", at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/render/chunk/RenderSection;getBounds()Lme/jellysquid/mods/sodium/client/render/chunk/data/ChunkRenderBounds;", ordinal = 0))
|
||||
public void cullleaves$shouldApplyTransparentBlockFaceCullingFix(List<RenderSection> sections, BlockRenderPass pass, ChunkCameraContext camera, CallbackInfoReturnable<Boolean> cir) {
|
||||
doFix = pass.getAlphaCutoff() != 0 && CullLeavesConfig.enabled && CullLeavesConfig.sodiumBlockFaceCullingFix && this.isBlockFaceCullingEnabled;
|
||||
}
|
||||
@Redirect(method = "buildDrawBatches", at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/render/chunk/ChunkGraphicsState;getModelPart(Lme/jellysquid/mods/sodium/client/model/quad/properties/ModelQuadFacing;)Lme/jellysquid/mods/sodium/client/gl/util/ElementRange;", ordinal = 0))
|
||||
public ElementRange cullleaves$fixTransparentBlockFaceCulling(ChunkGraphicsState state, ModelQuadFacing facing) {
|
||||
if (doFix) {
|
||||
long indexOffset = state.getIndexSegment().getOffset();
|
||||
int baseVertex = state.getVertexSegment().getOffset() / this.vertexFormat.getStride();
|
||||
for (ModelQuadFacing direction : ModelQuadFacing.DIRECTIONS) {
|
||||
this.addDrawCall(state.getModelPart(direction), indexOffset, baseVertex);
|
||||
}
|
||||
}
|
||||
return state.getModelPart(ModelQuadFacing.UNASSIGNED);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package eu.midnightdust.cullleaves.mixin;
|
||||
|
||||
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
||||
import me.jellysquid.mods.sodium.client.gui.SodiumGameOptionPages;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionFlag;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionGroup;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionImpact;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionImpl;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.control.TickBoxControl;
|
||||
import me.jellysquid.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("cullleaves");
|
||||
}, opts -> CullLeavesConfig.enabled)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
);
|
||||
|
||||
return groups;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
{
|
||||
"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"
|
||||
"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.sodiumBlockFaceCullingFix.tooltip": "Fixes resourcepacks utilizing leaf culling flickering when using Sodium.\nYou probably want this to be enabled.",
|
||||
"cullleaves.midnightconfig.sodiumBlockFaceCullingFix": "Fix Sodium Block Face Culling on Leaves"
|
||||
}
|
||||
@@ -1,5 +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"
|
||||
"cullleaves.midnightconfig.enabled":"Ativado Cull Leaves"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"cullleaves.midnightconfig.title":"Настройки Cull Leaves",
|
||||
"cullleaves.midnightconfig.enabled.tooltip":"После изменения этого параметра необходимо перезагрузить чанки (F3 + A)",
|
||||
"cullleaves.midnightconfig.enabled":"Включён"
|
||||
"cullleaves.midnightconfig.enabled":"Включён Cull Leaves"
|
||||
}
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
"required": true,
|
||||
"package": "eu.midnightdust.cullleaves.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"minVersion": "0.8",
|
||||
"client": [
|
||||
"MixinLeavesBlock"
|
||||
],
|
||||
"mixins": [
|
||||
"MixinLeavesBlock",
|
||||
"MixinRegionChunkRenderer",
|
||||
"MixinSodiumGameOptionPages"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
||||
@@ -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.01, 0],
|
||||
"to": [16, 0.01, 16],
|
||||
"faces": {
|
||||
"up": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "down", "tintindex": 0}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "west",
|
||||
"from": [0.01, 0, 0],
|
||||
"to": [0.01, 16, 16],
|
||||
"faces": {
|
||||
"east": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "west", "tintindex": 0}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "north",
|
||||
"from": [0, 0, 0.01],
|
||||
"to": [16, 16, 0.01],
|
||||
"faces": {
|
||||
"south": {"uv": [0, 0, 16, 16], "texture": "#all", "cullface": "north", "tintindex": 0}
|
||||
}
|
||||
},
|
||||
{
|
||||
"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", "tintindex": 0}
|
||||
}
|
||||
},
|
||||
{
|
||||
"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", "tintindex": 0}
|
||||
}
|
||||
},
|
||||
{
|
||||
"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", "tintindex": 0}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
10
common/src/main/resources/resourcepacks/smartleaves/license.txt
Executable file
10
common/src/main/resources/resourcepacks/smartleaves/license.txt
Executable file
@@ -0,0 +1,10 @@
|
||||
The MIT License
|
||||
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"),
|
||||
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.
|
||||
6
common/src/main/resources/resourcepacks/smartleaves/pack.mcmeta
Executable file
6
common/src/main/resources/resourcepacks/smartleaves/pack.mcmeta
Executable file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"pack": {
|
||||
"pack_format": 9,
|
||||
"description": "§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 |
Reference in New Issue
Block a user