Search in sources :

Example 31 with CoreRoutedPipe

use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.

the class TextureMatrix method refreshStates.

public void refreshStates(CoreUnroutedPipe pipe) {
    if (textureIndex != pipe.getTextureIndex()) {
        dirty = true;
    }
    textureIndex = pipe.getTextureIndex();
    if (isRouted != pipe.isRoutedPipe()) {
        dirty = true;
    }
    isRouted = pipe.isRoutedPipe();
    if (isRouted) {
        CoreRoutedPipe cPipe = (CoreRoutedPipe) pipe;
        for (int i = 0; i < 6; i++) {
            if (isRoutedInDir[i] != cPipe.getRouter().isRoutedExit(ForgeDirection.getOrientation(i))) {
                dirty = true;
            }
            isRoutedInDir[i] = cPipe.getRouter().isRoutedExit(ForgeDirection.getOrientation(i));
        }
        for (int i = 0; i < 6; i++) {
            if (isSubPowerInDir[i] != cPipe.getRouter().isSubPoweredExit(ForgeDirection.getOrientation(i))) {
                dirty = true;
            }
            isSubPowerInDir[i] = cPipe.getRouter().isSubPoweredExit(ForgeDirection.getOrientation(i));
        }
        if (hasPowerUpgrade != (cPipe.getUpgradeManager().hasRFPowerSupplierUpgrade() || cPipe.getUpgradeManager().getIC2PowerLevel() > 0)) {
            dirty = true;
        }
        hasPowerUpgrade = cPipe.getUpgradeManager().hasRFPowerSupplierUpgrade() || cPipe.getUpgradeManager().getIC2PowerLevel() > 0;
        if (hasPower != (cPipe._textureBufferPowered || Configs.LOGISTICS_POWER_USAGE_DISABLED)) {
            dirty = true;
        }
        hasPower = cPipe._textureBufferPowered || Configs.LOGISTICS_POWER_USAGE_DISABLED;
        if (isFluid != cPipe.isFluidPipe()) {
            dirty = true;
        }
        isFluid = cPipe.isFluidPipe();
        if (pointedOrientation != cPipe.getPointedOrientation()) {
            dirty = true;
        }
        pointedOrientation = cPipe.getPointedOrientation();
    } else {
        isRoutedInDir = new boolean[6];
    }
}
Also used : CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Example 32 with CoreRoutedPipe

use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.

the class RequestTreeNode method getCrafters.

private static List<Pair<ICraftingTemplate, List<IFilter>>> getCrafters(IResource iRequestType, List<ExitRoute> validDestinations) {
    List<Pair<ICraftingTemplate, List<IFilter>>> crafters = new ArrayList<>(validDestinations.size());
    for (ExitRoute r : validDestinations) {
        CoreRoutedPipe pipe = r.destination.getPipe();
        if (r.containsFlag(PipeRoutingConnectionType.canRequestFrom)) {
            if (pipe instanceof ICraft) {
                ICraftingTemplate craftable = ((ICraft) pipe).addCrafting(iRequestType);
                if (craftable != null) {
                    for (IFilter filter : r.filters) {
                        if (filter.isBlocked() == filter.isFilteredItem(craftable.getResultItem()) || filter.blockCrafting()) {
                            continue;
                        }
                    }
                    List<IFilter> list = new LinkedList<>();
                    list.addAll(r.filters);
                    crafters.add(new Pair<>(craftable, list));
                }
            }
        }
    }
    //		Collections.sort(crafters,new CraftingTemplate.PairPrioritizer());
    return crafters;
}
Also used : ICraft(logisticspipes.interfaces.routing.ICraft) IFilter(logisticspipes.interfaces.routing.IFilter) ArrayList(java.util.ArrayList) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) ExitRoute(logisticspipes.routing.ExitRoute) LinkedList(java.util.LinkedList) Pair(logisticspipes.utils.tuples.Pair)

Example 33 with CoreRoutedPipe

use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.

the class ClientRouter method getPipe.

@Override
public CoreRoutedPipe getPipe() {
    World worldObj = MainProxy.proxy.getWorld();
    if (worldObj == null) {
        return null;
    }
    TileEntity tile = worldObj.getTileEntity(_xCoord, _yCoord, _zCoord);
    if (!(tile instanceof LogisticsTileGenericPipe)) {
        return null;
    }
    LogisticsTileGenericPipe pipe = (LogisticsTileGenericPipe) tile;
    if (!(pipe.pipe instanceof CoreRoutedPipe)) {
        return null;
    }
    return (CoreRoutedPipe) pipe.pipe;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) World(net.minecraft.world.World)

Example 34 with CoreRoutedPipe

use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.

the class LogisticsSolderingTileEntity method updateEntity.

@Override
public void updateEntity() {
    super.updateEntity();
    if (MainProxy.isClient(getWorldObj())) {
        return;
    }
    hasWork = hasWork();
    if (hasWork && heat < 100) {
        boolean usedEnergy = false;
        if (Configs.LOGISTICS_POWER_USAGE_DISABLED) {
            if (heat < 100) {
                heat += 5;
            }
            if (heat > 100) {
                heat = 100;
            }
            usedEnergy = true;
        } else {
            for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
                DoubleCoordinates pos = CoordinateUtils.add(new DoubleCoordinates(this), dir);
                TileEntity tile = pos.getTileEntity(getWorldObj());
                if (!(tile instanceof LogisticsTileGenericPipe)) {
                    continue;
                }
                LogisticsTileGenericPipe tPipe = (LogisticsTileGenericPipe) tile;
                if (!(tPipe.pipe instanceof CoreRoutedPipe)) {
                    continue;
                }
                CoreRoutedPipe pipe = (CoreRoutedPipe) tPipe.pipe;
                if (pipe.useEnergy(50)) {
                    heat += 5;
                    if (heat > 100) {
                        heat = 100;
                    }
                    updateHeat();
                    usedEnergy = true;
                    break;
                }
            }
        }
        if (!usedEnergy && getWorldObj().getTotalWorldTime() % 5 == 0) {
            heat--;
            if (heat < 0) {
                heat = 0;
            }
            updateHeat();
        }
    } else if (!hasWork && heat > 0) {
        heat--;
        updateHeat();
    }
    if (hasWork && heat >= 100) {
        for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
            DoubleCoordinates pos = CoordinateUtils.add(new DoubleCoordinates(this), dir);
            TileEntity tile = pos.getTileEntity(getWorldObj());
            if (!(tile instanceof LogisticsTileGenericPipe)) {
                continue;
            }
            LogisticsTileGenericPipe tPipe = (LogisticsTileGenericPipe) tile;
            if (!(tPipe.pipe instanceof CoreRoutedPipe)) {
                continue;
            }
            CoreRoutedPipe pipe = (CoreRoutedPipe) tPipe.pipe;
            if (pipe.useEnergy(30)) {
                progress += 3;
            } else if (pipe.useEnergy(20)) {
                progress += 2;
            } else if (pipe.useEnergy(10)) {
                progress += 1;
            }
            if (progress >= 100) {
                if (tryCraft()) {
                    progress = 0;
                } else {
                    progress -= 50;
                }
            }
            updateProgress();
        }
    } else if (!hasWork && progress != 0) {
        progress = 0;
        updateProgress();
    }
}
Also used : IGuiTileEntity(logisticspipes.interfaces.IGuiTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 35 with CoreRoutedPipe

use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.

the class LogisticsEventListener method onPlayerInteract.

@SubscribeEvent
public void onPlayerInteract(final PlayerInteractEvent event) {
    if (MainProxy.isServer(event.entityPlayer.worldObj)) {
        if (event.action == Action.LEFT_CLICK_BLOCK) {
            final TileEntity tile = event.entityPlayer.worldObj.getTileEntity(event.x, event.y, event.z);
            if (tile instanceof LogisticsTileGenericPipe) {
                if (((LogisticsTileGenericPipe) tile).pipe instanceof CoreRoutedPipe) {
                    if (!((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).canBeDestroyedByPlayer(event.entityPlayer)) {
                        event.setCanceled(true);
                        event.entityPlayer.addChatComponentMessage(new ChatComponentTranslation("lp.chat.permissiondenied"));
                        ((LogisticsTileGenericPipe) tile).scheduleNeighborChange();
                        event.entityPlayer.worldObj.markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord);
                        ((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).delayTo = System.currentTimeMillis() + 200;
                        ((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).repeatFor = 10;
                    } else {
                        ((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).setDestroyByPlayer();
                    }
                }
            }
        }
        if (event.action == Action.RIGHT_CLICK_BLOCK) {
            WorldCoordinatesWrapper worldCoordinates = new WorldCoordinatesWrapper(event.entityPlayer.worldObj, event.x, event.y, event.z);
            TileEntity tileEntity = worldCoordinates.getTileEntity();
            if (tileEntity instanceof TileEntityChest || SimpleServiceLocator.ironChestProxy.isIronChest(tileEntity)) {
                //@formatter:off
                List<WeakReference<ModuleQuickSort>> list = worldCoordinates.getAdjacentTileEntities().filter(adjacent -> adjacent.tileEntity instanceof LogisticsTileGenericPipe).filter(adjacent -> ((LogisticsTileGenericPipe) adjacent.tileEntity).pipe instanceof PipeLogisticsChassi).filter(adjacent -> ((PipeLogisticsChassi) ((LogisticsTileGenericPipe) adjacent.tileEntity).pipe).getPointedOrientation() == adjacent.direction.getOpposite()).map(adjacent -> (PipeLogisticsChassi) ((LogisticsTileGenericPipe) adjacent.tileEntity).pipe).flatMap(pipeLogisticsChassi -> Arrays.stream(pipeLogisticsChassi.getModules().getModules())).filter(logisticsModule -> logisticsModule instanceof ModuleQuickSort).map(logisticsModule -> new WeakReference<>((ModuleQuickSort) logisticsModule)).collect(Collectors.toList());
                if (!list.isEmpty()) {
                    LogisticsEventListener.chestQuickSortConnection.put(event.entityPlayer, list);
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Action(net.minecraftforge.event.entity.player.PlayerInteractEvent.Action) Arrays(java.util.Arrays) ModuleQuickSort(logisticspipes.modules.ModuleQuickSort) MainProxy(logisticspipes.proxy.MainProxy) VersionChecker(logisticspipes.ticks.VersionChecker) PlayerCollectionList(logisticspipes.utils.PlayerCollectionList) Configs(logisticspipes.config.Configs) ChestGuiOpened(logisticspipes.network.packets.chassis.ChestGuiOpened) ChatComponentText(net.minecraft.util.ChatComponentText) LogisticsHUDRenderer(logisticspipes.renderer.LogisticsHUDRenderer) LogisticsGuiOverrenderer(logisticspipes.renderer.LogisticsGuiOverrenderer) Map(java.util.Map) FMLClientHandler(cpw.mods.fml.client.FMLClientHandler) PlayerLoggedInEvent(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent) PlayerLoggedOutEvent(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent) ClientConnectedToServerEvent(cpw.mods.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent) EntityItem(net.minecraft.entity.item.EntityItem) ChestGuiClosed(logisticspipes.network.packets.chassis.ChestGuiClosed) Side(cpw.mods.fml.relauncher.Side) SideOnly(cpw.mods.fml.relauncher.SideOnly) UnWatch(net.minecraftforge.event.world.ChunkWatchEvent.UnWatch) WorldEvent(net.minecraftforge.event.world.WorldEvent) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) PacketHandler(logisticspipes.network.PacketHandler) Collectors(java.util.stream.Collectors) List(java.util.List) EntityJoinWorldEvent(net.minecraftforge.event.entity.EntityJoinWorldEvent) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) PipeLogisticsChassi(logisticspipes.pipes.PipeLogisticsChassi) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent) PlayerIdentifier(logisticspipes.utils.PlayerIdentifier) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) Queue(java.util.Queue) PlayerConfig(logisticspipes.config.PlayerConfig) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) ChunkCoordIntPair(net.minecraft.world.ChunkCoordIntPair) Setter(lombok.Setter) Getter(lombok.Getter) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) GuiReopenPacket(logisticspipes.network.packets.gui.GuiReopenPacket) HashMap(java.util.HashMap) PlayerConfigToClientPacket(logisticspipes.network.packets.PlayerConfigToClientPacket) Watch(net.minecraftforge.event.world.ChunkWatchEvent.Watch) TileEntityChest(net.minecraft.tileentity.TileEntityChest) ItemStack(net.minecraft.item.ItemStack) IItemAdvancedExistance(logisticspipes.interfaces.IItemAdvancedExistance) TextureStitchEvent(net.minecraftforge.client.event.TextureStitchEvent) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) WeakReference(java.lang.ref.WeakReference) LinkedList(java.util.LinkedList) PlayerInteractEvent(net.minecraftforge.event.entity.player.PlayerInteractEvent) WeakHashMap(java.util.WeakHashMap) IOException(java.io.IOException) GuiChest(net.minecraft.client.gui.inventory.GuiChest) GuiOpenEvent(net.minecraftforge.client.event.GuiOpenEvent) QuickSortChestMarkerStorage(logisticspipes.utils.QuickSortChestMarkerStorage) TileEntity(net.minecraft.tileentity.TileEntity) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) AllArgsConstructor(lombok.AllArgsConstructor) TileEntityChest(net.minecraft.tileentity.TileEntityChest) PipeLogisticsChassi(logisticspipes.pipes.PipeLogisticsChassi) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) WeakReference(java.lang.ref.WeakReference) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) ModuleQuickSort(logisticspipes.modules.ModuleQuickSort) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)68 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)43 TileEntity (net.minecraft.tileentity.TileEntity)22 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)16 ExitRoute (logisticspipes.routing.ExitRoute)15 ArrayList (java.util.ArrayList)14 LinkedList (java.util.LinkedList)13 IRouter (logisticspipes.routing.IRouter)11 Pair (logisticspipes.utils.tuples.Pair)10 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)10 List (java.util.List)9 HashMap (java.util.HashMap)8 IFilter (logisticspipes.interfaces.routing.IFilter)8 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)7 Map (java.util.Map)6 PipeRoutingConnectionType (logisticspipes.routing.PipeRoutingConnectionType)6 World (net.minecraft.world.World)6 BitSet (java.util.BitSet)5 Collections (java.util.Collections)5 EnumSet (java.util.EnumSet)5