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.

Funlerz

Members
  • Joined

  • Last visited

  1. I have created a block with a TileEntity and when the player right clicks on it with a empty bucket it adds a bucket of milk to their inventory. I have it all working except for some reason when the milk bucket is added to the player's inventory it is invisible until the player interacts with one of the invisible milk buckets. public void giveMilk(EntityPlayer playerIn) { if (milkBucketCount > 0) { if (ItemStack.areItemsEqual(playerIn.inventory.getCurrentItem(), new ItemStack(Items.bucket))) { this.fillBucket(playerIn); } } } private void fillBucket(EntityPlayer playerIn) { ItemStack emptyBuckets = playerIn.inventory.getCurrentItem(); int currentSlot = playerIn.inventory.currentItem; if (playerIn.capabilities.isCreativeMode) { return; } else if (emptyBuckets.stackSize <= 1) { playerIn.inventory.setInventorySlotContents(currentSlot, new ItemStack(Items.milk_bucket)); milkBucketCount--; } else { if (!playerIn.inventory.addItemStackToInventory(new ItemStack(Items.milk_bucket))) { playerIn.dropPlayerItemWithRandomChoice(new ItemStack(Items.milk_bucket, 1, 0), false); } playerIn.inventory.setInventorySlotContents(currentSlot, new ItemStack(Items.bucket, --emptyBuckets.stackSize)); milkBucketCount--; } } Those two functions are in my TileEntity. The giveMilk() function is called when the block is right clicked on by a player. If the player is only holding one bucket the empty bucket gets replaced with a full milk bucket that is visible, so that works fine while for some reason if the player is holding a stack of empty buckets they get the item but as I said it is invisible. I did some googling and the only results I found were that it was because of a server/client discrepancy, but I have tried checking to see if (!this.worldObj.isRemote) in various places but it had no effect, and if I tried checking for if (this.worldObj.isRemote) then it just never executed whatever was inside that if statement. I am really stuck on this, I have everything working how I want except that the items are invisible! Any help?

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.