Search in sources :

Example 1 with PipeLogisticsChassis

use of logisticspipes.pipes.PipeLogisticsChassis in project LogisticsPipes by RS485.

the class ChassisGuiProvider method getContainer.

@Override
public DummyContainer getContainer(EntityPlayer player) {
    LogisticsTileGenericPipe pipe = getTileAs(player.world, LogisticsTileGenericPipe.class);
    if (!(pipe.pipe instanceof PipeLogisticsChassis)) {
        return null;
    }
    final PipeLogisticsChassis _chassiPipe = (PipeLogisticsChassis) pipe.pipe;
    IInventory _moduleInventory = _chassiPipe.getModuleInventory();
    DummyContainer dummy = new DummyContainer(player.inventory, _moduleInventory);
    if (_chassiPipe.getChassisSize() < 5) {
        dummy.addNormalSlotsForPlayerInventory(18, 97);
    } else {
        dummy.addNormalSlotsForPlayerInventory(18, 174);
    }
    for (int i = 0; i < _chassiPipe.getChassisSize(); i++) {
        dummy.addModuleSlot(i, _moduleInventory, 19, 9 + 20 * i, _chassiPipe);
    }
    if (_chassiPipe.getUpgradeManager().hasUpgradeModuleUpgrade()) {
        for (int i = 0; i < _chassiPipe.getChassisSize(); i++) {
            final int fI = i;
            ModuleUpgradeManager upgradeManager = _chassiPipe.getModuleUpgradeManager(i);
            dummy.addUpgradeSlot(0, upgradeManager, 0, 145, 9 + i * 20, itemStack -> ChassisGuiProvider.checkStack(itemStack, _chassiPipe, fI));
            dummy.addUpgradeSlot(1, upgradeManager, 1, 165, 9 + i * 20, itemStack -> ChassisGuiProvider.checkStack(itemStack, _chassiPipe, fI));
        }
    }
    return dummy;
}
Also used : IInventory(net.minecraft.inventory.IInventory) DummyContainer(logisticspipes.utils.gui.DummyContainer) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) PipeLogisticsChassis(logisticspipes.pipes.PipeLogisticsChassis) ModuleUpgradeManager(logisticspipes.pipes.upgrades.ModuleUpgradeManager)

Example 2 with PipeLogisticsChassis

use of logisticspipes.pipes.PipeLogisticsChassis in project LogisticsPipes by RS485.

the class LogisticsEventListener method onPlayerLeftClickBlock.

