Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-03 01:50:07 +01:00
Some cleanup of mutables
Dieser Commit ist enthalten in:
Ursprung
8928556c1d
Commit
6f5430a940
@ -1,6 +1,5 @@
|
|||||||
package com.fastasyncworldedit.core.extent;
|
package com.fastasyncworldedit.core.extent;
|
||||||
|
|
||||||
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
@ -15,7 +14,6 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
|
|||||||
private final int dx;
|
private final int dx;
|
||||||
private final int dy;
|
private final int dy;
|
||||||
private final int dz;
|
private final int dz;
|
||||||
private final MutableBlockVector3 mutable = new MutableBlockVector3();
|
|
||||||
|
|
||||||
public BlockTranslateExtent(Extent extent, int dx, int dy, int dz) {
|
public BlockTranslateExtent(Extent extent, int dx, int dy, int dz) {
|
||||||
super(extent);
|
super(extent);
|
||||||
@ -26,15 +24,12 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
|
|||||||
|
|
||||||
@Override
|
@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 {
|
||||||
mutable.mutX(location.getX() + dx);
|
return getExtent().setBlock(location.getX(), location.getY(), location.getZ(), block);
|
||||||
mutable.mutY(location.getY() + dy);
|
|
||||||
mutable.mutZ(location.getZ() + dz);
|
|
||||||
return getExtent().setBlock(mutable, block);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 this.setBlock(BlockVector3.at(x, y, z), block);
|
return getExtent().setBlock(x, y, z, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,7 +42,7 @@ public class SourceMaskExtent extends TemporalExtent {
|
|||||||
@Override
|
@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 {
|
||||||
set(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
|
set(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
|
||||||
return mask.test(location) && super.setBlock(location, block);
|
return mask.test(location) && super.setBlock(location.getX(), location.getY(), location.getZ(), block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -167,7 +167,6 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
|
|||||||
}
|
}
|
||||||
Map<String, Object> structure = FaweCache.IMP.asMap("version", 1, "author", owner);
|
Map<String, Object> structure = FaweCache.IMP.asMap("version", 1, "author", owner);
|
||||||
// ignored: version / owner
|
// ignored: version / owner
|
||||||
MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0);
|
|
||||||
Int2ObjectArrayMap<Integer> indexes = new Int2ObjectArrayMap<>();
|
Int2ObjectArrayMap<Integer> indexes = new Int2ObjectArrayMap<>();
|
||||||
// Size
|
// Size
|
||||||
structure.put("size", Arrays.asList(width, height, length));
|
structure.put("size", Arrays.asList(width, height, length));
|
||||||
|
@ -68,6 +68,7 @@ public class ScalableHeightMap implements HeightMap {
|
|||||||
int maxY = clipboard.getMaximumPoint().getBlockY();
|
int maxY = clipboard.getMaximumPoint().getBlockY();
|
||||||
int clipHeight = maxY - minY + 1;
|
int clipHeight = maxY - minY + 1;
|
||||||
HashSet<IntPair> visited = new HashSet<>();
|
HashSet<IntPair> visited = new HashSet<>();
|
||||||
|
MutableBlockVector3 bv = new MutableBlockVector3();
|
||||||
for (BlockVector3 pos : clipboard.getRegion()) {
|
for (BlockVector3 pos : clipboard.getRegion()) {
|
||||||
IntPair pair = new IntPair(pos.getBlockX(), pos.getBlockZ());
|
IntPair pair = new IntPair(pos.getBlockX(), pos.getBlockZ());
|
||||||
if (visited.contains(pair)) {
|
if (visited.contains(pair)) {
|
||||||
@ -77,7 +78,7 @@ public class ScalableHeightMap implements HeightMap {
|
|||||||
int xx = pos.getBlockX();
|
int xx = pos.getBlockX();
|
||||||
int zz = pos.getBlockZ();
|
int zz = pos.getBlockZ();
|
||||||
int highestY = minY;
|
int highestY = minY;
|
||||||
MutableBlockVector3 bv = new MutableBlockVector3(pos);
|
bv.setComponents(pos);
|
||||||
for (int y = minY; y <= maxY; y++) {
|
for (int y = minY; y <= maxY; y++) {
|
||||||
bv.mutY(y);
|
bv.mutY(y);
|
||||||
BlockState block = clipboard.getBlock(bv);
|
BlockState block = clipboard.getBlock(bv);
|
||||||
|
@ -807,6 +807,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
if (current != 0 && current < currentLight) {
|
if (current != 0 && current < currentLight) {
|
||||||
iChunk.setBlockLight(x, y, z, 0);
|
iChunk.setBlockLight(x, y, z, 0);
|
||||||
if (current > 1) {
|
if (current > 1) {
|
||||||
|
mutableBlockPos.setComponents(x, y, z);
|
||||||
if (!visited.containsKey(mutableBlockPos)) {
|
if (!visited.containsKey(mutableBlockPos)) {
|
||||||
MutableBlockVector3 index = new MutableBlockVector3(x, y, z);
|
MutableBlockVector3 index = new MutableBlockVector3(x, y, z);
|
||||||
visited.put(index, present);
|
visited.put(index, present);
|
||||||
|
@ -39,24 +39,22 @@ public class ScaleTransform extends ResettableExtent {
|
|||||||
return super.setExtent(extent);
|
return super.setExtent(extent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlockVector3 getPos(BlockVector3 pos) {
|
private void getPos(BlockVector3 pos) {
|
||||||
if (min == null) {
|
if (min == null) {
|
||||||
min = pos;
|
min = pos;
|
||||||
}
|
}
|
||||||
mutable.mutX(min.getX() + (pos.getX() - min.getX()) * dx);
|
mutable.mutX(min.getX() + (pos.getX() - min.getX()) * dx);
|
||||||
mutable.mutY(min.getY() + (pos.getY() - min.getY()) * dy);
|
mutable.mutY(min.getY() + (pos.getY() - min.getY()) * dy);
|
||||||
mutable.mutZ(min.getZ() + (pos.getZ() - min.getZ()) * dz);
|
mutable.mutZ(min.getZ() + (pos.getZ() - min.getZ()) * dz);
|
||||||
return mutable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlockVector3 getPos(int x, int y, int z) {
|
private void getPos(int x, int y, int z) {
|
||||||
if (min == null) {
|
if (min == null) {
|
||||||
min = BlockVector3.at(x, y, z);
|
min = BlockVector3.at(x, y, z);
|
||||||
}
|
}
|
||||||
mutable.mutX(min.getX() + (x - min.getX()) * dx);
|
mutable.mutX(min.getX() + (x - min.getX()) * dx);
|
||||||
mutable.mutY(min.getY() + (y - min.getY()) * dy);
|
mutable.mutY(min.getY() + (y - min.getY()) * dy);
|
||||||
mutable.mutZ(min.getZ() + (z - min.getZ()) * dz);
|
mutable.mutZ(min.getZ() + (z - min.getZ()) * dz);
|
||||||
return mutable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -64,17 +62,17 @@ public class ScaleTransform extends ResettableExtent {
|
|||||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block)
|
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block)
|
||||||
throws WorldEditException {
|
throws WorldEditException {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
MutableBlockVector3 pos = new MutableBlockVector3(getPos(location));
|
getPos(location);
|
||||||
double sx = pos.getX();
|
double sx = mutable.getX();
|
||||||
double sy = pos.getY();
|
double sy = mutable.getY();
|
||||||
double sz = pos.getZ();
|
double sz = mutable.getZ();
|
||||||
double ex = sx + dx;
|
double ex = sx + dx;
|
||||||
double ey = Math.min(maxy, sy + dy);
|
double ey = Math.min(maxy, sy + dy);
|
||||||
double ez = sz + dz;
|
double ez = sz + dz;
|
||||||
for (pos.mutY(sy); pos.getY() < ey; pos.mutY(pos.getY() + 1)) {
|
for (mutable.mutY(sy); mutable.getY() < ey; mutable.mutY(mutable.getY() + 1)) {
|
||||||
for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) {
|
for (mutable.mutZ(sz); mutable.getZ() < ez; mutable.mutZ(mutable.getZ() + 1)) {
|
||||||
for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) {
|
for (mutable.mutX(sx); mutable.getX() < ex; mutable.mutX(mutable.getX() + 1)) {
|
||||||
result |= super.setBlock(pos, block);
|
result |= super.setBlock(mutable, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,17 +82,17 @@ public class ScaleTransform extends ResettableExtent {
|
|||||||
@Override
|
@Override
|
||||||
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
public boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
MutableBlockVector3 pos = new MutableBlockVector3(getPos(position));
|
getPos(position);
|
||||||
double sx = pos.getX();
|
double sx = mutable.getX();
|
||||||
double sy = pos.getY();
|
double sy = mutable.getY();
|
||||||
double sz = pos.getZ();
|
double sz = mutable.getZ();
|
||||||
double ex = sx + dx;
|
double ex = sx + dx;
|
||||||
double ey = Math.min(maxy, sy + dy);
|
double ey = Math.min(maxy, sy + dy);
|
||||||
double ez = sz + dz;
|
double ez = sz + dz;
|
||||||
for (pos.mutY(sy); pos.getY() < ey; pos.mutY(pos.getY() + 1)) {
|
for (mutable.mutY(sy); mutable.getY() < ey; mutable.mutY(mutable.getY() + 1)) {
|
||||||
for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) {
|
for (mutable.mutZ(sz); mutable.getZ() < ez; mutable.mutZ(mutable.getZ() + 1)) {
|
||||||
for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) {
|
for (mutable.mutX(sx); mutable.getX() < ex; mutable.mutX(mutable.getX() + 1)) {
|
||||||
result |= super.setBiome(pos, biome);
|
result |= super.setBiome(mutable, biome);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,17 +103,17 @@ public class ScaleTransform extends ResettableExtent {
|
|||||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x1, int y1, int z1, B block)
|
public <B extends BlockStateHolder<B>> boolean setBlock(int x1, int y1, int z1, B block)
|
||||||
throws WorldEditException {
|
throws WorldEditException {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
MutableBlockVector3 pos = new MutableBlockVector3(getPos(x1, y1, z1));
|
getPos(x1, y1, z1);
|
||||||
double sx = pos.getX();
|
double sx = mutable.getX();
|
||||||
double sy = pos.getY();
|
double sy = mutable.getY();
|
||||||
double sz = pos.getZ();
|
double sz = mutable.getZ();
|
||||||
double ex = pos.getX() + dx;
|
double ex = mutable.getX() + dx;
|
||||||
double ey = Math.min(maxy, sy + dy);
|
double ey = Math.min(maxy, sy + dy);
|
||||||
double ez = pos.getZ() + dz;
|
double ez = mutable.getZ() + dz;
|
||||||
for (pos.mutY(sy); pos.getY() < ey; pos.mutY(pos.getY() + 1)) {
|
for (mutable.mutY(sy); mutable.getY() < ey; mutable.mutY(mutable.getY() + 1)) {
|
||||||
for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) {
|
for (mutable.mutZ(sz); mutable.getZ() < ez; mutable.mutZ(mutable.getZ() + 1)) {
|
||||||
for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) {
|
for (mutable.mutX(sx); mutable.getX() < ex; mutable.mutX(mutable.getX() + 1)) {
|
||||||
result |= super.setBlock(pos, block);
|
result |= super.setBlock(mutable, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,8 +123,9 @@ public class ScaleTransform extends ResettableExtent {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Entity createEntity(Location location, BaseEntity entity) {
|
public Entity createEntity(Location location, BaseEntity entity) {
|
||||||
|
getPos(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||||
Location newLoc = new Location(location.getExtent(),
|
Location newLoc = new Location(location.getExtent(),
|
||||||
getPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()).toVector3(),
|
mutable.toVector3(),
|
||||||
location.getYaw(), location.getPitch()
|
location.getYaw(), location.getPitch()
|
||||||
);
|
);
|
||||||
return super.createEntity(newLoc, entity);
|
return super.createEntity(newLoc, entity);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.fastasyncworldedit.core.function.mask;
|
package com.fastasyncworldedit.core.function.mask;
|
||||||
|
|
||||||
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||||
@ -21,8 +20,6 @@ public class AngleMask extends SolidBlockMask implements ResettableMask {
|
|||||||
protected final int maxY;
|
protected final int maxY;
|
||||||
protected final int distance;
|
protected final int distance;
|
||||||
|
|
||||||
protected transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
|
||||||
|
|
||||||
public AngleMask(Extent extent, double min, double max, boolean overlay, int distance) {
|
public AngleMask(Extent extent, double min, double max, boolean overlay, int distance) {
|
||||||
super(extent);
|
super(extent);
|
||||||
this.mask = new CachedMask(new SolidBlockMask(extent));
|
this.mask = new CachedMask(new SolidBlockMask(extent));
|
||||||
@ -36,7 +33,6 @@ public class AngleMask extends SolidBlockMask implements ResettableMask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
mutable = new MutableBlockVector3();
|
|
||||||
cacheBotX = Integer.MIN_VALUE;
|
cacheBotX = Integer.MIN_VALUE;
|
||||||
cacheBotZ = Integer.MIN_VALUE;
|
cacheBotZ = Integer.MIN_VALUE;
|
||||||
lastX = Integer.MIN_VALUE;
|
lastX = Integer.MIN_VALUE;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.fastasyncworldedit.core.function.pattern;
|
package com.fastasyncworldedit.core.function.pattern;
|
||||||
|
|
||||||
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
@ -20,10 +19,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
public class RandomFullClipboardPattern extends AbstractPattern {
|
public class RandomFullClipboardPattern extends AbstractPattern {
|
||||||
|
|
||||||
private final Extent extent;
|
private final Extent extent;
|
||||||
private final MutableBlockVector3 mutable = new MutableBlockVector3();
|
|
||||||
private final List<ClipboardHolder> clipboards;
|
private final List<ClipboardHolder> clipboards;
|
||||||
private final boolean randomRotate;
|
private final boolean randomRotate;
|
||||||
private final boolean randomFlip;
|
private final boolean randomFlip;
|
||||||
|
private final Vector3 flipVector = Vector3.at(1, 0, 0).multiply(-2).add(1, 1, 1);
|
||||||
|
|
||||||
public RandomFullClipboardPattern(Extent extent, List<ClipboardHolder> clipboards, boolean randomRotate, boolean randomFlip) {
|
public RandomFullClipboardPattern(Extent extent, List<ClipboardHolder> clipboards, boolean randomRotate, boolean randomFlip) {
|
||||||
checkNotNull(clipboards);
|
checkNotNull(clipboards);
|
||||||
@ -42,7 +41,7 @@ public class RandomFullClipboardPattern extends AbstractPattern {
|
|||||||
holder.setTransform(new AffineTransform().rotateY(ThreadLocalRandom.current().nextInt(4) * 90));
|
holder.setTransform(new AffineTransform().rotateY(ThreadLocalRandom.current().nextInt(4) * 90));
|
||||||
}
|
}
|
||||||
if (randomFlip) {
|
if (randomFlip) {
|
||||||
transform = transform.scale(Vector3.at(1, 0, 0).multiply(-2).add(1, 1, 1));
|
transform = transform.scale(flipVector);
|
||||||
}
|
}
|
||||||
if (!transform.isIdentity()) {
|
if (!transform.isIdentity()) {
|
||||||
holder.setTransform(transform);
|
holder.setTransform(transform);
|
||||||
|
@ -36,9 +36,9 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern {
|
|||||||
|
|
||||||
private BlockVector3 travel(BlockVector3 pos) {
|
private BlockVector3 travel(BlockVector3 pos) {
|
||||||
cur.setComponents(pos);
|
cur.setComponents(pos);
|
||||||
|
MutableBlockVector3 next;
|
||||||
for (int move = 0; move < moves; move++) {
|
for (int move = 0; move < moves; move++) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
MutableBlockVector3 next;
|
|
||||||
for (int i = 0; i < allowed.length; i++) {
|
for (int i = 0; i < allowed.length; i++) {
|
||||||
next = buffer[i];
|
next = buffer[i];
|
||||||
BlockVector3 dir = BreadthFirstSearch.DIAGONAL_DIRECTIONS[i];
|
BlockVector3 dir = BreadthFirstSearch.DIAGONAL_DIRECTIONS[i];
|
||||||
|
@ -26,7 +26,7 @@ public class BlockVector3ChunkMap<T> implements IAdaptedMap<BlockVector3, T, Sho
|
|||||||
int x = MathMan.untripleBlockCoordX(key);
|
int x = MathMan.untripleBlockCoordX(key);
|
||||||
int y = MathMan.untripleBlockCoordY(key);
|
int y = MathMan.untripleBlockCoordY(key);
|
||||||
int z = MathMan.untripleBlockCoordZ(key);
|
int z = MathMan.untripleBlockCoordZ(key);
|
||||||
return MutableBlockVector3.get(x, y, z);
|
return BlockVector3.at(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -309,7 +309,6 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
public void forEach(BlockVectorSetVisitor visitor) {
|
public void forEach(BlockVectorSetVisitor visitor) {
|
||||||
int size = size();
|
int size = size();
|
||||||
int index = -1;
|
int index = -1;
|
||||||
BlockVector3 mVec = MutableBlockVector3.get(0, 0, 0);
|
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
index = set.nextSetBit(index + 1);
|
index = set.nextSetBit(index + 1);
|
||||||
int b1 = (index & 0xFF);
|
int b1 = (index & 0xFF);
|
||||||
|
@ -2079,7 +2079,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
int px = mutableBlockVector3.getBlockX();
|
int px = mutableBlockVector3.getBlockX();
|
||||||
int py = mutableBlockVector3.getBlockY();
|
int py = mutableBlockVector3.getBlockY();
|
||||||
int pz = mutableBlockVector3.getBlockZ();
|
int pz = mutableBlockVector3.getBlockZ();
|
||||||
MutableBlockVector3 mutable = new MutableBlockVector3();
|
|
||||||
|
|
||||||
final int ceilRadiusX = (int) Math.ceil(radiusX);
|
final int ceilRadiusX = (int) Math.ceil(radiusX);
|
||||||
final int ceilRadiusZ = (int) Math.ceil(radiusZ);
|
final int ceilRadiusZ = (int) Math.ceil(radiusZ);
|
||||||
@ -2122,10 +2121,10 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int y = 0; y < height; ++y) {
|
for (int y = 0; y < height; ++y) {
|
||||||
this.setBlock(mutable.setComponents(px + x, py + y, pz + z), block);
|
this.setBlock(mutableBlockVector3.setComponents(px + x, py + y, pz + z), block);
|
||||||
this.setBlock(mutable.setComponents(px - x, py + y, pz + z), block);
|
this.setBlock(mutableBlockVector3.setComponents(px - x, py + y, pz + z), block);
|
||||||
this.setBlock(mutable.setComponents(px + x, py + y, pz - z), block);
|
this.setBlock(mutableBlockVector3.setComponents(px + x, py + y, pz - z), block);
|
||||||
this.setBlock(mutable.setComponents(px - x, py + y, pz - z), block);
|
this.setBlock(mutableBlockVector3.setComponents(px - x, py + y, pz - z), block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2158,10 +2157,10 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
|
|
||||||
for (int y = 0; y < height; ++y) {
|
for (int y = 0; y < height; ++y) {
|
||||||
//FAWE start - mutable
|
//FAWE start - mutable
|
||||||
this.setBlock(mutable.setComponents(px + x, py + y, pz + z), block);
|
this.setBlock(mutableBlockVector3.setComponents(px + x, py + y, pz + z), block);
|
||||||
this.setBlock(mutable.setComponents(px - x, py + y, pz + z), block);
|
this.setBlock(mutableBlockVector3.setComponents(px - x, py + y, pz + z), block);
|
||||||
this.setBlock(mutable.setComponents(px + x, py + y, pz - z), block);
|
this.setBlock(mutableBlockVector3.setComponents(px + x, py + y, pz - z), block);
|
||||||
this.setBlock(mutable.setComponents(px - x, py + y, pz - z), block);
|
this.setBlock(mutableBlockVector3.setComponents(px - x, py + y, pz - z), block);
|
||||||
//FAWE end
|
//FAWE end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,10 +213,11 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default int getHighestTerrainBlock(final int x, final int z, int minY, int maxY, Mask filter) {
|
default int getHighestTerrainBlock(final int x, final int z, int minY, int maxY, Mask filter) {
|
||||||
maxY = Math.min(maxY, Math.max(0, maxY));
|
maxY = Math.min(maxY, getMaxY());
|
||||||
minY = Math.max(0, minY);
|
minY = Math.max(getMinY(), minY);
|
||||||
|
BlockVector3 pos = MutableBlockVector3.at(x, minY, z);
|
||||||
for (int y = maxY; y >= minY; --y) {
|
for (int y = maxY; y >= minY; --y) {
|
||||||
if (filter.test(MutableBlockVector3.get(x, y, z))) {
|
if (filter.test(pos.mutY(y))) {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -286,28 +287,29 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
int clearanceAbove = maxY - y;
|
int clearanceAbove = maxY - y;
|
||||||
int clearanceBelow = y - minY;
|
int clearanceBelow = y - minY;
|
||||||
int clearance = Math.min(clearanceAbove, clearanceBelow);
|
int clearance = Math.min(clearanceAbove, clearanceBelow);
|
||||||
boolean state = !mask.test(MutableBlockVector3.get(x, y, z));
|
BlockVector3 pos = MutableBlockVector3.get(x, y, z);
|
||||||
|
boolean state = !mask.test(pos);
|
||||||
int offset = state ? 0 : 1;
|
int offset = state ? 0 : 1;
|
||||||
for (int d = 0; d <= clearance; d++) {
|
for (int d = 0; d <= clearance; d++) {
|
||||||
int y1 = y + d;
|
int y1 = y + d;
|
||||||
if (mask.test(MutableBlockVector3.get(x, y1, z)) != state) {
|
if (mask.test(pos.mutY(y1)) != state) {
|
||||||
return y1 - offset;
|
return y1 - offset;
|
||||||
}
|
}
|
||||||
int y2 = y - d;
|
int y2 = y - d;
|
||||||
if (mask.test(MutableBlockVector3.get(x, y2, z)) != state) {
|
if (mask.test(pos.mutY(y2)) != state) {
|
||||||
return y2 + offset;
|
return y2 + offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (clearanceAbove != clearanceBelow) {
|
if (clearanceAbove != clearanceBelow) {
|
||||||
if (clearanceAbove < clearanceBelow) {
|
if (clearanceAbove < clearanceBelow) {
|
||||||
for (int layer = y - clearance - 1; layer >= minY; layer--) {
|
for (int layer = y - clearance - 1; layer >= minY; layer--) {
|
||||||
if (mask.test(MutableBlockVector3.get(x, layer, z)) != state) {
|
if (mask.test(pos.mutY(layer)) != state) {
|
||||||
return layer + offset;
|
return layer + offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int layer = y + clearance + 1; layer <= maxY; layer++) {
|
for (int layer = y + clearance + 1; layer <= maxY; layer++) {
|
||||||
if (mask.test(MutableBlockVector3.get(x, layer, z)) != state) {
|
if (mask.test(pos.mutY(layer)) != state) {
|
||||||
return layer - offset;
|
return layer - offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
*/
|
*/
|
||||||
public class NoiseFilter extends AbstractMask {
|
public class NoiseFilter extends AbstractMask {
|
||||||
|
|
||||||
|
//FAWE start - mutable
|
||||||
|
private MutableVector3 mutable;
|
||||||
|
//FAWE end
|
||||||
private NoiseGenerator noiseGenerator;
|
private NoiseGenerator noiseGenerator;
|
||||||
private double density;
|
private double density;
|
||||||
|
|
||||||
@ -65,6 +68,9 @@ public class NoiseFilter extends AbstractMask {
|
|||||||
public void setNoiseGenerator(NoiseGenerator noiseGenerator) {
|
public void setNoiseGenerator(NoiseGenerator noiseGenerator) {
|
||||||
checkNotNull(noiseGenerator);
|
checkNotNull(noiseGenerator);
|
||||||
this.noiseGenerator = noiseGenerator;
|
this.noiseGenerator = noiseGenerator;
|
||||||
|
//FAWE start - mutable
|
||||||
|
this.mutable = new MutableVector3();
|
||||||
|
//FAWE end
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,11 +89,16 @@ public class NoiseFilter extends AbstractMask {
|
|||||||
checkArgument(density >= 0, "density must be >= 0");
|
checkArgument(density >= 0, "density must be >= 0");
|
||||||
checkArgument(density <= 1, "density must be <= 1");
|
checkArgument(density <= 1, "density must be <= 1");
|
||||||
this.density = density;
|
this.density = density;
|
||||||
|
//FAWE start - mutable
|
||||||
|
this.mutable = new MutableVector3();
|
||||||
|
//FAWE end
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return noiseGenerator.noise(MutableVector3.get(vector.getX(), vector.getY(), vector.getZ())) <= density;
|
//FAWE start - mutable
|
||||||
|
return noiseGenerator.noise(mutable.setComponents(vector.getX(), vector.getZ(), vector.getZ())) <= density;
|
||||||
|
//FAWE end
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren