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 having an issues finding documentation or assistance in working with item frames. I write this post after three days of not finding so much as one page or discussion on even the basics of item frames. A search on these forums returns only crashlogs in an almost unreadable search response. Here is my situation and question:

 

In my current project, upon a player walking on a custom block, which I will call the 'key' block, I check the blocks near this key block to determine if the player has built a structure to proper arrangement - a properly built multi-block structure. If the structure is not properly built, then following methods (teleportation in this case) will not occur. Determining a block type by location is simple and well documented, and I have had no issues checking for a proper build of blocks.

 

if (world.getBlock(x + 0, y + 2, z + 1) == Blocks.quartz_block)

 

...where x,y,z is the key block location, triggered by the onEntityWalking event in the custom key block.

 

However, I would like one of the required units to be an item frame, but how do I check for an item frame relative to the key block? I've tried several get properties and conversions, but to no avail. I believe I need to find an EntityItemFrame, but there has to be a simple answer. The 'block' returns as air, for example. Also I want to determine if the contents of the item frame match a certain criteria, and I imagine I will have that question as well when I get there. :)

 

Any help would be appreciated.

 

 

I'll need help, and I'll give help. Just ask, you know I will!

  • Author

Right, the entity part I had found, but not that method. I haven't worked with AABB yet, but I'm sure I can power through it. Thanks! I'll post my exact findings if it helps any further modders.

I'll need help, and I'll give help. Just ask, you know I will!

  • 2 weeks later...
  • Author

Sorry for just now getting around to posting the solution, but here goes:

 

List l = world.getEntitiesWithinAABB(EntityItemFrame.class, AxisAlignedBB.getBoundingBox((double) x - 1.0d,(double) y + 2.0d,(double) z + 1.0d,(double) x,(double) y + 3.0d,(double) z + 2.0d));

if (l.size() > 0) {
// found an item frame!
EntityItemFrame f = (EntityItemFrame) l.get(0);
ItemStack istack = f.getDisplayedItem();
if (istack != null	&& istack.stackSize > 0) {
	// found item in frame
        }

 

For anyone else happening upon this, this is how you find item frames and the items within them relative to another block location! Thanks!

I'll need help, and I'll give help. Just ask, you know I will!

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.