Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.Share;
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.decoration.bracket.BracketBlock;
import net.minecraft.core.BlockPos;
Expand All @@ -29,6 +31,7 @@ public class BlockMixin {
)
private static boolean canCopycatOcclude(BlockState instance,
Operation<Boolean> original,
@Share("copycat$blockState") LocalRef<BlockState> stateRef,
@Local(argsOnly = true) BlockGetter level,
@Local(argsOnly = true, ordinal = 1) BlockPos pos) {
if (AllBlocks.COPYCAT_BASE.has(instance)) {
Expand All @@ -38,7 +41,11 @@ private static boolean canCopycatOcclude(BlockState instance,
return false;
}
if (instance.getBlock() instanceof ICopycatBlock copycatBlock) {
return copycatBlock.canOcclude(level, instance, pos);
if (copycatBlock.canOcclude(level, instance, pos)) {
stateRef.set(instance);
return true;
}
return false;
}
return original.call(instance);
}
Expand All @@ -48,9 +55,10 @@ private static boolean canCopycatOcclude(BlockState instance,
at = @At(value = "NEW", target = "net/minecraft/world/level/block/Block$BlockStatePairKey"),
cancellable = true
)
private static void calculateOcclusionShape(BlockState state, BlockGetter level, BlockPos offset, Direction face, BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
BlockState blockState = level.getBlockState(pos);
if (blockState.getBlock() instanceof ICopycatBlock copycatBlock) {
private static void calculateOcclusionShape(BlockState state, BlockGetter level, BlockPos offset, Direction face, BlockPos pos,
CallbackInfoReturnable<Boolean> cir, @Share("copycat$blockState") LocalRef<BlockState> stateRef) {
BlockState blockState = stateRef.get();
if (blockState != null && blockState.getBlock() instanceof ICopycatBlock copycatBlock) {
Optional<Boolean> result = copycatBlock.shapeCanOccludeNeighbor(level, pos, blockState, offset, face.getOpposite()).map(b -> !b);
result.ifPresent(cir::setReturnValue);
}
Expand Down