private String getItemShortTermName(ItemStack stack) { return net.minecraft.util.text.translation.I18n.translateToLocal(stack.getTranslationKey().replaceAll("item.", "item.botania:") + ".short"); }
public static void set(EntityPlayer player, ItemStack displayStack, Pattern pattern) { int count = 0; for(int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack stack = player.inventory.getStackInSlot(i); if(!stack.isEmpty() && pattern.matcher(stack.getTranslationKey()).find()) count += stack.getCount(); } set(displayStack, count); }
public static String stackToString(ItemStack stack, boolean forceIgnore) { if(stack.isEmpty()) return "NULL"; if(stack.hasTagCompound() && stack.getItem() instanceof IRecipeKeyProvider) return ((IRecipeKeyProvider) stack.getItem()).getKey(stack); return stack.getTranslationKey() + (forceIgnore || ignoreMeta(stack) ? "" : "~" + stack.getItemDamage()); }
@Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack par1ItemStack, World world, List<String> stacks, ITooltipFlag flags) { Block block = getBlock(par1ItemStack); if(block != null) { int count = getBlockCount(par1ItemStack); stacks.add(count + " " + I18n.format(new ItemStack(block, 1, getBlockMeta(par1ItemStack)).getTranslationKey() + ".name")); } if(par1ItemStack.getItemDamage() == 1) addStringToTooltip(I18n.format("botaniamisc.active"), stacks); else addStringToTooltip(I18n.format("botaniamisc.inactive"), stacks); }
@Override public String describe() { if (in instanceof ItemStack) { return "Adding smashing recipe for " + ((ItemStack) in).getTranslationKey(); } else if (in instanceof String) { return "Adding smashing recipe for " + in; } return null; }
@SideOnly(Side.CLIENT) public void addBindInfo(List<String> list, ItemStack stack) { if(GuiScreen.isShiftKeyDown()) { if(!hasUUID(stack)) { addStringToTooltip(I18n.format("botaniamisc.relicUnbound"), list); } else { if(!getSoulbindUUID(stack).equals(Minecraft.getMinecraft().player.getUniqueID())) addStringToTooltip(I18n.format("botaniamisc.notYourSagittarius"), list); else addStringToTooltip(I18n.format("botaniamisc.relicSoulbound", Minecraft.getMinecraft().player.getName()), list); } if(stack.getItem() == ModItems.dice) { addStringToTooltip("", list); String name = stack.getTranslationKey() + ".poem"; for(int i = 0; i < 4; i++) addStringToTooltip(TextFormatting.ITALIC + I18n.format(name + i), list); } } else addStringToTooltip(I18n.format("botaniamisc.shiftinfo"), list); }
@Override public String getUnlocalizedTitle() { ItemStack cartItem = getCartItem(); return cartItem.getTranslationKey() + ".name"; }
@Override public String getHeaderText() { return I18n.format(stack.getTranslationKey() + ".name"); }
@SideOnly(Side.CLIENT) public void renderHUD(Minecraft mc, ScaledResolution res) { ItemStack pool = new ItemStack(ModBlocks.pool, 1, world.getBlockState(getPos()).getValue(BotaniaStateProps.POOL_VARIANT).ordinal()); String name = I18n.format(pool.getTranslationKey().replaceAll("tile.", "tile." + LibResources.PREFIX_MOD) + ".name"); int color = 0x4444FF; HUDHandler.drawSimpleManaHUD(color, knownMana, manaCap, name, res); int x = res.getScaledWidth() / 2 - 11; int y = res.getScaledHeight() / 2 + 30; int u = outputting ? 22 : 0; int v = 38; GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); mc.renderEngine.bindTexture(HUDHandler.manaBar); RenderHelper.drawTexturedModalRect(x, y, 0, u, v, 22, 15); GlStateManager.color(1F, 1F, 1F, 1F); ItemStack tablet = new ItemStack(ModItems.manaTablet); ItemManaTablet.setStackCreative(tablet); net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); mc.getRenderItem().renderItemAndEffectIntoGUI(tablet, x - 20, y); mc.getRenderItem().renderItemAndEffectIntoGUI(pool, x + 26, y); net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); GlStateManager.disableLighting(); GlStateManager.disableBlend(); }
public static String getName(ItemStack stack) { String name = stack.getTranslationKey(); if (!Strings.isNullOrEmpty(name)) { name = StringUtils.removeStart(name, "tile."); name = StringUtils.removeStart(name, "item."); name = StringUtils.removeEnd(name, ".name"); return name; } else { return stack.getItem().getRegistryName().toString(); } }
public RecipeHydrate(ItemStack[] in, ItemStack out, int w) { if (in.length > TileEntityHydrator.RECIPE_SIZE || in.length == 0) { throw new IllegalArgumentException("Input array must be length 4 or less"); } for (int i = 0; i < in.length; i++) { if (in[i] != null && in[i].isEmpty() == false) recipeInput.set(i, in[i]); } this.fluidCost = w; this.resultItem = out; this.setRegistryName(new ResourceLocation(Const.MODID, "hydrator_" + UUID.randomUUID().toString() + out.getTranslationKey())); }
@Override public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag advanced) { super.addInformation(stack, world, tooltip, advanced); int charges = 0; NBTTagCompound compound = stack.getTagCompound(); if (compound != null) { charges = compound.getInteger("Charges"); } tooltip.add(TextFormatting.GOLD + Translator.translateToLocalFormatted(stack.getTranslationKey() + ".charges", charges)); } }
public RecipePackager(ItemStack out, ItemStack[] in) { if (in.length > 6 || in.length == 0) { throw new IllegalArgumentException("Input array must be length 6 or less"); } input = NonNullList.withSize(in.length, ItemStack.EMPTY); for (int i = 0; i < in.length; i++) { if (in[i] != null && in[i].isEmpty() == false) input.set(i, in[i]); } output = out; this.setRegistryName(new ResourceLocation(Const.MODID, "packager" + UUID.randomUUID().toString() + out.getTranslationKey())); }
@SideOnly(Side.CLIENT) public static void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag flag) { String unlocalizedName = stack.getTranslationKey(); String tooltipKey = unlocalizedName + ".tooltip"; if (Translator.canTranslateToLocal(tooltipKey)) { String tooltipInfo = Translator.translateToLocal(tooltipKey); Minecraft minecraft = Minecraft.getMinecraft(); List<String> tooltipInfoWrapped = minecraft.fontRenderer.listFormattedStringToWidth(tooltipInfo, 150); tooltip.addAll(tooltipInfoWrapped); } }
public static AbstractPage createItemPage(ItemStack stack, PageCategory category) { String body = I18n.format("pe.manual." + stack.getTranslationKey().substring(5)); List<List<String>> parts = Lists.partition(GUIManual.splitBody(body), GUIManual.TEXT_HEIGHT / GUIManual.TEXT_Y_OFFSET); AbstractPage ret = new ItemPage(stack.copy(), category, StringUtils.join(parts.get(0), "")); for (int i = 1; i < parts.size(); i++) { ret.addSubPage(new ItemPage(stack.copy(), category, StringUtils.join(parts.get(i), "")).setIndexed(false)); } return ret; }
public static ResourceLocation buildName(ItemStack output) { ResourceLocation firstTry = new ResourceLocation(Const.MODID, output.getTranslationKey()); int limit = 999; int index = 0; while (usedRecipeNames.containsKey(firstTry.toString()) || index > limit) { index++; firstTry = new ResourceLocation(Const.MODID, firstTry.getPath() + "_" + index); } usedRecipeNames.put(firstTry.toString(), true); return firstTry; }
@SideOnly(Side.CLIENT) public void renderHUD(Minecraft mc, ScaledResolution res) { String name = I18n.format(new ItemStack(ModBlocks.spreader, 1, world.getBlockState(getPos()).getValue(BotaniaStateProps.SPREADER_VARIANT).ordinal()).getTranslationKey().replaceAll("tile.", "tile." + LibResources.PREFIX_MOD) + ".name"); int color = isRedstone() ? 0xFF0000 : isDreamwood() ? 0xFF00AE : 0x00FF00; HUDHandler.drawSimpleManaHUD(color, knownMana, getMaxMana(), name, res);
private List<ITextComponent> getStatus(IItemHandler handler) { List<ITextComponent> components = new ArrayList<>(); for (int i = 0; i < handler.getSlots(); ++i) { ItemStack stack = handler.getStackInSlot(i); if (!stack.isEmpty()) { components.add(new TextComponentString(stack.getCount() + "x ").appendSibling(new TextComponentTranslation(stack.getTranslationKey() + ".name"))); } } return components; }
if(SEED_PATTERN.matcher(stack.getTranslationKey()).find()) { for(RecipePetals recipe : BotaniaAPI.petalRecipes) { if(recipe.matches(itemHandler)) {
@Override public void registerBlockAsNeeded(final ItemStack stack) { final int hashCode = stack.hasTagCompound() ? stack.getTagCompound().hashCode() : 0; if (getOwnBuilding(AbstractBuildingStructureBuilder.class) .getNeededResources() .get(stack.getTranslationKey() + ":" + stack.getItemDamage() + "-" + hashCode) == null) { getOwnBuilding(AbstractBuildingStructureBuilder.class).addNeededResource(stack, 1); } }