Jump to content

Recommended Posts

Posted

So Im sending a packet to the server. And then all of a sudden I get this error as soon as I send the packet...

 

io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: index: 1, length: 57 (expected: range(0, 40))
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:99) ~[MessageToMessageDecoder.class:?]
at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:?]
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) [DefaultChannelPipeline.class:?]
at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) [EmbeddedChannel.class:?]
at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:86) [FMLProxyPacket.class:?]
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?]
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?]
Caused by: java.lang.IndexOutOfBoundsException: index: 1, length: 57 (expected: range(0, 40))
at io.netty.buffer.AbstractByteBuf.checkIndex(AbstractByteBuf.java:1128) ~[AbstractByteBuf.class:?]
at io.netty.buffer.SlicedByteBuf.nioBuffer(SlicedByteBuf.java:261) ~[slicedByteBuf.class:?]
at io.netty.buffer.AbstractByteBuf.toString(AbstractByteBuf.java:953) ~[AbstractByteBuf.class:?]
at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:119) ~[byteBufUtils.class:?]
at com.starwarsmace.healthbeam.ChangeHealth.fromBytes(ChangeHealth.java:33) ~[ChangeHealth.class:?]
at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.decodeInto(SimpleIndexedCodec.java:17) ~[simpleIndexedCodec.class:?]
at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.decodeInto(SimpleIndexedCodec.java:7) ~[simpleIndexedCodec.class:?]
at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:77) ~[FMLIndexedMessageToMessageCodec.class:?]
at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:17) ~[FMLIndexedMessageToMessageCodec.class:?]
at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:?]
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) ~[MessageToMessageDecoder.class:?]
... 13 more
[17:29:11] [server thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception
io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: index: 1, length: 57 (expected: range(0, 40))
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:99) ~[MessageToMessageDecoder.class:?]
at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:?]
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) [DefaultChannelPipeline.class:?]
at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) [EmbeddedChannel.class:?]
at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:86) [FMLProxyPacket.class:?]
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?]
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?]
Caused by: java.lang.IndexOutOfBoundsException: index: 1, length: 57 (expected: range(0, 40))
at io.netty.buffer.AbstractByteBuf.checkIndex(AbstractByteBuf.java:1128) ~[AbstractByteBuf.class:?]
at io.netty.buffer.SlicedByteBuf.nioBuffer(SlicedByteBuf.java:261) ~[slicedByteBuf.class:?]
at io.netty.buffer.AbstractByteBuf.toString(AbstractByteBuf.java:953) ~[AbstractByteBuf.class:?]
at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:119) ~[byteBufUtils.class:?]
at com.starwarsmace.healthbeam.ChangeHealth.fromBytes(ChangeHealth.java:33) ~[ChangeHealth.class:?]
at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.decodeInto(SimpleIndexedCodec.java:17) ~[simpleIndexedCodec.class:?]
at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.decodeInto(SimpleIndexedCodec.java:7) ~[simpleIndexedCodec.class:?]
at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:77) ~[FMLIndexedMessageToMessageCodec.class:?]
at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:17) ~[FMLIndexedMessageToMessageCodec.class:?]
at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:?]
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) ~[MessageToMessageDecoder.class:?]
... 13 more
[17:29:11] [server thread/ERROR] [FML]: There was a critical exception handling a packet on channel ChangeHealth
io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: index: 1, length: 57 (expected: range(0, 40))
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:99) ~[MessageToMessageDecoder.class:?]
at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:?]
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) ~[DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) ~[DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) ~[DefaultChannelPipeline.class:?]
at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) ~[EmbeddedChannel.class:?]
at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:86) [FMLProxyPacket.class:?]
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?]
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?]
Caused by: java.lang.IndexOutOfBoundsException: index: 1, length: 57 (expected: range(0, 40))
at io.netty.buffer.AbstractByteBuf.checkIndex(AbstractByteBuf.java:1128) ~[AbstractByteBuf.class:?]
at io.netty.buffer.SlicedByteBuf.nioBuffer(SlicedByteBuf.java:261) ~[slicedByteBuf.class:?]
at io.netty.buffer.AbstractByteBuf.toString(AbstractByteBuf.java:953) ~[AbstractByteBuf.class:?]
at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:119) ~[byteBufUtils.class:?]
at com.starwarsmace.healthbeam.ChangeHealth.fromBytes(ChangeHealth.java:33) ~[ChangeHealth.class:?]
at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.decodeInto(SimpleIndexedCodec.java:17) ~[simpleIndexedCodec.class:?]
at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.decodeInto(SimpleIndexedCodec.java:7) ~[simpleIndexedCodec.class:?]
at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:77) ~[FMLIndexedMessageToMessageCodec.class:?]
at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:17) ~[FMLIndexedMessageToMessageCodec.class:?]
at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:?]
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) ~[MessageToMessageDecoder.class:?]
... 13 more
[17:29:11] [server thread/ERROR] [FML]: FMLIndexedMessageCodec exception caught
io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: index: 1, length: 57 (expected: range(0, 40))
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:99) ~[MessageToMessageDecoder.class:?]
at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:?]
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) [DefaultChannelPipeline.class:?]
at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) [EmbeddedChannel.class:?]
at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:86) [FMLProxyPacket.class:?]
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?]
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?]
Caused by: java.lang.IndexOutOfBoundsException: index: 1, length: 57 (expected: range(0, 40))
at io.netty.buffer.AbstractByteBuf.checkIndex(AbstractByteBuf.java:1128) ~[AbstractByteBuf.class:?]
at io.netty.buffer.SlicedByteBuf.nioBuffer(SlicedByteBuf.java:261) ~[slicedByteBuf.class:?]
at io.netty.buffer.AbstractByteBuf.toString(AbstractByteBuf.java:953) ~[AbstractByteBuf.class:?]
at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:119) ~[byteBufUtils.class:?]
at com.starwarsmace.healthbeam.ChangeHealth.fromBytes(ChangeHealth.java:33) ~[ChangeHealth.class:?]
at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.decodeInto(SimpleIndexedCodec.java:17) ~[simpleIndexedCodec.class:?]
at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.decodeInto(SimpleIndexedCodec.java:7) ~[simpleIndexedCodec.class:?]
at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:77) ~[FMLIndexedMessageToMessageCodec.class:?]
at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:17) ~[FMLIndexedMessageToMessageCodec.class:?]
at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:?]
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) ~[MessageToMessageDecoder.class:?]
... 13 more
[17:29:11] [server thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception
io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: index: 1, length: 57 (expected: range(0, 40))
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:99) ~[MessageToMessageDecoder.class:?]
at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:?]
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) [DefaultChannelPipeline.class:?]
at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) [EmbeddedChannel.class:?]
at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:86) [FMLProxyPacket.class:?]
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?]
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?]
Caused by: java.lang.IndexOutOfBoundsException: index: 1, length: 57 (expected: range(0, 40))
at io.netty.buffer.AbstractByteBuf.checkIndex(AbstractByteBuf.java:1128) ~[AbstractByteBuf.class:?]
at io.netty.buffer.SlicedByteBuf.nioBuffer(SlicedByteBuf.java:261) ~[slicedByteBuf.class:?]
at io.netty.buffer.AbstractByteBuf.toString(AbstractByteBuf.java:953) ~[AbstractByteBuf.class:?]
at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:119) ~[byteBufUtils.class:?]
at com.starwarsmace.healthbeam.ChangeHealth.fromBytes(ChangeHealth.java:33) ~[ChangeHealth.class:?]
at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.decodeInto(SimpleIndexedCodec.java:17) ~[simpleIndexedCodec.class:?]
at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.decodeInto(SimpleIndexedCodec.java:7) ~[simpleIndexedCodec.class:?]
at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:77) ~[FMLIndexedMessageToMessageCodec.class:?]
at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:17) ~[FMLIndexedMessageToMessageCodec.class:?]
at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:?]
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) ~[MessageToMessageDecoder.class:?]
... 13 more
[17:29:11] [server thread/ERROR] [FML]: There was a critical exception handling a packet on channel ChangeHealth
io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: index: 1, length: 57 (expected: range(0, 40))
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:99) ~[MessageToMessageDecoder.class:?]
at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:?]
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) ~[DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) ~[DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) ~[DefaultChannelPipeline.class:?]
at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) ~[EmbeddedChannel.class:?]
at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:86) [FMLProxyPacket.class:?]
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?]
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?]
Caused by: java.lang.IndexOutOfBoundsException: index: 1, length: 57 (expected: range(0, 40))
at io.netty.buffer.AbstractByteBuf.checkIndex(AbstractByteBuf.java:1128) ~[AbstractByteBuf.class:?]
at io.netty.buffer.SlicedByteBuf.nioBuffer(SlicedByteBuf.java:261) ~[slicedByteBuf.class:?]
at io.netty.buffer.AbstractByteBuf.toString(AbstractByteBuf.java:953) ~[AbstractByteBuf.class:?]
at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:119) ~[byteBufUtils.class:?]
at com.starwarsmace.healthbeam.ChangeHealth.fromBytes(ChangeHealth.java:33) ~[ChangeHealth.class:?]
at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.decodeInto(SimpleIndexedCodec.java:17) ~[simpleIndexedCodec.class:?]
at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.decodeInto(SimpleIndexedCodec.java:7) ~[simpleIndexedCodec.class:?]
at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:77) ~[FMLIndexedMessageToMessageCodec.class:?]
at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:17) ~[FMLIndexedMessageToMessageCodec.class:?]
at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:?]
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) ~[MessageToMessageDecoder.class:?]
... 13 more

 

What did I go out of bounds with? All I did was use ByteBufUtils.writeUTF8String and read it

 

My packet code:

 

public class ChangeHealth implements IMessage {
private String uuid;
public ChangeHealth(){}
public ChangeHealth(String uuid) {
	super();
	this.uuid=uuid;
}
public String getMessage(){
	return this.uuid;
}
@Override
public void toBytes(ByteBuf buf) {
	ByteBufUtils.writeUTF8String(buf, this.uuid);

}
@Override
public void fromBytes(ByteBuf buf) {

	this.uuid=ByteBufUtils.readUTF8String(buf);
}


public static class ChangeHealthHandler implements IMessageHandler<ChangeHealth, IMessage>{

	@SuppressWarnings("unchecked")
	@Override
	public IMessage onMessage(ChangeHealth message, MessageContext ctx) {
		String b = message.getMessage().split(":")[1];
		String uuid = message.getMessage().split(":")[0];
		EntityPlayer healer = null;
		for(EntityPlayer player : (List<EntityPlayer>)MinecraftServer.getServer().getConfigurationManager().playerEntityList){
			if(player.getUniqueID().toString()==uuid){
				healer=player;
				break;
			}
		}

		if(b=="add"){
			if(healer!=null){
				HealthBeamHandler.addHealer(healer);

			}else{
				return null;
			}
		}else{
			if(healer!=null){
				HealthBeamHandler.removeHealer(UUID.fromString(uuid));

			}else{
				return null;
			}
		}
		return null;
	}

}
}

 

