diff --git a/src/main/java/com/sk89q/worldedit/LocalPlayer.java b/src/main/java/com/sk89q/worldedit/LocalPlayer.java index 99a102f99..c673fa99d 100644 --- a/src/main/java/com/sk89q/worldedit/LocalPlayer.java +++ b/src/main/java/com/sk89q/worldedit/LocalPlayer.java @@ -252,8 +252,7 @@ public abstract class LocalPlayer { // Found a ceiling! if (!BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) { int platformY = Math.max(initialY, y - 3 - clearance); - world.setBlockType(new Vector(x, platformY, z), BlockID.GLASS); - setPosition(new Vector(x + 0.5, platformY + 1, z + 0.5)); + floatAt(x, platformY + 1, z); return true; } @@ -284,8 +283,7 @@ public abstract class LocalPlayer { } else if (y > maxY + 1) { break; } else if (y == maxY + 1) { - world.setBlockType(new Vector(x, y - 2, z), BlockID.GLASS); - setPosition(new Vector(x + 0.5, y - 1, z + 0.5)); + floatAt(x, y - 1, z); return true; } @@ -295,6 +293,18 @@ public abstract class LocalPlayer { return false; } + /** + * Make the player float in the given blocks. + * + * @param x The X coordinate of the block to float in + * @param y The Y coordinate of the block to float in + * @param z The Z coordinate of the block to float in + */ + private void floatAt(int x, int y, int z) { + getPosition().getWorld().setBlockType(new Vector(x, y - 1, z), BlockID.GLASS); + setPosition(new Vector(x + 0.5, y, z + 0.5)); + } + /** * Get the point of the block that is being stood in. *