mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
Current progress with update
This commit is contained in:
@ -20,7 +20,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;
|
||||
@ -28,7 +28,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)
|
||||
|
@ -22,9 +22,16 @@ package com.sk89q.worldedit.internal.command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.*;
|
||||
=======
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
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;
|
||||
@ -99,13 +106,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;
|
||||
}
|
||||
|
@ -26,11 +26,13 @@ import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.PlayerDirection;
|
||||
import com.sk89q.worldedit.UnknownDirectionException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
=======
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.input.NoMatchException;
|
||||
@ -42,6 +44,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;
|
||||
@ -53,6 +56,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.block.BlockType;
|
||||
@ -306,10 +310,17 @@ public class WorldEditBinding extends BindingHelper {
|
||||
* @throws UnknownDirectionException on an unknown direction
|
||||
*/
|
||||
@BindingMatch(classifier = Direction.class,
|
||||
<<<<<<< HEAD
|
||||
type = Vector.class,
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1)
|
||||
public Vector getDirection(ArgumentStack context, Direction direction)
|
||||
=======
|
||||
type = BlockVector3.class,
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1)
|
||||
public BlockVector3 getDirection(ArgumentStack context, Direction direction)
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
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;
|
||||
|
@ -0,0 +1,155 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.internal.cui;
|
||||
|
||||
import com.sk89q.jnbt.ByteTag;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
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;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Handles creation of server-side CUI systems.
|
||||
*/
|
||||
public class ServerCUIHandler {
|
||||
|
||||
private ServerCUIHandler() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a structure block that shows the region.
|
||||
*
|
||||
* <p>
|
||||
* Null symbolises removal of the CUI.
|
||||
* </p>
|
||||
*
|
||||
* @param player The player to create the structure block for.
|
||||
* @return The structure block, or null
|
||||
*/
|
||||
@Nullable
|
||||
public static com.sk89q.worldedit.blocks.BaseBlock createStructureBlock(Player player) {
|
||||
LocalSession session = WorldEdit.getInstance().getSessionManager().get(player);
|
||||
RegionSelector regionSelector = session.getRegionSelector(player.getWorld());
|
||||
|
||||
int posX, posY, posZ;
|
||||
int width, height, length;
|
||||
|
||||
if (regionSelector instanceof CuboidRegionSelector) {
|
||||
if (regionSelector.isDefined()) {
|
||||
try {
|
||||
CuboidRegion region = ((CuboidRegionSelector) regionSelector).getRegion();
|
||||
|
||||
posX = region.getMinimumPoint().getBlockX();
|
||||
posY = region.getMinimumPoint().getBlockY();
|
||||
posZ = region.getMinimumPoint().getBlockZ();
|
||||
|
||||
width = region.getWidth();
|
||||
height = region.getHeight();
|
||||
length = region.getLength();
|
||||
} catch (IncompleteRegionException e) {
|
||||
// This will never happen.
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
CuboidRegion region = ((CuboidRegionSelector) regionSelector).getIncompleteRegion();
|
||||
BlockVector3 point;
|
||||
if (region.getPos1() != null) {
|
||||
point = region.getPos1();
|
||||
} else if (region.getPos2() != null) {
|
||||
point = region.getPos2();
|
||||
} else {
|
||||
// No more selection
|
||||
return null;
|
||||
}
|
||||
|
||||
// Just select the point.
|
||||
posX = point.getBlockX();
|
||||
posY = point.getBlockY();
|
||||
posZ = point.getBlockZ();
|
||||
width = 1;
|
||||
height = 1;
|
||||
length = 1;
|
||||
}
|
||||
} else {
|
||||
// We only support cuboid regions right now.
|
||||
return null;
|
||||
}
|
||||
|
||||
if (width > 32 || length > 32 || height > 32) {
|
||||
// Structure blocks have a limit of 32x32x32
|
||||
return null;
|
||||
}
|
||||
|
||||
// Borrowed this math from FAWE
|
||||
double rotX = player.getLocation().getYaw();
|
||||
double rotY = player.getLocation().getPitch();
|
||||
double xz = Math.cos(Math.toRadians(rotY));
|
||||
int x = (int) (player.getLocation().getX() - (-xz * Math.sin(Math.toRadians(rotX))) * 12);
|
||||
int z = (int) (player.getLocation().getZ() - (xz * Math.cos(Math.toRadians(rotX))) * 12);
|
||||
int y = Math.max(0, Math.min(Math.min(255, posY + 32), posY + 3));
|
||||
|
||||
Map<String, Tag> structureTag = new HashMap<>();
|
||||
|
||||
posX -= x;
|
||||
posY -= y;
|
||||
posZ -= z;
|
||||
|
||||
if (Math.abs(posX) > 32 || Math.abs(posY) > 32 || Math.abs(posZ) > 32) {
|
||||
// Structure blocks have a limit
|
||||
return null;
|
||||
}
|
||||
|
||||
structureTag.put("name", new StringTag("worldedit:" + player.getName()));
|
||||
structureTag.put("author", new StringTag(player.getName()));
|
||||
structureTag.put("metadata", new StringTag(""));
|
||||
structureTag.put("x", new IntTag(x));
|
||||
structureTag.put("y", new IntTag(y));
|
||||
structureTag.put("z", new IntTag(z));
|
||||
structureTag.put("posX", new IntTag(posX));
|
||||
structureTag.put("posY", new IntTag(posY));
|
||||
structureTag.put("posZ", new IntTag(posZ));
|
||||
structureTag.put("sizeX", new IntTag(width));
|
||||
structureTag.put("sizeY", new IntTag(height));
|
||||
structureTag.put("sizeZ", new IntTag(length));
|
||||
structureTag.put("rotation", new StringTag("NONE"));
|
||||
structureTag.put("mirror", new StringTag("NONE"));
|
||||
structureTag.put("mode", new StringTag("SAVE"));
|
||||
structureTag.put("ignoreEntities", new ByteTag((byte) 1));
|
||||
structureTag.put("showboundingbox", new ByteTag((byte) 1));
|
||||
structureTag.put("id", new StringTag(BlockTypes.STRUCTURE_BLOCK.getId()));
|
||||
|
||||
return BlockTypes.STRUCTURE_BLOCK.getDefaultState().toBaseBlock(new CompoundTag(structureTag));
|
||||
}
|
||||
}
|
@ -19,11 +19,15 @@
|
||||
|
||||
package com.sk89q.worldedit.internal.expression.runtime;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
=======
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
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;
|
||||
@ -397,7 +401,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);
|
||||
@ -410,7 +414,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);
|
||||
@ -424,7 +428,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