Jump to content

Recommended Posts

Posted

I'm trying to make a TileEntity which will open a GUI that will have a GuiTextBox. I've managed to make packets that send the TextBox' data back to the server, but there is something weird. Code works perfectly in singleplayer, but packet handler is not even called when using a remote server.

GUI code:
 

@Override
public void onGuiClosed()
{
	System.out.println("onGuiClosed 1");
	PacketHandler.INSTANCE.sendToServer(new UpdateTileFilter(tileEntity.getPos(), FilterInput.getText()));
	System.out.println("onGuiClosed 2");
	super.onGuiClosed();
	Keyboard.enableRepeatEvents(false);
}

Packet Handler:
 

public IMessage onMessage(UpdateTileFilter message, MessageContext ctx)
{
	System.out.println("is this even called?"); // this is not printed when using remote server
	EntityPlayerMP serverPlayer = ctx.getServerHandler().player;
	BlockPos pos = message.getBlockPos();
	serverPlayer.getServerWorld().addScheduledTask(() -> 
	{
		WorldServer sWorld = serverPlayer.getServerWorld();
		if (sWorld == null || !sWorld.isBlockLoaded(pos))
		{
			return;
		}
		TileEntity tile = sWorld.getTileEntity(pos);

		if (tile != null && tile instanceof TileEntityFilteredHopper)
		{
			TileEntityFilteredHopper customTile = (TileEntityFilteredHopper)tile;
			customTile.setFilters(message.filter);
		}
	});
	
	return null;
}

 

Packet, block and tile are correctly registered. My tile is marked dirty whenever the "filter" changes. That's why everything works perfectly in singleplayer world, but NBT tag never changes on multiplayer (checking it out via commands)

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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