wip upstream merge

This commit is contained in:
Jesse Boyd 2019-04-04 00:25:16 +11:00
parent 7086eb8b3e
commit 8897109dc4
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
52 changed files with 236 additions and 209 deletions

View File

@ -189,7 +189,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@Override @Override
public int getBiomeId(Biome biome) { public BiomeType getBiomeId(Biome biome) {
BiomeBase mcBiome = CraftBlock.biomeToBiomeBase(biome); BiomeBase mcBiome = CraftBlock.biomeToBiomeBase(biome);
return mcBiome != null ? IRegistry.BIOME.a(mcBiome) : 0; return mcBiome != null ? IRegistry.BIOME.a(mcBiome) : 0;
} }

View File

@ -352,7 +352,7 @@
// } // }
// //
// @Override // @Override
// public int getBiomeId(Biome biome) { // public BiomeType getBiomeType(Biome biome) {
// try { // try {
// Object biomeBase = biomeToBiomeBase.invoke(null, biome); // Object biomeBase = biomeToBiomeBase.invoke(null, biome);
// if (biomeBase != null) return (int) biomeBaseToTypeId.invoke(null, biomeBase); // if (biomeBase != null) return (int) biomeBaseToTypeId.invoke(null, biomeBase);

View File

@ -232,7 +232,7 @@ public class AsyncBlock implements Block {
@Override @Override
public Biome getBiome() { public Biome getBiome() {
return world.getAdapter().getBiome(queue.getBiomeId(x, z)); return world.getAdapter().getBiome(queue.getBiomeType(x, z));
} }
@Override @Override

View File

@ -20,7 +20,6 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.function.Supplier;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
@ -859,7 +858,7 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
@Override @Override
public Biome getBiome(int x, int z) { public Biome getBiome(int x, int z) {
return adapter.getBiome(queue.getBiomeId(x, z)); return adapter.getBiome(queue.getBiomeType(x, z));
} }
@Override @Override

View File

@ -29,24 +29,7 @@ public class FaweCache {
*/ */
public final static byte[][] CACHE_Z = new byte[16][]; public final static byte[][] CACHE_Z = new byte[16][];
/**
* Immutable biome cache
*/
public final static BiomeType[] CACHE_BIOME = new BiomeType[256];
public static final BiomeType getBiome(int id) {
return CACHE_BIOME[id];
}
static { static {
for (int i = 0; i < 256; i++) {
CACHE_BIOME[i] = new BiomeType(i) {
@Override
public void setId(int id) {
throw new IllegalStateException("Cannot set id");
}
};
}
CACHE_X[0] = new byte[4096]; CACHE_X[0] = new byte[4096];
CACHE_Z[0] = new byte[4096]; CACHE_Z[0] = new byte[4096];
for (int y = 0; y < 16; y++) { for (int y = 0; y < 16; y++) {

View File

@ -529,9 +529,9 @@ public class CFICommands extends MethodCommands {
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void biome(FawePlayer fp, BiomeType biome, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException{ public void biome(FawePlayer fp, BiomeType biome, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException{
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (image != null) gen.setBiome(load(image), (byte) biome.getId(), !disableWhiteOnly); if (image != null) gen.setBiome(load(image), biome, !disableWhiteOnly);
else if (mask != null) gen.setBiome(mask, (byte) biome.getId()); else if (mask != null) gen.setBiome(mask, biome);
else gen.setBiome((byte) biome.getId()); else gen.setBiome(biome);
msg("Set biome!").send(fp); msg("Set biome!").send(fp);
assertSettings(fp).resetComponent(); assertSettings(fp).resetComponent();
component(fp); component(fp);

View File

@ -753,7 +753,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, CHUNKSECTIONS, SECTION> impl
} }
@Override @Override
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException { public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
int cx = x >> 4; int cx = x >> 4;
int cz = z >> 4; int cz = z >> 4;
lastSectionY = -1; lastSectionY = -1;

View File

@ -1,7 +1,6 @@
package com.boydti.fawe.jnbt.anvil; package com.boydti.fawe.jnbt.anvil;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.example.SimpleIntFaweChunk; import com.boydti.fawe.example.SimpleIntFaweChunk;
import com.boydti.fawe.object.*; import com.boydti.fawe.object.*;
import com.boydti.fawe.object.brush.visualization.VirtualWorld; import com.boydti.fawe.object.brush.visualization.VirtualWorld;
@ -17,6 +16,7 @@ import com.boydti.fawe.util.image.ImageViewer;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.*; import com.sk89q.worldedit.*;
import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
@ -744,7 +744,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
public boolean setBiome(int x, int z, BiomeType biome) { public boolean setBiome(int x, int z, BiomeType biome) {
int index = z * getWidth() + x; int index = z * getWidth() + x;
if (index < 0 || index >= getArea()) return false; if (index < 0 || index >= getArea()) return false;
biomes.setByte(index, (byte) biome.getId()); biomes.setByte(index, (byte) biome.getInternalId());
return true; return true;
} }
@ -920,7 +920,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
} }
@Override @Override
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException { public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
int index = z * getWidth() + x; 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 biomes.getByte(index) & 0xFF; return biomes.getByte(index) & 0xFF;
@ -1011,7 +1011,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
@Override @Override
public BiomeType getBiome(BlockVector2 position) { public BiomeType getBiome(BlockVector2 position) {
return FaweCache.CACHE_BIOME[getBiomeId(position.getBlockX(), position.getBlockZ())]; return BiomeTypes.get(getBiomeType(position.getBlockX(), position.getBlockZ()));
} }
@Override @Override
@ -1069,9 +1069,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
return heights.getByte(index) & 0xFF; return heights.getByte(index) & 0xFF;
} }
public void setBiome(BufferedImage img, byte biome, boolean white) { public void setBiome(BufferedImage img, BiomeType biome, boolean white) {
if (img.getWidth() != getWidth() || img.getHeight() != getLength()) if (img.getWidth() != getWidth() || img.getHeight() != getLength())
throw new IllegalArgumentException("Input image dimensions do not match the current height map!"); throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
byte biomeByte = (byte) biome.getInternalId();
biomes.record(new Runnable() { biomes.record(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -1082,7 +1083,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
int height = img.getRGB(x, z) & 0xFF; int height = img.getRGB(x, z) & 0xFF;
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current() if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
.nextInt(256) <= height) { .nextInt(256) <= height) {
biomeArr[index] = biome; biomeArr[index] = biomeByte;
} }
} }
} }
@ -1317,8 +1318,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
})); }));
} }
public void setBiome(Mask mask, byte biome) { public void setBiome(Mask mask, BiomeType biome) {
int index = 0; int index = 0;
byte biomeByte = (byte) biome.getInternalId();
for (int z = 0; z < getLength(); z++) { for (int z = 0; z < getLength(); z++) {
mutable.mutZ(z); mutable.mutZ(z);
for (int x = 0; x < getWidth(); x++, index++) { for (int x = 0; x < getWidth(); x++, index++) {
@ -1326,7 +1328,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
mutable.mutX(x); mutable.mutX(x);
mutable.mutY(y); mutable.mutY(y);
if (mask.test(mutable)) { if (mask.test(mutable)) {
biomes.setByte(index, biome); biomes.setByte(index, biomeByte);
} }
} }
} }
@ -1528,8 +1530,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
} }
} }
public void setBiome(int biome) { public void setBiome(BiomeType biome) {
biomes.record(() -> Arrays.fill(biomes.get(), (byte) biome)); biomes.record(() -> Arrays.fill(biomes.get(), (byte) biome.getInternalId()));
} }
public void setFloor(Pattern value) { public void setFloor(Pattern value) {

View File

@ -90,7 +90,7 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
if (faweChunk instanceof MCAChunk) { if (faweChunk instanceof MCAChunk) {
return ((MCAChunk) faweChunk).getBiomeArray()[((z & 0xF) << 4 | x & 0xF)]; return ((MCAChunk) faweChunk).getBiomeArray()[((z & 0xF) << 4 | x & 0xF)];
} else if (parent != null) { } else if (parent != null) {
return parent.getBiomeId(x, z); return parent.getBiomeType(x, z);
} else { } else {
return 0; return 0;
} }

View File

@ -9,7 +9,7 @@ public class DeleteBiomeFilterSimple extends MCAFilterCounter {
private final int id; private final int id;
public DeleteBiomeFilterSimple(BiomeType biome) { public DeleteBiomeFilterSimple(BiomeType biome) {
this.id = biome.getId(); this.id = biome.getInternalId();
} }
@Override @Override

View File

@ -45,9 +45,9 @@ public class ChangeSetFaweQueue extends DelegateFaweQueue {
@Override @Override
public boolean setBiome(int x, int z, BiomeType biome) { public boolean setBiome(int x, int z, BiomeType biome) {
if (super.setBiome(x, z, biome)) { if (super.setBiome(x, z, biome)) {
int oldBiome = getParent().getBiomeId(x, z); BiomeType oldBiome = getParent().getBiomeType(x, z);
if (oldBiome != biome.getId()) { if (oldBiome != biome) {
set.addBiomeChange(x, z, FaweCache.getBiome(oldBiome), biome); set.addBiomeChange(x, z, oldBiome, biome);
return true; return true;
} }
} }

View File

@ -167,7 +167,7 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
return null; return null;
} }
public abstract byte[] getBiomeArray(); public abstract BiomeType[] getBiomeArray();
public void forEachQueuedBlock(FaweChunkVisitor onEach) { public void forEachQueuedBlock(FaweChunkVisitor onEach) {
for (int y = 0; y < HEIGHT; y++) { for (int y = 0; y < HEIGHT; y++) {
@ -290,7 +290,7 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
public abstract CompoundTag getTile(int x, int y, int z); public abstract CompoundTag getTile(int x, int y, int z);
public void setBiome(final int x, final int z, final BiomeType biome) { public void setBiome(final int x, final int z, final BiomeType biome) {
setBiome(x, z, (byte) biome.getId()); setBiome(x, z, biome);
} }
public abstract void setBiome(final int x, final int z, final byte biome); public abstract void setBiome(final int x, final int z, final byte biome);

View File

@ -400,7 +400,7 @@ public interface FaweQueue extends HasFaweQueue, Extent {
return getCombinedId4Data(x, y, z) != 0; return getCombinedId4Data(x, y, z) != 0;
} }
int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException; BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException;
int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException; int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException;

View File

@ -9,6 +9,7 @@ import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.SetQueue; import com.boydti.fawe.util.SetQueue;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.*; import com.sk89q.worldedit.*;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operation;
@ -62,7 +63,7 @@ public abstract class ImmutableVirtualWorld implements VirtualWorld {
@Override @Override
public BiomeType getBiome(BlockVector2 position) { public BiomeType getBiome(BlockVector2 position) {
return FaweCache.getBiome(0); return BiomeTypes.FOREST;
} }
@Override @Override

View File

@ -5,31 +5,32 @@ import com.sk89q.worldedit.history.UndoContext;
import com.sk89q.worldedit.history.change.Change; import com.sk89q.worldedit.history.change.Change;
import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.math.MutableBlockVector2;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
public class MutableBiomeChange implements Change { public class MutableBiomeChange implements Change {
private MutableBlockVector2 mutable = new MutableBlockVector2(); private MutableBlockVector2 mutable = new MutableBlockVector2();
private BiomeType from; private int from;
private BiomeType to; private int to;
public MutableBiomeChange() { public MutableBiomeChange() {
this.from = new BiomeType(0); this.from = 0;
this.to = new BiomeType(0); this.to = 0;
} }
public void setBiome(int x, int z, int from, int to) { public void setBiome(int x, int z, int from, int to) {
mutable.setComponents(x, z); mutable.setComponents(x, z);
this.from.setId(from); this.from = from;
this.to.setId(to); this.to = to;
} }
@Override @Override
public void undo(UndoContext context) throws WorldEditException { public void undo(UndoContext context) throws WorldEditException {
context.getExtent().setBiome(mutable, from); context.getExtent().setBiome(mutable, BiomeTypes.get(from));
} }
@Override @Override
public void redo(UndoContext context) throws WorldEditException { public void redo(UndoContext context) throws WorldEditException {
context.getExtent().setBiome(mutable, to); context.getExtent().setBiome(mutable, BiomeTypes.get(to));
} }
} }

View File

@ -268,16 +268,16 @@ public abstract class FaweChangeSet implements ChangeSet {
synchronized (FaweChangeSet.this) { synchronized (FaweChangeSet.this) {
// Biome changes // Biome changes
if (previous.getBiomeArray() != null) { if (previous.getBiomeArray() != null) {
byte[] previousBiomes = previous.getBiomeArray(); BiomeType[] previousBiomes = previous.getBiomeArray();
byte[] nextBiomes = next.getBiomeArray(); BiomeType[] nextBiomes = next.getBiomeArray();
int index = 0; int index = 0;
for (int z = 0; z < 16; z++) { for (int z = 0; z < 16; z++) {
int zz = bz + z; int zz = bz + z;
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
byte idFrom = previousBiomes[index]; BiomeType idFrom = previousBiomes[index];
byte idTo = nextBiomes[index]; BiomeType idTo = nextBiomes[index];
if (idFrom != idTo && idTo != 0) { if (idFrom != idTo && idTo != null) {
addBiomeChange(bx + x, zz, FaweCache.getBiome(idFrom & 0xFF), FaweCache.getBiome(idTo & 0xFF)); addBiomeChange(bx + x, zz, idFrom, idTo);
} }
index++; index++;
} }

View File

@ -337,8 +337,8 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
os.write((byte) (z >> 16)); os.write((byte) (z >> 16));
os.write((byte) (z >> 8)); os.write((byte) (z >> 8));
os.write((byte) (z)); os.write((byte) (z));
os.write(from.getId()); ((FaweOutputStream) os).writeVarInt(from.getInternalId());
os.write(to.getId()); ((FaweOutputStream) os).writeVarInt(to.getInternalId());
} catch (Throwable e) { } catch (Throwable e) {
MainUtil.handleError(e); MainUtil.handleError(e);
} }
@ -462,8 +462,8 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
if (int1 != -1) { if (int1 != -1) {
int x = ((int1 << 24) + (is.read() << 16) + (is.read() << 8) + (is.read() << 0)); int x = ((int1 << 24) + (is.read() << 16) + (is.read() << 8) + (is.read() << 0));
int z = ((is.read() << 24) + (is.read() << 16) + (is.read() << 8) + (is.read() << 0)); int z = ((is.read() << 24) + (is.read() << 16) + (is.read() << 8) + (is.read() << 0));
int from = is.read(); int from = ((FaweInputStream) is).readVarInt();
int to = is.read(); int to = ((FaweInputStream) is).readVarInt();
change.setBiome(x, z, from, to); change.setBiome(x, z, from, to);
return change; return change;
} }

View File

@ -33,7 +33,7 @@ public class CPUOptimizedClipboard extends FaweClipboard {
private int area; private int area;
private int volume; private int volume;
private byte[] biomes = null; private BiomeType[] biomes = null;
private int[] states; private int[] states;
private final HashMap<IntegerTrio, CompoundTag> nbtMapLoc; private final HashMap<IntegerTrio, CompoundTag> nbtMapLoc;
@ -65,11 +65,11 @@ public class CPUOptimizedClipboard extends FaweClipboard {
} }
@Override @Override
public void setBiome(int index, int biome) { public void setBiome(int index, BiomeType biome) {
if (biomes == null) { if (biomes == null) {
biomes = new byte[area]; biomes = new BiomeType[area];
} }
biomes[index] = (byte) biome; biomes[index] = biome;
} }
@Override @Override
@ -88,7 +88,7 @@ public class CPUOptimizedClipboard extends FaweClipboard {
if (!hasBiomes()) { if (!hasBiomes()) {
return null; return null;
} }
return FaweCache.CACHE_BIOME[biomes[index] & 0xFF]; return biomes[index];
} }
@Override @Override

View File

@ -71,7 +71,7 @@ public abstract class ReadOnlyClipboard extends FaweClipboard {
int index = 0; int index = 0;
for (int z = 0; z <= dim.getBlockZ(); z++) { for (int z = 0; z <= dim.getBlockZ(); z++) {
for (int x = 0; x <= dim.getBlockX(); x++, index++) { for (int x = 0; x <= dim.getBlockX(); x++, index++) {
task.run(index, getBiome(x, z).getId()); task.run(index, getBiome(x, z));
} }
} }
} }

View File

@ -1,12 +1,11 @@
package com.boydti.fawe.object.extent; package com.boydti.fawe.object.extent;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.HasFaweQueue; import com.boydti.fawe.object.HasFaweQueue;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.ReflectionUtils;
import com.sk89q.jnbt.*; import com.sk89q.jnbt.*;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
@ -18,7 +17,6 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
@ -107,7 +105,7 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa
@Override @Override
public BiomeType getBiome(final BlockVector2 position) { public BiomeType getBiome(final BlockVector2 position) {
return FaweCache.CACHE_BIOME[queue.getBiomeId(position.getBlockX(), position.getBlockZ())]; return BiomeTypes.get(queue.getBiomeType(position.getBlockX(), position.getBlockZ()));
} }
@Override @Override

View File

@ -103,7 +103,7 @@ public class PatternExtent extends AbstractPattern implements Extent {
@Override @Override
public BiomeType getBiome(BlockVector2 position) { public BiomeType getBiome(BlockVector2 position) {
return new BiomeType(0); return null;
} }
@Override @Override

View File

@ -58,8 +58,8 @@ public class FaweQueueDelegateExtent extends DelegateFaweQueue {
} }
@Override @Override
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException { public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
return parentExtent.getBiome(BlockVector2.at(x, z)).getId(); return parentExtent.getBiome(BlockVector2.at(x, z));
} }
@Override @Override

View File

@ -343,8 +343,8 @@ public interface IDelegateFaweQueue extends FaweQueue {
} }
@Override @Override
default int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException { default BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
return getQueue().getBiomeId(x, z); return getQueue().getBiomeType(x, z);
} }
@Override @Override

View File

@ -183,7 +183,7 @@ public class NullFaweQueue implements FaweQueue {
} }
@Override @Override
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException { public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
return 0; return 0;
} }

View File

@ -578,7 +578,7 @@ public class SchemVis extends ImmutableVirtualWorld {
public void sendChunk(int x, int z, int bitMask) { /* do nothing - never used*/ } public void sendChunk(int x, int z, int bitMask) { /* do nothing - never used*/ }
@Override @Override
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException { public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
// TODO later (currently not used) // TODO later (currently not used)
return 0; return 0;
} }

View File

@ -12,6 +12,7 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.biome.Biomes; import com.sk89q.worldedit.world.biome.Biomes;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
@ -94,7 +95,7 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
if (reg == null) { if (reg == null) {
reg = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.USER_COMMANDS).getRegistries().getBiomeRegistry(); reg = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.USER_COMMANDS).getRegistries().getBiomeRegistry();
} }
List<BiomeType> biomes = reg.getBiomes(); List<BiomeType> biomes = BiomeTypes.values();
lastBiome = biome; lastBiome = biome;
this.biome = Biomes.findBiomeByName(biomes, biome, reg); this.biome = Biomes.findBiomeByName(biomes, biome, reg);
} }

