Search in sources :

Example 6 with PipeLogisticsChassis

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

the class ModuleCoordinatesPacket method getLogisticsModule.

@SuppressWarnings("unchecked")
public <T> T getLogisticsModule(EntityPlayer player, Class<T> clazz) {
    LogisticsModule module;
    if (type == ModulePositionType.IN_PIPE) {
        moduleBased = true;
        LogisticsTileGenericPipe pipe = this.getPipe(player.getEntityWorld(), LTGPCompletionCheck.NONE);
        moduleBased = false;
        if (!(pipe.pipe instanceof CoreRoutedPipe)) {
            throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", pipe didn't exsist", this);
        }
        module = ((CoreRoutedPipe) pipe.pipe).getLogisticsModule();
    } else if (type == ModulePositionType.IN_HAND) {
        if (MainProxy.isServer(player.getEntityWorld())) {
            if (player.openContainer instanceof DummyModuleContainer) {
                DummyModuleContainer dummy = (DummyModuleContainer) player.openContainer;
                module = dummy.getModule();
            } else if (player.openContainer instanceof ContainerPlayer) {
                module = ItemModule.getLogisticsModule(player, getPositionInt());
                if (module == null) {
                    throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", module not found at slot " + getPositionInt(), this);
                }
            } else {
                throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", no DummyModuleContainer open and the player is in another GUI", this);
            }
        } else {
            module = MainProxy.proxy.getModuleFromGui();
            if (module == null) {
                module = ItemModule.getLogisticsModule(player, getPositionInt());
            }
            if (module == null) {
                throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", GUI didn't provide the module and module not found at slot " + getPositionInt(), this);
            }
        }
    } else {
        moduleBased = true;
        LogisticsTileGenericPipe pipe = this.getPipe(player.getEntityWorld(), LTGPCompletionCheck.NONE);
        moduleBased = false;
        if (!(pipe.pipe instanceof CoreRoutedPipe)) {
            throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", pipe didn't exsist", this);
        } else if (!pipe.isInitialized()) {
            return null;
        }
        if (!(pipe.pipe instanceof PipeLogisticsChassis)) {
            throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", pipe wasn't a chassi pipe", this);
        }
        module = ((PipeLogisticsChassis) pipe.pipe).getSubModule(positionInt);
    }
    if (module != null) {
        if (!(clazz.isAssignableFrom(module.getClass()))) {
            throw new TargetNotFoundException("Couldn't find " + clazz.getName() + ", found " + module.getClass(), this);
        }
    } else {
        throw new TargetNotFoundException("Couldn't find " + clazz.getName(), this);
    }
    return (T) module;
}
Also used : ContainerPlayer(net.minecraft.inventory.ContainerPlayer) DummyModuleContainer(logisticspipes.utils.gui.DummyModuleContainer) LogisticsModule(logisticspipes.modules.LogisticsModule) TargetNotFoundException(logisticspipes.network.exception.TargetNotFoundException) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) PipeLogisticsChassis(logisticspipes.pipes.PipeLogisticsChassis) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Example 7 with PipeLogisticsChassis

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

the class ChassisPipeModuleContent method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    final LogisticsTileGenericPipe pipe = this.getPipe(player.world, LTGPCompletionCheck.PIPE);
    if (pipe.pipe instanceof PipeLogisticsChassis) {
        PipeLogisticsChassis chassis = (PipeLogisticsChassis) pipe.pipe;
        chassis.handleModuleItemIdentifierList(getIdentList());
    }
}
Also used : LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) PipeLogisticsChassis(logisticspipes.pipes.PipeLogisticsChassis)

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