I have attempted to fix this error in several ways.
First: If the checks for a valid spawn position in the Y column fail, the x and z positions will be incremented to check for valid spawn locations at other positions.
Second: If no valid position could be found after incrementing the x and z positions, a spawn location will attempt to be forcibly created.
I am putting this forward for feedback. At the time of writing this PR, I have realized that the createSpawnPosition method could be simplified to create a spawn position directly at the provided coordinates, if we do not care that the spawn position will be created in the air. Originally, I had been searching for solid ground below the player's feet.
I do need some feedback on the createSpawnPosition call, as if all checks fail in the method, we will be stuck in a loop. Simply creating the spawn position in the air could resolve this, as we will guarantee that a spawn position could be created.
Additionally while writing this, I noticed that I am passing in the incorrect block coordinates to the createSpawnPosition method. Passing basePos means that the incrementing that I do when trying to force the spawn will be useless. Edit: However, passing in pos will mean that the player will spawn at the lowest possible point in the world, as that is where the checking begins.
Basically, I could use some feedback on this.
Edit: If we do force the spawn, the createSpawnPosition method could be simplified to just create a box around the player, instead of just attempting to remove fluids around the player. This could even be done if we don't simplify to forcing a spawn at the provided coordinates.
Edit 2: After some review, I have refactored this for readability, as well as removing the possibility of forcing a spawn location, instead just increasing the searched area until a suitable spot is found. I have also removed the possibility of the infinite while loop.
Previously, players were spawning at Y = 0 if the checks for the Y position in this method, https://github.com/JackyyTV/DimensionalEdibles/blob/dev-1.12.2/src/main/java/jackyy/dimensionaledibles/util/TeleporterHandler.java#L137 both failed. Both while loops failing would leave the Y pos as Y = 0.
I have attempted to fix this error in several ways. First: If the checks for a valid spawn position in the Y column fail, the x and z positions will be incremented to check for valid spawn locations at other positions. Second: If no valid position could be found after incrementing the x and z positions, a spawn location will attempt to be forcibly created.
I am putting this forward for feedback. At the time of writing this PR, I have realized that the createSpawnPosition method could be simplified to create a spawn position directly at the provided coordinates, if we do not care that the spawn position will be created in the air. Originally, I had been searching for solid ground below the player's feet.
I do need some feedback on the createSpawnPosition call, as if all checks fail in the method, we will be stuck in a loop. Simply creating the spawn position in the air could resolve this, as we will guarantee that a spawn position could be created.
Additionally while writing this, I noticed that I am passing in the incorrect block coordinates to the createSpawnPosition method. Passing basePos means that the incrementing that I do when trying to force the spawn will be useless. Edit: However, passing in
pos
will mean that the player will spawn at the lowest possible point in the world, as that is where the checking begins.Basically, I could use some feedback on this.
Edit: If we do force the spawn, the createSpawnPosition method could be simplified to just create a box around the player, instead of just attempting to remove fluids around the player. This could even be done if we don't simplify to forcing a spawn at the provided coordinates.
Edit 2: After some review, I have refactored this for readability, as well as removing the possibility of forcing a spawn location, instead just increasing the searched area until a suitable spot is found. I have also removed the possibility of the infinite while loop.