Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.halestormxv.Main.handler.network.packets;
- import com.halestormxv.Main.MainRegistry;
- import com.halestormxv.Main.handler.network.AbstractServerMessageHandler;
- import com.halestormxv.item.CelestialCraft_items;
- import cpw.mods.fml.common.network.simpleimpl.IMessage;
- import cpw.mods.fml.common.network.simpleimpl.MessageContext;
- import io.netty.buffer.ByteBuf;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.inventory.IInventory;
- public class OpenGuiPacketAlt implements IMessage {
- // this will store the id of the gui to open
- private int id;
- // The basic, no-argument constructor MUST be included to use the new automated handling
- public OpenGuiPacketAlt() {}
- // if there are any class fields, be sure to provide a constructor that allows
- // for them to be initialized, and use that constructor when sending the packet
- public OpenGuiPacketAlt(int id) {
- this.id = id;
- }
- @Override
- public void fromBytes(ByteBuf buffer) {
- // basic Input/Output operations, very much like DataInputStream
- id = buffer.readInt();
- }
- @Override
- public void toBytes(ByteBuf buffer) {
- // basic Input/Output operations, very much like DataOutputStream
- buffer.writeInt(id);
- }
- public static class Handler extends AbstractServerMessageHandler<OpenGuiPacketAlt> {
- @Override
- public IMessage handleServerMessage(EntityPlayer player, OpenGuiPacketAlt message, MessageContext ctx)
- {
- System.out.println("Congratulations you finally created a frigen packet that works!");
- player.openGui(MainRegistry.modInstance, message.id, player.worldObj, 0, 0, 0);
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement