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

For example when you craft a cake, you get the bucket back. Do IRecipe objects have a method where I can get a list of ItemStacks that are returned to your inventory or something like that?

I like trains.

Hi

 

CraftingManager.getInstance().getRecipeList() will give you a list of all the recipes, and you can use getRecipeOutput() on each member of the list

 

I think this is what you're asking?

 

-TGG

Hi

 

The milk bucket is a "container item".  Container items are returned to your inventory like that.  So you could get a list of recipes from the CraftingManager, and inspect each ItemStack in .recipeItems for ones which have hasContainerItem().

 

Seems like a lot of hassle to me.  What are you trying to do exactly?

 

-TGG

 

        Item itemBucket = (new ItemBucket(Blocks.air)).setUnlocalizedName("bucket").setMaxStackSize(16).setTextureName("bucket_empty");
        itemRegistry.addObject(325, "bucket", itemBucket );
        itemRegistry.addObject(326, "water_bucket", (new ItemBucket(Blocks.flowing_water)).setUnlocalizedName("bucketWater").setContainerItem(itemBucket ).setTextureName("bucket_water"));
        itemRegistry.addObject(327, "lava_bucket", (new ItemBucket(Blocks.flowing_lava)).setUnlocalizedName("bucketLava").setContainerItem(itemBucket ).setTextureName("bucket_lava"));
        itemRegistry.addObject(335, "milk_bucket", (new ItemBucketMilk()).setUnlocalizedName("milk").setContainerItem(itemBucket).setTextureName("bucket_milk"));

 

Look in SlotCrafting.onPickupFromSlot to see how it is used, i.e.

 

                if (itemstack1.getItem().hasContainerItem(itemstack1))
                {
                    ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1);

                    if (itemstack2 != null && itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage())
                    {
                        MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, itemstack2));
                        continue;
                    }

                    if (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) || !this.thePlayer.inventory.addItemStackToInventory(itemstack2))
                    {
                        if (this.craftMatrix.getStackInSlot(i) == null)
                        {
                            this.craftMatrix.setInventorySlotContents(i, itemstack2);
                        }
                        else
                        {
                            this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false);
                        }
                    }
                }

 

  • Author

I'm the developer of the Minecraft Resource Calculator and I'm currently working on a mod that'll make adding mods to my calculator easier.

 

The mod is currently able to save mod data, item data, oredict stuff and the conventional recipes to an SQLite database. The one thing I forgot about was processing "leftover" stuff in recipes, like buckets when making cake. So I need to add support for that.

 

In the second code snippet you posted, itemstack1 would be a milk bucket (in the cake example) and itemstack2 would be an empty bucket. Is that right?

I like trains.

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.