@SubscribeEvent
public void onPlayerLeftClickBlock(final PlayerInteractEvent.RightClickBlock event) {
    if (MainProxy.isServer(event.getEntityPlayer().world)) {
        WorldCoordinatesWrapper worldCoordinates = new WorldCoordinatesWrapper(event.getEntityPlayer().world, event.getPos());
        TileEntity tileEntity = worldCoordinates.getTileEntity();
        if (tileEntity instanceof TileEntityChest || SimpleServiceLocator.ironChestProxy.isIronChest(tileEntity)) {
            List<WeakReference<AsyncQuicksortModule>> list = worldCoordinates.allNeighborTileEntities().stream().filter(NeighborTileEntity::isLogisticsPipe).filter(adjacent -> ((LogisticsTileGenericPipe) adjacent.getTileEntity()).pipe instanceof PipeLogisticsChassis).filter(adjacent -> ((PipeLogisticsChassis) ((LogisticsTileGenericPipe) adjacent.getTileEntity()).pipe).getPointedOrientation() == adjacent.getOurDirection()).map(adjacent -> (PipeLogisticsChassis) ((LogisticsTileGenericPipe) adjacent.getTileEntity()).pipe).flatMap(chassis -> chassis.getModules().getModules()).filter(logisticsModule -> logisticsModule instanceof AsyncQuicksortModule).map(logisticsModule -> new WeakReference<>((AsyncQuicksortModule) logisticsModule)).collect(Collectors.toList());
            if (!list.isEmpty()) {
                LogisticsEventListener.chestQuickSortConnection.put(event.getEntityPlayer(), list);
            }
        }
    }
}
Also used : NeighborTileEntity(network.rs485.logisticspipes.connection.NeighborTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) NeighborTileEntity(network.rs485.logisticspipes.connection.NeighborTileEntity) PipeLogisticsChassis(logisticspipes.pipes.PipeLogisticsChassis) PlayerEvent(net.minecraftforge.fml.common.gameevent.PlayerEvent) MainProxy(logisticspipes.proxy.MainProxy) VersionChecker(logisticspipes.ticks.VersionChecker) PlayerCollectionList(logisticspipes.utils.PlayerCollectionList) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) Configs(logisticspipes.config.Configs) TEControl(logisticspipes.routing.pathfinder.changedetection.TEControl) ChestGuiOpened(logisticspipes.network.packets.chassis.ChestGuiOpened) PlayerConfiguration(network.rs485.logisticspipes.config.PlayerConfiguration) Side(net.minecraftforge.fml.relauncher.Side) LogisticsHUDRenderer(logisticspipes.renderer.LogisticsHUDRenderer) ClientConfiguration(network.rs485.logisticspipes.config.ClientConfiguration) LogisticsGuiOverrenderer(logisticspipes.renderer.LogisticsGuiOverrenderer) Map(java.util.Map) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) EntityItem(net.minecraft.entity.item.EntityItem) ChestGuiClosed(logisticspipes.network.packets.chassis.ChestGuiClosed) BlockEvent(net.minecraftforge.event.world.BlockEvent) UnWatch(net.minecraftforge.event.world.ChunkWatchEvent.UnWatch) WorldEvent(net.minecraftforge.event.world.WorldEvent) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) AsyncQuicksortModule(network.rs485.logisticspipes.module.AsyncQuicksortModule) ChunkPos(net.minecraft.util.math.ChunkPos) LPTickHandler(logisticspipes.ticks.LPTickHandler) PacketHandler(logisticspipes.network.PacketHandler) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) PlayerLoggedOutEvent(net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent) List(java.util.List) EntityJoinWorldEvent(net.minecraftforge.event.entity.EntityJoinWorldEvent) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) FMLClientHandler(net.minecraftforge.fml.client.FMLClientHandler) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemTooltipEvent(net.minecraftforge.event.entity.player.ItemTooltipEvent) PlayerIdentifier(logisticspipes.utils.PlayerIdentifier) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) Queue(java.util.Queue) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) ClientConnectedToServerEvent(net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent) PlayerLoggedInEvent(net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent) Setter(lombok.Setter) TextUtil(network.rs485.logisticspipes.util.TextUtil) 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) ItemRoutingInformation(logisticspipes.routing.ItemRoutingInformation) WeakReference(java.lang.ref.WeakReference) LinkedList(java.util.LinkedList) PlayerInteractEvent(net.minecraftforge.event.entity.player.PlayerInteractEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) WeakHashMap(java.util.WeakHashMap) ChatColor(logisticspipes.utils.string.ChatColor) World(net.minecraft.world.World) BlockPos(net.minecraft.util.math.BlockPos) GuiChest(net.minecraft.client.gui.inventory.GuiChest) TextComponentString(net.minecraft.util.text.TextComponentString) IBlockState(net.minecraft.block.state.IBlockState) GuiOpenEvent(net.minecraftforge.client.event.GuiOpenEvent) QuickSortChestMarkerStorage(logisticspipes.utils.QuickSortChestMarkerStorage) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) TileEntity(net.minecraft.tileentity.TileEntity) AllArgsConstructor(lombok.AllArgsConstructor) TileEntityChest(net.minecraft.tileentity.TileEntityChest) AsyncQuicksortModule(network.rs485.logisticspipes.module.AsyncQuicksortModule) WeakReference(java.lang.ref.WeakReference) PipeLogisticsChassis(logisticspipes.pipes.PipeLogisticsChassis) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with PipeLogisticsChassis

use of logisticspipes.pipes.PipeLogisticsChassis in project LogisticsPipes by RS485.

the class AdvancedExtractorSneakyGuiPacket method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    if (getType() == ModulePositionType.IN_HAND) {
        if (player.openContainer instanceof DummyModuleContainer) {
            DummyModuleContainer dummy = (DummyModuleContainer) player.openContainer;
            if (dummy.getModule() instanceof AsyncAdvancedExtractor) {
                player.closeScreen();
                NewGuiHandler.getGui(SneakyModuleInHandGuiProvider.class).setInvSlot(getPositionInt()).open(player);
            }
        }
        return;
    }
    PipeLogisticsChassis pipe = getTileOrPipe(player.world, PipeLogisticsChassis.class);
    LogisticsModule subModule = pipe.getSubModule(getPositionInt());
    if (subModule instanceof AsyncAdvancedExtractor) {
        NewGuiHandler.getGui(SneakyModuleInSlotGuiProvider.class).setSneakyOrientation(((AsyncAdvancedExtractor) subModule).getSneakyDirection()).setSlot(getType()).setPositionInt(getPositionInt()).setPosX(getPosX()).setPosY(getPosY()).setPosZ(getPosZ()).open(player);
    }
}
Also used : DummyModuleContainer(logisticspipes.utils.gui.DummyModuleContainer) LogisticsModule(logisticspipes.modules.LogisticsModule) PipeLogisticsChassis(logisticspipes.pipes.PipeLogisticsChassis) AsyncAdvancedExtractor(network.rs485.logisticspipes.module.AsyncAdvancedExtractor) SneakyModuleInSlotGuiProvider(logisticspipes.network.guis.module.inpipe.SneakyModuleInSlotGuiProvider)

