materials = registerItem(registry, new ItemMetaDynamic(), "materials"); edibles = registerItem(registry, new ItemEdible(), "edible"); searedBrick = materials.addMeta(0, "seared_brick"); mudBrick = materials.addMeta(1, "mud_brick"); nuggetCobalt = nuggets.addMeta(0, "cobalt"); ingotCobalt = ingots.addMeta(0, "cobalt"); nuggetArdite = nuggets.addMeta(1, "ardite"); ingotArdite = ingots.addMeta(1, "ardite"); nuggetManyullyn = nuggets.addMeta(2, "manyullyn"); ingotManyullyn = ingots.addMeta(2, "manyullyn"); nuggetPigIron = nuggets.addMeta(4, "pigiron"); ingotPigIron = ingots.addMeta(4, "pigiron"); nuggetAlubrass = nuggets.addMeta(5, "alubrass"); ingotAlubrass = ingots.addMeta(5, "alubrass"); matSlimeCrystalGreen = materials.addMeta(9, "slimecrystal_green"); matSlimeCrystalBlue = materials.addMeta(10, "slimecrystal_blue"); matSlimeCrystalMagma = materials.addMeta(11, "slimecrystal_magma"); matExpanderW = materials.addMeta(12, "expander_w"); matExpanderH = materials.addMeta(13, "expander_h"); matReinforcement = materials.addMeta(14, "reinforcement"); matSilkyCloth = materials.addMeta(15, "silky_cloth");
@Override public void registerModels() { // ignore color state for the clear stained glass, it is handled by tinting ModelLoader.setCustomStateMapper(blockClearStainedGlass, (new StateMap.Builder()).ignore(BlockClearStainedGlass.COLOR).build()); nuggets.registerItemModels(); ingots.registerItemModels(); materials.registerItemModels(); edibles.registerItemModels(); registerItemModel(book, 0, "inventory"); registerItemBlockMeta(blockMetal); registerItemBlockMeta(blockSoil); registerItemBlockMeta(blockOre); registerItemBlockMeta(blockFirewood); registerItemBlockMeta(blockSlime); registerItemBlockMeta(blockSlimeCongealed); registerItemBlockMeta(slabFirewood); registerItemModel(stairsFirewood); registerItemModel(stairsLavawood); registerItemModel(blockClearGlass); registerItemModel(blockClearStainedGlass); // this is enumBlock, but the model is tinted instead of using a state registerItemBlockMeta(blockDecoGround); registerItemBlockMeta(slabDecoGround); registerItemModel(stairsMudBrick); } }
@Override public int getMetadata(ItemStack stack) { return dynamic.getMetadata(stack); }
@Override public ItemStack addMeta(int meta, String name) { if(!values.containsKey(meta)) { throw new RuntimeException("Usage of wrong function. Use the addMeta function that has an amount paired with it with this implementation"); } return super.addMeta(meta, name); } }
public ItemEdible() { super(0, 0, false); this.setHasSubtypes(true); dynamic = new ItemMetaDynamic(); foodLevels = new TIntIntHashMap(); saturations = new TIntFloatHashMap(); potionEffects = new TIntObjectHashMap<PotionEffect[]>(); alwaysEdible = new BitSet(); displayEffectsTooltip = true; }
/** * Add a valid metadata. * * @param meta The metadata value * @param name The name used for registering the itemmodel as well as the unlocalized name of the meta. The unlocalized name will be lowercased and stripped of whitespaces. * @return An itemstack representing the Item-Meta combination. */ public ItemStack addMeta(int meta, String name) { if(meta > MAX) { throw new IllegalArgumentException(String .format("Metadata for %s too high, highest supported value is %d. Meta was %d", name, MAX, meta)); } else if(isValid(meta)) { throw new IllegalArgumentException(String .format("Metadata for %s is already taken. Meta %d is %s", name, meta, names .get(meta))); } while(meta >= availabilityMask.length) { availabilityMask = Arrays.copyOf(availabilityMask, availabilityMask.length * 2); } setValid(meta); names.put(meta, name); return new ItemStack(this, 1, meta); }
return saturations.get(stack.getMetadata()); // should call getMetadata below return foodLevels.get(stack.getMetadata()); // should call getMetadata below protected void onFoodEaten(ItemStack stack, World worldIn, @Nonnull EntityPlayer player) { if(!worldIn.isRemote) { for(PotionEffect potion : potionEffects.get(stack.getMetadata())) { player.addPotionEffect(new PotionEffect(potion.getPotion(), potion.getDuration(), potion.getAmplifier(), potion .getIsAmbient(), potion.doesShowParticles())); for(PotionEffect potionEffect : potionEffects.get(stack.getMetadata())) { tooltip.add(I18n.translateToLocal(potionEffect.getEffectName()).trim()); if(this.isInCreativeTab(tab)) { for(int i = 0; i <= dynamic.availabilityMask.length; i++) { if(dynamic.isValid(i)) { subItems.add(new ItemStack(this, 1, i)); int meta = itemStackIn.getMetadata(); if(dynamic.isValid(meta) && playerIn.canEat(this.alwaysEdible.get(itemStackIn.getMetadata())))
public String getUnlocalizedName(ItemStack stack) { int meta = stack.getMetadata(); // should call getMetadata below if(isValid(meta)) { return super.getUnlocalizedName(stack) + "." + LocUtils.makeLocString(names.get(meta)); if(this.isInCreativeTab(tab)) { for(int i = 0; i <= availabilityMask.length; i++) { if(isValid(i)) { subItems.add(new ItemStack(this, 1, i)); public int getMetadata(int damage) { int meta = super.getMetadata(damage); return isValid(meta) ? meta : 0;
@Override public ItemStack addMeta(int meta, String name) { if (!this.states.containsKey(meta)) { throw new RuntimeException("Usage of wrong function. Use the addMeta function that has an state paired with it with this implementation"); } return super.addMeta(meta, name); }
materials = registerItem(registry, new ItemMetaDynamic(), "materials"); empty_bowls = registerItem(registry, new ItemMetaDynamic(), "empty_bowls"); edibles = registerItem(registry, new ItemNaturaEdible(), "edibles"); soups = registerItem(registry, new ItemNaturaEdibleSoup(), "soups"); seed_bags = registerItem(registry, new ItemSeedBag(), "seed_bags"); sticks = registerItem(registry, new ItemMetaDynamic(), "sticks"); barley = materials.addMeta(0, "barley"); barleyFlour = materials.addMeta(1, "barley_flour"); wheatFlour = materials.addMeta(2, "wheat_flour"); cotton = materials.addMeta(3, "cotton"); sulfurPowder = materials.addMeta(4, "sulfur_powder"); ghostwoodFletching = materials.addMeta(5, "ghostwood_fletching"); blueDye = materials.addMeta(8, "blue_dye"); impLeather = materials.addMeta(6, "imp_leather"); flameString = materials.addMeta(7, "flame_string"); ghostwood_emptybowl = empty_bowls.addMeta(0, "ghostwood_bowl"); bloodwood_emptybowl = empty_bowls.addMeta(1, "bloodwood_bowl"); darkwood_emptybowl = empty_bowls.addMeta(2, "darkwood_bowl"); fusewood_emptybowl = empty_bowls.addMeta(3, "fusewood_bowl"); maple_stick = sticks.addMeta(0, "maple_stick"); silverbell_stick = sticks.addMeta(1, "silverbell_stick"); amaranth_stick = sticks.addMeta(2, "amaranth_stick"); tiger_stick = sticks.addMeta(3, "tiger_stick"); willow_stick = sticks.addMeta(4, "willow_stick"); eucalyptus_stick = sticks.addMeta(5, "eucalyptus_stick");
@Override public ItemStack addMeta(int meta, String name) { if (!this.states.containsKey(meta)) { throw new RuntimeException("Usage of wrong function. Use the addMeta function that has an state paired with it with this implementation"); } return super.addMeta(meta, name); }
@SideOnly(Side.CLIENT) public void registerItemModels() { dynamic.registerItemModels(this); }
@Override public ItemStack addMeta(int meta, String name) { if (!this.states.containsKey(meta)) { throw new RuntimeException("Usage of wrong function. Use the addMeta function that has an amount paired with it with this implementation"); } return super.addMeta(meta, name); }
@SideOnly(Side.CLIENT) public void registerItemModels() { registerItemModels(this); }
@Override protected void registerModels() { registerItemBlockMeta(clouds); materials.registerItemModels(); empty_bowls.registerItemModels(); soups.registerItemModels(); edibles.registerItemModels(); seed_bags.registerItemModels(); sticks.registerItemModels(); registerItemModel(boneMealBag); } }
/** * Add a new food type! * * @param meta Metadata to use, has to be free * @param food How much food it restores on eating * @param saturation Saturation multiplier on the food * @param name Unlocalized postfix * @param alwaysEdible Item is always edible even when hunger is full * @param effects PotionEffects that will be applied on eating. The PotionEffect passed will be directly applied * @return Itemstack containing the registered item */ public ItemStack addFood(int meta, int food, float saturation, String name, boolean alwaysEdible, PotionEffect... effects) { dynamic.addMeta(meta, name); foodLevels.put(meta, food); saturations.put(meta, saturation); potionEffects.put(meta, effects); this.alwaysEdible.set(meta, alwaysEdible); return new ItemStack(this, 1, meta); }
TinkerGadgets.spaghetti.registerItemModels(); registerToolModel(TinkerGadgets.momsSpaghetti, Util.getResource("moms_spaghetti" + ToolModelLoader.EXTENSION));