Java Code Examples for net.minecraft.item.ItemStack#getUnlocalizedName()

The following examples show how to use net.minecraft.item.ItemStack#getUnlocalizedName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluginGT6VeinStat.java    From GTNEIOrePlugin with MIT License 6 votes vote down vote up
@Override
public void loadCraftingRecipes(ItemStack stack) {
    String unlocalizedName = stack.getUnlocalizedName();
    if (unlocalizedName.startsWith("oredict.ore") && !unlocalizedName.startsWith("oredict.oreSmall") && !unlocalizedName.startsWith("oredict.oreBedrock")) {
        short meta = (short)stack.getItemDamage();
        for (OreLayerWrapper worldGen: GT6OreLayerHelper.mapOreLayerWrapper.values()) {
            if (meta==worldGen.primaryMeta || meta==worldGen.secondaryMeta || meta==worldGen.betweenMeta || meta==worldGen.sporadicMeta) {
                List<ItemStack> stackListPrimary = new ArrayList<ItemStack>();
                List<ItemStack> stackListSecondary = new ArrayList<ItemStack>();
                List<ItemStack> stackListBetween = new ArrayList<ItemStack>();
                List<ItemStack> stackListSporadic = new ArrayList<ItemStack>();
                for (PrefixBlock prefixBlock: GT6OreLayerHelper.setOreNormalBasicTypes) {
                    stackListPrimary.add(new ItemStack(prefixBlock, 1, worldGen.primaryMeta));
                    stackListSecondary.add(new ItemStack(prefixBlock, 1, worldGen.secondaryMeta));
                    stackListBetween.add(new ItemStack(prefixBlock, 1, worldGen.betweenMeta));
                    stackListSporadic.add(new ItemStack(prefixBlock, 1, worldGen.sporadicMeta));
                }
                this.arecipes.add(new CachedVeinStatRecipe(worldGen.veinName, stackListPrimary, stackListSecondary, stackListBetween, stackListSporadic));
            }
        }
    }
    else
        super.loadCraftingRecipes(stack);
}
 
Example 2
Source File: InventoryDumper.java    From NEI-Integration with MIT License 6 votes vote down vote up
private void addToList(List<String[]> list, ItemStack[] stacks, boolean isArmor) {
    for (int i = 0; i < stacks.length; i++) {
        ItemStack stack = stacks[i];
        if (stack == null || stack.getItem() == null) {
            continue;
        }
        
        String slot = String.valueOf(i + (isArmor ? 100 : 0));
        String displayName = stack.getDisplayName();
        String amount = String.valueOf(stack.stackSize);
        String damage = String.valueOf(stack.getItemDamage());
        String maxDamage = String.valueOf(stack.getMaxDamage());
        String itemID = Item.itemRegistry.getNameForObject(stack.getItem());
        String unlocalizedName = stack.getUnlocalizedName();
        String itemClass = stack.getItem().getClass().getName();
        String nbt = stack.stackTagCompound != null ? stack.stackTagCompound.toString() : "";
        
        list.add(new String[] { slot, displayName, amount, damage, maxDamage, itemID, unlocalizedName, itemClass, nbt });
    }
}
 
Example 3
Source File: BlockPneumaticCraft.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List curInfo, boolean extraInfo){
    if(PneumaticCraft.proxy.isSneakingInGui()) {
        TileEntity te = createNewTileEntity(player.worldObj, 0);
        if(te instanceof TileEntityPneumaticBase) {
            float pressure = ((TileEntityPneumaticBase)te).DANGER_PRESSURE;
            curInfo.add(EnumChatFormatting.YELLOW + I18n.format("gui.tooltip.maxPressure", pressure));
        }
    }

    String info = "gui.tab.info." + stack.getUnlocalizedName();
    String translatedInfo = I18n.format(info);
    if(!translatedInfo.equals(info)) {
        if(PneumaticCraft.proxy.isSneakingInGui()) {
            translatedInfo = EnumChatFormatting.AQUA + translatedInfo.substring(2);
            if(!Loader.isModLoaded(ModIds.IGWMOD)) translatedInfo += " \\n \\n" + I18n.format("gui.tab.info.assistIGW");
            curInfo.addAll(PneumaticCraftUtils.convertStringIntoList(translatedInfo, 60));
        } else {
            curInfo.add(EnumChatFormatting.AQUA + I18n.format("gui.tooltip.sneakForInfo"));
        }
    }
}
 
