aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/handlers/PacketHandler.java
blob: a4fd85e27dca6e365c246649eee990025f61b62f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package me.Danker.handlers;

import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext;
import me.Danker.utils.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S04PacketEntityEquipment;

import java.lang.reflect.Field;

public class PacketHandler extends ChannelDuplexHandler {
	
	// Spirit boots fix
	@Override
	public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
		if (Utils.inSkyblock && msg instanceof Packet && msg.getClass().getName().endsWith("S04PacketEntityEquipment")) { // Inventory packet name
			S04PacketEntityEquipment packet = (S04PacketEntityEquipment) msg;
			if (packet.getEntityID() == Minecraft.getMinecraft().thePlayer.getEntityId()) {
				Field slot = packet.getClass().getDeclaredField("field_149392_b"); // equipmentSlot
				slot.setAccessible(true);
				slot.setInt(packet, slot.getInt(packet) + 1);
				msg = packet;
			}
		}
		
		super.channelRead(ctx, msg);
	}
	
}