Jump to content

[Solved]Simple help with Item Frames


strumshot

Recommended Posts

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!

Link to comment
Share on other sites

  • 2 weeks later...

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!

Link to comment
Share on other sites

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.