aboutsummaryrefslogtreecommitdiff
path: root/main/java/gregtech/common/blocks/GT_Packet_Ores.java
blob: c6648b17d0d3f83717ff02dc94043fb440f90e22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package gregtech.common.blocks;

import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import gregtech.api.net.GT_Packet;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class GT_Packet_Ores
  extends GT_Packet
{
  private int mX;
  private int mZ;
  private short mY;
  private short mMetaData;
  
  public GT_Packet_Ores()
  {
    super(true);
  }
  
  public GT_Packet_Ores(int aX, short aY, int aZ, short aMetaData)
  {
    super(false);
    this.mX = aX;
    this.mY = aY;
    this.mZ = aZ;
    this.mMetaData = aMetaData;
  }
  
  public byte[] encode()
  {
    ByteArrayDataOutput tOut = ByteStreams.newDataOutput(12);
    
    tOut.writeInt(this.mX);
    tOut.writeShort(this.mY);
    tOut.writeInt(this.mZ);
    tOut.writeShort(this.mMetaData);
    
    return tOut.toByteArray();
  }
  
  public GT_Packet decode(ByteArrayDataInput aData)
  {
    return new GT_Packet_Ores(aData.readInt(), aData.readShort(), aData.readInt(), aData.readShort());
  }
  
  public void process(IBlockAccess aWorld)
  {
    if (aWorld != null)
    {
      TileEntity tTileEntity = aWorld.getTileEntity(this.mX, this.mY, this.mZ);
      if ((tTileEntity instanceof GT_TileEntity_Ores)) {
        ((GT_TileEntity_Ores)tTileEntity).mMetaData = this.mMetaData;
      }
      if (((aWorld instanceof World)) && (((World)aWorld).isRemote)) {
        ((World)aWorld).markBlockForUpdate(this.mX, this.mY, this.mZ);
      }
    }
  }
  
  public byte getPacketID()
  {
    return 3;
  }
}



/* Location:           F:\Torrent\minecraft\jd-gui-0.3.6.windows\gregtech_1.7.10-5.07.07-dev.jar

 * Qualified Name:     gregtech.common.blocks.GT_Packet_Ores

 * JD-Core Version:    0.7.0.1

 */