Skip to content

Instantly share code, notes, and snippets.

@MultiMote
Created October 15, 2014 09:34
Show Gist options
  • Save MultiMote/657a040133c2495129b1 to your computer and use it in GitHub Desktop.
Save MultiMote/657a040133c2495129b1 to your computer and use it in GitHub Desktop.
package com.multimote.microz.handlers.packet;
import com.multimote.microz.Core;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
/**
* Created by MultiMote on 15.10.2014.
*/
public class GuiRequestPacket implements IMessage, IMessageHandler<GuiRequestPacket, IMessage> {
int type;
int entityID;
public GuiRequestPacket() {
}
public GuiRequestPacket(int type, int entityID) {
this.type = type;
this.entityID = entityID;
}
public void toBytes(ByteBuf target) {
target.writeInt(type);
target.writeInt(entityID);
}
public void fromBytes(ByteBuf dat) {
type = dat.readInt();
entityID = dat.readInt();
}
@Override
public IMessage onMessage(GuiRequestPacket message, MessageContext ctx) {
System.out.println("requested guiID" + message.type + " for entity ID " + message.entityID);
EntityPlayer player = ctx.getServerHandler().playerEntity;
World world = player.worldObj;
player.openGui(Core.instance, message.type, world, message.entityID, 0, 0);
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment