mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-05 12:36:40 +00:00
Small spring cleaning
I changed really small bits and pieces of code. If you have questions just comment and I'll answer them.
This commit is contained in:
@ -1,15 +1,14 @@
|
||||
package com.boydti.fawe.object.extent;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.PassthroughExtent;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
public class BlockTranslateExtent extends AbstractDelegateExtent {
|
||||
@ -25,9 +24,9 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
|
||||
mutable.mutX((location.getX() + dx));
|
||||
mutable.mutY((location.getY() + dy));
|
||||
mutable.mutZ((location.getZ() + dz));
|
||||
mutable.mutX(location.getX() + dx);
|
||||
mutable.mutY(location.getY() + dy);
|
||||
mutable.mutZ(location.getZ() + dz);
|
||||
return getExtent().setBlock(mutable, block);
|
||||
}
|
||||
|
||||
|
@ -2,11 +2,14 @@ package com.boydti.fawe.object.extent;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.PassthroughExtent;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ExtentHeightCacher extends PassthroughExtent {
|
||||
|
||||
private transient int cacheBotX = Integer.MIN_VALUE;
|
||||
private transient int cacheBotZ = Integer.MIN_VALUE;
|
||||
private transient byte[] cacheHeights;
|
||||
private transient int lastY;
|
||||
public ExtentHeightCacher(Extent extent) {
|
||||
super(extent);
|
||||
}
|
||||
@ -19,11 +22,6 @@ public class ExtentHeightCacher extends PassthroughExtent {
|
||||
}
|
||||
}
|
||||
|
||||
private transient int cacheBotX = Integer.MIN_VALUE;
|
||||
private transient int cacheBotZ = Integer.MIN_VALUE;
|
||||
private transient byte[] cacheHeights;
|
||||
private transient int lastY;
|
||||
|
||||
@Override
|
||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
|
||||
int rx = x - cacheBotX + 16;
|
||||
@ -46,7 +44,8 @@ public class ExtentHeightCacher extends PassthroughExtent {
|
||||
}
|
||||
int result = cacheHeights[index] & 0xFF;
|
||||
if (result == 0) {
|
||||
cacheHeights[index] = (byte) (result = lastY = super.getNearestSurfaceTerrainBlock(x, z, lastY, minY, maxY));
|
||||
cacheHeights[index] = (byte) (result = lastY = super
|
||||
.getNearestSurfaceTerrainBlock(x, z, lastY, minY, maxY));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import java.util.Collection;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class FaweRegionExtent extends ResettableExtent implements IBatchProcessor {
|
||||
|
||||
private final FaweLimit limit;
|
||||
|
||||
/**
|
||||
@ -68,7 +69,8 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
||||
}
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block)
|
||||
throws WorldEditException {
|
||||
if (!contains(x, y, z)) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
||||
|
@ -38,7 +38,9 @@ public class HeightBoundExtent extends FaweRegionExtent {
|
||||
|
||||
@Override
|
||||
public Collection<Region> getRegions() {
|
||||
return Collections.singletonList(new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, min, max, Integer.MIN_VALUE, Integer.MAX_VALUE));
|
||||
return Collections.singletonList(
|
||||
new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, min, max, Integer.MIN_VALUE,
|
||||
Integer.MAX_VALUE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ import com.sk89q.worldedit.extent.PassthroughExtent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
public class MemoryCheckingExtent extends PassthroughExtent {
|
||||
|
||||
private final Player player;
|
||||
|
||||
public MemoryCheckingExtent(Player player, Extent extent) {
|
||||
|
@ -7,15 +7,14 @@ import com.boydti.fawe.object.FaweLimit;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionIntersection;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
public class MultiRegionExtent extends FaweRegionExtent {
|
||||
|
||||
private final RegionIntersection intersection;
|
||||
private Region region;
|
||||
private final Region[] regions;
|
||||
private Region region;
|
||||
private int index;
|
||||
|
||||
/**
|
||||
|
@ -9,15 +9,17 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class MultiTransform extends RandomTransform {
|
||||
|
||||
private ResettableExtent[] extents;
|
||||
|
||||
public MultiTransform(Collection<ResettableExtent> extents) {
|
||||
for (ResettableExtent extent : extents) add(extent, 1);
|
||||
for (ResettableExtent extent : extents) {
|
||||
add(extent, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public MultiTransform() {
|
||||
@ -31,18 +33,24 @@ public class MultiTransform extends RandomTransform {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
||||
throws WorldEditException {
|
||||
// don't use streams for each block place, it'd be incredibly slow
|
||||
boolean result = false;
|
||||
for (AbstractDelegateExtent extent : extents) result |= extent.setBlock(x, y, z, block);
|
||||
for (AbstractDelegateExtent extent : extents) {
|
||||
result |= extent.setBlock(x, y, z, block);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block)
|
||||
throws WorldEditException {
|
||||
// don't use streams for each block place, it'd be incredibly slow
|
||||
boolean result = false;
|
||||
for (AbstractDelegateExtent extent : extents) result |= extent.setBlock(location, block);
|
||||
for (AbstractDelegateExtent extent : extents) {
|
||||
result |= extent.setBlock(location, block);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -50,7 +58,9 @@ public class MultiTransform extends RandomTransform {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
// don't use streams for each block place, it'd be incredibly slow
|
||||
boolean result = false;
|
||||
for (AbstractDelegateExtent extent : extents) result |= extent.setBiome(position, biome);
|
||||
for (AbstractDelegateExtent extent : extents) {
|
||||
result |= extent.setBiome(position, biome);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -58,7 +68,9 @@ public class MultiTransform extends RandomTransform {
|
||||
@Override
|
||||
public Entity createEntity(Location location, BaseEntity entity) {
|
||||
Entity created = null;
|
||||
for (AbstractDelegateExtent extent : extents) created = extent.createEntity(location, entity);
|
||||
for (AbstractDelegateExtent extent : extents) {
|
||||
created = extent.createEntity(location, entity);
|
||||
}
|
||||
return created;
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
//todo This should be removed in favor of com.sk89q.worldedit.extent.NullExtent
|
||||
public class NullExtent extends FaweRegionExtent implements IBatchProcessor {
|
||||
|
||||
private final FaweException reason;
|
||||
|
@ -9,6 +9,7 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
public class OffsetExtent extends ResettableExtent {
|
||||
|
||||
private final int dx, dy, dz;
|
||||
private transient MutableBlockVector2 mutable = new MutableBlockVector2();
|
||||
|
||||
@ -21,7 +22,9 @@ public class OffsetExtent extends ResettableExtent {
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return getExtent().setBiome(mutable.setComponents(position.getBlockX() + dx, position.getBlockZ() + dz), biome);
|
||||
return getExtent()
|
||||
.setBiome(mutable.setComponents(position.getBlockX() + dx, position.getBlockZ() + dz),
|
||||
biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -30,12 +33,15 @@ public class OffsetExtent extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
|
||||
return getExtent().setBlock(location.getBlockX() + dx, location.getBlockY() + dy, location.getBlockZ() + dz, block);
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block)
|
||||
throws WorldEditException {
|
||||
return getExtent().setBlock(location.getBlockX() + dx, location.getBlockY() + dy,
|
||||
location.getBlockZ() + dz, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
||||
throws WorldEditException {
|
||||
return getExtent().setBlock(x + dx, y + dy, z + dz, block);
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
package com.boydti.fawe.object.extent;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
public class PatternTransform extends ResettableExtent {
|
||||
|
||||
private final Pattern pattern;
|
||||
|
||||
public PatternTransform(Extent parent, Pattern pattern) {
|
||||
@ -16,7 +16,8 @@ public class PatternTransform extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block)
|
||||
throws WorldEditException {
|
||||
return pattern.apply(getExtent(), location, location);
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ public class PositionTransformExtent extends ResettableExtent {
|
||||
return super.setExtent(extent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrigin(BlockVector3 pos) {
|
||||
this.min = pos;
|
||||
}
|
||||
@ -38,9 +39,9 @@ public class PositionTransformExtent extends ResettableExtent {
|
||||
if (min == null) {
|
||||
min = pos;
|
||||
}
|
||||
mutable.mutX(((pos.getX() - min.getX())));
|
||||
mutable.mutY(((pos.getY() - min.getY())));
|
||||
mutable.mutZ(((pos.getZ() - min.getZ())));
|
||||
mutable.mutX(pos.getX() - min.getX());
|
||||
mutable.mutY(pos.getY() - min.getY());
|
||||
mutable.mutZ(pos.getZ() - min.getZ());
|
||||
MutableVector3 tmp = new MutableVector3(transform.apply(mutable.toVector3()));
|
||||
return min.add(tmp.toBlockPoint());
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package com.boydti.fawe.object.extent;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.FaweLimit;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.util.WEManager;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
@ -19,6 +18,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
|
||||
private final FaweLimit limit;
|
||||
private final Extent extent;
|
||||
|
||||
@ -65,7 +65,8 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block)
|
||||
throws WorldEditException {
|
||||
return setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
|
||||
}
|
||||
|
||||
@ -75,7 +76,8 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block)
|
||||
throws WorldEditException {
|
||||
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||
if (hasNbt) {
|
||||
if (!limit.MAX_BLOCKSTATES()) {
|
||||
|
@ -1,21 +1,19 @@
|
||||
package com.boydti.fawe.object.extent;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.SplittableRandom;
|
||||
|
||||
public class RandomOffsetTransform extends ResettableExtent {
|
||||
private transient SplittableRandom random;
|
||||
private transient MutableBlockVector2 mutable = new MutableBlockVector2();
|
||||
|
||||
private final int dx, dy, dz;
|
||||
private transient SplittableRandom random;
|
||||
private transient MutableBlockVector2 mutable = new MutableBlockVector2();
|
||||
|
||||
public RandomOffsetTransform(Extent parent, int dx, int dy, int dz) {
|
||||
super(parent);
|
||||
@ -33,7 +31,8 @@ public class RandomOffsetTransform extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 pos, T block) throws WorldEditException {
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 pos, T block)
|
||||
throws WorldEditException {
|
||||
int x = pos.getBlockX() + random.nextInt(1 + (dx << 1)) - dx;
|
||||
int y = pos.getBlockY() + random.nextInt(1 + (dy << 1)) - dy;
|
||||
int z = pos.getBlockZ() + random.nextInt(1 + (dz << 1)) - dz;
|
||||
@ -41,7 +40,8 @@ public class RandomOffsetTransform extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
||||
throws WorldEditException {
|
||||
x = x + random.nextInt(1 + (dx << 1)) - dx;
|
||||
y = y + random.nextInt(1 + (dy << 1)) - dy;
|
||||
z = z + random.nextInt(1 + (dz << 1)) - dz;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.boydti.fawe.object.extent;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.object.collection.RandomCollection;
|
||||
import com.boydti.fawe.object.random.SimpleRandom;
|
||||
import com.boydti.fawe.object.random.TrueRandom;
|
||||
@ -10,9 +12,6 @@ import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Uses a random pattern of a weighted list of patterns.
|
||||
*/
|
||||
@ -28,6 +27,10 @@ public class RandomTransform extends SelectTransform {
|
||||
this(new TrueRandom());
|
||||
}
|
||||
|
||||
public RandomTransform(SimpleRandom random) {
|
||||
this.random = random;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractDelegateExtent getExtent(int x, int y, int z) {
|
||||
return collection.next(x, y, z);
|
||||
@ -38,10 +41,6 @@ public class RandomTransform extends SelectTransform {
|
||||
return collection.next(x, 0, z);
|
||||
}
|
||||
|
||||
public RandomTransform(SimpleRandom random) {
|
||||
this.random = random;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResettableExtent setExtent(Extent extent) {
|
||||
if (collection == null) {
|
||||
|
@ -14,6 +14,7 @@ import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class ResettableExtent extends AbstractDelegateExtent implements Serializable {
|
||||
|
||||
public ResettableExtent(Extent parent) {
|
||||
super(parent);
|
||||
}
|
||||
@ -26,12 +27,14 @@ public class ResettableExtent extends AbstractDelegateExtent implements Serializ
|
||||
setOrigin(pos);
|
||||
}
|
||||
|
||||
protected void setOrigin(BlockVector3 pos) {}
|
||||
protected void setOrigin(BlockVector3 pos) {
|
||||
}
|
||||
|
||||
public ResettableExtent setExtent(Extent extent) {
|
||||
checkNotNull(extent);
|
||||
Extent next = getExtent();
|
||||
if (!(next instanceof NullExtent) && !(next instanceof World) && next instanceof ResettableExtent) {
|
||||
if (!(next instanceof NullExtent) && !(next instanceof World)
|
||||
&& next instanceof ResettableExtent) {
|
||||
((ResettableExtent) next).setExtent(extent);
|
||||
} else {
|
||||
new ExtentTraverser(this).setNext(new AbstractDelegateExtent(extent));
|
||||
@ -49,7 +52,8 @@ public class ResettableExtent extends AbstractDelegateExtent implements Serializ
|
||||
}
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||
private void readObject(java.io.ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
if (stream.readBoolean()) {
|
||||
try {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.boydti.fawe.object.extent;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
@ -11,16 +10,15 @@ import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ScaleTransform extends ResettableExtent {
|
||||
|
||||
private final double dx, dy, dz;
|
||||
private transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
private transient int maxy;
|
||||
private transient BlockVector3 min;
|
||||
|
||||
private final double dx, dy, dz;
|
||||
|
||||
|
||||
public ScaleTransform(Extent parent, double dx, double dy, double dz) {
|
||||
super(parent);
|
||||
@ -42,9 +40,9 @@ public class ScaleTransform extends ResettableExtent {
|
||||
if (min == null) {
|
||||
min = pos;
|
||||
}
|
||||
mutable.mutX((min.getX() + (pos.getX() - min.getX()) * dx));
|
||||
mutable.mutY((min.getY() + (pos.getY() - min.getY()) * dy));
|
||||
mutable.mutZ((min.getZ() + (pos.getZ() - min.getZ()) * dz));
|
||||
mutable.mutX(min.getX() + (pos.getX() - min.getX()) * dx);
|
||||
mutable.mutY(min.getY() + (pos.getY() - min.getY()) * dy);
|
||||
mutable.mutZ(min.getZ() + (pos.getZ() - min.getZ()) * dz);
|
||||
return mutable;
|
||||
}
|
||||
|
||||
@ -52,15 +50,16 @@ public class ScaleTransform extends ResettableExtent {
|
||||
if (min == null) {
|
||||
min = BlockVector3.at(x, y, z);
|
||||
}
|
||||
mutable.mutX((min.getX() + (x - min.getX()) * dx));
|
||||
mutable.mutY((min.getY() + (y - min.getY()) * dy));
|
||||
mutable.mutZ((min.getZ() + (z - min.getZ()) * dz));
|
||||
mutable.mutX(min.getX() + (x - min.getX()) * dx);
|
||||
mutable.mutY(min.getY() + (y - min.getY()) * dy);
|
||||
mutable.mutZ(min.getZ() + (z - min.getZ()) * dz);
|
||||
return mutable;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block)
|
||||
throws WorldEditException {
|
||||
boolean result = false;
|
||||
MutableBlockVector3 pos = new MutableBlockVector3(getPos(location));
|
||||
double sx = pos.getX();
|
||||
@ -82,7 +81,8 @@ public class ScaleTransform extends ResettableExtent {
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
boolean result = false;
|
||||
MutableBlockVector3 pos = new MutableBlockVector3(getPos(position.getBlockX(), 0, position.getBlockZ()));
|
||||
MutableBlockVector3 pos = new MutableBlockVector3(
|
||||
getPos(position.getBlockX(), 0, position.getBlockZ()));
|
||||
double sx = pos.getX();
|
||||
double sz = pos.getZ();
|
||||
double ex = pos.getX() + dx;
|
||||
@ -96,7 +96,8 @@ public class ScaleTransform extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x1, int y1, int z1, B block) throws WorldEditException {
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x1, int y1, int z1, B block)
|
||||
throws WorldEditException {
|
||||
boolean result = false;
|
||||
MutableBlockVector3 pos = new MutableBlockVector3(getPos(x1, y1, z1));
|
||||
double sx = pos.getX();
|
||||
@ -118,7 +119,9 @@ public class ScaleTransform extends ResettableExtent {
|
||||
@Nullable
|
||||
@Override
|
||||
public Entity createEntity(Location location, BaseEntity entity) {
|
||||
Location newLoc = new Location(location.getExtent(), getPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()).toVector3(), location.getYaw(), location.getPitch());
|
||||
Location newLoc = new Location(location.getExtent(),
|
||||
getPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()).toVector3(),
|
||||
location.getYaw(), location.getPitch());
|
||||
return super.createEntity(newLoc, entity);
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class SelectTransform extends ResettableExtent {
|
||||
|
||||
public SelectTransform() {
|
||||
super(new NullExtent());
|
||||
}
|
||||
@ -31,19 +32,22 @@ public abstract class SelectTransform extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
||||
throws WorldEditException {
|
||||
return getExtent(x, y, z).setBlock(x, y, z, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException {
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block)
|
||||
throws WorldEditException {
|
||||
return getExtent(position).setBlock(position, block);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Entity createEntity(Location position, BaseEntity entity) {
|
||||
return getExtent(position.getBlockX(), position.getBlockY(), position.getBlockZ()).createEntity(position, entity);
|
||||
return getExtent(position.getBlockX(), position.getBlockY(), position.getBlockZ())
|
||||
.createEntity(position, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,7 +61,7 @@ public class TemporalExtent extends PassthroughExtent {
|
||||
if (position.getX() == x && position.getY() == y && position.getZ() == z) {
|
||||
if(block instanceof BaseBlock) {
|
||||
return (BaseBlock)block;
|
||||
}else {
|
||||
} else {
|
||||
return block.toBaseBlock();
|
||||
}
|
||||
}
|
||||
|
@ -93,13 +93,15 @@ public class TransformExtent extends BlockTransformExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
||||
throws WorldEditException {
|
||||
return super.setBlock(getPos(x, y, z), transformInverse(block));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block)
|
||||
throws WorldEditException {
|
||||
return super.setBlock(getPos(location), transformInverse(block));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user