Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hi,

 

I'm trying to make a coremod (to update my tile entity's nbt when an S35PacketUpdateTileEntity is received) since Forge isn't out for 1.8 yet and I have run into a problem with Labels. I need to jump to an existing label, and I'm not sure how. Anyone know how to do this? Heres my code:

@Override
public byte[] transform(String name, String transformedName, byte[] clazz) {
	if (name.equals(NHPCName.replace("/", "."))){
		ClassNode classnode = CoreUtils.getClassNode(clazz);
		MethodNode teMethodNode = CoreUtils.getMethodNode(classnode, handleUpdateTileEntityName, "(Lnet/minecraft/network/play/server/S35PacketUpdateTileEntity;)V");

		InsnList instructions = new InsnList();

		instructions.add(new VarInsnNode(Opcodes.ALOAD, 2));
		instructions.add(new TypeInsnNode(Opcodes.INSTANCEOF, "com/eternaldoom/realmsofchaos/blocks/TileEntityDisplayCase"));
		Label l7 = new Label();
		instructions.add(new JumpInsnNode(Opcodes.IFNE, new LabelNode(l7)));	

		teMethodNode.instructions.insertBefore(getInsertionPoint(teMethodNode), instructions);
    }
	return clazz;
}

I'm trying to patch this method in NetHandlerPlayClient:

public void handleUpdateTileEntity(S35PacketUpdateTileEntity packetIn)
    {
        PacketThreadUtil.func_180031_a(packetIn, this, this.gameController);

        if (this.gameController.theWorld.isBlockLoaded(packetIn.func_179823_a()))
        {
            TileEntity tileentity = this.gameController.theWorld.getTileEntity(packetIn.func_179823_a());
            int i = packetIn.getTileEntityType();

            if (i == 1 && tileentity instanceof TileEntityMobSpawner || i == 2 && tileentity instanceof TileEntityCommandBlock || i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || i == 5 && tileentity instanceof TileEntityFlowerPot || i == 6 && tileentity instanceof TileEntityBanner)
            {
                tileentity.readFromNBT(packetIn.getNbtCompound());
            }
        }
    }

I just need to add my tile entity to the if statement. The problem is, I need to jump to the label L7 (tileentity.readFromNBT) and I can't figure out how.

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

  • Author

Never mind, that was a stupid question, all I had to do was call a method in my class. Heres my code if anyone is interested:

if (name.equals(netHandlerPlayClientName.replace("/", "."))){
		ClassNode classnode = CoreUtils.getClassNode(clazz);
		MethodNode teMethodNode = CoreUtils.getMethodNode(classnode, handleUpdateTileEntityName, "(Lnet/minecraft/network/play/server/S35PacketUpdateTileEntity;)V");

		InsnList instructions = new InsnList();

		instructions.add(new VarInsnNode(Opcodes.ALOAD, 2));
		instructions.add(new VarInsnNode(Opcodes.ALOAD, 1));
		instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/eternaldoom/realmsofchaos/asm/CoreMethods", "handleTileEntityPackets", "(Lnet/minecraft/tileentity/TileEntity;Lnet/minecraft/network/play/server/S35PacketUpdateTileEntity;)V", false));

		teMethodNode.instructions.insertBefore(getTEInsertionPoint(teMethodNode), instructions);
		return CoreUtils.getBytes(classnode);
    }

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.