Jump to content

Recommended Posts

Posted

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);
                        }
                    }
                }

 

Posted

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...

×   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.