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;
}
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));
}
}
}
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);
}
}
}
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);
}
}
Aggregations