use of gregtech.api.util.BlockPosFace in project GregTech by GregTechCEu.
the class MetaTileEntityCentralMonitor method writeCovers.
private void writeCovers(PacketBuffer buf) {
if (netCovers == null) {
buf.writeInt(0);
} else {
buf.writeInt(netCovers.size());
for (BlockPosFace cover : netCovers) {
buf.writeBlockPos(cover.pos);
buf.writeByte(cover.facing.getIndex());
}
}
if (remoteCovers == null) {
buf.writeInt(0);
} else {
buf.writeInt(remoteCovers.size());
for (BlockPosFace cover : remoteCovers) {
buf.writeBlockPos(cover.pos);
buf.writeByte(cover.facing.getIndex());
}
}
}
use of gregtech.api.util.BlockPosFace in project GregTech by GregTechCEu.
the class MetaTileEntityCentralMonitor method readCovers.
private void readCovers(PacketBuffer buf) {
netCovers = new HashSet<>();
remoteCovers = new HashSet<>();
int size = buf.readInt();
for (int i = 0; i < size; i++) {
netCovers.add(new BlockPosFace(buf.readBlockPos(), EnumFacing.byIndex(buf.readByte())));
}
size = buf.readInt();
for (int i = 0; i < size; i++) {
remoteCovers.add(new BlockPosFace(buf.readBlockPos(), EnumFacing.byIndex(buf.readByte())));
}
}
use of gregtech.api.util.BlockPosFace in project GregTech by GregTechCEu.
the class MetaTileEntityMonitorScreen method readSync.
private void readSync(PacketBuffer buf) {
if (buf.readBoolean()) {
BlockPos pos = buf.readBlockPos();
EnumFacing side = EnumFacing.byIndex(buf.readByte());
BlockPosFace pair = new BlockPosFace(pos, side);
if (!pair.equals(this.coverPos)) {
this.coverTMP = null;
this.coverPos = pair;
}
} else {
this.coverPos = null;
this.coverTMP = null;
}
this.mode = CoverDigitalInterface.MODE.VALUES[buf.readByte()];
this.slot = buf.readVarInt();
this.scale = buf.readFloat();
this.frameColor = buf.readVarInt();
updateProxyPlugin();
}
use of gregtech.api.util.BlockPosFace in project GregTech by GregTechCEu.
the class MetaTileEntityCentralMonitor method checkCovers.
private boolean checkCovers() {
boolean dirty = false;
updateNodes();
Set<BlockPosFace> checkCovers = new HashSet<>();
World world = this.getWorld();
for (BlockPos pos : activeNodes) {
TileEntity tileEntityCable = world.getTileEntity(pos);
if (!(tileEntityCable instanceof TileEntityPipeBase)) {
continue;
}
for (EnumFacing facing : EnumFacing.VALUES) {
if (((TileEntityPipeBase<?, ?>) tileEntityCable).isConnected(facing)) {
TileEntity tileEntity = world.getTileEntity(pos.offset(facing));
if (tileEntity instanceof MetaTileEntityHolder) {
MetaTileEntity metaTileEntity = ((MetaTileEntityHolder) tileEntity).getMetaTileEntity();
if (metaTileEntity != null) {
CoverBehavior cover = metaTileEntity.getCoverAtSide(facing.getOpposite());
if (cover instanceof CoverDigitalInterface && ((CoverDigitalInterface) cover).isProxy()) {
checkCovers.add(new BlockPosFace(metaTileEntity.getPos(), cover.attachedSide));
}
}
}
}
}
}
Iterator<BlockPosFace> iterator = remoteCovers.iterator();
while (iterator.hasNext()) {
BlockPosFace blockPosFace = iterator.next();
TileEntity tileEntity = world.getTileEntity(blockPosFace.pos);
if (tileEntity instanceof MetaTileEntityHolder) {
MetaTileEntity metaTileEntity = ((MetaTileEntityHolder) tileEntity).getMetaTileEntity();
if (metaTileEntity != null) {
CoverBehavior cover = metaTileEntity.getCoverAtSide(blockPosFace.facing);
if (cover instanceof CoverDigitalInterface && ((CoverDigitalInterface) cover).isProxy()) {
continue;
}
}
}
iterator.remove();
dirty = true;
}
if (checkCovers.size() != netCovers.size() || !netCovers.containsAll(checkCovers)) {
netCovers = checkCovers;
dirty = true;
}
return dirty;
}
use of gregtech.api.util.BlockPosFace in project GregTech by GregTechCEu.
the class MetaTileEntityMonitorScreen method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound data) {
super.readFromNBT(data);
this.frameColor = data.hasKey("color") ? data.getInteger("color") : 0XFF00Ff00;
this.scale = data.hasKey("scale") ? data.getFloat("scale") : 1;
this.slot = data.hasKey("slot") ? data.getInteger("slot") : 0;
this.mode = CoverDigitalInterface.MODE.VALUES[data.hasKey("mode") ? data.getByte("mode") : 0];
this.inventory.deserializeNBT(data.getCompoundTag("Inventory"));
if (data.hasKey("coverPos") && data.hasKey("coverSide")) {
BlockPos pos = NBTUtil.getPosFromTag(data.getCompoundTag("coverPos"));
EnumFacing side = EnumFacing.byIndex(data.getByte("coverSide"));
this.coverPos = new BlockPosFace(pos, side);
} else {
this.coverPos = null;
}
MonitorPluginBaseBehavior behavior = MonitorPluginBaseBehavior.getBehavior(this.inventory.getStackInSlot(0));
if (behavior == null) {
unloadPlugin();
} else {
loadPlugin(behavior);
}
}
Aggregations