This commit is contained in:
Jesse Boyd 2019-06-29 01:19:58 +10:00
parent c773a1e278
commit d9906c9026
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
4 changed files with 82 additions and 57 deletions

View File

@ -340,7 +340,7 @@ public class Fawe {
try { try {
String arch = System.getenv("PROCESSOR_ARCHITECTURE"); String arch = System.getenv("PROCESSOR_ARCHITECTURE");
String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432"); String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432");
boolean x86OS = !arch.endsWith("64") && (wow64Arch == null || !wow64Arch.endsWith("64")); boolean x86OS = !(arch.endsWith("64") || wow64Arch != null && wow64Arch.endsWith("64"));
boolean x86JVM = System.getProperty("sun.arch.data.model").equals("32"); boolean x86JVM = System.getProperty("sun.arch.data.model").equals("32");
if (x86OS != x86JVM) { if (x86OS != x86JVM) {
debug("====== UPGRADE TO 64-BIT JAVA ======"); debug("====== UPGRADE TO 64-BIT JAVA ======");

View File

@ -33,6 +33,7 @@ import com.sk89q.worldedit.extension.platform.PlatformManager;
import com.sk89q.worldedit.extension.platform.PlayerProxy; import com.sk89q.worldedit.extension.platform.PlayerProxy;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.ConvexPolyhedralRegion; import com.sk89q.worldedit.regions.ConvexPolyhedralRegion;
import com.sk89q.worldedit.regions.CylinderRegion; import com.sk89q.worldedit.regions.CylinderRegion;
import com.sk89q.worldedit.regions.Polygonal2DRegion; import com.sk89q.worldedit.regions.Polygonal2DRegion;
@ -369,7 +370,7 @@ public abstract class FawePlayer<T> extends Metadatable {
* @return * @return
*/ */
public World getWorld() { public World getWorld() {
return FaweAPI.getWorld(getLocation().world); return getPlayer().getWorld();
} }
public FaweQueue getFaweQueue(boolean autoQueue) { public FaweQueue getFaweQueue(boolean autoQueue) {
@ -681,8 +682,7 @@ public abstract class FawePlayer<T> extends Metadatable {
PlayerProxy proxy = new PlayerProxy(player, permActor, cuiActor, world); PlayerProxy proxy = new PlayerProxy(player, permActor, cuiActor, world);
if (world instanceof VirtualWorld) { if (world instanceof VirtualWorld) {
//todo fix this proxy.setOffset(Vector3.ZERO.subtract(((VirtualWorld) world).getOrigin()));
//proxy.setOffset(Vector3.ZERO.subtract(((VirtualWorld) world).getOrigin()));
} }
return proxy; return proxy;
} }

View File

@ -42,6 +42,7 @@ import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes; import com.sk89q.worldedit.world.gamemode.GameModes;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import java.io.File; import java.io.File;
@ -136,7 +137,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
final BlockVector3 pos = BlockVector3.at(x, y, z); final BlockVector3 pos = BlockVector3.at(x, y, z);
final BlockState id = world.getBlock(pos); final BlockState id = world.getBlock(pos);
if (id.getBlockType().getMaterial().isMovementBlocker()) { if (id.getBlockType().getMaterial().isMovementBlocker()) {
setPosition(Vector3.at(x + 0.5, y + 1, z + 0.5)); setPosition(new Location(world, Vector3.at(x + 0.5, y + + BlockTypeUtil.centralTopLimit(id), z + 0.5)));
return; return;
} }
@ -157,36 +158,47 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
final int z = pos.getBlockZ(); final int z = pos.getBlockZ();
final Extent world = pos.getExtent(); final Extent world = pos.getExtent();
byte free = 0; int maxY = world.getMaxY();
byte spots = 0; if (y >= maxY) return false;
while (y <= world.getMaximumPoint().getY() + 2) { BlockMaterial initialMaterial = world.getBlockType(BlockVector3.at(x, y, z)).getMaterial();
if (!world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
++free;
} else {
free = 0;
}
if (free == 2) { boolean lastState = initialMaterial.isMovementBlocker() && initialMaterial.isFullCube();
++spots;
if (spots == 2) {
final BlockVector3 platform = BlockVector3.at(x, y - 2, z);
final BlockState block = world.getBlock(platform);
final com.sk89q.worldedit.world.block.BlockType type = block.getBlockType();
// Don't get put in lava! double height = 1.85;
if (type == BlockTypes.LAVA) { double freeStart = -1;
return false;
}
setPosition(platform.toVector3().add(0.5, 1, 0.5)); for (int level = y + 1; level <= maxY + 2; level++) {
return true; BlockState state;
if (level >= maxY) state = BlockTypes.VOID_AIR.getDefaultState();
else state = world.getBlock(BlockVector3.at(x, level, z));
BlockType type = state.getBlockType();
BlockMaterial material = type.getMaterial();
if (!material.isFullCube() || !material.isMovementBlocker()) {
if (!lastState) {
lastState = BlockTypeUtil.centralBottomLimit(state) != 1;
continue;
} }
if (freeStart == -1) {
freeStart = level + BlockTypeUtil.centralTopLimit(state);
} else {
double bottomLimit = BlockTypeUtil.centralBottomLimit(state);
double space = level + bottomLimit - freeStart;
if (space >= height) {
setPosition(Vector3.at(x + 0.5, freeStart, z + 0.5));
return true;
}
// Not enough room, reset the free position
if (bottomLimit != 1) {
freeStart = -1;
}
}
} else {
freeStart = -1;
lastState = true;
} }
++y;
} }
return false; return false;
} }
@ -194,44 +206,52 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
public boolean descendLevel() { public boolean descendLevel() {
final Location pos = getBlockIn(); final Location pos = getBlockIn();
final int x = pos.getBlockX(); final int x = pos.getBlockX();
int y = Math.max(0, pos.getBlockY() - 1); int y = Math.max(0, pos.getBlockY());
final int z = pos.getBlockZ(); final int z = pos.getBlockZ();
final Extent world = pos.getExtent(); final Extent world = pos.getExtent();
byte free = 0; BlockMaterial initialMaterial = world.getBlockType(BlockVector3.at(x, y, z)).getMaterial();
while (y >= 1) { boolean lastState = initialMaterial.isMovementBlocker() && initialMaterial.isFullCube();
if (!world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
++free;
} else {
free = 0;
}
if (free == 2) { double height = 1.85;
// So we've found a spot, but we have to drop the player double freeEnd = -1;
// lightly and also check to see if there's something to
// stand upon
while (y >= 0) {
final BlockVector3 platform = BlockVector3.at(x, y, z);
final BlockState block = world.getBlock(platform);
final BlockType type = block.getBlockType();
// Don't want to end up in lava int maxY = world.getMaxY();
if (!type.getMaterial().isAir() && type != BlockTypes.LAVA) { if (y <= 2) return false;
// Found a block!
setPosition(platform.toVector3().add(0.5, 1, 0.5)); for (int level = y + 1; level > 0; level--) {
BlockState state;
if (level >= maxY) state = BlockTypes.VOID_AIR.getDefaultState();
else state = world.getBlock(BlockVector3.at(x, level, z));
BlockType type = state.getBlockType();
BlockMaterial material = type.getMaterial();
if (!material.isFullCube() || !material.isMovementBlocker()) {
if (!lastState) {
lastState = BlockTypeUtil.centralTopLimit(state) != 0;
continue;
}
if (freeEnd == -1) {
freeEnd = level + BlockTypeUtil.centralBottomLimit(state);
} else {
double topLimit = BlockTypeUtil.centralTopLimit(state);
double freeStart = level + topLimit;
double space = freeEnd - freeStart;
if (space >= height) {
setPosition(Vector3.at(x + 0.5, freeStart, z + 0.5));
return true; return true;
} }
// Not enough room, reset the free position
--y; if (topLimit != 0) {
freeEnd = -1;
}
} }
} else {
return false; lastState = true;
freeEnd = -1;
} }
--y;
} }
return false; return false;
} }
@ -373,7 +393,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
if (typeId.hasBlockType()) { if (typeId.hasBlockType()) {
return typeId.getBlockType().getDefaultState().toBaseBlock(); return typeId.getBlockType().getDefaultState().toBaseBlock();
} else { } else {
throw new NotABlockException(); return BlockTypes.AIR.getDefaultState().toBaseBlock();
} }
} }

View File

@ -47,6 +47,7 @@ public class PlayerProxy extends AbstractPlayerActor {
private final Actor permActor; private final Actor permActor;
private final Actor cuiActor; private final Actor cuiActor;
private final World world; private final World world;
private Vector3 offset = Vector3.ZERO;
public PlayerProxy(Player basePlayer, Actor permActor, Actor cuiActor, World world) { public PlayerProxy(Player basePlayer, Actor permActor, Actor cuiActor, World world) {
checkNotNull(basePlayer); checkNotNull(basePlayer);
@ -59,6 +60,9 @@ public class PlayerProxy extends AbstractPlayerActor {
this.world = world; this.world = world;
} }
public void setOffset(Vector3 position) {
this.offset = position;
}
@Override @Override
public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException { public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException {
@ -102,7 +106,8 @@ public class PlayerProxy extends AbstractPlayerActor {
@Override @Override
public Location getLocation() { public Location getLocation() {
return basePlayer.getLocation(); Location loc = this.basePlayer.getLocation();
return new Location(loc.getExtent(), loc.add(offset), loc.getDirection());
} }
@Override @Override