mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
Refactor vector system to be cleaner
- Move Vector, etc. into `.math` package - Drop many methods that will be auto-promoted anyways, eg. with `divide(int)` and `divide(double)` the first is now gone. - Take Block vectors into their own class hierarchy - Make it clear throughout the API what takes blockvectors - many more improvements
This commit is contained in:
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.extension.factory;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.NotABlockException;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
@ -37,6 +36,7 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
@ -245,7 +245,7 @@ class DefaultBlockParser extends InputParser<BlockStateHolder> {
|
||||
} else if ("pos1".equalsIgnoreCase(typeString)) {
|
||||
// Get the block type from the "primary position"
|
||||
final World world = context.requireWorld();
|
||||
final BlockVector primaryPosition;
|
||||
final BlockVector3 primaryPosition;
|
||||
try {
|
||||
primaryPosition = context.requireSession().getRegionSelector(world).getPrimaryPosition();
|
||||
} catch (IncompleteRegionException e) {
|
||||
|
@ -20,7 +20,6 @@
|
||||
package com.sk89q.worldedit.extension.factory;
|
||||
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.NoMatchException;
|
||||
@ -42,6 +41,8 @@ import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.noise.RandomNoise;
|
||||
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||
import com.sk89q.worldedit.session.request.Request;
|
||||
@ -134,7 +135,7 @@ class DefaultMaskParser extends InputParser<Mask> {
|
||||
} else {
|
||||
submask = new ExistingBlockMask(extent);
|
||||
}
|
||||
OffsetMask offsetMask = new OffsetMask(submask, new Vector(0, firstChar == '>' ? -1 : 1, 0));
|
||||
OffsetMask offsetMask = new OffsetMask(submask, new BlockVector3(0, firstChar == '>' ? -1 : 1, 0));
|
||||
return new MaskIntersection(offsetMask, Masks.negate(submask));
|
||||
|
||||
case '$':
|
||||
@ -161,7 +162,7 @@ class DefaultMaskParser extends InputParser<Mask> {
|
||||
try {
|
||||
Expression exp = Expression.compile(component.substring(1), "x", "y", "z");
|
||||
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(
|
||||
Request.request().getEditSession(), Vector.ONE, Vector.ZERO);
|
||||
Request.request().getEditSession(), Vector3.ONE, Vector3.ZERO);
|
||||
exp.setEnvironment(env);
|
||||
return new ExpressionMask(exp);
|
||||
} catch (ExpressionException e) {
|
||||
|
@ -21,16 +21,17 @@ package com.sk89q.worldedit.extension.platform;
|
||||
|
||||
import com.sk89q.worldedit.NotABlockException;
|
||||
import com.sk89q.worldedit.PlayerDirection;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.TargetBlock;
|
||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
@ -105,7 +106,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
byte free = 0;
|
||||
|
||||
while (y <= world.getMaximumPoint().getBlockY() + 2) {
|
||||
if (!world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
if (!world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
++free;
|
||||
} else {
|
||||
free = 0;
|
||||
@ -113,7 +114,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
|
||||
if (free == 2) {
|
||||
if (y - 1 != origY) {
|
||||
setPosition(new Vector(x + 0.5, y - 2 + 1, z + 0.5));
|
||||
setPosition(new Vector3(x + 0.5, y - 2 + 1, z + 0.5));
|
||||
}
|
||||
|
||||
return;
|
||||
@ -131,10 +132,10 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
int z = searchPos.getBlockZ();
|
||||
|
||||
while (y >= 0) {
|
||||
final Vector pos = new Vector(x, y, z);
|
||||
final BlockVector3 pos = new BlockVector3(x, y, z);
|
||||
final BlockState id = world.getBlock(pos);
|
||||
if (id.getBlockType().getMaterial().isMovementBlocker()) {
|
||||
setPosition(new Vector(x + 0.5, y + 1, z + 0.5));
|
||||
setPosition(new Vector3(x + 0.5, y + 1, z + 0.5));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -159,7 +160,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
byte spots = 0;
|
||||
|
||||
while (y <= world.getMaximumPoint().getY() + 2) {
|
||||
if (!world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
if (!world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
++free;
|
||||
} else {
|
||||
free = 0;
|
||||
@ -168,7 +169,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
if (free == 2) {
|
||||
++spots;
|
||||
if (spots == 2) {
|
||||
final Vector platform = new Vector(x, y - 2, z);
|
||||
final BlockVector3 platform = new BlockVector3(x, y - 2, z);
|
||||
final BlockStateHolder block = world.getBlock(platform);
|
||||
final com.sk89q.worldedit.world.block.BlockType type = block.getBlockType();
|
||||
|
||||
@ -177,7 +178,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
return false;
|
||||
}
|
||||
|
||||
setPosition(platform.add(0.5, 1, 0.5));
|
||||
setPosition(platform.toVector3().add(0.5, 1, 0.5));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -199,7 +200,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
byte free = 0;
|
||||
|
||||
while (y >= 1) {
|
||||
if (!world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
if (!world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
++free;
|
||||
} else {
|
||||
free = 0;
|
||||
@ -210,14 +211,14 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
// lightly and also check to see if there's something to
|
||||
// stand upon
|
||||
while (y >= 0) {
|
||||
final Vector platform = new Vector(x, y, z);
|
||||
final BlockVector3 platform = new BlockVector3(x, y, z);
|
||||
final BlockStateHolder block = world.getBlock(platform);
|
||||
final BlockType type = block.getBlockType();
|
||||
|
||||
// Don't want to end up in lava
|
||||
if (!type.getMaterial().isAir() && type != BlockTypes.LAVA) {
|
||||
// Found a block!
|
||||
setPosition(platform.add(0.5, 1, 0.5));
|
||||
setPosition(platform.toVector3().add(0.5, 1, 0.5));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -248,13 +249,13 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
Extent world = getLocation().getExtent();
|
||||
|
||||
// No free space above
|
||||
if (!world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isAir()) {
|
||||
if (!world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isAir()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (y <= world.getMaximumPoint().getY()) {
|
||||
// Found a ceiling!
|
||||
if (world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
if (world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
int platformY = Math.max(initialY, y - 3 - clearance);
|
||||
floatAt(x, platformY + 1, z, alwaysGlass);
|
||||
return true;
|
||||
@ -282,7 +283,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
final Extent world = getLocation().getExtent();
|
||||
|
||||
while (y <= world.getMaximumPoint().getY() + 2) {
|
||||
if (world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
if (world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
break; // Hit something
|
||||
} else if (y > maxY + 1) {
|
||||
break;
|
||||
@ -300,24 +301,24 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
@Override
|
||||
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
|
||||
try {
|
||||
Vector spot = new Vector(x, y - 1, z);
|
||||
BlockVector3 spot = new BlockVector3(x, y - 1, z);
|
||||
if (!getLocation().getExtent().getBlock(spot).getBlockType().getMaterial().isMovementBlocker()) {
|
||||
getLocation().getExtent().setBlock(spot, BlockTypes.GLASS.getDefaultState());
|
||||
}
|
||||
} catch (WorldEditException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setPosition(new Vector(x + 0.5, y, z + 0.5));
|
||||
setPosition(new Vector3(x + 0.5, y, z + 0.5));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getBlockIn() {
|
||||
return getLocation().setPosition(getLocation().toVector().toBlockVector());
|
||||
return getLocation().setPosition(getLocation().toVector().floor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getBlockOn() {
|
||||
return getLocation().setPosition(getLocation().setY(getLocation().getY() - 1).toVector().toBlockVector());
|
||||
return getLocation().setPosition(getLocation().setY(getLocation().getY() - 1).toVector().floor());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -392,7 +393,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
boolean inFree = false;
|
||||
|
||||
while ((block = hitBlox.getNextBlock()) != null) {
|
||||
boolean free = !world.getBlock(block.toVector()).getBlockType().getMaterial().isMovementBlocker();
|
||||
boolean free = !world.getBlock(block.toVector().toBlockPoint()).getBlockType().getMaterial().isMovementBlocker();
|
||||
|
||||
if (firstBlock) {
|
||||
firstBlock = false;
|
||||
@ -426,7 +427,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector pos) {
|
||||
public void setPosition(Vector3 pos) {
|
||||
setPosition(pos, getLocation().getPitch(), getLocation().getYaw());
|
||||
}
|
||||
|
||||
@ -499,7 +500,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendFakeBlock(Vector pos, BlockStateHolder block) {
|
||||
public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.tool.BlockTool;
|
||||
import com.sk89q.worldedit.command.tool.DoubleActionBlockTool;
|
||||
@ -38,6 +37,8 @@ import com.sk89q.worldedit.event.platform.PlatformInitializeEvent;
|
||||
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
||||
import com.sk89q.worldedit.event.platform.PlayerInputEvent;
|
||||
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
@ -302,7 +303,7 @@ public class PlatformManager {
|
||||
Actor actor = createProxyActor(event.getCause());
|
||||
|
||||
Location location = event.getLocation();
|
||||
Vector vector = location.toVector();
|
||||
Vector3 vector = location.toVector();
|
||||
|
||||
// At this time, only handle interaction from players
|
||||
if (actor instanceof Player) {
|
||||
@ -321,8 +322,9 @@ public class PlatformManager {
|
||||
|
||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||
|
||||
if (selector.selectPrimary(location.toVector(), ActorSelectorLimits.forActor(player))) {
|
||||
selector.explainPrimarySelection(actor, session, vector);
|
||||
BlockVector3 blockPoint = vector.toBlockPoint();
|
||||
if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
||||
selector.explainPrimarySelection(actor, session, blockPoint);
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
@ -356,8 +358,9 @@ public class PlatformManager {
|
||||
}
|
||||
|
||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||
if (selector.selectSecondary(vector, ActorSelectorLimits.forActor(player))) {
|
||||
selector.explainSecondarySelection(actor, session, vector);
|
||||
BlockVector3 blockPoint = vector.toBlockPoint();
|
||||
if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
||||
selector.explainSecondarySelection(actor, session, blockPoint);
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
@ -21,12 +21,13 @@ package com.sk89q.worldedit.extension.platform;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.session.SessionKey;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
@ -92,7 +93,7 @@ class PlayerProxy extends AbstractPlayerActor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector pos, float pitch, float yaw) {
|
||||
public void setPosition(Vector3 pos, float pitch, float yaw) {
|
||||
basePlayer.setPosition(pos, pitch, yaw);
|
||||
}
|
||||
|
||||
@ -158,7 +159,7 @@ class PlayerProxy extends AbstractPlayerActor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendFakeBlock(Vector pos, BlockStateHolder block) {
|
||||
public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) {
|
||||
basePlayer.sendFakeBlock(pos, block);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user