equivalent-exchange-3/common/com/pahimar/ee3/network/packet/PacketTileUpdate.java

76 lines
1.9 KiB
Java
Raw Normal View History

2013-08-23 16:59:50 +02:00
package com.pahimar.ee3.network.packet;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.network.INetworkManager;
import net.minecraftforge.common.ForgeDirection;
import com.pahimar.ee3.EquivalentExchange3;
import com.pahimar.ee3.network.PacketTypeHandler;
import cpw.mods.fml.common.network.Player;
/**
* Equivalent-Exchange-3
*
* PacketTileUpdate
*
* @author pahimar
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*
*/
public class PacketTileUpdate extends PacketEE {
public int x, y, z;
public byte orientation;
public byte state;
public String customName;
public PacketTileUpdate() {
super(PacketTypeHandler.TILE, true);
}
public PacketTileUpdate(int x, int y, int z, ForgeDirection orientation, byte state, String customName) {
super(PacketTypeHandler.TILE, true);
this.x = x;
this.y = y;
this.z = z;
this.orientation = (byte) orientation.ordinal();
this.state = state;
this.customName = customName;
}
@Override
public void writeData(DataOutputStream data) throws IOException {
data.writeInt(x);
data.writeInt(y);
data.writeInt(z);
data.writeByte(orientation);
data.writeByte(state);
data.writeUTF(customName);
}
@Override
public void readData(DataInputStream data) throws IOException {
x = data.readInt();
y = data.readInt();
z = data.readInt();
orientation = data.readByte();
state = data.readByte();
customName = data.readUTF();
}
@Override
public void execute(INetworkManager manager, Player player) {
EquivalentExchange3.proxy.handleTileEntityPacket(x, y, z, ForgeDirection.getOrientation(orientation), state, customName);
}
}