use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class LogisticsSolidBlock method getActualState.
@Nonnull
@Override
public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess worldIn, BlockPos pos) {
state = super.getActualState(state, worldIn, pos);
TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof LogisticsSolidTileEntity) {
LogisticsSolidTileEntity ste = (LogisticsSolidTileEntity) tile;
int rotation = ste.getRotation();
state = state.withProperty(rotationProperty, Math.min(Math.max(rotation, 0), 3)).withProperty(active, ste.isActive());
}
if (tile != null) {
for (EnumFacing side : EnumFacing.VALUES) {
boolean render = true;
TileEntity sideTile = worldIn.getTileEntity(pos.offset(side));
if (sideTile instanceof LogisticsTileGenericPipe) {
LogisticsTileGenericPipe tilePipe = (LogisticsTileGenericPipe) sideTile;
if (tilePipe.renderState.pipeConnectionMatrix.isConnected(side.getOpposite())) {
render = false;
}
}
state = state.withProperty(connectionPropertys.get(side), render);
}
}
return state;
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class LogisticsNewRenderPipe method getBasicPipeFrameRenderList.
public static List<RenderEntry> getBasicPipeFrameRenderList() {
if (pipeFrameRenderList.isEmpty()) {
LogisticsTileGenericPipe pipe = new LogisticsTileGenericPipe();
pipe.pipe = new PipeItemsBasicLogistics(null);
fillObjectsToRenderList(pipeFrameRenderList, pipe, pipe.renderState);
}
return pipeFrameRenderList;
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class PipeRenderState method checkForRenderUpdate.
public void checkForRenderUpdate(IBlockAccess worldIn, BlockPos blockPos) {
boolean[] solidSides = new boolean[6];
for (EnumFacing dir : EnumFacing.VALUES) {
DoubleCoordinates pos = CoordinateUtils.add(new DoubleCoordinates(blockPos), dir);
IBlockState blockSide = pos.getBlockState(worldIn);
if (blockSide != null && blockSide.isSideSolid(worldIn, pos.getBlockPos(), dir.getOpposite()) && !pipeConnectionMatrix.isConnected(dir)) {
solidSides[dir.ordinal()] = true;
}
}
if (!Arrays.equals(solidSides, solidSidesCache)) {
solidSidesCache = solidSides.clone();
clearRenderCaches();
}
DoubleCoordinates pos = new DoubleCoordinates(blockPos);
TileEntity tile = pos.getTileEntity(worldIn);
if (tile instanceof LogisticsTileGenericPipe) {
boolean hasParts = SimpleServiceLocator.mcmpProxy.hasParts((LogisticsTileGenericPipe) tile);
if (savedStateHasMCMultiParts != hasParts) {
savedStateHasMCMultiParts = hasParts;
clearRenderCaches();
}
}
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class RemoteOrderer method getPipe.
public static PipeItemsRemoteOrdererLogistics getPipe(@Nonnull ItemStack stack) {
if (stack.isEmpty() || !stack.hasTagCompound()) {
return null;
}
final NBTTagCompound tag = Objects.requireNonNull(stack.getTagCompound());
if (!tag.hasKey("connectedPipe-x") || !tag.hasKey("connectedPipe-y") || !tag.hasKey("connectedPipe-z")) {
return null;
}
if (!tag.hasKey("connectedPipe-world-dim")) {
return null;
}
int dim = tag.getInteger("connectedPipe-world-dim");
World world = DimensionManager.getWorld(dim);
if (world == null) {
return null;
}
TileEntity tile = world.getTileEntity(new BlockPos(tag.getInteger("connectedPipe-x"), tag.getInteger("connectedPipe-y"), tag.getInteger("connectedPipe-z")));
if (!(tile instanceof LogisticsTileGenericPipe)) {
return null;
}
CoreUnroutedPipe pipe = ((LogisticsTileGenericPipe) tile).pipe;
if (pipe instanceof PipeItemsRemoteOrdererLogistics) {
return (PipeItemsRemoteOrdererLogistics) pipe;
}
return null;
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class RequestRoutingLasersPacket method handleRouteInDirection.
private void handleRouteInDirection(final LogisticsTileGenericPipe pipeIn, ForgeDirection dirIn, ArrayList<ExitRoute> connectedRoutersIn, final List<LaserData> lasersIn, EnumSet<PipeRoutingConnectionType> connectionTypeIn, final Log logIn) {
List<DataEntry> worklist = new LinkedList<>();
worklist.add(new DataEntry(pipeIn, dirIn, connectedRoutersIn, lasersIn, connectionTypeIn, logIn));
while (!worklist.isEmpty()) {
final DataEntry entry = worklist.remove(0);
final LogisticsTileGenericPipe pipe = entry.pipe;
final ForgeDirection dir = entry.dir;
final ArrayList<ExitRoute> connectedRouters = entry.connectedRouters;
final List<LaserData> lasers = entry.lasers;
final EnumSet<PipeRoutingConnectionType> connectionType = entry.connectionType;
final Log log = entry.log;
if (LPConstants.DEBUG) {
log.log("Size: " + connectedRouters.size());
}
lasers.add(new LaserData(pipe.xCoord, pipe.yCoord, pipe.zCoord, dir, connectionType).setStartPipe(firstPipe));
firstPipe = false;
HashMap<CoreRoutedPipe, ExitRoute> map = PathFinder.paintAndgetConnectedRoutingPipes(pipe, dir, Configs.LOGISTICS_DETECTION_COUNT, Configs.LOGISTICS_DETECTION_LENGTH, (worldObj, laser) -> {
if (pipe.getWorld() == worldObj) {
lasers.add(laser);
}
}, connectionType);
for (CoreRoutedPipe connectedPipe : map.keySet()) {
IRouter newRouter = connectedPipe.getRouter();
Iterator<ExitRoute> iRoutes = connectedRouters.iterator();
while (iRoutes.hasNext()) {
ExitRoute route = iRoutes.next();
if (route.destination == newRouter) {
iRoutes.remove();
}
}
}
Map<CoreRoutedPipe, ArrayList<ExitRoute>> sort = new HashMap<>();
for (ExitRoute routeTo : connectedRouters) {
ExitRoute result = null;
CoreRoutedPipe resultPipe = null;
for (Entry<CoreRoutedPipe, ExitRoute> routeCanidate : map.entrySet()) {
List<ExitRoute> distances = routeCanidate.getValue().destination.getDistanceTo(routeTo.destination);
for (ExitRoute distance : distances) {
if (distance.isSameWay(routeTo)) {
if (result == null || result.distanceToDestination > distance.distanceToDestination) {
result = distance;
resultPipe = routeCanidate.getKey();
}
}
}
}
if (result == null) {
continue;
}
if (!sort.containsKey(resultPipe)) {
sort.put(resultPipe, new ArrayList<>());
}
if (!sort.get(resultPipe).contains(result)) {
sort.get(resultPipe).add(result);
}
}
for (Entry<CoreRoutedPipe, ArrayList<ExitRoute>> connectedPipe : sort.entrySet()) {
HashMap<ForgeDirection, ArrayList<ExitRoute>> routers = new HashMap<>();
for (ExitRoute exit : connectedPipe.getValue()) {
if (!routers.containsKey(exit.exitOrientation)) {
routers.put(exit.exitOrientation, new ArrayList<>());
}
if (!routers.get(exit.exitOrientation).contains(exit)) {
routers.get(exit.exitOrientation).add(exit);
}
}
for (final ForgeDirection exitDir : routers.keySet()) {
if (exitDir == ForgeDirection.UNKNOWN) {
continue;
}
worklist.add(new DataEntry(connectedPipe.getKey().container, exitDir, routers.get(exitDir), lasers, map.get(connectedPipe.getKey()).connectionDetails, new Log() {
@Override
void log(String logString) {
if (LPConstants.DEBUG) {
log.log(exitDir.name() + ": " + logString);
}
}
}));
}
}
}
}
Aggregations