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

    • Looking to save big while shopping online? Our Temu coupon code 100€ off is here to make your shopping experience across Europe even better. If you're from Germany, France, Italy, or Switzerland, using the "acw696499" Temu coupon code guarantees you maximum benefits on all your purchases. This powerful code works seamlessly on both the Temu app and official website. With Temu coupon 100€ off and Temu 100 off coupon code, you're not only securing major savings but also unlocking exclusive offers across thousands of categories. Don't miss this golden opportunity to shop smart in 2025! What Is The Coupon Code For Temu 100€ Off? Great news for all shoppers—whether you're a new user or a long-time customer, you can enjoy exciting discounts with our Temu coupon 100€ off. With this 100€ off Temu coupon, shopping across Europe has never been more rewarding. acw696499: Use this code to get a flat 100€ discount instantly. acw696499: Unlock a 100€ coupon pack usable multiple times. acw696499: New customers get a 100€ flat discount as a welcome gift. acw696499: Existing customers receive an additional 100€ promo offer. acw696499: Designed specifically for users in Germany, France, Italy, Switzerland, and more. Temu Coupon Code 100€ Off For New Users In 2025 As a new user, you're in luck! The Temu coupon 100€ off makes your first experience unforgettable with savings that are hard to ignore. Our Temu coupon code 100€ off guarantees the best deals for new users on their first purchases across Europe. acw696499: Flat 100€ discount for all first-time buyers. acw696499: Receive a 100€ coupon bundle immediately after signing up. acw696499: Enjoy up to 100€ coupon value usable multiple times. acw696499: Benefit from free shipping to Germany, France, Italy, Switzerland, etc. acw696499: Get an extra 30% off on your first purchase. How To Redeem The Temu coupon 100€ off For New Customers? To use the Temu 100€ coupon, start by downloading the Temu app or visiting the official website. Then follow this step-by-step guide to apply the Temu 100€ off coupon code for new users: Create an account or sign up on the Temu platform. Browse through categories and add items to your cart. Proceed to checkout and enter the code "acw696499". Apply the code and see the discount reflected instantly. Complete your purchase and enjoy your savings! Temu Coupon 100€ Off For Existing Customers Existing users can also enjoy big rewards! Our Temu 100€ coupon codes for existing users offer various benefits when shopping with the Temu app or site. You can unlock exclusive Temu coupon 100€ off for existing customers free shipping deals using our code "acw696499" today. acw696499: Get a 100€ discount as a returning Temu shopper. acw696499: Claim a 100€ coupon bundle valid across multiple purchases. acw696499: Receive a free gift with fast delivery across Europe. acw696499: Stack up to 70% off on top of your 100€ coupon. acw696499: Enjoy free shipping in Germany, France, Italy, Spain, Switzerland, and more. How To Use The Temu Coupon Code 100€ Off For Existing Customers? To apply the Temu coupon code 100€ off, visit the Temu website or open the app and log into your existing account. Here's how to redeem the Temu coupon 100€ off code: Select the items you wish to purchase. Add them to your cart and proceed to checkout. Enter the code "acw696499" in the promo section. Enjoy the instant 100€ discount applied to your total. Complete the payment to finalize your purchase. Latest Temu Coupon 100€ Off First Order Don't miss the chance to get the biggest deal on your very first purchase with our Temu coupon code 100€ off first order. Whether you're from France, Italy, Germany, or Switzerland, this Temu coupon code first order is your gateway to mega savings. Use this Temu coupon code 100€ off first time user to unlock the following: acw696499: Flat 100€ discount on your very first Temu order. acw696499: Enjoy a 100€ coupon pack tailored for your first-time use. acw696499: Up to 100€ in coupons spread over multiple uses. acw696499: Free shipping to countries like Germany, France, Italy, Switzerland, and Spain. acw696499: Additional 30% off on your first order. How To Find The Temu Coupon Code 100€ Off? You can easily find the Temu coupon 100€ off by subscribing to the Temu newsletter, where verified codes are shared regularly. Users searching for Temu coupon 100€ off Reddit can also explore discussions for active and tested codes. To ensure the best deals, follow Temu on social media platforms for real-time updates. Trusted coupon websites also offer the latest, verified Temu promo codes. Is Temu 100€ Off Coupon Legit? Yes, the Temu 100€ Off Coupon Legit claim is absolutely true. Our code "acw696499" has been tested multiple times to ensure legitimacy. You can confidently use our code knowing it's not only genuine but also safe for first and repeat orders. This Temu 100 off coupon legit code is valid across Europe and has no expiry date. How Does Temu 100€ Off Coupon Work? To put it simply, once you apply our Temu coupon code 100€ off first-time user, the discount is automatically subtracted from your total at checkout. The process is instant and works on both the app and website. The Temu coupon codes 100 off activate exclusive discounts depending on your user status (new or existing). Once validated, the code applies a flat 100€ reduction or bundles, which can include gifts, free shipping, and more discounts. How To Earn Temu 100€ Coupons As A New Customer? You can earn the Temu coupon code 100€ off simply by signing up as a new user. Additionally, inviting friends or completing tasks on the Temu app can get you extra coupons. Our 100 off Temu coupon code is available to every first-time user without any hidden conditions. Be active on the platform and check for pop-up deals that often contain surprise coupon drops. What Are The Advantages Of Using Temu Coupon 100€ Off? Here are the top reasons why you should apply our Temu coupon code 100 off and Temu coupon code 100€ off: 100€ discount on your very first order. 100€ coupon bundle valid for multiple uses. Up to 70% off on popular items. Extra 30% off for European existing customers. Up to 90% off on selected products. Free gift for new users across Europe. Free delivery in countries like Germany, France, Italy, Switzerland, and more. Temu 100€ Discount Code And Free Gift For New And Existing Customers Using the Temu 100€ off coupon code and 100€ off Temu coupon code gives you access to premium perks. acw696499: Flat 100€ off on your very first Temu purchase. acw696499: Additional 30% discount on any item. acw696499: Free welcome gift for new users. acw696499: Up to 70% off on top-rated items. acw696499: Free gift with fast shipping across Germany, France, Italy, Switzerland. Pros And Cons Of Using Temu Coupon Code 100€ Off This Month Here are some Temu coupon 100€ off code and Temu 100 off coupon benefits and limitations: Pros: Saves you up to 100€ instantly. No minimum purchase requirement. Works on both app and website. Valid in multiple European countries. Bonus gifts and free delivery available. Cons: Some items may not be eligible. One-time use per account per offer type. Terms And Conditions Of Using The Temu Coupon 100€ Off In 2025 Here are the Temu coupon code 100€ off free shipping and latest Temu coupon code 100€ off rules you should know: No expiration date on the code "acw696499." Valid for both new and existing users. Usable in Germany, France, Italy, Switzerland, Spain, and more. No minimum order requirement. Can be used on all product categories. Stackable with certain site promotions. Final Note: Use The Latest Temu Coupon Code 100€ Off Start saving instantly with our Temu coupon code 100€ off and elevate your online shopping journey today. There has never been a better time to use Temu for your fashion, tech, home, or beauty needs. With our verified Temu coupon 100€ off, you can enjoy discounts, free shipping, and bonus gifts across Europe. Happy shopping! FAQs Of Temu 100€ Off Coupon What is the latest working Temu coupon code 100€ off? The latest working Temu coupon code is "acw696499" which provides 100€ off for new and existing users across Europe. Is there any expiry date for this coupon code? No, our coupon code "acw696499" does not have an expiration date and is valid all year round. Can existing customers also use the Temu 100€ coupon? Yes, existing users can redeem the 100€ coupon using "acw696499" and enjoy exclusive benefits. Is the Temu 100€ off coupon legit? Absolutely! Our coupon code "acw696499" is tested and verified regularly for legitimacy. How many times can I use the Temu coupon code 100€ off? You can use it once per user type (new or existing), and it may apply for multiple uses depending on promotions.
    • Looking to grab the Temu coupon code $100 off this month? You're in the right place for the biggest savings on your favorite products. Use the exclusive "acw696499" Temu coupon code for maximum benefits across the USA, Canada, and European nations. Whether you're a new customer or a long-time user, this code unlocks massive discounts and perks. With the Temu coupon $100 off and Temu 100 off coupon code, you’re not just saving money—you’re upgrading your shopping experience. What Is The Coupon Code For Temu $100 Off? Both new and existing customers can enjoy unbeatable savings with our exclusive coupon code. Use this Temu coupon $100 off and get a $100 off Temu coupon for your next order. acw696499 – Flat $100 off your order at checkout. acw696499 – $100 coupon pack you can use on multiple products. acw696499 – $100 flat discount exclusively for new customers. acw696499 – Extra $100 promo code for loyal, existing customers. acw696499 – $100 coupon available for shoppers in the USA and Canada. Temu Coupon Code $100 Off For New Users In 2025 If you're new to Temu, you're in for a treat. Use our code for the Temu coupon $100 off and enjoy unmatched discounts. acw696499 – Flat $100 discount for first-time buyers. acw696499 – Unlock a $100 coupon bundle specially for new customers. acw696499 – Redeem up to $100 coupon value across multiple purchases. acw696499 – Get free shipping to over 68 countries. acw696499 – Enjoy an extra 30% off any purchase as a new user. How To Redeem The Temu Coupon $100 Off For New Customers? To use the Temu $100 coupon and claim your Temu $100 off coupon code for new users, follow these steps: Download the Temu app or visit the official website. Register for a new account using your email or phone number. Add your favorite products to the cart. Enter the coupon code acw696499 at checkout. Enjoy instant savings and free shipping benefits. Temu Coupon $100 Off For Existing Customers Returning customers can still enjoy exceptional deals by applying our exclusive code. Use the Temu $100 coupon codes for existing users and unlock Temu coupon $100 off for existing customers free shipping perks. acw696499 – Receive an additional $100 discount as a returning user. acw696499 – Use the $100 coupon bundle for multiple purchases. acw696499 – Get a free gift with express shipping across the USA and Canada. acw696499 – Enjoy an extra 30% off on top of your current discounts. acw696499 – Free shipping available to 68 countries worldwide. How To Use The Temu Coupon Code $100 Off For Existing Customers? To activate the Temu coupon code $100 off and enjoy your savings as a returning buyer, follow these simple steps: Log into your existing Temu account. Add your chosen items to the shopping cart. Head to the checkout page. Apply the code acw696499 in the promo code box. Watch your total drop instantly with the Temu coupon $100 off code. Latest Temu Coupon $100 Off First Order Enjoy your first shopping experience on Temu with massive savings! Apply the Temu coupon code $100 off first order, Temu coupon code first order, or Temu coupon code $100 off first time user to save more. acw696499 – Flat $100 discount for your first order. acw696499 – Special $100 Temu coupon code for first orders. acw696499 – Enjoy up to $100 coupon bundle across different purchases. acw696499 – Free shipping to more than 68 countries. acw696499 – Extra 30% off on your initial order. How To Find The Temu Coupon Code $100 Off? Searching for the best Temu coupon $100 off deals? Check out Temu coupon $100 off Reddit threads for user-shared experiences and updated codes. You can also sign up for Temu’s newsletter for personalized offers. Visit their official social media pages or rely on trusted coupon-sharing websites to grab the most recent working promo codes. Is Temu $100 Off Coupon Legit? Yes, the Temu $100 Off Coupon Legit claim is absolutely true. We guarantee our Temu 100 off coupon legit code "acw696499" is tested and verified for accuracy. Anyone can safely use this code to receive $100 off their first or repeat orders. It’s valid internationally and doesn’t expire, so use it anytime for instant savings. How Does Temu $100 Off Coupon Work? The Temu coupon code $100 off first-time user and Temu coupon codes 100 off give users a direct discount during checkout. When you enter the coupon code during payment, the system automatically deducts $100 from your total bill. Whether you're a first-time buyer or a loyal customer, our code ensures unbeatable savings. How To Earn Temu $100 Coupons As A New Customer? To earn the Temu coupon code $100 off and get access to the 100 off Temu coupon code, sign up as a new customer on the Temu platform. Once registered, apply the promo code "acw696499" during checkout. You’ll instantly receive a $100 coupon bundle, free shipping, and extra discounts exclusive to new users. What Are The Advantages Of Using The Temu Coupon $100 Off? Using the Temu coupon code 100 off and Temu coupon code $100 off unlocks the following perks: $100 discount on your first order. $100 coupon bundle for multiple uses. 70% discount on popular items. Extra 30% off for returning customers. Up to 90% off on selected products. Free gift for new users. Free shipping to over 68 countries. Temu $100 Discount Code And Free Gift For New And Existing Customers Want more than discounts? The Temu $100 off coupon code and $100 off Temu coupon code offer added bonuses for everyone. acw696499 – $100 discount for your first order. acw696499 – Extra 30% off on any product. acw696499 – Free gift for first-time buyers. acw696499 – Up to 70% discount sitewide. acw696499 – Free shipping and gift in 68 countries including USA & UK. Pros And Cons Of Using The Temu Coupon Code $100 Off This Month Using the Temu coupon $100 off code and Temu 100 off coupon offers major pros and a couple of cons: Pros: Huge $100 discount on first and repeat orders. Free shipping globally. Free gift for new users. Up to 90% off on exclusive deals. Extra 30% discount for all users. Cons: Cannot be combined with certain flash sale items. Limited-time availability for some regional users. Terms And Conditions Of Using The Temu Coupon $100 Off In 2025 Before using the Temu coupon code $100 off free shipping and latest Temu coupon code $100 off, keep these in mind: Valid for both new and returning users. Code "acw696499" works across 68 countries worldwide. No minimum purchase required. No expiration date—use it anytime. Free shipping and gifts depend on regional availability. Final Note: Use The Latest Temu Coupon Code $100 Off Save big on every order with our Temu coupon code $100 off—it’s the smartest way to shop. Apply your Temu coupon $100 off today and make your online shopping budget-friendly and exciting.
    • Update your drivers: https://www.amd.com/en/support/downloads/previous-drivers.html/processors/ryzen/ryzen-3000-series/amd-ryzen-7-3700u.html
    • mclo only shows 25000 lines - add the rest with another link
    • Make a test without Create Big Cannons More Shells
  • Topics

×
×
  • Create New...

Important Information

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