3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-07 12:00:07 +01:00

Remove dead code and minor changes to existing code

Dieser Commit ist enthalten in:
MattBDev 2020-02-18 13:18:43 -05:00
Ursprung 3e718e2e0b
Commit 728b36cd8c
11 geänderte Dateien mit 303 neuen und 1029 gelöschten Zeilen

Datei anzeigen

@ -54,19 +54,19 @@ fun Project.applyPlatformAndCoreConfiguration() {
// Java 8 turns on doclint which we fail
tasks.withType<Javadoc>().configureEach {
delete("docs/javadoc")
setDestinationDir(file("docs/javadoc"))
title = "${project.name} ${project.version} API"
(options as StandardJavadocDocletOptions).addStringOption("author", "true")
//delete("docs/javadoc")
//setDestinationDir(file("docs/javadoc"))
//title = "${project.name} ${project.version} API"
//(options as StandardJavadocDocletOptions).addStringOption("author", "true")
(options as CoreJavadocOptions).addStringOption("Xdoclint:none", "-quiet")
subprojects.forEach { proj ->
proj.tasks.withType<Javadoc>().forEach { javadocTask ->
source += javadocTask.source
classpath += javadocTask.classpath
excludes += javadocTask.excludes
includes += javadocTask.includes
}
}
// subprojects.forEach { proj ->
// proj.tasks.withType<Javadoc>().forEach { javadocTask ->
// source += javadocTask.source
// classpath += javadocTask.classpath
// excludes += javadocTask.excludes
// includes += javadocTask.includes
// }
// }
}
tasks.register<Jar>("javadocJar") {

Datei anzeigen

@ -17,12 +17,12 @@ public class Flood {
private final Long2ObjectLinkedOpenHashMap<int[][]> chunkQueues;
private int[] queue;
private long[] visit;
private int[][] queues;
private long[][] visits;
private final int[][] queues;
private final long[][] visits;
private int chunkX;
private int chunkYLayer;
private int chunkZ;
private ConcurrentLinkedQueue<int[]> queuePool = new ConcurrentLinkedQueue<>();
private final ConcurrentLinkedQueue<int[]> queuePool = new ConcurrentLinkedQueue<>();
public Flood(int maxBranch, int maxDepth, Direction[] directions) {
this.maxBranch = maxBranch;

Datei anzeigen

@ -8,14 +8,18 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import javax.annotation.Nullable;
public abstract class AbstractFilterBlock extends FilterBlock {
@Override
public abstract BaseBlock getFullBlock();
@Override
public abstract void setFullBlock(BaseBlock block);
public abstract BlockVector3 getPosition();
@Override
public abstract Extent getExtent();
@ -76,16 +80,16 @@ public abstract class AbstractFilterBlock extends FilterBlock {
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
throws WorldEditException {
throws WorldEditException {
if (x == this.getX() && y == this.getY() && z == this.getZ()) {
setFullBlock(block.toBaseBlock());
return true;
}
return getExtent().setBlock(x,y, z, block);
return getExtent().setBlock(x, y, z, block);
}
@Override
public boolean setBiome(int x, int y, int z, BiomeType biome) {
return getExtent().setBiome(x, y, z,biome);
return getExtent().setBiome(x, y, z, biome);
}
}

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.beta.implementation.filter.block;
import com.boydti.fawe.beta.Filter;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
@ -9,7 +8,6 @@ import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypesCache;
import javax.annotation.Nullable;
public class ArrayFilterBlock extends AbstractExtentFilterBlock {

Datei anzeigen

@ -396,10 +396,8 @@ public class CharFilterBlock extends ChunkFilterBlock {
public char getOrdinalChar(Extent orDefault) {
return getOrdinalChar();
}
/*
Set delegate
*/
//Set delegate
private SetDelegate initSet() {
setArr = set.load(layer);
return delegate = FULL;

Datei anzeigen

@ -46,7 +46,7 @@ public abstract class ChunkFilterBlock extends AbstractExtentFilterBlock {
/**
* filter a single block
* Filter a single block
* @param filter
* @param x
* @param y

Datei anzeigen

@ -1,819 +0,0 @@
package com.boydti.fawe.beta.implementation.filter.block;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.generator.GenBase;
import com.sk89q.worldedit.function.generator.Resource;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Countable;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Nullable;
public class DelegateFilterBlock extends FilterBlock {
private final FilterBlock parent;
public DelegateFilterBlock(FilterBlock parent) {
this.parent = parent;
}
public static BlockVector3 at(double x, double y, double z) {
return BlockVector3.at(x, y, z);
}
public static BlockVector3 at(int x, int y, int z) {
return BlockVector3.at(x, y, z);
}
public static Comparator<BlockVector3> sortByCoordsYzx() {
return BlockVector3.sortByCoordsYzx();
}
@Override
public Extent getExtent() {
return parent.getExtent();
}
@Override
public boolean hasNbtData() {
return parent.hasNbtData();
}
@Override
public void setBiome(BiomeType biome) {
parent.setBiome(biome);
}
@Override
public int getOrdinal() {
return parent.getOrdinal();
}
@Override
public void setOrdinal(int ordinal) {
parent.setOrdinal(ordinal);
}
@Override
public BlockState getBlock() {
return parent.getBlock();
}
@Override
public void setBlock(BlockState state) {
parent.setBlock(state);
}
@Override
public BaseBlock getFullBlock() {
return parent.getFullBlock();
}
@Override
public void setFullBlock(BaseBlock block) {
parent.setFullBlock(block);
}
@Override
public CompoundTag getNbtData() {
return parent.getNbtData();
}
@Override
public void setNbtData(@Nullable CompoundTag nbtData) {
parent.setNbtData(nbtData);
}
@Override
public BlockVector3 getMinimumPoint() {
return parent.getMinimumPoint();
}
@Override
public BlockVector3 getMaximumPoint() {
return parent.getMaximumPoint();
}
@Override
public BlockState getBlock(int x, int y, int z) {
return parent.getBlock(x, y, z);
}
@Override
public BaseBlock getFullBlock(int x, int y, int z) {
return parent.getFullBlock(x, y, z);
}
@Override
public BlockState getBlockBelow() {
return parent.getBlockBelow();
}
@Override
public BlockState getBlockAbove() {
return parent.getBlockAbove();
}
@Override
public BlockState getBlockNorth() {
return parent.getBlockNorth();
}
@Override
public BlockState getBlockEast() {
return parent.getBlockEast();
}
@Override
public BlockState getBlockSouth() {
return parent.getBlockSouth();
}
@Override
public BlockState getBlockWest() {
return parent.getBlockWest();
}
@Override
public BlockState getBlockRelativeY(int y) {
return parent.getBlockRelativeY(y);
}
@Override
public int getX() {
return parent.getX();
}
@Override
public int getY() {
return parent.getY();
}
@Override
public int getZ() {
return parent.getZ();
}
@Override
public int getLocalX() {
return parent.getLocalX();
}
@Override
public int getLocalY() {
return parent.getLocalY();
}
@Override
public int getLocalZ() {
return parent.getLocalZ();
}
@Override
public int getChunkX() {
return parent.getChunkX();
}
@Override
public int getChunkZ() {
return parent.getChunkZ();
}
@Override
public boolean setOrdinal(Extent orDefault, int ordinal) {
return parent.setOrdinal(orDefault, ordinal);
}
@Override
public boolean setBlock(Extent orDefault, BlockState state) {
return parent.setBlock(orDefault, state);
}
@Override
public boolean setFullBlock(Extent orDefault, BaseBlock block) {
return parent.setFullBlock(orDefault, block);
}
@Override
public boolean setBiome(Extent orDefault, BiomeType biome) {
return parent.setBiome(orDefault, biome);
}
@Override
public int getOrdinal(Extent orDefault) {
return parent.getOrdinal(orDefault);
}
@Override
public BlockState getBlock(Extent orDefault) {
return parent.getBlock(orDefault);
}
@Override
public BaseBlock getFullBlock(Extent orDefault) {
return parent.getFullBlock(orDefault);
}
@Override
public CompoundTag getNbtData(Extent orDefault) {
return parent.getNbtData(orDefault);
}
@Override
public BlockState getOrdinalBelow(Extent orDefault) {
return parent.getOrdinalBelow(orDefault);
}
@Override
public BlockState getStateAbove(Extent orDefault) {
return parent.getStateAbove(orDefault);
}
@Override
public BlockState getStateRelativeY(Extent orDefault, int y) {
return parent.getStateRelativeY(orDefault, y);
}
@Override
public MutableBlockVector3 setComponents(double x, double y, double z) {
return parent.setComponents(x, y, z);
}
@Override
public MutableBlockVector3 setComponents(int x, int y, int z) {
return parent.setComponents(x, y, z);
}
@Override
public MutableBlockVector3 mutX(double x) {
return parent.mutX(x);
}
@Override
public MutableBlockVector3 mutY(double y) {
return parent.mutY(y);
}
@Override
public MutableBlockVector3 mutZ(double z) {
return parent.mutZ(z);
}
@Override
public MutableBlockVector3 mutX(int x) {
return parent.mutX(x);
}
@Override
public MutableBlockVector3 mutY(int y) {
return parent.mutY(y);
}
@Override
public MutableBlockVector3 mutZ(int z) {
return parent.mutZ(z);
}
@Override
public BlockVector3 toImmutable() {
return parent.toImmutable();
}
// @Override
// public BlockVector3 north() {
// return parent.north();
// }
//
// @Override
// public BlockVector3 east() {
// return parent.east();
// }
//
// @Override
// public BlockVector3 south() {
// return parent.south();
// }
//
// @Override
// public BlockVector3 west() {
// return parent.west();
// }
@Override
public int getBlockX() {
return parent.getBlockX();
}
@Override
public BlockVector3 withX(int x) {
return parent.withX(x);
}
@Override
public int getBlockY() {
return parent.getBlockY();
}
@Override
public BlockVector3 withY(int y) {
return parent.withY(y);
}
@Override
public int getBlockZ() {
return parent.getBlockZ();
}
@Override
public BlockVector3 withZ(int z) {
return parent.withZ(z);
}
@Override
public BlockVector3 add(BlockVector3 other) {
return parent.add(other);
}
@Override
public BlockVector3 add(int x, int y, int z) {
return parent.add(x, y, z);
}
@Override
public BlockVector3 add(BlockVector3... others) {
return parent.add(others);
}
@Override
public BlockVector3 subtract(BlockVector3 other) {
return parent.subtract(other);
}
@Override
public BlockVector3 subtract(int x, int y, int z) {
return parent.subtract(x, y, z);
}
@Override
public BlockVector3 subtract(BlockVector3... others) {
return parent.subtract(others);
}
@Override
public BlockVector3 multiply(BlockVector3 other) {
return parent.multiply(other);
}
@Override
public BlockVector3 multiply(int x, int y, int z) {
return parent.multiply(x, y, z);
}
@Override
public BlockVector3 multiply(BlockVector3... others) {
return parent.multiply(others);
}
@Override
public BlockVector3 multiply(int n) {
return parent.multiply(n);
}
@Override
public BlockVector3 divide(BlockVector3 other) {
return parent.divide(other);
}
@Override
public BlockVector3 divide(int x, int y, int z) {
return parent.divide(x, y, z);
}
@Override
public BlockVector3 divide(int n) {
return parent.divide(n);
}
@Override
public BlockVector3 shr(int x, int y, int z) {
return parent.shr(x, y, z);
}
@Override
public BlockVector3 shr(int n) {
return parent.shr(n);
}
@Override
public BlockVector3 shl(int x, int y, int z) {
return parent.shl(x, y, z);
}
@Override
public BlockVector3 shl(int n) {
return parent.shl(n);
}
@Override
public double length() {
return parent.length();
}
@Override
public int lengthSq() {
return parent.lengthSq();
}
@Override
public double distance(BlockVector3 other) {
return parent.distance(other);
}
@Override
public int distanceSq(BlockVector3 other) {
return parent.distanceSq(other);
}
@Override
public BlockVector3 normalize() {
return parent.normalize();
}
@Override
public double dot(BlockVector3 other) {
return parent.dot(other);
}
@Override
public BlockVector3 cross(BlockVector3 other) {
return parent.cross(other);
}
@Override
public boolean containedWithin(BlockVector3 min, BlockVector3 max) {
return parent.containedWithin(min, max);
}
@Override
public BlockVector3 clampY(int min, int max) {
return parent.clampY(min, max);
}
@Override
public BlockVector3 floor() {
return parent.floor();
}
@Override
public BlockVector3 ceil() {
return parent.ceil();
}
@Override
public BlockVector3 round() {
return parent.round();
}
@Override
public BlockVector3 abs() {
return parent.abs();
}
@Override
public BlockVector3 transform2D(double angle, double aboutX, double aboutZ, double translateX,
double translateZ) {
return parent.transform2D(angle, aboutX, aboutZ, translateX, translateZ);
}
@Override
public double toPitch() {
return parent.toPitch();
}
@Override
public double toYaw() {
return parent.toYaw();
}
@Override
public BlockVector3 getMinimum(BlockVector3 v2) {
return parent.getMinimum(v2);
}
@Override
public BlockVector3 getMaximum(BlockVector3 v2) {
return parent.getMaximum(v2);
}
@Override
public char getOrdinalChar(Extent orDefault) {
return parent.getOrdinalChar(orDefault);
}
@Override
public BlockVector2 toBlockVector2() {
return parent.toBlockVector2();
}
@Override
public Vector3 toVector3() {
return parent.toVector3();
}
@Override
public boolean equals(Object obj) {
return parent.equals(obj);
}
@Override
public int hashCode() {
return parent.hashCode();
}
@Override
public String toString() {
return parent.toString();
}
@Override
public List<? extends Entity> getEntities(Region region) {
return parent.getEntities(region);
}
@Override
public List<? extends Entity> getEntities() {
return parent.getEntities();
}
@Override
@Nullable
public Entity createEntity(Location location, BaseEntity entity) {
return parent.createEntity(location, entity);
}
@Override
public void removeEntity(int x, int y, int z, UUID uuid) {
parent.removeEntity(x, y, z, uuid);
}
@Override
public boolean isQueueEnabled() {
return parent.isQueueEnabled();
}
@Override
public void enableQueue() {
parent.enableQueue();
}
@Override
public void disableQueue() {
parent.disableQueue();
}
@Override
public boolean isWorld() {
return parent.isWorld();
}
@Override
public boolean regenerateChunk(int x, int z, @Nullable BiomeType type, @Nullable Long seed) {
return parent.regenerateChunk(x, z, type, seed);
}
@Override
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
return parent.getHighestTerrainBlock(x, z, minY, maxY);
}
@Override
public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) {
return parent.getHighestTerrainBlock(x, z, minY, maxY, filter);
}
@Override
public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) {
return parent.getNearestSurfaceLayer(x, z, y, minY, maxY);
}
@Override
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY,
boolean ignoreAir) {
return parent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, ignoreAir);
}
@Override
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
return parent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY);
}
@Override
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin,
int failedMax) {
return parent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax);
}
@Override
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin,
int failedMax, Mask mask) {
return parent
.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask);
}
@Override
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin,
int failedMax, boolean ignoreAir) {
return parent
.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir);
}
@Override
public void addCaves(Region region) throws WorldEditException {
parent.addCaves(region);
}
@Override
public void generate(Region region, GenBase gen) throws WorldEditException {
parent.generate(region, gen);
}
@Override
public void addSchems(Region region, Mask mask, List<ClipboardHolder> clipboards, int rarity,
boolean rotate) throws WorldEditException {
parent.addSchems(region, mask, clipboards, rarity, rotate);
}
@Override
public void spawnResource(Region region, Resource gen, int rarity, int frequency)
throws WorldEditException {
parent.spawnResource(region, gen, rarity, frequency);
}
@Override
public boolean contains(BlockVector3 pt) {
return parent.contains(pt);
}
@Override
public void addOre(Region region, Mask mask, Pattern material, int size, int frequency,
int rarity, int minY, int maxY) throws WorldEditException {
parent.addOre(region, mask, material, size, frequency, rarity, minY, maxY);
}
@Override
public void addOres(Region region, Mask mask) throws WorldEditException {
parent.addOres(region, mask);
}
@Override
public List<Countable<BlockType>> getBlockDistribution(Region region) {
return parent.getBlockDistribution(region);
}
@Override
public List<Countable<BlockState>> getBlockDistributionWithData(Region region) {
return parent.getBlockDistributionWithData(region);
}
@Override
public Clipboard lazyCopy(Region region) {
return parent.lazyCopy(region);
}
@Override
public int countBlocks(Region region, Set<BaseBlock> searchBlocks) {
return parent.countBlocks(region, searchBlocks);
}
@Override
public int countBlocks(Region region, Mask searchMask) {
return parent.countBlocks(region, searchMask);
}
@Override
public <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
return parent.setBlocks(region, block);
}
@Override
public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
return parent.setBlocks(region, pattern);
}
@Override
public <B extends BlockStateHolder<B>> int replaceBlocks(Region region, Set<BaseBlock> filter, B replacement) throws MaxChangedBlocksException {
return parent.replaceBlocks(region, filter, replacement);
}
@Override
public int replaceBlocks(Region region, Set<BaseBlock> filter, Pattern pattern) throws MaxChangedBlocksException {
return parent.replaceBlocks(region, filter, pattern);
}
@Override
public int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException {
return parent.replaceBlocks(region, mask, pattern);
}
@Override
public int center(Region region, Pattern pattern) throws MaxChangedBlocksException {
return parent.center(region, pattern);
}
@Override
public int setBlocks(Set<BlockVector3> vset, Pattern pattern) {
return parent.setBlocks(vset, pattern);
}
@Override
@Nullable
public Operation commit() {
return parent.commit();
}
@Override
public boolean cancel() {
return parent.cancel();
}
@Override
public int getMaxY() {
return parent.getMaxY();
}
@Override
public BlockState getBlock(BlockVector3 position) {
return parent.getBlock(position);
}
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
return parent.getFullBlock(position);
}
@Override
public BiomeType getBiome(BlockVector2 position) {
return parent.getBiome(position);
}
@Override
public BiomeType getBiomeType(int x, int y, int z) {
return parent.getBiomeType(x, y, z);
}
@Deprecated
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block)
throws WorldEditException {
return parent.setBlock(position, block);
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
throws WorldEditException {
return parent.setBlock(x, y, z, block);
}
@Override
public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException {
return parent.setTile(x, y, z, tile);
}
@Override
public boolean setBiome(BlockVector2 position, BiomeType biome) {
return parent.setBiome(position, biome);
}
@Override
public boolean setBiome(int x, int y, int z, BiomeType biome) {
return parent.setBiome(x, y, z, biome);
}
@Override
public String getNbtId() {
return parent.getNbtId();
}
}

Datei anzeigen

@ -1,39 +0,0 @@
package com.boydti.fawe.beta.implementation.filter.block;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import javax.annotation.Nullable;
public class MultiFilterBlock extends DelegateFilterBlock {
private final FilterBlock[] blocks;
private final int length;
public MultiFilterBlock(FilterBlock... blocks) {
super(blocks[0]);
this.blocks = blocks;
this.length = blocks.length;
}
@Override
public void setOrdinal(int ordinal) {
for (int i = 0; i < length; i++) blocks[i].setOrdinal(ordinal);
}
@Override
public void setBlock(BlockState state) {
for (int i = 0; i < length; i++) blocks[i].setBlock(state);
}
@Override
public void setFullBlock(BaseBlock block) {
for (int i = 0; i < length; i++) blocks[i].setFullBlock(block);
}
@Override
public void setNbtData(@Nullable CompoundTag nbtData) {
for (int i = 0; i < length; i++) blocks[i].setNbtData(nbtData);
}
}

Datei anzeigen

@ -7,12 +7,8 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IBlocks;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.filter.block.AbstractFilterBlock;
import com.boydti.fawe.beta.implementation.filter.block.ArrayFilterBlock;
import com.boydti.fawe.beta.implementation.filter.block.MultiFilterBlock;
import com.boydti.fawe.beta.implementation.filter.block.SingleFilterBlock;
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
import com.boydti.fawe.beta.implementation.blocks.FallbackChunkGet;
import com.boydti.fawe.beta.implementation.filter.block.ArrayFilterBlock;
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
import com.boydti.fawe.jnbt.anvil.MCAChunk;
import com.boydti.fawe.object.FaweInputStream;
@ -39,7 +35,6 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operation;
@ -59,7 +54,6 @@ import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockID;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -79,7 +73,9 @@ import java.util.concurrent.ThreadLocalRandom;
import java.util.function.Supplier;
import javax.annotation.Nullable;
public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Drawable, VirtualWorld {
public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Drawable,
VirtualWorld {
private final MutableBlockVector3 mutable = new MutableBlockVector3();
private final DifferentialBlockBuffer blocks;
@ -95,6 +91,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
private CFIPrimitives oldPrimitives = new CFIPrimitives();
public final class CFIPrimitives implements Cloneable {
int waterHeight;
int floorThickness;
int worldThickness;
@ -111,7 +108,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
try {
for (Field field : CFIPrimitives.class.getDeclaredFields()) {
if (field.get(this) != field.get(obj)) return false;
if (field.get(this) != field.get(obj)) {
return false;
}
}
} catch (IllegalAccessException e) {
e.printStackTrace();
@ -132,9 +131,12 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
floor.flushChanges(out);
main.flushChanges(out);
out.writeBoolean(overlay != null);
if (overlay != null) overlay.flushChanges(out);
if (overlay != null) {
overlay.flushChanges(out);
}
try {
for (Field field : ReflectionUtils.sortFields(CFIPrimitives.class.getDeclaredFields())) {
for (Field field : ReflectionUtils
.sortFields(CFIPrimitives.class.getDeclaredFields())) {
Object now = field.get(primitives);
Object old = field.get(oldPrimitives);
boolean diff = old != now;
@ -154,10 +156,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
public boolean isModified() {
return blocks.isModified() ||
heights.isModified() ||
biomes.isModified() ||
heights.isModified() ||
biomes.isModified() ||
overlay != null && overlay.isModified() ||
!primitives.equals(oldPrimitives);
!primitives.equals(oldPrimitives);
}
private void resetPrimitives() throws CloneNotSupportedException {
@ -170,9 +172,12 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
biomes.undoChanges(in);
floor.undoChanges(in);
main.undoChanges(in);
if (in.readBoolean()) overlay.undoChanges(in);
if (in.readBoolean()) {
overlay.undoChanges(in);
}
try {
for (Field field : ReflectionUtils.sortFields(CFIPrimitives.class.getDeclaredFields())) {
for (Field field : ReflectionUtils
.sortFields(CFIPrimitives.class.getDeclaredFields())) {
if (in.readBoolean()) {
field.set(primitives, in.readPrimitive(field.getType())); // old
in.readPrimitive(field.getType()); // new
@ -191,10 +196,13 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
biomes.redoChanges(in);
floor.redoChanges(in);
main.redoChanges(in);
if (in.readBoolean()) overlay.redoChanges(in);
if (in.readBoolean()) {
overlay.redoChanges(in);
}
try {
for (Field field : ReflectionUtils.sortFields(CFIPrimitives.class.getDeclaredFields())) {
for (Field field : ReflectionUtils
.sortFields(CFIPrimitives.class.getDeclaredFields())) {
if (in.readBoolean()) {
in.readPrimitive(field.getType()); // old
field.set(primitives, in.readPrimitive(field.getType())); // new
@ -208,7 +216,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
blocks.clearChanges(); // blocks.redoChanges(in); Unsupported
}
// @Override TODO NOT IMPLEMENTED
// @Override TODO NOT IMPLEMENTED
public void addEditSession(EditSession session) {
session.setFastMode(true);
this.editSession = session;
@ -261,7 +269,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
this.player = player;
if (player != null) {
Location pos = player.getLocation();
this.chunkOffset = BlockVector2.at(1 + (pos.getBlockX() >> 4), 1 + (pos.getBlockZ() >> 4));
this.chunkOffset = BlockVector2
.at(1 + (pos.getBlockX() >> 4), 1 + (pos.getBlockZ() >> 4));
}
}
@ -271,7 +280,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
private char[][][] getChunkArray(int x, int z) {
char[][][][][] blocksData = blocks.get();
if (blocksData == null) return null;
if (blocksData == null) {
return null;
}
char[][][][] arr = blocksData[z];
return arr != null ? arr[x] : null;
}
@ -295,7 +306,6 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
int lenCX = (getWidth() + 15) >> 4;
int lenCZ = (getLength() + 15) >> 4;
Location position = player.getLocation();
int pcx = (position.getBlockX() >> 4) - chunkOffset.getBlockX();
int pcz = (position.getBlockZ() >> 4) - chunkOffset.getBlockZ();
@ -444,7 +454,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
for (int x = minX; x <= maxX; x++, index++, localIndex++) {
int combined = floor[index];
if (BlockTypes.getFromStateOrdinal(combined) == BlockTypes.SNOW) {
layers[localIndex] = (char) (((heights[index] & 0xFF) << 3) + (floor[index] >> BlockTypesCache.BIT_OFFSET) - 7);
layers[localIndex] = (char) (
((heights[index] & 0xFF) << 3) + (floor[index]
>> BlockTypesCache.BIT_OFFSET) - 7);
} else {
layers[localIndex] = (char) ((heights[index] & 0xFF) << 3);
}
@ -480,10 +492,12 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
case BlockID.SNOW_BLOCK:
if (layerHeight != 0) {
this.heights.setByte(index, (byte) (blockHeight + 1));
this.floor.setInt(index, BlockTypes.SNOW.getDefaultState().getOrdinalChar() + layerHeight);
this.floor.setInt(index,
BlockTypes.SNOW.getDefaultState().getOrdinalChar() + layerHeight);
} else {
this.heights.setByte(index, (byte) blockHeight);
this.floor.setInt(index, BlockTypes.SNOW_BLOCK.getDefaultState().getOrdinalChar());
this.floor
.setInt(index, BlockTypes.SNOW_BLOCK.getDefaultState().getOrdinalChar());
}
break;
default:
@ -505,10 +519,12 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
case BlockID.SNOW_BLOCK:
if (layerHeight != 0) {
this.heights.getByteArray()[index] = (byte) (blockHeight + 1);
this.overlay.getCharArray()[index] = (char) (BlockTypes.SNOW.getDefaultState().getOrdinalChar() + layerHeight);
this.overlay.getCharArray()[index] = (char) (
BlockTypes.SNOW.getDefaultState().getOrdinalChar() + layerHeight);
} else {
this.heights.getByteArray()[index] = (byte) blockHeight;
this.overlay.getCharArray()[index] = BlockTypes.SNOW_BLOCK.getDefaultState().getOrdinalChar();
this.overlay.getCharArray()[index] = BlockTypes.SNOW_BLOCK.getDefaultState()
.getOrdinalChar();
}
break;
default:
@ -532,7 +548,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
for (int i = 0; i < heights.length; i++) {
int combined = floor[i];
if (BlockTypes.getFromStateOrdinal(combined) == BlockTypes.SNOW) {
layers[i] = (char) (((heights[i] & 0xFF) << 3) + (floor[i] >> BlockTypesCache.BIT_OFFSET) - 7);
layers[i] = (char) (
((heights[i] & 0xFF) << 3) + (floor[i] >> BlockTypesCache.BIT_OFFSET)
- 7);
} else {
layers[i] = (char) ((heights[i] & 0xFF) << 3);
}
@ -544,7 +562,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
.nextInt(256) <= height) {
.nextInt(256) <= height) {
int newHeight = table.average(x, z, index);
setLayerHeightRaw(index, newHeight);
}
@ -585,19 +603,25 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
public void addCaves() throws WorldEditException {
CuboidRegion region = new CuboidRegion(BlockVector3.at(0, 0, 0), BlockVector3.at(getWidth() -1, 255, getLength() -1));
CuboidRegion region = new CuboidRegion(BlockVector3.at(0, 0, 0),
BlockVector3.at(getWidth() - 1, 255, getLength() - 1));
addCaves(region);
}
@Deprecated
public void addSchems(Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean rotate) throws WorldEditException {
CuboidRegion region = new CuboidRegion(BlockVector3.at(0, 0, 0), BlockVector3.at(getWidth() -1, 255, getLength() -1));
public void addSchems(Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean rotate)
throws WorldEditException {
CuboidRegion region = new CuboidRegion(BlockVector3.at(0, 0, 0),
BlockVector3.at(getWidth() - 1, 255, getLength() - 1));
addSchems(region, mask, clipboards, rarity, rotate);
}
public void addSchems(BufferedImage img, Mask mask, List<ClipboardHolder> clipboards, int rarity, int distance, boolean randomRotate) throws WorldEditException {
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
public void addSchems(BufferedImage img, Mask mask, List<ClipboardHolder> clipboards,
int rarity, int distance, boolean randomRotate) throws WorldEditException {
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) {
throw new IllegalArgumentException(
"Input image dimensions do not match the current height map!");
}
double doubleRarity = rarity / 100d;
int index = 0;
AffineTransform identity = new AffineTransform();
@ -607,7 +631,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
for (int x = 0; x < getWidth(); x++, index++) {
int y = heights.getByte(index) & 0xFF;
int height = img.getRGB(x, z) & 0xFF;
if (height == 0 || ThreadLocalRandom.current().nextInt(256) > height * doubleRarity) {
if (height == 0
|| ThreadLocalRandom.current().nextInt(256) > height * doubleRarity) {
continue;
}
mutable.mutX(x);
@ -619,11 +644,13 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
continue;
}
placed.add(x, z);
ClipboardHolder holder = clipboards.get(ThreadLocalRandom.current().nextInt(clipboards.size()));
ClipboardHolder holder = clipboards
.get(ThreadLocalRandom.current().nextInt(clipboards.size()));
if (randomRotate) {
int rotate = ThreadLocalRandom.current().nextInt(4) * 90;
if (rotate != 0) {
holder.setTransform(new AffineTransform().rotateY(ThreadLocalRandom.current().nextInt(4) * 90));
holder.setTransform(new AffineTransform()
.rotateY(ThreadLocalRandom.current().nextInt(4) * 90));
} else {
holder.setTransform(identity);
}
@ -645,7 +672,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
}
public void addSchems(Mask mask, List<ClipboardHolder> clipboards, int rarity, int distance, boolean randomRotate) throws WorldEditException {
public void addSchems(Mask mask, List<ClipboardHolder> clipboards, int rarity, int distance,
boolean randomRotate) throws WorldEditException {
int scaledRarity = 256 * rarity / 100;
int index = 0;
AffineTransform identity = new AffineTransform();
@ -667,11 +695,13 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
mutable.mutY(y + 1);
placed.add(x, z);
ClipboardHolder holder = clipboards.get(ThreadLocalRandom.current().nextInt(clipboards.size()));
ClipboardHolder holder = clipboards
.get(ThreadLocalRandom.current().nextInt(clipboards.size()));
if (randomRotate) {
int rotate = ThreadLocalRandom.current().nextInt(4) * 90;
if (rotate != 0) {
holder.setTransform(new AffineTransform().rotateY(ThreadLocalRandom.current().nextInt(4) * 90));
holder.setTransform(new AffineTransform()
.rotateY(ThreadLocalRandom.current().nextInt(4) * 90));
} else {
holder.setTransform(identity);
}
@ -693,13 +723,16 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
}
public void addOre(Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
CuboidRegion region = new CuboidRegion(BlockVector3.at(0, 0, 0), BlockVector3.at(getWidth() -1, 255, getLength() -1));
public void addOre(Mask mask, Pattern material, int size, int frequency, int rarity, int minY,
int maxY) throws WorldEditException {
CuboidRegion region = new CuboidRegion(BlockVector3.at(0, 0, 0),
BlockVector3.at(getWidth() - 1, 255, getLength() - 1));
addOre(region, mask, material, size, frequency, rarity, minY, maxY);
}
public void addDefaultOres(Mask mask) throws WorldEditException {
addOres(new CuboidRegion(BlockVector3.at(0, 0, 0), BlockVector3.at(getWidth() -1, 255, getLength() -1)), mask);
addOres(new CuboidRegion(BlockVector3.at(0, 0, 0),
BlockVector3.at(getWidth() - 1, 255, getLength() - 1)), mask);
}
@Override
@ -718,13 +751,16 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
@Override
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block) throws WorldEditException {
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block)
throws WorldEditException {
return setBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ(), block);
}
private boolean setBlock(int x, int y, int z, char combined) {
int index = z * getWidth() + x;
if (index < 0 || index >= getArea()) return false;
if (index < 0 || index >= getArea()) {
return false;
}
int height = heights.getByte(index) & 0xFF;
switch (y - height) {
case 0:
@ -738,7 +774,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
byte currentHeight = heights.getByte(index);
currentHeight++;
heights.setByte(index, currentHeight);
if (mainId == floorId) return true;
if (mainId == floorId) {
return true;
}
y--;
combined = floorId;
default:
@ -754,7 +792,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
@Override
public boolean setBiome(int x, int y, int z, BiomeType biome) {
int index = z * getWidth() + x;
if (index < 0 || index >= getArea()) return false;
if (index < 0 || index >= getArea()) {
return false;
}
biomes.setByte(index, (byte) biome.getInternalId());
return true;
}
@ -904,14 +944,20 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
@Override
public BiomeType getBiomeType(int x, int y, int z) throws FaweChunkLoadException {
int index = z * getWidth() + x;
if (index < 0 || index >= getArea()) index = Math.floorMod(index, getArea());
if (index < 0 || index >= getArea()) {
index = Math.floorMod(index, getArea());
}
return BiomeTypes.get(biomes.getByte(index));
}
public int getOrdinal(int x, int y, int z) throws FaweChunkLoadException {
int index = z * getWidth() + x;
if (y < 0) return 0;
if (index < 0 || index >= getArea() || x < 0 || x >= getWidth()) return 0;
if (y < 0) {
return 0;
}
if (index < 0 || index >= getArea() || x < 0 || x >= getWidth()) {
return 0;
}
int height = heights.getByte(index) & 0xFF;
if (y > height) {
if (y == height + 1) {
@ -951,7 +997,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
@Override
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block)
throws WorldEditException {
return this.setBlock(x, y, z, block.getOrdinalChar());
}
@ -992,27 +1039,36 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
@Override
public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) {
int index = z * getWidth() + x;
if (index < 0 || index >= getArea()) index = Math.floorMod(index, getArea());
if (index < 0 || index >= getArea()) {
index = Math.floorMod(index, getArea());
}
return ((heights.getByte(index) & 0xFF) << 3) + (overlay.getChar(index) & 0xFF) + 1;
}
@Override
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
int index = z * getWidth() + x;
if (index < 0 || index >= getArea()) index = Math.floorMod(index, getArea());
if (index < 0 || index >= getArea()) {
index = Math.floorMod(index, getArea());
}
return heights.getByte(index) & 0xFF;
}
@Override
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) {
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin,
int failedMax) {
int index = z * getWidth() + x;
if (index < 0 || index >= getArea()) index = Math.floorMod(index, getArea());
if (index < 0 || index >= getArea()) {
index = Math.floorMod(index, getArea());
}
return heights.getByte(index) & 0xFF;
}
public void setBiome(BufferedImage img, BiomeType biome, boolean white) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) {
throw new IllegalArgumentException(
"Input image dimensions do not match the current height map!");
}
byte biomeByte = (byte) biome.getInternalId();
biomes.record(new Runnable() {
@Override
@ -1023,7 +1079,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
.nextInt(256) <= height) {
.nextInt(256) <= height) {
biomeArr[index] = biomeByte;
}
}
@ -1045,13 +1101,16 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
return (primitives.biomePriority + 32768) * 100 / 65536;
}
public void setBlockAndBiomeColor(BufferedImage img, Mask mask, BufferedImage imgMask, boolean whiteOnly) {
public void setBlockAndBiomeColor(BufferedImage img, Mask mask, BufferedImage imgMask,
boolean whiteOnly) {
if (mask == null && imgMask == null) {
setBlockAndBiomeColor(img);
return;
}
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) {
throw new IllegalArgumentException(
"Input image dimensions do not match the current height map!");
}
TextureUtil textureUtil = getTextureUtil();
int widthIndex = img.getWidth() - 1;
@ -1071,15 +1130,20 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
if (mask != null) {
mutable.mutX(z);
mutable.mutY(heights.getByte(index) & 0xFF);
if (!mask.test(this, mutable)) continue;
if (!mask.test(this, mutable)) {
continue;
}
}
if (imgMask != null) {
int height = imgMask.getRGB(x, z) & 0xFF;
if (height != 255 && (height <= 0 || !whiteOnly || ThreadLocalRandom
.current().nextInt(256) > height)) continue;
.current().nextInt(256) > height)) {
continue;
}
}
int color = img.getRGB(x, z);
if (textureUtil.getIsBlockCloserThanBiome(buffer, color, primitives.biomePriority)) {
if (textureUtil
.getIsBlockCloserThanBiome(buffer, color, primitives.biomePriority)) {
char combined = buffer[0];
mainArr[index] = combined;
floorArr[index] = combined;
@ -1091,8 +1155,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
public void setBlockAndBiomeColor(BufferedImage img) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) {
throw new IllegalArgumentException(
"Input image dimensions do not match the current height map!");
}
TextureUtil textureUtil = getTextureUtil();
int heightIndex = img.getHeight() - 1;
@ -1106,7 +1172,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
for (int y = 0; y < img.getHeight(); y++) {
for (int x = 0; x < img.getWidth(); x++, index++) {
int color = img.getRGB(x, y);
if (textureUtil.getIsBlockCloserThanBiome(buffer, color, primitives.biomePriority)) {
if (textureUtil
.getIsBlockCloserThanBiome(buffer, color, primitives.biomePriority)) {
char combined = buffer[0];
mainArr[index] = combined;
floorArr[index] = combined;
@ -1118,8 +1185,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
public void setBiomeColor(BufferedImage img) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) {
throw new IllegalArgumentException(
"Input image dimensions do not match the current height map!");
}
TextureUtil textureUtil = getTextureUtil();
biomes.record(() -> {
@ -1139,10 +1208,14 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
public void setColor(BufferedImage img, BufferedImage mask, boolean white) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (mask.getWidth() != getWidth() || mask.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) {
throw new IllegalArgumentException(
"Input image dimensions do not match the current height map!");
}
if (mask.getWidth() != getWidth() || mask.getHeight() != getLength()) {
throw new IllegalArgumentException(
"Input image dimensions do not match the current height map!");
}
primitives.modifiedMain = true;
TextureUtil textureUtil = getTextureUtil();
@ -1155,7 +1228,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
for (int x = 0; x < getWidth(); x++, index++) {
int height = mask.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
.nextInt(256) <= height) {
.nextInt(256) <= height) {
int color = img.getRGB(x, z);
BlockType block = textureUtil.getNearestBlock(color);
if (block != null) {
@ -1170,12 +1243,13 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
public void setColor(BufferedImage img, Mask mask) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) {
throw new IllegalArgumentException(
"Input image dimensions do not match the current height map!");
}
primitives.modifiedMain = true;
TextureUtil textureUtil = getTextureUtil();
floor.record(() -> main.record(() -> {
char[] mainArr = main.get();
char[] floorArr = floor.get();
@ -1201,8 +1275,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
public void setColor(BufferedImage img) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) {
throw new IllegalArgumentException(
"Input image dimensions do not match the current height map!");
}
primitives.modifiedMain = true;
TextureUtil textureUtil = getTextureUtil();
@ -1227,8 +1303,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
public void setColorWithGlass(BufferedImage img) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) {
throw new IllegalArgumentException(
"Input image dimensions do not match the current height map!");
}
TextureUtil textureUtil = getTextureUtil();
floor.record(() -> main.record(() -> {
@ -1272,20 +1350,23 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
} else if (pattern instanceof BlockType) {
setOverlay(img, ((BlockType) pattern).getDefaultState().getOrdinalChar(), white);
} else {
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) {
throw new IllegalArgumentException(
"Input image dimensions do not match the current height map!");
}
if (overlay == null) {
overlay = new DifferentialArray<>(new char[getArea()]);
}
overlay.record(() -> {
ArrayFilterBlock filter = new ArrayFilterBlock(this, overlay.get(), heights.get(), getWidth(), getLength(), 1);
ArrayFilterBlock filter = new ArrayFilterBlock(this, overlay.get(), heights.get(),
getWidth(), getLength(), 1);
int index = 0;
for (int z = 0; z < getLength(); z++) {
for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
.nextInt(256) <= height) {
.nextInt(256) <= height) {
filter.init(x, z, index);
pattern.apply(this, filter, filter);
}
@ -1300,18 +1381,21 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
if (pattern instanceof BlockStateHolder) {
setMain(img, ((BlockStateHolder) pattern).getOrdinalChar(), white);
} else {
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) {
throw new IllegalArgumentException(
"Input image dimensions do not match the current height map!");
}
primitives.modifiedMain = true;
main.record(() -> {
ArrayFilterBlock filter = new ArrayFilterBlock(this, main.get(), heights.get(), getWidth(), getLength(), -1);
ArrayFilterBlock filter = new ArrayFilterBlock(this, main.get(), heights.get(),
getWidth(), getLength(), -1);
int index = 0;
for (int z = 0; z < getLength(); z++) {
for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
.nextInt(256) <= height) {
.nextInt(256) <= height) {
filter.init(x, z, index);
pattern.apply(this, filter, filter);
}
@ -1325,17 +1409,20 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
if (pattern instanceof BlockStateHolder) {
setFloor(img, ((BlockStateHolder) pattern).getOrdinalChar(), white);
} else {
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) {
throw new IllegalArgumentException(
"Input image dimensions do not match the current height map!");
}
floor.record(() -> {
ArrayFilterBlock filter = new ArrayFilterBlock(this, floor.get(), heights.get(), getWidth(), getLength(), 1);
ArrayFilterBlock filter = new ArrayFilterBlock(this, floor.get(), heights.get(),
getWidth(), getLength(), 1);
int index = 0;
for (int z = 0; z < getLength(); z++) {
for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
.nextInt(256) <= height) {
.nextInt(256) <= height) {
filter.init(x, z, index);
pattern.apply(this, filter, filter);
}
@ -1349,20 +1436,24 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
if (pattern instanceof BlockStateHolder) {
setColumn(img, ((BlockStateHolder) pattern).getOrdinalChar(), white);
} else {
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) {
throw new IllegalArgumentException(
"Input image dimensions do not match the current height map!");
}
primitives.modifiedMain = true;
main.record(() -> floor.record(() -> {
ArrayFilterBlock filterFloor = new ArrayFilterBlock(this, floor.get(), heights.get(), getWidth(), getLength(), 0);
ArrayFilterBlock filterMain = new ArrayFilterBlock(this, main.get(), heights.get(), getWidth(), getLength(), -1);
ArrayFilterBlock filterFloor = new ArrayFilterBlock(this, floor.get(),
heights.get(), getWidth(), getLength(), 0);
ArrayFilterBlock filterMain = new ArrayFilterBlock(this, main.get(), heights.get(),
getWidth(), getLength(), -1);
int index = 0;
for (int z = 0; z < getLength(); z++) {
for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
.nextInt(256) <= height) {
.nextInt(256) <= height) {
filterFloor.init(x, z, index);
filterMain.init(x, z, index);
@ -1379,9 +1470,12 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
if (pattern instanceof BlockStateHolder) {
setOverlay(mask, ((BlockStateHolder) pattern).getOrdinalChar());
} else {
if (overlay == null) overlay = new DifferentialArray<>(new char[getArea()]);
if (overlay == null) {
overlay = new DifferentialArray<>(new char[getArea()]);
}
overlay.record(() -> {
ArrayFilterBlock filter = new ArrayFilterBlock(this, overlay.get(), heights.get(), getWidth(), getLength(), 1);
ArrayFilterBlock filter = new ArrayFilterBlock(this, overlay.get(), heights.get(),
getWidth(), getLength(), 1);
int index = 0;
for (int z = 0; z < getLength(); z++) {
for (int x = 0; x < getWidth(); x++, index++) {
@ -1401,7 +1495,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
setFloor(mask, ((BlockStateHolder) pattern).getOrdinalChar());
} else {
floor.record(() -> {
ArrayFilterBlock filter = new ArrayFilterBlock(this, floor.get(), heights.get(), getWidth(), getLength(), 0);
ArrayFilterBlock filter = new ArrayFilterBlock(this, floor.get(), heights.get(),
getWidth(), getLength(), 0);
int index = 0;
for (int z = 0; z < getLength(); z++) {
for (int x = 0; x < getWidth(); x++, index++) {
@ -1420,7 +1515,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
setMain(mask, ((BlockStateHolder) pattern).getOrdinalChar());
} else {
main.record(() -> {
ArrayFilterBlock filter = new ArrayFilterBlock(this, main.get(), heights.get(), getWidth(), getLength(), -1);
ArrayFilterBlock filter = new ArrayFilterBlock(this, main.get(), heights.get(),
getWidth(), getLength(), -1);
primitives.modifiedMain = true;
int index = 0;
for (int z = 0; z < getLength(); z++) {
@ -1439,8 +1535,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
setColumn(mask, ((BlockStateHolder) pattern).getOrdinalChar());
} else {
floor.record(() -> main.record(() -> {
ArrayFilterBlock floorFilter = new ArrayFilterBlock(this, floor.get(), heights.get(), getWidth(), getLength(), 0);
ArrayFilterBlock mainFilter = new ArrayFilterBlock(this, main.get(), heights.get(), getWidth(), getLength(), -1);
ArrayFilterBlock floorFilter = new ArrayFilterBlock(this, floor.get(),
heights.get(), getWidth(), getLength(), 0);
ArrayFilterBlock mainFilter = new ArrayFilterBlock(this, main.get(), heights.get(),
getWidth(), getLength(), -1);
primitives.modifiedMain = true;
int index = 0;
for (int z = 0; z < getLength(); z++) {
@ -1469,7 +1567,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
setFloor(((BlockStateHolder) value).getOrdinalChar());
} else {
floor.record(() -> {
ArrayFilterBlock filter = new ArrayFilterBlock(this, floor.get(), heights.get(), getWidth(), getLength(), 0);
ArrayFilterBlock filter = new ArrayFilterBlock(this, floor.get(), heights.get(),
getWidth(), getLength(), 0);
int index = 0;
for (int z = 0; z < getLength(); z++) {
for (int x = 0; x < getWidth(); x++, index++) {
@ -1486,8 +1585,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
setColumn(((BlockStateHolder) value).getOrdinalChar());
} else {
main.record(() -> floor.record(() -> {
ArrayFilterBlock floorFilter = new ArrayFilterBlock(this, floor.get(), heights.get(), getWidth(), getLength(), 0);
ArrayFilterBlock mainFilter = new ArrayFilterBlock(this, main.get(), heights.get(), getWidth(), getLength(), -1);
ArrayFilterBlock floorFilter = new ArrayFilterBlock(this, floor.get(),
heights.get(), getWidth(), getLength(), 0);
ArrayFilterBlock mainFilter = new ArrayFilterBlock(this, main.get(), heights.get(),
getWidth(), getLength(), -1);
int index = 0;
for (int z = 0; z < getLength(); z++) {
for (int x = 0; x < getWidth(); x++, index++) {
@ -1506,7 +1607,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
setMain(((BlockStateHolder) value).getOrdinalChar());
} else {
main.record(() -> {
ArrayFilterBlock filter = new ArrayFilterBlock(this, main.get(), heights.get(), getWidth(), getLength(), -1);
ArrayFilterBlock filter = new ArrayFilterBlock(this, main.get(), heights.get(),
getWidth(), getLength(), -1);
int index = 0;
for (int z = 0; z < getLength(); z++) {
for (int x = 0; x < getWidth(); x++, index++) {
@ -1519,12 +1621,15 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
public void setOverlay(Pattern value) {
if (overlay == null) overlay = new DifferentialArray<>(new char[getArea()]);
if (overlay == null) {
overlay = new DifferentialArray<>(new char[getArea()]);
}
if (value instanceof BlockStateHolder) {
setOverlay(((BlockStateHolder) value).getOrdinalChar());
} else {
overlay.record(() -> {
ArrayFilterBlock filter = new ArrayFilterBlock(this, overlay.get(), heights.get(), getWidth(), getLength(), 1);
ArrayFilterBlock filter = new ArrayFilterBlock(this, overlay.get(), heights.get(),
getWidth(), getLength(), 1);
int index = 0;
for (int z = 0; z < getLength(); z++) {
for (int x = 0; x < getWidth(); x++, index++) {
@ -1538,7 +1643,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
public void setHeight(int x, int z, int height) {
int index = z * getWidth() + x;
if (index < 0 || index >= getArea()) return;
if (index < 0 || index >= getArea()) {
return;
}
heights.setByte(index, (byte) height);
}
@ -1610,7 +1717,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
Arrays.fill(chunk.blocks, 0, maxIndex, (char) BlockID.STONE);
}
final boolean hasFloorThickness = primitives.floorThickness != 0 || primitives.worldThickness != 0;
final boolean hasFloorThickness =
primitives.floorThickness != 0 || primitives.worldThickness != 0;
if (primitives.worldThickness != 0) {
int endLayer = minY - primitives.worldThickness + 1 >> 4;
for (int layer = 0; layer < endLayer; layer++) {
@ -1630,10 +1738,18 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
char floorCombined = floor[globalIndex];
if (hasFloorThickness) {
if (x > 0) maxMainY = Math.min(heights[globalIndex - 1] & 0xFF, maxMainY);
if (x < getWidth() - 1) maxMainY = Math.min(heights[globalIndex + 1] & 0xFF, maxMainY);
if (z > 0) maxMainY = Math.min(heights[globalIndex - getWidth()] & 0xFF, maxMainY);
if (z < getLength() - 1) maxMainY = Math.min(heights[globalIndex + getWidth()] & 0xFF, maxMainY);
if (x > 0) {
maxMainY = Math.min(heights[globalIndex - 1] & 0xFF, maxMainY);
}
if (x < getWidth() - 1) {
maxMainY = Math.min(heights[globalIndex + 1] & 0xFF, maxMainY);
}
if (z > 0) {
maxMainY = Math.min(heights[globalIndex - getWidth()] & 0xFF, maxMainY);
}
if (z < getLength() - 1) {
maxMainY = Math.min(heights[globalIndex + getWidth()] & 0xFF, maxMainY);
}
int min = maxMainY;
@ -1642,8 +1758,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
for (int y = maxMainY; y <= height; y++) {
chunk.blocks[index + (y << 8)] = floorCombined;
}
}
else {
} else {
chunk.blocks[index + (height << 8)] = floorCombined;
}
@ -1690,7 +1805,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
int zIndex = index + (z << 4);
for (int x = 0; x < zBlocks.length; x++, zIndex++) {
char combined = zBlocks[x];
if (combined == 0) continue;
if (combined == 0) {
continue;
}
chunk.blocks[zIndex] = combined;
}
}
@ -1740,7 +1857,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
private void setOverlay(Mask mask, int combined) {
int index = 0;
if (overlay == null) overlay = new DifferentialArray<>(new char[getArea()]);
if (overlay == null) {
overlay = new DifferentialArray<>(new char[getArea()]);
}
for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++) {
@ -1817,14 +1936,20 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
private void setOverlay(char value) {
if (overlay == null) overlay = new DifferentialArray<>(new char[getArea()]);
if (overlay == null) {
overlay = new DifferentialArray<>(new char[getArea()]);
}
overlay.record(() -> Arrays.fill(overlay.get(), value));
}
private void setOverlay(BufferedImage img, char combined, boolean white) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (overlay == null) overlay = new DifferentialArray<>(new char[getArea()]);
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) {
throw new IllegalArgumentException(
"Input image dimensions do not match the current height map!");
}
if (overlay == null) {
overlay = new DifferentialArray<>(new char[getArea()]);
}
overlay.record(() -> {
int index = 0;
@ -1832,7 +1957,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && white && ThreadLocalRandom.current()
.nextInt(256) <= height) {
.nextInt(256) <= height) {
overlay.get()[index] = combined;
}
}
@ -1841,8 +1966,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
private void setMain(BufferedImage img, char combined, boolean white) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) {
throw new IllegalArgumentException(
"Input image dimensions do not match the current height map!");
}
primitives.modifiedMain = true;
main.record(() -> {
@ -1851,7 +1978,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
.nextInt(256) <= height) {
.nextInt(256) <= height) {
main.get()[index] = combined;
}
}
@ -1860,8 +1987,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
private void setFloor(BufferedImage img, char combined, boolean white) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) {
throw new IllegalArgumentException(
"Input image dimensions do not match the current height map!");
}
floor.record(() -> {
int index = 0;
@ -1869,7 +1998,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
.nextInt(256) <= height) {
.nextInt(256) <= height) {
floor.get()[index] = combined;
}
}
@ -1878,8 +2007,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
private void setColumn(BufferedImage img, char combined, boolean white) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) {
throw new IllegalArgumentException(
"Input image dimensions do not match the current height map!");
}
primitives.modifiedMain = true;
main.record(() -> floor.record(() -> {
@ -1888,7 +2019,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
for (int x = 0; x < getWidth(); x++, index++) {
int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
.nextInt(256) <= height) {
.nextInt(256) <= height) {
main.get()[index] = combined;
floor.get()[index] = combined;
}
@ -1907,14 +2038,17 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
File folder = getFolder();
if (folder != null) {
String name = folder.getName();
if (name.equalsIgnoreCase("region")) return folder.getParentFile().getName();
if (name.equalsIgnoreCase("region")) {
return folder.getParentFile().getName();
}
return name;
}
return Integer.toString(hashCode());
}
@Override
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException {
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block,
boolean notifyAndLight) throws WorldEditException {
return setBlock(position, block);
}
@ -1940,7 +2074,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
@Override
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException {
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession,
BlockVector3 position) throws MaxChangedBlocksException {
return false;
}
@ -1957,7 +2092,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
@Override
public boolean notifyAndLightBlock(BlockVector3 position, BlockState previousType) throws WorldEditException {
public boolean notifyAndLightBlock(BlockVector3 position, BlockState previousType)
throws WorldEditException {
// TODO Auto-generated method stub
return false;
}

Datei anzeigen

@ -151,7 +151,7 @@ public class MathMan {
}
public static long pairInt(int x, int y) {
return (((long) x) << 32) | (y & 0xffffffffL);
return ((long) x << 32) | (y & 0xffffffffL);
}
public static long tripleWorldCoord(int x, int y, int z) {

Datei anzeigen

@ -289,22 +289,18 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
if (containsEntireCuboid(bx, tx, by, ty, bz, tz)) {
continue;
} else {
boolean changed = true;
processExtra = true;
char[] arr = set.load(layer);
for (int y = 0, index = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {
for (int x = 0; x < 16; x++, index++) {
if (arr[index] != 0 && !contains(x, y, z)) {
changed = true;
arr[index] = 0;
}
}
}
}
if (changed) {
set.setBlocks(layer, arr);
}
set.setBlocks(layer, arr);
}
}
if (processExtra) {