Permalink
Browse files

Added a way to get the spawn position of a world

  • Loading branch information...
me4502 committed Dec 21, 2018
1 parent c949b07 commit ea3057878141548b44c6dd269d33b019b7bc1c99
@@ -404,6 +404,11 @@ public void setWeather(WeatherType weatherType, long duration) {
}
}

@Override
public BlockVector3 getSpawnPosition() {
return BukkitAdapter.asBlockVector(getWorld().getSpawnLocation());
}

@Override
public void simulateBlockMine(BlockVector3 pt) {
getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).breakNaturally();
@@ -125,6 +125,11 @@ public void setWeather(WeatherType weatherType) {
public void setWeather(WeatherType weatherType, long duration) {
}

@Override
public BlockVector3 getSpawnPosition() {
return BlockVector3.ZERO;
}

@Override
public BlockState getBlock(BlockVector3 position) {
return BlockTypes.AIR.getDefaultState();
@@ -246,6 +246,13 @@
*/
void setWeather(WeatherType weatherType, long duration);

/**
* Gets the spawn position of this world.
*
* @return The spawn position
*/
BlockVector3 getSpawnPosition();

@Override
boolean equals(Object other);

@@ -54,8 +54,8 @@ public static Vector3 adapt(Vec3d vector) {
return Vector3.at(vector.x, vector.y, vector.z);
}

public static Vector3 adapt(BlockPos pos) {
return Vector3.at(pos.getX(), pos.getY(), pos.getZ());
public static BlockVector3 adapt(BlockPos pos) {
return BlockVector3.at(pos.getX(), pos.getY(), pos.getZ());
}

public static Vec3d toVec3(BlockVector3 vector) {
@@ -467,6 +467,11 @@ public void setWeather(WeatherType weatherType, long duration) {
}
}

@Override
public BlockVector3 getSpawnPosition() {
return ForgeAdapter.adapt(getWorld().getSpawnPoint());
}

@Override
public BlockState getBlock(BlockVector3 position) {
World world = getWorld();
@@ -320,6 +320,11 @@ public void setWeather(WeatherType weatherType, long duration) {
getWorld().setWeather(Sponge.getRegistry().getType(Weather.class, weatherType.getId()).get(), duration);
}

@Override
public BlockVector3 getSpawnPosition() {
return SpongeAdapter.asBlockVector(getWorld().getSpawnLocation());
}

/**
* Thrown when the reference to the world is lost.
*/

0 comments on commit ea30578

Please sign in to comment.