use of buildcraft.builders.addon.AddonFillerPlanner in project BuildCraft by BuildCraft.
the class TileFiller method readPayload.
@Override
public void readPayload(int id, PacketBufferBC buffer, Side side, MessageContext ctx) throws IOException {
super.readPayload(id, buffer, side, ctx);
if (side == Side.CLIENT) {
if (id == NET_RENDER_DATA) {
builder.readFromByteBuf(buffer);
readPayload(NET_BOX, buffer, side, ctx);
} else if (id == NET_GUI_DATA || id == NET_GUI_TICK) {
readPayload(NET_CAN_EXCAVATE, buffer, side, ctx);
readPayload(NET_INVERT, buffer, side, ctx);
readPayload(NET_PATTERN, buffer, side, ctx);
builder.readFromByteBuf(buffer);
finished = buffer.readBoolean();
lockedTicks = buffer.readBoolean() ? (byte) 1 : (byte) 0;
mode = buffer.readEnumValue(Mode.class);
} else if (id == NET_BOX) {
box.readData(buffer);
markerBox = buffer.readBoolean();
if (buffer.readBoolean()) {
UUID volumeBoxId = buffer.readUniqueId();
VolumeBox volumeBox = world.isRemote ? ClientVolumeBoxes.INSTANCE.volumeBoxes.stream().filter(localVolumeBox -> localVolumeBox.id.equals(volumeBoxId)).findFirst().orElseThrow(NullPointerException::new) : WorldSavedDataVolumeBoxes.get(world).getVolumeBoxFromId(volumeBoxId);
addon = (AddonFillerPlanner) volumeBox.addons.get(buffer.readEnumValue(EnumAddonSlot.class));
}
} else if (id == NET_CAN_EXCAVATE) {
canExcavate = buffer.readBoolean();
} else if (id == NET_INVERT) {
inverted = buffer.readBoolean();
} else if (id == NET_PATTERN) {
patternStatement.readFromBuffer(buffer);
}
}
if (side == Side.SERVER) {
if (id == NET_CAN_EXCAVATE) {
canExcavate = buffer.readBoolean();
sendNetworkGuiUpdate(NET_CAN_EXCAVATE);
}
}
}
use of buildcraft.builders.addon.AddonFillerPlanner in project BuildCraft by BuildCraft.
the class TileFiller method onPlacedBy.
@Override
public void onPlacedBy(EntityLivingBase placer, ItemStack stack) {
super.onPlacedBy(placer, stack);
if (world.isRemote) {
return;
}
IBlockState blockState = world.getBlockState(pos);
WorldSavedDataVolumeBoxes volumeBoxes = WorldSavedDataVolumeBoxes.get(world);
BlockPos offsetPos = pos.offset(blockState.getValue(BlockBCBase_Neptune.PROP_FACING).getOpposite());
VolumeBox volumeBox = volumeBoxes.getVolumeBoxAt(offsetPos);
TileEntity tile = world.getTileEntity(offsetPos);
if (volumeBox != null) {
addon = (AddonFillerPlanner) volumeBox.addons.values().stream().filter(AddonFillerPlanner.class::isInstance).findFirst().orElse(null);
if (addon != null) {
volumeBox.locks.add(new Lock(new Lock.Cause.CauseBlock(pos, blockState.getBlock()), new Lock.Target.TargetAddon(addon.getSlot()), new Lock.Target.TargetRemove(), new Lock.Target.TargetResize(), new Lock.Target.TargetUsedByMachine(Lock.Target.TargetUsedByMachine.EnumType.STRIPES_WRITE)));
volumeBoxes.markDirty();
addon.updateBuildingInfo();
markerBox = false;
} else {
box.reset();
box.setMin(volumeBox.box.min());
box.setMax(volumeBox.box.max());
volumeBox.locks.add(new Lock(new Lock.Cause.CauseBlock(pos, blockState.getBlock()), new Lock.Target.TargetRemove(), new Lock.Target.TargetResize(), new Lock.Target.TargetUsedByMachine(Lock.Target.TargetUsedByMachine.EnumType.STRIPES_WRITE)));
volumeBoxes.markDirty();
markerBox = false;
}
} else if (tile instanceof IAreaProvider) {
IAreaProvider provider = (IAreaProvider) tile;
box.reset();
box.setMin(provider.min());
box.setMax(provider.max());
provider.removeFromWorld();
}
updateBuildingInfo();
sendNetworkUpdate(NET_RENDER_DATA);
}
Aggregations