diff --git a/src/main/java/gregtech/common/ConfigHolder.java b/src/main/java/gregtech/common/ConfigHolder.java index d8fd4b50ac0..321f3474de4 100644 --- a/src/main/java/gregtech/common/ConfigHolder.java +++ b/src/main/java/gregtech/common/ConfigHolder.java @@ -157,6 +157,9 @@ public static class VanillaRecipes { @Config.Comment("Whether to make vanilla tools and armor recipes harder. Excludes flint and steel, and buckets. Default: false") public boolean hardToolArmorRecipes = false; + + @Config.Comment("Whether to disable the vanilla Concrete from Powder with Water behavior, forcing the GT recipe. Default: false") + public boolean disableConcreteInWorld = false; } public static class NanoSaberConfiguration { diff --git a/src/main/java/gregtech/common/asm/ConcretePowderVisitor.java b/src/main/java/gregtech/common/asm/ConcretePowderVisitor.java new file mode 100644 index 00000000000..7cfd1b2b92b --- /dev/null +++ b/src/main/java/gregtech/common/asm/ConcretePowderVisitor.java @@ -0,0 +1,22 @@ +package gregtech.common.asm; + +import gregtech.common.asm.util.ObfMapping; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; + +public class ConcretePowderVisitor extends MethodVisitor implements Opcodes { + + public static final String TARGET_CLASS_NAME = "net/minecraft/block/BlockConcretePowder"; + public static final String TARGET_SIGNATURE = "(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/state/IBlockState;)Z"; + public static final ObfMapping TARGET_METHOD = new ObfMapping(TARGET_CLASS_NAME, "tryTouchWater", TARGET_SIGNATURE); + + public ConcretePowderVisitor(MethodVisitor mv) { + super(Opcodes.ASM5, mv); + } + + @Override + public void visitCode() { + mv.visitInsn(Opcodes.ICONST_0); + mv.visitInsn(Opcodes.IRETURN); + } +} diff --git a/src/main/java/gregtech/common/asm/GTCETransformer.java b/src/main/java/gregtech/common/asm/GTCETransformer.java index c8b02f73817..68905f2248d 100644 --- a/src/main/java/gregtech/common/asm/GTCETransformer.java +++ b/src/main/java/gregtech/common/asm/GTCETransformer.java @@ -1,5 +1,6 @@ package gregtech.common.asm; +import gregtech.common.ConfigHolder; import gregtech.common.asm.util.TargetClassVisitor; import net.minecraft.launchwrapper.IClassTransformer; import org.objectweb.asm.ClassReader; @@ -16,6 +17,13 @@ public byte[] transform(String name, String transformedName, byte[] basicClass) ClassWriter classWriter = new ClassWriter(0); classReader.accept(new TargetClassVisitor(classWriter, JEIVisitor.TARGET_METHOD, JEIVisitor::new), 0); return classWriter.toByteArray(); + } else if (internalName.equals(ConcretePowderVisitor.TARGET_CLASS_NAME)) { + if (ConfigHolder.vanillaRecipes.disableConcreteInWorld) { + ClassReader classReader = new ClassReader(basicClass); + ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); + classReader.accept(new TargetClassVisitor(classWriter, ConcretePowderVisitor.TARGET_METHOD, ConcretePowderVisitor::new), 0); + return classWriter.toByteArray(); + } } return basicClass; }