View File

@ -12,6 +12,9 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import jdk.internal.reflect.ConstructorAccessor;
import jdk.internal.reflect.FieldAccessor;
import sun.reflect.ConstructorAccessor; import sun.reflect.ConstructorAccessor;
import sun.reflect.FieldAccessor; import sun.reflect.FieldAccessor;
import sun.reflect.ReflectionFactory; import sun.reflect.ReflectionFactory;

View File

@ -1409,23 +1409,23 @@ public class LocalSession implements TextureHolder {
this.fastMode = fastMode; this.fastMode = fastMode;
} }
/** // /**
* Gets the reorder mode of the session. // * Gets the reorder mode of the session.
* // *
* @return The reorder mode // * @return The reorder mode
*/ // */
public EditSession.ReorderMode getReorderMode() { // public EditSession.ReorderMode getReorderMode() {
return reorderMode; // return reorderMode;
} // }
//
/** // /**
* Sets the reorder mode of the session. // * Sets the reorder mode of the session.
* // *
* @param reorderMode The reorder mode // * @param reorderMode The reorder mode
*/ // */
public void setReorderMode(EditSession.ReorderMode reorderMode) { // public void setReorderMode(EditSession.ReorderMode reorderMode) {
this.reorderMode = reorderMode; // this.reorderMode = reorderMode;
} // }
/** /**
* Get the mask. * Get the mask.

View File

@ -37,6 +37,9 @@ import com.sk89q.worldedit.extension.platform.PlatformManager;
import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.runtime.Constant;
import com.sk89q.worldedit.internal.expression.runtime.RValue;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.scripting.CraftScriptContext; import com.sk89q.worldedit.scripting.CraftScriptContext;
import com.sk89q.worldedit.scripting.CraftScriptEngine; import com.sk89q.worldedit.scripting.CraftScriptEngine;
@ -73,8 +76,6 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import static com.sk89q.worldedit.event.platform.Interaction.HIT; import static com.sk89q.worldedit.event.platform.Interaction.HIT;
import static com.sk89q.worldedit.event.platform.Interaction.OPEN; import static com.sk89q.worldedit.event.platform.Interaction.OPEN;

View File

@ -56,6 +56,7 @@ import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeData; import com.sk89q.worldedit.world.biome.BiomeData;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.registry.BiomeRegistry; import com.sk89q.worldedit.world.registry.BiomeRegistry;
import java.util.ArrayList; import java.util.ArrayList;
@ -65,6 +66,8 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
/** /**
* Implements biome-related commands such as "/biomelist". * Implements biome-related commands such as "/biomelist".
*/ */
@ -104,7 +107,7 @@ public class BiomeCommands extends MethodCommands {
} }
BiomeRegistry biomeRegistry = getBiomeRegistry(); BiomeRegistry biomeRegistry = getBiomeRegistry();
List<BiomeType> biomes = biomeRegistry.getBiomes(); List<BiomeType> biomes = BiomeTypes.values();
int totalPages = biomes.size() / 19 + 1; int totalPages = biomes.size() / 19 + 1;
Message msg = BBC.BIOME_LIST_HEADER.m(page, totalPages); Message msg = BBC.BIOME_LIST_HEADER.m(page, totalPages);
String setBiome = Commands.getAlias(BiomeCommands.class, "/setbiome"); String setBiome = Commands.getAlias(BiomeCommands.class, "/setbiome");
@ -141,7 +144,8 @@ public class BiomeCommands extends MethodCommands {
@CommandPermissions("worldedit.biome.info") @CommandPermissions("worldedit.biome.info")
public void biomeInfo(Player player, LocalSession session, final EditSession editSession, CommandContext args) throws WorldEditException { public void biomeInfo(Player player, LocalSession session, final EditSession editSession, CommandContext args) throws WorldEditException {
BiomeRegistry biomeRegistry = getBiomeRegistry(); BiomeRegistry biomeRegistry = getBiomeRegistry();
final int[] biomes = new int[256]; List<BiomeType> values = BiomeTypes.values();
final int[] biomes = new int[values.size()];
final String qualifier; final String qualifier;
int size = 0; int size = 0;
@ -165,14 +169,14 @@ public class BiomeCommands extends MethodCommands {
if (region instanceof FlatRegion) { if (region instanceof FlatRegion) {
for (BlockVector2 pt : new Fast2DIterator(((FlatRegion) region).asFlatRegion(), editSession)) { for (BlockVector2 pt : new Fast2DIterator(((FlatRegion) region).asFlatRegion(), editSession)) {
biomes[editSession.getBiome(pt).getId()]++; biomes[editSession.getBiome(pt).getInternalId()]++;
size++; size++;
} }
} else { } else {
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() { RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
@Override @Override
public boolean apply(BlockVector3 position) throws WorldEditException { public boolean apply(BlockVector3 position) throws WorldEditException {
biomes[editSession.getBiome(position.toBlockVector2()).getId()]++; biomes[editSession.getBiome(position.toBlockVector2()).getInternalId()]++;
return true; return true;
} }
}, editSession); }, editSession);
@ -187,7 +191,7 @@ public class BiomeCommands extends MethodCommands {
for (int i = 0; i < biomes.length; i++) { for (int i = 0; i < biomes.length; i++) {
int count = biomes[i]; int count = biomes[i];
if (count != 0) { if (count != 0) {
distribution.add(new Countable<>(new BiomeType(i), count)); distribution.add(new Countable<>(BiomeTypes.get(i), count));
} }
} }
Collections.sort(distribution); Collections.sort(distribution);

View File

@ -25,6 +25,7 @@ import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandPermissions; import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.worldedit.*; import com.sk89q.worldedit.*;
import com.sk89q.worldedit.extension.input.DisallowedUsageException;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;

View File

@ -54,7 +54,17 @@ import com.sk89q.worldedit.util.command.binding.Range;
import com.sk89q.worldedit.util.command.binding.Switch; import com.sk89q.worldedit.util.command.binding.Switch;
import com.sk89q.worldedit.util.command.binding.Text; import com.sk89q.worldedit.util.command.binding.Text;
import com.sk89q.worldedit.util.command.parametric.Optional; import com.sk89q.worldedit.util.command.parametric.Optional;
import com.sk89q.worldedit.util.command.parametric.ParameterException;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockType;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import static com.sk89q.minecraft.util.commands.Logging.LogMode.*;
/** /**
* Commands for the generation of shapes and other objects. * Commands for the generation of shapes and other objects.
@ -427,7 +437,8 @@ public class GenerationCommands extends MethodCommands {
@Switch('h') boolean hollow, @Switch('h') boolean hollow,
@Switch('r') boolean useRawCoords, @Switch('r') boolean useRawCoords,
@Switch('o') boolean offset, @Switch('o') boolean offset,
@Switch('c') boolean offsetCenter) throws WorldEditException { @Switch('c') boolean offsetCenter,
CommandContext context) throws WorldEditException {
final Vector3 zero; final Vector3 zero;
Vector3 unit; Vector3 unit;

View File

@ -53,6 +53,7 @@ import com.sk89q.worldedit.function.visitor.LayerVisitor;
import com.sk89q.worldedit.internal.annotation.Direction; import com.sk89q.worldedit.internal.annotation.Direction;
import com.sk89q.worldedit.internal.annotation.Selection; import com.sk89q.worldedit.internal.annotation.Selection;
import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.convolution.GaussianKernel; import com.sk89q.worldedit.math.convolution.GaussianKernel;
@ -66,6 +67,11 @@ import com.sk89q.worldedit.util.command.binding.Range;
import com.sk89q.worldedit.util.command.binding.Switch; import com.sk89q.worldedit.util.command.binding.Switch;
import com.sk89q.worldedit.util.command.binding.Text; import com.sk89q.worldedit.util.command.binding.Text;
import com.sk89q.worldedit.util.command.parametric.Optional; import com.sk89q.worldedit.util.command.parametric.Optional;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.biome.Biomes;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.registry.BiomeRegistry;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
@ -704,7 +710,7 @@ public class RegionCommands extends MethodCommands {
BiomeType biome = null; BiomeType biome = null;
if (context.argsLength() >= 1) { if (context.argsLength() >= 1) {
BiomeRegistry biomeRegistry = worldEdit.getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry(); BiomeRegistry biomeRegistry = worldEdit.getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
List<BiomeType> knownBiomes = biomeRegistry.getBiomes(); List<BiomeType> knownBiomes = BiomeTypes.values();
biome = Biomes.findBiomeByName(knownBiomes, context.getString(0), biomeRegistry); biome = Biomes.findBiomeByName(knownBiomes, context.getString(0), biomeRegistry);
} }
Long seed = context.argsLength() != 2 || !MathMan.isInteger(context.getString(1)) ? null : Long.parseLong(context.getString(1)); Long seed = context.argsLength() != 2 || !MathMan.isInteger(context.getString(1)) ? null : Long.parseLong(context.getString(1));

View File

@ -65,8 +65,10 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL;
import java.nio.channels.Channels; import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel; import java.nio.channels.ReadableByteChannel;
import java.nio.file.Files; import java.nio.file.Files;
@ -79,6 +81,7 @@ import java.util.UUID;
import java.util.concurrent.atomic.LongAdder; import java.util.concurrent.atomic.LongAdder;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static com.boydti.fawe.util.ReflectionUtils.as;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
/** /**
@ -92,7 +95,6 @@ public class SchematicCommands extends MethodCommands {
*/ */
private static final int SCHEMATICS_PER_PAGE = 9; private static final int SCHEMATICS_PER_PAGE = 9;
private static final Logger log = LoggerFactory.getLogger(SchematicCommands.class); private static final Logger log = LoggerFactory.getLogger(SchematicCommands.class);
private final WorldEdit worldEdit;
/** /**
* Create a new instance. * Create a new instance.
@ -279,7 +281,7 @@ public class SchematicCommands extends MethodCommands {
player.printError("Unknown filename: " + filename); player.printError("Unknown filename: " + filename);
} catch (URISyntaxException | IOException e) { } catch (URISyntaxException | IOException e) {
player.printError("File could not be read or it does not exist: " + e.getMessage()); player.printError("File could not be read or it does not exist: " + e.getMessage());
log.log(Level.WARNING, "Failed to load a saved clipboard", e); log.warn("Failed to load a saved clipboard", e);
} finally { } finally {
if (in != null) { if (in != null) {
try { try {

View File

@ -60,6 +60,7 @@ import com.sk89q.worldedit.regions.selector.RegionSelectorType;
import com.sk89q.worldedit.regions.selector.SphereRegionSelector; import com.sk89q.worldedit.regions.selector.SphereRegionSelector;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.Countable;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.command.binding.Switch; import com.sk89q.worldedit.util.command.binding.Switch;
import com.sk89q.worldedit.util.formatting.ColorCodeBuilder; import com.sk89q.worldedit.util.formatting.ColorCodeBuilder;
import com.sk89q.worldedit.util.formatting.Style; import com.sk89q.worldedit.util.formatting.Style;
@ -103,7 +104,7 @@ public class SelectionCommands {
@CommandPermissions("worldedit.selection.pos") @CommandPermissions("worldedit.selection.pos")
public void pos1(Player player, LocalSession session, CommandContext args) throws WorldEditException { public void pos1(Player player, LocalSession session, CommandContext args) throws WorldEditException {
Location pos; BlockVector3 pos;
if (args.argsLength() == 1) { if (args.argsLength() == 1) {
if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) { if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
@ -136,7 +137,7 @@ public class SelectionCommands {
@CommandPermissions("worldedit.selection.pos") @CommandPermissions("worldedit.selection.pos")
public void pos2(Player player, LocalSession session, CommandContext args) throws WorldEditException { public void pos2(Player player, LocalSession session, CommandContext args) throws WorldEditException {
Location pos; BlockVector3 pos;
if (args.argsLength() == 1) { if (args.argsLength() == 1) {
if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) { if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
String[] coords = args.getString(0).split(","); String[] coords = args.getString(0).split(",");
@ -735,7 +736,7 @@ public class SelectionCommands {
min = 0, min = 0,
max = 1 max = 1
) )
public void select(Player player, LocalSession session, CommandContext args) throws WorldEditException { public void select(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
final World world = player.getWorld(); final World world = player.getWorld();
if (args.argsLength() == 0) { if (args.argsLength() == 0) {
session.getRegionSelector(world).clear(); session.getRegionSelector(world).clear();

View File

@ -27,6 +27,10 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
@ -70,7 +74,8 @@ public class FloatingTreeRemover implements BlockTool {
Player player, LocalSession session, Location clicked) { Player player, LocalSession session, Location clicked) {
final World world = (World) clicked.getExtent(); final World world = (World) clicked.getExtent();
final BlockState state = world.getBlock(clicked.toBlockPoint()); BlockVector3 pos = clicked.toBlockPoint();
final BlockState state = world.getBlock(pos);
if (!isTreeBlock(state.getBlockType())) { if (!isTreeBlock(state.getBlockType())) {
player.printError("That's not a tree."); player.printError("That's not a tree.");

View File

@ -21,14 +21,11 @@ package com.sk89q.worldedit.command.tool.brush;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class GravityBrush implements Brush { public class GravityBrush implements Brush {

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.event.extent; package com.sk89q.worldedit.event.extent;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.event.Cancellable;
import com.sk89q.worldedit.event.Event; import com.sk89q.worldedit.event.Event;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.extension.factory;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.factory.parser.pattern.BlockCategoryPatternParser; import com.sk89q.worldedit.extension.factory.parser.pattern.BlockCategoryPatternParser;
import com.sk89q.worldedit.extension.factory.parser.pattern.ClipboardPatternParser; import com.sk89q.worldedit.extension.factory.parser.pattern.ClipboardPatternParser;
import com.sk89q.worldedit.extension.factory.parser.pattern.DefaultPatternParser;
import com.sk89q.worldedit.extension.factory.parser.pattern.RandomPatternParser; import com.sk89q.worldedit.extension.factory.parser.pattern.RandomPatternParser;
import com.sk89q.worldedit.extension.factory.parser.pattern.RandomStatePatternParser; import com.sk89q.worldedit.extension.factory.parser.pattern.RandomStatePatternParser;
import com.sk89q.worldedit.extension.factory.parser.pattern.SingleBlockPatternParser; import com.sk89q.worldedit.extension.factory.parser.pattern.SingleBlockPatternParser;

View File

@ -44,6 +44,7 @@ import com.sk89q.worldedit.command.composition.DeformCommand;
import com.sk89q.worldedit.command.composition.PaintCommand; import com.sk89q.worldedit.command.composition.PaintCommand;
import com.sk89q.worldedit.command.composition.ShapedBrushCommand; import com.sk89q.worldedit.command.composition.ShapedBrushCommand;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.platform.CommandEvent; import com.sk89q.worldedit.event.platform.CommandEvent;
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent; import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
@ -486,7 +487,7 @@ public final class CommandManager {
actor.printError(BBC.getPrefix() + e.getMessage()); actor.printError(BBC.getPrefix() + e.getMessage());
} else { } else {
actor.printError(BBC.getPrefix() + "An unknown FAWE error has occurred! Please see console."); actor.printError(BBC.getPrefix() + "An unknown FAWE error has occurred! Please see console.");
log.log(Level.SEVERE, "An unknown FAWE error occurred", e); log.error("An unknown FAWE error occurred", e);
} }
} catch (Throwable e) { } catch (Throwable e) {
Exception faweException = FaweException.get(e); Exception faweException = FaweException.get(e);
@ -496,7 +497,7 @@ public final class CommandManager {
} else { } else {
actor.printError(BBC.getPrefix() + "There was an error handling a FAWE command: [See console]"); actor.printError(BBC.getPrefix() + "There was an error handling a FAWE command: [See console]");
actor.printRaw(e.getClass().getName() + ": " + e.getMessage()); actor.printRaw(e.getClass().getName() + ": " + e.getMessage());
log.log(Level.SEVERE, "An unexpected error occurred while handling a FAWE command", e); log.error("An unexpected error occurred while handling a FAWE command", e);
} }
} finally { } finally {
final EditSession editSession = locals.get(EditSession.class); final EditSession editSession = locals.get(EditSession.class);

View File

@ -36,6 +36,8 @@ import com.google.common.io.Files;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import javax.annotation.Nullable;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;

View File

@ -61,7 +61,7 @@ import javax.annotation.Nullable;
*/ */
public class BlockTransformExtent extends ResettableExtent { public class BlockTransformExtent extends ResettableExtent {
private final Transform transform; private Transform transform;
public BlockTransformExtent(Extent parent) { public BlockTransformExtent(Extent parent) {
@ -138,9 +138,6 @@ public class BlockTransformExtent extends ResettableExtent {
return super.setBlock(location, transformBlock(block, true)); return super.setBlock(location, transformBlock(block, true));
} }
private static final Set<String> directionNames = Sets.newHashSet("north", "south", "east", "west");
private static final Set<String> directionNames = Sets.newHashSet("north", "south", "east", "west"); private static final Set<String> directionNames = Sets.newHashSet("north", "south", "east", "west");
/** /**

View File

@ -150,8 +150,7 @@ public class Deform implements Contextual<Operation> {
} }
LocalSession session = context.getSession(); LocalSession session = context.getSession();
return new DeformOperation(context.getDestination(), region, zero, unit, expression, return new DeformOperation(context.getDestination(), region, zero, unit, expression);
session == null ? WorldEdit.getInstance().getConfiguration().calculationTimeout : session.getTimeout());
} }
private static final class DeformOperation implements Operation { private static final class DeformOperation implements Operation {
@ -160,7 +159,6 @@ public class Deform implements Contextual<Operation> {
private final Vector3 zero; private final Vector3 zero;
private final Vector3 unit; private final Vector3 unit;
private final String expression; private final String expression;
private final int timeout;
private DeformOperation(Extent destination, Region region, Vector3 zero, Vector3 unit, String expression) { private DeformOperation(Extent destination, Region region, Vector3 zero, Vector3 unit, String expression) {
this.destination = destination; this.destination = destination;
@ -168,7 +166,6 @@ public class Deform implements Contextual<Operation> {
this.zero = zero; this.zero = zero;
this.unit = unit; this.unit = unit;
this.expression = expression; this.expression = expression;
this.timeout = timeout;
} }
@Override @Override

View File

@ -12,6 +12,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
/** /**

View File

@ -20,6 +20,8 @@
package com.sk89q.worldedit.world.biome; package com.sk89q.worldedit.world.biome;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List;
import java.util.Set;
/** /**
* Stores a list of common Biome String IDs. * Stores a list of common Biome String IDs.
@ -121,4 +123,8 @@ public class BiomeTypes {
public static BiomeType get(int parseInt) { public static BiomeType get(int parseInt) {
// TODO // TODO
} }
public static List<BiomeType> values() {
}
} }

View File

@ -29,6 +29,7 @@ import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.FawePattern; import com.sk89q.worldedit.function.pattern.FawePattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
@ -52,31 +53,17 @@ import java.util.Set;
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class BlockState implements BlockStateHolder<BlockState>, FawePattern { public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
private final BlockType blockType; private BlockMaterial material;
private BlockType blockType;
private int internalId, ordinal;
private BaseBlock emptyBaseBlock; private BaseBlock emptyBaseBlock;
BlockState(BlockType blockType) { BlockState(BlockType blockType, int internalId, int ordinal) {
this.blockType = blockType; this.blockType = blockType;
this.emptyBaseBlock = new BaseBlock(this); this.internalId = internalId;
this.ordinal = ordinal;
} }
BlockState(BlockType blockType, BaseBlock baseBlock){
this.blockType = blockType;
this.emptyBaseBlock = baseBlock;
}
/**
* Creates a fuzzy BlockState. This can be used for partial matching.
*
* @param blockType The block type
* @param values The block state values
*/
private BlockState(BlockType blockType, Map<Property<?>, Object> values) {
this.blockType = blockType;
// this.values = values;
// this.fuzzy = true;
}
/** /**
* Returns a temporary BlockState for a given internal id * Returns a temporary BlockState for a given internal id
* @param combinedId * @param combinedId
@ -364,13 +351,22 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
@Override @Override
public BlockMaterial getMaterial() { public BlockMaterial getMaterial() {
return blockType.getMaterial(); if (this.material == null) {
if (blockType == BlockTypes.__RESERVED__) {
return this.material = blockType.getMaterial();
}
if (this.material == null) {
this.material = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getMaterial(this);
}
}
return material;
} }
@Override @Override
public int getOrdinal() { public int getOrdinal() {
get ordinal return this.ordinal;
} }
/** /**
* Internal method used for creating the initial BlockState. * Internal method used for creating the initial BlockState.
* *
@ -399,8 +395,6 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
return equalsFuzzy((BlockState) obj); return equalsFuzzy((BlockState) obj);
} }
private Integer hashCodeCache = null;
@Override @Override
public int hashCode() { public int hashCode() {
return getOrdinal(); return getOrdinal();

View File

@ -21,14 +21,13 @@ package com.sk89q.worldedit.world.block;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.collect.ImmutableList; import com.boydti.fawe.util.ReflectionUtils;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.SingleBlockTypeMask; import com.sk89q.worldedit.function.mask.SingleBlockTypeMask;
import com.sk89q.worldedit.function.pattern.FawePattern; import com.sk89q.worldedit.function.pattern.FawePattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.google.common.collect.ImmutableMap;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
@ -37,16 +36,11 @@ import com.sk89q.worldedit.registry.state.AbstractProperty;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.registry.state.PropertyKey; import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.registry.BundledBlockData;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.registry.LegacyMapper;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
@ -55,33 +49,50 @@ public class BlockType implements FawePattern {
public static final NamespacedRegistry<BlockType> REGISTRY = new NamespacedRegistry<>("block type"); public static final NamespacedRegistry<BlockType> REGISTRY = new NamespacedRegistry<>("block type");
private final @Nonnull String id; private final @Nonnull String id;
private ArrayList<BlockState> states; private final BlockTypeEnum typeEnum;
public final Function<BlockState, BlockState> defaultValue; private BlockTypes.Settings settings;
private BlockTypes.Settings settings;
private BlockMaterial material;
public BlockType(@Nonnull String id) { // private ArrayList<BlockState> states;
this(id, null); // public final Function<BlockState, BlockState> defaultValue;
//
// private BlockMaterial material;
public BlockType(@Nonnull BlockTypeEnum typeEnum) {
this.typeEnum = typeEnum;
} }
public BlockType(@Nonnull String id, Function<BlockState, BlockState> defaultValue) { public BlockTypeEnum getTypeEnum() {
this.id = id; return typeEnum;
this.defaultValue = defaultValue; }
}
private void init(String id, int internalId, List<BlockState> states) {
public void setStates(ArrayList<BlockState> states) { try {
if (getId() == null) {
String name = (name().indexOf(':') == -1 ? "minecraft:" : "") + name().toLowerCase();
ReflectionUtils.setFailsafeFieldValue(BlockTypes.class.getDeclaredField("id"), this, name);
}
Settings settings = new Settings(this, id, internalId, states);
ReflectionUtils.setFailsafeFieldValue(BlockTypes.class.getDeclaredField("settings"), this, settings);
} catch (Throwable e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
public void setStates(ArrayList<BlockState> states) { //
this.states = states; this.states = states;
} }
public void setSettings(BlockTypes.Settings settings) { public void setSettings(BlockTypes.Settings settings) { //
this.settings = settings; this.settings = settings;
} }
public BlockTypes.Settings getSettings(){ public BlockTypes.Settings getSettings(){ //
return settings; return settings;
} }
public ArrayList<BlockState> updateStates(){ public ArrayList<BlockState> updateStates(){ //
if(settings != null) { if(settings != null) {
return settings.localStates = new ArrayList<>(settings.localStates.stream() return settings.localStates = new ArrayList<>(settings.localStates.stream()
.map(state -> new BlockStateImpl(this, state.getInternalId(), state.getOrdinal())).collect(Collectors.toList())); .map(state -> new BlockStateImpl(this, state.getInternalId(), state.getOrdinal())).collect(Collectors.toList()));
@ -130,13 +141,13 @@ public class BlockType implements FawePattern {
} }
@Deprecated @Deprecated
public BlockState withPropertyId(int propertyId) { public BlockState withPropertyId(int internalPropertiesId) {
if (settings.stateOrdinals == null) return settings.defaultState; if (internalPropertiesId == 0) return getDefaultState();
return states.get(settings.stateOrdinals[propertyId]); return BlockState.getFromInternalId(getInternalId() + (internalPropertiesId << BlockTypes.BIT_OFFSET));
} }
@Deprecated @Deprecated
public BlockState withStateId(int internalStateId) { public BlockState withStateId(int internalStateId) { //
return this.withPropertyId(internalStateId >> BlockTypes.BIT_OFFSET); return this.withPropertyId(internalStateId >> BlockTypes.BIT_OFFSET);
} }
@ -145,7 +156,7 @@ public class BlockType implements FawePattern {
* @param properties * @param properties
* @return * @return
*/ */
public BlockState withProperties(String properties) { public BlockState withProperties(String properties) { //
int id = getInternalId(); int id = getInternalId();
for (String keyPair : properties.split(",")) { for (String keyPair : properties.split(",")) {
String[] split = keyPair.split("="); String[] split = keyPair.split("=");
@ -190,7 +201,6 @@ public class BlockType implements FawePattern {
*/ */
@Deprecated @Deprecated
public <V> Property<V> getProperty(String name) { public <V> Property<V> getProperty(String name) {
checkArgument(this.settings.propertiesMap.get(name) != null, "%s has no property named %s", this, name);
return (Property<V>) this.settings.propertiesMap.get(name); return (Property<V>) this.settings.propertiesMap.get(name);
} }
@ -213,18 +223,14 @@ public class BlockType implements FawePattern {
* @return The default state * @return The default state
*/ */
public BlockState getDefaultState() { public BlockState getDefaultState() {
BlockState defaultState = this.settings.defaultState; return this.settings.defaultState;
if (defaultValue != null) {
defaultState = defaultValue.apply(defaultState);
}
return defaultState;
} }
public FuzzyBlockState getFuzzyMatcher() { public FuzzyBlockState getFuzzyMatcher() { //
return new FuzzyBlockState(this); return new FuzzyBlockState(this);
} }
public FuzzyBlockState getFuzzyMatcher() { public FuzzyBlockState getFuzzyMatcher() { //
return updateField(emptyFuzzy, () -> new FuzzyBlockState(this)); return updateField(emptyFuzzy, () -> new FuzzyBlockState(this));
} }
@ -235,7 +241,7 @@ public class BlockType implements FawePattern {
@Deprecated @Deprecated
public List<BlockState> getAllStates() { public List<BlockState> getAllStates() {
if (settings.stateOrdinals == null) return Collections.singletonList(getDefaultState()); if (settings.stateOrdinals == null) return Collections.singletonList(getDefaultState());
return IntStream.of(settings.stateOrdinals).filter(i -> i != -1).mapToObj(i -> states.get(i)).collect(Collectors.toList()); return IntStream.of(settings.stateOrdinals).filter(i -> i != -1).mapToObj(i -> BlockTypes.states[i]).collect(Collectors.toList());
} }
/** /**
@ -243,7 +249,7 @@ public class BlockType implements FawePattern {
* *
* @return The state, if it exists * @return The state, if it exists
*/ */
public BlockState getState(Map<Property<?>, Object> key) { public BlockState getState(Map<Property<?>, Object> key) { //
int id = getInternalId(); int id = getInternalId();
for (Map.Entry<Property<?>, Object> iter : key.entrySet()) { for (Map.Entry<Property<?>, Object> iter : key.entrySet()) {
Property<?> prop = iter.getKey(); Property<?> prop = iter.getKey();
@ -278,7 +284,7 @@ public class BlockType implements FawePattern {
*/ */
@Nullable @Nullable
public ItemType getItemType() { public ItemType getItemType() {
return ItemTypes.get(this); return settings.itemType;
} }
/** /**
@ -287,9 +293,7 @@ public class BlockType implements FawePattern {
* @return The material * @return The material
*/ */
public BlockMaterial getMaterial() { public BlockMaterial getMaterial() {
return this.material == null ? return this.settings.blockMaterial;
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getMaterial(this)
: this.material;
} }
/** /**
@ -317,12 +321,12 @@ public class BlockType implements FawePattern {
@Override @Override
public int hashCode() { public int hashCode() {
return this.getSettings().defaultState.ordinal(); return settings.internalId;
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
return obj instanceof BlockType && this.id.equals(((BlockType) obj).id); return obj == this;
} }
@Override @Override
@ -347,7 +351,7 @@ public class BlockType implements FawePattern {
@Deprecated @Deprecated
public int getLegacyId() { public int getLegacyId() { //
Integer id = LegacyMapper.getInstance().getLegacyCombined(this.getDefaultState()); Integer id = LegacyMapper.getInstance().getLegacyCombined(this.getDefaultState());
if (id != null) { if (id != null) {
return id >> 4; return id >> 4;

View File

@ -0,0 +1,5 @@
package com.sk89q.worldedit.world.block;
public enum BlockTypeEnum {
}

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.world.item; package com.sk89q.worldedit.world.item;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.registry.NamespacedRegistry; import com.sk89q.worldedit.registry.NamespacedRegistry;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;

View File

@ -872,6 +872,10 @@ public final class ItemTypes {
return ItemType.REGISTRY.register(type.getId(), type); return ItemType.REGISTRY.register(type.getId(), type);
} }
public static final @Nullable ItemType get(String id) {
}
public static final @Nullable ItemType get(BlockType type) { public static final @Nullable ItemType get(BlockType type) {
ItemType item = get(type.getId()); ItemType item = get(type.getId());
if (item != null && item.getBlockType() == null) { if (item != null && item.getBlockType() == null) {

View File

@ -51,11 +51,4 @@ public class BundledItemRegistry implements ItemRegistry {
public Collection<String> registerItems() { public Collection<String> registerItems() {
return Collections.emptyList(); return Collections.emptyList();
} }
@Nullable
@Override
public String getName(ItemType itemType) {
BundledItemData.ItemEntry itemEntry = BundledItemData.getInstance().findById(itemType.getId());
return itemEntry != null ? itemEntry.localizedName : null;
}
} }

View File

@ -233,7 +233,7 @@ public class LegacyMapper {
try { try {
return BlockTypes.get(plotBlock.toString()).getDefaultState().toBaseBlock(); return BlockTypes.get(plotBlock.toString()).getDefaultState().toBaseBlock();
}catch(Throwable failed) { }catch(Throwable failed) {
log.severe("Unable to convert StringPlotBlock " + plotBlock + " to BaseBlock!"); log.error("Unable to convert StringPlotBlock " + plotBlock + " to BaseBlock!");
failed.printStackTrace(); failed.printStackTrace();
return null; return null;
} }
@ -241,12 +241,12 @@ public class LegacyMapper {
try { try {
return new BaseBlock(((LegacyPlotBlock)plotBlock).getId(), ((LegacyPlotBlock)plotBlock).getData()); return new BaseBlock(((LegacyPlotBlock)plotBlock).getId(), ((LegacyPlotBlock)plotBlock).getData());
}catch(Throwable failed) { }catch(Throwable failed) {
log.severe("Unable to convert LegacyPlotBlock " + plotBlock + " to BaseBlock!"); log.error("Unable to convert LegacyPlotBlock " + plotBlock + " to BaseBlock!");
failed.printStackTrace(); failed.printStackTrace();
return null; return null;
} }
}else { }else {
log.severe("Unable to convert LegacyPlotBlock " + plotBlock + " to BaseBlock!"); log.error("Unable to convert LegacyPlotBlock " + plotBlock + " to BaseBlock!");
return null; return null;
} }
} }