Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.techmage.magetech.network;
- import com.techmage.magetech.init.ModItems;
- import com.techmage.magetech.utility.LogHelper;
- 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 cpw.mods.fml.relauncher.Side;
- import io.netty.buffer.ByteBuf;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.ItemStack;
- public class PacketTalismanSwitch implements IMessage
- {
- private int talisman;
- public PacketTalismanSwitch() { }
- public PacketTalismanSwitch(int talisman)
- {
- this.talisman = talisman;
- }
- @Override
- public void fromBytes(ByteBuf buf)
- {
- talisman = buf.readInt();
- }
- @Override
- public void toBytes(ByteBuf buf)
- {
- buf.writeInt(talisman);
- }
- public static class Handler implements IMessageHandler<PacketTalismanSwitch, IMessage>
- {
- @Override
- public IMessage onMessage(PacketTalismanSwitch msg, MessageContext ctx)
- {
- if (ctx.side == Side.SERVER)
- {
- EntityPlayer player = ctx.getServerHandler().playerEntity;
- switch (msg.talisman)
- {
- case 0:
- player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(ModItems.talismanFire));
- break;
- case 1:
- player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(ModItems.talismanAir));
- break;
- default:
- break;
- }
- }
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement