Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

HazeTrance

Members
  • Joined

  • Last visited

  1. I have very limited knowledge, but with a stroke of luck, a little bit of common sense, your method worked for me! I didn't have to change the way I made all my items, or anything. So I thank you for that. As for everyone else who helped, I really appreciate it, for this experience made me learn A LOT. Thanks~
  2. I created this thread to ask the community to diagnose the problem, so I can fix it. If there is no other solution, then I will resort to other code.
  3. Well, as I stated before, I am quite new to modding, so I'll have to learn how to "meta", but is there an alternate solution where I can declare a new food similar to how I declare regular items? ModItem Code: package net.gwee.mod; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.item.Item; import net.minecraft.util.Icon; public class ModItem extends Item { private String iconPath; @SideOnly(Side.CLIENT) private Icon icon; public ModItem(int par1, String par2String){ super(par1); this.iconPath = par2String; } @SideOnly(Side.CLIENT) public void registerIcons(IconRegister par1IconRegister){ this.icon = par1IconRegister.registerIcon("mod/" + this.iconPath); } @SideOnly(Side.CLIENT) public Icon getIconFromDamage(int par1){ return this.icon; } } If I want to make a new item with this method: public static Item example = new ModItem(1337, "texture").setUnlocalizedName("example");
  4. Sorry, forgot to mention. Both of them have their own respective properties, just that the names are swapped. Is there anyway of doing it without 2 different classes?
  5. I am fairly new to this whole modding thing, so I have started to experiment by implementing random stuffs into the game. I just started to work with food items, so I made a new ModFood class file. Here is the source code: package net.gwee.mod; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.item.Item; import net.minecraft.item.ItemFood; import net.minecraft.util.Icon; public class ModFood extends ItemFood { private String iconPath; private String unlocalizedName; @SideOnly(Side.CLIENT) private Icon icon; public ModFood( int par1, String par5String, int par2, float par3, boolean par4 ){ super(par1, par2, par3, par4); this.iconPath = par5String; } @SideOnly(Side.CLIENT) public void registerIcons(IconRegister par1IconRegister){ this.icon = par1IconRegister.registerIcon("mod/" + this.iconPath); } @SideOnly(Side.CLIENT) public Icon getIconFromDamage(int par1){ return this.icon; } public ModFood setUnlocalizedName(String par1Str) { this.unlocalizedName = par1Str; return this; } } http://paste.minecraftforge.net/view/dbe7ac49 Just in case, here is the source code of ItemFood: package net.minecraft.item; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; public class ItemFood extends Item { public final int itemUseDuration; private final int healAmount; private final float saturationModifier; private final boolean isWolfsFavoriteMeat; private boolean alwaysEdible; private int potionId; private int potionDuration; private int potionAmplifier; private float potionEffectProbability; public ItemFood(int par1, int par2, float par3, boolean par4) { super(par1); this.itemUseDuration = 32; this.healAmount = par2; this.isWolfsFavoriteMeat = par4; this.saturationModifier = par3; this.setCreativeTab(CreativeTabs.tabFood); } public ItemFood(int par1, int par2, boolean par3) { this(par1, par2, 0.6F, par3); } public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { --par1ItemStack.stackSize; par3EntityPlayer.getFoodStats().addStats(this); par2World.playSoundAtEntity(par3EntityPlayer, "random.burp", 0.5F, par2World.rand.nextFloat() * 0.1F + 0.9F); this.onFoodEaten(par1ItemStack, par2World, par3EntityPlayer); return par1ItemStack; } protected void onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (!par2World.isRemote && this.potionId > 0 && par2World.rand.nextFloat() < this.potionEffectProbability) { par3EntityPlayer.addPotionEffect(new PotionEffect(this.potionId, this.potionDuration * 20, this.potionAmplifier)); } } public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 32; } public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.eat; } public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (par3EntityPlayer.canEat(this.alwaysEdible)) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); } return par1ItemStack; } public int getHealAmount() { return this.healAmount; } public float getSaturationModifier() { return this.saturationModifier; } public boolean isWolfsFavoriteMeat() { return this.isWolfsFavoriteMeat; } public ItemFood setPotionEffect(int par1, int par2, int par3, float par4) { this.potionId = par1; this.potionDuration = par2; this.potionAmplifier = par3; this.potionEffectProbability = par4; return this; } public ItemFood setAlwaysEdible() { this.alwaysEdible = true; return this; } } http://paste.minecraftforge.net/view/0ccae1ba Anyways, so I created new 2 new food items, toast and butter. I created everything needed to implement it into the game, but for some odd reason, both of them appear as "Butter". I suspect it must be UnlocalizedName in some way, but I haven't really found out how to fix it. Here is the code of interest in the main class file: public static ModFood toast = new ModFood(8150, "toast", 6, 6.5F, false).setUnlocalizedName("toast"); public static ModFood butter = new ModFood(8151, "butter", 1, 1F, false).setUnlocalizedName("butter"); public static CreativeTabs tabBillMod = new CreativeTabBillMod(CreativeTabs.getNextID(), derpEssenceR.itemID, "tabBillMod", "Bill's Mod"); @Override public void load() { //Register CreativeTabs toast.setCreativeTab(tabBillMod); butter.setCreativeTab(tabBillMod); //Register Item GameRegistry.registerItem(toast, "toast"); GameRegistry.registerItem(butter, "butter"); //Register Names LanguageRegistry.addName(toast, "Toast"); LanguageRegistry.addName(butter, "Butter"); } http://paste.minecraftforge.net/view/dee39682 Any help or feedback would be extremely appreciated!

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.