xray works
This commit is contained in:
parent
57f90824a2
commit
e7542418f3
|
@ -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<Block> whitelistBlocks;
|
||||
public ArrayList<Fluid> 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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Boolean> 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<Boolean> cir
|
||||
) {
|
||||
if (MCPHTClient.XRAY.enable && MCPHTClient.CONFIG.xRay.enable) {
|
||||
cir.setReturnValue(MCPHTClient.XRAY.showRenderBlock(state));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue