Jump to content

[SOLVED] Change NBT tag of ItemStack in container from GUI


Recommended Posts

Posted

hello

 

I'm trying to change a tag in the NBT data of an itemstack that is in a container from a gui (on the press of a button).

 

when the button is pressed, the packet seems to be successfully sent and processed, but nothing happens.

 

Packet/handler

 

  Reveal hidden contents

 

 

TileEntity

 

  Reveal hidden contents

 

 

Container

 

  Reveal hidden contents

 

 

GUI

 

  Reveal hidden contents

 

 

I can't figure what is not working, please help.

 

EDIT: forge 1.7.10 (1.7.10-10.13.0.1188)

Posted

When you say nothing happens, are you logging the expected changes on the server or client?

 

In my example, I send the updated info back to the client as the return to the Imessage (another packet)

 

@Override
        public IMessage onMessage(ChangeCostUp message, MessageContext ctx) {
        	
        	EntityPlayer player = ctx.getServerHandler().playerEntity;
        	ContainerShop container = (ContainerShop)player.openContainer;     
            
        	container.tileEntity.Cost++;
        	if(container.tileEntity.Cost > 144) container.tileEntity.Cost = 144;
        	player.worldObj.markBlockForUpdate(container.tileEntity.xCoord, container.tileEntity.yCoord, container.tileEntity.zCoord);
        	container.tileEntity.markDirty();        	
        	
        	return new SendCost((short) container.tileEntity.Cost); 
        }

 

whether you are updating a field (in my case) or NBT (yours) the situation should be the same.

I'll need help, and I'll give help. Just ask, you know I will!

Posted

..to clarify my example, the client has a gui open, presses a button, and then this packet is sent to the server for processing, where the value is changed. I returned a packet to update the client from this, where you are only returning null. Guis sit on the client alone, and so will not be updating automatically. Again, my first question would be where are you watching the value to which nothing is happening?

I'll need help, and I'll give help. Just ask, you know I will!

Posted
  Quote
where are you watching the value to which nothing is happening

 

I'm not sure... I would guess on the client (the item in question changes its rendering depending on the NBT, and it does not change when the button is pressed). that said, it is not updated on world reload either.

 

I see I don't mark the tileentity as dirty, I'll try that...

 

also, out of curiosity, how do you handle your SendCost packet (reply) on the client?

Posted

return new SendCost((short) container.tileEntity.Cost);

 

In this scenario, SendCost is just another packet, registered on the client side, not the server. So just like any other packet.

 

network.registerMessage(PacketToServer.Handler.class, PacketToServer.class, 0, Side.SERVER);
    	network.registerMessage(ResponseToClient.Handler.class, ResponseToClient.class, 1, Side.CLIENT);

 

@Override
        public IMessage onMessage(PacketToServer message, MessageContext ctx) {
        	
        	
        	return new ResponseToClient(); 
        }

 

@Override
        public IMessage onMessage(ResponseToClient message, MessageContext ctx) {
        	
        	
        	return null;
        }

 

 

I'll need help, and I'll give help. Just ask, you know I will!

Posted

I meant to update the client...

 

I tried setting up a reply, but the item still does not change. I mus be doing something wrong, but I can't find what

 

packet

 

  Reveal hidden contents

 

Posted

You can't send the same packet back to the client. What you want to do is simplify your packets as much as possible. For example, make a button that increases a value. This will send an empty pack to the server (and is registered to be handled by the server) called, lets say, InrcreaseValuePacket(). The server sees this packet, and increases the value. You can make as many buttons and packets as you like! Then each of those will have a relative packet, say RespondWithIncreasePacket(), that is registered on the client. If you send packet A to the server - where its registered to be handled - you cant send packet A back to the client, it won't ever hit the handler. You would make packet B and register is to be handled on the client. You can make unlimited packets, just make sure you register the handlers on the right side, and also you can minimize the information stored within. It looks like you are sending an UpdateEveryValueEver() packet to the server, and trying to send the UpdateEveryValueEver() packet right back to client (sometimes.)

 

