Jump to content

Recommended Posts

Posted

Yep, it's me again :P

Any help on this? It does not work.

GymDbellItem.java

package com.bagasmc.gym.items;

import java.util.List;

import com.bagasmc.gym.handlers.CreativeTabHandler;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class GymDbellItem extends Item {

	public static ItemBase gymDumbbell;
	public static ItemStack dumBell;
	
	 public static void init() {
	 gymDumbbell = register(new ItemBase("dumbBell").setCreativeTab(CreativeTabHandler.tabBlocks));
	 }
	 
	 @Override
	 public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean check) {
	  list.add("     STAMINA     ");
	  list.add("3 kilos   6.6 lbs");

	 }
	 
	private static <T extends Item> T register(T item) {
		GameRegistry.register(item);
		
		if(item instanceof ItemModelProvider) {
			((ItemModelProvider)item).registerItemModel(item);
		}
		
		return item;
	}
}

 

 

It does not show the lore :(

Posted
1 minute ago, diesieben07 said:

For example, yes.‚

 

 

Can you show how to properly use it please? it keeps giving me error.. :/

Posted

package com.bagasmc.gym.items;

import java.util.List;

import com.bagasmc.gym.handlers.CreativeTabHandler;

import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class GymDumbbell extends Item {

     public static ItemBase dumbBell;
     gymDumbbell gymdumbbell = new gymDumbbell();
     
     public static void init() {
     dumbBell = register(new ItemBase("dumbbell").setCreativeTab(CreativeTabHandler.tabBlocks));
     }
     
     @Override
     public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean check) {
      list.add("     STAMINA     ");
      list.add("3 kilos   6.6 lbs");

     }
     
    private static <T extends Item> T register(T item) {
        GameRegistry.register(item);
        
        if(item instanceof ItemModelProvider) {
            ((ItemModelProvider)item).registerItemModel(item);
        }
        
        return item;
    }
}
 

Posted

Try moving the gymdumbell = new gymdumbell() part into a moditems file and just calling the moditems in the common proxy. I can give a better example when I get home in about 5 and a half hours

Posted (edited)

You are registering

ItemBase dumbBell

and not

GymDumbbell gymdumbbell

. dumbBell is just ItemBase and will not have any properties from GymDumbbell.

Also, If you have too many Items your code might begin to look ugly. Move register() and init() to seperate class just for registering and holding Item objects for cleaner code. Normally called ModItems.

Edited by Gortart
giving out copy-paste-ready code is not a good idea.
Posted
9 minutes ago, diesieben07 said:

Why? There is no reason for this if you don't have like 50 items or so. Please don't blindly recommend / follow practices like this if you don't understand why they exist.

 

Also, please don't just post copy-paste-ready code, especially when it's obvious that OP doesn't have the necessary programming experience.

Sorry, should I edit those parts out?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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