Search in sources :

Example 1 with SneakyUpgradeConfig

use of logisticspipes.pipes.upgrades.SneakyUpgradeConfig in project LogisticsPipes by RS485.

the class PipeController method getContainer.

@Override
public DummyContainer getContainer(EntityPlayer player) {
    LogisticsTileGenericPipe tile = getPipe(player.getEntityWorld());
    if (tile == null || !(tile.pipe instanceof CoreRoutedPipe)) {
        return null;
    }
    final CoreRoutedPipe pipe = (CoreRoutedPipe) tile.pipe;
    DummyContainer dummy = new DummyContainer(player, null, pipe.getOriginalUpgradeManager().getGuiController(), new IGuiOpenControler() {

        //Network Statistics
        @Override
        public void guiOpenedByPlayer(EntityPlayer player) {
            pipe.playerStartWatching(player, 0);
        }

        @Override
        public void guiClosedByPlayer(EntityPlayer player) {
            pipe.playerStopWatching(player, 0);
        }
    });
    dummy.addNormalSlotsForPlayerInventory(0, 0);
    // TAB_1 SLOTS
    for (int pipeSlot = 0; pipeSlot < 9; pipeSlot++) {
        dummy.addUpgradeSlot(pipeSlot, pipe.getOriginalUpgradeManager(), pipeSlot, 8 + pipeSlot * 18, 18, itemStack -> {
            if (itemStack == null) {
                return false;
            }
            if (itemStack.getItem() == LogisticsPipes.UpgradeItem) {
                if (!LogisticsPipes.UpgradeItem.getUpgradeForItem(itemStack, null).isAllowedForPipe(pipe)) {
                    return false;
                }
            } else {
                return false;
            }
            return true;
        });
    }
    for (int pipeSlot = 0; pipeSlot < 9; pipeSlot++) {
        dummy.addSneakyUpgradeSlot(pipeSlot, pipe.getOriginalUpgradeManager(), pipeSlot + 9, 8 + pipeSlot * 18, 48, itemStack -> {
            if (itemStack == null) {
                return false;
            }
            if (itemStack.getItem() == LogisticsPipes.UpgradeItem) {
                IPipeUpgrade upgrade = LogisticsPipes.UpgradeItem.getUpgradeForItem(itemStack, null);
                if (!(upgrade instanceof SneakyUpgrade) && !(upgrade instanceof SneakyUpgradeConfig)) {
                    return false;
                }
                if (!upgrade.isAllowedForPipe(pipe)) {
                    return false;
                }
            } else {
                return false;
            }
            return true;
        });
    }
    // TAB_2 SLOTS
    dummy.addStaticRestrictedSlot(0, pipe.getOriginalUpgradeManager().getSecInv(), 8 + 8 * 18, 18, itemStack -> {
        if (itemStack == null) {
            return false;
        }
        if (itemStack.getItem() != LogisticsPipes.LogisticsItemCard) {
            return false;
        }
        if (itemStack.getItemDamage() != LogisticsItemCard.SEC_CARD) {
            return false;
        }
        return SimpleServiceLocator.securityStationManager.isAuthorized(UUID.fromString(itemStack.getTagCompound().getString("UUID")));
    }, 1);
    dummy.addRestrictedSlot(0, tile.logicController.diskInv, 14, 36, LogisticsPipes.LogisticsItemDisk);
    return dummy;
}
Also used : DummyContainer(logisticspipes.utils.gui.DummyContainer) IPipeUpgrade(logisticspipes.pipes.upgrades.IPipeUpgrade) IGuiOpenControler(logisticspipes.interfaces.IGuiOpenControler) SneakyUpgradeConfig(logisticspipes.pipes.upgrades.SneakyUpgradeConfig) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SneakyUpgrade(logisticspipes.pipes.upgrades.SneakyUpgrade)

Aggregations

IGuiOpenControler (logisticspipes.interfaces.IGuiOpenControler)1 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)1 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)1 IPipeUpgrade (logisticspipes.pipes.upgrades.IPipeUpgrade)1 SneakyUpgrade (logisticspipes.pipes.upgrades.SneakyUpgrade)1 SneakyUpgradeConfig (logisticspipes.pipes.upgrades.SneakyUpgradeConfig)1 DummyContainer (logisticspipes.utils.gui.DummyContainer)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1