Jump to content

[1.11] SubItems stack onto each other when picked up.


Recommended Posts

Posted

Hey there,

 

So I have 4 types of 'gems', in the inventory, they cannot be stacked, however, when they are picked up or /give they look like the respective crystal, but they ended up stacking in the inventory. My explanation might be dull, so here are some captioned pictures of whats happening:

 

 

93056514526d4d3b9de2af6f325eee05.png

In the inventory, the different gems cannot be stacked.

 

7a839c023cda428aa15fece19c2d3417.png

|

v

ccfc539728c1491ea5d83f0b3a66a49f.png

However, when I pick up a clearly non-stackable crystal, it stacks into it.

 

 

 

Here is item class code:

public class ItemMagicGems extends ItemBase {

    public static final Gems[] ALL_GEMS = Gems.values();

    public Gems type;
    private final boolean isEmpowered;



    public ItemMagicGems(String name, boolean isEmpowered) {
        super(name);
        this.setFull3D();
        this.isEmpowered = isEmpowered;

    }

    @Override
    public String getUnlocalizedName(ItemStack stack){
        return stack.getItemDamage() >= ALL_GEMS.length ? StringUtil.BUGGED_ITEM_NAME : this.getUnlocalizedName()+"_"+ALL_GEMS[stack.getItemDamage()].name;
    }

    @Override
    public boolean hasEffect(ItemStack stack){
        return this.isEmpowered;
    }

    @Override
    public EnumRarity getRarity(ItemStack stack){
        return stack.getItemDamage() >= ALL_GEMS.length ? EnumRarity.COMMON : ALL_GEMS[stack.getItemDamage()].rarity;
    }

    @Override
    @SideOnly(Side.CLIENT)
    public void getSubItems(Item item, CreativeTabs tab, NonNullList list){
        for(int j = 0; j < ALL_GEMS.length; j++){
            list.add(new ItemStack(this, 1, j));
        }
    }

    @Override
    protected void registerRendering(){
        for(int i = 0; i < ALL_GEMS.length; i++){
            String name = this.getRegistryName()+"_"+ALL_GEMS[i].name;
            PlentifulMisc.proxy.addRenderRegister(new ItemStack(this, 1, i), new ResourceLocation(name), "inventory");
        }
    }

}

,

here is how I'm registering them:

        item_gems = new ItemMagicGems("item_gem", false);

 

Thanks

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

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.