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

I am creating a new block which can contain some items,

and, now, if the block is destroyed, only the block is dropped.

I want to make it possible to drop not only the block but also items in it.

I read the code of HopperTileEntity and I think extending LocableLootTileIntity is a key,

but I cannot understand which methods are important.
 

Would you tell me how to change a loot table dynamically?

 

Edited by serena41605866

I think your block needs to mimic the HopperBlock's onReplaced method. The loot information in the hopper's tile entity is for items that can have loot tables associated with them which is not what you're asking for (you just want to drop current inventory sounds like). Also check out the ChestBlock or BarrelBlock code.

Yes, you should override your block's onReplaced() method and drop any contained items there.  Note that dropping the contents of a tile entity's inventory is a different operation from dropping the tile entity's own block (which should be done by a loot table in 1.14).

 

Please don't make your tile entity a subclass of LockableLootTileEntity, which uses the vanilla IInventory system.  Instead use Forge capabilities, and store your items in an IItemHandler implementation (most likely ItemStackHandler or a subclass of that).  If you insist on using vanilla IInventory, don't be surprised when people complain that your block's inventory is not accessible by any other mods...

Edited by desht

  • Author

The_Wabbit, desht:

Thank you for your quick and brief replies.

I have read onReplaced method of ChestBlock and understood how to implement.

 

:D:P:D

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.