use of logisticspipes.utils.LPPositionSet in project LogisticsPipes by RS485.
the class HSTubeSpeedup method addCollisionBoxesToList.
@Override
public void addCollisionBoxesToList(List arraylist, AxisAlignedBB axisalignedbb) {
DoubleCoordinates pos = getLPPosition();
DoubleCoordinates posMin = new DoubleCoordinates(LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS);
DoubleCoordinates posMax = new DoubleCoordinates(LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS, -3);
orientation.rotatePositions(posMin);
orientation.rotatePositions(posMax);
if (orientation == SpeedupDirection.EAST) {
pos.add(new DoubleCoordinates(1, 0, 0));
} else if (orientation == SpeedupDirection.SOUTH) {
pos.add(new DoubleCoordinates(1, 0, 1));
} else if (orientation == SpeedupDirection.WEST) {
pos.add(new DoubleCoordinates(0, 0, 1));
}
posMin.add(pos);
posMax.add(pos);
LPPositionSet<DoubleCoordinates> set = new LPPositionSet<>(DoubleCoordinates.class);
set.add(posMin);
set.add(posMax);
AxisAlignedBB box = set.toABB();
if (box != null && (axisalignedbb == null || axisalignedbb.intersectsWith(box))) {
arraylist.add(box);
}
}
use of logisticspipes.utils.LPPositionSet 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 logisticspipes.utils.LPPositionSet 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 logisticspipes.utils.LPPositionSet 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 logisticspipes.utils.LPPositionSet in project LogisticsPipes by RS485.
the class ItemLogisticsPipe method onItemUse.
@Override
public //TODO use own pipe handling
boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int sideI, float par8, float par9, float par10) {
int side = sideI;
Block block = LogisticsPipes.LogisticsPipeBlock;
int i = x;
int j = y;
int k = z;
Block worldBlock = world.getBlock(i, j, k);
if (worldBlock == Blocks.snow) {
side = 1;
} else if (worldBlock != Blocks.vine && worldBlock != Blocks.tallgrass && worldBlock != Blocks.deadbush && (worldBlock == null || !worldBlock.isReplaceable(world, i, j, k))) {
if (side == 0) {
j--;
}
if (side == 1) {
j++;
}
if (side == 2) {
k--;
}
if (side == 3) {
k++;
}
if (side == 4) {
i--;
}
if (side == 5) {
i++;
}
}
if (itemstack.stackSize == 0) {
return false;
}
if (!dummyPipe.isMultiBlock()) {
if (world.canPlaceEntityOnSide(block, i, j, k, false, side, entityplayer, itemstack)) {
CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.createPipe(this);
if (pipe == null) {
LogisticsPipes.log.log(Level.WARN, "Pipe failed to create during placement at {0},{1},{2}", new Object[] { i, j, k });
return true;
}
if (LogisticsBlockGenericPipe.placePipe(pipe, world, i, j, k, block, 0)) {
block.onBlockPlacedBy(world, i, j, k, entityplayer, itemstack);
itemstack.stackSize--;
}
return true;
} else {
return false;
}
} else {
CoreMultiBlockPipe multiPipe = (CoreMultiBlockPipe) dummyPipe;
boolean isFreeSpace = true;
DoubleCoordinates placeAt = new DoubleCoordinates(i, j, k);
LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> globalPos = new LPPositionSet<>(DoubleCoordinatesType.class);
globalPos.add(new DoubleCoordinatesType<>(placeAt, CoreMultiBlockPipe.SubBlockTypeForShare.NON_SHARE));
LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> positions = multiPipe.getSubBlocks();
ITubeOrientation orientation = multiPipe.getTubeOrientation(entityplayer, i, k);
if (orientation == null) {
return false;
}
orientation.rotatePositions(positions);
positions.stream().map(pos -> pos.add(placeAt)).forEach(globalPos::add);
globalPos.addToAll(orientation.getOffset());
placeAt.add(orientation.getOffset());
for (DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare> pos : globalPos) {
if (!world.canPlaceEntityOnSide(block, pos.getXInt(), pos.getYInt(), pos.getZInt(), false, side, entityplayer, itemstack)) {
TileEntity tile = world.getTileEntity(pos.getXInt(), pos.getYInt(), pos.getZInt());
boolean canPlace = false;
if (tile instanceof LogisticsTileGenericSubMultiBlock) {
if (CoreMultiBlockPipe.canShare(((LogisticsTileGenericSubMultiBlock) tile).getSubTypes(), pos.getType())) {
canPlace = true;
}
}
if (!canPlace) {
isFreeSpace = false;
break;
}
}
}
if (isFreeSpace) {
CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.createPipe(this);
if (pipe == null) {
LogisticsPipes.log.log(Level.WARN, "Pipe failed to create during placement at {0},{1},{2}", new Object[] { i, j, k });
return true;
}
if (LogisticsBlockGenericPipe.placePipe(pipe, world, placeAt.getXInt(), placeAt.getYInt(), placeAt.getZInt(), block, 0, orientation)) {
//TODO
block.onBlockPlacedBy(world, i, j, k, entityplayer, itemstack);
itemstack.stackSize--;
}
return true;
} else {
return false;
}
}
}
Aggregations