use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class HSTubeGain method getConnectedEndTile.
@Override
public TileEntity getConnectedEndTile(ForgeDirection output) {
if (orientation.dir.getOpposite() == output) {
return container.getTile(output);
} else {
DoubleCoordinates pos = new DoubleCoordinates(0, 1, -3);
LPPositionSet<DoubleCoordinates> set = new LPPositionSet<>(DoubleCoordinates.class);
set.add(pos);
orientation.rotatePositions(set);
TileEntity subTile = pos.add(getLPPosition()).getTileEntity(getWorld());
if (subTile instanceof LogisticsTileGenericSubMultiBlock) {
return ((LogisticsTileGenericSubMultiBlock) subTile).getTile(output);
}
}
return null;
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class HSTubeGain method addCollisionBoxesToList.
@Override
public void addCollisionBoxesToList(List arraylist, AxisAlignedBB axisalignedbb) {
if (boxes == null || boxes.isEmpty()) {
boxes = new ArrayList<>();
double x = getX();
double y = getY();
double z = getZ();
for (int i = -1; i < 54; i++) {
double xOne = x;
double yOne = y;
double zOne = z;
double xTwo = x;
double yTwo = y + 2;
double zTwo = z;
if (orientation.getRenderOrientation() == TubeGainRenderOrientation.SOUTH) {
zOne += 4.0F * (i - 4) / 50;
zTwo += 4.0F * (i + 4) / 50;
xOne += 1;
xTwo -= 2;
} else if (orientation.getRenderOrientation() == TubeGainRenderOrientation.WEST) {
xOne -= 3;
xTwo -= 3;
xOne += 4.0F * (i - 4) / 50;
xTwo += 4.0F * (i + 4) / 50;
zOne -= 1;
zTwo += 2;
} else if (orientation.getRenderOrientation() == TubeGainRenderOrientation.NORTH) {
zOne += 1;
zTwo += 1;
zOne -= 4.0F * (i - 4) / 50;
zTwo -= 4.0F * (i + 4) / 50;
xOne -= 1;
xTwo += 2;
} else if (orientation.getRenderOrientation() == TubeGainRenderOrientation.EAST) {
xOne += 4;
xTwo += 4;
xOne -= 4.0F * (i - 4) / 50;
xTwo -= 4.0F * (i + 4) / 50;
zOne -= 1;
zTwo += 2;
}
AxisAlignedBB box = GainTubeRenderer.getObjectBoundsAt(AxisAlignedBB.getBoundingBox(Math.min(xOne, xTwo), Math.min(yOne, yTwo), Math.min(zOne, zTwo), Math.max(xOne, xTwo), Math.max(yOne, yTwo), Math.max(zOne, zTwo)).getOffsetBoundingBox(-x, -y, -z), orientation);
if (box != null) {
LPPositionSet<DoubleCoordinates> lpBox = new LPPositionSet<>(DoubleCoordinates.class);
lpBox.addFrom(box);
DoubleCoordinates center = lpBox.getCenter();
box = AxisAlignedBB.getBoundingBox(center.getXCoord() - 0.3D, center.getYCoord() - 0.3D, center.getZCoord() - 0.3D, center.getXCoord() + 0.3D, center.getYCoord() + 0.3D, center.getZCoord() + 0.3D);
if (box != null) {
AxisAlignedBB cBox = getCompleteBox();
if (box.minX < cBox.minX) {
box.minX = cBox.minX;
}
if (box.minY < cBox.minY) {
box.minY = cBox.minY;
}
if (box.minZ < cBox.minZ) {
box.minZ = cBox.minZ;
}
if (box.maxX > cBox.maxX) {
box.maxX = cBox.maxX;
}
if (box.maxY > cBox.maxY) {
box.maxY = cBox.maxY;
}
if (box.maxZ > cBox.maxZ) {
box.maxZ = cBox.maxZ;
}
box = box.getOffsetBoundingBox(x, y, z);
boxes.add(box);
}
}
}
}
arraylist.addAll(boxes.stream().filter(box -> box != null && (axisalignedbb == null || axisalignedbb.intersectsWith(box))).collect(Collectors.toList()));
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class HSTubeSCurve method addCollisionBoxesToList.
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "unchecked", "rawtypes" })
public void addCollisionBoxesToList(List arraylist, AxisAlignedBB axisalignedbb) {
if (boxes == null || boxes.isEmpty()) {
boxes = new ArrayList<>();
double x = getX();
double y = getY();
double z = getZ();
for (int i = -1; i < 54; i++) {
double xOne = x;
double yOne = y;
double zOne = z;
double xTwo = x;
double yTwo = y + 1;
double zTwo = z;
if (orientation.getRenderOrientation() == TurnSDirection.NORTH_INV || orientation.getRenderOrientation() == TurnSDirection.NORTH) {
zOne += 1;
zTwo += 1;
zOne -= 4.0F * (i - 4) / 50;
zTwo -= 4.0F * (i + 4) / 50;
xOne -= 1;
xTwo += 2;
} else if (orientation.getRenderOrientation() == TurnSDirection.EAST_INV || orientation.getRenderOrientation() == TurnSDirection.EAST) {
xOne += 4;
xTwo += 4;
xOne -= 4.0F * (i - 4) / 50;
xTwo -= 4.0F * (i + 4) / 50;
zOne -= 1;
zTwo += 2;
}
AxisAlignedBB box = SCurveTubeRenderer.getObjectBoundsAt(AxisAlignedBB.getBoundingBox(Math.min(xOne, xTwo), Math.min(yOne, yTwo), Math.min(zOne, zTwo), Math.max(xOne, xTwo), Math.max(yOne, yTwo), Math.max(zOne, zTwo)).getOffsetBoundingBox(-x, -y, -z), orientation);
if (box != null) {
LPPositionSet<DoubleCoordinates> lpBox = new LPPositionSet<>(DoubleCoordinates.class);
lpBox.addFrom(box);
DoubleCoordinates center = lpBox.getCenter();
box = AxisAlignedBB.getBoundingBox(center.getXCoord() - 0.3D, center.getYCoord() - 0.3D, center.getZCoord() - 0.3D, center.getXCoord() + 0.3D, center.getYCoord() + 0.3D, center.getZCoord() + 0.3D);
if (box != null) {
AxisAlignedBB cBox = getCompleteBox();
if (box.minX < cBox.minX) {
box.minX = cBox.minX;
}
if (box.minY < cBox.minY) {
box.minY = cBox.minY;
}
if (box.minZ < cBox.minZ) {
box.minZ = cBox.minZ;
}
if (box.maxX > cBox.maxX) {
box.maxX = cBox.maxX;
}
if (box.maxY > cBox.maxY) {
box.maxY = cBox.maxY;
}
if (box.maxZ > cBox.maxZ) {
box.maxZ = cBox.maxZ;
}
box = box.getOffsetBoundingBox(x, y, z);
boxes.add(box);
}
}
}
}
arraylist.addAll(boxes.stream().filter(box -> box != null && (axisalignedbb == null || axisalignedbb.intersectsWith(box))).collect(Collectors.toList()));
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class PipeItemsSatelliteLogistics method getRawInventory.
private IInventory getRawInventory(ForgeDirection dir) {
DoubleCoordinates pos = CoordinateUtils.add(new DoubleCoordinates(this), dir);
TileEntity tile = pos.getTileEntity(getWorld());
if (SimpleServiceLocator.pipeInformationManager.isItemPipe(tile)) {
return null;
}
if (!(tile instanceof IInventory)) {
return null;
}
return InventoryHelper.getInventory((IInventory) tile);
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class BaseWrapperClass method load.
@Override
public void load(NBTTagCompound nbt) {
if (object != null) {
return;
}
String type = nbt.getString("Type");
if (type.equals("")) {
return;
}
if (type.equals("LPGlobalCCAccess")) {
object = LogisticsPipes.getComputerLP();
checkType();
} else if (type.equals("CoreRoutedPipe")) {
int x = nbt.getInteger("X");
int y = nbt.getInteger("Y");
int z = nbt.getInteger("Z");
final DoubleCoordinates pos = new DoubleCoordinates(x, y, z);
final int dim = nbt.getInteger("Dim");
QueuedTasks.queueTask(() -> {
World world = DimensionManager.getWorld(dim);
if (world != null) {
TileEntity tile = pos.getTileEntity(world);
if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe instanceof CoreRoutedPipe) {
object = ((LogisticsTileGenericPipe) tile).pipe;
checkType();
}
}
return null;
});
} else if (type.equals("CCItemIdentifierImplementation")) {
ItemStack stack = ItemStack.loadItemStackFromNBT(nbt);
if (stack != null) {
object = new CCItemIdentifierImplementation(ItemIdentifier.get(stack));
checkType();
}
} else if (type.equals("CCItemIdentifierStackImplementation")) {
ItemStack stack = ItemStack.loadItemStackFromNBT(nbt);
if (stack != null) {
object = new CCItemIdentifierStackImplementation(ItemIdentifierStack.getFromStack(stack));
checkType();
}
} else if (type.equals("CCItemIdentifierBuilder")) {
ItemStack stack = ItemStack.loadItemStackFromNBT(nbt);
if (stack != null) {
CCItemIdentifierBuilder builder = new CCItemIdentifierBuilder();
builder.setItemID(Double.valueOf(Item.getIdFromItem(stack.getItem())));
builder.setItemData(Double.valueOf(stack.getItemDamage()));
object = builder;
checkType();
}
} else if (type.equals("LogisticsSolidTileEntity")) {
int x = nbt.getInteger("X");
int y = nbt.getInteger("Y");
int z = nbt.getInteger("Z");
final DoubleCoordinates pos = new DoubleCoordinates(x, y, z);
final int dim = nbt.getInteger("Dim");
QueuedTasks.queueTask(() -> {
World world = DimensionManager.getWorld(dim);
if (world != null) {
TileEntity tile = pos.getTileEntity(world);
if (tile instanceof LogisticsSolidTileEntity) {
object = tile;
checkType();
}
}
return null;
});
} else {
System.out.println("Unknown type to load");
}
}
Aggregations