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.

Featured Replies

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 :(

  • Author

Something like this?

gymDumbbell gymdumbbell = new gymDumbbell();

  • Author
1 minute ago, diesieben07 said:

For example, yes.‚

 

 

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

  • Author
19 hours ago, diesieben07 said:

Show what you tried.

 

That one,  gymDumbbell gymdumbbell = new gymDumbbell();

  • Author

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;
    }
}
 

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

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.

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...

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.