diff --git a/src/client/java/de/cscherr/mcpht/XRay.java b/src/client/java/de/cscherr/mcpht/XRay.java index 7b4fd60..d193c0b 100644 --- a/src/client/java/de/cscherr/mcpht/XRay.java +++ b/src/client/java/de/cscherr/mcpht/XRay.java @@ -1,6 +1,7 @@ package de.cscherr.mcpht; import net.minecraft.block.Block; +import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.fluid.Fluid; @@ -9,7 +10,7 @@ import java.util.Collection; import java.util.List; public class XRay { - public boolean enable = false; + public boolean enable = true; public ArrayList whitelistBlocks; public ArrayList whitelistFluids; @@ -25,6 +26,7 @@ public class XRay { Blocks.DIAMOND_ORE, Blocks.EMERALD_ORE, Blocks.REDSTONE_ORE, + Blocks.ANCIENT_DEBRIS, // Deepslate Ores Blocks.DEEPSLATE_COAL_ORE, @@ -58,6 +60,7 @@ public class XRay { // Danger Blocks.TNT, + Blocks.SPAWNER, // Shulker Boxes // FIXME: Add the ones I forgot @@ -79,4 +82,7 @@ public class XRay { ) ); } + public boolean showRenderBlock(BlockState state) { + return whitelistBlocks.contains(state.getBlock()); + } } diff --git a/src/client/java/de/cscherr/mcpht/mixin/client/BlockMixin.java b/src/client/java/de/cscherr/mcpht/mixin/client/BlockMixin.java index 5152149..25f886f 100644 --- a/src/client/java/de/cscherr/mcpht/mixin/client/BlockMixin.java +++ b/src/client/java/de/cscherr/mcpht/mixin/client/BlockMixin.java @@ -1,6 +1,8 @@ package de.cscherr.mcpht.mixin.client; import de.cscherr.mcpht.MCPHTClient; +import de.cscherr.mcpht.XRay; +import net.minecraft.util.Identifier; import org.spongepowered.asm.mixin.Mixin; import net.minecraft.block.Block; @@ -12,23 +14,18 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(value = Block.class) +@Mixin(Block.class) public abstract class BlockMixin { - @Inject(at = @At("RETURN"), method = "shouldDrawSide(" + "Lnet/minecraft/block/BlockState;" + // state - "Lnet/minecraft/world/BlockView;" + // reader - "Lnet/minecraft/util/math/BlockPos;" + // pos - "Lnet/minecraft/util/math/Direction;" + // face - "Lnet/minecraft/util/math/BlockPos;" + // blockPos - ")Z", // ci - cancellable = true) - private static void shouldDrawSide(BlockState state, BlockView reader, BlockPos pos, Direction face, - BlockPos blockPos, CallbackInfoReturnable ci) { - if (MCPHTClient.CONFIG.xRay.enable) { - if (MCPHTClient.XRAY.whitelistBlocks.contains(state.getBlock())) { - ci.setReturnValue(true); - } else { - ci.setReturnValue(false); - } + @Inject(method = "shouldDrawSide", at = @At("RETURN"), cancellable = true) + private static void shouldDrawSide(BlockState state, + BlockView world, + BlockPos pos, + Direction side, + BlockPos otherPos, + CallbackInfoReturnable cir + ) { + if (MCPHTClient.XRAY.enable && MCPHTClient.CONFIG.xRay.enable) { + cir.setReturnValue(MCPHTClient.XRAY.showRenderBlock(state)); } } }