Jump to content

Recommended Posts

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.

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.