mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46: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,7 @@
|
||||
|
||||
package com.sk89q.worldedit.internal.annotation;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@ -27,7 +27,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Annotates a {@link Vector} parameter to inject a direction.
|
||||
* Annotates a {@link Vector3} parameter to inject a direction.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.PARAMETER)
|
||||
|
@ -26,10 +26,10 @@ import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.util.command.parametric.AbstractInvokeListener;
|
||||
import com.sk89q.worldedit.util.command.parametric.InvokeHandler;
|
||||
import com.sk89q.worldedit.util.command.parametric.ParameterData;
|
||||
@ -102,13 +102,13 @@ public class CommandLoggingHandler extends AbstractInvokeListener implements Inv
|
||||
}
|
||||
|
||||
if (logMode != null && sender.isPlayer()) {
|
||||
Vector position = player.getLocation().toVector();
|
||||
Vector3 position = player.getLocation().toVector();
|
||||
LocalSession session = worldEdit.getSessionManager().get(player);
|
||||
|
||||
switch (logMode) {
|
||||
case PLACEMENT:
|
||||
try {
|
||||
position = session.getPlacementPosition(player);
|
||||
position = session.getPlacementPosition(player).toVector3();
|
||||
} catch (IncompleteRegionException e) {
|
||||
break;
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.UnknownDirectionException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.input.NoMatchException;
|
||||
@ -38,6 +36,7 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||
@ -49,6 +48,7 @@ import com.sk89q.worldedit.util.command.parametric.ParameterException;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.Biomes;
|
||||
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.registry.BiomeRegistry;
|
||||
@ -258,10 +258,10 @@ public class WorldEditBinding extends BindingHelper {
|
||||
* @throws UnknownDirectionException on an unknown direction
|
||||
*/
|
||||
@BindingMatch(classifier = Direction.class,
|
||||
type = Vector.class,
|
||||
type = BlockVector3.class,
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1)
|
||||
public Vector getDirection(ArgumentStack context, Direction direction)
|
||||
public BlockVector3 getDirection(ArgumentStack context, Direction direction)
|
||||
throws ParameterException, UnknownDirectionException {
|
||||
Player sender = getPlayer(context);
|
||||
return worldEdit.getDirection(sender, context.next());
|
||||
|
@ -21,15 +21,15 @@
|
||||
|
||||
package com.sk89q.worldedit.internal.cui;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector2;
|
||||
|
||||
public class SelectionCylinderEvent implements CUIEvent {
|
||||
|
||||
protected final Vector pos;
|
||||
protected final Vector2D radius;
|
||||
protected final BlockVector3 pos;
|
||||
protected final Vector2 radius;
|
||||
|
||||
public SelectionCylinderEvent(Vector pos, Vector2D radius) {
|
||||
public SelectionCylinderEvent(BlockVector3 pos, Vector2 radius) {
|
||||
this.pos = pos;
|
||||
this.radius = radius;
|
||||
}
|
||||
|
@ -19,14 +19,14 @@
|
||||
|
||||
package com.sk89q.worldedit.internal.cui;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
public class SelectionEllipsoidPointEvent implements CUIEvent {
|
||||
|
||||
protected final int id;
|
||||
protected final Vector pos;
|
||||
protected final BlockVector3 pos;
|
||||
|
||||
public SelectionEllipsoidPointEvent(int id, Vector pos) {
|
||||
public SelectionEllipsoidPointEvent(int id, BlockVector3 pos) {
|
||||
this.id = id;
|
||||
this.pos = pos;
|
||||
}
|
||||
|
@ -19,27 +19,27 @@
|
||||
|
||||
package com.sk89q.worldedit.internal.cui;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
public class SelectionPoint2DEvent implements CUIEvent {
|
||||
|
||||
protected final int id;
|
||||
protected final int blockx;
|
||||
protected final int blockz;
|
||||
protected final int blockX;
|
||||
protected final int blockZ;
|
||||
protected final int area;
|
||||
|
||||
public SelectionPoint2DEvent(int id, Vector2D pos, int area) {
|
||||
public SelectionPoint2DEvent(int id, BlockVector2 pos, int area) {
|
||||
this.id = id;
|
||||
this.blockx = pos.getBlockX();
|
||||
this.blockz = pos.getBlockZ();
|
||||
this.blockX = pos.getX();
|
||||
this.blockZ = pos.getZ();
|
||||
this.area = area;
|
||||
}
|
||||
|
||||
public SelectionPoint2DEvent(int id, Vector pos, int area) {
|
||||
public SelectionPoint2DEvent(int id, BlockVector3 pos, int area) {
|
||||
this.id = id;
|
||||
this.blockx = pos.getBlockX();
|
||||
this.blockz = pos.getBlockZ();
|
||||
this.blockX = pos.getX();
|
||||
this.blockZ = pos.getZ();
|
||||
this.area = area;
|
||||
}
|
||||
|
||||
@ -52,8 +52,8 @@ public class SelectionPoint2DEvent implements CUIEvent {
|
||||
public String[] getParameters() {
|
||||
return new String[] {
|
||||
String.valueOf(id),
|
||||
String.valueOf(blockx),
|
||||
String.valueOf(blockz),
|
||||
String.valueOf(blockX),
|
||||
String.valueOf(blockZ),
|
||||
String.valueOf(area)
|
||||
};
|
||||
}
|
||||
|
@ -19,15 +19,15 @@
|
||||
|
||||
package com.sk89q.worldedit.internal.cui;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
public class SelectionPointEvent implements CUIEvent {
|
||||
|
||||
protected final int id;
|
||||
protected final Vector pos;
|
||||
protected final BlockVector3 pos;
|
||||
protected final int area;
|
||||
|
||||
public SelectionPointEvent(int id, Vector pos, int area) {
|
||||
public SelectionPointEvent(int id, BlockVector3 pos, int area) {
|
||||
this.id = id;
|
||||
this.pos = pos;
|
||||
this.area = area;
|
||||
|
@ -26,9 +26,9 @@ import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
@ -85,7 +85,7 @@ public class ServerCUIHandler {
|
||||
}
|
||||
} else {
|
||||
CuboidRegion region = ((CuboidRegionSelector) regionSelector).getIncompleteRegion();
|
||||
Vector point;
|
||||
BlockVector3 point;
|
||||
if (region.getPos1() != null) {
|
||||
point = region.getPos1();
|
||||
} else if (region.getPos2() != null) {
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.internal.expression.runtime;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.Function.Dynamic;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.noise.PerlinNoise;
|
||||
import com.sk89q.worldedit.math.noise.RidgedMultiFractalNoise;
|
||||
import com.sk89q.worldedit.math.noise.VoronoiNoise;
|
||||
@ -392,7 +392,7 @@ public final class Functions {
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new EvaluationException(0, "Perlin noise error: " + e.getMessage());
|
||||
}
|
||||
return perlin.noise(new Vector(x.getValue(), y.getValue(), z.getValue()));
|
||||
return perlin.noise(new Vector3(x.getValue(), y.getValue(), z.getValue()));
|
||||
}
|
||||
|
||||
private static final ThreadLocal<VoronoiNoise> localVoronoi = ThreadLocal.withInitial(VoronoiNoise::new);
|
||||
@ -405,7 +405,7 @@ public final class Functions {
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new EvaluationException(0, "Voronoi error: " + e.getMessage());
|
||||
}
|
||||
return voronoi.noise(new Vector(x.getValue(), y.getValue(), z.getValue()));
|
||||
return voronoi.noise(new Vector3(x.getValue(), y.getValue(), z.getValue()));
|
||||
}
|
||||
|
||||
private static final ThreadLocal<RidgedMultiFractalNoise> localRidgedMulti = ThreadLocal.withInitial(RidgedMultiFractalNoise::new);
|
||||
@ -419,7 +419,7 @@ public final class Functions {
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new EvaluationException(0, "Ridged multi error: " + e.getMessage());
|
||||
}
|
||||
return ridgedMulti.noise(new Vector(x.getValue(), y.getValue(), z.getValue()));
|
||||
return ridgedMulti.noise(new Vector3(x.getValue(), y.getValue(), z.getValue()));
|
||||
}
|
||||
|
||||
private static double queryInternal(RValue type, RValue data, double typeId, double dataValue) throws EvaluationException {
|
||||
|
Reference in New Issue
Block a user