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

Hi

 

I made a topic talking about having a generic item model. I learnt it would be pretty hard to do that so I have met it half-way:

Each new item material has its own model file, but the content inside it is identical to one another. I'm making a new post due to the old one became cold and nothing happened and my question has changed somewhat. So here goes:

 

The full idea was to have one superclass which will make an ingot (+ nugget), dust (+ tiny) and plate item when extended:

Code:

Spoiler

ItemElement.java


/*
 * @TODO
 * Should register an dust (+ tiny), ingot (+ nugget), plate.
 * Is going to be a extension of this class to make code shorter.
 */
public class ItemElement extends Item implements IItemColor
{
    protected int tint;

    public ItemElement(String name, String oredict, int tint)
    {
        super(new Item.Properties().group(IntercraftItemGroups.RESOURCES));

        this.tint = tint;
        setRegistryName(name + "_ingot");
    }

    @Override
    public int getColor(ItemStack itemStack, int tint)
    {
        return Color.GREEN.getRGB();
    }
}

 

Example usage (most of the child class' content is due to change):

Uranium.java


public class Uranium extends ItemElement
{
    public Uranium()
    {
        super("u", "uranium", 0x92d67d);
    }

    @Override
    public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
    {
        int amp = 0;

        if (isSelected)
            amp = 1;

        PotionEffect effect = new PotionEffect(MobEffects.POISON, 60, amp);
        if (entityIn instanceof EntityPlayer)
            ((EntityPlayer) entityIn).addPotionEffect(effect);
    }
}

 

The ones without any special properties are simply going to be initialized instead of making a new class for it.

 

 

I have been trying for a while to have the item change colour like how Minecraft colour their potion flasks' content. The code I wrote now I expected it would at least change the tint of the item to green, but to no avail:

Spoiler

2019-05-30_15_59_06.png.7e8d7a37479c7516008e80e1e67fff49.png

 

 

Something I wonder too is how Ore Dictionary now works. The idea was to add the prefix of the item and the type: "ingotCopper", "dustUranium", etc.

You need to register your IItemColors using the ColorHandlerEvent.Item event, fired on the MinecraftForge.EVENT_BUS. You don't need your item to implement IItemColor.

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.