Jump to content

[1.7.2]Problem with packets


f1rSt1kChannel

Recommended Posts

Hello

I'm trying to send a packet to the server to open a GUI, but the console writes the following:

 

[server thread / ERROR] [FML]: Messages for channel Esoteric for side SERVER were not processed by the embedded channel [agravaine.agravainelib.network.packet.message.PacketOpenGui @ 198c9c7]. 
  They have been dropped. 

Length: 0

 

Made from the tutorial http://www.minecraftforge.net/wiki/Netty_Packet_Handling.

Link to comment
Share on other sites

Thanks.

Not work...

Writes the same thing...

My packet:

public class PacketOpenGui implements IMessage, IMessageHandler<PacketOpenGui, IMessage>{

Object mod;
int id;

public PacketOpenGui(){}

public PacketOpenGui(Object modGui, int guiId){
	mod = modGui;
	id = guiId;
}

public void fromBytes(ByteBuf buf){}

public void toBytes(ByteBuf buf){}

public IMessage onMessage(PacketOpenGui message, MessageContext ctx){
	Esoteric.logger.info("DUDE");
	EntityPlayerMP player = ctx.getServerHandler().playerEntity;
	player.openGui(mod, id, player.worldObj, (int)player.posX, (int)player.posY, (int)player.posZ);
	return null;
}
}

Link to comment
Share on other sites

Packet code remained unchanged.

Register:

packetSender.registerMessage(PacketOpenGui.class, PacketOpenGui.class, 0, Side.SERVER);

Sending:

@SubscribeEvent
public void keyEvent(KeyInputEvent event){
	if(key.getIsKeyPressed() && FMLClientHandler.instance().getClient().inGameHasFocus){
		Esoteric.logger.info("MEOW");
		Esoteric.packetSender.sendToServer(new PacketOpenGui(Esoteric.instance, 2));
	}
}

Gui handler:

public class EsotericGuiHandler implements IGuiHandler{

public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z){
	TileEntity tileEntity = world.getTileEntity(x, y, z);
	if(id == 0){
		return new ContainerRelic(player.inventory, (TileEntityRelic)tileEntity);
	}
	if(id == 1){
		return new ContainerCampfire(player.inventory, (TileEntityCampfire)tileEntity);
	}
	if(id == 2){
		return new ContainerPlayerExtended(player.inventory, !world.isRemote, player);
	}
	return null;
}

public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z){
	TileEntity tileEntity = world.getTileEntity(x, y, z);
	if(id == 0){
		return new GuiRelic(player.inventory, (TileEntityRelic)tileEntity);
	}
	if(id == 1){
		return new GuiCampfire(player.inventory, (TileEntityCampfire)tileEntity);
	}
	if(id == 2){
		return new GuiPlayerExtended(player);
	}
	return null;
}
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

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

×   Your previous content has been restored.   Clear editor

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

Announcements



×
×
  • Create New...

Important Information

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