Made /ascend and /descend use centralTopLimit.

This commit is contained in:
TomyLobo 2013-06-24 17:58:57 +02:00
parent 921c354db7
commit 1ec17b5a44

View File

@ -141,11 +141,11 @@ public abstract class LocalPlayer {
* @return true if a spot was found * @return true if a spot was found
*/ */
public boolean ascendLevel() { public boolean ascendLevel() {
Vector pos = getBlockIn(); final WorldVector pos = getBlockIn();
int x = pos.getBlockX(); final int x = pos.getBlockX();
int y = Math.max(0, pos.getBlockY()); int y = Math.max(0, pos.getBlockY());
int z = pos.getBlockZ(); final int z = pos.getBlockZ();
LocalWorld world = getPosition().getWorld(); final LocalWorld world = pos.getWorld();
byte free = 0; byte free = 0;
byte spots = 0; byte spots = 0;
@ -160,14 +160,16 @@ public abstract class LocalPlayer {
if (free == 2) { if (free == 2) {
++spots; ++spots;
if (spots == 2) { if (spots == 2) {
int type = world.getBlockType(new Vector(x, y - 2, z)); final Vector platform = new Vector(x, y - 2, z);
final BaseBlock block = world.getBlock(platform);
final int type = block.getId();
// Don't get put in lava! // Don't get put in lava!
if (type == BlockID.LAVA || type == BlockID.STATIONARY_LAVA) { if (type == BlockID.LAVA || type == BlockID.STATIONARY_LAVA) {
return false; return false;
} }
setPosition(new Vector(x + 0.5, y - 1, z + 0.5)); setPosition(platform.add(0.5, BlockType.centralTopLimit(block), 0.5));
return true; return true;
} }
} }
@ -184,11 +186,11 @@ public abstract class LocalPlayer {
* @return true if a spot was found * @return true if a spot was found
*/ */
public boolean descendLevel() { public boolean descendLevel() {
Vector pos = getBlockIn(); final WorldVector pos = getBlockIn();
int x = pos.getBlockX(); final int x = pos.getBlockX();
int y = Math.max(0, pos.getBlockY() - 1); int y = Math.max(0, pos.getBlockY() - 1);
int z = pos.getBlockZ(); final int z = pos.getBlockZ();
LocalWorld world = getPosition().getWorld(); final LocalWorld world = pos.getWorld();
byte free = 0; byte free = 0;
@ -204,12 +206,14 @@ public abstract class LocalPlayer {
// lightly and also check to see if there's something to // lightly and also check to see if there's something to
// stand upon // stand upon
while (y >= 0) { while (y >= 0) {
int type = world.getBlockType(new Vector(x, y, z)); final Vector platform = new Vector(x, y, z);
final BaseBlock block = world.getBlock(platform);
final int type = block.getId();
// Don't want to end up in lava // Don't want to end up in lava
if (type != BlockID.AIR && type != BlockID.LAVA && type != BlockID.STATIONARY_LAVA) { if (type != BlockID.AIR && type != BlockID.LAVA && type != BlockID.STATIONARY_LAVA) {
// Found a block! // Found a block!
setPosition(new Vector(x + 0.5, y + 1, z + 0.5)); setPosition(platform.add(0.5, BlockType.centralTopLimit(block), 0.5));
return true; return true;
} }