xray works
This commit is contained in:
parent
57f90824a2
commit
e7542418f3
|
@ -1,6 +1,7 @@
|
||||||
package de.cscherr.mcpht;
|
package de.cscherr.mcpht;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.fluid.Fluid;
|
import net.minecraft.fluid.Fluid;
|
||||||
|
|
||||||
|
@ -9,7 +10,7 @@ import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class XRay {
|
public class XRay {
|
||||||
public boolean enable = false;
|
public boolean enable = true;
|
||||||
public ArrayList<Block> whitelistBlocks;
|
public ArrayList<Block> whitelistBlocks;
|
||||||
public ArrayList<Fluid> whitelistFluids;
|
public ArrayList<Fluid> whitelistFluids;
|
||||||
|
|
||||||
|
@ -25,6 +26,7 @@ public class XRay {
|
||||||
Blocks.DIAMOND_ORE,
|
Blocks.DIAMOND_ORE,
|
||||||
Blocks.EMERALD_ORE,
|
Blocks.EMERALD_ORE,
|
||||||
Blocks.REDSTONE_ORE,
|
Blocks.REDSTONE_ORE,
|
||||||
|
Blocks.ANCIENT_DEBRIS,
|
||||||
|
|
||||||
// Deepslate Ores
|
// Deepslate Ores
|
||||||
Blocks.DEEPSLATE_COAL_ORE,
|
Blocks.DEEPSLATE_COAL_ORE,
|
||||||
|
@ -58,6 +60,7 @@ public class XRay {
|
||||||
|
|
||||||
// Danger
|
// Danger
|
||||||
Blocks.TNT,
|
Blocks.TNT,
|
||||||
|
Blocks.SPAWNER,
|
||||||
|
|
||||||
// Shulker Boxes
|
// Shulker Boxes
|
||||||
// FIXME: Add the ones I forgot
|
// 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;
|
package de.cscherr.mcpht.mixin.client;
|
||||||
|
|
||||||
import de.cscherr.mcpht.MCPHTClient;
|
import de.cscherr.mcpht.MCPHTClient;
|
||||||
|
import de.cscherr.mcpht.XRay;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
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.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
@Mixin(value = Block.class)
|
@Mixin(Block.class)
|
||||||
public abstract class BlockMixin {
|
public abstract class BlockMixin {
|
||||||
@Inject(at = @At("RETURN"), method = "shouldDrawSide(" + "Lnet/minecraft/block/BlockState;" + // state
|
@Inject(method = "shouldDrawSide", at = @At("RETURN"), cancellable = true)
|
||||||
"Lnet/minecraft/world/BlockView;" + // reader
|
private static void shouldDrawSide(BlockState state,
|
||||||
"Lnet/minecraft/util/math/BlockPos;" + // pos
|
BlockView world,
|
||||||
"Lnet/minecraft/util/math/Direction;" + // face
|
BlockPos pos,
|
||||||
"Lnet/minecraft/util/math/BlockPos;" + // blockPos
|
Direction side,
|
||||||
")Z", // ci
|
BlockPos otherPos,
|
||||||
cancellable = true)
|
CallbackInfoReturnable<Boolean> cir
|
||||||
private static void shouldDrawSide(BlockState state, BlockView reader, BlockPos pos, Direction face,
|
) {
|
||||||
BlockPos blockPos, CallbackInfoReturnable<Boolean> ci) {
|
if (MCPHTClient.XRAY.enable && MCPHTClient.CONFIG.xRay.enable) {
|
||||||
if (MCPHTClient.CONFIG.xRay.enable) {
|
cir.setReturnValue(MCPHTClient.XRAY.showRenderBlock(state));
|
||||||
if (MCPHTClient.XRAY.whitelistBlocks.contains(state.getBlock())) {
|
|
||||||
ci.setReturnValue(true);
|
|
||||||
} else {
|
|
||||||
ci.setReturnValue(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue