Search in sources :

Example 46 with LogisticsTileGenericPipe

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;
}
Also used : LogisticsRFPowerProviderTileEntity(logisticspipes.blocks.powertile.LogisticsRFPowerProviderTileEntity) LogisticsPowerJunctionTileEntity(logisticspipes.blocks.powertile.LogisticsPowerJunctionTileEntity) IGuiTileEntity(logisticspipes.interfaces.IGuiTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) LogisticsCraftingTableTileEntity(logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity) LogisticsIC2PowerProviderTileEntity(logisticspipes.blocks.powertile.LogisticsIC2PowerProviderTileEntity) LogisticsStatisticsTileEntity(logisticspipes.blocks.stats.LogisticsStatisticsTileEntity) EnumFacing(net.minecraft.util.EnumFacing) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) Nonnull(javax.annotation.Nonnull)

Example 47 with LogisticsTileGenericPipe

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;
}
Also used : PipeItemsBasicLogistics(logisticspipes.pipes.PipeItemsBasicLogistics) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe)

Example 48 with LogisticsTileGenericPipe

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();
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 49 with LogisticsTileGenericPipe

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) PipeItemsRemoteOrdererLogistics(logisticspipes.pipes.PipeItemsRemoteOrdererLogistics)

Example 50 with LogisticsTileGenericPipe

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);
                        }
                    }
                }));
            }
        }
    }
}
Also used : PipeRoutingConnectionType(logisticspipes.routing.PipeRoutingConnectionType) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) IRouter(logisticspipes.routing.IRouter) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) LinkedList(java.util.LinkedList) LaserData(logisticspipes.routing.LaserData) ExitRoute(logisticspipes.routing.ExitRoute)

Aggregations

LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)115 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)47 TileEntity (net.minecraft.tileentity.TileEntity)45 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)21 EnumFacing (net.minecraft.util.EnumFacing)15 ArrayList (java.util.ArrayList)14 List (java.util.List)12 EntityPlayer (net.minecraft.entity.player.EntityPlayer)10 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)10 BlockPos (net.minecraft.util.math.BlockPos)10 World (net.minecraft.world.World)9 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)9 HashMap (java.util.HashMap)8 LinkedList (java.util.LinkedList)8 PipeBlockRequestTable (logisticspipes.pipes.PipeBlockRequestTable)8 LogisticsPowerJunctionTileEntity (logisticspipes.blocks.powertile.LogisticsPowerJunctionTileEntity)7 MainProxy (logisticspipes.proxy.MainProxy)7 ExitRoute (logisticspipes.routing.ExitRoute)7 PipeLogisticsChassi (logisticspipes.pipes.PipeLogisticsChassi)6 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)6