Jump to content

Help With SetContainerItem [ 1.12.2 ]


chrizz

Recommended Posts

How to set a container item? My item is called bowl_and_pestle. I want it to stay in the crafting table like buckets. Sorry for bad english. Thanks for the help ? I am a beginner developer so please don't write hard code. Thanks ;)

Edited by chrizz
Link to comment
Share on other sites

A container item is what happens when you remove contents from an item and leave its container.

e.g.:

Bucket of Milk (has container Bucket)

Bowl of Stew (has container Bowl)

 

So your mortar and pestle would have a container item of mortar and pestle.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

14 minutes ago, Draco18s said:

A container item is what happens when you remove contents from an item and leave its container.

e.g.:

Bucket of Milk (has container Bucket)

Bowl of Stew (has container Bowl)

 

So your mortar and pestle would have a container item of mortar and pestle.

Yeah but I don't know the code...

Link to comment
Share on other sites

For now i've done that but it not work.

package com.c_h_r_i_z_.bakerymod.items;

import com.c_h_r_i_z_.bakerymod.items.base.ItemBase;

import net.minecraft.item.ItemStack;

public class ItemBowlAndPestle extends ItemBase
{

	public ItemBowlAndPestle(String name) 
	{
		super(name);
		
		setMaxStackSize(1);
		setNoRepair();
		setMaxDamage(40);
	}
	
	@Override
    public ItemStack getContainerItem(ItemStack itemstack)
	{
        ItemStack stack = itemstack.copy();
        stack.attemptDamageItem(1, itemRand, null);
        return stack;
    } 

   @Override
    public boolean hasContainerItem(ItemStack stack)
   {
        return true;
    }

	
}

 

Link to comment
Share on other sites

42 minutes ago, chrizz said:

it not work.

Huh, I wonder how one might solve this problem you have here. It not working is a big one. If only we new what not working meant.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

29 minutes ago, chrizz said:

Someone send the correct code please I really need that.

No. We will never write your code for you.

What are you trying to achieve?

Have you looked at Item#setContainerItem

https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/mods-discussion/1403810-how-to-return-buckets-after-crafting

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

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.