One possible example of flow could/should be like this:

 

  • Player activates block which opens gui on the client only
  • Gui sends update request to server(packet A)
  • server responds with data the gui needs to display(packet B)
  • player clicks button to adjust a value
  • gui sends packet to adjust specific value to server(packet C)
  • server receives packet and changes value, responds with either total update (packet B) or value specific update (packet D)

 

Packets A and C would be registered to be handled on the server and would most likely hold 0 specific data whatsoever. the server would know what to do just based on the packet type.

 

Packets B and D would be registered to be handled on the client, and packet D would have the advantage of not carrying much data.

 

...I sure hope that makes sense/helps!

I'll need help, and I'll give help. Just ask, you know I will!

Posted

yes, this makes sense.

 

I tried doing that, but I have trouble understanding how to arrange the communication between the GUI and the packethandler.

 

if it helps, the full code is on GitHub.

 

  • 2 weeks later...
Posted

ok, i've set up a few new packets in an attempt to properly update things, but I get a crash when opening the GUI.

 

log:

[15:56:55] [server thread/ERROR] [FML]: FMLIndexedMessageCodec exception caught
io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: readerIndex(11) + length(1) exceeds writerIndex(11): SlicedByteBuf(ridx: 11, widx: 11, cap: 11/11, unwrapped: UnpooledHeapByteBuf(ridx: 1, widx: 12, cap: 12/12))
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:247) [NetworkManager.class:?]
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:736) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:624) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:495) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:762) [MinecraftServer$2.class:?]
Caused by: java.lang.IndexOutOfBoundsException: readerIndex(11) + length(1) exceeds writerIndex(11): SlicedByteBuf(ridx: 11, widx: 11, cap: 11/11, unwrapped: UnpooledHeapByteBuf(ridx: 1, widx: 12, cap: 12/12))
at io.netty.buffer.AbstractByteBuf.checkReadableBytes(AbstractByteBuf.java:1160) ~[AbstractByteBuf.class:?]
at io.netty.buffer.AbstractByteBuf.readByte(AbstractByteBuf.java:562) ~[AbstractByteBuf.class:?]
at cpw.mods.fml.common.network.ByteBufUtils.readVarInt(ByteBufUtils.java:46) ~[byteBufUtils.class:?]
at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:118) ~[byteBufUtils.class:?]
at com.zpig333.runesofwizardry.gui.DustDyeUpdatePacket.fromBytes(DustDyeUpdatePacket.java:27) ~[DustDyeUpdatePacket.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
[15:56:55] [server thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception
io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: readerIndex(11) + length(1) exceeds writerIndex(11): SlicedByteBuf(ridx: 11, widx: 11, cap: 11/11, unwrapped: UnpooledHeapByteBuf(ridx: 1, widx: 12, cap: 12/12))
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:247) [NetworkManager.class:?]
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:736) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:624) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:495) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:762) [MinecraftServer$2.class:?]
Caused by: java.lang.IndexOutOfBoundsException: readerIndex(11) + length(1) exceeds writerIndex(11): SlicedByteBuf(ridx: 11, widx: 11, cap: 11/11, unwrapped: UnpooledHeapByteBuf(ridx: 1, widx: 12, cap: 12/12))
at io.netty.buffer.AbstractByteBuf.checkReadableBytes(AbstractByteBuf.java:1160) ~[AbstractByteBuf.class:?]
at io.netty.buffer.AbstractByteBuf.readByte(AbstractByteBuf.java:562) ~[AbstractByteBuf.class:?]
at cpw.mods.fml.common.network.ByteBufUtils.readVarInt(ByteBufUtils.java:46) ~[byteBufUtils.class:?]
at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:118) ~[byteBufUtils.class:?]
at com.zpig333.runesofwizardry.gui.DustDyeUpdatePacket.fromBytes(DustDyeUpdatePacket.java:27) ~[DustDyeUpdatePacket.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
[15:56:55] [server thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception
io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: readerIndex(11) + length(1) exceeds writerIndex(11): SlicedByteBuf(ridx: 11, widx: 11, cap: 11/11, unwrapped: UnpooledHeapByteBuf(ridx: 1, widx: 12, cap: 12/12))
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:247) [NetworkManager.class:?]
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:736) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:624) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:495) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:762) [MinecraftServer$2.class:?]
Caused by: java.lang.IndexOutOfBoundsException: readerIndex(11) + length(1) exceeds writerIndex(11): SlicedByteBuf(ridx: 11, widx: 11, cap: 11/11, unwrapped: UnpooledHeapByteBuf(ridx: 1, widx: 12, cap: 12/12))
at io.netty.buffer.AbstractByteBuf.checkReadableBytes(AbstractByteBuf.java:1160) ~[AbstractByteBuf.class:?]
at io.netty.buffer.AbstractByteBuf.readByte(AbstractByteBuf.java:562) ~[AbstractByteBuf.class:?]
at cpw.mods.fml.common.network.ByteBufUtils.readVarInt(ByteBufUtils.java:46) ~[byteBufUtils.class:?]
at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:118) ~[byteBufUtils.class:?]
at com.zpig333.runesofwizardry.gui.DustDyeUpdatePacket.fromBytes(DustDyeUpdatePacket.java:27) ~[DustDyeUpdatePacket.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
[15:56:55] [server thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception
io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: readerIndex(11) + length(1) exceeds writerIndex(11): SlicedByteBuf(ridx: 11, widx: 11, cap: 11/11, unwrapped: UnpooledHeapByteBuf(ridx: 1, widx: 12, cap: 12/12))
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:247) [NetworkManager.class:?]
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:736) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:624) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:495) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:762) [MinecraftServer$2.class:?]
Caused by: java.lang.IndexOutOfBoundsException: readerIndex(11) + length(1) exceeds writerIndex(11): SlicedByteBuf(ridx: 11, widx: 11, cap: 11/11, unwrapped: UnpooledHeapByteBuf(ridx: 1, widx: 12, cap: 12/12))
at io.netty.buffer.AbstractByteBuf.checkReadableBytes(AbstractByteBuf.java:1160) ~[AbstractByteBuf.class:?]
at io.netty.buffer.AbstractByteBuf.readByte(AbstractByteBuf.java:562) ~[AbstractByteBuf.class:?]
at cpw.mods.fml.common.network.ByteBufUtils.readVarInt(ByteBufUtils.java:46) ~[byteBufUtils.class:?]
at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:118) ~[byteBufUtils.class:?]
at com.zpig333.runesofwizardry.gui.DustDyeUpdatePacket.fromBytes(DustDyeUpdatePacket.java:27) ~[DustDyeUpdatePacket.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
[15:56:55] [server thread/ERROR] [FML]: There was a critical exception handling a packet on channel RunesWiz
io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: readerIndex(11) + length(1) exceeds writerIndex(11): SlicedByteBuf(ridx: 11, widx: 11, cap: 11/11, unwrapped: UnpooledHeapByteBuf(ridx: 1, widx: 12, cap: 12/12))
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:247) [NetworkManager.class:?]
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:736) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:624) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:495) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:762) [MinecraftServer$2.class:?]
Caused by: java.lang.IndexOutOfBoundsException: readerIndex(11) + length(1) exceeds writerIndex(11): SlicedByteBuf(ridx: 11, widx: 11, cap: 11/11, unwrapped: UnpooledHeapByteBuf(ridx: 1, widx: 12, cap: 12/12))
at io.netty.buffer.AbstractByteBuf.checkReadableBytes(AbstractByteBuf.java:1160) ~[AbstractByteBuf.class:?]
at io.netty.buffer.AbstractByteBuf.readByte(AbstractByteBuf.java:562) ~[AbstractByteBuf.class:?]
at cpw.mods.fml.common.network.ByteBufUtils.readVarInt(ByteBufUtils.java:46) ~[byteBufUtils.class:?]
at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:118) ~[byteBufUtils.class:?]
at com.zpig333.runesofwizardry.gui.DustDyeUpdatePacket.fromBytes(DustDyeUpdatePacket.java:27) ~[DustDyeUpdatePacket.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
[15:56:55] [server thread/INFO]: Player180 lost connection: TextComponent{text='A fatal error has occured, this connection is terminated', siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null}}
[15:56:55] [server thread/INFO]: Player180 left the game

 

