Search in sources :

Example 91 with LogisticsTileGenericPipe

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

the class InvSysConGuiProvider method getContainer.

@Override
public DummyContainer getContainer(EntityPlayer player) {
    LogisticsTileGenericPipe pipe = getTileAs(player.world, LogisticsTileGenericPipe.class);
    if (!(pipe.pipe instanceof PipeItemsInvSysConnector)) {
        return null;
    }
    DummyContainer dummy = new DummyContainer(player, null, (PipeItemsInvSysConnector) pipe.pipe);
    dummy.addNormalSlotsForPlayerInventory(0, 50);
    return dummy;
}
Also used : PipeItemsInvSysConnector(logisticspipes.pipes.PipeItemsInvSysConnector) DummyContainer(logisticspipes.utils.gui.DummyContainer) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe)

Example 92 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe 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)

Example 93 with LogisticsTileGenericPipe

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

the class SneakyUpgradeConfigGuiProvider method getClientGui.

@Override
public Object getClientGui(EntityPlayer player) {
    LogisticsTileGenericPipe bPipe = getTileAs(player.world, LogisticsTileGenericPipe.class);
    if (!(bPipe.pipe instanceof CoreRoutedPipe)) {
        return null;
    }
    List<DoubleCoordinates> list = new WorldCoordinatesWrapper(bPipe).connectedTileEntities().stream().filter(in -> SimpleServiceLocator.pipeInformationManager.isNotAPipe(in.getTileEntity())).map(in -> new DoubleCoordinates(in.getTileEntity())).collect(Collectors.toList());
    if (list.isEmpty()) {
        list = new WorldCoordinatesWrapper(bPipe).connectedTileEntities().stream().map(in -> new DoubleCoordinates(in.getTileEntity())).collect(Collectors.toList());
    }
    return new SneakyConfigurationPopup(list, getSlot(player, UpgradeSlot.class));
}
Also used : UpgradeSlot(logisticspipes.utils.gui.UpgradeSlot) UpgradeCoordinatesGuiProvider(logisticspipes.network.abstractguis.UpgradeCoordinatesGuiProvider) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) Collectors(java.util.stream.Collectors) GuiProvider(logisticspipes.network.abstractguis.GuiProvider) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) List(java.util.List) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) EntityPlayer(net.minecraft.entity.player.EntityPlayer) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) StaticResolve(logisticspipes.utils.StaticResolve) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) SneakyConfigurationPopup(logisticspipes.gui.popup.SneakyConfigurationPopup) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) SneakyConfigurationPopup(logisticspipes.gui.popup.SneakyConfigurationPopup) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) UpgradeSlot(logisticspipes.utils.gui.UpgradeSlot)

Example 94 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe 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 95 with LogisticsTileGenericPipe

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

the class DiskMacroRequestPacket method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    final LogisticsTileGenericPipe pipe = this.getPipe(player.world);
    if (pipe == null) {
        return;
    }
    if (pipe.pipe instanceof PipeItemsRequestLogisticsMk2) {
        if (((PipeItemsRequestLogisticsMk2) pipe.pipe).getDisk() == null) {
            return;
        }
        if (!((PipeItemsRequestLogisticsMk2) pipe.pipe).getDisk().getItem().equals(LPItems.disk)) {
            return;
        }
        if (!((PipeItemsRequestLogisticsMk2) pipe.pipe).getDisk().hasTagCompound()) {
            return;
        }
        NBTTagCompound nbt = ((PipeItemsRequestLogisticsMk2) pipe.pipe).getDisk().getTagCompound();
        if (!nbt.hasKey("macroList")) {
            NBTTagList list = new NBTTagList();
            nbt.setTag("macroList", list);
        }
        NBTTagList list = nbt.getTagList("macroList", 10);
        for (int i = 0; i < list.tagCount(); i++) {
            if (i == getInteger()) {
                NBTTagCompound itemlist = list.getCompoundTagAt(i);
                RequestHandler.requestMacrolist(itemlist, (PipeItemsRequestLogisticsMk2) pipe.pipe, player);
                break;
            }
        }
    }
    if (pipe.pipe instanceof PipeBlockRequestTable) {
        if (((PipeBlockRequestTable) pipe.pipe).getDisk() == null) {
            return;
        }
        if (!((PipeBlockRequestTable) pipe.pipe).getDisk().getItem().equals(LPItems.disk)) {
            return;
        }
        if (!((PipeBlockRequestTable) pipe.pipe).getDisk().hasTagCompound()) {
            return;
        }
        NBTTagCompound nbt = ((PipeBlockRequestTable) pipe.pipe).getDisk().getTagCompound();
        if (!nbt.hasKey("macroList")) {
            NBTTagList list = new NBTTagList();
            nbt.setTag("macroList", list);
        }
        NBTTagList list = nbt.getTagList("macroList", 10);
        for (int i = 0; i < list.tagCount(); i++) {
            if (i == getInteger()) {
                NBTTagCompound itemlist = list.getCompoundTagAt(i);
                RequestHandler.requestMacrolist(itemlist, (PipeBlockRequestTable) pipe.pipe, player);
                break;
            }
        }
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) PipeItemsRequestLogisticsMk2(logisticspipes.pipes.PipeItemsRequestLogisticsMk2)

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