Note: Used a nested class for the handler

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Posted

Flaws of your code:

 

1. Separate Message and Handler to different classes. (Belive me, in some cases this saves you from very hard to notice bug).

 

2. Don't use UUID! Not only a waste of bytes sent, but just bad.

To send entity reference through packet you want to use entity ID.

On IMessage

entity.getEntityId();

And write it into buffer (int).

On receiver:

Entity e = world.getEntityByID(msg.entityId);

 

Also - send stuff like "add" in bytes (0, 1, 2 for example).

 

EDIT: Additional info:

As to sending string - pack it into NBT and send whole NBT.

ByteBufUtils.writeTag(buffer, NBTTag);

As to UUID - it is a 2x longs - you can UUID.getLeastSignificantBits() and .getMostSignificantBits(), you can write UUID to NBT or send as longs and recreate it on receiver.

 

Side note: NEVER use UUID for anything other than presistent data (HDD saves), unless you have to ofc. (attribute modifiers are example, which in my opinion are coded simply badly).

1.7.10 is no longer supported by forge, you are on your own.

Posted

Flaws of your code:

 

1. Separate Message and Handler to different classes. (Belive me, in some cases this saves you from very hard to notice bug).

 

2. Don't use UUID! Not only a waste of bytes sent, but just bad.

To send entity reference through packet you want to use entity ID.

On IMessage

entity.getEntityId();

And write it into buffer (int).

On receiver:

Entity e = world.getEntityByID(msg.entityId);

 

Also - send stuff like "add" in bytes (0, 1, 2 for example).

 

EDIT: Additional info:

As to sending string - pack it into NBT and send whole NBT.

ByteBufUtils.writeTag(buffer, NBTTag);

As to UUID - it is a 2x longs - you can UUID.getLeastSignificantBits() and .getMostSignificantBits(), you can write UUID to NBT or send as longs and recreate it on receiver.

 

Side note: NEVER use UUID for anything other than presistent data (HDD saves), unless you have to ofc. (attribute modifiers are example, which in my opinion are coded simply badly).

1. Oh alright then.

 

2. Well I am using UUID because I am going to be having things being sent in from bukkit and into forge. Unless bukkit has some entity.getEntityId that I haven't noticed I was going to use UUID.

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Posted

If bukkit doesn't have IDs then you would have to make ("sending a packet to the server"): ClientMod---(send entityID)--->ServerForgeMod(read entity id)---(pass entity instance)--->Bukkit(operate).

 

And from what I remember bukkit doesn't have it because it is only server-sided, who would use those IDs?

1.7.10 is no longer supported by forge, you are on your own.

Posted

The UUID is not going to work, since the Client (afaik) does not know the UUID of an Entity. I don't know the bukkit API, but most likely it does not have an entityID method.

Actually, there is another packet that receives the packet from Bukkit and that packet passes almost the same message to this packet(which goes to the server).

 

Also, there is no forge to bukkit sending involved. Just bukkit to forge and forge to forge.

 

Also, does the crash have something to do with the UUID being long?

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Posted

First of all your packet code is horrible. Don't send things as Strings that aren't strings. Don't send things as one big String. Send individual data.

Also: You cannot compare Strings with ==, it will almost always be false.

 

The crash is probably because Forge packets have a packetID prepended (as a byte). You need to make sure to send that one from bukkit as well.

 

Bukkit to forge meaning server to client? Thats as I said not gonna work most likely, but I dont know the bukkit api very well. Unless they do have an EntityID getter you have to use proprietary methods and call into the net.minecraft packages.

 

I guess you are right about my packet code being horrible...

 

And that == with Strings happens when youre up coding at 2AM and have no idea what the heck youre doing. Otherwise Im done with those java noob mistakes :D

 

Second:

 

For now Im just checking whether my other code is working(the one on forge) so Im not using bukkit right now. Im just using an item to send that packet to test whether the other parts of my mods work...

 

Question:

So is the UUID's getLeastSignificantBits() the first 64 of the 128.

and the getMostSignificantBits is the second 64 of the 128?

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Posted

ok...

I think I figured out how to make the uuid into two longs and into an nbt.

 

public class ChangeHealth implements IMessage {
private UUID uuid;
private boolean add;
public ChangeHealth(){}
public ChangeHealth(UUID uuid,boolean add) {
	super();
	this.uuid=uuid;
	this.add = add;
}

@Override
public void toBytes(ByteBuf buf) {
	NBTTagCompound n = new NBTTagCompound();
	n.setLong("least", this.uuid.getLeastSignificantBits());
	n.setLong("most", this.uuid.getMostSignificantBits());
	n.setBoolean("add", this.add);
	ByteBufUtils.writeTag(buf, n);

}
@Override
public void fromBytes(ByteBuf buf) {

	NBTTagCompound n =ByteBufUtils.readTag(buf);
	this.uuid= new UUID(n.getLong("most"),n.getLong("least"));
	this.add=n.getBoolean("add");
}

}

 

Then in my code for the handler I do this:

 