Example 4 with PipeLogisticsChassis

use of logisticspipes.pipes.PipeLogisticsChassis in project LogisticsPipes by RS485.

the class PipeTransportLogistics method handleTileReachedServer_internal.

protected final void handleTileReachedServer_internal(LPTravelingItemServer arrivingItem, TileEntity tile, EnumFacing dir) {
    if (getPipe() instanceof PipeItemsFluidSupplier) {
        ((PipeItemsFluidSupplier) getPipe()).endReached(arrivingItem, tile);
        if (arrivingItem.getItemIdentifierStack().getStackSize() <= 0) {
            return;
        }
    }
    markChunkModified(tile);
    if (arrivingItem.getInfo() != null && arrivingItem.getArrived() && isRouted) {
        getRoutedPipe().notifyOfItemArival(arrivingItem.getInfo());
    }
    if (getPipe() instanceof FluidRoutedPipe) {
        if (((FluidRoutedPipe) getPipe()).endReached(arrivingItem, tile)) {
            return;
        }
    }
    boolean isSpecialConnectionInformationTransition = false;
    if (SimpleServiceLocator.specialtileconnection.needsInformationTransition(tile)) {
        isSpecialConnectionInformationTransition = true;
        SimpleServiceLocator.specialtileconnection.transmit(tile, arrivingItem);
    }
    if (SimpleServiceLocator.pipeInformationManager.isItemPipe(tile)) {
        if (passToNextPipe(arrivingItem, tile)) {
            return;
        }
    } else {
        IInventoryUtil util = SimpleServiceLocator.inventoryUtilFactory.getInventoryUtil(tile, dir.getOpposite());
        if (util != null && isRouted) {
            getRoutedPipe().getCacheHolder().trigger(CacheTypes.Inventory);
            // destroy the item on exit if it isn't exitable
            if (!isSpecialConnectionInformationTransition && isItemUnwanted(arrivingItem.getItemIdentifierStack())) {
                return;
            }
            // last chance for chassi to back out
            if (arrivingItem.getTransportMode() != TransportMode.Active && !getRoutedPipe().getTransportLayer().stillWantItem(arrivingItem)) {
                reverseItem(arrivingItem);
                return;
            }
            final ISlotUpgradeManager slotManager;
            {
                ModulePositionType slot = null;
                int positionInt = -1;
                if (arrivingItem.getInfo().targetInfo instanceof ChassiTargetInformation) {
                    positionInt = ((ChassiTargetInformation) arrivingItem.getInfo().targetInfo).getModuleSlot();
                    slot = ModulePositionType.SLOT;
                } else if (LogisticsPipes.isDEBUG() && container.pipe instanceof PipeLogisticsChassis) {
                    System.out.println(arrivingItem);
                    new RuntimeException("[ItemInsertion] Information weren't ment for a chassi pipe").printStackTrace();
                }
                slotManager = getRoutedPipe().getUpgradeManager(slot, positionInt);
            }
            if (arrivingItem.getAdditionalTargetInformation() instanceof ITargetSlotInformation) {
                ITargetSlotInformation information = (ITargetSlotInformation) arrivingItem.getAdditionalTargetInformation();
                if (util instanceof ISpecialInsertion) {
                    int slot = information.getTargetSlot();
                    int amount = information.getAmount();
                    if (util.getSizeInventory() > slot) {
                        ItemStack content = util.getStackInSlot(slot);
                        ItemStack toAdd = arrivingItem.getItemIdentifierStack().makeNormalStack();
                        final int amountLeft = Math.max(0, amount - content.getCount());
                        toAdd.setCount(Math.min(toAdd.getCount(), amountLeft));
                        if (toAdd.getCount() > 0) {
                            if (util.getSizeInventory() > slot) {
                                int added = ((ISpecialInsertion) util).addToSlot(toAdd, slot);
                                arrivingItem.getItemIdentifierStack().lowerStackSize(added);
                            }
                        }
                    }
                    if (information.isLimited()) {
                        if (arrivingItem.getItemIdentifierStack().getStackSize() > 0) {
                            reverseItem(arrivingItem);
                        }
                        return;
                    }
                }
            }
            // sneaky insertion
            if (!getRoutedPipe().getUpgradeManager().hasCombinedSneakyUpgrade() || slotManager.hasOwnSneakyUpgrade()) {
                EnumFacing insertion = arrivingItem.output.getOpposite();
                if (slotManager.hasSneakyUpgrade()) {
                    insertion = slotManager.getSneakyOrientation();
                }
                if (insertArrivingItem(arrivingItem, tile, insertion))
                    return;
            } else {
                EnumFacing[] dirs = getRoutedPipe().getUpgradeManager().getCombinedSneakyOrientation();
                for (EnumFacing insertion : dirs) {
                    if (insertion == null) {
                        continue;
                    }
                    if (insertArrivingItem(arrivingItem, tile, insertion))
                        return;
                }
            }
            if (arrivingItem.getItemIdentifierStack().getStackSize() > 0) {
                reverseItem(arrivingItem);
            }
            // the item is handled
            return;
        }
    // end of insert into IInventory
    }
    dropItem(arrivingItem);
}
Also used : ITargetSlotInformation(logisticspipes.interfaces.routing.ITargetSlotInformation) FluidRoutedPipe(logisticspipes.pipes.basic.fluid.FluidRoutedPipe) IInventoryUtil(logisticspipes.interfaces.IInventoryUtil) EnumFacing(net.minecraft.util.EnumFacing) PipeLogisticsChassis(logisticspipes.pipes.PipeLogisticsChassis) ModulePositionType(logisticspipes.modules.LogisticsModule.ModulePositionType) PipeItemsFluidSupplier(logisticspipes.pipes.PipeItemsFluidSupplier) ISpecialInsertion(logisticspipes.interfaces.ISpecialInsertion) ChassiTargetInformation(logisticspipes.pipes.PipeLogisticsChassis.ChassiTargetInformation) ItemStack(net.minecraft.item.ItemStack) ISlotUpgradeManager(logisticspipes.interfaces.ISlotUpgradeManager)

Example 5 with PipeLogisticsChassis

use of logisticspipes.pipes.PipeLogisticsChassis in project LogisticsPipes by RS485.

the class ModuleCoordinatesGuiProvider method getLogisticsModule.

@SuppressWarnings("unchecked")
public <T> T getLogisticsModule(World world, Class<T> clazz) {
    LogisticsTileGenericPipe pipe = getTileAs(world, LogisticsTileGenericPipe.class);
    if (!(pipe.pipe instanceof CoreRoutedPipe)) {
        if (LogisticsPipes.isDEBUG() && pipe.isInitialized()) {
            LogisticsPipes.log.fatal(toString());
            new RuntimeException("Couldn't find " + clazz.getName() + ", pipe didn't exsist").printStackTrace();
        }
        return null;
    }
    LogisticsModule module;
    if (slot == ModulePositionType.IN_PIPE) {
        module = ((CoreRoutedPipe) pipe.pipe).getLogisticsModule();
    } else if (slot == ModulePositionType.IN_HAND) {
        throw new UnsupportedOperationException("NO IN_HAND FOR THIS PACKET TYPE");
    } else {
        if (!(pipe.pipe instanceof PipeLogisticsChassis)) {
            if (LogisticsPipes.isDEBUG()) {
                LogisticsPipes.log.fatal(toString());
                new RuntimeException("Couldn't find " + clazz.getName() + ", pipe wasn't a chassi pipe").printStackTrace();
            }
            return null;
        }
        module = ((PipeLogisticsChassis) pipe.pipe).getSubModule(positionInt);
    }
    if (module != null) {
        if (!(clazz.isAssignableFrom(module.getClass()))) {
            if (LogisticsPipes.isDEBUG()) {
                LogisticsPipes.log.fatal(toString());
                new RuntimeException("Couldn't find " + clazz.getName() + ", found " + module.getClass()).printStackTrace();
            }
            return null;
        }
    } else {
        if (LogisticsPipes.isDEBUG()) {
            LogisticsPipes.log.fatal(toString());
            new RuntimeException("Couldn't find " + clazz.getName()).printStackTrace();
        }
    }
    return (T) module;
}
Also used : LogisticsModule(logisticspipes.modules.LogisticsModule) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) PipeLogisticsChassis(logisticspipes.pipes.PipeLogisticsChassis) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Aggregations

PipeLogisticsChassis (logisticspipes.pipes.PipeLogisticsChassis)7 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)5 LogisticsModule (logisticspipes.modules.LogisticsModule)3 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)3 DummyModuleContainer (logisticspipes.utils.gui.DummyModuleContainer)2 WeakReference (java.lang.ref.WeakReference)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Queue (java.util.Queue)1 WeakHashMap (java.util.WeakHashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Collectors (java.util.stream.Collectors)1 Configs (logisticspipes.config.Configs)1 IInventoryUtil (logisticspipes.interfaces.IInventoryUtil)1 IItemAdvancedExistance (logisticspipes.interfaces.IItemAdvancedExistance)1 ISlotUpgradeManager (logisticspipes.interfaces.ISlotUpgradeManager)1 ISpecialInsertion (logisticspipes.interfaces.ISpecialInsertion)1