Netglex Posted January 26, 2013 Posted January 26, 2013 I have the following problem: I programmed a custom bucket: the golden bucket (for example). Now, I want to milk a cow with it. I've already seen, that in ItemBucket.java, there is the important part: else if (this.isFull == 0 && var12.entityHit instanceof EntityCow) { return new ItemStack(Item.bucketMilk); } However, I recognized that in the file EntityCow.java, there is another important method: public boolean interact(EntityPlayer par1EntityPlayer) { ItemStack var2 = par1EntityPlayer.inventory.getCurrentItem(); if (var2 != null && var2.itemID == Item.bucketEmpty.itemID) { if (--var2.stackSize <= 0) { par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, new ItemStack(Item.bucketMilk)); } else if (!par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Item.bucketMilk))) { par1EntityPlayer.dropPlayerItem(new ItemStack(Item.bucketMilk.itemID, 1, 0)); } return true; } else { return super.interact(par1EntityPlayer); } } This is probably also responsable for the milking process. My question is now: How can I milk with a golden bucket without changing EntityCow.java and just changing my own mod files? Quote
thebest108 Posted January 27, 2013 Posted January 27, 2013 Don't use the buckets code for reference, it's overcomplicated. Instead, add the method itemInteractionForEntity() in your bucket class, and then do ItemStack.id = filledgoldenbucket.id+256 Quote "you seem to be THE best modder I've seen imo." ~spynathan ლ(́◉◞౪◟◉‵ლ
iguanaman Posted August 26, 2013 Posted August 26, 2013 Don't use the buckets code for reference, it's overcomplicated. Instead, add the method itemInteractionForEntity() in your bucket class, and then do ItemStack.id = filledgoldenbucket.id+256 Sorry to bring back an old thread but this the only thread I could find on the issue and my reply is about this suggested method. This suggestion would cause a stack of empty buckets to be filled with milk. How do we allow only one bucket to be filled, since that method doesn't provide an EntityPlayer? Quote
GotoLink Posted August 26, 2013 Posted August 26, 2013 Use EntityInteractEvent. It contains the player instance and the entity targetted. Do a check for a cow entity, and the bucket stack in the player's hand. Decrease the stack size, and give the player a filled bucket. Quote
Recommended Posts
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.