aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/me')
-rw-r--r--src/main/java/me/Danker/TheMod.java12
-rw-r--r--src/main/java/me/Danker/handlers/PacketHandler.java31
2 files changed, 43 insertions, 0 deletions
diff --git a/src/main/java/me/Danker/TheMod.java b/src/main/java/me/Danker/TheMod.java
index 3bb11cf..fa327fe 100644
--- a/src/main/java/me/Danker/TheMod.java
+++ b/src/main/java/me/Danker/TheMod.java
@@ -45,6 +45,7 @@ import me.Danker.gui.EditLocationsGui;
import me.Danker.gui.OnlySlayerGui;
import me.Danker.handlers.APIHandler;
import me.Danker.handlers.ConfigHandler;
+import me.Danker.handlers.PacketHandler;
import me.Danker.handlers.ScoreboardHandler;
import me.Danker.handlers.TextRenderer;
import me.Danker.utils.Utils;
@@ -86,6 +87,7 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
+import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent;
import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion;
@Mod(modid = TheMod.MODID, version = TheMod.VERSION, clientSideOnly = true)
@@ -124,6 +126,7 @@ public class TheMod
public void init(FMLInitializationEvent event) {
FMLCommonHandler.instance().bus().register(this);
MinecraftForge.EVENT_BUS.register(this);
+ MinecraftForge.EVENT_BUS.register(new PacketHandler());
final ConfigHandler cf = new ConfigHandler();
cf.reloadConfig();
@@ -2034,6 +2037,15 @@ public class TheMod
}
}
+ @SubscribeEvent
+ public void onServerConnect(ClientConnectedToServerEvent event) {
+ if (!PacketHandler.added) {
+ event.manager.channel().pipeline().addBefore("packet_handler", "danker_packet_handler", new PacketHandler());
+ PacketHandler.added = true;
+ System.out.println("Added packet handler to channel pipeline.");
+ }
+ }
+
public void increaseSeaCreatures() {
LootCommand lc = new LootCommand();
ConfigHandler cf = new ConfigHandler();
diff --git a/src/main/java/me/Danker/handlers/PacketHandler.java b/src/main/java/me/Danker/handlers/PacketHandler.java
new file mode 100644
index 0000000..56bbc24
--- /dev/null
+++ b/src/main/java/me/Danker/handlers/PacketHandler.java
@@ -0,0 +1,31 @@
+package me.Danker.handlers;
+
+import java.lang.reflect.Field;
+
+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;
+
+public class PacketHandler extends ChannelDuplexHandler {
+
+ public static boolean added = false;
+
+ @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);
+ }
+
+}