Posted February 18, 20178 yr 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.
February 18, 20178 yr 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.
February 18, 20178 yr 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.
February 18, 20178 yr 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.
February 18, 20178 yr 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)
February 18, 20178 yr 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 February 18, 20178 yr 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/
February 18, 20178 yr 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
February 18, 20178 yr 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.
February 18, 20178 yr 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 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]) {
February 18, 20178 yr 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.