@Override
	public IMessage onMessage(ChangeHealth message, MessageContext ctx) {
		EntityPlayer healer = null;
		for(EntityPlayer player : (List<EntityPlayer>)MinecraftServer.getServer().getConfigurationManager().playerEntityList){
			if(player.getUniqueID().equals(message.uuid)){
				healer=player;
				break;
			}
		}

		if(message.add){
			if(healer!=null){
				HealthBeamHandler.addHealer(healer);

			}else{
				return null;
			}
		}else{
			if(healer!=null){
				HealthBeamHandler.removeHealer(message.uuid);

			}else{
				return null;
			}
		}
		return null;
	}

 

I think that might work...

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Posted

Jesus mercy...

Seriously?

 

Writing:

 

buf.writeLong(uuid.getLeastSignificantBits());
buf.writeLong(uuid.getMostSignificantBits());

 

Reading:

 

long lsb = buf.readLong(),
long msb = buf.readLong();
UUID uuid = new UUID(msb, lsb);

 

But as I said before: This will not work. The UUID is different on the client.

Jesus mercy...

Seriously?

 

Writing:

 

buf.writeLong(uuid.getLeastSignificantBits());
buf.writeLong(uuid.getMostSignificantBits());

 

Reading:

 

long lsb = buf.readLong(),
long msb = buf.readLong();
UUID uuid = new UUID(msb, lsb);

 

But as I said before: This will not work. The UUID is different on the client.

 

1. Following what Ernio was saying with the nbt...

EDIT: Additional info:

As to sending string - pack it into NBT and send whole NBT.

ByteBufUtils.writeTag(buffer, NBTTag);

As to UUID - it is a 2x longs - you can UUID.getLeastSignificantBits() and .getMostSignificantBits(), you can write UUID to NBT or send as longs and recreate it on receiver.

I mean he did say to do it for sending strings but... I thought it would apply to other things too

 

2. Im not working with the client currently. The client is just for receiving the bukkit message and passing it onto another packet which sends it to the forge server. So that UUID is fine.

 

3. Tested out my code and it worked... Though your writing and reading is probably more efficient.

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Posted

I mean he did say to do it for sending strings but... I thought it would apply to other things too

Not sure what Ernio was up to there. Don't send NBT in packets.

2. Im not working with the client currently. The client is just for receiving the bukkit message and passing it onto another packet which sends it to the forge server. So that UUID is fine.

If you are not working with the client, then what are you doing with packets? Packets go client to server or server to client. Nothing else.

3. Tested out my code and it worked... Though your writing and reading is probably more efficient.

I am very curious as to what the fuck you are doing to make that code work.

 

1. Alright then....

 

2.  I can't seem to have the forge server receive the packets from bukkit. I'm just using forge client as a way of receiving it.

 

3. What code?

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Posted

My humble explanation:

That NBT thingy was a total side-note (a fact that might be used). And:

"As to UUID - it is a 2x longs - you can UUID.getLeastSignificantBits() and .getMostSignificantBits(), you can write UUID to NBT or send as longs and recreate it on receiver."

 

That might have been confusing, I give you that. But yeah, sending NBT is rather a trick if you don't care about few extra symbols and you alredy have some NBT write/read methods. (e.g you encode NBT of IExtendedEntityProperties and read it on client using readNBT, or other example is simply sending ItemStack as NBT - which I think MC doeas itself). In this case - sure, write longs directly.

 

Note: I still have not a damn idea what are you after. :P

1.7.10 is no longer supported by forge, you are on your own.

Posted

2.  I can't seem to have the forge server receive the packets from bukkit.
Of course not. The server cannot send packets to itself. Just call the methods in your Bukkit plugin directly, they are running on the same machine, in the same JVM.

How would I call the methods though? There is no communication going on between bukkit and forge right?

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Posted

No, there is not. But they still run on the same machine, in the same Java process. You can access one from the other just fine. Either use reflection or figure out a way to have your plugin code accessible to your forge code when building and vice versa.

Could using server commands and have them called in bukkit a good way?

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Posted

No...

Just call a method. Like any other method.

Well yes...

But instead of using reflection, I could call a server command that I made in forge on bukkit and then that calls whatever I need to call...

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Posted

Not really the nicest of ways to be honest.

Not the nicest...

Not the best....

But it works :D

 

And the player can't run it because its a server command...

 

Edit: Another question: Would reflection really be better than this idea?

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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