use of buildcraft.core.DefaultAreaProvider in project BuildCraft by BuildCraft.
the class TileQuarry method setBoundaries.
private void setBoundaries(boolean useDefaultI) {
boolean useDefault = useDefaultI;
if (BuildCraftBuilders.quarryLoadsChunks && chunkTicket == null) {
chunkTicket = ForgeChunkManager.requestTicket(BuildCraftBuilders.instance, worldObj, Type.NORMAL);
}
if (chunkTicket != null) {
chunkTicket.getModData().setInteger("quarryX", pos.getX());
chunkTicket.getModData().setInteger("quarryY", pos.getY());
chunkTicket.getModData().setInteger("quarryZ", pos.getZ());
ForgeChunkManager.forceChunk(chunkTicket, new ChunkPos(pos.getX() >> 4, pos.getZ() >> 4));
}
IAreaProvider a = null;
if (!useDefault) {
a = Utils.getNearbyAreaProvider(worldObj, pos);
}
if (a == null) {
a = new DefaultAreaProvider(pos, pos.add(new BlockPos(10, 4, 10)));
useDefault = true;
}
int xSize = a.max().getX() - a.min().getX() + 1;
int zSize = a.max().getZ() - a.min().getZ() + 1;
if (xSize < 3 || zSize < 3 || (chunkTicket != null && ((xSize * zSize) >> 8) >= chunkTicket.getMaxChunkListDepth())) {
if (placedBy != null) {
placedBy.addChatMessage(new TextComponentTranslation("chat.buildcraft.quarry.tooSmall", xSize, zSize, chunkTicket != null ? chunkTicket.getMaxChunkListDepth() : 0));
}
a = new DefaultAreaProvider(pos, pos.add(new BlockPos(10, 4, 10)));
useDefault = true;
}
xSize = a.max().getX() - a.min().getX() + 1;
int ySize = a.max().getY() - a.min().getY() + 1;
zSize = a.max().getZ() - a.min().getZ() + 1;
box.initialize(a);
if (ySize < 5) {
ySize = 5;
box.setMax(VecUtil.replaceValue(box.max(), Axis.Y, box.min().getY() + ySize - 1));
}
if (useDefault) {
int xMin, zMin;
EnumFacing face = worldObj.getBlockState(pos).getValue(BuildCraftProperties.BLOCK_FACING).getOpposite();
switch(face) {
case EAST:
xMin = pos.getX() + 1;
zMin = pos.getZ() - 4 - 1;
break;
case WEST:
xMin = pos.getX() - 9 - 2;
zMin = pos.getZ() - 4 - 1;
break;
case SOUTH:
xMin = pos.getX() - 4 - 1;
zMin = pos.getZ() + 1;
break;
case NORTH:
default:
xMin = pos.getX() - 4 - 1;
zMin = pos.getZ() - 9 - 2;
break;
}
box.reset();
box.setMin(new BlockPos(xMin, pos.getY(), zMin));
box.setMax(new BlockPos(xMin + xSize - 1, pos.getY() + ySize - 1, zMin + zSize - 1));
}
a.removeFromWorld();
if (chunkTicket != null) {
forceChunkLoading(chunkTicket);
}
sendNetworkUpdate();
}
Aggregations