2015-06-23 22:29:05 +00:00
|
|
|
package gregtech.common.blocks;
|
|
|
|
|
|
|
|
import com.google.common.io.ByteArrayDataInput;
|
|
|
|
import com.google.common.io.ByteArrayDataOutput;
|
|
|
|
import com.google.common.io.ByteStreams;
|
2016-09-12 11:07:17 +00:00
|
|
|
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine;
|
2015-06-23 22:29:05 +00:00
|
|
|
import gregtech.api.net.GT_Packet;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2016-08-10 19:43:37 +00:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2015-06-23 22:29:05 +00:00
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
import net.minecraft.world.World;
|
2016-09-12 11:07:17 +00:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2015-06-23 22:29:05 +00:00
|
|
|
|
|
|
|
public class GT_Packet_Ores
|
2015-10-22 02:06:25 +00:00
|
|
|
extends GT_Packet {
|
|
|
|
private int mX;
|
|
|
|
private int mZ;
|
2016-08-10 19:43:37 +00:00
|
|
|
private int mY;
|
2015-10-22 02:06:25 +00:00
|
|
|
private short mMetaData;
|
|
|
|
|
|
|
|
public GT_Packet_Ores() {
|
|
|
|
super(true);
|
|
|
|
}
|
|
|
|
|
2016-08-10 19:43:37 +00:00
|
|
|
public GT_Packet_Ores(BlockPos blockPos, short aMetaData) {
|
2015-10-22 02:06:25 +00:00
|
|
|
super(false);
|
2016-08-10 19:43:37 +00:00
|
|
|
this.mX = blockPos.getX();
|
|
|
|
this.mY = blockPos.getY();
|
|
|
|
this.mZ = blockPos.getZ();
|
2015-10-22 02:06:25 +00:00
|
|
|
this.mMetaData = aMetaData;
|
|
|
|
}
|
|
|
|
|
2016-08-10 19:43:37 +00:00
|
|
|
@Override
|
2015-10-22 02:06:25 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2016-08-10 19:43:37 +00:00
|
|
|
@Override
|
2015-10-22 02:06:25 +00:00
|
|
|
public GT_Packet decode(ByteArrayDataInput aData) {
|
2016-08-10 19:43:37 +00:00
|
|
|
return new GT_Packet_Ores(new BlockPos(aData.readInt(), aData.readShort(), aData.readInt()), aData.readShort());
|
2015-10-22 02:06:25 +00:00
|
|
|
}
|
|
|
|
|
2016-08-10 19:43:37 +00:00
|
|
|
@Override
|
2015-10-22 02:06:25 +00:00
|
|
|
public void process(IBlockAccess aWorld) {
|
|
|
|
if (aWorld != null) {
|
2016-08-10 19:43:37 +00:00
|
|
|
BlockPos blockPos = new BlockPos(this.mX, this.mY, this.mZ);
|
2016-09-12 11:07:17 +00:00
|
|
|
GT_TileEntity_Ores tileEntity_ores = (GT_TileEntity_Ores) aWorld.getTileEntity(blockPos);
|
|
|
|
if(tileEntity_ores != null) {
|
|
|
|
tileEntity_ores.mMetaData = mMetaData;
|
|
|
|
tileEntity_ores.causeChunkUpdate();
|
2015-10-22 02:06:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-10 19:43:37 +00:00
|
|
|
@Override
|
2015-10-22 02:06:25 +00:00
|
|
|
public byte getPacketID() {
|
|
|
|
return 3;
|
2015-06-23 22:29:05 +00:00
|
|
|
}
|
|
|
|
}
|