Search in sources :

Example 1 with IPipeUpgrade

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

the class PipeController method getContainer.

@Override
public DummyContainer getContainer(EntityPlayer player) {
    LogisticsTileGenericPipe tile = getTileAs(player.world, LogisticsTileGenericPipe.class);
    if (!(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 -> !itemStack.isEmpty() && itemStack.getItem() instanceof ItemUpgrade && ((ItemUpgrade) itemStack.getItem()).getUpgradeForItem(itemStack, null).isAllowedForPipe(pipe));
    }
    for (int pipeSlot = 0; pipeSlot < 9; pipeSlot++) {
        dummy.addSneakyUpgradeSlot(pipeSlot, pipe.getOriginalUpgradeManager(), pipeSlot + 9, 8 + pipeSlot * 18, 48, itemStack -> {
            if (itemStack.isEmpty()) {
                return false;
            }
            if (itemStack.getItem() instanceof ItemUpgrade) {
                IPipeUpgrade upgrade = ((ItemUpgrade) itemStack.getItem()).getUpgradeForItem(itemStack, null);
                return upgrade instanceof SneakyUpgradeConfig && upgrade.isAllowedForPipe(pipe);
            } else {
                return false;
            }
        });
    }
    // TAB_2 SLOTS
    dummy.addStaticRestrictedSlot(0, pipe.getOriginalUpgradeManager().secInv, 8 + 8 * 18, 18, itemStack -> {
        if (itemStack.isEmpty()) {
            return false;
        }
        if (itemStack.getItem() != LPItems.itemCard) {
            return false;
        }
        if (itemStack.getItemDamage() != LogisticsItemCard.SEC_CARD) {
            return false;
        }
        final NBTTagCompound tag = Objects.requireNonNull(itemStack.getTagCompound());
        return SimpleServiceLocator.securityStationManager.isAuthorized(UUID.fromString(tag.getString("UUID")));
    }, 1);
    dummy.addRestrictedSlot(0, tile.logicController.diskInv, 14, 36, LPItems.disk);
    return dummy;
}
Also used : DummyContainer(logisticspipes.utils.gui.DummyContainer) IPipeUpgrade(logisticspipes.pipes.upgrades.IPipeUpgrade) IGuiOpenControler(logisticspipes.interfaces.IGuiOpenControler) ItemUpgrade(logisticspipes.items.ItemUpgrade) SneakyUpgradeConfig(logisticspipes.pipes.upgrades.SneakyUpgradeConfig) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 2 with IPipeUpgrade

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

the class ItemUpgrade method addInformation.

@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "rawtypes", "unchecked" })
public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean flag) {
    super.addInformation(stack, par2EntityPlayer, list, flag);
    IPipeUpgrade upgrade = getUpgradeForItem(stack, null);
    if (upgrade == null) {
        return;
    }
    List<String> pipe = Arrays.asList(upgrade.getAllowedPipes());
    List<String> module = Arrays.asList(upgrade.getAllowedModules());
    if (pipe.isEmpty() && module.isEmpty()) {
        return;
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
        if (!pipe.isEmpty() && !module.isEmpty()) {
            //Can be applied to {0} pipes
            //and {0} modules
            String base1 = StringUtils.translate(ItemUpgrade.SHIFT_INFO_PREFIX + "both1");
            String base2 = StringUtils.translate(ItemUpgrade.SHIFT_INFO_PREFIX + "both2");
            list.add(MessageFormat.format(base1, join(pipe)));
            list.add(MessageFormat.format(base2, join(module)));
        } else if (!pipe.isEmpty()) {
            //Can be applied to {0} pipes
            String base = StringUtils.translate(ItemUpgrade.SHIFT_INFO_PREFIX + "pipe");
            list.add(MessageFormat.format(base, join(pipe)));
        } else if (!module.isEmpty()) {
            //Can be applied to {0} modules
            String base = StringUtils.translate(ItemUpgrade.SHIFT_INFO_PREFIX + "module");
            list.add(MessageFormat.format(base, join(module)));
        }
    } else {
        String baseKey = MessageFormat.format("{0}.tip", stack.getItem().getUnlocalizedName(stack));
        String key = baseKey + 1;
        String translation = StringUtils.translate(key);
        if (translation.equals(key)) {
            list.add(StringUtils.translate(StringUtils.KEY_HOLDSHIFT));
        }
    }
}
Also used : IPipeUpgrade(logisticspipes.pipes.upgrades.IPipeUpgrade) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 3 with IPipeUpgrade

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

the class OpenUpgradePacket method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    UpgradeSlot slot = getSlot(player, UpgradeSlot.class);
    IPipeUpgrade upgrade = slot.getUpgrade();
    if (upgrade instanceof IConfigPipeUpgrade) {
        UpgradeCoordinatesGuiProvider gui = ((IConfigPipeUpgrade) upgrade).getGUI();
        if (gui != null) {
            gui.setSlot(slot).setLPPos(slot.getManager().getPipePosition()).open(player);
        }
    }
}
Also used : UpgradeCoordinatesGuiProvider(logisticspipes.network.abstractguis.UpgradeCoordinatesGuiProvider) IPipeUpgrade(logisticspipes.pipes.upgrades.IPipeUpgrade) IConfigPipeUpgrade(logisticspipes.pipes.upgrades.IConfigPipeUpgrade) UpgradeSlot(logisticspipes.utils.gui.UpgradeSlot)

Example 4 with IPipeUpgrade

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

the class ItemUpgrade method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(@Nonnull ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
    super.addInformation(stack, worldIn, tooltip, flagIn);
    IPipeUpgrade upgrade = getUpgradeForItem(stack, null);
    if (upgrade == null) {
        return;
    }
    List<String> pipe = Arrays.asList(upgrade.getAllowedPipes());
    List<String> module = Arrays.asList(upgrade.getAllowedModules());
    if (pipe.isEmpty() && module.isEmpty()) {
        return;
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
        if (!pipe.isEmpty() && !module.isEmpty()) {
            // Can be applied to {0} pipes
            // and {0} modules
            String base1 = TextUtil.translate(ItemUpgrade.SHIFT_INFO_PREFIX + "both1");
            String base2 = TextUtil.translate(ItemUpgrade.SHIFT_INFO_PREFIX + "both2");
            tooltip.add(MessageFormat.format(base1, join(pipe)));
            tooltip.add(MessageFormat.format(base2, join(module)));
        } else if (!pipe.isEmpty()) {
            // Can be applied to {0} pipes
            String base = TextUtil.translate(ItemUpgrade.SHIFT_INFO_PREFIX + "pipe");
            tooltip.add(MessageFormat.format(base, join(pipe)));
        } else {
            // Can be applied to {0} modules
            String base = TextUtil.translate(ItemUpgrade.SHIFT_INFO_PREFIX + "module");
            tooltip.add(MessageFormat.format(base, join(module)));
        }
    } else {
        TextUtil.addTooltipInformation(stack, tooltip, false);
    }
}
Also used : IPipeUpgrade(logisticspipes.pipes.upgrades.IPipeUpgrade) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

IPipeUpgrade (logisticspipes.pipes.upgrades.IPipeUpgrade)4 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 IGuiOpenControler (logisticspipes.interfaces.IGuiOpenControler)1 ItemUpgrade (logisticspipes.items.ItemUpgrade)1 UpgradeCoordinatesGuiProvider (logisticspipes.network.abstractguis.UpgradeCoordinatesGuiProvider)1 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)1 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)1 IConfigPipeUpgrade (logisticspipes.pipes.upgrades.IConfigPipeUpgrade)1 SneakyUpgradeConfig (logisticspipes.pipes.upgrades.SneakyUpgradeConfig)1 DummyContainer (logisticspipes.utils.gui.DummyContainer)1 UpgradeSlot (logisticspipes.utils.gui.UpgradeSlot)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1