I can't find where this comes from :(

 

code (GitHub because IMO it's easier than copy-pasting 5 files and miss those you need to see)

Posted

I can tell you from that error that you haven't numbered your packets correctly - they each need an individual number - or you haven't referenced that number correctly.

I'll need help, and I'll give help. Just ask, you know I will!

Posted

yep, that was it. However, for the packet that updates the GUI/TileEntity, should I register it on Side.SERVER or Side.CLIENT? if it is on Client, how do I access the TileEntity? the client handler (MessageContext.getClientHandler()) does not have access to the player/world to obtain the TE (and, of course, getServerHandler crashes since it's client-side)

Posted

Yes, that can be tricky! I added a field to store my TE in my container, which I assigned in construction. Then, I was able to access the TE through the container in the client packet handler like such:

 

GuiScreen screen = Minecraft.getMinecraft().currentScreen;
        	
        	if (screen instanceof GuiShopper) {
			ContainerShopper container = ((GuiShopper) screen).container;

			container.tileEntity.Cost = message.cost;
			container.tileEntity.markDirty();
		}

 

Your usage will look different, but you get the idea. You are right, you cant access the player simply!

I'll need help, and I'll give help. Just ask, you know I will!

Posted

You should be able to get it now. Maybe the flow would be like:

 

  • Client presses button(handled in the gui)
  • Gui sends a packet "pressedUpButton" to server
  • Server makes changes to item nbt according to "up button" packet
  • Server responds with a "ichangedthenbt" packet
  • Client changes the local nbt or refreshes from server, etc. to you can see the changes in the gui
  • Eat a cookie

I'll need help, and I'll give help. Just ask, you know I will!

Posted

that is indeed what I did, and it works (also, the reply from the server does not seem necessary either).

 

however, I noticed that if I break the tileEntity and place a new one in the same spot, the new one takes the properties of the old one, and if there was an ItemStack in it (dropped when the TE is broken), it is still there, although with only 1 item. Reloading the world between the breaking and placing of the TE fixes it.

 

do I need to do something specific to reset the TileEntity when it is broken?

Posted

here you go.

 

also, I didn't notice before, but the block seems to be instantly broken (and does not drop) with the empty hand in survival mode, even though the harvest level has been set.

 

package com.zpig333.runesofwizardry.block;

import com.zpig333.runesofwizardry.RunesOfWizardry;
import com.zpig333.runesofwizardry.core.ModLogger;
import com.zpig333.runesofwizardry.gui.GuiDustDye;
import com.zpig333.runesofwizardry.tileentity.TileEntityDustDye;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class BlockDustDye extends BlockContainer {

    private Random random = new Random();

    public BlockDustDye(Material mat) {
        super(mat);
        setCreativeTab(RunesOfWizardry.wizardry_tab);
        setHarvestLevel("pickaxe", 0);
    }

    @Override
    public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
        return new TileEntityDustDye();
    }

    //drops the items when the block is broken (?)
    @Override
    public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) {
        TileEntityDustDye tileentityDustDye = (TileEntityDustDye) p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);

        if (tileentityDustDye != null) {
            for (int i1 = 0; i1 < tileentityDustDye.getSizeInventory(); ++i1) {
                ItemStack itemstack = tileentityDustDye.getStackInSlot(i1);

                if (itemstack != null) {
                    float f = this.random.nextFloat() * 0.8F + 0.1F;
                    float f1 = this.random.nextFloat() * 0.8F + 0.1F;
                    EntityItem entityitem;

                    for (float f2 = this.random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; p_149749_1_.spawnEntityInWorld(entityitem)) {
                        int j1 = this.random.nextInt(21) + 10;

                        if (j1 > itemstack.stackSize) {
                            j1 = itemstack.stackSize;
                        }

                        itemstack.stackSize -= j1;
                        entityitem = new EntityItem(p_149749_1_, (double) ((float) p_149749_2_ + f), (double) ((float) p_149749_3_ + f1), (double) ((float) p_149749_4_ + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
                        float f3 = 0.05F;
                        entityitem.motionX = (double) ((float) this.random.nextGaussian() * f3);
                        entityitem.motionY = (double) ((float) this.random.nextGaussian() * f3 + 0.2F);
                        entityitem.motionZ = (double) ((float) this.random.nextGaussian() * f3);

                        if (itemstack.hasTagCompound()) {
                            entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
                        }
                    }
                }
            }

            p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
        }

    }
    
    @Override
    public boolean onBlockActivated(World world, int x, int y, int z,
                        EntityPlayer player, int metadata, float what, float these, float are){
       /* if (world.isRemote)
        {
            return true;
        }
        else
        { */
            TileEntityDustDye tileentityDD = (TileEntityDustDye)world.getTileEntity(x,y,z);
            
            if (tileentityDD == null || player.isSneaking()) {
                        return false;
            }
            player.openGui(RunesOfWizardry.instance, GuiDustDye.GUI_ID, world, x, y, z);            
            return true;
        }
    }

Posted

adding tileentityDustDye.invalidate(); at the end of the the breakBlock method seems to fix the issue where the issue of the container staying the same after breaking it, although I am unsure of what this method does.

Posted

SOLVED.

 

it seems the proper way of fixing the "ghost" tileEntity was to call super.breakBlock()

 

also, harvesting problem was solved by using setHardness() and making canHarvest() always return true.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • New users at Temu receive a $100 discount on orders over $100 Use the code [aci789589] during checkout to get Temu Coupon Code $100 off For New Users. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. Temu 100% Off coupon code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. You can get a$100 bonus plus 30% off any purchase at Temu with the$100 Coupon Bundle at Temu if you sign up with the referral code [aci789589] and make a first purchase of$50 or more. The Temu $100 Off coupon code (aci789589) will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes Temu offers $100 Off Coupon Code “aci789589” for First Time Users. Yes, Temu offers $100 off coupon code {aci789589} for first-time users. You can get a $100 bonus plus 100% off any purchase at Temu with the $100 Coupon Bundle if you sign up with the referral code [aci789589] and make a first purchase of $100 or more. If you are who wish to join Temu, then you should use this exclusive Temu coupon code $100 off (aci789589) and get $100 off on your purchase with Temu. You can get a $100 discount with Temu coupon code {aci789589}. This exclusive offer is for existing customers and can be used for a $100 reduction on your total purchase. Enter coupon code {aci789589} at checkout to avail of the discount. You can use the code {aci789589} to get a $100 off Temu coupon as a new customer. Apply this Temu coupon code $100 off (aci789589) to get a $100 discount on your shopping with Temu. If you’re a first-time user and looking for a Temu coupon code $100 first time user(aci789589) then using this code will give you a flat $100 Off and a 90% discount on your Temu shopping. Temu $100% Off Coupon Code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Temu coupon code$100off-{aci789589} Temu coupon code -{aci789589} Temu coupon code$50 off-{aci789589} Temu Coupon code [aci789589] for existing users can get up to 50% discount on product during checkout. Temu Coupon Codes for Existing Customers-aci789589 Temu values its loyal customers and offers various promo codes, including the Legit Temu Coupon Code (aci789589]) or (aci789589), which existing users can use. This ensures that repeat shoppers can also benefit from significant discounts on their purchases. Keep an eye out for special promotions and offers that are periodically available to enhance your shopping experience.
    • New users at Temu receive a $100 discount on orders over $100 Use the code [aci789589] during checkout to get Temu Coupon Code $100 off For New Users. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. Temu 100% Off coupon code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. You can get a$100 bonus plus 30% off any purchase at Temu with the$100 Coupon Bundle at Temu if you sign up with the referral code [aci789589] and make a first purchase of$50 or more. The Temu $100 Off coupon code (aci789589) will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes Temu offers $100 Off Coupon Code “aci789589” for First Time Users. Yes, Temu offers $100 off coupon code {aci789589} for first-time users. You can get a $100 bonus plus 100% off any purchase at Temu with the $100 Coupon Bundle if you sign up with the referral code [aci789589] and make a first purchase of $100 or more. If you are who wish to join Temu, then you should use this exclusive Temu coupon code $100 off (aci789589) and get $100 off on your purchase with Temu. You can get a $100 discount with Temu coupon code {aci789589}. This exclusive offer is for existing customers and can be used for a $100 reduction on your total purchase. Enter coupon code {aci789589} at checkout to avail of the discount. You can use the code {aci789589} to get a $100 off Temu coupon as a new customer. Apply this Temu coupon code $100 off (aci789589) to get a $100 discount on your shopping with Temu. If you’re a first-time user and looking for a Temu coupon code $100 first time user(aci789589) then using this code will give you a flat $100 Off and a 90% discount on your Temu shopping. Temu $100% Off Coupon Code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Temu coupon code$100off-{aci789589} Temu coupon code -{aci789589} Temu coupon code$50 off-{aci789589} Temu Coupon code [aci789589] for existing users can get up to 50% discount on product during checkout. Temu Coupon Codes for Existing Customers-aci789589 Temu values its loyal customers and offers various promo codes, including the Legit Temu Coupon Code (aci789589]) or (aci789589), which existing users can use. This ensures that repeat shoppers can also benefit from significant discounts on their purchases. Keep an eye out for special promotions and offers that are periodically available to enhance your shopping experience.
    • New users at Temu receive a $100 discount on orders over $100 Use the code [aci789589] during checkout to get Temu Coupon Code $100 off For New Users. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. Temu 100% Off coupon code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. You can get a$100 bonus plus 30% off any purchase at Temu with the$100 Coupon Bundle at Temu if you sign up with the referral code [aci789589] and make a first purchase of$50 or more. The Temu $100 Off coupon code (aci789589) will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes Temu offers $100 Off Coupon Code “aci789589” for First Time Users. Yes, Temu offers $100 off coupon code {aci789589} for first-time users. You can get a $100 bonus plus 100% off any purchase at Temu with the $100 Coupon Bundle if you sign up with the referral code [aci789589] and make a first purchase of $100 or more. If you are who wish to join Temu, then you should use this exclusive Temu coupon code $100 off (aci789589) and get $100 off on your purchase with Temu. You can get a $100 discount with Temu coupon code {aci789589}. This exclusive offer is for existing customers and can be used for a $100 reduction on your total purchase. Enter coupon code {aci789589} at checkout to avail of the discount. You can use the code {aci789589} to get a $100 off Temu coupon as a new customer. Apply this Temu coupon code $100 off (aci789589) to get a $100 discount on your shopping with Temu. If you’re a first-time user and looking for a Temu coupon code $100 first time user(aci789589) then using this code will give you a flat $100 Off and a 90% discount on your Temu shopping. Temu $100% Off Coupon Code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Temu coupon code$100off-{aci789589} Temu coupon code -{aci789589} Temu coupon code$50 off-{aci789589} Temu Coupon code [aci789589] for existing users can get up to 50% discount on product during checkout. Temu Coupon Codes for Existing Customers-aci789589 Temu values its loyal customers and offers various promo codes, including the Legit Temu Coupon Code (aci789589]) or (aci789589), which existing users can use. This ensures that repeat shoppers can also benefit from significant discounts on their purchases. Keep an eye out for special promotions and offers that are periodically available to enhance your shopping experience.
    • "Looking to save big on your next shopping spree? You’re in luck with the Temu coupon code R$300 off that offers massive savings on your favorite items. Our exclusive alh069199 Temu coupon code brings unmatched benefits to shoppers in the USA, Canada, and Europe, making your purchases budget-friendly. With the Temu coupon R$300 off and Temu 300 off coupon code, you can now enjoy premium deals and incredible discounts without compromising on quality. [h]What Is The Coupon Code For Temu R$300 Off?[/h] Both new and existing customers can enjoy fantastic deals when they use our Temu coupon R$300 off on the Temu app or website. Unlock great savings with the R$300 off Temu coupon and shop guilt-free. alh069199: Enjoy a flat R$300 off your total purchase instantly. alh069199: Access a R$300 coupon pack with multiple use vouchers. alh069199: New users receive a R$300 discount on their first purchase. alh069199: Existing users can get an extra R$300 in promo codes. alh069199: Special R$300 coupon for users in the USA and Canada. Temu Coupon Code R$300 Off For New Users In 2025 New to Temu? You can receive maximum benefits by using our code on your very first purchase. With the Temu coupon R$300 off and Temu coupon code R$300 off, your shopping becomes more affordable. alh069199: Flat R$300 discount for all new Temu users. alh069199: A R$300 coupon bundle with versatile offers. alh069199: Get up to R$300 in coupon value for multiple purchases. alh069199: Enjoy free shipping to over 68 countries worldwide. alh069199: Receive an extra 30% off on your first-time order. How To Redeem The Temu Coupon R$300 Off For New Customers? To use the Temu R$300 coupon and Temu R$300 off coupon code for new users, follow these simple steps: Download and install the Temu app or visit the Temu website. Create a new user account using your email or social login. Go to the ""Coupons"" section in your account settings. Enter the code alh069199 and tap ""Apply."" Shop your favorite items and enjoy a R$300 discount on your total. Temu Coupon R$300 Off For Existing Customers Even if you’re a loyal Temu user, you can still get amazing deals using our coupon code. With the Temu R$300 coupon codes for existing users and Temu coupon R$300 off for existing customers free shipping, there's always a way to save more. alh069199: Claim a R$300 extra discount exclusively for existing users. alh069199: Unlock a R$300 coupon pack for multiple transactions. alh069199: Enjoy a free gift and express shipping in the USA and Canada. alh069199: Get an additional 30% off, even on already discounted items. alh069199: Access free shipping to 68 global destinations. How To Use The Temu Coupon Code R$300 Off For Existing Customers? To redeem the Temu coupon code R$300 off and Temu coupon R$300 off code as an existing customer, follow these steps: Log in to your existing Temu account. Navigate to the ""Coupons"" or ""Promo Codes"" section. Enter alh069199 into the code field and apply. Browse and add items to your cart. Checkout with your discount automatically applied. Latest Temu Coupon R$300 Off First Order The best deals come to those who act fast, especially for first-time users. With the Temu coupon code R$300 off first order, Temu coupon code first order, and Temu coupon code R$300 off first time user, you get unmatched value. alh069199: Flat R$300 discount on your first-ever purchase. alh069199: Unlock a R$300 Temu coupon pack for your first order. alh069199: Get multiple-use coupons adding up to R$300. alh069199: Enjoy free shipping to 68 countries. alh069199: Benefit from an extra 30% off on your first order. How To Find The Temu Coupon Code R$300 Off? Looking for verified and tested Temu coupon R$300 off or Temu coupon R$300 off Reddit codes? Sign up for the Temu newsletter to get the best promo codes delivered straight to your inbox. Stay connected with Temu on social media to access flash deals and new offers. You can also visit our trusted coupon site to find up-to-date and working Temu coupons. Is Temu R$300 Off Coupon Legit? Yes, the Temu R$300 Off Coupon Legit offers are 300% valid and trustworthy. Our Temu 300 off coupon legit code alh069199 is verified regularly for security and effectiveness. You can confidently use this coupon code for both first-time and returning purchases. It works globally and doesn’t have an expiration date, making it your go-to shopping companion. How Does Temu R$300 Off Coupon Work? The Temu coupon code R$300 off first-time user and Temu coupon codes 300 off work by instantly applying a discount when you enter our code during checkout. Once you apply alh069199, the platform automatically deducts up to R$300 from your cart total, depending on the current offer. This code can be reused for different types of discounts, including bundles, flat discounts, and free gifts. No minimum purchase amount is required, making it versatile for all types of orders. How To Earn Temu R$300 Coupons As A New Customer? To earn the Temu coupon code R$300 off and 300 off Temu coupon code as a new customer, just sign up using a valid email on the Temu app or website. Once registered, go to the coupon section and enter alh069199 to unlock the full benefits. You’ll receive a combination of flat discounts, percentage-based savings, and free shipping offers across multiple purchases. What Are The Advantages Of Using The Temu Coupon R$300 Off? Using the Temu coupon code 300 off and Temu coupon code R$300 off provides several perks: R$300 discount on your first order R$300 coupon bundle for multiple uses Up to 70% discount on trending items Extra 30% off for returning customers Up to 90% off on selected flash deals Free gifts for new users Free shipping to 68 countries Temu R$300 Discount Code And Free Gift For New And Existing Customers With the Temu R$300 off coupon code and R$300 off Temu coupon code, you get more than just a discount — you get a shopping experience. alh069199: Save R$300 on your first purchase. alh069199: Enjoy an additional 30% off on all items. alh069199: Receive a complimentary gift as a new user. alh069199: Unlock up to 70% discount on selected products. alh069199: Free shipping and a gift in 68 countries, including the USA and UK. Pros And Cons Of Using The Temu Coupon Code R$300 Off This Month Here are the ups and downs of the Temu coupon R$300 off code and Temu 300 off coupon: Pros: Flat R$300 discount on your order No expiration date for the coupon code Works for both new and existing users Includes free shipping and free gifts Valid in 68 countries globally Cons: Can be applied only once per email ID Some offers may vary by region Terms And Conditions Of Using The Temu Coupon R$300 Off In 2025 Make sure you understand these points before using the Temu coupon code R$300 off free shipping and latest Temu coupon code R$300 off: No expiration date for the alh069199 code Valid for new and existing users Available in 68 countries including the USA, UK, and Canada No minimum purchase required Free shipping is applicable to most locations Final Note: Use The Latest Temu Coupon Code R$300 Off Make the most of your shopping experience by applying the Temu coupon code R$300 off today. Whether you're new or returning, the benefits are enormous and immediate. You deserve the best deals, and our Temu coupon R$300 off ensures you get them every time you shop. Act now and save big! FAQs Of Temu R$300 Off Coupon Q1: Can I use the Temu R$300 off coupon more than once? No, each email/account can only redeem the coupon once. However, the code offers multiple coupons within one pack. Q2: Is the Temu coupon code valid for existing users? Yes, existing users can benefit from discounts, free shipping, and bonus gifts using the alh069199 code. Q3: Do I need a minimum purchase to use the R$300 Temu coupon? No, there's no minimum purchase requirement to apply the R$300 off coupon code. Q4: How can I get the Temu R$300 coupon code for free? Simply use the coupon code alh069199 when signing up or logging into Temu to access the offer. Q5: Is the R$300 off Temu coupon code available worldwide? Yes, the code is valid in 68 countries including the USA, UK, and Canada with no region-based restrictions."
    • yeah its the same crash when ever i load into a world, if TileEntity cant solve this one then i fear ill have to do it the long way of disabling and enable mods :'{ as i feared 
  • Topics

×
×
  • Create New...

Important Information

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