mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-10 17:58:36 +00:00
Javadoc and Formatting fixes. (#619)
Javadoc and Formatting fixes. Also, extremely minor code changes which have been tested. This commit is only part one of two commits that aim to fix problems with formatting in our project. In part two I will modify the Google Java Style Guide (since it closely matches our code style) for our project so there is guidance on how to format and document. * Updated PlotSquared URL * Removed plugin acronyms * Fixed a typo * Fixed grammar * Use modern block id's * Update YouTube video URL
This commit is contained in:
@ -42,7 +42,9 @@ public class DataAnglePattern extends AbstractPattern {
|
||||
public BaseBlock apply(BlockVector3 position) {
|
||||
BlockState block = extent.getBlock(position);
|
||||
int slope = getSlope(block, position, extent);
|
||||
if (slope == -1) return block.toBaseBlock();
|
||||
if (slope == -1) {
|
||||
return block.toBaseBlock();
|
||||
}
|
||||
int data = Math.min(slope, 255) >> 4;
|
||||
return block.withPropertyId(data).toBaseBlock();
|
||||
}
|
||||
@ -51,7 +53,9 @@ public class DataAnglePattern extends AbstractPattern {
|
||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
||||
BlockState block = extent.getBlock(getPosition);
|
||||
int slope = getSlope(block, getPosition, extent);
|
||||
if (slope == -1) return false;
|
||||
if (slope == -1) {
|
||||
return false;
|
||||
}
|
||||
int data = Math.min(slope, 255) >> 4;
|
||||
return extent.setBlock(setPosition, block.withPropertyId(data));
|
||||
}
|
||||
|
@ -136,72 +136,100 @@ public class FaweLimit {
|
||||
}
|
||||
|
||||
public void THROW_MAX_CHANGES() {
|
||||
if (MAX_CHANGES-- <= 0) throw FaweCache.MAX_CHANGES;
|
||||
if (MAX_CHANGES-- <= 0) {
|
||||
throw FaweCache.MAX_CHANGES;
|
||||
}
|
||||
}
|
||||
|
||||
public void THROW_MAX_FAILS() {
|
||||
if (MAX_FAILS-- <= 0) throw FaweCache.MAX_CHECKS;
|
||||
if (MAX_FAILS-- <= 0) {
|
||||
throw FaweCache.MAX_CHECKS;
|
||||
}
|
||||
}
|
||||
|
||||
public void THROW_MAX_CHECKS() {
|
||||
if (MAX_CHECKS-- <= 0) throw FaweCache.MAX_CHECKS;
|
||||
if (MAX_CHECKS-- <= 0) {
|
||||
throw FaweCache.MAX_CHECKS;
|
||||
}
|
||||
}
|
||||
|
||||
public void THROW_MAX_ITERATIONS() {
|
||||
if (MAX_ITERATIONS-- <= 0) throw FaweCache.MAX_ITERATIONS;
|
||||
if (MAX_ITERATIONS-- <= 0) {
|
||||
throw FaweCache.MAX_ITERATIONS;
|
||||
}
|
||||
}
|
||||
|
||||
public void THROW_MAX_BLOCKSTATES() {
|
||||
if (MAX_BLOCKSTATES-- <= 0) throw FaweCache.MAX_TILES;
|
||||
if (MAX_BLOCKSTATES-- <= 0) {
|
||||
throw FaweCache.MAX_TILES;
|
||||
}
|
||||
}
|
||||
|
||||
public void THROW_MAX_ENTITIES() {
|
||||
if (MAX_ENTITIES-- <= 0) throw FaweCache.MAX_ENTITIES;
|
||||
if (MAX_ENTITIES-- <= 0) {
|
||||
throw FaweCache.MAX_ENTITIES;
|
||||
}
|
||||
}
|
||||
|
||||
public void THROW_MAX_CHANGES(int amt) {
|
||||
if ((MAX_CHANGES -= amt) <= 0) throw FaweCache.MAX_CHANGES;
|
||||
if ((MAX_CHANGES -= amt) <= 0) {
|
||||
throw FaweCache.MAX_CHANGES;
|
||||
}
|
||||
}
|
||||
public void THROW_MAX_CHANGES(long amt) {
|
||||
if ((MAX_CHANGES -= amt) <= 0) throw FaweCache.MAX_CHANGES;
|
||||
if ((MAX_CHANGES -= amt) <= 0) {
|
||||
throw FaweCache.MAX_CHANGES;
|
||||
}
|
||||
}
|
||||
|
||||
public void THROW_MAX_FAILS(int amt) {
|
||||
if ((MAX_FAILS -= amt) <= 0) throw FaweCache.MAX_CHECKS;
|
||||
if ((MAX_FAILS -= amt) <= 0) {
|
||||
throw FaweCache.MAX_CHECKS;
|
||||
}
|
||||
}
|
||||
|
||||
public void THROW_MAX_CHECKS(int amt) {
|
||||
if ((MAX_CHECKS -= amt) <= 0) throw FaweCache.MAX_CHECKS;
|
||||
if ((MAX_CHECKS -= amt) <= 0) {
|
||||
throw FaweCache.MAX_CHECKS;
|
||||
}
|
||||
}
|
||||
|
||||
public void THROW_MAX_CHECKS(long amt) {
|
||||
if ((MAX_CHECKS -= amt) <= 0) throw FaweCache.MAX_CHECKS;
|
||||
if ((MAX_CHECKS -= amt) <= 0) {
|
||||
throw FaweCache.MAX_CHECKS;
|
||||
}
|
||||
}
|
||||
|
||||
public void THROW_MAX_ITERATIONS(int amt) {
|
||||
if ((MAX_ITERATIONS -= amt) <= 0) throw FaweCache.MAX_ITERATIONS;
|
||||
if ((MAX_ITERATIONS -= amt) <= 0) {
|
||||
throw FaweCache.MAX_ITERATIONS;
|
||||
}
|
||||
}
|
||||
|
||||
public void THROW_MAX_BLOCKSTATES(int amt) {
|
||||
if ((MAX_BLOCKSTATES -= amt) <= 0) throw FaweCache.MAX_TILES;
|
||||
if ((MAX_BLOCKSTATES -= amt) <= 0) {
|
||||
throw FaweCache.MAX_TILES;
|
||||
}
|
||||
}
|
||||
|
||||
public void THROW_MAX_ENTITIES(int amt) {
|
||||
if ((MAX_ENTITIES -= amt) <= 0) throw FaweCache.MAX_ENTITIES;
|
||||
if ((MAX_ENTITIES -= amt) <= 0) {
|
||||
throw FaweCache.MAX_ENTITIES;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isUnlimited() {
|
||||
return MAX_CHANGES == Integer.MAX_VALUE &&
|
||||
MAX_FAILS == Integer.MAX_VALUE &&
|
||||
MAX_CHECKS == Integer.MAX_VALUE &&
|
||||
MAX_ITERATIONS == Integer.MAX_VALUE &&
|
||||
MAX_BLOCKSTATES == Integer.MAX_VALUE &&
|
||||
MAX_ENTITIES == Integer.MAX_VALUE &&
|
||||
MAX_HISTORY == Integer.MAX_VALUE &&
|
||||
INVENTORY_MODE == 0 &&
|
||||
SPEED_REDUCTION == 0 &&
|
||||
FAST_PLACEMENT &&
|
||||
(STRIP_NBT == null || STRIP_NBT.isEmpty());
|
||||
return MAX_CHANGES == Integer.MAX_VALUE
|
||||
&& MAX_FAILS == Integer.MAX_VALUE
|
||||
&& MAX_CHECKS == Integer.MAX_VALUE
|
||||
&& MAX_ITERATIONS == Integer.MAX_VALUE
|
||||
&& MAX_BLOCKSTATES == Integer.MAX_VALUE
|
||||
&& MAX_ENTITIES == Integer.MAX_VALUE
|
||||
&& MAX_HISTORY == Integer.MAX_VALUE
|
||||
&& INVENTORY_MODE == 0
|
||||
&& SPEED_REDUCTION == 0
|
||||
&& FAST_PLACEMENT
|
||||
&& (STRIP_NBT == null || STRIP_NBT.isEmpty());
|
||||
}
|
||||
|
||||
public void set(FaweLimit limit) {
|
||||
|
@ -5,7 +5,7 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
|
||||
@Deprecated
|
||||
public class RegionWrapper extends CuboidRegion {
|
||||
private final static RegionWrapper GLOBAL = new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||
private static final RegionWrapper GLOBAL = new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||
|
||||
public int minX;
|
||||
public int maxX;
|
||||
|
@ -21,7 +21,6 @@ public class BlendBall implements Brush {
|
||||
int ty = position.getBlockY();
|
||||
int tz = position.getBlockZ();
|
||||
|
||||
// Map<BlockState, Integer> frequency = Maps.newHashMap();
|
||||
int[] frequency = new int[BlockTypes.size()];
|
||||
|
||||
int maxY = editSession.getMaximumPoint().getBlockY();
|
||||
|
@ -64,9 +64,9 @@ public class BlobBrush implements Brush {
|
||||
}
|
||||
} else {
|
||||
AffineTransform transform = new AffineTransform()
|
||||
.rotateX(ThreadLocalRandom.current().nextInt(360))
|
||||
.rotateY(ThreadLocalRandom.current().nextInt(360))
|
||||
.rotateZ(ThreadLocalRandom.current().nextInt(360));
|
||||
.rotateX(ThreadLocalRandom.current().nextInt(360))
|
||||
.rotateY(ThreadLocalRandom.current().nextInt(360))
|
||||
.rotateZ(ThreadLocalRandom.current().nextInt(360));
|
||||
|
||||
double manScaleX = 1.25 + seedX * 0.5;
|
||||
double manScaleY = 1.25 + seedY * 0.5;
|
||||
@ -93,9 +93,7 @@ public class BlobBrush implements Brush {
|
||||
double manDist = xScaled + yScaled + zScaled;
|
||||
double distSqr = x * x * modX + z * z * modZ + y * y * modY;
|
||||
|
||||
double distance =
|
||||
Math.sqrt(distSqr) * sphericity +
|
||||
MathMan.max(manDist, xScaled * manScaleX, yScaled * manScaleY, zScaled * manScaleZ) * roughness;
|
||||
double distance = Math.sqrt(distSqr) * sphericity + MathMan.max(manDist, xScaled * manScaleX, yScaled * manScaleY, zScaled * manScaleZ) * roughness;
|
||||
|
||||
double noise = this.amplitude * SimplexNoise.noise(seedX + x * distort, seedZ + z * distort, seedZ + z * distort);
|
||||
if (distance + distance * noise < radius) {
|
||||
|
@ -6,6 +6,7 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
@ -17,7 +18,9 @@ import java.util.List;
|
||||
|
||||
public class CatenaryBrush implements Brush, ResettableTool {
|
||||
|
||||
private final boolean shell, select, direction;
|
||||
private final boolean shell;
|
||||
private final boolean select;
|
||||
private final boolean direction;
|
||||
private final double slack;
|
||||
|
||||
private BlockVector3 pos1;
|
||||
@ -34,21 +37,25 @@ public class CatenaryBrush implements Brush, ResettableTool {
|
||||
@Override
|
||||
public void build(EditSession editSession, BlockVector3 pos2, final Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
boolean visual = editSession.getExtent() instanceof VisualExtent;
|
||||
Player player = editSession.getPlayer();
|
||||
if (player == null) {
|
||||
return; //todo throw error
|
||||
}
|
||||
if (pos1 == null || pos2.equals(pos1)) {
|
||||
if (!visual) {
|
||||
pos1 = pos2;
|
||||
editSession.getPlayer().print(Caption.of("fawe.worldedit.brush.brush.line.primary", pos2));
|
||||
player.print(Caption.of("fawe.worldedit.brush.brush.line.primary", pos2));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (this.vertex == null) {
|
||||
vertex = getVertex(pos1.toVector3(), pos2.toVector3(), slack);
|
||||
if (this.direction) {
|
||||
editSession.getPlayer().print(Caption.of("fawe.worldedit.brush.brush.catenary.direction", 2));
|
||||
player.print(Caption.of("fawe.worldedit.brush.brush.catenary.direction", 2));
|
||||
return;
|
||||
}
|
||||
} else if (this.direction) {
|
||||
Location loc = editSession.getPlayer().getLocation();
|
||||
Location loc = player.getLocation();
|
||||
Vector3 facing = loc.getDirection().normalize();
|
||||
BlockVector3 midpoint = pos1.add(pos2).divide(2);
|
||||
BlockVector3 offset = midpoint.subtract(vertex);
|
||||
@ -62,7 +69,7 @@ public class CatenaryBrush implements Brush, ResettableTool {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (!visual) {
|
||||
editSession.getPlayer().print(TranslatableComponent.of("fawe.worldedit.brush.brush.line.secondary"));
|
||||
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.line.secondary"));
|
||||
if (!select) {
|
||||
pos1 = null;
|
||||
return;
|
||||
@ -78,7 +85,9 @@ public class CatenaryBrush implements Brush, ResettableTool {
|
||||
}
|
||||
|
||||
public static BlockVector3 getVertex(Vector3 pos1, Vector3 pos2, double lenPercent) {
|
||||
if (lenPercent <= 1) return pos1.add(pos2).divide(2).toBlockPoint();
|
||||
if (lenPercent <= 1) {
|
||||
return pos1.add(pos2).divide(2).toBlockPoint();
|
||||
}
|
||||
double curveLen = pos1.distance(pos2) * lenPercent;
|
||||
double dy = pos2.getY() - pos1.getY();
|
||||
double dx = pos2.getX() - pos1.getX();
|
||||
@ -86,8 +95,10 @@ public class CatenaryBrush implements Brush, ResettableTool {
|
||||
double dh = Math.sqrt(dx * dx + dz * dz);
|
||||
double g = Math.sqrt(curveLen * curveLen - dy * dy) / 2;
|
||||
double a = 0.00001;
|
||||
for (;g < a * Math.sinh(dh/(2 * a)); a *= 1.00001);
|
||||
double vertX = (dh-a*Math.log((curveLen + dy)/(curveLen - dy)))/2.0;
|
||||
for (; g < a * Math.sinh(dh / (2 * a)); a *= 1.00001) {
|
||||
;
|
||||
}
|
||||
double vertX = (dh - a * Math.log((curveLen + dy) / (curveLen - dy))) / 2.0;
|
||||
double z = (dh / 2) / a;
|
||||
double oY = (dy - curveLen * (Math.cosh(z) / Math.sinh(z))) / 2;
|
||||
double vertY = a * 1 + oY;
|
||||
|
@ -90,7 +90,7 @@ public class CopyPastaBrush implements Brush, ResettableTool {
|
||||
ClipboardHolder holder = new ClipboardHolder(newClipboard);
|
||||
session.setClipboard(holder);
|
||||
int blocks = builder.size();
|
||||
player.print(Caption.of("fawe.worldedit.copy.command.copy" , blocks));
|
||||
player.print(Caption.of("fawe.worldedit.copy.command.copy", blocks));
|
||||
} else {
|
||||
AffineTransform transform = null;
|
||||
if (randomRotate) {
|
||||
@ -99,7 +99,9 @@ public class CopyPastaBrush implements Brush, ResettableTool {
|
||||
transform = transform.rotateY(rotate);
|
||||
}
|
||||
if (autoRotate) {
|
||||
if (transform == null) transform = new AffineTransform();
|
||||
if (transform == null) {
|
||||
transform = new AffineTransform();
|
||||
}
|
||||
Location loc = player.getLocation();
|
||||
float yaw = loc.getYaw();
|
||||
float pitch = loc.getPitch();
|
||||
|
@ -20,7 +20,10 @@ import java.util.Arrays;
|
||||
public class ErodeBrush implements Brush {
|
||||
|
||||
private static final BlockVector3[] FACES_TO_CHECK = Direction.valuesOf(Direction.Flag.CARDINAL).stream().map(Direction::toBlockVector).toArray(BlockVector3[]::new);
|
||||
private final int erodeFaces, erodeRecursion, fillFaces, fillRecursion;
|
||||
private final int erodeFaces;
|
||||
private final int erodeRecursion;
|
||||
private final int fillFaces;
|
||||
private final int fillRecursion;
|
||||
|
||||
public ErodeBrush() {
|
||||
this(2, 1, 5, 1);
|
||||
|
@ -30,7 +30,9 @@ public class FallingSphere implements Brush {
|
||||
int ax = px + x;
|
||||
|
||||
int remainingY = remaining - xx;
|
||||
if (remainingY < 0) continue;
|
||||
if (remainingY < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int yRadius = MathMan.usqrt(remainingY);
|
||||
int startY = Math.max(0, py - yRadius);
|
||||
|
@ -99,11 +99,19 @@ public class HeightBrush implements Brush {
|
||||
for (int z = minZ; z <= maxZ; z++, zIndex += width) {
|
||||
int zz = bz + z;
|
||||
int index = zIndex + (bx + minX);
|
||||
if (index < minIndex) continue;
|
||||
if (index >= metaHeight.length) break;
|
||||
if (index < minIndex) {
|
||||
continue;
|
||||
}
|
||||
if (index >= metaHeight.length) {
|
||||
break;
|
||||
}
|
||||
for (int x = minX; x <= maxX; x++, index++) {
|
||||
if (index < 0) continue;
|
||||
if (index >= metaHeight.length) break;
|
||||
if (index < 0) {
|
||||
continue;
|
||||
}
|
||||
if (index >= metaHeight.length) {
|
||||
break;
|
||||
}
|
||||
|
||||
int xx = bx + x;
|
||||
int currentBlockHeight = hmmg.getHeight(index);
|
||||
|
@ -76,7 +76,6 @@ public class ImageBrush implements Brush {
|
||||
float yaw = loc.getYaw();
|
||||
float pitch = loc.getPitch();
|
||||
AffineTransform transform = new AffineTransform().rotateY((-yaw) % 360).rotateX((pitch - 90) % 360).inverse();
|
||||
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(
|
||||
new ImageBrushMask(solid, center, transform, scale, centerImageX, centerImageZ, width, height, colorFunction, editSession,
|
||||
session.getTextureUtil()), vector -> true, Integer.MAX_VALUE);
|
||||
|
@ -107,7 +107,7 @@ public class InspectBrush extends BrushTool {
|
||||
player.print(msg);
|
||||
}
|
||||
}
|
||||
player.print(Caption.of("fawe.worldedit.tool.tool.inspect.info.footer" , count));
|
||||
player.print(Caption.of("fawe.worldedit.tool.tool.inspect.info.footer", count));
|
||||
} catch (IOException e) {
|
||||
System.out.println("IOE");
|
||||
throw new RuntimeException(e);
|
||||
|
@ -11,7 +11,9 @@ import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
public class LineBrush implements Brush, ResettableTool {
|
||||
|
||||
private final boolean shell, select, flat;
|
||||
private final boolean shell;
|
||||
private final boolean select;
|
||||
private final boolean flat;
|
||||
private BlockVector3 pos1;
|
||||
|
||||
public LineBrush(boolean shell, boolean select, boolean flat) {
|
||||
|
@ -33,9 +33,9 @@ public class RockBrush implements Brush {
|
||||
|
||||
double distort = this.frequency / size;
|
||||
|
||||
double modX = 1d/radius.getX();
|
||||
double modY = 1d/radius.getY();
|
||||
double modZ = 1d/radius.getZ();
|
||||
double modX = 1D / radius.getX();
|
||||
double modY = 1D / radius.getY();
|
||||
double modZ = 1D / radius.getZ();
|
||||
|
||||
int radiusSqr = (int) (size * size);
|
||||
int sizeInt = (int) size * 2;
|
||||
|
@ -39,10 +39,14 @@ public class SurfaceSpline implements Brush {
|
||||
boolean vis = editSession.getExtent() instanceof VisualExtent;
|
||||
if (path.isEmpty() || !pos.equals(path.get(path.size() - 1))) {
|
||||
int max = editSession.getNearestSurfaceTerrainBlock(pos.getBlockX(), pos.getBlockZ(), pos.getBlockY(), 0, editSession.getMaxY());
|
||||
if (max == -1) return;
|
||||
if (max == -1) {
|
||||
return;
|
||||
}
|
||||
path.add(BlockVector3.at(pos.getBlockX(), max, pos.getBlockZ()));
|
||||
editSession.getPlayer().printInfo(TranslatableComponent.of("fawe.worldedit.brush.spline.primary.2"));
|
||||
if (!vis) return;
|
||||
if (!vis) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
final List<Node> nodes = new ArrayList<>(path.size());
|
||||
final KochanekBartelsInterpolation interpol = new KochanekBartelsInterpolation();
|
||||
@ -64,7 +68,9 @@ public class SurfaceSpline implements Brush {
|
||||
final int tipz = (int) tipv.getZ();
|
||||
int tipy = MathMan.roundInt(tipv.getY());
|
||||
tipy = editSession.getNearestSurfaceTerrainBlock(tipx, tipz, tipy, 0, maxY);
|
||||
if (tipy == -1) continue;
|
||||
if (tipy == -1) {
|
||||
continue;
|
||||
}
|
||||
if (radius == 0) {
|
||||
BlockVector3 set = mutable.setComponents(tipx, tipy, tipz);
|
||||
try {
|
||||
@ -81,19 +87,25 @@ public class SurfaceSpline implements Brush {
|
||||
LocalBlockVectorSet newSet = new LocalBlockVectorSet();
|
||||
final int ceilrad = (int) Math.ceil(radius);
|
||||
for (BlockVector3 v : vset) {
|
||||
final int tipx = v.getBlockX(), tipy = v.getBlockY(), tipz = v.getBlockZ();
|
||||
final int tipx = v.getBlockX();
|
||||
final int tipy = v.getBlockY();
|
||||
final int tipz = v.getBlockZ();
|
||||
for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) {
|
||||
for (int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) {
|
||||
if (MathMan.hypot2(loopx - tipx, 0, loopz - tipz) <= radius2) {
|
||||
int y = editSession.getNearestSurfaceTerrainBlock(loopx, loopz, v.getBlockY(), 0, maxY);
|
||||
if (y == -1) continue;
|
||||
if (y == -1) {
|
||||
continue;
|
||||
}
|
||||
newSet.add(loopx, y, loopz);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
editSession.setBlocks(newSet, pattern);
|
||||
if (!vis) path.clear();
|
||||
if (!vis) {
|
||||
path.clear();
|
||||
}
|
||||
}
|
||||
editSession.getPlayer().printInfo(TranslatableComponent.of("fawe.worldedit.brush.spline.secondary"));
|
||||
}
|
||||
|
@ -4,9 +4,11 @@ public class ArrayHeightMap extends ScalableHeightMap {
|
||||
// The heights
|
||||
private final byte[][] height;
|
||||
// The height map width/length
|
||||
private final int width, length;
|
||||
private final int width;
|
||||
private final int length;
|
||||
// The size to width/length ratio
|
||||
private double rx, rz;
|
||||
private double rx;
|
||||
private double rz;
|
||||
|
||||
public ArrayHeightMap(byte[][] height) {
|
||||
setSize(5);
|
||||
|
@ -13,7 +13,7 @@ import com.sk89q.worldedit.util.Location;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public interface HeightMap {
|
||||
|
||||
|
||||
double getHeight(int x, int z);
|
||||
|
||||
void setSize(int size);
|
||||
@ -89,7 +89,9 @@ public interface HeightMap {
|
||||
height = tmpY = session.getNearestSurfaceLayer(xx, zz, tmpY, 0, maxY);
|
||||
} else {
|
||||
height = tmpY = session.getNearestSurfaceTerrainBlock(xx, zz, tmpY, 0, maxY);
|
||||
if (height == -1) continue;
|
||||
if (height == -1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
oldData[index] = height;
|
||||
if (height == 0) {
|
||||
@ -131,7 +133,9 @@ public interface HeightMap {
|
||||
height = session.getNearestSurfaceLayer(xx, zz, height, 0, maxY);
|
||||
} else {
|
||||
height = session.getNearestSurfaceTerrainBlock(xx, zz, height, 0, maxY);
|
||||
if (height == -1) continue;
|
||||
if (height == -1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
oldData[index] = height;
|
||||
if (height == 0) {
|
||||
|
@ -15,6 +15,7 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public abstract class Scroll implements ScrollTool {
|
||||
private BrushTool tool;
|
||||
@ -32,7 +33,7 @@ public abstract class Scroll implements ScrollTool {
|
||||
|
||||
public static Scroll fromArguments(BrushTool tool, Player player, LocalSession session, String actionArgs, boolean message) {
|
||||
String[] split = actionArgs.split(" ");
|
||||
Action mode = Action.valueOf(split[0].toUpperCase());
|
||||
Action mode = Action.valueOf(split[0].toUpperCase(Locale.ROOT));
|
||||
List<String> args = Arrays.asList(Arrays.copyOfRange(split, 1, split.length));
|
||||
return fromArguments(tool, player, session, mode, args, message);
|
||||
}
|
||||
@ -47,7 +48,9 @@ public abstract class Scroll implements ScrollTool {
|
||||
return null;
|
||||
case CLIPBOARD:
|
||||
if (arguments.size() != 2) {
|
||||
if (message) player.print(Caption.of("fawe.error.command.syntax" , "clipboard [file]"));
|
||||
if (message) {
|
||||
player.print(Caption.of("fawe.error.command.syntax", "clipboard [file]"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
String filename = arguments.get(1);
|
||||
@ -62,7 +65,9 @@ public abstract class Scroll implements ScrollTool {
|
||||
}
|
||||
case MASK:
|
||||
if (arguments.size() < 2) {
|
||||
if (message) player.print(Caption.of("fawe.error.command.syntax" , "mask [mask 1] [mask 2] [mask 3]..."));
|
||||
if (message) {
|
||||
player.print(Caption.of("fawe.error.command.syntax", "mask [mask 1] [mask 2] [mask 3]..."));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
Mask[] masks = new Mask[arguments.size() - 1];
|
||||
@ -73,7 +78,9 @@ public abstract class Scroll implements ScrollTool {
|
||||
return (new ScrollMask(tool, masks));
|
||||
case PATTERN:
|
||||
if (arguments.size() < 2) {
|
||||
if (message) player.print(Caption.of("fawe.error.command.syntax" , "pattern [pattern 1] [pattern 2] [pattern 3]..."));
|
||||
if (message) {
|
||||
player.print(Caption.of("fawe.error.command.syntax", "pattern [pattern 1] [pattern 2] [pattern 3]..."));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
Pattern[] patterns = new Pattern[arguments.size() - 1];
|
||||
|
@ -33,34 +33,44 @@ public class ClipboardSpline extends Spline {
|
||||
private LocalBlockVectorSet buffer;
|
||||
|
||||
/**
|
||||
* Constructor without position-correction. Use this constructor for an interpolation implementation which does not need position-correction.
|
||||
* <p>
|
||||
* Be advised that currently subsequent changes to the interpolation parameters may not be supported.
|
||||
* @param editSession The EditSession which will be used when pasting the clipboard content
|
||||
* Constructor without position-correction. Use this constructor for an interpolation
|
||||
* implementation which does not need position-correction.
|
||||
*
|
||||
* @param editSession The EditSession which will be used when pasting the clipboard content
|
||||
* @param clipboardHolder The clipboard that will be pasted along the spline
|
||||
* @param interpolation An implementation of the interpolation algorithm used to calculate the curve
|
||||
* @param interpolation An implementation of the interpolation algorithm used to calculate
|
||||
* the curve
|
||||
* @apiNote Be advised that currently subsequent changes to the interpolation parameters may
|
||||
* not be supported.
|
||||
*/
|
||||
public ClipboardSpline(EditSession editSession, ClipboardHolder clipboardHolder, Interpolation interpolation) {
|
||||
this(editSession, clipboardHolder, interpolation, new AffineTransform(), -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with position-correction. Use this constructor for an interpolation implementation that needs position-correction.
|
||||
* Constructor with position-correction. Use this constructor for an interpolation
|
||||
* implementation that needs position-correction.
|
||||
*
|
||||
* <p>
|
||||
* Some interpolation implementations calculate the position on the curve (used by {@link #pastePosition(double)})
|
||||
* based on an equidistant distribution of the nodes on the curve. For example: on a spline with 5 nodes position 0.0 would refer
|
||||
* to the first node, 0.25 to the second, 0.5 to the third, ... .<br>
|
||||
* By providing this method with the amount of nodes used by the interpolation implementation the distribution of the
|
||||
* nodes is converted to a proportional distribution based on the length between two adjacent nodes calculated by {@link Interpolation#arcLength(double, double)}.<br>
|
||||
* This means that the distance between two positions used to paste the clipboard (e.g., 0.75 - 0.5 = 0.25) on the curve
|
||||
* will always amount to that part of the length (e.g., 40 units) of the curve. In this example it would amount to
|
||||
* 0.25 × 40 = 10 units of curve length between these two positions.
|
||||
* <p>
|
||||
* Be advised that currently subsequent changes to the interpolation parameters may not be supported.
|
||||
* @param editSession The EditSession which will be used when pasting the clipboard content
|
||||
* Some interpolation implementations calculate the position on the curve (used by {@link
|
||||
* #pastePosition(double)}) based on an equidistant distribution of the nodes on the curve. For
|
||||
* example: on a spline with 5 nodes position 0.0 would refer to the first node, 0.25 to the
|
||||
* second, 0.5 to the third, ... .<br> By providing this method with the amount of nodes used by
|
||||
* the interpolation implementation the distribution of the nodes is converted to a proportional
|
||||
* distribution based on the length between two adjacent nodes calculated by {@link
|
||||
* Interpolation#arcLength(double, double)}.<br> This means that the distance between two
|
||||
* positions used to paste the clipboard (e.g., 0.75 - 0.5 = 0.25) on the curve will always
|
||||
* amount to that part of the length (e.g., 40 units) of the curve. In this example it would
|
||||
* amount to 0.25 × 40 = 10 units of curve length between these two positions.
|
||||
* </p>
|
||||
*
|
||||
* @param editSession The EditSession which will be used when pasting the clipboard content
|
||||
* @param clipboardHolder The clipboard that will be pasted along the spline
|
||||
* @param interpolation An implementation of the interpolation algorithm used to calculate the curve
|
||||
* @param nodeCount The number of nodes provided to the interpolation object
|
||||
* @param interpolation An implementation of the interpolation algorithm used to calculate
|
||||
* the curve
|
||||
* @param nodeCount The number of nodes provided to the interpolation object
|
||||
* @apiNote Be advised that currently subsequent changes to the interpolation parameters may
|
||||
* not be supported.
|
||||
*/
|
||||
public ClipboardSpline(EditSession editSession, ClipboardHolder clipboardHolder, Interpolation interpolation, Transform transform, int nodeCount) {
|
||||
super(editSession, interpolation, nodeCount);
|
||||
@ -72,7 +82,7 @@ public class ClipboardSpline extends Spline {
|
||||
|
||||
Region region = clipboard.getRegion();
|
||||
BlockVector3 origin = clipboard.getOrigin();
|
||||
// center = region.getCenter().setY(origin.getY() - 1);
|
||||
// center = region.getCenter().setY(origin.getY() - 1);
|
||||
center = region.getCenter().withY(origin.getY() - 1).toBlockPoint();
|
||||
this.centerOffset = center.subtract(center.round());
|
||||
this.center = center.subtract(centerOffset);
|
||||
|
@ -2,7 +2,6 @@ package com.boydti.fawe.object.brush.sweep;
|
||||
|
||||
import com.boydti.fawe.object.brush.ResettableTool;
|
||||
import com.boydti.fawe.object.brush.visualization.VisualExtent;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.EmptyClipboardException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
@ -12,15 +11,12 @@ import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableVector3;
|
||||
import com.sk89q.worldedit.math.Vector2;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.interpolation.Interpolation;
|
||||
import com.sk89q.worldedit.math.interpolation.KochanekBartelsInterpolation;
|
||||
import com.sk89q.worldedit.math.interpolation.Node;
|
||||
import com.sk89q.worldedit.math.interpolation.ReparametrisingInterpolation;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
@ -91,7 +87,7 @@ public class SweepBrush implements Brush, ResettableTool {
|
||||
|
||||
ClipboardSpline spline = new ClipboardSpline(editSession, holder, interpol, transform, nodes.size());
|
||||
|
||||
if (dimensions.getBlockX() > dimensions.getBlockZ()) {
|
||||
if (dimensions.getBlockX() > dimensions.getBlockZ()) {
|
||||
spline.setDirection(Vector2.at(0, 1));
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ public final class CFIDrawer {
|
||||
int start = i * size;
|
||||
int end = Math.min(heights.length, start + size);
|
||||
pool.submit((Runnable) () -> {
|
||||
for (int index = start; index < end; index ++) {
|
||||
for (int index = start; index < end; index++) {
|
||||
int height = (heights[index] & 0xFF);
|
||||
char ordinal;
|
||||
if ((ordinal = overlay[index]) == 0) {
|
||||
@ -105,11 +105,11 @@ public final class CFIDrawer {
|
||||
int c0 = tu.getBiome(biomes[index] & 0xFF).grassCombined;
|
||||
int c2 = getBiome(biomes, index + 1 + width, index);
|
||||
int c1 = getBiome(biomes, index - 1 - width, index);
|
||||
// int c3 = getBiome(biomes, index + width, index);
|
||||
// int c4 = getBiome(biomes, index - width, index);
|
||||
int r = ((c0 >> 16) & 0xFF) + ((c1 >> 16) & 0xFF) + ((c2 >> 16) & 0xFF);// + ((c3 >> 16) & 0xFF) + ((c4 >> 16) & 0xFF);
|
||||
int g = ((c0 >> 8) & 0xFF) + ((c1 >> 8) & 0xFF) + ((c2 >> 8) & 0xFF);// + ((c3 >> 8) & 0xFF) + ((c4 >> 8) & 0xFF);
|
||||
int b = ((c0) & 0xFF) + ((c1) & 0xFF) + ((c2) & 0xFF);// + ((c3) & 0xFF) + ((c4) & 0xFF);
|
||||
// int c3 = getBiome(biomes, index + width, index);
|
||||
// int c4 = getBiome(biomes, index - width, index);
|
||||
int r = ((c0 >> 16) & 0xFF) + ((c1 >> 16) & 0xFF) + ((c2 >> 16) & 0xFF); // + ((c3 >> 16) & 0xFF) + ((c4 >> 16) & 0xFF);
|
||||
int g = ((c0 >> 8) & 0xFF) + ((c1 >> 8) & 0xFF) + ((c2 >> 8) & 0xFF); // + ((c3 >> 8) & 0xFF) + ((c4 >> 8) & 0xFF);
|
||||
int b = ((c0) & 0xFF) + ((c1) & 0xFF) + ((c2) & 0xFF); // + ((c3) & 0xFF) + ((c4) & 0xFF);
|
||||
r = r * 85 >> 8;
|
||||
g = g * 85 >> 8;
|
||||
b = b * 85 >> 8;
|
||||
@ -117,7 +117,9 @@ public final class CFIDrawer {
|
||||
}
|
||||
|
||||
private final int getBiome(byte[] biomes, int newIndex, int index) {
|
||||
if (newIndex < 0 || newIndex >= biomes.length) newIndex = index;
|
||||
if (newIndex < 0 || newIndex >= biomes.length) {
|
||||
newIndex = index;
|
||||
}
|
||||
int biome = biomes[newIndex] & 0xFF;
|
||||
return tu.getBiome(biome).grassCombined;
|
||||
}
|
||||
@ -125,16 +127,18 @@ public final class CFIDrawer {
|
||||
private int getSlope(byte[] heights, int width, int index, int height) {
|
||||
return (
|
||||
+ getHeight(heights, index + 1, height)
|
||||
// + getHeight(heights, index + width, height)
|
||||
+ getHeight(heights, index + width + 1, height)
|
||||
- getHeight(heights, index - 1, height)
|
||||
// - getHeight(heights, index - width, height)
|
||||
- getHeight(heights, index - width - 1, height)
|
||||
);
|
||||
// + getHeight(heights, index + width, height)
|
||||
+ getHeight(heights, index + width + 1, height)
|
||||
- getHeight(heights, index - 1, height)
|
||||
// - getHeight(heights, index - width, height)
|
||||
- getHeight(heights, index - width - 1, height)
|
||||
);
|
||||
}
|
||||
|
||||
private int getHeight(byte[] heights, int index, int height) {
|
||||
if (index < 0 || index >= heights.length) return height;
|
||||
if (index < 0 || index >= heights.length) {
|
||||
return height;
|
||||
}
|
||||
return heights[index] & 0xFF;
|
||||
}
|
||||
}
|
||||
|
@ -799,7 +799,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
try {
|
||||
blocks.set(x, y, z, combined);
|
||||
return true;
|
||||
} catch (IndexOutOfBoundsException ignore) {
|
||||
} catch (IndexOutOfBoundsException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,8 @@ public abstract class MCAWriter implements Extent {
|
||||
private final int length;
|
||||
private final int width;
|
||||
private final int area;
|
||||
private int OX, OZ;
|
||||
private int OX;
|
||||
private int OZ;
|
||||
|
||||
|
||||
public MCAWriter(int width, int length, File regionFolder) {
|
||||
@ -91,7 +92,7 @@ public abstract class MCAWriter implements Extent {
|
||||
final ForkJoinPool pool = new ForkJoinPool();
|
||||
int tcx = (width - 1) >> 4;
|
||||
int tcz = (length - 1) >> 4;
|
||||
try (CleanableThreadLocal<MCAChunk> chunkStore = createCache()){
|
||||
try (CleanableThreadLocal<MCAChunk> chunkStore = createCache()) {
|
||||
final ThreadLocal<byte[]> byteStore1 = ThreadLocal.withInitial(() -> new byte[500000]);
|
||||
final ThreadLocal<byte[]> byteStore2 = ThreadLocal.withInitial(() -> new byte[500000]);
|
||||
final ThreadLocal<Deflater> deflateStore = ThreadLocal
|
||||
|
@ -22,7 +22,7 @@ public interface StreamChange {
|
||||
default void flushChanges(File file) throws IOException {
|
||||
try (BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file))) {
|
||||
try (LZ4BlockOutputStream compressed = new LZ4BlockOutputStream(out)) {
|
||||
// compressed.setLevel(Deflater.BEST_SPEED);
|
||||
// compressed.setLevel(Deflater.BEST_SPEED);
|
||||
try (FaweOutputStream fos = new FaweOutputStream(compressed)) {
|
||||
flushChanges(fos);
|
||||
}
|
||||
|
@ -278,6 +278,10 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return waitingCombined.get() == 0 && waitingAsync.get() == 0 && size() == 0;
|
||||
}
|
||||
|
||||
public void add(BlockVector3 loc, BaseBlock from, BaseBlock to) {
|
||||
int x = loc.getBlockX();
|
||||
int y = loc.getBlockY();
|
||||
@ -308,10 +312,6 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return waitingCombined.get() == 0 && waitingAsync.get() == 0 && size() == 0;
|
||||
}
|
||||
|
||||
public void add(int x, int y, int z, int combinedFrom, BaseBlock to) {
|
||||
try {
|
||||
if (to.hasNbtData()) {
|
||||
|
@ -29,21 +29,6 @@ public class AbstractDelegateChangeSet extends AbstractChangeSet {
|
||||
this.waitingAsync = parent.waitingAsync;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeAsync() {
|
||||
parent.closeAsync();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
parent.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
parent.close();
|
||||
}
|
||||
|
||||
public final AbstractChangeSet getParent() {
|
||||
return parent;
|
||||
}
|
||||
@ -54,28 +39,13 @@ public class AbstractDelegateChangeSet extends AbstractChangeSet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int x, int y, int z, int combinedFrom, int combinedTo) {
|
||||
parent.add(x, y, z, combinedFrom, combinedTo);
|
||||
public void closeAsync() {
|
||||
parent.closeAsync();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Change> backwardIterator() {
|
||||
return parent.backwardIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Change> forwardIterator() {
|
||||
return parent.forwardIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return parent.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBiomeChange(int x, int z, BiomeType from, BiomeType to) {
|
||||
parent.addBiomeChange(x, z, from, to);
|
||||
public void flush() {
|
||||
parent.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -98,6 +68,11 @@ public class AbstractDelegateChangeSet extends AbstractChangeSet {
|
||||
parent.addEntityCreate(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBiomeChange(int x, int z, BiomeType from, BiomeType to) {
|
||||
parent.addBiomeChange(x, z, from, to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Change> getIterator(BlockBag blockBag, int mode, boolean redo) {
|
||||
return parent.getIterator(blockBag, mode, redo);
|
||||
@ -108,16 +83,6 @@ public class AbstractDelegateChangeSet extends AbstractChangeSet {
|
||||
return parent.getIterator(redo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
parent.delete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChangeSetSummary summarize(Region region, boolean shallow) {
|
||||
return parent.summarize(region, shallow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EditSession toEditSession(Player player) {
|
||||
return parent.toEditSession(player);
|
||||
@ -128,6 +93,11 @@ public class AbstractDelegateChangeSet extends AbstractChangeSet {
|
||||
return parent.toEditSession(player, regions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int x, int y, int z, int combinedFrom, int combinedTo) {
|
||||
parent.add(x, y, z, combinedFrom, combinedTo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(EntityCreate change) {
|
||||
parent.add(change);
|
||||
@ -159,13 +129,28 @@ public class AbstractDelegateChangeSet extends AbstractChangeSet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return parent.isEmpty();
|
||||
public void add(int x, int y, int z, int combinedFrom, BaseBlock to) {
|
||||
parent.add(x, y, z, combinedFrom, to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int x, int y, int z, int combinedFrom, BaseBlock to) {
|
||||
parent.add(x, y, z, combinedFrom, to);
|
||||
public Iterator<Change> backwardIterator() {
|
||||
return parent.backwardIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Change> forwardIterator() {
|
||||
return parent.forwardIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
parent.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return parent.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -187,4 +172,19 @@ public class AbstractDelegateChangeSet extends AbstractChangeSet {
|
||||
public void setRecordChanges(boolean recordChanges) {
|
||||
parent.setRecordChanges(recordChanges);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return parent.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
parent.delete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChangeSetSummary summarize(Region region, boolean shallow) {
|
||||
return parent.summarize(region, shallow);
|
||||
}
|
||||
}
|
||||
|
@ -33,9 +33,8 @@ public class BlockBagChangeSet extends AbstractDelegateChangeSet {
|
||||
*
|
||||
* @return a block bag, which may be null if none is used
|
||||
*/
|
||||
public
|
||||
@Nullable
|
||||
BlockBag getBlockBag() {
|
||||
public BlockBag getBlockBag() {
|
||||
return blockBag;
|
||||
}
|
||||
|
||||
|
@ -25,16 +25,22 @@ public class CFIChangeSet extends AbstractChangeSet {
|
||||
int max = MainUtil.getMaxFileId(folder);
|
||||
this.file = new File(folder, max + ".cfi");
|
||||
File parent = this.file.getParentFile();
|
||||
if (!parent.exists()) this.file.getParentFile().mkdirs();
|
||||
if (!this.file.exists()) this.file.createNewFile();
|
||||
if (!parent.exists()) {
|
||||
this.file.getParentFile().mkdirs();
|
||||
}
|
||||
if (!this.file.exists()) {
|
||||
this.file.createNewFile();
|
||||
}
|
||||
hmmg.flushChanges(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {}
|
||||
public void close() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeAsync() {}
|
||||
public void closeAsync() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int x, int y, int z, int combinedFrom, int combinedTo) {
|
||||
|
@ -65,13 +65,13 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
super(world);
|
||||
init(uuid, world.getName());
|
||||
}
|
||||
|
||||
|
||||
private void init(UUID uuid, String worldName) {
|
||||
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + worldName + File.separator + uuid);
|
||||
int max = MainUtil.getMaxFileId(folder);
|
||||
init(uuid, max);
|
||||
}
|
||||
|
||||
|
||||
public DiskStorageHistory(World world, UUID uuid, int index) {
|
||||
super(world);
|
||||
init(uuid, index);
|
||||
@ -83,7 +83,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
this.index = i;
|
||||
initFiles(folder);
|
||||
}
|
||||
|
||||
|
||||
private void initFiles(File folder) {
|
||||
nbtfFile = new File(folder, index + ".nbtf");
|
||||
nbttFile = new File(folder, index + ".nbtt");
|
||||
@ -174,12 +174,24 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
super.flush();
|
||||
synchronized (this) {
|
||||
try {
|
||||
if (osBD != null) osBD.flush();
|
||||
if (osBIO != null) osBIO.flush();
|
||||
if (osNBTF != null) osNBTF.flush();
|
||||
if (osNBTT != null) osNBTT.flush();
|
||||
if (osENTCF != null) osENTCF.flush();
|
||||
if (osENTCT != null) osENTCT.flush();
|
||||
if (osBD != null) {
|
||||
osBD.flush();
|
||||
}
|
||||
if (osBIO != null) {
|
||||
osBIO.flush();
|
||||
}
|
||||
if (osNBTF != null) {
|
||||
osNBTF.flush();
|
||||
}
|
||||
if (osNBTT != null) {
|
||||
osNBTT.flush();
|
||||
}
|
||||
if (osENTCF != null) {
|
||||
osENTCF.flush();
|
||||
}
|
||||
if (osENTCT != null) {
|
||||
osENTCT.flush();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
||||
public FaweStreamChangeSet(World world) {
|
||||
this(world, Settings.IMP.HISTORY.COMPRESSION_LEVEL, Settings.IMP.HISTORY.STORE_REDO, Settings.IMP.HISTORY.SMALL_EDITS);
|
||||
}
|
||||
|
||||
|
||||
public FaweStreamChangeSet(World world, int compression, boolean storeRedo, boolean smallLoc) {
|
||||
super(world);
|
||||
this.compression = compression;
|
||||
@ -129,7 +129,9 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
||||
}
|
||||
if (mode == 1 || mode == 4) { // small
|
||||
posDel = new FaweStreamPositionDelegate() {
|
||||
int lx, ly, lz;
|
||||
int lx;
|
||||
int ly;
|
||||
int lz;
|
||||
|
||||
@Override
|
||||
public void write(OutputStream out, int x, int y, int z) throws IOException {
|
||||
@ -169,7 +171,9 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
||||
} else {
|
||||
posDel = new FaweStreamPositionDelegate() {
|
||||
final byte[] buffer = new byte[5];
|
||||
int lx, ly, lz;
|
||||
int lx;
|
||||
int ly;
|
||||
int lz;
|
||||
|
||||
@Override
|
||||
public void write(OutputStream stream, int x, int y, int z) throws IOException {
|
||||
@ -696,7 +700,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
||||
public Change next() {
|
||||
try {
|
||||
return current.next();
|
||||
} catch (Throwable ignore) {
|
||||
} catch (Throwable ignored) {
|
||||
if (i >= iterators.length - 1) {
|
||||
throw new NoSuchElementException("End of iterator");
|
||||
}
|
||||
|
@ -53,12 +53,24 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
|
||||
super.flush();
|
||||
synchronized (this) {
|
||||
try {
|
||||
if (idsStream != null) idsStreamZip.flush();
|
||||
if (biomeStream != null) biomeStreamZip.flush();
|
||||
if (entCStream != null) entCStreamZip.flush();
|
||||
if (entRStream != null) entRStreamZip.flush();
|
||||
if (tileCStream != null) tileCStreamZip.flush();
|
||||
if (tileRStream != null) tileRStreamZip.flush();
|
||||
if (idsStream != null) {
|
||||
idsStreamZip.flush();
|
||||
}
|
||||
if (biomeStream != null) {
|
||||
biomeStreamZip.flush();
|
||||
}
|
||||
if (entCStream != null) {
|
||||
entCStreamZip.flush();
|
||||
}
|
||||
if (entRStream != null) {
|
||||
entRStreamZip.flush();
|
||||
}
|
||||
if (tileCStream != null) {
|
||||
tileCStreamZip.flush();
|
||||
}
|
||||
if (tileRStream != null) {
|
||||
tileRStreamZip.flush();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class CPUOptimizedClipboard extends LinearClipboard {
|
||||
nbtMapLoc = new HashMap<>();
|
||||
nbtMapIndex = new HashMap<>();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasBiomes() {
|
||||
return biomes != null;
|
||||
@ -66,7 +66,9 @@ public class CPUOptimizedClipboard extends LinearClipboard {
|
||||
|
||||
@Override
|
||||
public void streamBiomes(IntValueReader task) {
|
||||
if (!hasBiomes()) return;
|
||||
if (!hasBiomes()) {
|
||||
return;
|
||||
}
|
||||
int index = 0;
|
||||
try {
|
||||
for (int z = 0; z < getLength(); z++) {
|
||||
|
@ -57,7 +57,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
|
||||
|
||||
private static int HEADER_SIZE = 14;
|
||||
private static final int MAX_SIZE = Short.MAX_VALUE - Short.MIN_VALUE;
|
||||
|
||||
|
||||
private final HashMap<IntTriple, CompoundTag> nbtMap;
|
||||
private final File file;
|
||||
|
||||
@ -114,7 +114,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public URI getURI() {
|
||||
return file.toURI();
|
||||
@ -207,7 +207,9 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
|
||||
|
||||
@Override
|
||||
public void streamBiomes(IntValueReader task) {
|
||||
if (!hasBiomes()) return;
|
||||
if (!hasBiomes()) {
|
||||
return;
|
||||
}
|
||||
int index = 0;
|
||||
int mbbIndex = HEADER_SIZE + (getVolume() << 1);
|
||||
try {
|
||||
@ -266,7 +268,9 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
|
||||
}
|
||||
|
||||
private void closeDirectBuffer(ByteBuffer cb) {
|
||||
if (cb == null || !cb.isDirect()) return;
|
||||
if (cb == null || !cb.isDirect()) {
|
||||
return;
|
||||
}
|
||||
// we could use this type cast and call functions without reflection code,
|
||||
// but static import from sun.* package is risky for non-SUN virtual machine.
|
||||
//try { ((sun.nio.ch.DirectBuffer)cb).cleaner().clean(); } catch (Exception ex) { }
|
||||
@ -373,7 +377,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
|
||||
int diskIndex = HEADER_SIZE + (index << 1);
|
||||
char ordinal = byteBuffer.getChar(diskIndex);
|
||||
return BlockState.getFromOrdinal(ordinal);
|
||||
} catch (IndexOutOfBoundsException ignore) {
|
||||
} catch (IndexOutOfBoundsException ignored) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -448,7 +452,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
|
||||
public List<? extends Entity> getEntities() {
|
||||
return new ArrayList<>(entities);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities(Region region) {
|
||||
return new ArrayList<>(entities.stream().filter(e -> region.contains(e.getLocation().toBlockPoint())).collect(Collectors.toList()));
|
||||
|
@ -91,7 +91,9 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
|
||||
|
||||
@Override
|
||||
public void streamBiomes(IntValueReader task) {
|
||||
if (!hasBiomes()) return;
|
||||
if (!hasBiomes()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
int index = 0;
|
||||
for (int z = 0; z < getLength(); z++) {
|
||||
@ -308,7 +310,7 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
|
||||
public List<? extends Entity> getEntities(Region region) {
|
||||
return new ArrayList<>(entities.stream().filter(e -> region.contains(e.getLocation().toBlockPoint())).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeEntity(Entity entity) {
|
||||
if (entity instanceof ClipboardEntity) {
|
||||
|
@ -28,7 +28,9 @@ public class MultiClipboardHolder extends URIClipboardHolder {
|
||||
|
||||
public MultiClipboardHolder(URI uri, URIClipboardHolder... addHolders) {
|
||||
this(uri);
|
||||
for (URIClipboardHolder h : addHolders) add(h);
|
||||
for (URIClipboardHolder h : addHolders) {
|
||||
add(h);
|
||||
}
|
||||
}
|
||||
|
||||
public MultiClipboardHolder(Clipboard clipboard) {
|
||||
@ -44,7 +46,9 @@ public class MultiClipboardHolder extends URIClipboardHolder {
|
||||
public void remove(URI uri) {
|
||||
cached = null;
|
||||
if (getUri().equals(uri)) {
|
||||
for (ClipboardHolder holder : holders) holder.close();
|
||||
for (ClipboardHolder holder : holders) {
|
||||
holder.close();
|
||||
}
|
||||
holders.clear();
|
||||
return;
|
||||
}
|
||||
@ -66,7 +70,9 @@ public class MultiClipboardHolder extends URIClipboardHolder {
|
||||
if (holder instanceof URIClipboardHolder) {
|
||||
URIClipboardHolder uriHolder = (URIClipboardHolder) holder;
|
||||
URI uri = uriHolder.getURI(clipboard);
|
||||
if (uri != null) return uri;
|
||||
if (uri != null) {
|
||||
return uri;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -79,7 +85,9 @@ public class MultiClipboardHolder extends URIClipboardHolder {
|
||||
@Override
|
||||
public boolean contains(Clipboard clipboard) {
|
||||
for (ClipboardHolder holder : holders) {
|
||||
if (holder.contains(clipboard)) return true;
|
||||
if (holder.contains(clipboard)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -128,7 +136,9 @@ public class MultiClipboardHolder extends URIClipboardHolder {
|
||||
return true;
|
||||
}
|
||||
for (URIClipboardHolder uch : holders) {
|
||||
if (uch.contains(uri)) return true;
|
||||
if (uch.contains(uri)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -154,7 +164,9 @@ public class MultiClipboardHolder extends URIClipboardHolder {
|
||||
for (ClipboardHolder holder : getHolders()) {
|
||||
if (holder instanceof URIClipboardHolder) {
|
||||
URI uri = ((URIClipboardHolder) holder).getUri();
|
||||
if (!uri.toString().isEmpty()) set.add(uri);
|
||||
if (!uri.toString().isEmpty()) {
|
||||
set.add(uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
return set;
|
||||
|
@ -24,8 +24,9 @@ public class URIClipboardHolder extends ClipboardHolder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the original clipboard source, typically a file or uri.
|
||||
* @deprecated If a holder has multiple sources, this will return an empty URI
|
||||
* @return The original source of this clipboard (usually a file or url)
|
||||
* @return the source of the clipboard
|
||||
*/
|
||||
@Deprecated
|
||||
public URI getUri() {
|
||||
|
@ -61,7 +61,9 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities() {
|
||||
if (!hasEntities) return new ArrayList<>();
|
||||
if (!hasEntities) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return getExtent().getEntities(getRegion());
|
||||
}
|
||||
|
||||
|
@ -33,13 +33,15 @@ public final class BitArray {
|
||||
}
|
||||
|
||||
public final void set(int index, int value) {
|
||||
if (longLen == 0) return;
|
||||
if (longLen == 0) {
|
||||
return;
|
||||
}
|
||||
int bitIndexStart = index * bitsPerEntry;
|
||||
int longIndexStart = bitIndexStart >> 6;
|
||||
int localBitIndexStart = bitIndexStart & 63;
|
||||
this.data[longIndexStart] = this.data[longIndexStart] & ~(mask << localBitIndexStart) | (long) value << localBitIndexStart;
|
||||
|
||||
if(localBitIndexStart > maxSeqLocIndex) {
|
||||
if (localBitIndexStart > maxSeqLocIndex) {
|
||||
int longIndexEnd = longIndexStart + 1;
|
||||
int localShiftStart = 64 - localBitIndexStart;
|
||||
int localShiftEnd = bitsPerEntry - localShiftStart;
|
||||
@ -48,14 +50,16 @@ public final class BitArray {
|
||||
}
|
||||
|
||||
public final int get(int index) {
|
||||
if (longLen == 0) return 0;
|
||||
if (longLen == 0) {
|
||||
return 0;
|
||||
}
|
||||
int bitIndexStart = index * bitsPerEntry;
|
||||
|
||||
int longIndexStart = bitIndexStart >> 6;
|
||||
|
||||
int localBitIndexStart = bitIndexStart & 63;
|
||||
if(localBitIndexStart <= maxSeqLocIndex) {
|
||||
return (int)(this.data[longIndexStart] >>> localBitIndexStart & mask);
|
||||
if (localBitIndexStart <= maxSeqLocIndex) {
|
||||
return (int) (this.data[longIndexStart] >>> localBitIndexStart & mask);
|
||||
} else {
|
||||
int localShift = 64 - localBitIndexStart;
|
||||
return (int) ((this.data[longIndexStart] >>> localBitIndexStart | this.data[longIndexStart + 1] << localShift) & mask);
|
||||
@ -65,7 +69,7 @@ public final class BitArray {
|
||||
public int getLength() {
|
||||
return longLen;
|
||||
}
|
||||
|
||||
|
||||
public final void fromRaw(int[] arr) {
|
||||
final long[] data = this.data;
|
||||
final int bitsPerEntry = this.bitsPerEntry;
|
||||
|
@ -40,7 +40,9 @@ public final class BitArrayUnstretched {
|
||||
}
|
||||
|
||||
public final void set(int index, int value) {
|
||||
if (longLen == 0) return;
|
||||
if (longLen == 0) {
|
||||
return;
|
||||
}
|
||||
int bitIndexStart = index * bitsPerEntry + MathMan.floorZero((double) index / longLen) * emptyBitCount;
|
||||
int longIndexStart = bitIndexStart >> 6;
|
||||
int localBitIndexStart = bitIndexStart & 63;
|
||||
@ -48,19 +50,21 @@ public final class BitArrayUnstretched {
|
||||
}
|
||||
|
||||
public final int get(int index) {
|
||||
if (longLen == 0) return 0;
|
||||
if (longLen == 0) {
|
||||
return 0;
|
||||
}
|
||||
int bitIndexStart = index * bitsPerEntry + MathMan.floorZero((double) index / longLen) * emptyBitCount;
|
||||
|
||||
int longIndexStart = bitIndexStart >> 6;
|
||||
|
||||
int localBitIndexStart = bitIndexStart & 63;
|
||||
return (int)(this.data[longIndexStart] >>> localBitIndexStart & mask);
|
||||
return (int) (this.data[longIndexStart] >>> localBitIndexStart & mask);
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return longLen;
|
||||
}
|
||||
|
||||
|
||||
public final void fromRaw(int[] arr) {
|
||||
final long[] data = this.data;
|
||||
final int bitsPerEntry = this.bitsPerEntry;
|
||||
|
@ -17,10 +17,12 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* The BlockVectorSet is a Memory optimized Set for storing BlockVectors
|
||||
* - Internally it uses a map of Index->LocalBlockVectorSet
|
||||
* - All BlockVectors must be a valid world coordinate: y=[0,255],x=[-30000000,30000000],z=[-30000000,30000000]
|
||||
* - This will use ~8 bytes for every 64 BlockVectors (about 800x less than a HashSet)
|
||||
* The BlockVectorSet is a memory optimized Set for storing {@link BlockVector3}'s.
|
||||
*
|
||||
* <p>
|
||||
* It uses about 8 bytes of memory for every 64 {@code BlockVector3}s (about 800 times less than a
|
||||
* {@code HashSet}.
|
||||
* </p>
|
||||
*/
|
||||
public class BlockVectorSet extends AbstractCollection<BlockVector3> implements Set<BlockVector3> {
|
||||
private Int2ObjectMap<LocalBlockVectorSet> localSets = new Int2ObjectOpenHashMap<>();
|
||||
@ -92,7 +94,7 @@ public class BlockVectorSet extends AbstractCollection<BlockVector3> implements
|
||||
return new Iterator<BlockVector3>() {
|
||||
Int2ObjectMap.Entry<LocalBlockVectorSet> entry = entries.next();
|
||||
Iterator<BlockVector3> entryIter = entry.getValue().iterator();
|
||||
MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
final MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
@ -185,7 +187,7 @@ public class BlockVectorSet extends AbstractCollection<BlockVector3> implements
|
||||
public boolean retainAll(@NotNull Collection<?> c) {
|
||||
Objects.requireNonNull(c);
|
||||
boolean modified = false;
|
||||
Iterator it = iterator();
|
||||
Iterator<BlockVector3> it = iterator();
|
||||
while (it.hasNext()) {
|
||||
if (!c.contains(it.next())) {
|
||||
it.remove();
|
||||
|
@ -118,7 +118,7 @@ public class CleanableThreadLocal<T> extends ThreadLocal<T> implements Closeable
|
||||
if (methodRemove != null) {
|
||||
try {
|
||||
methodRemove.invoke(tlm, instance);
|
||||
} catch (Throwable ignore) {
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
@ -158,7 +158,7 @@ public class CleanableThreadLocal<T> extends ThreadLocal<T> implements Closeable
|
||||
clean(threadLocal);
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
// We will tolerate an exception here and just log it
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
@ -139,8 +139,11 @@ public final class DifferentialArray<T> implements DifferentialCollection<T> {
|
||||
}
|
||||
}
|
||||
if (caught != null) {
|
||||
if (caught instanceof RuntimeException) throw (RuntimeException) caught;
|
||||
else throw new RuntimeException(caught);
|
||||
if (caught instanceof RuntimeException) {
|
||||
throw (RuntimeException) caught;
|
||||
} else {
|
||||
throw new RuntimeException(caught);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -277,7 +280,7 @@ public final class DifferentialArray<T> implements DifferentialCollection<T> {
|
||||
changed = true;
|
||||
try {
|
||||
changesBytes[index] += (dataBytes[index] - value);
|
||||
} catch (NullPointerException ignore) {
|
||||
} catch (NullPointerException ignored) {
|
||||
changes = (T) (changesBytes = new byte[dataBytes.length]);
|
||||
changesBytes[index] += (dataBytes[index] - value);
|
||||
}
|
||||
@ -288,7 +291,7 @@ public final class DifferentialArray<T> implements DifferentialCollection<T> {
|
||||
changed = true;
|
||||
try {
|
||||
changesInts[index] += dataInts[index] - value;
|
||||
} catch (NullPointerException ignore) {
|
||||
} catch (NullPointerException ignored) {
|
||||
changes = (T) (changesInts = new int[dataInts.length]);
|
||||
changesInts[index] += dataInts[index] - value;
|
||||
}
|
||||
@ -299,7 +302,7 @@ public final class DifferentialArray<T> implements DifferentialCollection<T> {
|
||||
changed = true;
|
||||
try {
|
||||
changesChars[index] += dataChars[index] - value;
|
||||
} catch (NullPointerException ignore) {
|
||||
} catch (NullPointerException ignored) {
|
||||
changes = (T) (changesChars = new char[dataChars.length]);
|
||||
changesChars[index] += dataChars[index] - value;
|
||||
}
|
||||
|
@ -12,8 +12,10 @@ import java.lang.reflect.Array;
|
||||
*/
|
||||
public final class DifferentialBlockBuffer implements DifferentialCollection<char[][][][][]> {
|
||||
|
||||
private final int width, length;
|
||||
private final int t1, t2;
|
||||
private final int width;
|
||||
private final int length;
|
||||
private final int t1;
|
||||
private final int t2;
|
||||
private char[][][][][] data;
|
||||
private char[][][][][] changes;
|
||||
|
||||
@ -63,7 +65,9 @@ public final class DifferentialBlockBuffer implements DifferentialCollection<cha
|
||||
|
||||
@Override
|
||||
public void undoChanges(FaweInputStream in) throws IOException {
|
||||
if (changes != null && changes.length != 0) throw new IllegalStateException("There are uncommitted changes, please flush first");
|
||||
if (changes != null && changes.length != 0) {
|
||||
throw new IllegalStateException("There are uncommitted changes, please flush first");
|
||||
}
|
||||
boolean modified = in.readBoolean();
|
||||
if (modified) {
|
||||
int len = in.readVarInt();
|
||||
@ -118,7 +122,9 @@ public final class DifferentialBlockBuffer implements DifferentialCollection<cha
|
||||
}
|
||||
|
||||
public void set(int x, int y, int z, char combined) {
|
||||
if (combined == 0) combined = 1;
|
||||
if (combined == 0) {
|
||||
combined = 1;
|
||||
}
|
||||
int localX = x & 15;
|
||||
int localZ = z & 15;
|
||||
int chunkX = x >> 4;
|
||||
@ -154,7 +160,9 @@ public final class DifferentialBlockBuffer implements DifferentialCollection<cha
|
||||
}
|
||||
|
||||
} else {
|
||||
if (changes == null || changes.length == 0) changes = new char[t1][][][][];
|
||||
if (changes == null || changes.length == 0) {
|
||||
changes = new char[t1][][][][];
|
||||
}
|
||||
appendChange(changes, chunkX, chunkZ, localX, localZ, y, (char) (zMap[localX] - combined));
|
||||
}
|
||||
|
||||
@ -166,25 +174,33 @@ public final class DifferentialBlockBuffer implements DifferentialCollection<cha
|
||||
if (arr == null) {
|
||||
src[chunkZ] = new char[0][][][];
|
||||
return;
|
||||
} else if (arr.length == 0) return;
|
||||
} else if (arr.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
char[][][] arr2 = arr[chunkX];
|
||||
if (arr2 == null) {
|
||||
arr[chunkX] = new char[0][][];
|
||||
return;
|
||||
} else if (arr2.length == 0) return;
|
||||
} else if (arr2.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
char[][] yMap = arr2[y];
|
||||
if (yMap == null) {
|
||||
arr2[y] = new char[0][];
|
||||
return;
|
||||
} else if (yMap.length == 0) return;
|
||||
} else if (yMap.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
char[] zMap = yMap[localZ];
|
||||
if (zMap == null) {
|
||||
yMap[localZ] = new char[0];
|
||||
return;
|
||||
} else if (zMap.length == 0) return;
|
||||
} else if (zMap.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int current = zMap[localX];
|
||||
zMap[localX] = combined;
|
||||
|
@ -12,8 +12,10 @@ import java.lang.reflect.Array;
|
||||
*/
|
||||
public final class DifferentialCharBlockBuffer implements DifferentialCollection<char[][][][][]> {
|
||||
|
||||
private final int width, length;
|
||||
private final int t1, t2;
|
||||
private final int width;
|
||||
private final int length;
|
||||
private final int t1;
|
||||
private final int t2;
|
||||
private char[][][][][] data;
|
||||
private char[][][][][] changes;
|
||||
|
||||
@ -63,7 +65,9 @@ public final class DifferentialCharBlockBuffer implements DifferentialCollection
|
||||
|
||||
@Override
|
||||
public void undoChanges(FaweInputStream in) throws IOException {
|
||||
if (changes != null && changes.length != 0) throw new IllegalStateException("There are uncommitted changes, please flush first");
|
||||
if (changes != null && changes.length != 0) {
|
||||
throw new IllegalStateException("There are uncommitted changes, please flush first");
|
||||
}
|
||||
boolean modified = in.readBoolean();
|
||||
if (modified) {
|
||||
int len = in.readVarInt();
|
||||
@ -118,7 +122,9 @@ public final class DifferentialCharBlockBuffer implements DifferentialCollection
|
||||
}
|
||||
|
||||
public void set(int x, int y, int z, char combined) {
|
||||
if (combined == 0) combined = 1;
|
||||
if (combined == 0) {
|
||||
combined = 1;
|
||||
}
|
||||
int localX = x & 15;
|
||||
int localZ = z & 15;
|
||||
int chunkX = x >> 4;
|
||||
@ -154,7 +160,9 @@ public final class DifferentialCharBlockBuffer implements DifferentialCollection
|
||||
}
|
||||
|
||||
} else {
|
||||
if (changes == null || changes.length == 0) changes = new char[t1][][][][];
|
||||
if (changes == null || changes.length == 0) {
|
||||
changes = new char[t1][][][][];
|
||||
}
|
||||
appendChange(changes, chunkX, chunkZ, localX, localZ, y, (char) (zMap[localX] - combined));
|
||||
}
|
||||
|
||||
@ -166,25 +174,33 @@ public final class DifferentialCharBlockBuffer implements DifferentialCollection
|
||||
if (arr == null) {
|
||||
src[chunkZ] = new char[0][][][];
|
||||
return;
|
||||
} else if (arr.length == 0) return;
|
||||
} else if (arr.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
char[][][] arr2 = arr[chunkX];
|
||||
if (arr2 == null) {
|
||||
arr[chunkX] = new char[0][][];
|
||||
return;
|
||||
} else if (arr2.length == 0) return;
|
||||
} else if (arr2.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
char[][] yMap = arr2[y];
|
||||
if (yMap == null) {
|
||||
arr2[y] = new char[0][];
|
||||
return;
|
||||
} else if (yMap.length == 0) return;
|
||||
} else if (yMap.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
char[] zMap = yMap[localZ];
|
||||
if (zMap == null) {
|
||||
yMap[localZ] = new char[0];
|
||||
return;
|
||||
} else if (zMap.length == 0) return;
|
||||
} else if (zMap.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
char current = zMap[localX];
|
||||
zMap[localX] = combined;
|
||||
@ -210,4 +226,4 @@ public final class DifferentialCharBlockBuffer implements DifferentialCollection
|
||||
}
|
||||
zMap[localX] = combined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,22 +24,23 @@ public final class FastBitSet {
|
||||
return (bits[i >> 6] & (1L << (i & 0x3F))) != 0;
|
||||
}
|
||||
|
||||
public static final void set(long[] bits, final int i) {
|
||||
public static void set(long[] bits, final int i) {
|
||||
bits[i >> 6] |= (1L << (i & 0x3F));
|
||||
}
|
||||
|
||||
public static final void clear(long[] bits, final int i) {
|
||||
public static void clear(long[] bits, final int i) {
|
||||
bits[i >> 6] &= ~(1L << (i & 0x3F));
|
||||
}
|
||||
|
||||
public static final void set(long[] bits, final int i, final boolean v) {
|
||||
if (v)
|
||||
public static void set(long[] bits, final int i, final boolean v) {
|
||||
if (v) {
|
||||
set(bits, i);
|
||||
else
|
||||
} else {
|
||||
clear(bits, i);
|
||||
}
|
||||
}
|
||||
|
||||
public static final void setRange(long[] bits, final int b, final int e) {
|
||||
public static void setRange(long[] bits, final int b, final int e) {
|
||||
final int bt = b >> 6;
|
||||
final int et = e >> 6;
|
||||
if (bt != et) {
|
||||
@ -51,7 +52,7 @@ public final class FastBitSet {
|
||||
}
|
||||
}
|
||||
|
||||
public static final void clearRange(long[] bits, final int b, final int e) {
|
||||
public static void clearRange(long[] bits, final int b, final int e) {
|
||||
final int bt = b >> 6;
|
||||
final int et = e >> 6;
|
||||
if (bt != et) {
|
||||
@ -63,53 +64,70 @@ public final class FastBitSet {
|
||||
}
|
||||
}
|
||||
|
||||
public static final void setAll(long[] bits) {
|
||||
public static void setAll(long[] bits) {
|
||||
Arrays.fill(bits, -1L);
|
||||
}
|
||||
|
||||
public static final void clearAll(long[] bits) {
|
||||
public static void clearAll(long[] bits) {
|
||||
Arrays.fill(bits, 0L);
|
||||
}
|
||||
|
||||
public static final void invertAll(long[] bits) {
|
||||
for (int i = 0; i < bits.length; ++i)
|
||||
public static void invertAll(long[] bits) {
|
||||
for (int i = 0; i < bits.length; ++i) {
|
||||
bits[i] = ~bits[i];
|
||||
}
|
||||
}
|
||||
|
||||
public static final void and(long[] bits, final long[] other) {
|
||||
public static void and(long[] bits, final long[] other) {
|
||||
final int end = Math.min(other.length, bits.length);
|
||||
for (int i = 0; i < end; ++i)
|
||||
for (int i = 0; i < end; ++i) {
|
||||
bits[i] &= other[i];
|
||||
}
|
||||
}
|
||||
|
||||
public static final void or(long[] bits, final long[] other) {
|
||||
public static void or(long[] bits, final long[] other) {
|
||||
final int end = Math.min(other.length, bits.length);
|
||||
for (int i = 0; i < end; ++i)
|
||||
for (int i = 0; i < end; ++i) {
|
||||
bits[i] |= other[i];
|
||||
}
|
||||
}
|
||||
|
||||
public static final void nand(long[] bits, final long[] other) {
|
||||
public static void nand(long[] bits, final long[] other) {
|
||||
final int end = Math.min(other.length, bits.length);
|
||||
for (int i = 0; i < end; ++i)
|
||||
for (int i = 0; i < end; ++i) {
|
||||
bits[i] = ~(bits[i] & other[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static final void nor(long[] bits, final long[] other) {
|
||||
public static void nor(long[] bits, final long[] other) {
|
||||
final int end = Math.min(other.length, bits.length);
|
||||
for (int i = 0; i < end; ++i)
|
||||
for (int i = 0; i < end; ++i) {
|
||||
bits[i] = ~(bits[i] | other[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static final void xor(long[] bits, final long[] other) {
|
||||
public static void xor(long[] bits, final long[] other) {
|
||||
final int end = Math.min(other.length, bits.length);
|
||||
for (int i = 0; i < end; ++i)
|
||||
for (int i = 0; i < end; ++i) {
|
||||
bits[i] ^= other[i];
|
||||
}
|
||||
}
|
||||
|
||||
public static final long memoryUsage(long[] bits) {
|
||||
public static long memoryUsage(long[] bits) {
|
||||
return 8L * bits.length;
|
||||
}
|
||||
|
||||
private static void fill(final long[] a, final int b, final int e, final long l) {
|
||||
for (int i = b; i < e; ++i) {
|
||||
a[i] = l;
|
||||
}
|
||||
}
|
||||
|
||||
public static long calculateMemoryUsage(int entries) {
|
||||
final int numLongs = (entries + 64) >> 6;
|
||||
return 8L * numLongs;
|
||||
}
|
||||
|
||||
public final boolean get(final int i) {
|
||||
return (bits[i >> 6] & (1L << (i & 0x3F))) != 0;
|
||||
}
|
||||
@ -123,10 +141,11 @@ public final class FastBitSet {
|
||||
}
|
||||
|
||||
public final void set(final int i, final boolean v) {
|
||||
if (v)
|
||||
if (v) {
|
||||
set(i);
|
||||
else
|
||||
} else {
|
||||
clear(i);
|
||||
}
|
||||
}
|
||||
|
||||
public final void setRange(final int b, final int e) {
|
||||
@ -162,45 +181,54 @@ public final class FastBitSet {
|
||||
}
|
||||
|
||||
public final void invertAll() {
|
||||
for (int i = 0; i < bits.length; ++i)
|
||||
for (int i = 0; i < bits.length; ++i) {
|
||||
bits[i] = ~bits[i];
|
||||
}
|
||||
}
|
||||
|
||||
public final void and(final FastBitSet other) {
|
||||
final int end = Math.min(other.bits.length, bits.length);
|
||||
for (int i = 0; i < end; ++i)
|
||||
for (int i = 0; i < end; ++i) {
|
||||
bits[i] &= other.bits[i];
|
||||
}
|
||||
}
|
||||
|
||||
public final void or(final FastBitSet other) {
|
||||
final int end = Math.min(other.bits.length, bits.length);
|
||||
for (int i = 0; i < end; ++i)
|
||||
for (int i = 0; i < end; ++i) {
|
||||
bits[i] |= other.bits[i];
|
||||
}
|
||||
}
|
||||
|
||||
public final void nand(final FastBitSet other) {
|
||||
final int end = Math.min(other.bits.length, bits.length);
|
||||
for (int i = 0; i < end; ++i)
|
||||
for (int i = 0; i < end; ++i) {
|
||||
bits[i] = ~(bits[i] & other.bits[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public final void nor(final FastBitSet other) {
|
||||
final int end = Math.min(other.bits.length, bits.length);
|
||||
for (int i = 0; i < end; ++i)
|
||||
for (int i = 0; i < end; ++i) {
|
||||
bits[i] = ~(bits[i] | other.bits[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public final void xor(final FastBitSet other) {
|
||||
final int end = Math.min(other.bits.length, bits.length);
|
||||
for (int i = 0; i < end; ++i)
|
||||
for (int i = 0; i < end; ++i) {
|
||||
bits[i] ^= other.bits[i];
|
||||
}
|
||||
}
|
||||
|
||||
public final int cardinality() {
|
||||
if (size == 0) return 0;
|
||||
if (size == 0) {
|
||||
return 0;
|
||||
}
|
||||
int count = 0;
|
||||
for (int i = 0; i < bits.length - 1; ++i)
|
||||
for (int i = 0; i < bits.length - 1; ++i) {
|
||||
count += Long.bitCount(bits[i]);
|
||||
}
|
||||
return count + Long.bitCount(bits[bits.length - 1] & ~(-1L << (size & 0x3F)));
|
||||
}
|
||||
|
||||
@ -212,16 +240,6 @@ public final class FastBitSet {
|
||||
return 8L * bits.length;
|
||||
}
|
||||
|
||||
private static void fill(final long[] a, final int b, final int e, final long l) {
|
||||
for (int i = b; i < e; ++i)
|
||||
a[i] = l;
|
||||
}
|
||||
|
||||
public static long calculateMemoryUsage(int entries) {
|
||||
final int numLongs = (entries + 64) >> 6;
|
||||
return 8L * numLongs;
|
||||
}
|
||||
|
||||
public IntIterator iterator() {
|
||||
return new IntIterator();
|
||||
}
|
||||
@ -240,8 +258,8 @@ public final class FastBitSet {
|
||||
index++;
|
||||
}
|
||||
final long lowBit = Long.lowestOneBit(bitBuffer);
|
||||
final int bitIndex = Long.bitCount(lowBit-1);
|
||||
value = ((index-1)<<6)+bitIndex;
|
||||
final int bitIndex = Long.bitCount(lowBit - 1);
|
||||
value = ((index - 1) << 6) + bitIndex;
|
||||
bitBuffer = bitBuffer ^ lowBit;
|
||||
return true;
|
||||
}
|
||||
@ -250,4 +268,4 @@ public final class FastBitSet {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,15 +16,15 @@ public class FastRandomCollection<T> extends RandomCollection<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new FastRandomCollection if the given values and weights match the criteria.
|
||||
* The criteria may change at any point, so this method isn't guaranteed to return a
|
||||
* non-empty Optional in any case.
|
||||
* Create a new FastRandomCollection if the given values and weights match the criteria. The
|
||||
* criteria may change at any point, so this method isn't guaranteed to return a non-empty
|
||||
* {@code Optional} in any case.
|
||||
*
|
||||
* @param weights the weight of the values.
|
||||
* @param random the random generator to use for this collection.
|
||||
* @param <T> the value type.
|
||||
* @return an {@link Optional} containing the new collection if it could
|
||||
* be created, {@link Optional#empty()} otherwise.
|
||||
* @return an {@link Optional} containing the new collection if it could be created, {@link
|
||||
* Optional#empty()} otherwise.
|
||||
* @see RandomCollection for API usage.
|
||||
*/
|
||||
public static <T> Optional<RandomCollection<T>> create(Map<T, Double> weights, SimpleRandom random) {
|
||||
|
@ -71,21 +71,27 @@ public interface IAdaptedMap<K, V, K2, V2> extends Map<K, V> {
|
||||
@NotNull
|
||||
@Override
|
||||
default Set<K> keySet() {
|
||||
if (isEmpty()) return Collections.emptySet();
|
||||
if (isEmpty()) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
return new AdaptedSetCollection<>(getParent().keySet(), this::adaptKey2);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
default Collection<V> values() {
|
||||
if (isEmpty()) return Collections.emptySet();
|
||||
if (isEmpty()) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
return new AdaptedSetCollection<>(getParent().values(), this::adaptValue2);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
default Set<Entry<K, V>> entrySet() {
|
||||
if (isEmpty()) return Collections.emptySet();
|
||||
if (isEmpty()) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
return new AdaptedSetCollection<>(getParent().entrySet(), new Function<Entry<K2, V2>, Entry<K, V>>() {
|
||||
private MutablePair<K, V> entry = new MutablePair<>();
|
||||
@Override
|
||||
|
@ -51,7 +51,9 @@ public class LocalBlockVector2DSet implements Set<BlockVector2> {
|
||||
|
||||
public boolean containsRadius(int x, int y, int radius) {
|
||||
int size = size();
|
||||
if (size == 0) return false;
|
||||
if (size == 0) {
|
||||
return false;
|
||||
}
|
||||
if (radius <= 0 || size == 1) {
|
||||
return contains(x, y);
|
||||
}
|
||||
|
@ -15,7 +15,8 @@ import java.util.Set;
|
||||
* - This will use 8 bytes for every 64 BlockVectors (about 800x less than a HashSet)
|
||||
*/
|
||||
public class LocalBlockVectorSet implements Set<BlockVector3> {
|
||||
private int offsetX, offsetZ;
|
||||
private int offsetX;
|
||||
private int offsetZ;
|
||||
private final SparseBitSet set;
|
||||
|
||||
public LocalBlockVectorSet() {
|
||||
|
@ -61,7 +61,9 @@ public class LongHashSet {
|
||||
public void add(long key) {
|
||||
int mainIdx = (int) (key & 255);
|
||||
long outer[][] = this.values[mainIdx];
|
||||
if (outer == null) this.values[mainIdx] = outer = new long[256][];
|
||||
if (outer == null) {
|
||||
this.values[mainIdx] = outer = new long[256][];
|
||||
}
|
||||
|
||||
int outerIdx = (int) ((key >> 32) & 255);
|
||||
long inner[] = outer[outerIdx];
|
||||
@ -88,23 +90,33 @@ public class LongHashSet {
|
||||
|
||||
public boolean containsKey(long key) {
|
||||
long[][] outer = this.values[(int) (key & 255)];
|
||||
if (outer == null) return false;
|
||||
if (outer == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
long[] inner = outer[(int) ((key >> 32) & 255)];
|
||||
if (inner == null) return false;
|
||||
if (inner == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (long entry : inner) {
|
||||
if (entry == key) return true;
|
||||
if (entry == key) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void remove(long key) {
|
||||
long[][] outer = this.values[(int) (key & 255)];
|
||||
if (outer == null) return;
|
||||
if (outer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
long[] inner = outer[(int) ((key >> 32) & 255)];
|
||||
if (inner == null) return;
|
||||
if (inner == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int max = inner.length - 1;
|
||||
for (int i = 0; i <= max; i++) {
|
||||
@ -122,11 +134,15 @@ public class LongHashSet {
|
||||
|
||||
public long popFirst() {
|
||||
for (long[][] outer: this.values) {
|
||||
if (outer == null) continue;
|
||||
if (outer == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int i = 0; i < outer.length; i++) {
|
||||
long[] inner = outer[i];
|
||||
if (inner == null || inner.length == 0) continue;
|
||||
if (inner == null || inner.length == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.count--;
|
||||
long ret = inner[inner.length - 1];
|
||||
@ -142,11 +158,15 @@ public class LongHashSet {
|
||||
int index = 0;
|
||||
long[] ret = new long[this.count];
|
||||
for (long[][] outer : this.values) {
|
||||
if (outer == null) continue;
|
||||
if (outer == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int oIdx = outer.length - 1; oIdx >= 0; oIdx--) {
|
||||
long[] inner = outer[oIdx];
|
||||
if (inner == null) continue;
|
||||
if (inner == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (long entry: inner) {
|
||||
ret[index++] = entry;
|
||||
@ -162,10 +182,14 @@ public class LongHashSet {
|
||||
int index = 0;
|
||||
long[] ret = new long[this.count];
|
||||
for (long[][] outer : this.values) {
|
||||
if (outer == null) continue;
|
||||
if (outer == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (long[] inner : outer) {
|
||||
if (inner == null) continue;
|
||||
if (inner == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (long entry : inner) {
|
||||
ret[index++] = entry;
|
||||
|
@ -20,11 +20,11 @@ import java.util.Set;
|
||||
* - Grouping / iteration is by chunk section, and the y>z>x order
|
||||
*/
|
||||
public final class MemBlockSet extends BlockSet {
|
||||
public final static int BITS_PER_WORD = 6;
|
||||
public final static int WORDS = FaweCache.IMP.BLOCKS_PER_LAYER >> BITS_PER_WORD;
|
||||
public final static IRow NULL_ROW_X = new NullRowX();
|
||||
public final static IRow NULL_ROW_Z = new NullRowZ();
|
||||
public final static IRow NULL_ROW_Y = new NullRowY();
|
||||
public static final int BITS_PER_WORD = 6;
|
||||
public static final int WORDS = FaweCache.IMP.BLOCKS_PER_LAYER >> BITS_PER_WORD;
|
||||
public static final IRow NULL_ROW_X = new NullRowX();
|
||||
public static final IRow NULL_ROW_Z = new NullRowZ();
|
||||
public static final IRow NULL_ROW_Y = new NullRowY();
|
||||
public final IRow[] rows;
|
||||
public final MutableBlockVector3 mutable;
|
||||
|
||||
@ -35,7 +35,9 @@ public final class MemBlockSet extends BlockSet {
|
||||
public MemBlockSet(int size, int offsetX, int offsetZ) {
|
||||
super(offsetX, offsetZ);
|
||||
this.rows = new IRow[size];
|
||||
for (int i = 0; i < size; i++) rows[i] = NULL_ROW_X;
|
||||
for (int i = 0; i < size; i++) {
|
||||
rows[i] = NULL_ROW_X;
|
||||
}
|
||||
this.mutable = new MutableBlockVector3();
|
||||
}
|
||||
|
||||
@ -92,19 +94,21 @@ public final class MemBlockSet extends BlockSet {
|
||||
return new Iterator<BlockVector2>() {
|
||||
private MutableBlockVector2 mutable = new MutableBlockVector2();
|
||||
private boolean hasNext;
|
||||
private int X,Z;
|
||||
private int setX, setZ;
|
||||
private int X;
|
||||
private int Z;
|
||||
private int setX;
|
||||
private int setZ;
|
||||
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
for (;X < rows.length; X++) {
|
||||
for (; X < rows.length; X++) {
|
||||
IRow nullRowX = rows[X];
|
||||
if (nullRowX instanceof RowX) {
|
||||
RowX rowx = (RowX) nullRowX;
|
||||
for (;Z < rowx.rows.length; Z++) {
|
||||
for (; Z < rowx.rows.length; Z++) {
|
||||
IRow nullRowZ = rowx.rows[Z];
|
||||
if (nullRowZ instanceof RowZ) {
|
||||
setX = X;
|
||||
@ -182,23 +186,27 @@ public final class MemBlockSet extends BlockSet {
|
||||
return new Iterator<BlockVector3>() {
|
||||
private MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
private boolean hasNext;
|
||||
private int X, Z, Y;
|
||||
private int setX, setY, setZ;
|
||||
private int X;
|
||||
private int Z;
|
||||
private int Y;
|
||||
private int setX;
|
||||
private int setY;
|
||||
private int setZ;
|
||||
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
for (;X < rows.length; X++) {
|
||||
for (; X < rows.length; X++) {
|
||||
IRow nullRowX = rows[X];
|
||||
if (nullRowX instanceof RowX) {
|
||||
RowX rowx = (RowX) nullRowX;
|
||||
for (;Z < rowx.rows.length; Z++) {
|
||||
for (; Z < rowx.rows.length; Z++) {
|
||||
IRow nullRowZ = rowx.rows[Z];
|
||||
if (nullRowZ instanceof RowZ) {
|
||||
RowZ rowz = (RowZ) nullRowZ;
|
||||
for (;Y < rowz.rows.length;Y++) {
|
||||
for (; Y < rowz.rows.length; Y++) {
|
||||
IRow nullRowY = rowz.rows[Y];
|
||||
if (nullRowY instanceof RowY) {
|
||||
setX = X;
|
||||
@ -224,7 +232,8 @@ public final class MemBlockSet extends BlockSet {
|
||||
|
||||
@Override
|
||||
public BlockVector3 next() {
|
||||
mutable.setComponents(setX + getBlockOffsetX(), setY, setZ + getBlockOffsetX());
|
||||
mutable.setComponents(
|
||||
setX + getBlockOffsetX(), setY, setZ + getBlockOffsetX());
|
||||
init();
|
||||
return mutable;
|
||||
}
|
||||
@ -287,19 +296,22 @@ public final class MemBlockSet extends BlockSet {
|
||||
int maxy = 16;
|
||||
int by = Integer.MAX_VALUE;
|
||||
for (IRow nullRowX : rows) {
|
||||
if (!(nullRowX instanceof RowX))
|
||||
if (!(nullRowX instanceof RowX)) {
|
||||
continue;
|
||||
}
|
||||
RowX rowx = (RowX) nullRowX;
|
||||
for (int Z = 0; Z < rowx.rows.length; Z++) {
|
||||
IRow nullRowZ = rowx.rows[Z];
|
||||
if (!(nullRowZ instanceof RowZ))
|
||||
if (!(nullRowZ instanceof RowZ)) {
|
||||
continue;
|
||||
}
|
||||
RowZ rowz = (RowZ) nullRowZ;
|
||||
outer:
|
||||
for (int Y = 0; Y <= maxY; Y++) {
|
||||
IRow nullRowY = rowz.rows[Y];
|
||||
if (!(nullRowY instanceof RowY))
|
||||
if (!(nullRowY instanceof RowY)) {
|
||||
continue;
|
||||
}
|
||||
RowY rowY = (RowY) nullRowY;
|
||||
int localMaxy = Y == maxY ? maxy : 15;
|
||||
for (int y = 0, i = 0; y < localMaxy; y++) {
|
||||
@ -314,8 +326,9 @@ public final class MemBlockSet extends BlockSet {
|
||||
maxy = y;
|
||||
}
|
||||
by = (Y << 4) + y;
|
||||
if (by == 0)
|
||||
if (by == 0) {
|
||||
return 0;
|
||||
}
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
@ -332,19 +345,22 @@ public final class MemBlockSet extends BlockSet {
|
||||
int maxy = 0;
|
||||
int by = Integer.MIN_VALUE;
|
||||
for (IRow nullRowX : rows) {
|
||||
if (!(nullRowX instanceof RowX))
|
||||
if (!(nullRowX instanceof RowX)) {
|
||||
continue;
|
||||
}
|
||||
RowX rowx = (RowX) nullRowX;
|
||||
for (int Z = 0; Z < rowx.rows.length; Z++) {
|
||||
IRow nullRowZ = rowx.rows[Z];
|
||||
if (!(nullRowZ instanceof RowZ))
|
||||
if (!(nullRowZ instanceof RowZ)) {
|
||||
continue;
|
||||
}
|
||||
RowZ rowz = (RowZ) nullRowZ;
|
||||
outer:
|
||||
for (int Y = 15; Y >= maxY; Y--) {
|
||||
IRow nullRowY = rowz.rows[Y];
|
||||
if (!(nullRowY instanceof RowY))
|
||||
if (!(nullRowY instanceof RowY)) {
|
||||
continue;
|
||||
}
|
||||
RowY rowY = (RowY) nullRowY;
|
||||
int localMaxy = Y == maxY ? maxy : 0;
|
||||
for (int y = 15, i = 63; y >= localMaxy; y--) {
|
||||
@ -359,8 +375,9 @@ public final class MemBlockSet extends BlockSet {
|
||||
maxy = y + 1;
|
||||
}
|
||||
by = (Y << 4) + y;
|
||||
if (by == FaweCache.IMP.WORLD_MAX_Y)
|
||||
if (by == FaweCache.IMP.WORLD_MAX_Y) {
|
||||
return FaweCache.IMP.WORLD_MAX_Y;
|
||||
}
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
@ -377,12 +394,16 @@ public final class MemBlockSet extends BlockSet {
|
||||
int tz = Integer.MIN_VALUE;
|
||||
for (int X = rows.length - 1; X >= 0; X--) {
|
||||
IRow nullRowX = rows[X];
|
||||
if (!(nullRowX instanceof RowX)) continue;
|
||||
if (!(nullRowX instanceof RowX)) {
|
||||
continue;
|
||||
}
|
||||
RowX rowx = (RowX) nullRowX;
|
||||
outer:
|
||||
for (int Z = rowx.rows.length - 1; Z >= maxChunkZ ; Z--) {
|
||||
for (int Z = rowx.rows.length - 1; Z >= maxChunkZ; Z--) {
|
||||
IRow nullRowZ = rowx.rows[Z];
|
||||
if (!(nullRowZ instanceof RowZ)) continue;
|
||||
if (!(nullRowZ instanceof RowZ)) {
|
||||
continue;
|
||||
}
|
||||
RowZ rowz = (RowZ) nullRowZ;
|
||||
if (Z != maxChunkZ) {
|
||||
maxChunkZ = Z;
|
||||
@ -390,7 +411,9 @@ public final class MemBlockSet extends BlockSet {
|
||||
}
|
||||
for (int Y = rowz.rows.length - 1; Y >= 0; Y--) {
|
||||
IRow nullRowY = rowz.rows[Y];
|
||||
if (!(nullRowY instanceof RowY)) continue;
|
||||
if (!(nullRowY instanceof RowY)) {
|
||||
continue;
|
||||
}
|
||||
RowY rowY = (RowY) nullRowY;
|
||||
for (int y = 15, i1 = 63; y >= 0; y--, i1 -= 4) {
|
||||
for (int z = 12, i = i1; z > maxz - 3; z -= 4, i--) {
|
||||
@ -419,21 +442,29 @@ public final class MemBlockSet extends BlockSet {
|
||||
public int getMaxX() {
|
||||
for (int X = rows.length - 1; X >= 0; X--) {
|
||||
IRow nullRowX = rows[X];
|
||||
if (!(nullRowX instanceof RowX)) continue;
|
||||
if (!(nullRowX instanceof RowX)) {
|
||||
continue;
|
||||
}
|
||||
int tx = (X << 4);
|
||||
RowX rowx = (RowX) nullRowX;
|
||||
long or = 0;
|
||||
for (int Z = rowx.rows.length - 1; Z >= 0 ; Z--) {
|
||||
for (int Z = rowx.rows.length - 1; Z >= 0; Z--) {
|
||||
IRow nullRowZ = rowx.rows[Z];
|
||||
if (!(nullRowZ instanceof RowZ)) continue;
|
||||
if (!(nullRowZ instanceof RowZ)) {
|
||||
continue;
|
||||
}
|
||||
RowZ rowz = (RowZ) nullRowZ;
|
||||
for (int Y = rowz.rows.length - 1; Y >= 0; Y--) {
|
||||
IRow nullRowY = rowz.rows[Y];
|
||||
if (!(nullRowY instanceof RowY)) continue;
|
||||
if (!(nullRowY instanceof RowY)) {
|
||||
continue;
|
||||
}
|
||||
RowY rowY = (RowY) nullRowY;
|
||||
or |= Arrays.stream(rowY.bits).reduce(0, (a, b) -> a | b);
|
||||
or = (or & 0xFFFF) | ((or >> 16) & 0xFFFF) | ((or >> 32) & 0xFFFF) | ((or >> 48) & 0xFFFF);
|
||||
if (highestBit(or) == 15) return tx + 15;
|
||||
if (highestBit(or) == 15) {
|
||||
return tx + 15;
|
||||
}
|
||||
}
|
||||
}
|
||||
int highest = highestBit(or);
|
||||
@ -449,14 +480,16 @@ public final class MemBlockSet extends BlockSet {
|
||||
int maxz = 16;
|
||||
int bz = Integer.MAX_VALUE;
|
||||
for (IRow nullRowX : rows) {
|
||||
if (!(nullRowX instanceof RowX))
|
||||
if (!(nullRowX instanceof RowX)) {
|
||||
continue;
|
||||
}
|
||||
RowX rowx = (RowX) nullRowX;
|
||||
outer:
|
||||
for (int Z = 0; Z <= maxChunkZ; Z++) {
|
||||
IRow nullRowZ = rowx.rows[Z];
|
||||
if (!(nullRowZ instanceof RowZ))
|
||||
if (!(nullRowZ instanceof RowZ)) {
|
||||
continue;
|
||||
}
|
||||
RowZ rowz = (RowZ) nullRowZ;
|
||||
if (Z != maxChunkZ) {
|
||||
maxChunkZ = Z;
|
||||
@ -464,8 +497,9 @@ public final class MemBlockSet extends BlockSet {
|
||||
}
|
||||
for (int Y = 0; Y < rowz.rows.length; Y++) {
|
||||
IRow nullRowY = rowz.rows[Y];
|
||||
if (!(nullRowY instanceof RowY))
|
||||
if (!(nullRowY instanceof RowY)) {
|
||||
continue;
|
||||
}
|
||||
RowY rowY = (RowY) nullRowY;
|
||||
for (int y = 0, i1 = 0; y < 16; y++, i1 += 4) {
|
||||
for (int z = 0, i = i1; z < maxz; z += 4, i++) {
|
||||
@ -494,21 +528,29 @@ public final class MemBlockSet extends BlockSet {
|
||||
public int getMinX() {
|
||||
for (int X = 0; X < rows.length; X++) {
|
||||
IRow nullRowX = rows[X];
|
||||
if (!(nullRowX instanceof RowX)) continue;
|
||||
if (!(nullRowX instanceof RowX)) {
|
||||
continue;
|
||||
}
|
||||
int bx = X << 4;
|
||||
RowX rowx = (RowX) nullRowX;
|
||||
long or = 0;
|
||||
for (int Z = 0; Z < rowx.rows.length; Z++) {
|
||||
IRow nullRowZ = rowx.rows[Z];
|
||||
if (!(nullRowZ instanceof RowZ)) continue;
|
||||
if (!(nullRowZ instanceof RowZ)) {
|
||||
continue;
|
||||
}
|
||||
RowZ rowz = (RowZ) nullRowZ;
|
||||
for (int Y = 0; Y < rowz.rows.length; Y++) {
|
||||
IRow nullRowY = rowz.rows[Y];
|
||||
if (!(nullRowY instanceof RowY)) continue;
|
||||
if (!(nullRowY instanceof RowY)) {
|
||||
continue;
|
||||
}
|
||||
RowY rowY = (RowY) nullRowY;
|
||||
or |= Arrays.stream(rowY.bits).reduce(0, (a, b) -> a | b);
|
||||
or = (or & 0xFFFF) | ((or >> 16) & 0xFFFF) | ((or >> 32) & 0xFFFF) | ((or >> 48) & 0xFFFF);
|
||||
if (lowestBit(or) == 0) return bx;
|
||||
if (lowestBit(or) == 0) {
|
||||
return bx;
|
||||
}
|
||||
}
|
||||
}
|
||||
int lowest = lowestBit(or);
|
||||
@ -522,17 +564,23 @@ public final class MemBlockSet extends BlockSet {
|
||||
public void iterate(BlockIterator iterator) {
|
||||
for (int X = 0; X < rows.length; X++) {
|
||||
IRow nullRowX = rows[X];
|
||||
if (!(nullRowX instanceof RowX)) continue;
|
||||
if (!(nullRowX instanceof RowX)) {
|
||||
continue;
|
||||
}
|
||||
int bx = getBlockOffsetX() + (X << 4);
|
||||
RowX rowx = (RowX) nullRowX;
|
||||
for (int Z = 0; Z < rowx.rows.length; Z++) {
|
||||
IRow nullRowZ = rowx.rows[Z];
|
||||
if (!(nullRowZ instanceof RowZ)) continue;
|
||||
if (!(nullRowZ instanceof RowZ)) {
|
||||
continue;
|
||||
}
|
||||
int bz = getBlockOffsetZ() + (Z << 4);
|
||||
RowZ rowz = (RowZ) nullRowZ;
|
||||
for (int Y = 0; Y < rowz.rows.length; Y++) {
|
||||
IRow nullRowY = rowz.rows[Y];
|
||||
if (!(nullRowY instanceof RowY)) continue;
|
||||
if (!(nullRowY instanceof RowY)) {
|
||||
continue;
|
||||
}
|
||||
int by = Y << 4;
|
||||
RowY rowY = (RowY) nullRowY;
|
||||
for (int y = 0, i = 0; y < 16; y++) {
|
||||
@ -567,7 +615,11 @@ public final class MemBlockSet extends BlockSet {
|
||||
@Override
|
||||
public Iterator<BlockVector3> iterator() {
|
||||
return new Iterator<BlockVector3>() {
|
||||
private int bx, by, bz, zz, yy;
|
||||
private int bx;
|
||||
private int by;
|
||||
private int bz;
|
||||
private int zz;
|
||||
private int yy;
|
||||
private RowX rowX;
|
||||
private RowZ rowZ;
|
||||
private long[] bits;
|
||||
@ -658,7 +710,7 @@ public final class MemBlockSet extends BlockSet {
|
||||
@Override
|
||||
public BlockVector3 next() {
|
||||
final long lowBit = Long.lowestOneBit(bitBuffer);
|
||||
final int bitIndex = Long.bitCount(lowBit-1);
|
||||
final int bitIndex = Long.bitCount(lowBit - 1);
|
||||
mutable.setComponents((bx) + (bitIndex & 15), yy, (zz) + (bitIndex));
|
||||
bitBuffer = bitBuffer ^ lowBit;
|
||||
nextLong();
|
||||
@ -676,22 +728,26 @@ public final class MemBlockSet extends BlockSet {
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
for (IRow nullRowX : rows) {
|
||||
if (!(nullRowX instanceof RowX))
|
||||
if (!(nullRowX instanceof RowX)) {
|
||||
continue;
|
||||
}
|
||||
RowX rowx = (RowX) nullRowX;
|
||||
for (int Z = 0; Z < rowx.rows.length; Z++) {
|
||||
IRow nullRowZ = rowx.rows[Z];
|
||||
if (!(nullRowZ instanceof RowZ))
|
||||
if (!(nullRowZ instanceof RowZ)) {
|
||||
continue;
|
||||
}
|
||||
RowZ rowz = (RowZ) nullRowZ;
|
||||
for (int Y = 0; Y < 16; Y++) {
|
||||
IRow nullRowY = rowz.rows[Y];
|
||||
if (!(nullRowY instanceof RowY))
|
||||
if (!(nullRowY instanceof RowY)) {
|
||||
continue;
|
||||
}
|
||||
RowY rowY = (RowY) nullRowY;
|
||||
for (long bit : rowY.bits) {
|
||||
if (bit != 0)
|
||||
if (bit != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -709,13 +765,15 @@ public final class MemBlockSet extends BlockSet {
|
||||
long lastBit = 0;
|
||||
int lastCount = 0;
|
||||
for (IRow nullRowX : rows) {
|
||||
if (!(nullRowX instanceof RowX))
|
||||
if (!(nullRowX instanceof RowX)) {
|
||||
continue;
|
||||
}
|
||||
RowX rowx = (RowX) nullRowX;
|
||||
for (int z = 0; z < rowx.rows.length; z++) {
|
||||
IRow nullRowZ = rowx.rows[z];
|
||||
if (!(nullRowZ instanceof RowZ))
|
||||
if (!(nullRowZ instanceof RowZ)) {
|
||||
continue;
|
||||
}
|
||||
RowZ rowz = (RowZ) nullRowZ;
|
||||
for (int y = 0; y < 16; y++) {
|
||||
IRow nullRowY = rowz.rows[y];
|
||||
@ -749,17 +807,24 @@ public final class MemBlockSet extends BlockSet {
|
||||
void apply(int x, int y, int z);
|
||||
}
|
||||
|
||||
|
||||
public interface IRow {
|
||||
default boolean get(IRow[] rows, int x, int y, int z) { return false; }
|
||||
default boolean get(IRow[] rows, int x, int y, int z) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void set(IRow[] rows, int x, int y, int z);
|
||||
|
||||
default boolean add(IRow[] rows, int x, int y, int z) {
|
||||
set(rows, x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
default boolean remove(IRow[] rows, int x, int y, int z) {
|
||||
remove(rows, x, y, z);
|
||||
return false;
|
||||
}
|
||||
|
||||
default void clear(IRow[] rows, int x, int y, int z) {
|
||||
}
|
||||
}
|
||||
@ -796,7 +861,9 @@ public final class MemBlockSet extends BlockSet {
|
||||
|
||||
public RowX(int size) {
|
||||
this.rows = new IRow[size];
|
||||
for (int i = 0; i < size; i++) rows[i] = NULL_ROW_Z;
|
||||
for (int i = 0; i < size; i++) {
|
||||
rows[i] = NULL_ROW_Z;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -876,7 +943,9 @@ public final class MemBlockSet extends BlockSet {
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
for (int i = 0; i < FaweCache.IMP.CHUNK_LAYERS; i++) rows[i] = NULL_ROW_Y;
|
||||
for (int i = 0; i < FaweCache.IMP.CHUNK_LAYERS; i++) {
|
||||
rows[i] = NULL_ROW_Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -940,7 +1009,9 @@ public final class MemBlockSet extends BlockSet {
|
||||
int len = arr.length;
|
||||
int newLen = len == 1 ? 1 : Integer.highestOneBit(len - 1) * 2;
|
||||
IRow[] copy = Arrays.copyOf(arr, newLen, IRow[].class);
|
||||
for (int i = len; i < newLen; i++) copy[i] = def;
|
||||
for (int i = len; i < newLen; i++) {
|
||||
copy[i] = def;
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import java.util.Map;
|
||||
public class MutablePair<K, V> implements Map.Entry<K, V> {
|
||||
private K key;
|
||||
private V value;
|
||||
|
||||
@Override
|
||||
public K getKey() {
|
||||
return key;
|
||||
@ -17,9 +18,8 @@ public class MutablePair<K, V> implements Map.Entry<K, V> {
|
||||
|
||||
@Override
|
||||
public V setValue(V value) {
|
||||
V old = value;
|
||||
this.value = value;
|
||||
return old;
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setKey(K key) {
|
||||
|
@ -27,7 +27,9 @@ public class SimpleRandomCollection<E> extends RandomCollection<E> {
|
||||
}
|
||||
|
||||
public void add(double weight, E result) {
|
||||
if (weight <= 0) return;
|
||||
if (weight <= 0) {
|
||||
return;
|
||||
}
|
||||
total += weight;
|
||||
map.put(total, result);
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
// CHECKSTYLE:OFF
|
||||
package com.boydti.fawe.object.collection;
|
||||
|
||||
/*- This software is the work of Paladin Software International, Incorporated,
|
||||
@ -805,7 +804,7 @@ public class SparseBitSet implements Cloneable, Serializable
|
||||
* public int hashCode()
|
||||
* {
|
||||
* long hash = 1234L;
|
||||
* for( int i = bits.length; --i >= 0; )
|
||||
* for ( int i = bits.length; --i >= 0; )
|
||||
* hash ^= bits[i] * (i + 1);
|
||||
* return (int)((h >> 32) ^ h);
|
||||
* }</pre>
|
||||
@ -965,7 +964,7 @@ public class SparseBitSet implements Cloneable, Serializable
|
||||
* sbs</code>, use the following loop:
|
||||
*
|
||||
* <pre>
|
||||
* for( int i = sbbits.nextSetBit(0); i >= 0; i = sbbits.nextSetBit(i+1) )
|
||||
* for ( int i = sbbits.nextSetBit(0); i >= 0; i = sbbits.nextSetBit(i+1) )
|
||||
* {
|
||||
* // operate on index i here
|
||||
* }</pre>
|
||||
|
@ -6,10 +6,13 @@ import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
|
||||
/**
|
||||
* Efficient blur / average color over an image
|
||||
* Efficient blur / average color over an image.
|
||||
*/
|
||||
public class SummedColorTable {
|
||||
private final long[] reds, greens, blues, alpha;
|
||||
private final long[] reds;
|
||||
private final long[] greens;
|
||||
private final long[] blues;
|
||||
private final long[] alpha;
|
||||
private final int[] hasAlpha;
|
||||
private final int length;
|
||||
private final int width;
|
||||
@ -38,7 +41,9 @@ public class SummedColorTable {
|
||||
for (int j = 0; j < width; j++, index++) {
|
||||
int color = raw[index];
|
||||
int alpha = (color >> 24) & 0xFF;
|
||||
int red, green, blue;
|
||||
int red;
|
||||
int green;
|
||||
int blue;
|
||||
switch (alpha) {
|
||||
case 0:
|
||||
red = green = blue = 0;
|
||||
@ -68,7 +73,10 @@ public class SummedColorTable {
|
||||
for (int i = 0; i < length; i++) {
|
||||
for (int j = 0; j < width; j++, index++) {
|
||||
int color = raw[index];
|
||||
int red, green, blue, alpha;
|
||||
int red;
|
||||
int green;
|
||||
int blue;
|
||||
int alpha;
|
||||
if (((color >> 24) != 0)) {
|
||||
alpha = 1;
|
||||
red = (color >> 16) & 0xFF;
|
||||
@ -122,7 +130,9 @@ public class SummedColorTable {
|
||||
area += hasAlpha[pos];
|
||||
}
|
||||
|
||||
if (area == 0) return 0;
|
||||
if (area == 0) {
|
||||
return 0;
|
||||
}
|
||||
float factor = this.areaInverses[area - 1];
|
||||
return (255 << 24) + (((int) (totRed * factor)) << 16) + (((int) (totGreen * factor)) << 8) + (((int) (totBlue * factor)) << 0);
|
||||
}
|
||||
@ -166,7 +176,9 @@ public class SummedColorTable {
|
||||
area += hasAlpha[pos];
|
||||
}
|
||||
|
||||
if (totAlpha == 0) return 0;
|
||||
if (totAlpha == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
float factor = this.areaInverses[area - 1];
|
||||
float alpha = (totAlpha * factor);
|
||||
|
@ -10,7 +10,7 @@ public class FaweException extends RuntimeException {
|
||||
// DEBUG
|
||||
public static final FaweException _enableQueue = new FaweException("enableQueue");
|
||||
public static final FaweException _disableQueue = new FaweException("disableQueue");
|
||||
|
||||
|
||||
private final Component message;
|
||||
|
||||
public FaweException(String reason) {
|
||||
@ -42,9 +42,9 @@ public class FaweException extends RuntimeException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Faster exception throwing/handling if you don't fill the stacktrace
|
||||
* Faster exception throwing/handling if you don't fill the stacktrace.
|
||||
*
|
||||
* @return
|
||||
* @return a reference to this {@code Throwable} instance.
|
||||
*/
|
||||
@Override
|
||||
public Throwable fillInStackTrace() {
|
||||
|
@ -11,7 +11,9 @@ import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
public class BlockTranslateExtent extends AbstractDelegateExtent {
|
||||
private final int dx, dy, dz;
|
||||
private final int dx;
|
||||
private final int dy;
|
||||
private final int dz;
|
||||
private MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
|
||||
public BlockTranslateExtent(Extent extent, int dx, int dy, int dz) {
|
||||
|
@ -11,6 +11,7 @@ public class ExtentHeightCacher extends PassthroughExtent {
|
||||
private transient int cacheBotZ = Integer.MIN_VALUE;
|
||||
private transient byte[] cacheHeights;
|
||||
private transient int lastY;
|
||||
|
||||
public ExtentHeightCacher(Extent extent) {
|
||||
super(extent);
|
||||
}
|
||||
|
@ -15,7 +15,8 @@ import java.util.concurrent.Future;
|
||||
|
||||
public class HeightBoundExtent extends FaweRegionExtent {
|
||||
|
||||
private final int min, max;
|
||||
private final int min;
|
||||
private final int max;
|
||||
private int lastY = -1;
|
||||
private boolean lastResult;
|
||||
|
||||
|
@ -182,18 +182,18 @@ public class NullExtent extends FaweRegionExtent implements IBatchProcessor {
|
||||
|
||||
@Override
|
||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) {
|
||||
throw reason;
|
||||
}
|
||||
throw reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(int x, int z) {
|
||||
throw reason;
|
||||
}
|
||||
throw reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(int x, int y, int z) {
|
||||
throw reason;
|
||||
}
|
||||
throw reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Region> getRegions() {
|
||||
@ -273,13 +273,13 @@ public class NullExtent extends FaweRegionExtent implements IBatchProcessor {
|
||||
|
||||
@Override
|
||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, boolean ignoreAir) {
|
||||
throw reason;
|
||||
}
|
||||
throw reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
|
||||
throw reason;
|
||||
}
|
||||
throw reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) {
|
||||
@ -303,8 +303,8 @@ public class NullExtent extends FaweRegionExtent implements IBatchProcessor {
|
||||
|
||||
@Override
|
||||
public void generate(Region region, GenBase gen) throws WorldEditException {
|
||||
throw reason;
|
||||
}
|
||||
throw reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSchems(Region region, Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean rotate) throws WorldEditException {
|
||||
|
@ -10,7 +10,9 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
public class OffsetExtent extends ResettableExtent {
|
||||
|
||||
private final int dx, dy, dz;
|
||||
private final int dx;
|
||||
private final int dy;
|
||||
private final int dz;
|
||||
private transient MutableBlockVector2 mutable = new MutableBlockVector2();
|
||||
|
||||
public OffsetExtent(Extent parent, int dx, int dy, int dz) {
|
||||
|
@ -12,7 +12,9 @@ import java.util.SplittableRandom;
|
||||
|
||||
public class RandomOffsetTransform extends ResettableExtent {
|
||||
|
||||
private final int dx, dy, dz;
|
||||
private final int dx;
|
||||
private final int dy;
|
||||
private final int dz;
|
||||
private transient SplittableRandom random;
|
||||
private transient MutableBlockVector2 mutable = new MutableBlockVector2();
|
||||
|
||||
|
@ -15,7 +15,9 @@ import javax.annotation.Nullable;
|
||||
|
||||
public class ScaleTransform extends ResettableExtent {
|
||||
|
||||
private final double dx, dy, dz;
|
||||
private final double dx;
|
||||
private final double dy;
|
||||
private final double dz;
|
||||
private transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
private transient int maxy;
|
||||
private transient BlockVector3 min;
|
||||
|
@ -47,9 +47,13 @@ public class StripNBTExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
public <B extends BlockStateHolder<B>> B stripBlockNBT(B block) {
|
||||
if(!(block instanceof BaseBlock)) return block;
|
||||
BaseBlock localBlock = (BaseBlock)block;
|
||||
if (!localBlock.hasNbtData()) return block;
|
||||
if (!(block instanceof BaseBlock)) {
|
||||
return block;
|
||||
}
|
||||
BaseBlock localBlock = (BaseBlock) block;
|
||||
if (!localBlock.hasNbtData()) {
|
||||
return block;
|
||||
}
|
||||
CompoundTag nbt = localBlock.getNbtData();
|
||||
Map<String, Tag> value = nbt.getValue();
|
||||
for (String key : strip) {
|
||||
@ -59,7 +63,9 @@ public class StripNBTExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
public <T extends NbtValued> T stripEntityNBT(T entity) {
|
||||
if (!entity.hasNbtData()) return entity;
|
||||
if (!entity.hasNbtData()) {
|
||||
return entity;
|
||||
}
|
||||
CompoundTag nbt = entity.getNbtData();
|
||||
Map<String, Tag> value = nbt.getValue();
|
||||
for (String key : strip) {
|
||||
|
@ -10,10 +10,13 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
public class TemporalExtent extends PassthroughExtent {
|
||||
private int x, y, z = Integer.MAX_VALUE;
|
||||
private int x;
|
||||
private int y;
|
||||
private int z = Integer.MAX_VALUE;
|
||||
private BlockStateHolder<?> block = BlockTypes.AIR.getDefaultState();
|
||||
|
||||
private int bx, bz = Integer.MAX_VALUE;
|
||||
private int bx;
|
||||
private int bz = Integer.MAX_VALUE;
|
||||
private BiomeType biome = null;
|
||||
|
||||
/**
|
||||
@ -58,8 +61,8 @@ public class TemporalExtent extends PassthroughExtent {
|
||||
@Override
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
if (position.getX() == x && position.getY() == y && position.getZ() == z) {
|
||||
if(block instanceof BaseBlock) {
|
||||
return (BaseBlock)block;
|
||||
if (block instanceof BaseBlock) {
|
||||
return (BaseBlock) block;
|
||||
} else {
|
||||
return block.toBaseBlock();
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class BiomeCopy implements RegionFunction {
|
||||
int x = position.getBlockX();
|
||||
int y = position.getBlockY();
|
||||
int z = position.getBlockZ();
|
||||
if (x != mutableVector.getBlockX() || z != mutableVector.getBlockZ()|| y != mutableVector
|
||||
if (x != mutableVector.getBlockX() || z != mutableVector.getBlockZ() || y != mutableVector
|
||||
.getBlockY()) {
|
||||
mutableVector.setComponents(x, y, z);
|
||||
return destination.setBiome(mutableVector, source.getBiome(mutableVector));
|
||||
|
@ -20,7 +20,7 @@ public class CombinedBlockCopy implements RegionFunction {
|
||||
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
// BlockStateHolder block = source.getBlock(position);
|
||||
// BlockStateHolder block = source.getBlock(position);
|
||||
BaseBlock block = source.getFullBlock(position);
|
||||
function.apply(position);
|
||||
return destination.setBlock(position, block);
|
||||
|
@ -9,13 +9,14 @@ import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
* BufferedOutputStream that asynchronously flushes to disk, so callers don't
|
||||
* have to wait until the flush happens. Buffers are put into a queue that is
|
||||
* written asynchronously to disk once it is really available.
|
||||
* <p>
|
||||
* This class is thread-safe.
|
||||
*
|
||||
* <p>
|
||||
* The error handling (as all stream ops are done asynchronously) is done during
|
||||
* write and close. Exceptions on the asynchronous thread will be thrown to the
|
||||
* caller either while writing or closing this stream.
|
||||
* </p>
|
||||
*
|
||||
* @apiNote This class is thread-safe.
|
||||
* @author thomas.jungblut
|
||||
*/
|
||||
public final class AsyncBufferedOutputStream extends FilterOutputStream {
|
||||
|
@ -1,21 +1,3 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.boydti.fawe.object.io;
|
||||
|
||||
import java.io.File;
|
||||
@ -26,16 +8,14 @@ import java.util.Arrays;
|
||||
|
||||
|
||||
/**
|
||||
* A <code>BufferedRandomAccessFile</code> is like a
|
||||
* <code>RandomAccessFile</code>, but it uses a private buffer so that most
|
||||
* A {@code BufferedRandomAccessFile} is like a
|
||||
* {@code RandomAccessFile}, but it uses a private buffer so that most
|
||||
* operations do not require a disk access.
|
||||
* <P>
|
||||
*
|
||||
* Note: The operations on this class are unmonitored. Also, the correct
|
||||
* functioning of the <code>RandomAccessFile</code> methods that are not
|
||||
* overridden here relies on the implementation of those methods in the
|
||||
* superclass.
|
||||
* Author : Avinash Lakshman ( alakshman@facebook.com) & Prashant Malik ( pmalik@facebook.com )
|
||||
* @author Avinash Lakshman ( alakshman@facebook.com) & Prashant Malik ( pmalik@facebook.com )
|
||||
* @apiNote The operations on this class are unmonitored. Also, the correct
|
||||
* functioning of the {@code RandomAccessFile} methods that are not
|
||||
* overridden here relies on the implementation of those methods in the superclass.
|
||||
*/
|
||||
|
||||
public class BufferedRandomAccessFile extends RandomAccessFile {
|
||||
@ -50,7 +30,8 @@ public class BufferedRandomAccessFile extends RandomAccessFile {
|
||||
private boolean dirty_; // true iff unflushed bytes exist
|
||||
private boolean closed_; // true iff the file is closed
|
||||
private long curr_; // current position in file
|
||||
private long lo_, hi_; // bounds on characters in "buff"
|
||||
private long lo_; // bounds on characters in "buff"
|
||||
private long hi_; // bounds on characters in "buff"
|
||||
private byte[] buff_; // local buffer
|
||||
private long maxHi_; // this.lo + this.buff.length
|
||||
private boolean hitEOF_; // buffer contains last file block?
|
||||
@ -110,8 +91,8 @@ public class BufferedRandomAccessFile extends RandomAccessFile {
|
||||
*/
|
||||
|
||||
/**
|
||||
* Open a new <code>BufferedRandomAccessFile</code> on <code>file</code>
|
||||
* in mode <code>mode</code>, which should be "r" for reading only, or
|
||||
* Open a new {@code BufferedRandomAccessFile} on {@code file}
|
||||
* in mode {@code mode}, which should be "r" for reading only, or
|
||||
* "rw" for reading and writing.
|
||||
*/
|
||||
public BufferedRandomAccessFile(File file, String mode) throws IOException {
|
||||
@ -125,8 +106,8 @@ public class BufferedRandomAccessFile extends RandomAccessFile {
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a new <code>BufferedRandomAccessFile</code> on the file named
|
||||
* <code>name</code> in mode <code>mode</code>, which should be "r" for
|
||||
* Open a new {@code BufferedRandomAccessFile} on the file named
|
||||
* {@code name} in mode {@code mode}, which should be "r" for
|
||||
* reading only, or "rw" for reading and writing.
|
||||
*/
|
||||
public BufferedRandomAccessFile(String name, String mode) throws IOException {
|
||||
@ -176,8 +157,9 @@ public class BufferedRandomAccessFile extends RandomAccessFile {
|
||||
/* Flush any dirty bytes in the buffer to disk. */
|
||||
private void flushBuffer() throws IOException {
|
||||
if (this.dirty_) {
|
||||
if (this.diskPos_ != this.lo_)
|
||||
if (this.diskPos_ != this.lo_) {
|
||||
super.seek(this.lo_);
|
||||
}
|
||||
int len = (int) (this.curr_ - this.lo_);
|
||||
super.write(this.buff_, 0, len);
|
||||
this.diskPos_ = this.curr_;
|
||||
@ -195,8 +177,9 @@ public class BufferedRandomAccessFile extends RandomAccessFile {
|
||||
int rem = this.buff_.length;
|
||||
while (rem > 0) {
|
||||
int n = super.read(this.buff_, cnt, rem);
|
||||
if (n < 0)
|
||||
if (n < 0) {
|
||||
break;
|
||||
}
|
||||
cnt += n;
|
||||
rem -= n;
|
||||
}
|
||||
@ -277,13 +260,15 @@ public class BufferedRandomAccessFile extends RandomAccessFile {
|
||||
if (this.curr_ >= this.hi_) {
|
||||
// test for EOF
|
||||
// if (this.hi < this.maxHi) return -1;
|
||||
if (this.hitEOF_)
|
||||
if (this.hitEOF_) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// slow path -- read another buffer
|
||||
this.seek(this.curr_);
|
||||
if (this.curr_ == this.hi_)
|
||||
if (this.curr_ == this.hi_) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
byte res = this.buff_[(int) (this.curr_ - this.lo_)];
|
||||
this.curr_++;
|
||||
@ -294,13 +279,15 @@ public class BufferedRandomAccessFile extends RandomAccessFile {
|
||||
if (this.curr_ >= this.hi_) {
|
||||
// test for EOF
|
||||
// if (this.hi < this.maxHi) return -1;
|
||||
if (this.hitEOF_)
|
||||
if (this.hitEOF_) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// slow path -- read another buffer
|
||||
this.seek(this.curr_);
|
||||
if (this.curr_ == this.hi_)
|
||||
if (this.curr_ == this.hi_) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
byte res = this.buff_[(int) (this.curr_ - this.lo_)];
|
||||
this.curr_++;
|
||||
@ -317,13 +304,15 @@ public class BufferedRandomAccessFile extends RandomAccessFile {
|
||||
if (this.curr_ >= this.hi_) {
|
||||
// test for EOF
|
||||
// if (this.hi < this.maxHi) return -1;
|
||||
if (this.hitEOF_)
|
||||
if (this.hitEOF_) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// slow path -- read another buffer
|
||||
this.seek(this.curr_);
|
||||
if (this.curr_ == this.hi_)
|
||||
if (this.curr_ == this.hi_) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
len = Math.min(len, (int) (this.hi_ - this.curr_));
|
||||
int buffOff = (int) (this.curr_ - this.lo_);
|
||||
@ -336,13 +325,15 @@ public class BufferedRandomAccessFile extends RandomAccessFile {
|
||||
if (this.curr_ >= this.hi_) {
|
||||
// test for EOF
|
||||
// if (this.hi < this.maxHi) return -1;
|
||||
if (this.hitEOF_)
|
||||
if (this.hitEOF_) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// slow path -- read another buffer
|
||||
this.seek(this.curr_);
|
||||
if (this.curr_ == this.hi_)
|
||||
if (this.curr_ == this.hi_) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return this.buff_[(int) (this.curr_ - this.lo_)];
|
||||
}
|
||||
|
@ -66,8 +66,11 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
|
||||
@Override
|
||||
public void writeBoolean(boolean b) throws IOException {
|
||||
|
||||
if (b) this.write(1);
|
||||
else this.write(0);
|
||||
if (b) {
|
||||
this.write(1);
|
||||
} else {
|
||||
this.write(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -249,12 +252,18 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
|
||||
|
||||
for (int i = 0 ; i < numchars ; i++) {
|
||||
int c = s.charAt(i);
|
||||
if ((c >= 0x0001) && (c <= 0x007F)) numbytes++;
|
||||
else if (c > 0x07FF) numbytes += 3;
|
||||
else numbytes += 2;
|
||||
if ((c >= 0x0001) && (c <= 0x007F)) {
|
||||
numbytes++;
|
||||
} else if (c > 0x07FF) {
|
||||
numbytes += 3;
|
||||
} else {
|
||||
numbytes += 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (numbytes > 65535) throw new UTFDataFormatException();
|
||||
if (numbytes > 65535) {
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
|
||||
out.write((numbytes >>> 8) & 0xFF);
|
||||
out.write(numbytes & 0xFF);
|
||||
|
@ -35,7 +35,7 @@ public class PGZIPOutputStream extends FilterOutputStream {
|
||||
|
||||
|
||||
// private static final Logger LOG = LoggerFactory.getLogger(PGZIPOutputStream.class);
|
||||
private final static int GZIP_MAGIC = 0x8b1f;
|
||||
private static final int GZIP_MAGIC = 0x8b1f;
|
||||
|
||||
// todo: remove after block guessing is implemented
|
||||
// array list that contains the block sizes
|
||||
@ -175,10 +175,12 @@ public class PGZIPOutputStream extends FilterOutputStream {
|
||||
for (; ; ) {
|
||||
Future<byte[]> future = emitQueue.peek();
|
||||
// LOG.info("Peeked future " + future);
|
||||
if (future == null)
|
||||
if (future == null) {
|
||||
return;
|
||||
if (!future.isDone())
|
||||
}
|
||||
if (!future.isDone()) {
|
||||
return;
|
||||
}
|
||||
// It's an ordered queue. This MUST be the same element as above.
|
||||
emitQueue.remove();
|
||||
byte[] toWrite = future.get();
|
||||
@ -215,8 +217,9 @@ public class PGZIPOutputStream extends FilterOutputStream {
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
// LOG.info("Flush: " + block);
|
||||
if (block.in_length > 0)
|
||||
if (block.in_length > 0) {
|
||||
submit();
|
||||
}
|
||||
emitUntil(0);
|
||||
super.flush();
|
||||
}
|
||||
|
@ -52,16 +52,22 @@ public class CachedMask extends AbstractDelegateMask implements ResettableMask {
|
||||
return cache_results.contains(x, y, z);
|
||||
}
|
||||
boolean result = getMask().test(mutable.setComponents(x, y, z));
|
||||
if (result) cache_results.add(x, y, z);
|
||||
if (result) {
|
||||
cache_results.add(x, y, z);
|
||||
}
|
||||
return result;
|
||||
} catch (UnsupportedOperationException ignored) {
|
||||
boolean result = getMask().test(mutable.setComponents(x, y, z));
|
||||
if (y < 0 || y > 255) return result;
|
||||
if (y < 0 || y > 255) {
|
||||
return result;
|
||||
}
|
||||
resetCache();
|
||||
cache_checked.setOffset(x, z);
|
||||
cache_results.setOffset(x, z);
|
||||
cache_checked.add(x, y, z);
|
||||
if (result) cache_results.add(x, y, z);
|
||||
if (result) {
|
||||
cache_results.add(x, y, z);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,8 @@ public class ExtremaMask extends AngleMask {
|
||||
|
||||
@Override
|
||||
protected boolean testSlope(Extent extent, int x, int y, int z) {
|
||||
double slope, tmp;
|
||||
double slope;
|
||||
double tmp;
|
||||
boolean aboveMin;
|
||||
lastY = y;
|
||||
|
||||
@ -19,13 +20,19 @@ public class ExtremaMask extends AngleMask {
|
||||
slope = getHeight(extent, base, x, y, z, 1, 0, distance) * ADJACENT_MOD;
|
||||
|
||||
tmp = getHeight(extent, base, x, y, z, 0, 1, distance) * ADJACENT_MOD;
|
||||
if (Math.abs(tmp) > Math.abs(slope)) slope = tmp;
|
||||
if (Math.abs(tmp) > Math.abs(slope)) {
|
||||
slope = tmp;
|
||||
}
|
||||
|
||||
tmp = getHeight(extent, base, x, y, z, 1, 1, distance) * DIAGONAL_MOD;
|
||||
if (Math.abs(tmp) > Math.abs(slope)) slope = tmp;
|
||||
if (Math.abs(tmp) > Math.abs(slope)) {
|
||||
slope = tmp;
|
||||
}
|
||||
|
||||
tmp = getHeight(extent, base, x, y, z, 1, -1, distance) * DIAGONAL_MOD;
|
||||
if (Math.abs(tmp) > Math.abs(slope)) slope = tmp;
|
||||
if (Math.abs(tmp) > Math.abs(slope)) {
|
||||
slope = tmp;
|
||||
}
|
||||
|
||||
return lastValue = (slope > min && slope < max);
|
||||
}
|
||||
@ -35,7 +42,8 @@ public class ExtremaMask extends AngleMask {
|
||||
int lastHeight1 = base;
|
||||
int lastHeight2 = base;
|
||||
|
||||
int cox = OX, coz = OZ;
|
||||
int cox = OX;
|
||||
int coz = OZ;
|
||||
for (int i = 0; i < iterations; i++, cox += OX, coz += OZ) {
|
||||
int x1 = x + cox;
|
||||
int z1 = z + coz;
|
||||
@ -49,11 +57,18 @@ public class ExtremaMask extends AngleMask {
|
||||
int sign2 = Integer.signum(diff2);
|
||||
|
||||
if (sign == 0) {
|
||||
if (sign1 != 0) sign = sign1;
|
||||
else if (sign2 != 0) sign = sign2;
|
||||
if (sign1 != 0) {
|
||||
sign = sign1;
|
||||
} else if (sign2 != 0) {
|
||||
sign = sign2;
|
||||
}
|
||||
}
|
||||
if (sign1 == 0) {
|
||||
sign1 = sign;
|
||||
}
|
||||
if (sign2 == 0) {
|
||||
sign2 = sign;
|
||||
}
|
||||
if (sign1 == 0) sign1 = sign;
|
||||
if (sign2 == 0) sign2 = sign;
|
||||
if (sign1 != sign2) {
|
||||
return (lastHeight1 - base) + (lastHeight2 - base);
|
||||
}
|
||||
|
@ -27,7 +27,9 @@ public class MaskedTargetBlock extends TargetBlock {
|
||||
if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= world.getMaxY()) {
|
||||
searchForLastBlock = false;
|
||||
}
|
||||
} else if (current.getBlockY() <= 0) break;
|
||||
} else if (current.getBlockY() <= 0) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
@ -7,7 +7,9 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
public class PlaneMask extends AbstractMask implements ResettableMask {
|
||||
|
||||
private transient int mode = -1;
|
||||
private transient int originX = Integer.MAX_VALUE, originY = Integer.MAX_VALUE, originZ = Integer.MAX_VALUE;
|
||||
private transient int originX = Integer.MAX_VALUE;
|
||||
private transient int originY = Integer.MAX_VALUE;
|
||||
private transient int originZ = Integer.MAX_VALUE;
|
||||
|
||||
@Override
|
||||
public boolean test(BlockVector3 vector) {
|
||||
|
@ -20,15 +20,21 @@ public class ROCAngleMask extends AngleMask {
|
||||
|
||||
double tmp = (getHeight(extent, x, y, z + distance) - base - (base - getHeight(extent, x, y,
|
||||
z - distance))) * ADJACENT_MOD;
|
||||
if (Math.abs(tmp) > Math.abs(slope)) slope = tmp;
|
||||
if (Math.abs(tmp) > Math.abs(slope)) {
|
||||
slope = tmp;
|
||||
}
|
||||
|
||||
tmp = (getHeight(extent, x + distance, y, z + distance) - base - (base - getHeight(extent, x - distance, y,
|
||||
z - distance))) * DIAGONAL_MOD;
|
||||
if (Math.abs(tmp) > Math.abs(slope)) slope = tmp;
|
||||
if (Math.abs(tmp) > Math.abs(slope)) {
|
||||
slope = tmp;
|
||||
}
|
||||
|
||||
tmp = (getHeight(extent, x - distance, y, z + distance) - base - (base - getHeight(extent, x + distance, y,
|
||||
z - distance))) * DIAGONAL_MOD;
|
||||
if (Math.abs(tmp) > Math.abs(slope)) slope = tmp;
|
||||
if (Math.abs(tmp) > Math.abs(slope)) {
|
||||
slope = tmp;
|
||||
}
|
||||
|
||||
return lastValue = slope >= min && slope <= max;
|
||||
}
|
||||
|
@ -7,7 +7,8 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
public class RadiusMask extends AbstractMask implements ResettableMask {
|
||||
|
||||
private transient BlockVector3 pos;
|
||||
private final int minSqr, maxSqr;
|
||||
private final int minSqr;
|
||||
private final int maxSqr;
|
||||
|
||||
public RadiusMask(int min, int max) {
|
||||
this.minSqr = min * min;
|
||||
|
@ -6,7 +6,9 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
public class SimplexMask extends AbstractMask {
|
||||
private final double min, max, scale;
|
||||
private final double min;
|
||||
private final double max;
|
||||
private final double scale;
|
||||
|
||||
public SimplexMask(double scale, double min, double max) {
|
||||
this.scale = scale;
|
||||
|
@ -6,46 +6,47 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
|
||||
public class WallMask extends AbstractMask {
|
||||
private final int min, max;
|
||||
private final int min;
|
||||
private final int max;
|
||||
private final Mask mask;
|
||||
private MutableBlockVector3 v;
|
||||
private MutableBlockVector3 vector;
|
||||
|
||||
public WallMask(Mask mask, int requiredMin, int requiredMax) {
|
||||
this.mask = mask;
|
||||
this.min = requiredMin;
|
||||
this.max = requiredMax;
|
||||
this.v = new MutableBlockVector3();
|
||||
this.vector = new MutableBlockVector3();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(BlockVector3 bv) {
|
||||
v.setComponents(bv);
|
||||
vector.setComponents(bv);
|
||||
int count = 0;
|
||||
double x = v.getX();
|
||||
double y = v.getY();
|
||||
double z = v.getZ();
|
||||
v.mutX(x + 1);
|
||||
if (mask.test(v) && ++count == min && max >= 8) {
|
||||
v.mutX(x);
|
||||
double x = vector.getX();
|
||||
double y = vector.getY();
|
||||
double z = vector.getZ();
|
||||
vector.mutX(x + 1);
|
||||
if (mask.test(vector) && ++count == min && max >= 8) {
|
||||
vector.mutX(x);
|
||||
return true;
|
||||
}
|
||||
v.mutX(x - 1);
|
||||
if (mask.test(v) && ++count == min && max >= 8) {
|
||||
v.mutX(x);
|
||||
vector.mutX(x - 1);
|
||||
if (mask.test(vector) && ++count == min && max >= 8) {
|
||||
vector.mutX(x);
|
||||
return true;
|
||||
}
|
||||
v.mutX(x);
|
||||
v.mutZ(z + 1);
|
||||
if (mask.test(v) && ++count == min && max >= 8) {
|
||||
v.mutZ(z);
|
||||
vector.mutX(x);
|
||||
vector.mutZ(z + 1);
|
||||
if (mask.test(vector) && ++count == min && max >= 8) {
|
||||
vector.mutZ(z);
|
||||
return true;
|
||||
}
|
||||
v.mutZ(z - 1);
|
||||
if (mask.test(v) && ++count == min && max >= 8) {
|
||||
v.mutZ(z);
|
||||
vector.mutZ(z - 1);
|
||||
if (mask.test(vector) && ++count == min && max >= 8) {
|
||||
vector.mutZ(z);
|
||||
return true;
|
||||
}
|
||||
v.mutZ(z);
|
||||
vector.mutZ(z);
|
||||
return count >= min && count <= max;
|
||||
}
|
||||
|
||||
|
@ -29,21 +29,6 @@ public class AngleColorPattern extends DataAnglePattern {
|
||||
return (((color >> 24) & 0xFF) << 24) + (newRed << 16) + (newGreen << 8) + (newBlue << 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(BlockVector3 position) {
|
||||
BaseBlock block = extent.getFullBlock(position);
|
||||
int slope = getSlope(block, position, extent);
|
||||
if (slope == -1) {
|
||||
return block;
|
||||
}
|
||||
int color = holder.getTextureUtil().getColor(block.getBlockType());
|
||||
if (color == 0) {
|
||||
return block;
|
||||
}
|
||||
int newColor = getColor(color, slope);
|
||||
return holder.getTextureUtil().getNearestBlock(newColor).getDefaultState().toBaseBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> int getSlope(T block, BlockVector3 vector, Extent extent) {
|
||||
int slope = super.getSlope(block, vector, extent);
|
||||
@ -62,6 +47,21 @@ public class AngleColorPattern extends DataAnglePattern {
|
||||
return slope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(BlockVector3 position) {
|
||||
BaseBlock block = extent.getFullBlock(position);
|
||||
int slope = getSlope(block, position, extent);
|
||||
if (slope == -1) {
|
||||
return block;
|
||||
}
|
||||
int color = holder.getTextureUtil().getColor(block.getBlockType());
|
||||
if (color == 0) {
|
||||
return block;
|
||||
}
|
||||
int newColor = getColor(color, slope);
|
||||
return holder.getTextureUtil().getNearestBlock(newColor).getDefaultState().toBaseBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
BlockState block = get.getBlock(extent);
|
||||
|
@ -34,10 +34,14 @@ public class AverageColorPattern extends AbstractExtentPattern {
|
||||
BlockType blockType = get.getBlock(extent).getBlockType();
|
||||
TextureUtil util = holder.getTextureUtil();
|
||||
int currentColor = util.getColor(blockType);
|
||||
if (currentColor == 0) return false;
|
||||
if (currentColor == 0) {
|
||||
return false;
|
||||
}
|
||||
int newColor = util.averageColor(currentColor, color);
|
||||
BlockType newBlock = util.getNearestBlock(newColor);
|
||||
if (newBlock == blockType) return false;
|
||||
if (newBlock == blockType) {
|
||||
return false;
|
||||
}
|
||||
return set.setBlock(extent, newBlock.getDefaultState());
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,9 @@ public class BufferedPattern extends AbstractPattern implements ResettablePatter
|
||||
public BufferedPattern(Actor actor, Pattern parent) {
|
||||
this.uuid = actor.getUniqueId();
|
||||
long[] tmp = actor.getMeta("lastActionTime");
|
||||
if (tmp == null) actor.setMeta("lastActionTime", tmp = new long[2]);
|
||||
if (tmp == null) {
|
||||
actor.setMeta("lastActionTime", tmp = new long[2]);
|
||||
}
|
||||
actionTime = tmp;
|
||||
this.pattern = parent;
|
||||
this.timer = Fawe.get().getTimer();
|
||||
|
@ -10,7 +10,9 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
public class OffsetPattern extends AbstractPattern {
|
||||
|
||||
private final int dx, dy, dz;
|
||||
private final int dx;
|
||||
private final int dy;
|
||||
private final int dz;
|
||||
private transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
private final Pattern pattern;
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class PatternTraverser {
|
||||
Field field = current.getDeclaredField("extent");
|
||||
field.setAccessible(true);
|
||||
field.set(pattern, newExtent);
|
||||
} catch (NoSuchFieldException | IllegalAccessException | ClassCastException ignore) {
|
||||
} catch (NoSuchFieldException | IllegalAccessException | ClassCastException ignored) {
|
||||
}
|
||||
}
|
||||
try {
|
||||
@ -40,21 +40,21 @@ public class PatternTraverser {
|
||||
field.setAccessible(true);
|
||||
Object next = field.get(pattern);
|
||||
reset(next, newExtent);
|
||||
} catch (NoSuchFieldException | IllegalAccessException | ClassCastException ignore) {
|
||||
} catch (NoSuchFieldException | IllegalAccessException | ClassCastException ignored) {
|
||||
}
|
||||
try {
|
||||
Field field = current.getDeclaredField("mask");
|
||||
field.setAccessible(true);
|
||||
Object next = field.get(pattern);
|
||||
reset(next, newExtent);
|
||||
} catch (NoSuchFieldException | IllegalAccessException ignore) {
|
||||
} catch (NoSuchFieldException | IllegalAccessException ignored) {
|
||||
}
|
||||
try {
|
||||
Field field = current.getDeclaredField("material");
|
||||
field.setAccessible(true);
|
||||
Pattern next = (Pattern) field.get(pattern);
|
||||
reset(next, newExtent);
|
||||
} catch (NoSuchFieldException | IllegalAccessException | ClassCastException ignore) {
|
||||
} catch (NoSuchFieldException | IllegalAccessException | ClassCastException ignored) {
|
||||
}
|
||||
try {
|
||||
Field field = current.getDeclaredField("patterns");
|
||||
@ -63,7 +63,7 @@ public class PatternTraverser {
|
||||
for (Pattern next : patterns) {
|
||||
reset(next, newExtent);
|
||||
}
|
||||
} catch (NoSuchFieldException | IllegalAccessException | ClassCastException ignore) {
|
||||
} catch (NoSuchFieldException | IllegalAccessException | ClassCastException ignored) {
|
||||
}
|
||||
current = current.getSuperclass();
|
||||
}
|
||||
|
@ -62,7 +62,9 @@ public class PropertyPattern extends AbstractExtentPattern {
|
||||
}
|
||||
|
||||
private void add(BlockType type, PropertyKey key, Operator operator, MutableCharSequence value, boolean wrap) {
|
||||
if (!type.hasProperty(key)) return;
|
||||
if (!type.hasProperty(key)) {
|
||||
return;
|
||||
}
|
||||
AbstractProperty property = (AbstractProperty) type.getProperty(key);
|
||||
BlockState defaultState = type.getDefaultState();
|
||||
int valueInt;
|
||||
@ -78,9 +80,14 @@ public class PropertyPattern extends AbstractExtentPattern {
|
||||
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
int result = operator.apply(length, valueInt, i);
|
||||
if (wrap) result = MathMan.wrap(result, 0, length - 1);
|
||||
else result = Math.max(Math.min(result, length - 1), 0);
|
||||
if (result == i) continue;
|
||||
if (wrap) {
|
||||
result = MathMan.wrap(result, 0, length - 1);
|
||||
} else {
|
||||
result = Math.max(Math.min(result, length - 1), 0);
|
||||
}
|
||||
if (result == i) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int internalId = valueInt + i;
|
||||
|
||||
@ -88,7 +95,9 @@ public class PropertyPattern extends AbstractExtentPattern {
|
||||
if (type.getProperties().size() > 1) {
|
||||
ArrayList<Property> properties = new ArrayList<>(type.getProperties().size() - 1);
|
||||
for (Property current : type.getProperties()) {
|
||||
if (current == property) continue;
|
||||
if (current == property) {
|
||||
continue;
|
||||
}
|
||||
properties.add(current);
|
||||
}
|
||||
applyRecursive(type, property, properties, 0, state, result);
|
||||
@ -124,7 +133,9 @@ public class PropertyPattern extends AbstractExtentPattern {
|
||||
public PropertyPattern addRegex(String input) {
|
||||
if (input.charAt(input.length() - 1) == ']') {
|
||||
int propStart = StringMan.findMatchingBracket(input, input.length() - 1);
|
||||
if (propStart == -1) return this;
|
||||
if (propStart == -1) {
|
||||
return this;
|
||||
}
|
||||
|
||||
MutableCharSequence charSequence = MutableCharSequence.getTemporal();
|
||||
charSequence.setString(input);
|
||||
@ -142,7 +153,9 @@ public class PropertyPattern extends AbstractExtentPattern {
|
||||
blockTypeList.add(myType);
|
||||
}
|
||||
}
|
||||
if (blockTypeList.size() == 1) type = blockTypeList.get(0);
|
||||
if (blockTypeList.size() == 1) {
|
||||
type = blockTypeList.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
PropertyKey key = null;
|
||||
@ -157,14 +170,17 @@ public class PropertyPattern extends AbstractExtentPattern {
|
||||
case '{':
|
||||
case '(':
|
||||
int next = StringMan.findMatchingBracket(input, i);
|
||||
if (next != -1) i = next;
|
||||
if (next != -1) {
|
||||
i = next;
|
||||
}
|
||||
break;
|
||||
case ']':
|
||||
case ',': {
|
||||
charSequence.setSubstring(last, i);
|
||||
char firstChar = input.charAt(last + 1);
|
||||
if (type != null) add(type, key, operator, charSequence, wrap);
|
||||
else {
|
||||
if (type != null) {
|
||||
add(type, key, operator, charSequence, wrap);
|
||||
} else {
|
||||
for (BlockType myType : blockTypeList) {
|
||||
add(myType, key, operator, charSequence, wrap);
|
||||
}
|
||||
@ -180,8 +196,12 @@ public class PropertyPattern extends AbstractExtentPattern {
|
||||
char cp = input.charAt(i + 1);
|
||||
boolean extra = cp == '=';
|
||||
wrap = cp == '~';
|
||||
if (extra || wrap) i++;
|
||||
if (charSequence.length() > 0) key = PropertyKey.get(charSequence);
|
||||
if (extra || wrap) {
|
||||
i++;
|
||||
}
|
||||
if (charSequence.length() > 0) {
|
||||
key = PropertyKey.get(charSequence);
|
||||
}
|
||||
last = i + 1;
|
||||
}
|
||||
break;
|
||||
|
@ -11,10 +11,14 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import java.util.SplittableRandom;
|
||||
|
||||
public class RandomOffsetPattern extends AbstractPattern {
|
||||
private final int dx, dy, dz;
|
||||
private final int dx;
|
||||
private final int dy;
|
||||
private final int dz;
|
||||
private final Pattern pattern;
|
||||
|
||||
private transient int dx2, dy2, dz2;
|
||||
private transient int dx2;
|
||||
private transient int dy2;
|
||||
private transient int dz2;
|
||||
private transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
private transient SplittableRandom r;
|
||||
|
||||
|
@ -37,10 +37,14 @@ public class SaturatePattern extends AbstractPattern {
|
||||
BlockType block = get.getBlock(extent).getBlockType();
|
||||
TextureUtil util = holder.getTextureUtil();
|
||||
int currentColor = util.getColor(block);
|
||||
if (currentColor == 0) return false;
|
||||
if (currentColor == 0) {
|
||||
return false;
|
||||
}
|
||||
int newColor = util.multiplyColor(currentColor, color);
|
||||
BlockType newBlock = util.getNearestBlock(newColor);
|
||||
if (newBlock.equals(block)) return false;
|
||||
if (newBlock.equals(block)) {
|
||||
return false;
|
||||
}
|
||||
return set.setBlock(extent, newBlock.getDefaultState());
|
||||
}
|
||||
}
|
||||
|
@ -14,10 +14,14 @@ import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||
import java.util.SplittableRandom;
|
||||
|
||||
public class SolidRandomOffsetPattern extends AbstractPattern {
|
||||
private final int dx, dy, dz;
|
||||
private final int dx;
|
||||
private final int dy;
|
||||
private final int dz;
|
||||
private final Pattern pattern;
|
||||
|
||||
private final int dx2, dy2, dz2;
|
||||
private final int dx2;
|
||||
private final int dy2;
|
||||
private final int dz2;
|
||||
private final MutableBlockVector3 mutable;
|
||||
private SplittableRandom r;
|
||||
|
||||
|
@ -18,7 +18,12 @@ public class FuzzyRegion extends AbstractRegion {
|
||||
|
||||
private final Mask mask;
|
||||
private BlockVectorSet set = new BlockVectorSet();
|
||||
private int minX, minY, minZ, maxX, maxY, maxZ;
|
||||
private int minX;
|
||||
private int minY;
|
||||
private int minZ;
|
||||
private int maxX;
|
||||
private int maxY;
|
||||
private int maxZ;
|
||||
private Extent extent;
|
||||
|
||||
{
|
||||
|
@ -281,12 +281,24 @@ public class PolyhedralRegion extends AbstractRegion {
|
||||
final int z = position.getBlockZ();
|
||||
final BlockVector3 min = getMinimumPoint();
|
||||
final BlockVector3 max = getMaximumPoint();
|
||||
if (x < min.getBlockX()) return false;
|
||||
if (x > max.getBlockX()) return false;
|
||||
if (z < min.getBlockZ()) return false;
|
||||
if (z > max.getBlockZ()) return false;
|
||||
if (y < min.getBlockY()) return false;
|
||||
if (y > max.getBlockY()) return false;
|
||||
if (x < min.getBlockX()) {
|
||||
return false;
|
||||
}
|
||||
if (x > max.getBlockX()) {
|
||||
return false;
|
||||
}
|
||||
if (z < min.getBlockZ()) {
|
||||
return false;
|
||||
}
|
||||
if (z > max.getBlockZ()) {
|
||||
return false;
|
||||
}
|
||||
if (y < min.getBlockY()) {
|
||||
return false;
|
||||
}
|
||||
if (y > max.getBlockY()) {
|
||||
return false;
|
||||
}
|
||||
return containsRaw(position);
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,8 @@ public class Triangle {
|
||||
private boolean axisTestX01(double a, double b, double fa, double fb) {
|
||||
double p0 = a * v0[1] - b * v0[2];
|
||||
double p2 = a * v2[1] - b * v2[2];
|
||||
double min, max;
|
||||
double min;
|
||||
double max;
|
||||
if (p0 < p2) {
|
||||
min = p0;
|
||||
max = p2;
|
||||
@ -108,7 +109,8 @@ public class Triangle {
|
||||
private boolean axisTestX2(double a, double b, double fa, double fb) {
|
||||
double p0 = a * v0[1] - b * v0[2];
|
||||
double p1 = a * v1[1] - b * v1[2];
|
||||
double min, max;
|
||||
double min;
|
||||
double max;
|
||||
if (p0 < p1) {
|
||||
min = p0;
|
||||
max = p1;
|
||||
@ -123,7 +125,8 @@ public class Triangle {
|
||||
private boolean axisTestY02(double a, double b, double fa, double fb) {
|
||||
double p0 = -a * v0[0] + b * v0[2];
|
||||
double p2 = -a * v2[0] + b * v2[2];
|
||||
double min, max;
|
||||
double min;
|
||||
double max;
|
||||
if (p0 < p2) {
|
||||
min = p0;
|
||||
max = p2;
|
||||
@ -138,7 +141,8 @@ public class Triangle {
|
||||
private boolean axisTestY1(double a, double b, double fa, double fb) {
|
||||
double p0 = -a * v0[0] + b * v0[2];
|
||||
double p1 = -a * v1[0] + b * v1[2];
|
||||
double min, max;
|
||||
double min;
|
||||
double max;
|
||||
if (p0 < p1) {
|
||||
min = p0;
|
||||
max = p1;
|
||||
@ -153,7 +157,8 @@ public class Triangle {
|
||||
private boolean axisTestZ12(double a, double b, double fa, double fb) {
|
||||
double p1 = a * v1[0] - b * v1[1];
|
||||
double p2 = a * v2[0] - b * v2[1];
|
||||
double min, max;
|
||||
double min;
|
||||
double max;
|
||||
if (p2 < p1) {
|
||||
min = p2;
|
||||
max = p1;
|
||||
@ -168,7 +173,8 @@ public class Triangle {
|
||||
private boolean axisTestZ0(double a, double b, double fa, double fb) {
|
||||
double p0 = a * v0[0] - b * v0[1];
|
||||
double p1 = a * v1[0] - b * v1[1];
|
||||
double min, max;
|
||||
double min;
|
||||
double max;
|
||||
if (p0 < p1) {
|
||||
min = p0;
|
||||
max = p1;
|
||||
@ -182,7 +188,11 @@ public class Triangle {
|
||||
|
||||
|
||||
private boolean overlaps(double[] boxcenter, double[] boxhalfsize, double[][] triverts) {
|
||||
double min, max, fex, fey, fez;
|
||||
double min;
|
||||
double max;
|
||||
double fex;
|
||||
double fey;
|
||||
double fez;
|
||||
sub(v0, triverts[0], boxcenter);
|
||||
sub(v1, triverts[1], boxcenter);
|
||||
sub(v2, triverts[2], boxcenter);
|
||||
|
@ -187,7 +187,9 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
|
||||
for (AbstractProperty property : (List<AbstractProperty<?>>) type.getProperties()) {
|
||||
int propIndex = property.getIndex(block.getInternalId());
|
||||
if (propIndex != 0) {
|
||||
if (properties == null) properties = new HashMap<>();
|
||||
if (properties == null) {
|
||||
properties = new HashMap<>();
|
||||
}
|
||||
Object value = property.getValues().get(propIndex);
|
||||
properties.put(property.getName(), value.toString());
|
||||
}
|
||||
|
@ -65,7 +65,10 @@ public class PNGWriter implements ClipboardWriter {
|
||||
|
||||
boolean fill = length * 4 < imageSize && width * 4 < imageSize;
|
||||
|
||||
MutableBlockVector3 mutable, mutableTop, mutableRight, mutableLeft;
|
||||
MutableBlockVector3 mutable;
|
||||
MutableBlockVector3 mutableTop;
|
||||
MutableBlockVector3 mutableRight;
|
||||
MutableBlockVector3 mutableLeft;
|
||||
mutable = mutableTop = mutableRight = mutableLeft = new MutableBlockVector3(0, 0, 0);
|
||||
// Vector mutableTop = new Vector(0, 0, 0);
|
||||
// Vector mutableRight = new Vector(0, 0, 0);
|
||||
|
@ -129,7 +129,7 @@
|
||||
// URI uri = file.toURI();
|
||||
// ClipboardFormat format = ClipboardFormats.findByFile(file);
|
||||
// format.hold(player, uri, new FileInputStream(file));
|
||||
// player.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.loaded" , filename));
|
||||
// player.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.loaded", filename));
|
||||
// session.setVirtualWorld(null);
|
||||
// return;
|
||||
// }
|
||||
@ -165,7 +165,7 @@
|
||||
// MultiClipboardHolder multi = new MultiClipboardHolder(URI.create(""), new LazyClipboardHolder(uri, source, format, null));
|
||||
// session.addClipboard(multi);
|
||||
// select.put(clicked, true);
|
||||
// player.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.loaded" , file.getName()));
|
||||
// player.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.loaded", file.getName()));
|
||||
// }
|
||||
// }
|
||||
// // Resend relevant chunks
|
||||
@ -590,28 +590,4 @@
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean playEffect(Vector3 position, int type, int data) {
|
||||
// // TODO Auto-generated method stub
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
// // TODO Auto-generated method stub
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean notifyAndLightBlock(BlockVector3 position, BlockState previousType) throws WorldEditException {
|
||||
// // TODO Auto-generated method stub
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public BlockVector3 getSpawnPosition() {
|
||||
// // TODO Auto-generated method stub
|
||||
// return null;
|
||||
// }
|
||||
//}
|
||||
|
@ -61,7 +61,9 @@ public class JoinedCharSequence implements CharSequence {
|
||||
CharSequence anotherString = (CharSequence) obj;
|
||||
if (length == anotherString.length()) {
|
||||
for (int i = length - 1; i >= 0; i--) {
|
||||
if (charAt(i) != anotherString.charAt(i)) return false;
|
||||
if (charAt(i) != anotherString.charAt(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2,7 +2,8 @@ package com.boydti.fawe.object.string;
|
||||
|
||||
public class MutableCharSequence implements CharSequence {
|
||||
private String str;
|
||||
private int start, length;
|
||||
private int start;
|
||||
private int length;
|
||||
|
||||
private static final ThreadLocal<MutableCharSequence> mutableChar = ThreadLocal.withInitial(MutableCharSequence::new);
|
||||
|
||||
@ -16,7 +17,8 @@ public class MutableCharSequence implements CharSequence {
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
public MutableCharSequence() {}
|
||||
public MutableCharSequence() {
|
||||
}
|
||||
|
||||
public void setSubstring(int start, int end) {
|
||||
this.start = start;
|
||||
@ -58,7 +60,9 @@ public class MutableCharSequence implements CharSequence {
|
||||
|
||||
public int indexOf(char c) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (charAt(i) == c) return i;
|
||||
if (charAt(i) == c) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@ -68,7 +72,9 @@ public class MutableCharSequence implements CharSequence {
|
||||
CharSequence anotherString = (CharSequence) obj;
|
||||
if (length == anotherString.length()) {
|
||||
for (int i = length - 1; i >= 0; i--) {
|
||||
if (charAt(i) != anotherString.charAt(i)) return false;
|
||||
if (charAt(i) != anotherString.charAt(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -44,14 +44,18 @@ public class AsyncNotifyQueue implements Closeable {
|
||||
return task.call();
|
||||
} catch (Throwable e) {
|
||||
handler.uncaughtException(Thread.currentThread(), e);
|
||||
if (self[0] != null) self[0].cancel(true);
|
||||
if (self[0] != null) {
|
||||
self[0].cancel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
if (self[0] != null) self[0].cancel(true);
|
||||
if (self[0] != null) {
|
||||
self[0].cancel(true);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
self[0] = Fawe.get().getQueueHandler().async(wrapped);
|
||||
|
@ -30,8 +30,11 @@ public abstract class SingleThreadIntervalQueue<T> {
|
||||
}
|
||||
}
|
||||
synchronized (objMap) {
|
||||
if (!objMap.isEmpty()) TaskManager.IMP.laterAsync(this, interval);
|
||||
else queued.set(false);
|
||||
if (!objMap.isEmpty()) {
|
||||
TaskManager.IMP.laterAsync(this, interval);
|
||||
} else {
|
||||
queued.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -156,7 +156,9 @@ public abstract class DFSVisitor implements Operation {
|
||||
|
||||
public static final class Node {
|
||||
|
||||
private int x, y, z;
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
|
||||
public Node(int x, int y, int z) {
|
||||
this.x = x;
|
||||
|
Reference in New Issue
Block a user