Example 4
Source File: SakuraEventLoader.java    From Sakura_mod with MIT License 5 votes vote down vote up
public static void addFishingLoot(ItemStack stack,int weight){
    LootCondition[] lootConditions = new LootCondition[0];
    LootFunction[] setMeta = new LootFunction[] { new SetMetadata(lootConditions, new RandomValueRange(stack.getMetadata())) };
    LootEntry entry = new LootEntryItem(stack.getItem(), weight, 0, setMeta, lootConditions, stack.getUnlocalizedName());

    FishinglootPools.add(entry);
}
 
Example 5
Source File: VariantBlock.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, @Nullable World player, List<String> tooltip, ITooltipFlag advanced) {
    //tier less tooltip like: tile.turbine_casing.tooltip
    String unlocalizedVariantTooltip = getUnlocalizedName() + ".tooltip";
    if (I18n.hasKey(unlocalizedVariantTooltip))
        tooltip.addAll(Arrays.asList(I18n.format(unlocalizedVariantTooltip).split("/n")));
    //item specific tooltip: tile.turbine_casing.bronze_gearbox.tooltip
    String unlocalizedTooltip = stack.getUnlocalizedName() + ".tooltip";
    if (I18n.hasKey(unlocalizedTooltip))
        tooltip.addAll(Arrays.asList(I18n.format(unlocalizedTooltip).split("/n")));
}
 
Example 6
Source File: ThaumcraftHandler.java    From bartworks with MIT License 5 votes vote down vote up
public static void addAspectViaBW(ItemStack stack, Pair<Object,Integer>... aspectPair) {
    if (stack == null || stack.getItem() == null || stack.getUnlocalizedName() == null)
        return;
    try {
        Object aspectList = ThaumcraftHandler.AspectAdder.mAspectListClass.newInstance();
        for (Pair a : aspectPair) {
            if (API_ConfigValues.debugLog)
                DebugLog.log("Stack:"+ stack.getDisplayName() + " Damage:" +stack.getItemDamage() + " aspectPair: " + ThaumcraftHandler.AspectAdder.getName.invoke(a.getKey()) + " / " + a.getValue());
            ThaumcraftHandler.AspectAdder.addToList.invoke(aspectList, a.getKey(), a.getValue());
        }
        ThaumcraftHandler.AspectAdder.registerObjectTag.invoke(null, stack, aspectList);
    }catch (IllegalAccessException | InstantiationException | InvocationTargetException e){
        e.printStackTrace();
    }
}
 
Example 7
Source File: GTItemElectromagnet.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public ModelResourceLocation createResourceLocationForStack(ItemStack stack) {
	int damage = stack.getItemDamage();
	ResourceLocation location = this.getRegistryName();
	String name = stack.getUnlocalizedName();
	this.model[damage] = new ModelResourceLocation(location.getResourceDomain()
			+ name.substring(name.indexOf(".") + 1) + damage, "inventory");
	return this.model[damage];
}
 
Example 8
Source File: BookMetaProvider.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@Override
public Object getMeta(IItemPortalActivator target, ItemStack stack) {
	final ILinkInfo linkInfo = getLinkInfo(stack);
	if (linkInfo == null) return null;

	final String unlocalizedName = stack.getUnlocalizedName();
	final boolean isLinkbook = "item.myst.linkbook".equals(unlocalizedName);
	final boolean isAgebook = "item.myst.agebook".equals(unlocalizedName);

	Map<String, Object> result = Maps.newHashMap();

	result.put("type", isLinkbook? "link" : (isAgebook? "age" : "unknown"));
	result.put("destination", linkInfo.getDisplayName());
	result.put("dimension", linkInfo.getDimensionUID());

	final LinkPropertyAPI linkPropertiesApi = MystcraftAccess.linkPropertiesApi;
	if (linkPropertiesApi != null) {
		final Collection<String> allProperties = linkPropertiesApi.getLinkProperties();

		Set<String> flags = Sets.newHashSet();
		for (String flag : allProperties)
			if (linkInfo.getFlag(flag)) flags.add(flag);

		result.put("flags", flags);
	}

	{
		ChunkCoordinates coords = linkInfo.getSpawn();
		if (coords != null) result.put("spawn", Lists.newArrayList(coords.posX, coords.posY, coords.posZ));
	}

	result.put("spawnYaw", linkInfo.getSpawnYaw());

	return result;

}
 
Example 9
Source File: LexiconRecipeMappings.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
public static String stackToString(ItemStack stack) {
	if(stack == null || stack.getItem() == null)
		return "NULL";
	
	if(stack.hasTagCompound() && stack.getItem() instanceof IRecipeKeyProvider)
		return ((IRecipeKeyProvider) stack.getItem()).getKey(stack);

	return stack.getUnlocalizedName() + (ignoreMeta(stack) ? "" : "~" + stack.getItemDamage());
}
 
Example 10
Source File: ItemStackMetadataBuilder.java    From OpenPeripheral with MIT License 5 votes vote down vote up
private static String getNameForItemStack(ItemStack is) {
	try {
		return is.getDisplayName();
	} catch (Exception e) {}

	try {
		return is.getUnlocalizedName();
	} catch (Exception e2) {}

	return "unknown";
}
 
Example 11
Source File: EntityPlayerSPHook.java    From SkyblockAddons with MIT License 4 votes vote down vote up
public static EntityItem dropOneItemConfirmation(ReturnValue<?> returnValue) {
    SkyblockAddons main = SkyblockAddons.getInstance();
    Minecraft mc = Minecraft.getMinecraft();
    ItemStack heldItemStack = mc.thePlayer.getHeldItem();

    if ((main.getUtils().isOnSkyblock() || main.getPlayerListener().aboutToJoinSkyblockServer())) {
        if (main.getConfigValues().isEnabled(Feature.LOCK_SLOTS) && !main.getUtils().isInDungeon()) {
            int slot = mc.thePlayer.inventory.currentItem + 36;
            if (main.getConfigValues().getLockedSlots().contains(slot) && (slot >= 9 || mc.thePlayer.openContainer instanceof ContainerPlayer && slot >= 5)) {
                main.getUtils().playLoudSound("note.bass", 0.5);
                SkyblockAddons.getInstance().getUtils().sendMessage(main.getConfigValues().getRestrictedColor(Feature.DROP_CONFIRMATION) + Message.MESSAGE_SLOT_LOCKED.getMessage());
                returnValue.cancel();
                return null;
            }

            if (System.currentTimeMillis() - MinecraftHook.getLastLockedSlotItemChange() < 200) {
                main.getUtils().playLoudSound("note.bass", 0.5);
                SkyblockAddons.getInstance().getUtils().sendMessage(main.getConfigValues().getRestrictedColor(Feature.DROP_CONFIRMATION) + Message.MESSAGE_SWITCHED_SLOTS.getMessage());
                returnValue.cancel();
                return null;
            }
        }

        if (heldItemStack != null && main.getConfigValues().isEnabled(Feature.STOP_DROPPING_SELLING_RARE_ITEMS) && !main.getUtils().isInDungeon()) {
            if (!main.getUtils().getItemDropChecker().canDropItem(heldItemStack, true)) {
                main.getUtils().sendMessage(main.getConfigValues().getRestrictedColor(Feature.STOP_DROPPING_SELLING_RARE_ITEMS) + Message.MESSAGE_CANCELLED_DROPPING.getMessage());
                returnValue.cancel();
                return null;
            }

            if (System.currentTimeMillis() - MinecraftHook.getLastLockedSlotItemChange() < 200) {
                main.getUtils().playLoudSound("note.bass", 0.5);
                SkyblockAddons.getInstance().getUtils().sendMessage(main.getConfigValues().getRestrictedColor(Feature.DROP_CONFIRMATION) + Message.MESSAGE_SWITCHED_SLOTS.getMessage());
                returnValue.cancel();
                return null;
            }
        }
    }

    if (heldItemStack != null && main.getConfigValues().isEnabled(Feature.DROP_CONFIRMATION) && !main.getUtils().isInDungeon() && (main.getUtils().isOnSkyblock() || main.getPlayerListener().aboutToJoinSkyblockServer()
            || main.getConfigValues().isEnabled(Feature.DOUBLE_DROP_IN_OTHER_GAMES))) {
        lastDrop = Minecraft.getSystemTime();

        String heldItemName = heldItemStack.hasDisplayName() ? heldItemStack.getDisplayName() : heldItemStack.getUnlocalizedName();

        if (lastItemName == null || !lastItemName.equals(heldItemName) || Minecraft.getSystemTime() - lastDrop >= 3000L) {
            SkyblockAddons.getInstance().getUtils().sendMessage(main.getConfigValues().getRestrictedColor(Feature.DROP_CONFIRMATION) + Message.MESSAGE_DROP_CONFIRMATION.getMessage());
            lastItemName = heldItemName;
            returnValue.cancel();
        }
    }

    return null;
}
 
