i hope this works enough to play with
This commit is contained in:
parent
8b17944b74
commit
a0c41b1540
|
@ -12,7 +12,6 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class MCPHTClient implements ClientModInitializer {
|
public class MCPHTClient implements ClientModInitializer {
|
||||||
public static final String MOD_ID = "mcpht";
|
public static final String MOD_ID = "mcpht";
|
||||||
public static final String VERSION_NUMBER = "0.0.1";
|
|
||||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||||
public static MCPHTConfig CONFIG;
|
public static MCPHTConfig CONFIG;
|
||||||
public static XRay XRAY;
|
public static XRay XRAY;
|
||||||
|
|
|
@ -7,16 +7,14 @@ import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.client.option.KeyBinding;
|
import net.minecraft.client.option.KeyBinding;
|
||||||
import net.minecraft.client.util.InputUtil;
|
import net.minecraft.client.util.InputUtil;
|
||||||
import net.minecraft.fluid.Fluid;
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class XRay {
|
public class XRay {
|
||||||
public boolean enable = true;
|
public boolean enable = true;
|
||||||
public ArrayList<Block> whitelistBlocks = new ArrayList<Block>(
|
public ArrayList<Block> whitelistBlocks = new ArrayList<>(
|
||||||
List.of(
|
List.of(
|
||||||
// Ores
|
// Ores
|
||||||
Blocks.COAL_ORE,
|
Blocks.COAL_ORE,
|
||||||
|
@ -82,7 +80,6 @@ public class XRay {
|
||||||
Blocks.RED_SHULKER_BOX
|
Blocks.RED_SHULKER_BOX
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
public ArrayList<Fluid> whitelistFluids;
|
|
||||||
private static KeyBinding toggleKey;
|
private static KeyBinding toggleKey;
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
|
@ -105,4 +102,8 @@ public class XRay {
|
||||||
public boolean showRenderBlock(BlockState state) {
|
public boolean showRenderBlock(BlockState state) {
|
||||||
return whitelistBlocks.contains(state.getBlock());
|
return whitelistBlocks.contains(state.getBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getEnable() {
|
||||||
|
return enable && MCPHTClient.CONFIG.xRay.enable;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,14 +1,10 @@
|
||||||
package de.cscherr.mcpht.config;
|
package de.cscherr.mcpht.config;
|
||||||
|
|
||||||
import de.cscherr.mcpht.MCPHTClient;
|
import de.cscherr.mcpht.MCPHTClient;
|
||||||
import de.cscherr.mcpht.mixin.client.NetworkPacketLogMixin;
|
|
||||||
import me.shedaniel.autoconfig.ConfigData;
|
import me.shedaniel.autoconfig.ConfigData;
|
||||||
import me.shedaniel.autoconfig.annotation.Config;
|
import me.shedaniel.autoconfig.annotation.Config;
|
||||||
import me.shedaniel.autoconfig.annotation.ConfigEntry;
|
import me.shedaniel.autoconfig.annotation.ConfigEntry;
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.RedstoneBlock;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@Config(name = "mcphtconf")
|
@Config(name = "mcphtconf")
|
||||||
|
@ -26,15 +22,16 @@ public class MCPHTConfig implements ConfigData {
|
||||||
logSettings();
|
logSettings();
|
||||||
}
|
}
|
||||||
public void logSettings() {
|
public void logSettings() {
|
||||||
MCPHTClient.LOGGER.info(String.format("CONFIG: \n" +
|
MCPHTClient.LOGGER.info(String.format("""
|
||||||
"NetworkLogging\n" +
|
CONFIG:\s
|
||||||
" RX: %b\n" +
|
NetworkLogging
|
||||||
" TX: %b\n" +
|
RX: %b
|
||||||
" verbosity: %s\n" +
|
TX: %b
|
||||||
" regex: '%s'\n" +
|
verbosity: %s
|
||||||
" filter: %s\n" +
|
regex: '%s'
|
||||||
"Rendering\n" +
|
filter: %s
|
||||||
" enabled: %b",
|
Rendering
|
||||||
|
enabled: %b""",
|
||||||
MCPHTClient.CONFIG.networkLogging.RX,
|
MCPHTClient.CONFIG.networkLogging.RX,
|
||||||
MCPHTClient.CONFIG.networkLogging.TX,
|
MCPHTClient.CONFIG.networkLogging.TX,
|
||||||
MCPHTClient.CONFIG.networkLogging.verbosity,
|
MCPHTClient.CONFIG.networkLogging.verbosity,
|
||||||
|
@ -70,5 +67,6 @@ public class MCPHTConfig implements ConfigData {
|
||||||
// TODO: toggle with hotkey
|
// TODO: toggle with hotkey
|
||||||
public static class XRayScheme {
|
public static class XRayScheme {
|
||||||
public boolean enable = false;
|
public boolean enable = false;
|
||||||
|
public boolean overwriteBrightness;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,25 @@
|
||||||
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.slf4j.Logger;
|
|
||||||
import org.spongepowered.asm.mixin.Final;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.BlockView;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
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(Block.class)
|
@Mixin(Block.class)
|
||||||
public abstract class BlockMixin {
|
public abstract class MixinBlock {
|
||||||
@Shadow @Final private static Logger LOGGER;
|
@Inject(at = @At("RETURN"), method = "shouldDrawSide(" + "Lnet/minecraft/block/BlockState;" + // state
|
||||||
|
"Lnet/minecraft/world/BlockView;" + // reader
|
||||||
@Inject(method = "shouldDrawSide", at = @At("RETURN"), cancellable = true)
|
"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,
|
private static void shouldDrawSide(BlockState state,
|
||||||
BlockView world,
|
BlockView world,
|
||||||
BlockPos pos,
|
BlockPos pos,
|
||||||
|
@ -29,7 +27,7 @@ public abstract class BlockMixin {
|
||||||
BlockPos otherPos,
|
BlockPos otherPos,
|
||||||
CallbackInfoReturnable<Boolean> cir
|
CallbackInfoReturnable<Boolean> cir
|
||||||
) {
|
) {
|
||||||
if (MCPHTClient.XRAY.enable && MCPHTClient.CONFIG.xRay.enable) {
|
if (MCPHTClient.XRAY.getEnable()) {
|
||||||
cir.setReturnValue(MCPHTClient.XRAY.showRenderBlock(state));
|
cir.setReturnValue(MCPHTClient.XRAY.showRenderBlock(state));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package de.cscherr.mcpht.mixin.client;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.world.BlockView;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Pseudo;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Pseudo
|
||||||
|
@Mixin(targets = "me.jellysquid.mods.sodium.client.render.occlusion.BlockOcclusionCache")
|
||||||
|
/**
|
||||||
|
* Fix for sodium, so that it doesn't break xray.
|
||||||
|
*/
|
||||||
|
public class MixinBlockOcclusionCache {
|
||||||
|
@Inject(at = @At("HEAD"), method = "shouldDrawSide", cancellable = true, remap = false)
|
||||||
|
private void shouldDrawSide(BlockState state, BlockView reader, BlockPos pos, Direction face,
|
||||||
|
CallbackInfoReturnable<Boolean> ci) {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package de.cscherr.mcpht.mixin.client;
|
||||||
|
|
||||||
|
import de.cscherr.mcpht.MCPHTClient;
|
||||||
|
import net.minecraft.client.option.GameOptions;
|
||||||
|
import net.minecraft.client.option.SimpleOption;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
@Mixin(net.minecraft.client.render.LightmapTextureManager.class)
|
||||||
|
public class MixinLightmapTextureManager {
|
||||||
|
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/GameOptions;getGamma()Lnet/minecraft/client/option/SimpleOption;", opcode = Opcodes.INVOKEVIRTUAL), method = "update(F)V")
|
||||||
|
private SimpleOption<Double> getFieldValue(GameOptions options) {
|
||||||
|
// full brightness if xray is on with overwriteBrightness
|
||||||
|
if (MCPHTClient.CONFIG.xRay.overwriteBrightness && MCPHTClient.XRAY.getEnable()) {
|
||||||
|
return new SimpleOption<>("options.gamma", SimpleOption.emptyTooltip(), (optionText, value) -> Text.empty(), SimpleOption.DoubleSliderCallbacks.INSTANCE.withModifier(
|
||||||
|
d -> (double) 20f, d -> 1
|
||||||
|
), 0.5, value -> {
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return options.getGamma();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package de.cscherr.mcpht.mixin.client;
|
||||||
|
|
||||||
|
import de.cscherr.mcpht.MCPHTClient;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@Mixin(MinecraftClient.class)
|
||||||
|
public class MixinMinecraftClient {
|
||||||
|
@Inject(at = @At(value = "HEAD"), method = "isAmbientOcclusionEnabled()Z", cancellable = true)
|
||||||
|
private static void isAmbientOcclusionEnabled(CallbackInfoReturnable<Boolean> ci) {
|
||||||
|
if (MCPHTClient.XRAY.getEnable() && MCPHTClient.CONFIG.xRay.overwriteBrightness) {
|
||||||
|
ci.setReturnValue(false);
|
||||||
|
ci.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
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.config.MCPHTConfig;
|
|
||||||
import net.minecraft.network.ClientConnection;
|
import net.minecraft.network.ClientConnection;
|
||||||
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
|
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -15,10 +14,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
@Mixin(ClientConnection.class)
|
@Mixin(ClientConnection.class)
|
||||||
public class NetworkPacketLogMixin {
|
public class MixinNetworkPacketLog {
|
||||||
private static boolean filterPacket(Packet<?> packet) {
|
private static boolean filterPacket(Packet<?> packet) {
|
||||||
return MCPHTClient.networkPacketFilter.matcher(packet.getClass().getSimpleName()).find();
|
return MCPHTClient.networkPacketFilter.matcher(packet.getClass().getSimpleName()).find();
|
||||||
}
|
}
|
|
@ -1,12 +1,15 @@
|
||||||
{
|
{
|
||||||
"required": true,
|
"required": true,
|
||||||
"package": "de.cscherr.mcpht.mixin.client",
|
"package": "de.cscherr.mcpht.mixin.client",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"client": [
|
"client": [
|
||||||
"NetworkPacketLogMixin",
|
"MixinBlock",
|
||||||
"BlockMixin"
|
"MixinNetworkPacketLog",
|
||||||
],
|
"MixinBlockOcclusionCache",
|
||||||
"injectors": {
|
"MixinLightmapTextureManager",
|
||||||
"defaultRequire": 1
|
"MixinMinecraftClient"
|
||||||
}
|
],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"minVersion": "0.8",
|
||||||
|
"package": "de.cscherr.mcpht.mixin.client",
|
||||||
|
"compatibilityLevel": "JAVA_8",
|
||||||
|
"mixins": [],
|
||||||
|
"client": [
|
||||||
|
"MixinBlock",
|
||||||
|
"MixinBlockOcclusionCache",
|
||||||
|
"MixinMinecraftClient",
|
||||||
|
"MixinLightmapTextureManager"
|
||||||
|
],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,7 +7,11 @@
|
||||||
|
|
||||||
"text.autoconfig.mcphtconf.option.xRay": "XRay",
|
"text.autoconfig.mcphtconf.option.xRay": "XRay",
|
||||||
"text.autoconfig.mcphtconf.option.xRay.enable": "enable",
|
"text.autoconfig.mcphtconf.option.xRay.enable": "enable",
|
||||||
|
"text.autoconfig.mcphtconf.option.xRay.overwriteBrightness": "overwrite Brightness",
|
||||||
|
|
||||||
"text.autoconfig.mcphtconf.category.Networking": "Networking",
|
"text.autoconfig.mcphtconf.category.Networking": "Networking",
|
||||||
"text.autoconfig.mcphtconf.category.Rendering": "Rendering"
|
"text.autoconfig.mcphtconf.category.Rendering": "Rendering",
|
||||||
|
|
||||||
|
"key.mcpht.toggleXray": "XRay toggle",
|
||||||
|
"category.mcpht.rendering": "MCPHT-Rendering"
|
||||||
}
|
}
|
|
@ -35,6 +35,10 @@
|
||||||
{
|
{
|
||||||
"config": "mcpht.client.mixins.json",
|
"config": "mcpht.client.mixins.json",
|
||||||
"environment": "client"
|
"environment": "client"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"config": "mcpht.sodium.mixins.json",
|
||||||
|
"environment": "client"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
|
|
Loading…
Reference in New Issue