mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
This commit is contained in:
parent
c773a1e278
commit
d9906c9026
@ -340,7 +340,7 @@ public class Fawe {
|
||||
try {
|
||||
String arch = System.getenv("PROCESSOR_ARCHITECTURE");
|
||||
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");
|
||||
if (x86OS != x86JVM) {
|
||||
debug("====== UPGRADE TO 64-BIT JAVA ======");
|
||||
|
@ -33,6 +33,7 @@ import com.sk89q.worldedit.extension.platform.PlatformManager;
|
||||
import com.sk89q.worldedit.extension.platform.PlayerProxy;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.ConvexPolyhedralRegion;
|
||||
import com.sk89q.worldedit.regions.CylinderRegion;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
@ -369,7 +370,7 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
* @return
|
||||
*/
|
||||
public World getWorld() {
|
||||
return FaweAPI.getWorld(getLocation().world);
|
||||
return getPlayer().getWorld();
|
||||
}
|
||||
|
||||
public FaweQueue getFaweQueue(boolean autoQueue) {
|
||||
@ -681,8 +682,7 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
|
||||
PlayerProxy proxy = new PlayerProxy(player, permActor, cuiActor, world);
|
||||
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;
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
|
||||
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 BlockState id = world.getBlock(pos);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -157,36 +158,47 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
final int z = pos.getBlockZ();
|
||||
final Extent world = pos.getExtent();
|
||||
|
||||
byte free = 0;
|
||||
byte spots = 0;
|
||||
int maxY = world.getMaxY();
|
||||
if (y >= maxY) return false;
|
||||
|
||||
while (y <= world.getMaximumPoint().getY() + 2) {
|
||||
if (!world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
++free;
|
||||
} else {
|
||||
free = 0;
|
||||
}
|
||||
BlockMaterial initialMaterial = world.getBlockType(BlockVector3.at(x, y, z)).getMaterial();
|
||||
|
||||
if (free == 2) {
|
||||
++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();
|
||||
boolean lastState = initialMaterial.isMovementBlocker() && initialMaterial.isFullCube();
|
||||
|
||||
// Don't get put in lava!
|
||||
if (type == BlockTypes.LAVA) {
|
||||
return false;
|
||||
}
|
||||
double height = 1.85;
|
||||
double freeStart = -1;
|
||||
|
||||
setPosition(platform.toVector3().add(0.5, 1, 0.5));
|
||||
return true;
|
||||
for (int level = y + 1; level <= maxY + 2; 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.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;
|
||||
}
|
||||
|
||||
@ -194,44 +206,52 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
public boolean descendLevel() {
|
||||
final Location pos = getBlockIn();
|
||||
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 Extent world = pos.getExtent();
|
||||
|
||||
byte free = 0;
|
||||
BlockMaterial initialMaterial = world.getBlockType(BlockVector3.at(x, y, z)).getMaterial();
|
||||
|
||||
while (y >= 1) {
|
||||
if (!world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
++free;
|
||||
} else {
|
||||
free = 0;
|
||||
}
|
||||
boolean lastState = initialMaterial.isMovementBlocker() && initialMaterial.isFullCube();
|
||||
|
||||
if (free == 2) {
|
||||
// So we've found a spot, but we have to drop the player
|
||||
// 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();
|
||||
double height = 1.85;
|
||||
double freeEnd = -1;
|
||||
|
||||
// Don't want to end up in lava
|
||||
if (!type.getMaterial().isAir() && type != BlockTypes.LAVA) {
|
||||
// Found a block!
|
||||
setPosition(platform.toVector3().add(0.5, 1, 0.5));
|
||||
int maxY = world.getMaxY();
|
||||
if (y <= 2) return false;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
--y;
|
||||
// Not enough room, reset the free position
|
||||
if (topLimit != 0) {
|
||||
freeEnd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} else {
|
||||
lastState = true;
|
||||
freeEnd = -1;
|
||||
}
|
||||
|
||||
--y;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -373,7 +393,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
if (typeId.hasBlockType()) {
|
||||
return typeId.getBlockType().getDefaultState().toBaseBlock();
|
||||
} else {
|
||||
throw new NotABlockException();
|
||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@ public class PlayerProxy extends AbstractPlayerActor {
|
||||
private final Actor permActor;
|
||||
private final Actor cuiActor;
|
||||
private final World world;
|
||||
private Vector3 offset = Vector3.ZERO;
|
||||
|
||||
public PlayerProxy(Player basePlayer, Actor permActor, Actor cuiActor, World world) {
|
||||
checkNotNull(basePlayer);
|
||||
@ -59,6 +60,9 @@ public class PlayerProxy extends AbstractPlayerActor {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public void setOffset(Vector3 position) {
|
||||
this.offset = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException {
|
||||
@ -102,7 +106,8 @@ public class PlayerProxy extends AbstractPlayerActor {
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return basePlayer.getLocation();
|
||||
Location loc = this.basePlayer.getLocation();
|
||||
return new Location(loc.getExtent(), loc.add(offset), loc.getDirection());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user