Example 12
Source File: MinecraftTypeHelper.java    From malmo with MIT License 4 votes vote down vote up
/** Attempt to break the item on this itemstack into a type/variant/colour which we can use for communication with the Malmo platform.
 * @param is the ItemStack containing the item we are attempting to deconstruct.
 * @return an XML DrawItem object containing the item's type, variant, colour etc.
 */
public static DrawItem getDrawItemFromItemStack(ItemStack is)
{
    if (is == null)
        return null;

    DrawItem di = new DrawItem();
    String name = is.getUnlocalizedName();  // Get unlocalised name from the stack, not the stack's item - this ensures we keep the metadata.
    if (is.getHasSubtypes())
    {
        // If the item has subtypes, then there are varieties - eg different colours, types, etc.
        // Attempt to map from these subtypes back to variant/colour.
        // Do this by decomposing the unlocalised name:
        List<String> itemParts = new ArrayList<String>(Arrays.asList(name.split("\\.")));
        if (is.getItem() instanceof ItemMonsterPlacer)
        {
            // Special case for eggs:
            itemParts.add(ItemMonsterPlacer.getNamedIdFrom(is).toString());
        }
        // First part will be "tile" or "item".
        // Second part will be the item itself (eg "dyePowder" or "stainedGlass" etc).
        // Third part will be the variant, colour etc.
        Colour col = null;
        Variation var = null;
        for (int part = 2; part < itemParts.size(); part++)
        {
            String section = itemParts.get(part);
            // First see if this matches a colour:
            if (col == null)
            {
                col = attemptToGetAsColour(section);
                if (col == null && var == null) // If it wasn't a colour, check to see if it was a variant:
                    var = attemptToGetAsVariant(section, is);
            }
            else if (var == null)
                var = attemptToGetAsVariant(section, is);
        }
        di.setColour(col);
        di.setVariant(var);
    }
    // Use the item registry name for the item - this is what we use in Types.XSD
    Object obj = Item.REGISTRY.getNameForObject(is.getItem());
    String publicName;
    if (obj instanceof ResourceLocation)
        publicName = ((ResourceLocation)obj).getResourcePath();
    else
        publicName = obj.toString();
    di.setType(publicName);
    return di;
}