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

I start the server side in eclipse and then the client join the server excute a keybind, that gives me a new item and I need a packet to let the server know whats going on. So I got one and it works fine for singleplayer when before it would just switch back to nothing this is the error I get when sending the packet in singleplayer or multiplayer.

 

2013-10-04 16:11:21 [iNFO] [sTDERR] java.io.EOFException
2013-10-04 16:11:21 [iNFO] [sTDERR] at java.io.DataInputStream.readByte(Unknown Source)
2013-10-04 16:11:21 [iNFO] [sTDERR] at JangosMods.StarWarsSimpleMod.common.network.packet.PacketItemUpdate.readData(PacketItemUpdate.java:51)
2013-10-04 16:11:21 [iNFO] [sTDERR] at JangosMods.StarWarsSimpleMod.common.network.packet.PacketSWSMJ.readPopulate(PacketSWSMJ.java:44)
2013-10-04 16:11:21 [iNFO] [sTDERR] at JangosMods.StarWarsSimpleMod.common.network.PacketTypeHandler.buildPacket(PacketTypeHandler.java:44)
2013-10-04 16:11:21 [iNFO] [sTDERR] at JangosMods.StarWarsSimpleMod.common.network.PacketHandler.onPacketData(PacketHandler.java:25)
2013-10-04 16:11:21 [iNFO] [sTDERR] at cpw.mods.fml.common.network.NetworkRegistry.handlePacket(NetworkRegistry.java:255)
2013-10-04 16:11:21 [iNFO] [sTDERR] at cpw.mods.fml.common.network.NetworkRegistry.handleCustomPacket(NetworkRegistry.java:245)
2013-10-04 16:11:21 [iNFO] [sTDERR] at cpw.mods.fml.common.network.FMLNetworkHandler.handlePacket250Packet(FMLNetworkHandler.java:84)
2013-10-04 16:11:21 [iNFO] [sTDERR] at net.minecraft.network.NetServerHandler.handleCustomPayload(NetServerHandler.java:1111)
2013-10-04 16:11:21 [iNFO] [sTDERR] at net.minecraft.network.packet.Packet250CustomPayload.processPacket(Packet250CustomPayload.java:70)
2013-10-04 16:11:21 [iNFO] [sTDERR] at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89)
2013-10-04 16:11:21 [iNFO] [sTDERR] at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:141)
2013-10-04 16:11:21 [iNFO] [sTDERR] at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:54)
2013-10-04 16:11:21 [iNFO] [sTDERR] at net.minecraft.server.integrated.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:109)
2013-10-04 16:11:21 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:689)
2013-10-04 16:11:21 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:585)
2013-10-04 16:11:21 [iNFO] [sTDERR] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)
2013-10-04 16:11:21 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482)
2013-10-04 16:11:21 [iNFO] [sTDERR] at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)

 

This is the packet handler

 

public class PacketHandler implements IPacketHandler {

@Override
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
     // Build a PacketEE object from the data contained within the Packet250CustomPayload packet
     PacketSWSMJ packetEE = PacketTypeHandler.buildPacket(packet.data);
     // Execute the appropriate actions based on the PacketEE type
     packetEE.execute(manager, player);
    
if (packet.data != null && packet.data.length == 1 && packet.data[0] == 2) {
ArrayList<ItemStack> itemListToSend = new ArrayList<ItemStack>();
EntityPlayerMP thePlayer = (EntityPlayerMP) player;
thePlayer.inventory.setInventorySlotContents(Minecraft.getMinecraft().thePlayer.inventory.currentItem, new ItemStack(modItems.lightsaberON.itemID, 1, (Minecraft.getMinecraft().thePlayer.inventory.getStackInSlot(Minecraft.getMinecraft().thePlayer.inventory.currentItem).getItemDamage())));
for (int i = 0; i < thePlayer.openContainer.inventorySlots.size(); ++i) {
itemListToSend.add(((Slot) thePlayer.openContainer.inventorySlots.get(i)).getStack());
            
}
thePlayer.sendContainerAndContentsToPlayer(thePlayer.openContainer, itemListToSend);
}

if (packet.data != null && packet.data.length == 1 && packet.data[0] == 1) {
ArrayList<ItemStack> itemListToSend = new ArrayList<ItemStack>();
EntityPlayerMP thePlayer = (EntityPlayerMP) player;
thePlayer.inventory.setInventorySlotContents(Minecraft.getMinecraft().thePlayer.inventory.currentItem, new ItemStack(modItems.lightsaber.itemID, 1, (Minecraft.getMinecraft().thePlayer.inventory.getStackInSlot(Minecraft.getMinecraft().thePlayer.inventory.currentItem).getItemDamage())));
for (int i = 0; i < thePlayer.openContainer.inventorySlots.size(); ++i) {
itemListToSend.add(((Slot) thePlayer.openContainer.inventorySlots.get(i)).getStack());
            
}
thePlayer.sendContainerAndContentsToPlayer(thePlayer.openContainer, itemListToSend);
}
}
}

 

The code that sends the packet

 

@Override
public void doKeyBindingAction(EntityPlayer thePlayer, ItemStack itemStack, String keyBinding)
{
int CurrentItem = Minecraft.getMinecraft().thePlayer.inventory.currentItem;
ItemStack ItemInHand = Minecraft.getMinecraft().thePlayer.inventory.getStackInSlot(CurrentItem);
    
if (keyBinding.equals(ConfigurationSettings.LIGHTSABER_ONOFF))
{
PacketDispatcher.sendPacketToServer(new Packet250CustomPayload(Reference.CHANNEL_NAME, new byte[] { 2 }));
     }


    

}

 

Server side error

[sEVERE] Encountered an unexpected exception AbstractMethodError
java.lang.AbstractMethodError: JangosMods.StarWarsSimpleMod.common.Items.ItemLightsaber.doKeyBindingAction(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/item/ItemStack;Ljava/lang/String;)V
at JangosMods.StarWarsSimpleMod.common.network.packet.PacketKeyPressed.execute(PacketKeyPressed.java:48)
at JangosMods.StarWarsSimpleMod.common.network.PacketHandler.onPacketData(PacketHandler.java:28)
at cpw.mods.fml.common.network.NetworkRegistry.handlePacket(NetworkRegistry.java:255)
at cpw.mods.fml.common.network.NetworkRegistry.handleCustomPacket(NetworkRegistry.java:245)
at cpw.mods.fml.common.network.FMLNetworkHandler.handlePacket250Packet(FMLNetworkHandler.java:84)
at net.minecraft.network.NetServerHandler.handleCustomPayload(NetServerHandler.java:1111)
at net.minecraft.network.packet.Packet250CustomPayload.processPacket(Packet250CustomPayload.java:70)
at net.minecraft.network.TcpConnection.processReadPackets(TcpConnection.java:462)
at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:141)
at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:54)
at net.minecraft.server.dedicated.DedicatedServerListenThread.networkTick(DedicatedServerListenThread.java:34)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:689)
at net.minecraft.server.dedicated.DedicatedServer.updateTimeLightAndEntities(DedicatedServer.java:275)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:585)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482)
at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)

 

 

any ideas?

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.