diff --git a/gradle.properties b/gradle.properties index 7aac339..d6376b9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version_base = 1.15.0 +version_base = 1.16.0 # Sets default memory used for gradle commands. Can be overridden by user or command line properties. # This is required to provide enough memory for the Minecraft decompilation process. diff --git a/src/main/java/tv/darkosto/sevpatches/core/SevPatchesLoadingPlugin.java b/src/main/java/tv/darkosto/sevpatches/core/SevPatchesLoadingPlugin.java index d20e98e..c0a0ffb 100644 --- a/src/main/java/tv/darkosto/sevpatches/core/SevPatchesLoadingPlugin.java +++ b/src/main/java/tv/darkosto/sevpatches/core/SevPatchesLoadingPlugin.java @@ -62,6 +62,9 @@ public class SevPatchesLoadingPlugin implements IFMLLoadingPlugin { public static String GRAB_MOUSE_CURSOR; public static String UNGRAB_MOUSE_CURSOR; + public static String ENTITY_ON_ENTITY_COLLISION; + public static String ITEMSTACK_IS_ITEM_EQUAL; + public SevPatchesLoadingPlugin() { LOGGER.info("setting up mixin environment"); MixinBootstrap.init(); @@ -135,6 +138,9 @@ public void injectData(Map data) { SevPatchesLoadingPlugin.GRAB_MOUSE_CURSOR = dev ? "grabMouseCursor" : "a"; SevPatchesLoadingPlugin.UNGRAB_MOUSE_CURSOR = dev ? "ungrabMouseCursor" : "b"; + + SevPatchesLoadingPlugin.ENTITY_ON_ENTITY_COLLISION = dev ? "onEntityCollision" : "func_180634_a"; + SevPatchesLoadingPlugin.ITEMSTACK_IS_ITEM_EQUAL = dev ? "isItemEqual" : "func_77969_a"; } @Override diff --git a/src/main/java/tv/darkosto/sevpatches/core/SevPatchesTransformer.java b/src/main/java/tv/darkosto/sevpatches/core/SevPatchesTransformer.java index e41e981..01bf522 100644 --- a/src/main/java/tv/darkosto/sevpatches/core/SevPatchesTransformer.java +++ b/src/main/java/tv/darkosto/sevpatches/core/SevPatchesTransformer.java @@ -33,6 +33,8 @@ public byte[] transform(String name, String transformedName, byte[] basicClass) return new PatchPrimalNicerHammerHeads(basicClass).apply(); case "nmd.primal.core.common.entities.living.EntityCanisCampestris": return new PatchPrimalScaredyCat(basicClass).apply(); + case "nmd.primal.core.common.blocks.machines.Barrel": + return new PatchPrimalBarrel(basicClass).apply(); case "realdrops.handlers.EventHandler": return new PatchRidHandlerDeregister(basicClass).apply(); case "tehnut.harvest.ReplantHandlers": diff --git a/src/main/java/tv/darkosto/sevpatches/core/patches/PatchMacMouseFBP.java b/src/main/java/tv/darkosto/sevpatches/core/patches/PatchMacMouseFBP.java index ad0690c..f25c032 100644 --- a/src/main/java/tv/darkosto/sevpatches/core/patches/PatchMacMouseFBP.java +++ b/src/main/java/tv/darkosto/sevpatches/core/patches/PatchMacMouseFBP.java @@ -21,7 +21,7 @@ protected boolean patch() { for (MethodNode method : classNode.methods) { InsnList insnList = method.instructions; Iterable insnsIter = insnList::iterator; - Stream insns = StreamSupport.stream(insnsIter.spliterator(), true); + Stream insns = StreamSupport.stream(insnsIter.spliterator(), false); insns.filter(insn -> insn instanceof MethodInsnNode) .map(insn -> (MethodInsnNode) insn) diff --git a/src/main/java/tv/darkosto/sevpatches/core/patches/PatchPrimalBarrel.java b/src/main/java/tv/darkosto/sevpatches/core/patches/PatchPrimalBarrel.java new file mode 100644 index 0000000..4129f36 --- /dev/null +++ b/src/main/java/tv/darkosto/sevpatches/core/patches/PatchPrimalBarrel.java @@ -0,0 +1,43 @@ +package tv.darkosto.sevpatches.core.patches; + +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.tree.*; +import tv.darkosto.sevpatches.core.SevPatchesLoadingPlugin; +import tv.darkosto.sevpatches.core.utils.AsmUtils; + +import java.util.Optional; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; + +public class PatchPrimalBarrel extends Patch { + public PatchPrimalBarrel(byte[] inputClass) { + super(inputClass); + } + + @Override + protected boolean patch() { + MethodNode onEntityCollision = AsmUtils.findMethod(this.classNode, SevPatchesLoadingPlugin.ENTITY_ON_ENTITY_COLLISION); + if (onEntityCollision == null) return false; + + InsnList insns = onEntityCollision.instructions; + Iterable insnsIter = insns::iterator; + Stream nodes = StreamSupport.stream(insnsIter.spliterator(), false); + + Optional targetOpt = nodes.filter(node -> node instanceof MethodInsnNode) + .map(node -> (MethodInsnNode) node) + .filter(invoke -> invoke.owner.equals("net/minecraft/item/ItemStack") && invoke.name.equals(SevPatchesLoadingPlugin.ITEMSTACK_IS_ITEM_EQUAL)) + .findFirst(); + + if (!targetOpt.isPresent()) return false; + MethodInsnNode target = targetOpt.get(); + + InsnList newCondition = new InsnList(); + newCondition.add(new VarInsnNode(Opcodes.ALOAD, 13)); + newCondition.add(new TypeInsnNode(Opcodes.INSTANCEOF, "nmd/primal/core/common/compat/vanilla/VanillaTorchItem")); + newCondition.add(new InsnNode(Opcodes.IAND)); + + onEntityCollision.instructions.insert(target, newCondition); + + return true; + } +} diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 2b3a110..f57c77a 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -3,7 +3,7 @@ "modid": "sevpatches", "name": "SevPatches", "description": "Consolidated patches for mods that are EOL used in SevTech: Ages", - "version": "1.14.1", + "version": "1.16.0", "mcversion": "1.12.2", "url": "https://www.curseforge.com/minecraft/mc-mods/sevpatches", "updateUrl": "",