diff --git a/src/main/java/ru/fewizz/idextender/asm/AsmUtil.java b/src/main/java/ru/fewizz/idextender/asm/AsmUtil.java index e0d147d..f4cda23 100644 --- a/src/main/java/ru/fewizz/idextender/asm/AsmUtil.java +++ b/src/main/java/ru/fewizz/idextender/asm/AsmUtil.java @@ -93,7 +93,7 @@ public static boolean transformInlinedSizeMethod( boolean found = false; boolean foundOnce = false; final int i = 0; - final ListIterator it = (ListIterator) method.instructions.iterator(); + final ListIterator it = method.instructions.iterator(); while (it.hasNext()) { final AbstractInsnNode insn = it.next(); if (insn.getOpcode() == 3 && oldValue == 0) { @@ -122,23 +122,23 @@ public static boolean transformInlinedSizeMethod( if (found) { foundOnce = true; if (newValue == 0) { - it.set((AbstractInsnNode) new InsnNode(3)); + it.set(new InsnNode(3)); } else if (newValue == 1) { - it.set((AbstractInsnNode) new InsnNode(4)); + it.set(new InsnNode(4)); } else if (newValue == 2) { - it.set((AbstractInsnNode) new InsnNode(5)); + it.set(new InsnNode(5)); } else if (newValue == 3) { - it.set((AbstractInsnNode) new InsnNode(6)); + it.set(new InsnNode(6)); } else if (newValue == 4) { - it.set((AbstractInsnNode) new InsnNode(7)); + it.set(new InsnNode(7)); } else if (newValue == 5) { - it.set((AbstractInsnNode) new InsnNode(8)); + it.set(new InsnNode(8)); } else if (newValue >= -128 && newValue <= 127) { - it.set((AbstractInsnNode) new IntInsnNode(16, newValue)); + it.set(new IntInsnNode(16, newValue)); } else if (newValue >= -32768 && newValue <= 32767) { - it.set((AbstractInsnNode) new IntInsnNode(17, newValue)); + it.set(new IntInsnNode(17, newValue)); } else { - it.set((AbstractInsnNode) new LdcInsnNode((Object) newValue)); + it.set(new LdcInsnNode(newValue)); } found = false; } @@ -151,8 +151,8 @@ public static boolean transformInlinedSizeMethod( public static void dump(final InsnList list) { final Textifier textifier = new Textifier(); - final TraceMethodVisitor visitor = new TraceMethodVisitor((Printer) textifier); - list.accept((MethodVisitor) visitor); + final TraceMethodVisitor visitor = new TraceMethodVisitor(textifier); + list.accept(visitor); final PrintWriter writer = new PrintWriter(System.out); textifier.print(writer); writer.flush(); diff --git a/src/main/java/ru/fewizz/idextender/asm/ClassEdit.java b/src/main/java/ru/fewizz/idextender/asm/ClassEdit.java index 0713811..72d96f9 100644 --- a/src/main/java/ru/fewizz/idextender/asm/ClassEdit.java +++ b/src/main/java/ru/fewizz/idextender/asm/ClassEdit.java @@ -4,62 +4,51 @@ import ru.fewizz.idextender.asm.transformer.*; public enum ClassEdit { - SelfHooks((IClassNodeTransformer) new SelfHooks(), new String[] {"ru.fewizz.idextender.Hooks"}), - VanillaBlockFire((IClassNodeTransformer) new VanillaBlockFire(), new String[] {"net.minecraft.block.BlockFire"}), - VanillaStatList((IClassNodeTransformer) new VanillaStatList(), new String[] {"net.minecraft.stats.StatList"}), + SelfHooks(new SelfHooks(), new String[] {"ru.fewizz.idextender.Hooks"}), + VanillaBlockFire(new VanillaBlockFire(), new String[] {"net.minecraft.block.BlockFire"}), + VanillaStatList(new VanillaStatList(), new String[] {"net.minecraft.stats.StatList"}), VanillaAnvilChunkLoader( - (IClassNodeTransformer) new VanillaAnvilChunkLoader(), - new String[] {"net.minecraft.world.chunk.storage.AnvilChunkLoader"}), - VanillaChunk((IClassNodeTransformer) new VanillaChunk(), new String[] {"net.minecraft.world.chunk.Chunk"}), + new VanillaAnvilChunkLoader(), new String[] {"net.minecraft.world.chunk.storage.AnvilChunkLoader"}), + VanillaChunk(new VanillaChunk(), new String[] {"net.minecraft.world.chunk.Chunk"}), VanillaExtendedBlockStorage( - (IClassNodeTransformer) new VanillaExtendedBlockStorage(), - new String[] {"net.minecraft.world.chunk.storage.ExtendedBlockStorage"}), - VanillaDataWatcher( - (IClassNodeTransformer) new VanillaDataWatcher(), new String[] {"net.minecraft.entity.DataWatcher"}), + new VanillaExtendedBlockStorage(), new String[] {"net.minecraft.world.chunk.storage.ExtendedBlockStorage"}), + VanillaDataWatcher(new VanillaDataWatcher(), new String[] {"net.minecraft.entity.DataWatcher"}), VanillaNetHandlerPlayClient( - (IClassNodeTransformer) new VanillaNetHandlerPlayClient(), - new String[] {"net.minecraft.client.network.NetHandlerPlayClient"}), + new VanillaNetHandlerPlayClient(), new String[] {"net.minecraft.client.network.NetHandlerPlayClient"}), VanillaS21PacketChunkData( - (IClassNodeTransformer) new VanillaS21PacketChunkData(), - new String[] {"net.minecraft.network.play.server.S21PacketChunkData"}), + new VanillaS21PacketChunkData(), new String[] {"net.minecraft.network.play.server.S21PacketChunkData"}), VanillaS22PacketMultiBlockChange( - (IClassNodeTransformer) new VanillaS22PacketMultiBlockChange(), + new VanillaS22PacketMultiBlockChange(), new String[] {"net.minecraft.network.play.server.S22PacketMultiBlockChange"}), VanillaS24PacketBlockActivation( - (IClassNodeTransformer) new VanillaS24PacketBlockActivation(), + new VanillaS24PacketBlockActivation(), new String[] {"net.minecraft.network.play.server.S24PacketBlockAction"}), VanillaS26PacketMapChunkBulk( - (IClassNodeTransformer) new VanillaS26PacketMapChunkBulk(), + new VanillaS26PacketMapChunkBulk(), new String[] {"net.minecraft.network.play.server.S26PacketMapChunkBulk"}), - VanillaRenderGlobal( - (IClassNodeTransformer) new VanillaRenderGlobal(), - new String[] {"net.minecraft.client.renderer.RenderGlobal"}), + VanillaRenderGlobal(new VanillaRenderGlobal(), new String[] {"net.minecraft.client.renderer.RenderGlobal"}), VanillaPlayerControllerMP( - (IClassNodeTransformer) new VanillaPlayerControllerMP(), - new String[] {"net.minecraft.client.multiplayer.PlayerControllerMP"}), + new VanillaPlayerControllerMP(), new String[] {"net.minecraft.client.multiplayer.PlayerControllerMP"}), VanillaItemInWorldManager( - (IClassNodeTransformer) new VanillaItemInWorldManager(), - new String[] {"net.minecraft.server.management.ItemInWorldManager"}), - VanillaWorld((IClassNodeTransformer) new VanillaWorld(), new String[] {"net.minecraft.world.World"}), - FmlRegistry((IClassNodeTransformer) new FmlRegistry(), new String[] { + new VanillaItemInWorldManager(), new String[] {"net.minecraft.server.management.ItemInWorldManager"}), + VanillaWorld(new VanillaWorld(), new String[] {"net.minecraft.world.World"}), + FmlRegistry(new FmlRegistry(), new String[] { "cpw.mods.fml.common.registry.GameData", "cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry" }), - CofhBlockHelper((IClassNodeTransformer) new CofhBlockHelper(), new String[] {"cofh.lib.util.helpers.BlockHelper"}), + CofhBlockHelper(new CofhBlockHelper(), new String[] {"cofh.lib.util.helpers.BlockHelper"}), UndergroundBiomesOreUBifier( - (IClassNodeTransformer) new UndergroundBiomesOreUBifier(), - new String[] {"exterminatorJeff.undergroundBiomes.worldGen.OreUBifier"}), + new UndergroundBiomesOreUBifier(), new String[] {"exterminatorJeff.undergroundBiomes.worldGen.OreUBifier"}), UndergroundBiomesBiomeUndergroundDecorator( - (IClassNodeTransformer) new UndergroundBiomesBiomeUndergroundDecorator(), + new UndergroundBiomesBiomeUndergroundDecorator(), new String[] {"exterminatorJeff.undergroundBiomes.worldGen.BiomeUndergroundDecorator"}), - MFQM((IClassNodeTransformer) new MFQM(), new String[] {"MoreFunQuicksandMod.main.MFQM"}), - WorldEditBaseBlock( - (IClassNodeTransformer) new WorldEditBaseBlock(), new String[] {"com.sk89q.worldedit.blocks.BaseBlock"}); + MFQM(new MFQM(), new String[] {"MoreFunQuicksandMod.main.MFQM"}), + WorldEditBaseBlock(new WorldEditBaseBlock(), new String[] {"com.sk89q.worldedit.blocks.BaseBlock"}); private static final Map editMap; private final IClassNodeTransformer transformer; private final String[] classNames; - private ClassEdit(final IClassNodeTransformer transformer, final String[] classNames) { + ClassEdit(final IClassNodeTransformer transformer, final String[] classNames) { this.transformer = transformer; this.classNames = classNames; } diff --git a/src/main/java/ru/fewizz/idextender/asm/IETransformer.java b/src/main/java/ru/fewizz/idextender/asm/IETransformer.java index c1ddaf0..8533781 100644 --- a/src/main/java/ru/fewizz/idextender/asm/IETransformer.java +++ b/src/main/java/ru/fewizz/idextender/asm/IETransformer.java @@ -21,35 +21,32 @@ public byte[] transform(final String name, final String transformedName, final b if (edit == null) { return bytes; } - IETransformer.logger.debug("Patching {} with {}...", new Object[] {transformedName, edit.getName()}); + IETransformer.logger.debug("Patching {} with {}...", transformedName, edit.getName()); final ClassNode cn = new ClassNode(Opcodes.ASM5); final ClassReader reader = new ClassReader(bytes); final int readFlags = 0; - reader.accept((ClassVisitor) cn, 0); + reader.accept(cn, 0); try { edit.getTransformer().transform(cn, IETransformer.isObfuscated); } catch (AsmTransformException t) { IETransformer.logger.error( - "Error transforming {} with {}: {}", - new Object[] {transformedName, edit.getName(), t.getMessage()}); + "Error transforming {} with {}: {}", transformedName, edit.getName(), t.getMessage()); throw t; } catch (Throwable t2) { IETransformer.logger.error( - "Error transforming {} with {}: {}", - new Object[] {transformedName, edit.getName(), t2.getMessage()}); + "Error transforming {} with {}: {}", transformedName, edit.getName(), t2.getMessage()); throw new RuntimeException(t2); } final ClassWriter writer = new ClassWriter(0); try { - final ClassVisitor check = (ClassVisitor) new CheckClassAdapter((ClassVisitor) writer); + final ClassVisitor check = new CheckClassAdapter(writer); cn.accept(check); } catch (Throwable t3) { IETransformer.logger.error( - "Error verifying {} transformed with {}: {}", - new Object[] {transformedName, edit.getName(), t3.getMessage()}); + "Error verifying {} transformed with {}: {}", transformedName, edit.getName(), t3.getMessage()); throw new RuntimeException(t3); } - IETransformer.logger.debug("Patched {} successfully.", new Object[] {edit.getName()}); + IETransformer.logger.debug("Patched {} successfully.", edit.getName()); return writer.toByteArray(); } diff --git a/src/main/java/ru/fewizz/idextender/asm/Name.java b/src/main/java/ru/fewizz/idextender/asm/Name.java index 90ef1c1..f94ef7b 100644 --- a/src/main/java/ru/fewizz/idextender/asm/Name.java +++ b/src/main/java/ru/fewizz/idextender/asm/Name.java @@ -4,54 +4,38 @@ public enum Name { hooks("ru/fewizz/idextender/Hooks"), - hooks_create16BArray(Name.hooks, "create16BArray", (String) null, (String) null, "()[S"), + hooks_create16BArray(Name.hooks, "create16BArray", null, null, "()[S"), hooks_getBlockData( - Name.hooks, - "getBlockData", - (String) null, - (String) null, - "(Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;)[B"), + Name.hooks, "getBlockData", null, null, "(Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;)[B"), hooks_setBlockData( - Name.hooks, - "setBlockData", - (String) null, - (String) null, - "(Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;[BI)V"), + Name.hooks, "setBlockData", null, null, "(Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;[BI)V"), hooks_writeChunkToNbt( Name.hooks, "writeChunkToNbt", - (String) null, - (String) null, + null, + null, "(Lnet/minecraft/nbt/NBTTagCompound;Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;)V"), hooks_readChunkFromNbt( Name.hooks, "readChunkFromNbt", - (String) null, - (String) null, + null, + null, "(Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;Lnet/minecraft/nbt/NBTTagCompound;)V"), hooks_getBlockId( - Name.hooks, - "getBlockId", - (String) null, - (String) null, - "(Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;III)I"), + Name.hooks, "getBlockId", null, null, "(Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;III)I"), hooks_getBlockById( Name.hooks, "getBlock", - (String) null, - (String) null, + null, + null, "(Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;III)Lnet/minecraft/block/Block;"), hooks_setBlockId( - Name.hooks, - "setBlockId", - (String) null, - (String) null, - "(Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;IIII)V"), + Name.hooks, "setBlockId", null, null, "(Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;IIII)V"), hooks_getIdFromBlockWithCheck( Name.hooks, "getIdFromBlockWithCheck", - (String) null, - (String) null, + null, + null, "(Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)I"), acl("net/minecraft/world/chunk/storage/AnvilChunkLoader", "aqk"), block("net/minecraft/block/Block", "aji"), @@ -75,7 +59,7 @@ public enum Name { entityPlayer("net/minecraft/entity/player/EntityPlayer", "yz"), ebs_getBlock( Name.extendedBlockStorage, "getBlockByExtId", "a", "func_150819_a", "(III)Lnet/minecraft/block/Block;"), - ebs_setBlock(Name.extendedBlockStorage, "func_150818_a", "a", (String) null, "(IIILnet/minecraft/block/Block;)V"), + ebs_setBlock(Name.extendedBlockStorage, "func_150818_a", "a", null, "(IIILnet/minecraft/block/Block;)V"), ebs_getBlockLSBArray(Name.extendedBlockStorage, "getBlockLSBArray", "g", "func_76658_g", "()[B"), ebs_getBlockMSBArray( Name.extendedBlockStorage, @@ -138,36 +122,26 @@ public enum Name { "a", "func_147287_a", "(Lnet/minecraft/network/play/server/S22PacketMultiBlockChange;)V"), - s22_init_server(Name.s22, "", (String) null, (String) null, "(I[SLnet/minecraft/world/chunk/Chunk;)V"), - s21_undefined1(Name.s21, "func_149275_c", "c", (String) null, "()I"), + s22_init_server(Name.s22, "", null, null, "(I[SLnet/minecraft/world/chunk/Chunk;)V"), + s21_undefined1(Name.s21, "func_149275_c", "c", null, "()I"), s21_undefined2( Name.s21, "func_149269_a", "a", - (String) null, + null, "(Lnet/minecraft/world/chunk/Chunk;ZI)Lnet/minecraft/network/play/server/S21PacketChunkData$Extracted;"), renderGlobal_playAuxSFX( Name.renderGlobal, "playAuxSFX", "a", "func_72706_a", "(Lnet/minecraft/entity/player/EntityPlayer;IIIII)V"), playerControllerMP_onPlayerDestroyBlock( Name.playerControllerMP, "onPlayerDestroyBlock", "a", "func_78751_a", "(IIII)Z"), itemInWorldManager_tryHarvestBlock(Name.itemInWorldManager, "tryHarvestBlock", "b", "func_73084_b", "(III)Z"), - world_breakBlock(Name.world, "func_147480_a", "a", (String) null, "(IIIZ)Z"), + world_breakBlock(Name.world, "func_147480_a", "a", null, "(IIIZ)Z"), ub_bud("exterminatorJeff/undergroundBiomes/worldGen/BiomeUndergroundDecorator"), - ub_bud_replaceChunkOres_world( - Name.ub_bud, "replaceChunkOres", (String) null, (String) null, "(IILnet/minecraft/world/World;)V"), + ub_bud_replaceChunkOres_world(Name.ub_bud, "replaceChunkOres", null, null, "(IILnet/minecraft/world/World;)V"), ub_bud_replaceChunkOres_iChunkProvider( - Name.ub_bud, - "replaceChunkOres", - (String) null, - (String) null, - "(Lnet/minecraft/world/chunk/IChunkProvider;II)V"), + Name.ub_bud, "replaceChunkOres", null, null, "(Lnet/minecraft/world/chunk/IChunkProvider;II)V"), MFQM("MoreFunQuicksandMod/main/MFQM"), - MFQM_preInit( - Name.MFQM, - "preInit", - (String) null, - (String) null, - "(Lcpw/mods/fml/common/event/FMLPreInitializationEvent;)V"); + MFQM_preInit(Name.MFQM, "preInit", null, null, "(Lcpw/mods/fml/common/event/FMLPreInitializationEvent;)V"); public final Name clazz; public final String deobf; @@ -176,11 +150,11 @@ public enum Name { public final String desc; public String obfDesc; - private Name(final String deobf) { + Name(final String deobf) { this(deobf, deobf); } - private Name(final String deobf, final String obf) { + Name(final String deobf, final String obf) { this.clazz = null; this.deobf = deobf; this.obf = obf; @@ -188,7 +162,7 @@ private Name(final String deobf, final String obf) { this.desc = null; } - private Name(final Name clazz, final String deobf, final String obf, final String srg, final String desc) { + Name(final Name clazz, final String deobf, final String obf, final String srg, final String desc) { this.clazz = clazz; this.deobf = deobf; this.obf = ((obf != null) ? obf : deobf); diff --git a/src/main/java/ru/fewizz/idextender/asm/transformer/SelfHooks.java b/src/main/java/ru/fewizz/idextender/asm/transformer/SelfHooks.java index 20fe1f9..fe706c1 100644 --- a/src/main/java/ru/fewizz/idextender/asm/transformer/SelfHooks.java +++ b/src/main/java/ru/fewizz/idextender/asm/transformer/SelfHooks.java @@ -18,10 +18,10 @@ public void transform(final ClassNode cn, final boolean obfuscated) { private void transformGet(final ClassNode cn, final MethodNode method) { final InsnList code = method.instructions; code.clear(); - code.add((AbstractInsnNode) new VarInsnNode(25, 0)); - code.add((AbstractInsnNode) + code.add(new VarInsnNode(25, 0)); + code.add( new FieldInsnNode(180, Type.getArgumentTypes(method.desc)[0].getInternalName(), "block16BArray", "[S")); - code.add((AbstractInsnNode) new InsnNode(176)); + code.add(new InsnNode(176)); method.localVariables = null; method.maxStack = 1; } @@ -29,10 +29,10 @@ private void transformGet(final ClassNode cn, final MethodNode method) { private void transformSetBlockRefCount(final ClassNode cn, final MethodNode method, final boolean isObf) { final InsnList code = method.instructions; code.clear(); - code.add((AbstractInsnNode) new VarInsnNode(25, 0)); - code.add((AbstractInsnNode) new VarInsnNode(21, 1)); - code.add((AbstractInsnNode) Name.ebs_blockRefCount.virtualSet(isObf)); - code.add((AbstractInsnNode) new InsnNode(177)); + code.add(new VarInsnNode(25, 0)); + code.add(new VarInsnNode(21, 1)); + code.add(Name.ebs_blockRefCount.virtualSet(isObf)); + code.add(new InsnNode(177)); method.localVariables = null; method.maxStack = 2; } @@ -40,10 +40,10 @@ private void transformSetBlockRefCount(final ClassNode cn, final MethodNode meth private void transformSetTickRefCount(final ClassNode cn, final MethodNode method, final boolean isObf) { final InsnList code = method.instructions; code.clear(); - code.add((AbstractInsnNode) new VarInsnNode(25, 0)); - code.add((AbstractInsnNode) new VarInsnNode(21, 1)); - code.add((AbstractInsnNode) Name.ebs_tickRefCount.virtualSet(isObf)); - code.add((AbstractInsnNode) new InsnNode(177)); + code.add(new VarInsnNode(25, 0)); + code.add(new VarInsnNode(21, 1)); + code.add(Name.ebs_tickRefCount.virtualSet(isObf)); + code.add(new InsnNode(177)); method.localVariables = null; method.maxStack = 2; } diff --git a/src/main/java/ru/fewizz/idextender/asm/transformer/UndergroundBiomesBiomeUndergroundDecorator.java b/src/main/java/ru/fewizz/idextender/asm/transformer/UndergroundBiomesBiomeUndergroundDecorator.java index de9b320..eb74830 100644 --- a/src/main/java/ru/fewizz/idextender/asm/transformer/UndergroundBiomesBiomeUndergroundDecorator.java +++ b/src/main/java/ru/fewizz/idextender/asm/transformer/UndergroundBiomesBiomeUndergroundDecorator.java @@ -16,15 +16,15 @@ public void transform(final ClassNode cn, final boolean obfuscated) { private void transformReplaceChunkOres( final ClassNode cn, final MethodNode method, final boolean obfuscated, final int varOffset) { final InsnList code = method.instructions; - final ListIterator iterator = (ListIterator) code.iterator(); + final ListIterator iterator = code.iterator(); while (iterator.hasNext()) { final AbstractInsnNode insn = iterator.next(); if (insn.getOpcode() == 182 && Name.ebs_getBlockLSBArray.matches((MethodInsnNode) insn, obfuscated)) { iterator.remove(); - iterator.add((AbstractInsnNode) new VarInsnNode(21, 9 + varOffset)); - iterator.add((AbstractInsnNode) new VarInsnNode(21, 18 + varOffset)); - iterator.add((AbstractInsnNode) new VarInsnNode(21, 10 + varOffset)); - iterator.add((AbstractInsnNode) Name.hooks_getBlockId.staticInvocation(obfuscated)); + iterator.add(new VarInsnNode(21, 9 + varOffset)); + iterator.add(new VarInsnNode(21, 18 + varOffset)); + iterator.add(new VarInsnNode(21, 10 + varOffset)); + iterator.add(Name.hooks_getBlockId.staticInvocation(obfuscated)); while (iterator.next().getOpcode() != 54) { iterator.remove(); } diff --git a/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaAnvilChunkLoader.java b/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaAnvilChunkLoader.java index d9f7238..18403c7 100644 --- a/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaAnvilChunkLoader.java +++ b/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaAnvilChunkLoader.java @@ -15,7 +15,7 @@ public void transform(final ClassNode cn, final boolean obfuscated) { private void transformWriteChunkToNBT(final ClassNode cn, final MethodNode method, final boolean obfuscated) { final InsnList code = method.instructions; - final ListIterator iterator = (ListIterator) code.iterator(); + final ListIterator iterator = code.iterator(); while (iterator.hasNext()) { final AbstractInsnNode insn = iterator.next(); if (insn.getOpcode() == 18 && ((LdcInsnNode) insn).cst.equals("Blocks")) { @@ -25,7 +25,7 @@ private void transformWriteChunkToNBT(final ClassNode cn, final MethodNode metho iterator.remove(); iterator.next(); iterator.remove(); - iterator.add((AbstractInsnNode) Name.hooks_writeChunkToNbt.staticInvocation(obfuscated)); + iterator.add(Name.hooks_writeChunkToNbt.staticInvocation(obfuscated)); return; } } @@ -35,14 +35,14 @@ private void transformWriteChunkToNBT(final ClassNode cn, final MethodNode metho private void transformReadChunkFromNBT(final ClassNode cn, final MethodNode method, final boolean obfuscated) { final InsnList code = method.instructions; int part = 0; - final ListIterator iterator = (ListIterator) code.iterator(); + final ListIterator iterator = code.iterator(); while (iterator.hasNext()) { final AbstractInsnNode insn = iterator.next(); if (part == 0) { if (insn.getOpcode() != 18 || !((LdcInsnNode) insn).cst.equals("Blocks")) { continue; } - iterator.set((AbstractInsnNode) Name.hooks_readChunkFromNbt.staticInvocation(obfuscated)); + iterator.set(Name.hooks_readChunkFromNbt.staticInvocation(obfuscated)); ++part; } else if (part == 1) { iterator.remove(); diff --git a/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaChunk.java b/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaChunk.java index d2ef0d3..a063660 100644 --- a/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaChunk.java +++ b/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaChunk.java @@ -13,22 +13,22 @@ public void transform(final ClassNode cn, final boolean obfuscated) { } method.localVariables = null; int part = 0; - final ListIterator it = (ListIterator) method.instructions.iterator(); + final ListIterator it = method.instructions.iterator(); while (it.hasNext()) { AbstractInsnNode insn = it.next(); if (part == 0) { if (insn.getOpcode() != 182 || !Name.ebs_getBlockLSBArray.matches((MethodInsnNode) insn, obfuscated)) { continue; } - it.set((AbstractInsnNode) new VarInsnNode(25, 1)); - it.add((AbstractInsnNode) new VarInsnNode(21, 6)); - it.add((AbstractInsnNode) Name.hooks_setBlockData.staticInvocation(obfuscated)); + it.set(new VarInsnNode(25, 1)); + it.add(new VarInsnNode(21, 6)); + it.add(Name.hooks_setBlockData.staticInvocation(obfuscated)); ++part; } else if (part == 1) { if (insn.getOpcode() == 96) { - it.set((AbstractInsnNode) new VarInsnNode(21, 6)); - it.add((AbstractInsnNode) new LdcInsnNode((Object) 8192)); - it.add((AbstractInsnNode) new InsnNode(96)); + it.set(new VarInsnNode(21, 6)); + it.add(new LdcInsnNode(8192)); + it.add(new InsnNode(96)); ++part; } else { it.remove(); @@ -42,8 +42,7 @@ public void transform(final ClassNode cn, final boolean obfuscated) { do { insn = it.next(); } while (insn.getOpcode() != 161 && insn.getOpcode() != 162); - it.set((AbstractInsnNode) - new JumpInsnNode((insn.getOpcode() == 161) ? 163 : 161, ((JumpInsnNode) insn).label)); + it.set(new JumpInsnNode((insn.getOpcode() == 161) ? 163 : 161, ((JumpInsnNode) insn).label)); return; } continue; diff --git a/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaDataWatcher.java b/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaDataWatcher.java index 9b6f5e6..7218e8c 100644 --- a/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaDataWatcher.java +++ b/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaDataWatcher.java @@ -15,11 +15,11 @@ public void transform(final ClassNode cn, final boolean obfuscated) { AsmUtil.transformInlinedSizeMethod(cn, method, 31, 127); AsmUtil.transformInlinedSizeMethod(cn, method, 255, 1023); AsmUtil.transformInlinedSizeMethod(cn, method, 5, 7); - final ListIterator it = (ListIterator) method.instructions.iterator(); + final ListIterator it = method.instructions.iterator(); while (it.hasNext()) { final AbstractInsnNode insn = it.next(); if (insn.getOpcode() == 182 && ((MethodInsnNode) insn).name.equals("writeByte")) { - it.set((AbstractInsnNode) new MethodInsnNode( + it.set(new MethodInsnNode( 182, "net/minecraft/network/PacketBuffer", "writeShort", @@ -34,15 +34,14 @@ public void transform(final ClassNode cn, final boolean obfuscated) { AsmUtil.transformInlinedSizeMethod(cn, method, 31, 127); AsmUtil.transformInlinedSizeMethod(cn, method, 5, 7); int num = 0; - ListIterator it2 = (ListIterator) method.instructions.iterator(); + ListIterator it2 = method.instructions.iterator(); while (it2.hasNext()) { final AbstractInsnNode insn2 = it2.next(); if (insn2.getOpcode() == 182 && ((MethodInsnNode) insn2).name.equals("readByte")) { if (++num == 2) { continue; } - it2.set((AbstractInsnNode) - new MethodInsnNode(182, "net/minecraft/network/PacketBuffer", "readShort", "()S", false)); + it2.set(new MethodInsnNode(182, "net/minecraft/network/PacketBuffer", "readShort", "()S", false)); if (num == 3) { break; } @@ -51,11 +50,11 @@ public void transform(final ClassNode cn, final boolean obfuscated) { } method = AsmUtil.findMethod(cn, Name.dataWatcher_writeWatchedListToPacketBuffer); AsmUtil.transformInlinedSizeMethod(cn, method, 127, 32767); - it2 = (ListIterator) method.instructions.iterator(); + it2 = method.instructions.iterator(); while (it2.hasNext()) { final AbstractInsnNode insn2 = it2.next(); if (insn2.getOpcode() == 182 && ((MethodInsnNode) insn2).name.equals("writeByte")) { - it2.set((AbstractInsnNode) new MethodInsnNode( + it2.set(new MethodInsnNode( 182, "net/minecraft/network/PacketBuffer", "writeShort", @@ -66,11 +65,11 @@ public void transform(final ClassNode cn, final boolean obfuscated) { } method = AsmUtil.findMethod(cn, Name.dataWatcher_func_151509_a); AsmUtil.transformInlinedSizeMethod(cn, method, 127, 32767); - it2 = (ListIterator) method.instructions.iterator(); + it2 = method.instructions.iterator(); while (it2.hasNext()) { final AbstractInsnNode insn2 = it2.next(); if (insn2.getOpcode() == 182 && ((MethodInsnNode) insn2).name.equals("writeByte")) { - it2.set((AbstractInsnNode) new MethodInsnNode( + it2.set(new MethodInsnNode( 182, "net/minecraft/network/PacketBuffer", "writeShort", diff --git a/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaExtendedBlockStorage.java b/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaExtendedBlockStorage.java index 2feaba0..fcaf00f 100644 --- a/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaExtendedBlockStorage.java +++ b/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaExtendedBlockStorage.java @@ -7,7 +7,7 @@ public class VanillaExtendedBlockStorage implements IClassNodeTransformer { @Override public void transform(final ClassNode cn, final boolean obfuscated) { - cn.fields.add(new FieldNode(1, "block16BArray", "[S", (String) null, (Object) null)); + cn.fields.add(new FieldNode(1, "block16BArray", "[S", null, null)); AsmUtil.makePublic(AsmUtil.findField(cn, Name.ebs_blockRefCount)); AsmUtil.makePublic(AsmUtil.findField(cn, Name.ebs_tickRefCount)); MethodNode method = AsmUtil.findMethod(cn, ""); @@ -24,14 +24,14 @@ public void transform(final ClassNode cn, final boolean obfuscated) { private void transformConstructor(final ClassNode cn, final MethodNode method, final boolean obfuscated) { final InsnList code = method.instructions; - final ListIterator iterator = (ListIterator) code.iterator(); + final ListIterator iterator = code.iterator(); if (iterator.hasNext()) { AbstractInsnNode insn = iterator.next(); insn = insn.getNext().getNext(); final InsnList toInsert = new InsnList(); - toInsert.add((AbstractInsnNode) new VarInsnNode(25, 0)); - toInsert.add((AbstractInsnNode) Name.hooks_create16BArray.staticInvocation(obfuscated)); - toInsert.add((AbstractInsnNode) new FieldInsnNode(181, cn.name, "block16BArray", "[S")); + toInsert.add(new VarInsnNode(25, 0)); + toInsert.add(Name.hooks_create16BArray.staticInvocation(obfuscated)); + toInsert.add(new FieldInsnNode(181, cn.name, "block16BArray", "[S")); method.instructions.insert(insn, toInsert); } method.maxStack = Math.max(method.maxStack, 2); @@ -40,12 +40,12 @@ private void transformConstructor(final ClassNode cn, final MethodNode method, f private void transformGetBlock(final ClassNode cn, final MethodNode method, final boolean obfuscated) { final InsnList code = method.instructions; code.clear(); - code.add((AbstractInsnNode) new VarInsnNode(25, 0)); - code.add((AbstractInsnNode) new VarInsnNode(21, 1)); - code.add((AbstractInsnNode) new VarInsnNode(21, 2)); - code.add((AbstractInsnNode) new VarInsnNode(21, 3)); - code.add((AbstractInsnNode) Name.hooks_getBlockById.staticInvocation(obfuscated)); - code.add((AbstractInsnNode) new InsnNode(176)); + code.add(new VarInsnNode(25, 0)); + code.add(new VarInsnNode(21, 1)); + code.add(new VarInsnNode(21, 2)); + code.add(new VarInsnNode(21, 3)); + code.add(Name.hooks_getBlockById.staticInvocation(obfuscated)); + code.add(new InsnNode(176)); method.localVariables = null; method.maxStack = 4; } @@ -53,7 +53,7 @@ private void transformGetBlock(final ClassNode cn, final MethodNode method, fina private void transformSetBlock(final ClassNode cn, final MethodNode method, final boolean obfuscated) { final InsnList code = method.instructions; int part = 0; - final ListIterator iterator = (ListIterator) code.iterator(); + final ListIterator iterator = code.iterator(); while (iterator.hasNext()) { final AbstractInsnNode insn = iterator.next(); if (part == 0) { @@ -62,17 +62,17 @@ private void transformSetBlock(final ClassNode cn, final MethodNode method, fina continue; } ++part; - iterator.add((AbstractInsnNode) new VarInsnNode(25, 0)); - iterator.add((AbstractInsnNode) new VarInsnNode(21, 1)); - iterator.add((AbstractInsnNode) new VarInsnNode(21, 2)); - iterator.add((AbstractInsnNode) new VarInsnNode(21, 3)); - iterator.add((AbstractInsnNode) Name.ebs_getBlock.virtualInvocation(obfuscated)); + iterator.add(new VarInsnNode(25, 0)); + iterator.add(new VarInsnNode(21, 1)); + iterator.add(new VarInsnNode(21, 2)); + iterator.add(new VarInsnNode(21, 3)); + iterator.add(Name.ebs_getBlock.virtualInvocation(obfuscated)); } else if (part == 1) { if (insn.getOpcode() != 184) { continue; } - iterator.set((AbstractInsnNode) new VarInsnNode(25, 6)); - iterator.add((AbstractInsnNode) Name.hooks_getIdFromBlockWithCheck.staticInvocation(obfuscated)); + iterator.set(new VarInsnNode(25, 6)); + iterator.add(Name.hooks_getIdFromBlockWithCheck.staticInvocation(obfuscated)); ++part; } else { iterator.remove(); @@ -81,14 +81,14 @@ private void transformSetBlock(final ClassNode cn, final MethodNode method, fina if (part != 2) { throw new AsmTransformException("no match for part " + part); } - code.add((AbstractInsnNode) new VarInsnNode(54, 5)); - code.add((AbstractInsnNode) new VarInsnNode(25, 0)); - code.add((AbstractInsnNode) new VarInsnNode(21, 1)); - code.add((AbstractInsnNode) new VarInsnNode(21, 2)); - code.add((AbstractInsnNode) new VarInsnNode(21, 3)); - code.add((AbstractInsnNode) new VarInsnNode(21, 5)); - code.add((AbstractInsnNode) Name.hooks_setBlockId.staticInvocation(obfuscated)); - code.add((AbstractInsnNode) new InsnNode(177)); + code.add(new VarInsnNode(54, 5)); + code.add(new VarInsnNode(25, 0)); + code.add(new VarInsnNode(21, 1)); + code.add(new VarInsnNode(21, 2)); + code.add(new VarInsnNode(21, 3)); + code.add(new VarInsnNode(21, 5)); + code.add(Name.hooks_setBlockId.staticInvocation(obfuscated)); + code.add(new InsnNode(177)); method.localVariables = null; --method.maxLocals; method.maxStack = Math.max(method.maxStack, 5); @@ -97,8 +97,8 @@ private void transformSetBlock(final ClassNode cn, final MethodNode method, fina private void transformGetBlockMSBArray(final ClassNode cn, final MethodNode method) { final InsnList code = method.instructions; code.clear(); - code.add((AbstractInsnNode) new InsnNode(1)); - code.add((AbstractInsnNode) new InsnNode(176)); + code.add(new InsnNode(1)); + code.add(new InsnNode(176)); method.localVariables = null; method.maxStack = 1; } @@ -106,10 +106,10 @@ private void transformGetBlockMSBArray(final ClassNode cn, final MethodNode meth private void transformRemoveInvalidBlocks(final ClassNode cn, final MethodNode method) { final InsnList code = method.instructions; code.clear(); - code.add((AbstractInsnNode) new VarInsnNode(25, 0)); - code.add((AbstractInsnNode) new MethodInsnNode( + code.add(new VarInsnNode(25, 0)); + code.add(new MethodInsnNode( 184, "ru/fewizz/idextender/Hooks", "removeInvalidBlocksHook", "(L" + cn.name + ";)V", false)); - code.add((AbstractInsnNode) new InsnNode(177)); + code.add(new InsnNode(177)); method.localVariables = null; method.maxStack = 1; } diff --git a/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaNetHandlerPlayClient.java b/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaNetHandlerPlayClient.java index 5ef416a..a34a932 100644 --- a/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaNetHandlerPlayClient.java +++ b/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaNetHandlerPlayClient.java @@ -10,7 +10,7 @@ public void transform(final ClassNode cn, final boolean obfuscated) { final MethodNode method = AsmUtil.findMethod(cn, Name.nhpc_handleMultiBlockChange); final InsnList code = method.instructions; int part = 0; - final ListIterator iterator = (ListIterator) code.iterator(); + final ListIterator iterator = code.iterator(); while (iterator.hasNext()) { AbstractInsnNode insn = iterator.next(); if (part == 0) { @@ -24,15 +24,14 @@ public void transform(final ClassNode cn, final boolean obfuscated) { } iterator.remove(); insn = iterator.next(); - iterator.set((AbstractInsnNode) new InsnNode(3)); + iterator.set(new InsnNode(3)); ++part; } else if (part == 2) { if (insn.getOpcode() != 21 || ((VarInsnNode) insn).var != 7) { continue; } - iterator.set((AbstractInsnNode) new VarInsnNode(25, 4)); - iterator.add((AbstractInsnNode) - new MethodInsnNode(182, "java/io/DataInputStream", "readShort", "()S", false)); + iterator.set(new VarInsnNode(25, 4)); + iterator.add(new MethodInsnNode(182, "java/io/DataInputStream", "readShort", "()S", false)); ++part; } else if (part == 3) { if (insn.getOpcode() == 54) { @@ -44,11 +43,10 @@ public void transform(final ClassNode cn, final boolean obfuscated) { if (insn.getOpcode() != 21 || ((VarInsnNode) insn).var != 7) { continue; } - iterator.set((AbstractInsnNode) new VarInsnNode(25, 4)); - iterator.add((AbstractInsnNode) - new MethodInsnNode(182, "java/io/DataInputStream", "readByte", "()B", false)); - iterator.add((AbstractInsnNode) new IntInsnNode(16, 15)); - iterator.add((AbstractInsnNode) new InsnNode(126)); + iterator.set(new VarInsnNode(25, 4)); + iterator.add(new MethodInsnNode(182, "java/io/DataInputStream", "readByte", "()B", false)); + iterator.add(new IntInsnNode(16, 15)); + iterator.add(new InsnNode(126)); ++part; } else { if (part != 5) { diff --git a/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaS21PacketChunkData.java b/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaS21PacketChunkData.java index fd99a29..26583f4 100644 --- a/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaS21PacketChunkData.java +++ b/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaS21PacketChunkData.java @@ -19,13 +19,13 @@ public void transform(final ClassNode cn, final boolean obfuscated) { private void transformCreateData(final ClassNode cn, final MethodNode method, final boolean obfuscated) { final InsnList code = method.instructions; - final ListIterator iterator = (ListIterator) code.iterator(); + final ListIterator iterator = code.iterator(); while (iterator.hasNext()) { final AbstractInsnNode insn = iterator.next(); if (insn.getOpcode() == 182) { final MethodInsnNode node = (MethodInsnNode) insn; if (Name.ebs_getBlockLSBArray.matches(node, obfuscated)) { - iterator.set((AbstractInsnNode) Name.hooks_getBlockData.staticInvocation(obfuscated)); + iterator.set(Name.hooks_getBlockData.staticInvocation(obfuscated)); return; } continue; diff --git a/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaS22PacketMultiBlockChange.java b/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaS22PacketMultiBlockChange.java index b43dd60..9a81b14 100644 --- a/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaS22PacketMultiBlockChange.java +++ b/src/main/java/ru/fewizz/idextender/asm/transformer/VanillaS22PacketMultiBlockChange.java @@ -10,14 +10,14 @@ public void transform(final ClassNode cn, final boolean obfuscated) { final MethodNode method = AsmUtil.findMethod(cn, Name.s22_init_server); final InsnList code = method.instructions; int part = 0; - final ListIterator iterator = (ListIterator) code.iterator(); + final ListIterator iterator = code.iterator(); while (iterator.hasNext()) { final AbstractInsnNode insn = iterator.next(); if (part == 0) { if (insn.getOpcode() != 7) { continue; } - iterator.set((AbstractInsnNode) new InsnNode(8)); + iterator.set(new InsnNode(8)); ++part; } else if (part == 1) { if (insn.getOpcode() != 184) { @@ -27,8 +27,7 @@ public void transform(final ClassNode cn, final boolean obfuscated) { if (!Name.block_getIdFromBlock.matches(node, obfuscated)) { continue; } - iterator.add((AbstractInsnNode) - new MethodInsnNode(182, "java/io/DataOutputStream", "writeShort", "(I)V", false)); + iterator.add(new MethodInsnNode(182, "java/io/DataOutputStream", "writeShort", "(I)V", false)); ++part; } else if (part == 2) { if (insn.getOpcode() == 25) { @@ -40,10 +39,9 @@ public void transform(final ClassNode cn, final boolean obfuscated) { if (insn.getOpcode() != 182) { continue; } - iterator.add((AbstractInsnNode) new VarInsnNode(25, 6)); - iterator.add((AbstractInsnNode) new InsnNode(95)); - iterator.add((AbstractInsnNode) - new MethodInsnNode(182, "java/io/DataOutputStream", "writeByte", "(I)V", false)); + iterator.add(new VarInsnNode(25, 6)); + iterator.add(new InsnNode(95)); + iterator.add(new MethodInsnNode(182, "java/io/DataOutputStream", "writeByte", "(I)V", false)); ++part; } else { iterator.remove();