Advertisement
Guest User

Untitled

a guest
Jul 31st, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.73 KB | None | 0 0
  1. package com.arisux.avp.packets.client;
  2.  
  3. import com.arisux.avp.entities.tile.TileEntityTransformer;
  4. import com.arisux.avp.items.ItemFirearm;
  5.  
  6. import cpw.mods.fml.common.network.simpleimpl.IMessage;
  7. import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
  8. import cpw.mods.fml.common.network.simpleimpl.MessageContext;
  9. import io.netty.buffer.ByteBuf;
  10. import net.minecraft.client.Minecraft;
  11. import net.minecraft.tileentity.TileEntity;
  12. import net.minecraft.world.World;
  13. import net.minecraftforge.common.util.ForgeDirection;
  14.  
  15. public class PacketRotateTransformer implements IMessage, IMessageHandler<PacketRotateTransformer, PacketRotateTransformer>
  16. {
  17.     private int direction;
  18.     private int x;
  19.     private int y;
  20.     private int z;
  21.  
  22.     public PacketRotateTransformer()
  23.     {
  24.         ;
  25.     }
  26.  
  27.     public PacketRotateTransformer(int direction, int x, int y, int z)
  28.     {
  29.         this.direction = direction;
  30.         this.x = x;
  31.         this.y = y;
  32.         this.z = z;
  33.     }
  34.  
  35.     @Override
  36.     public void fromBytes(ByteBuf buf)
  37.     {
  38.         this.direction = buf.readInt();
  39.         this.x = buf.readInt();
  40.         this.y = buf.readInt();
  41.         this.z = buf.readInt();
  42.     }
  43.  
  44.     @Override
  45.     public void toBytes(ByteBuf buf)
  46.     {
  47.         buf.writeInt(direction);
  48.         buf.writeInt(x);
  49.         buf.writeInt(y);
  50.         buf.writeInt(z);
  51.     }
  52.  
  53.     @Override
  54.     public PacketRotateTransformer onMessage(PacketRotateTransformer packet, MessageContext ctx)
  55.     {
  56.         World world = Minecraft.getMinecraft().thePlayer.worldObj;
  57.         TileEntity tile = world.getTileEntity(x, y, z);
  58.  
  59.         if (world != null && tile != null && tile instanceof TileEntityTransformer)
  60.         {
  61.             TileEntityTransformer tileTransformer = (TileEntityTransformer) tile;
  62.             tileTransformer.acceptVoltageDirection = ForgeDirection.getOrientation(this.direction);
  63.         }
  64.  
  65.         return null;
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement