geforkt von Mirrors/FastAsyncWorldEdit
fix compile + use mutable vector for affine transform + fix bstats package
Dieser Commit ist enthalten in:
Ursprung
1529c187d2
Commit
093542c337
@ -1,6 +1,7 @@
|
|||||||
package org.bstats.bukkit;
|
package com.boydti.fawe.bukkit;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
@ -41,7 +41,6 @@ import com.boydti.fawe.util.TaskManager;
|
|||||||
import com.boydti.fawe.util.cui.CUI;
|
import com.boydti.fawe.util.cui.CUI;
|
||||||
import com.boydti.fawe.util.image.ImageViewer;
|
import com.boydti.fawe.util.image.ImageViewer;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import org.bstats.bukkit.BStats;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
@ -269,7 +268,7 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public void startMetrics() {
|
@Override public void startMetrics() {
|
||||||
BStats bStats = new BStats(plugin);
|
new BStats(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemUtil getItemUtil() {
|
public ItemUtil getItemUtil() {
|
||||||
|
@ -79,22 +79,22 @@ public class TransformExtent extends BlockTransformExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(int x, int y, int z) {
|
public BlockState getLazyBlock(int x, int y, int z) {
|
||||||
return transformBlock(super.getLazyBlock(getPos(x, y, z)), false).toImmutableState();
|
return transform(super.getLazyBlock(getPos(x, y, z)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(BlockVector3 position) {
|
public BlockState getLazyBlock(BlockVector3 position) {
|
||||||
return transformBlock(super.getLazyBlock(getPos(position)), false).toImmutableState();
|
return transform(super.getLazyBlock(getPos(position)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(BlockVector3 position) {
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
return transformBlock(super.getBlock(getPos(position)), false).toImmutableState();
|
return transform(super.getBlock(getPos(position)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
return transformBlock(super.getFullBlock(getPos(position)), false);
|
return transform(super.getFullBlock(getPos(position)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -106,14 +106,16 @@ public class TransformExtent extends BlockTransformExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
||||||
return super.setBlock(getPos(x, y, z), transformBlock((BlockState)block, false));
|
System.out.println("Set block transform");
|
||||||
|
return super.setBlock(getPos(x, y, z), transformInverse(block));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
|
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||||
return super.setBlock(getPos(location), transformBlock((BlockState)block, false));
|
System.out.println("Set block transform2");
|
||||||
|
return super.setBlock(getPos(location), transformInverse(block));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,9 +55,9 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
|
|
||||||
|
|
||||||
private long combine(Direction... directions) {
|
private long combine(Direction... directions) {
|
||||||
int mask = 0;
|
long mask = 0;
|
||||||
for (Direction dir : directions) {
|
for (Direction dir : directions) {
|
||||||
mask = mask | (1 << dir.ordinal());
|
mask = mask | (1L << dir.ordinal());
|
||||||
}
|
}
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
private long[] adapt(Direction... dirs) {
|
private long[] adapt(Direction... dirs) {
|
||||||
long[] arr = new long[dirs.length];
|
long[] arr = new long[dirs.length];
|
||||||
for (int i = 0; i < arr.length; i++) {
|
for (int i = 0; i < arr.length; i++) {
|
||||||
arr[i] = 1 << dirs[i].ordinal();
|
arr[i] = 1L << dirs[i].ordinal();
|
||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
@ -121,16 +121,16 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
result.add(combine(NORTH, EAST, SOUTH, WEST));
|
result.add(combine(NORTH, EAST, SOUTH, WEST));
|
||||||
continue;
|
continue;
|
||||||
case "inner_left":
|
case "inner_left":
|
||||||
result.add(notIndex(combine(NORTHEAST, SOUTHWEST), property.getIndexFor("outer_right")));
|
result.add(notIndex(combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST), property.getIndexFor("outer_right"), property.getIndexFor("outer_left")));
|
||||||
continue;
|
continue;
|
||||||
case "inner_right":
|
case "inner_right":
|
||||||
result.add(notIndex(combine(NORTHWEST, SOUTHEAST), property.getIndexFor("outer_left")));
|
result.add(notIndex(combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST), property.getIndexFor("outer_right"), property.getIndexFor("outer_left")));
|
||||||
continue;
|
continue;
|
||||||
case "outer_left":
|
case "outer_left":
|
||||||
result.add(notIndex(combine(NORTHEAST, SOUTHWEST), property.getIndexFor("inner_right")));
|
result.add(notIndex(combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST), property.getIndexFor("inner_left"), property.getIndexFor("inner_right")));
|
||||||
continue;
|
continue;
|
||||||
case "outer_right":
|
case "outer_right":
|
||||||
result.add(notIndex(combine(NORTHWEST, SOUTHEAST), property.getIndexFor("inner_left")));
|
result.add(notIndex(combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST), property.getIndexFor("inner_left"), property.getIndexFor("inner_right")));
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
System.out.println("Unknown direction " + value);
|
System.out.println("Unknown direction " + value);
|
||||||
@ -184,21 +184,15 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Direction getFirst(long mask) {
|
|
||||||
for (Direction dir : Direction.values()) {
|
|
||||||
if (hasDirection(mask, dir)) {
|
|
||||||
return dir;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean hasDirection(long mask, Direction dir) {
|
private static boolean hasDirection(long mask, Direction dir) {
|
||||||
return (mask & (1L << dir.ordinal())) != 0;
|
return (mask & (1L << dir.ordinal())) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long notIndex(long mask, int index) {
|
private static long notIndex(long mask, int... indexes) {
|
||||||
return mask | (1L << (index + values().length));
|
for (int index : indexes) {
|
||||||
|
mask = mask | (1L << (index + values().length));
|
||||||
|
}
|
||||||
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean hasIndex(long mask, int index) {
|
private static boolean hasIndex(long mask, int index) {
|
||||||
@ -209,39 +203,49 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
private static Integer getNewStateIndex(Transform transform, long[] directions, int oldIndex) {
|
private static Integer getNewStateIndex(Transform transform, long[] directions, int oldIndex) {
|
||||||
long oldDirMask = directions[oldIndex];
|
long oldDirMask = directions[oldIndex];
|
||||||
if (oldDirMask == 0) {
|
if (oldDirMask == 0) {
|
||||||
return oldIndex;
|
return null;
|
||||||
}
|
}
|
||||||
|
Integer newIndex = null;
|
||||||
|
|
||||||
for (Direction oldDirection : values()) {
|
for (Direction oldDirection : values()) {
|
||||||
if (!hasDirection(oldDirMask, oldDirection)) continue;
|
if (!hasDirection(oldDirMask, oldDirection)) {
|
||||||
if (oldDirection == null) {
|
continue;
|
||||||
System.out.println(oldDirMask);
|
|
||||||
}
|
}
|
||||||
Vector3 oldVector = oldDirection.toVector();
|
Vector3 oldVector = oldDirection.toVector();
|
||||||
Vector3 newVector = transform.apply(oldVector).subtract(transform.apply(Vector3.ZERO)).normalize();
|
Vector3 newVector = transform.apply(oldVector).subtract(transform.apply(Vector3.ZERO)).normalize();
|
||||||
int newIndex = oldIndex;
|
boolean flip = false;
|
||||||
|
|
||||||
|
if (transform instanceof AffineTransform) {
|
||||||
|
flip = ((AffineTransform) transform).isScaled(oldVector);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldVector.equals(newVector)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
double closest = oldVector.normalize().dot(newVector);
|
double closest = oldVector.normalize().dot(newVector);
|
||||||
boolean found = false;
|
|
||||||
for (int i = 0; i < directions.length; i++) {
|
for (int i = 0; i < directions.length; i++) {
|
||||||
int j = (oldIndex + i) % directions.length;
|
int j = (oldIndex + i) % directions.length;
|
||||||
long newDirMask = directions[j];
|
long newDirMask = directions[j];
|
||||||
if (!hasIndex(oldDirMask, j)) continue;
|
if (!hasIndex(oldDirMask, j)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for (Direction v : Direction.values()) {
|
for (Direction v : Direction.values()) {
|
||||||
// Check if it's one of the current directions
|
// Check if it's one of the current directions
|
||||||
if (!hasDirection(newDirMask, v)) continue;
|
if (!hasDirection(newDirMask, v)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// Check if the old mask excludes it
|
// Check if the old mask excludes it
|
||||||
double dot = v.toVector().normalize().dot(newVector);
|
double dot = v.toVector().normalize().dot(newVector);
|
||||||
if (dot > closest) {
|
if (dot > closest || (flip && dot >= closest)) { //
|
||||||
closest = dot;
|
closest = dot;
|
||||||
newIndex = j;
|
newIndex = j;
|
||||||
found = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found) {
|
if (newIndex != null) return newIndex;
|
||||||
return newIndex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return newIndex != null ? newIndex : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDirectional(Property property) {
|
private boolean isDirectional(Property property) {
|
||||||
@ -348,11 +352,13 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (AbstractProperty property : (Collection<AbstractProperty>) (Collection) type.getProperties()) {
|
for (AbstractProperty property : (Collection<AbstractProperty>) (Collection) type.getProperties()) {
|
||||||
long[] directions = getDirections(property);
|
if (isDirectional(property)) {
|
||||||
if (directions != null) {
|
long[] directions = getDirections(property);
|
||||||
Integer newIndex = getNewStateIndex(transform, directions, property.getIndex(state.getInternalId()));
|
if (directions != null) {
|
||||||
if (newIndex != null) {
|
Integer newIndex = getNewStateIndex(transform, directions, property.getIndex(state.getInternalId()));
|
||||||
newMaskedId = property.modifyIndex(newMaskedId, newIndex);
|
if (newIndex != null) {
|
||||||
|
newMaskedId = property.modifyIndex(newMaskedId, newIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -364,18 +370,18 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final BaseBlock transformInverse(BlockStateHolder block) {
|
public final BaseBlock transform(BlockStateHolder block) {
|
||||||
BlockState transformed = transform(block.toImmutableState());
|
BlockState transformed = transform(block.toImmutableState());
|
||||||
if (block.hasNbtData()) {
|
if (block.hasNbtData()) {
|
||||||
return transformFastWith(transformed, block.getNbtData(), transformInverse);
|
return transformFastWith(transformed, block.getNbtData(), transform);
|
||||||
}
|
}
|
||||||
return transformed.toBaseBlock();
|
return transformed.toBaseBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final BlockStateHolder transform(BlockStateHolder block) {
|
public final BlockStateHolder transformInverse(BlockStateHolder block) {
|
||||||
BlockState transformed = transform(block.toImmutableState());
|
BlockState transformed = transformInverse(block.toImmutableState());
|
||||||
if (block.hasNbtData()) {
|
if (block.hasNbtData()) {
|
||||||
return transformFastWith(transformed, block.getNbtData(), transform);
|
return transformFastWith(transformed, block.getNbtData(), transformInverse);
|
||||||
}
|
}
|
||||||
return transformed;
|
return transformed;
|
||||||
}
|
}
|
||||||
@ -407,32 +413,32 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
return transformed.toBaseBlock();
|
return transformed.toBaseBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final BlockState transformInverse(BlockState block) {
|
public final BlockState transform(BlockState block) {
|
||||||
return transform(block, BLOCK_TRANSFORM, transformInverse);
|
return transform(block, BLOCK_TRANSFORM, transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final BlockState transform(BlockState block) {
|
public final BlockState transformInverse(BlockState block) {
|
||||||
return transform(block, BLOCK_TRANSFORM_INVERSE, transform);
|
return transform(block, BLOCK_TRANSFORM_INVERSE, transformInverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(int x, int y, int z) {
|
public BlockState getLazyBlock(int x, int y, int z) {
|
||||||
return transformInverse(super.getLazyBlock(x, y, z));
|
return transform(super.getLazyBlock(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
return transformInverse(super.getFullBlock(position));
|
return transform(super.getFullBlock(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(BlockVector3 position) {
|
public BlockState getLazyBlock(BlockVector3 position) {
|
||||||
return transformInverse(super.getLazyBlock(position));
|
return transform(super.getLazyBlock(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(BlockVector3 position) {
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
return transformInverse(super.getBlock(position));
|
return transform(super.getBlock(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -442,13 +448,13 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
||||||
return super.setBlock(x, y, z, transform(block));
|
return super.setBlock(x, y, z, transformInverse(block));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||||
return super.setBlock(location, transform(block));
|
return super.setBlock(location, transformInverse(block));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import java.io.Serializable;
|
|||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.MathUtils;
|
import com.sk89q.worldedit.math.MathUtils;
|
||||||
|
import com.sk89q.worldedit.math.MutableVector3;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,7 +18,7 @@ import com.sk89q.worldedit.math.Vector3;
|
|||||||
*/
|
*/
|
||||||
public class AffineTransform implements Transform, Serializable {
|
public class AffineTransform implements Transform, Serializable {
|
||||||
|
|
||||||
private transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
private AffineTransform inverse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* coefficients for x coordinate.
|
* coefficients for x coordinate.
|
||||||
@ -162,8 +163,9 @@ public class AffineTransform implements Transform, Serializable {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AffineTransform inverse() {
|
public AffineTransform inverse() {
|
||||||
|
if (inverse != null) return inverse;
|
||||||
double det = this.determinant();
|
double det = this.determinant();
|
||||||
return new AffineTransform(
|
return inverse = new AffineTransform(
|
||||||
(m11 * m22 - m21 * m12) / det,
|
(m11 * m22 - m21 * m12) / det,
|
||||||
(m02 * m21 - m22 * m01) / det,
|
(m02 * m21 - m22 * m01) / det,
|
||||||
(m01 * m12 - m11 * m02) / det,
|
(m01 * m12 - m11 * m02) / det,
|
||||||
@ -290,16 +292,23 @@ public class AffineTransform implements Transform, Serializable {
|
|||||||
return scale(vec.getX(), vec.getY(), vec.getZ());
|
return scale(vec.getX(), vec.getY(), vec.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isScaled(Vector3 vector) {
|
||||||
|
boolean flip = false;
|
||||||
|
if (vector.getX() != 0 && m00 < 0) flip = !flip;
|
||||||
|
if (vector.getY() != 0 && m11 < 0) flip = !flip;
|
||||||
|
if (vector.getZ() != 0 && m22 < 0) flip = !flip;
|
||||||
|
return flip;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector3 apply(Vector3 vector) {
|
public Vector3 apply(Vector3 vector) {
|
||||||
return Vector3.at(
|
double x = (vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03);
|
||||||
vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03,
|
double y = (vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13);
|
||||||
vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13,
|
double z = (vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23);
|
||||||
vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23);
|
vector = vector.mutX(x);
|
||||||
// mutable.mutX((vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03));
|
vector = vector.mutY(y);
|
||||||
// mutable.mutY((vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13));
|
vector = vector.mutZ(z);
|
||||||
// mutable.mutZ((vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23));
|
return vector;
|
||||||
// return mutable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AffineTransform combine(AffineTransform other) {
|
public AffineTransform combine(AffineTransform other) {
|
||||||
@ -324,7 +333,6 @@ public class AffineTransform implements Transform, Serializable {
|
|||||||
|
|
||||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||||
stream.defaultReadObject();
|
stream.defaultReadObject();
|
||||||
mutable = new MutableBlockVector3();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren