Sponge: Max bound of ArchetypeVolume always throws PositionOutOfBoundsException

Created on 4 Feb 2020  路  4Comments  路  Source: SpongePowered/Sponge

I am currently running

  • SpongeForge version: 1.12.2-2838-7.1.8
  • Java version: 1.8.0_101
  • Operating System: Ubuntu 16.04
  • Plugins/Mods: None

Issue Description
When creating a Schematic, we need a world.createArchetypeVolume(min, max, origin). The issue is that this method on DefaultedExtend calls volume.getIntersectingEntities with max added by one (here), which checks the bounds and always throws the PositionOutOfBoundsException. So, no matter which max position we use, we'll always end up with this error.

accepted world bug

Most helpful comment

Okay, it's an off by one error and is an easy fix. I will sort it out tonight (UK time).

To explain, I introduced this change in this commit. There seems to be some confusion across the codebase as to whether something is in real space co-ordinates, or block co-ordinates. When writing the implementation, it's clear that someone assumed that AABBs were block space co-ordinates, when actually, AABBs work in real-space. So, the adding by one is correct in that method (as explained by the comment above it!), as I was converting a block co-ordinate to two corners in real space co-ordinates.

That check method that throws that error assumes block space co-ordinates - which for that scenario is wrong. There needs to be an equivalent for real-space.

Why has this occurred? Turns out that this error will only occur when entities exist within the AABB in question. I suspect all my testing was done without entities in the AABB!

@Hiroku I know you were having this issue too - figured you'd like to be pinged to know why!

All 4 comments

Stack trace? Don't really want to play guessing games with _where_ it's occurring.

I suspect it's a problem with confusiung block co-ordinates and real space co-ordinates, not directly what you said. That said, I did test that change extensively when I implemented it, so I'm curious to see what was missed.

Oh, forgot to include it in the ticket: https://pastebin.com/XUtN0vtf

Okay, it's an off by one error and is an easy fix. I will sort it out tonight (UK time).

To explain, I introduced this change in this commit. There seems to be some confusion across the codebase as to whether something is in real space co-ordinates, or block co-ordinates. When writing the implementation, it's clear that someone assumed that AABBs were block space co-ordinates, when actually, AABBs work in real-space. So, the adding by one is correct in that method (as explained by the comment above it!), as I was converting a block co-ordinate to two corners in real space co-ordinates.

That check method that throws that error assumes block space co-ordinates - which for that scenario is wrong. There needs to be an equivalent for real-space.

Why has this occurred? Turns out that this error will only occur when entities exist within the AABB in question. I suspect all my testing was done without entities in the AABB!

@Hiroku I know you were having this issue too - figured you'd like to be pinged to know why!

Thansk for clarifying! 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

XakepSDK picture XakepSDK  路  3Comments

randombyte-developer picture randombyte-developer  路  5Comments

DarkArc picture DarkArc  路  3Comments

jeffreykog picture jeffreykog  路  4Comments

XakepSDK picture XakepSDK  路  5Comments