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

Hey, i have a region type system, and i want to check whenever a player enters that region/area, and teleport him back(Basically not give him access to that area.), now i could just check with getEntitiesWithinAABB every tick but that sounds heavy on the tps and just pretty stupid, i wandered if there's some kind of event or better way to do that? thanks.

One alternative would be subscribing to PlayerTickEvent and checking if the player is in the region before teleporting them back. This probably has fairly minimal overhead, but you should profile it to check.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

  • Author
3 minutes ago, Choonster said:

One alternative would be subscribing to PlayerTickEvent and checking if the player is in the region before teleporting them back. This probably has fairly minimal overhead, but you should profile it to check.

well yea, that's just using a tick handler that's what i thought will probably lag the server.

26 minutes ago, DrPiggy said:

well yea, that's just using a tick handler that's what i thought will probably lag the server.

 

I don't think there's any other way than checking every tick, but doing it per-player may be less expensive than using World#getEntitiesWithinAABB.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

  • Author
2 hours ago, Choonster said:

 

I don't think there's any other way than checking every tick, but doing it per-player may be less expensive than using World#getEntitiesWithinAABB.

how would i check if hes inside an area if i only have the the xyz1 and xyz2 of the area? (Besides using getEntitiesWithinAABB)

3 minutes ago, DrPiggy said:

i only have the the xyz1 and xyz2 of the area

2
 

You can use these coordinates to determine the smaller and bigger coordinate of each axis, and check if the player's position is the coordinates.

Edited by larsgerrits

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

  • Author
Just now, diesieben07 said:

Check if the players xyz is greater than xyz1 and smaller than xyz2.

 

Just now, larsgerrits said:

You can use these coordinates to determine the smaller and bigger coordinate of each axis, and check if the player's position is the corodinates.

thanks :D

3 minutes ago, DrPiggy said:

how would i check if hes inside an area if i only have the the xyz1 and xyz2 of the area? (Besides using getEntitiesWithinAABB)

 

Just now, diesieben07 said:

Check if the players xyz is greater than xyz1 and smaller than xyz2.

 

You can get an entity's bounding box with Entity#getEntityBoundingBox and then use AxisAlignedBB#intersects(double, double, double, double, double, double) to check if it intersects with the region's coordinates. This is essentially what World#getEntitiesWithinAABB does for every entity in the chunks covered by the AABB.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

  • Author
Just now, Choonster said:

 

 

You can get an entity's bounding box with Entity#getEntityBoundingBox and then use AxisAlignedBB#intersects(double, double, double, double, double, double) to check if it intersects with the region's coordinates. This is essentially what World#getEntitiesWithinAABB does for every entity in the chunks covered by the AABB.

Welp, thanks! thats easier then this :P

if (event.player.posX >= area.getLocA()[0] && event.player.posY >= area.getLocA()[1]
					&& event.player.posZ >= area.getLocA()[2] && event.player.posX <= area.getLocB()[0]
					&& event.player.posY <= area.getLocB()[1] && event.player.posZ <= area.getLocB()[2]) {

 

  • Author

If i have a different question, which is related to this, should i ask it here, or open a new thread with the fitting title to help other people that may search for it someday?

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.