Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 1.21.1-multiloader
Browse files Browse the repository at this point in the history
# Conflicts:
#	common/src/main/java/ca/fxco/moreculling/mixin/models/SimpleBakedModel_cacheMixin.java
#	gradle.properties
  • Loading branch information
1foxy2 committed Mar 11, 2025
2 parents d2a5ca0 + 6c88eab commit c93f109
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package ca.fxco.moreculling.api.block;

/**
* implement this if your block should cull like leaves but doesn't extend leaves block
*/
public interface LeavesCulling {
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public static Screen createConfigScreen(Screen parent) {
if (modId.equals("minecraft")) {
continue;
}
if (!Services.PLATFORM.isModLoaded(modId)) {
continue;
}
DynamicBooleanListEntry aMod = new DynamicBooleanBuilder(Services.PLATFORM.getModName(modId))
.setValue(entry.getBooleanValue())
.setDefaultValue(MoreCulling.CONFIG.useOnModdedBlocksByDefault)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ca.fxco.moreculling.mixin.blocks;

import ca.fxco.moreculling.MoreCulling;
import ca.fxco.moreculling.api.block.LeavesCulling;
import ca.fxco.moreculling.api.block.MoreBlockCulling;
import ca.fxco.moreculling.config.option.LeavesCullingMode;
import ca.fxco.moreculling.utils.CullingUtils;
Expand All @@ -22,7 +23,7 @@
import static ca.fxco.moreculling.config.option.LeavesCullingMode.VERTICAL;

@Mixin(value = LeavesBlock.class, priority = 1220)
public class LeavesBlock_typesMixin extends Block implements MoreBlockCulling {
public class LeavesBlock_typesMixin extends Block implements MoreBlockCulling, LeavesCulling {

@Shadow
@Final
Expand All @@ -36,7 +37,7 @@ public LeavesBlock_typesMixin(Properties settings) {
public boolean skipRendering(BlockState state, BlockState stateFrom, Direction direction) {
if (MoreCulling.CONFIG.leavesCullingMode == FAST || CullingUtils.areLeavesOpaque() ||
(MoreCulling.CONFIG.leavesCullingMode == VERTICAL && direction.getAxis() == Direction.Axis.Y)) {
return stateFrom.getBlock() instanceof LeavesBlock || super.skipRendering(state, stateFrom, direction);
return stateFrom.getBlock() instanceof LeavesCulling || super.skipRendering(state, stateFrom, direction);
}
return super.skipRendering(state, stateFrom, direction);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
package ca.fxco.moreculling.mixin.blocks;

import ca.fxco.moreculling.MoreCulling;
import ca.fxco.moreculling.api.block.LeavesCulling;
import ca.fxco.moreculling.api.block.MoreBlockCulling;
import ca.fxco.moreculling.config.option.LeavesCullingMode;
import ca.fxco.moreculling.utils.CullingUtils;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.MangroveRootsBlock;
import net.minecraft.world.level.block.state.BlockState;
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.CallbackInfoReturnable;

import java.util.Optional;

@Mixin(value = MangroveRootsBlock.class, priority = 1220)
public class MangroveRootsBlock_typesMixin extends Block implements MoreBlockCulling {
public class MangroveRootsBlock_typesMixin extends Block implements MoreBlockCulling, LeavesCulling {

public MangroveRootsBlock_typesMixin(Properties settings) {
super(settings);
}

@Override
public boolean skipRendering(BlockState state, BlockState stateFrom, Direction direction) {
@Inject(
method = "skipRendering",
at = @At(value = "HEAD"),
cancellable = true
)
private void moreculling$skipRendering(BlockState thisState, BlockState sideState,
Direction face, CallbackInfoReturnable<Boolean> cir) {
if (!MoreCulling.CONFIG.includeMangroveRoots) {
return super.skipRendering(state, stateFrom, direction);
return;
}
if (MoreCulling.CONFIG.leavesCullingMode == LeavesCullingMode.FAST || CullingUtils.areLeavesOpaque()) {
return stateFrom.getBlock() instanceof LeavesBlock || super.skipRendering(state, stateFrom, direction);
cir.setReturnValue(sideState.getBlock() instanceof LeavesCulling ||
super.skipRendering(thisState, sideState, face));
}
return super.skipRendering(state, stateFrom, direction);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package ca.fxco.moreculling.mixin.compat;

import me.fallenbreath.conditionalmixin.api.annotation.Condition;
import me.fallenbreath.conditionalmixin.api.annotation.Restriction;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SignBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;

@Restriction(require = @Condition("enhancedblockentities"))
@Mixin(SignBlock.class)
public class SignBlock_ebeMixin extends Block {
@Unique
private static final VoxelShape moreculling$cullingShape = Block.box(7.3F, 0.0F, 7.3F, 8.7F, 16.0, 8.7F);

public SignBlock_ebeMixin(Properties p_49795_) {
super(p_49795_);
}

@Override
public VoxelShape getOcclusionShape(BlockState state) {
return moreculling$cullingShape;
}
}
14 changes: 7 additions & 7 deletions common/src/main/java/ca/fxco/moreculling/utils/CullingUtils.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ca.fxco.moreculling.utils;

import ca.fxco.moreculling.MoreCulling;
import ca.fxco.moreculling.api.block.LeavesCulling;
import ca.fxco.moreculling.api.blockstate.MoreStateCulling;
import ca.fxco.moreculling.api.blockstate.StateCullingShapeCache;
import it.unimi.dsi.fastutil.objects.Object2ByteLinkedOpenHashMap;
Expand All @@ -13,7 +14,6 @@
import net.minecraft.world.entity.decoration.ItemFrame;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
Expand Down Expand Up @@ -95,15 +95,15 @@ public static boolean areLeavesOpaque() {

public static Optional<Boolean> shouldDrawFaceCheck(BlockGetter view, BlockState sideState,
BlockPos thisPos, BlockPos sidePos, Direction side) {
if (sideState.getBlock() instanceof LeavesBlock ||
if (sideState.getBlock() instanceof LeavesCulling ||
(sideState.canOcclude() && ((StateCullingShapeCache) sideState)
.moreculling$getFaceCullingShape(side.getOpposite()) == Shapes.block())) {
boolean isSurrounded = true;
for (Direction dir : DirectionUtils.DIRECTIONS) {
if (dir != side) {
BlockPos pos = thisPos.relative(dir);
BlockState state = view.getBlockState(pos);
isSurrounded &= state.getBlock() instanceof LeavesBlock ||
isSurrounded &= state.getBlock() instanceof LeavesCulling ||
(state.canOcclude() && ((StateCullingShapeCache) state)
.moreculling$getFaceCullingShape(dir.getOpposite()) == Shapes.block());
}
Expand All @@ -116,13 +116,13 @@ public static Optional<Boolean> shouldDrawFaceCheck(BlockGetter view, BlockState
public static Optional<Boolean> shouldDrawFaceGap(BlockGetter view, BlockState sideState,
BlockPos sidePos, Direction side) {
Direction oppositeSide = side.getOpposite();
if (sideState.getBlock() instanceof LeavesBlock ||
if (sideState.getBlock() instanceof LeavesCulling ||
(sideState.canOcclude() && ((StateCullingShapeCache) sideState)
.moreculling$getFaceCullingShape(oppositeSide) == Shapes.block())) {
for (int i = 1; i < (5 - MoreCulling.CONFIG.leavesCullingAmount); i++) {
BlockPos pos = sidePos.relative(side, i);
BlockState state = view.getBlockState(pos);
if (state == null || !(state.getBlock() instanceof LeavesBlock ||
if (state == null || !(state.getBlock() instanceof LeavesCulling ||
(state.canOcclude() && ((StateCullingShapeCache) state)
.moreculling$getFaceCullingShape(oppositeSide) == Shapes.block()))) {
return Optional.of(false);
Expand All @@ -134,7 +134,7 @@ public static Optional<Boolean> shouldDrawFaceGap(BlockGetter view, BlockState s

public static Optional<Boolean> shouldDrawFaceDepth(BlockGetter view, BlockState sideState,
BlockPos sidePos, Direction side) {
if (sideState.getBlock() instanceof LeavesBlock ||
if (sideState.getBlock() instanceof LeavesCulling ||
(sideState.canOcclude() && ((StateCullingShapeCache) sideState)
.moreculling$getFaceCullingShape(side.getOpposite()) == Shapes.block())) {
for (int i = 1; i < MoreCulling.CONFIG.leavesCullingAmount + 1; i++) {
Expand All @@ -150,7 +150,7 @@ public static Optional<Boolean> shouldDrawFaceDepth(BlockGetter view, BlockState

public static Optional<Boolean> shouldDrawFaceRandom(BlockGetter view, BlockState sideState,
BlockPos sidePos, Direction side) {
if (sideState.getBlock() instanceof LeavesBlock ||
if (sideState.getBlock() instanceof LeavesCulling ||
(sideState.canOcclude() && ((StateCullingShapeCache) sideState)
.moreculling$getFaceCullingShape(side.getOpposite()) == Shapes.block())) {
if (RANDOM.nextIntBetweenInclusive(1, MoreCulling.CONFIG.leavesCullingAmount + 1) == 1) {
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/moreculling.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"compat.BambooStalkBlock_clientTweaksMixin",
"compat.BlockOcclusionCache_sodiumMixin",
"compat.ItemRenderer_sodiumMixin",
"compat.SignBlock_ebeMixin",
"entities.ItemFrameRenderer_cullMixin",
"gui.SodiumOptionsGUIMixin",
"models.BakedModel_extendsMixin",
Expand Down
1 change: 1 addition & 0 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies {
//modImplementation "maven.modrinth:balm:${project.clienttweaks_version}+fabric-${project.minecraft_version}"
// ^ uncomment to test with clienttweaks

//modImplementation("maven.modrinth:ebe:0.11.3+1.21.4")
modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
Expand Down

0 comments on commit c93f109

Please sign in to comment.