mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
wip upstream merge
This commit is contained in:
parent
7086eb8b3e
commit
8897109dc4
@ -189,7 +189,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public int getBiomeId(Biome biome) {
|
||||
public BiomeType getBiomeId(Biome biome) {
|
||||
BiomeBase mcBiome = CraftBlock.biomeToBiomeBase(biome);
|
||||
return mcBiome != null ? IRegistry.BIOME.a(mcBiome) : 0;
|
||||
}
|
||||
|
@ -352,7 +352,7 @@
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getBiomeId(Biome biome) {
|
||||
// public BiomeType getBiomeType(Biome biome) {
|
||||
// try {
|
||||
// Object biomeBase = biomeToBiomeBase.invoke(null, biome);
|
||||
// if (biomeBase != null) return (int) biomeBaseToTypeId.invoke(null, biomeBase);
|
||||
|
@ -232,7 +232,7 @@ public class AsyncBlock implements Block {
|
||||
|
||||
@Override
|
||||
public Biome getBiome() {
|
||||
return world.getAdapter().getBiome(queue.getBiomeId(x, z));
|
||||
return world.getAdapter().getBiome(queue.getBiomeType(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,7 +20,6 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -859,7 +858,7 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
|
||||
|
||||
@Override
|
||||
public Biome getBiome(int x, int z) {
|
||||
return adapter.getBiome(queue.getBiomeId(x, z));
|
||||
return adapter.getBiome(queue.getBiomeType(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,24 +29,7 @@ public class FaweCache {
|
||||
*/
|
||||
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 {
|
||||
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_Z[0] = new byte[4096];
|
||||
for (int y = 0; y < 16; y++) {
|
||||
|
@ -529,9 +529,9 @@ public class CFICommands extends MethodCommands {
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
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();
|
||||
if (image != null) gen.setBiome(load(image), (byte) biome.getId(), !disableWhiteOnly);
|
||||
else if (mask != null) gen.setBiome(mask, (byte) biome.getId());
|
||||
else gen.setBiome((byte) biome.getId());
|
||||
if (image != null) gen.setBiome(load(image), biome, !disableWhiteOnly);
|
||||
else if (mask != null) gen.setBiome(mask, biome);
|
||||
else gen.setBiome(biome);
|
||||
msg("Set biome!").send(fp);
|
||||
assertSettings(fp).resetComponent();
|
||||
component(fp);
|
||||
|
@ -753,7 +753,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, CHUNKSECTIONS, SECTION> impl
|
||||
}
|
||||
|
||||
@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 cz = z >> 4;
|
||||
lastSectionY = -1;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.boydti.fawe.jnbt.anvil;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.SimpleIntFaweChunk;
|
||||
import com.boydti.fawe.object.*;
|
||||
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.worldedit.*;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
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) {
|
||||
int index = z * getWidth() + x;
|
||||
if (index < 0 || index >= getArea()) return false;
|
||||
biomes.setByte(index, (byte) biome.getId());
|
||||
biomes.setByte(index, (byte) biome.getInternalId());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -920,7 +920,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
}
|
||||
|
||||
@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;
|
||||
if (index < 0 || index >= getArea()) index = Math.floorMod(index, getArea());
|
||||
return biomes.getByte(index) & 0xFF;
|
||||
@ -1011,7 +1011,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return FaweCache.CACHE_BIOME[getBiomeId(position.getBlockX(), position.getBlockZ())];
|
||||
return BiomeTypes.get(getBiomeType(position.getBlockX(), position.getBlockZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1069,9 +1069,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
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())
|
||||
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
|
||||
byte biomeByte = (byte) biome.getInternalId();
|
||||
biomes.record(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -1082,7 +1083,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
int height = img.getRGB(x, z) & 0xFF;
|
||||
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
|
||||
.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;
|
||||
byte biomeByte = (byte) biome.getInternalId();
|
||||
for (int z = 0; z < getLength(); z++) {
|
||||
mutable.mutZ(z);
|
||||
for (int x = 0; x < getWidth(); x++, index++) {
|
||||
@ -1326,7 +1328,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
mutable.mutX(x);
|
||||
mutable.mutY(y);
|
||||
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) {
|
||||
biomes.record(() -> Arrays.fill(biomes.get(), (byte) biome));
|
||||
public void setBiome(BiomeType biome) {
|
||||
biomes.record(() -> Arrays.fill(biomes.get(), (byte) biome.getInternalId()));
|
||||
}
|
||||
|
||||
public void setFloor(Pattern value) {
|
||||
|
@ -90,7 +90,7 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
|
||||
if (faweChunk instanceof MCAChunk) {
|
||||
return ((MCAChunk) faweChunk).getBiomeArray()[((z & 0xF) << 4 | x & 0xF)];
|
||||
} else if (parent != null) {
|
||||
return parent.getBiomeId(x, z);
|
||||
return parent.getBiomeType(x, z);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ public class DeleteBiomeFilterSimple extends MCAFilterCounter {
|
||||
private final int id;
|
||||
|
||||
public DeleteBiomeFilterSimple(BiomeType biome) {
|
||||
this.id = biome.getId();
|
||||
this.id = biome.getInternalId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,9 +45,9 @@ public class ChangeSetFaweQueue extends DelegateFaweQueue {
|
||||
@Override
|
||||
public boolean setBiome(int x, int z, BiomeType biome) {
|
||||
if (super.setBiome(x, z, biome)) {
|
||||
int oldBiome = getParent().getBiomeId(x, z);
|
||||
if (oldBiome != biome.getId()) {
|
||||
set.addBiomeChange(x, z, FaweCache.getBiome(oldBiome), biome);
|
||||
BiomeType oldBiome = getParent().getBiomeType(x, z);
|
||||
if (oldBiome != biome) {
|
||||
set.addBiomeChange(x, z, oldBiome, biome);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract byte[] getBiomeArray();
|
||||
public abstract BiomeType[] getBiomeArray();
|
||||
|
||||
public void forEachQueuedBlock(FaweChunkVisitor onEach) {
|
||||
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 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);
|
||||
|
@ -400,7 +400,7 @@ public interface FaweQueue extends HasFaweQueue, Extent {
|
||||
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;
|
||||
|
||||
|
@ -9,6 +9,7 @@ import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
@ -62,7 +63,7 @@ public abstract class ImmutableVirtualWorld implements VirtualWorld {
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return FaweCache.getBiome(0);
|
||||
return BiomeTypes.FOREST;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,31 +5,32 @@ import com.sk89q.worldedit.history.UndoContext;
|
||||
import com.sk89q.worldedit.history.change.Change;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
|
||||
public class MutableBiomeChange implements Change {
|
||||
|
||||
private MutableBlockVector2 mutable = new MutableBlockVector2();
|
||||
private BiomeType from;
|
||||
private BiomeType to;
|
||||
private int from;
|
||||
private int to;
|
||||
|
||||
public MutableBiomeChange() {
|
||||
this.from = new BiomeType(0);
|
||||
this.to = new BiomeType(0);
|
||||
this.from = 0;
|
||||
this.to = 0;
|
||||
}
|
||||
|
||||
public void setBiome(int x, int z, int from, int to) {
|
||||
mutable.setComponents(x, z);
|
||||
this.from.setId(from);
|
||||
this.to.setId(to);
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo(UndoContext context) throws WorldEditException {
|
||||
context.getExtent().setBiome(mutable, from);
|
||||
context.getExtent().setBiome(mutable, BiomeTypes.get(from));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redo(UndoContext context) throws WorldEditException {
|
||||
context.getExtent().setBiome(mutable, to);
|
||||
context.getExtent().setBiome(mutable, BiomeTypes.get(to));
|
||||
}
|
||||
}
|
||||
|
@ -268,16 +268,16 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
synchronized (FaweChangeSet.this) {
|
||||
// Biome changes
|
||||
if (previous.getBiomeArray() != null) {
|
||||
byte[] previousBiomes = previous.getBiomeArray();
|
||||
byte[] nextBiomes = next.getBiomeArray();
|
||||
BiomeType[] previousBiomes = previous.getBiomeArray();
|
||||
BiomeType[] nextBiomes = next.getBiomeArray();
|
||||
int index = 0;
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int zz = bz + z;
|
||||
for (int x = 0; x < 16; x++) {
|
||||
byte idFrom = previousBiomes[index];
|
||||
byte idTo = nextBiomes[index];
|
||||
if (idFrom != idTo && idTo != 0) {
|
||||
addBiomeChange(bx + x, zz, FaweCache.getBiome(idFrom & 0xFF), FaweCache.getBiome(idTo & 0xFF));
|
||||
BiomeType idFrom = previousBiomes[index];
|
||||
BiomeType idTo = nextBiomes[index];
|
||||
if (idFrom != idTo && idTo != null) {
|
||||
addBiomeChange(bx + x, zz, idFrom, idTo);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
@ -337,8 +337,8 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
os.write((byte) (z >> 16));
|
||||
os.write((byte) (z >> 8));
|
||||
os.write((byte) (z));
|
||||
os.write(from.getId());
|
||||
os.write(to.getId());
|
||||
((FaweOutputStream) os).writeVarInt(from.getInternalId());
|
||||
((FaweOutputStream) os).writeVarInt(to.getInternalId());
|
||||
} catch (Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
@ -462,8 +462,8 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
if (int1 != -1) {
|
||||
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 from = is.read();
|
||||
int to = is.read();
|
||||
int from = ((FaweInputStream) is).readVarInt();
|
||||
int to = ((FaweInputStream) is).readVarInt();
|
||||
change.setBiome(x, z, from, to);
|
||||
return change;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class CPUOptimizedClipboard extends FaweClipboard {
|
||||
private int area;
|
||||
private int volume;
|
||||
|
||||
private byte[] biomes = null;
|
||||
private BiomeType[] biomes = null;
|
||||
private int[] states;
|
||||
|
||||
private final HashMap<IntegerTrio, CompoundTag> nbtMapLoc;
|
||||
@ -65,11 +65,11 @@ public class CPUOptimizedClipboard extends FaweClipboard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int index, int biome) {
|
||||
public void setBiome(int index, BiomeType biome) {
|
||||
if (biomes == null) {
|
||||
biomes = new byte[area];
|
||||
biomes = new BiomeType[area];
|
||||
}
|
||||
biomes[index] = (byte) biome;
|
||||
biomes[index] = biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -88,7 +88,7 @@ public class CPUOptimizedClipboard extends FaweClipboard {
|
||||
if (!hasBiomes()) {
|
||||
return null;
|
||||
}
|
||||
return FaweCache.CACHE_BIOME[biomes[index] & 0xFF];
|
||||
return biomes[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,7 +71,7 @@ public abstract class ReadOnlyClipboard extends FaweClipboard {
|
||||
int index = 0;
|
||||
for (int z = 0; z <= dim.getBlockZ(); z++) {
|
||||
for (int x = 0; x <= dim.getBlockX(); x++, index++) {
|
||||
task.run(index, getBiome(x, z).getId());
|
||||
task.run(index, getBiome(x, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
package com.boydti.fawe.object.extent;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.HasFaweQueue;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.*;
|
||||
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.BlockState;
|
||||
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.world.World;
|
||||
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.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -107,7 +105,7 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa
|
||||
|
||||
@Override
|
||||
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
|
||||
|
@ -103,7 +103,7 @@ public class PatternExtent extends AbstractPattern implements Extent {
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return new BiomeType(0);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,8 +58,8 @@ public class FaweQueueDelegateExtent extends DelegateFaweQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
return parentExtent.getBiome(BlockVector2.at(x, z)).getId();
|
||||
public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
return parentExtent.getBiome(BlockVector2.at(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -343,8 +343,8 @@ public interface IDelegateFaweQueue extends FaweQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
default int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
return getQueue().getBiomeId(x, z);
|
||||
default BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
return getQueue().getBiomeType(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -183,7 +183,7 @@ public class NullFaweQueue implements FaweQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -578,7 +578,7 @@ public class SchemVis extends ImmutableVirtualWorld {
|
||||
public void sendChunk(int x, int z, int bitMask) { /* do nothing - never used*/ }
|
||||
|
||||
@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)
|
||||
return 0;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
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.biome.Biomes;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -94,7 +95,7 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
|
||||
if (reg == null) {
|
||||
reg = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.USER_COMMANDS).getRegistries().getBiomeRegistry();
|
||||
}
|
||||
List<BiomeType> biomes = reg.getBiomes();
|
||||
List<BiomeType> biomes = BiomeTypes.values();
|
||||
lastBiome = biome;
|
||||
this.biome = Biomes.findBiomeByName(biomes, biome, reg);
|
||||
}
|
||||
|
@ -12,6 +12,9 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import jdk.internal.reflect.ConstructorAccessor;
|
||||
import jdk.internal.reflect.FieldAccessor;
|
||||
import sun.reflect.ConstructorAccessor;
|
||||
import sun.reflect.FieldAccessor;
|
||||
import sun.reflect.ReflectionFactory;
|
||||
|
@ -1409,23 +1409,23 @@ public class LocalSession implements TextureHolder {
|
||||
this.fastMode = fastMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the reorder mode of the session.
|
||||
*
|
||||
* @return The reorder mode
|
||||
*/
|
||||
public EditSession.ReorderMode getReorderMode() {
|
||||
return reorderMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the reorder mode of the session.
|
||||
*
|
||||
* @param reorderMode The reorder mode
|
||||
*/
|
||||
public void setReorderMode(EditSession.ReorderMode reorderMode) {
|
||||
this.reorderMode = reorderMode;
|
||||
}
|
||||
// /**
|
||||
// * Gets the reorder mode of the session.
|
||||
// *
|
||||
// * @return The reorder mode
|
||||
// */
|
||||
// public EditSession.ReorderMode getReorderMode() {
|
||||
// return reorderMode;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Sets the reorder mode of the session.
|
||||
// *
|
||||
// * @param reorderMode The reorder mode
|
||||
// */
|
||||
// public void setReorderMode(EditSession.ReorderMode reorderMode) {
|
||||
// this.reorderMode = reorderMode;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Get the mask.
|
||||
|
@ -37,6 +37,9 @@ import com.sk89q.worldedit.extension.platform.PlatformManager;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
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.scripting.CraftScriptContext;
|
||||
import com.sk89q.worldedit.scripting.CraftScriptEngine;
|
||||
@ -73,8 +76,6 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
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.OPEN;
|
||||
|
@ -56,6 +56,7 @@ import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeData;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -65,6 +66,8 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
|
||||
/**
|
||||
* Implements biome-related commands such as "/biomelist".
|
||||
*/
|
||||
@ -104,7 +107,7 @@ public class BiomeCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
BiomeRegistry biomeRegistry = getBiomeRegistry();
|
||||
List<BiomeType> biomes = biomeRegistry.getBiomes();
|
||||
List<BiomeType> biomes = BiomeTypes.values();
|
||||
int totalPages = biomes.size() / 19 + 1;
|
||||
Message msg = BBC.BIOME_LIST_HEADER.m(page, totalPages);
|
||||
String setBiome = Commands.getAlias(BiomeCommands.class, "/setbiome");
|
||||
@ -141,7 +144,8 @@ public class BiomeCommands extends MethodCommands {
|
||||
@CommandPermissions("worldedit.biome.info")
|
||||
public void biomeInfo(Player player, LocalSession session, final EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
BiomeRegistry biomeRegistry = getBiomeRegistry();
|
||||
final int[] biomes = new int[256];
|
||||
List<BiomeType> values = BiomeTypes.values();
|
||||
final int[] biomes = new int[values.size()];
|
||||
final String qualifier;
|
||||
|
||||
int size = 0;
|
||||
@ -165,14 +169,14 @@ public class BiomeCommands extends MethodCommands {
|
||||
|
||||
if (region instanceof FlatRegion) {
|
||||
for (BlockVector2 pt : new Fast2DIterator(((FlatRegion) region).asFlatRegion(), editSession)) {
|
||||
biomes[editSession.getBiome(pt).getId()]++;
|
||||
biomes[editSession.getBiome(pt).getInternalId()]++;
|
||||
size++;
|
||||
}
|
||||
} else {
|
||||
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
biomes[editSession.getBiome(position.toBlockVector2()).getId()]++;
|
||||
biomes[editSession.getBiome(position.toBlockVector2()).getInternalId()]++;
|
||||
return true;
|
||||
}
|
||||
}, editSession);
|
||||
@ -187,7 +191,7 @@ public class BiomeCommands extends MethodCommands {
|
||||
for (int i = 0; i < biomes.length; i++) {
|
||||
int count = biomes[i];
|
||||
if (count != 0) {
|
||||
distribution.add(new Countable<>(new BiomeType(i), count));
|
||||
distribution.add(new Countable<>(BiomeTypes.get(i), count));
|
||||
}
|
||||
}
|
||||
Collections.sort(distribution);
|
||||
|
@ -25,6 +25,7 @@ import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.extension.input.DisallowedUsageException;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
|
@ -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.Text;
|
||||
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.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.
|
||||
@ -427,7 +437,8 @@ public class GenerationCommands extends MethodCommands {
|
||||
@Switch('h') boolean hollow,
|
||||
@Switch('r') boolean useRawCoords,
|
||||
@Switch('o') boolean offset,
|
||||
@Switch('c') boolean offsetCenter) throws WorldEditException {
|
||||
@Switch('c') boolean offsetCenter,
|
||||
CommandContext context) throws WorldEditException {
|
||||
final Vector3 zero;
|
||||
Vector3 unit;
|
||||
|
||||
|
@ -53,6 +53,7 @@ import com.sk89q.worldedit.function.visitor.LayerVisitor;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
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.Text;
|
||||
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.Iterator;
|
||||
@ -704,7 +710,7 @@ public class RegionCommands extends MethodCommands {
|
||||
BiomeType biome = null;
|
||||
if (context.argsLength() >= 1) {
|
||||
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);
|
||||
}
|
||||
Long seed = context.argsLength() != 2 || !MathMan.isInteger(context.getString(1)) ? null : Long.parseLong(context.getString(1));
|
||||
|
@ -65,8 +65,10 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.file.Files;
|
||||
@ -79,6 +81,7 @@ import java.util.UUID;
|
||||
import java.util.concurrent.atomic.LongAdder;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.boydti.fawe.util.ReflectionUtils.as;
|
||||
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 Logger log = LoggerFactory.getLogger(SchematicCommands.class);
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -279,7 +281,7 @@ public class SchematicCommands extends MethodCommands {
|
||||
player.printError("Unknown filename: " + filename);
|
||||
} catch (URISyntaxException | IOException e) {
|
||||
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 {
|
||||
if (in != null) {
|
||||
try {
|
||||
|
@ -60,6 +60,7 @@ import com.sk89q.worldedit.regions.selector.RegionSelectorType;
|
||||
import com.sk89q.worldedit.regions.selector.SphereRegionSelector;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
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.formatting.ColorCodeBuilder;
|
||||
import com.sk89q.worldedit.util.formatting.Style;
|
||||
@ -103,7 +104,7 @@ public class SelectionCommands {
|
||||
@CommandPermissions("worldedit.selection.pos")
|
||||
public void pos1(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
Location pos;
|
||||
BlockVector3 pos;
|
||||
|
||||
if (args.argsLength() == 1) {
|
||||
if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
|
||||
@ -136,7 +137,7 @@ public class SelectionCommands {
|
||||
@CommandPermissions("worldedit.selection.pos")
|
||||
public void pos2(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
Location pos;
|
||||
BlockVector3 pos;
|
||||
if (args.argsLength() == 1) {
|
||||
if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
|
||||
String[] coords = args.getString(0).split(",");
|
||||
@ -735,7 +736,7 @@ public class SelectionCommands {
|
||||
min = 0,
|
||||
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();
|
||||
if (args.argsLength() == 0) {
|
||||
session.getRegionSelector(world).clear();
|
||||
|
@ -27,6 +27,10 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
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.util.Direction;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
@ -70,7 +74,8 @@ public class FloatingTreeRemover implements BlockTool {
|
||||
Player player, LocalSession session, Location clicked) {
|
||||
|
||||
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())) {
|
||||
player.printError("That's not a tree.");
|
||||
|
@ -21,14 +21,11 @@ package com.sk89q.worldedit.command.tool.brush;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
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.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
public class GravityBrush implements Brush {
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
package com.sk89q.worldedit.event.extent;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.event.Cancellable;
|
||||
import com.sk89q.worldedit.event.Event;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.extension.factory;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
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.DefaultPatternParser;
|
||||
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.SingleBlockPatternParser;
|
||||
|
@ -44,6 +44,7 @@ import com.sk89q.worldedit.command.composition.DeformCommand;
|
||||
import com.sk89q.worldedit.command.composition.PaintCommand;
|
||||
import com.sk89q.worldedit.command.composition.ShapedBrushCommand;
|
||||
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.CommandSuggestionEvent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
@ -486,7 +487,7 @@ public final class CommandManager {
|
||||
actor.printError(BBC.getPrefix() + e.getMessage());
|
||||
} else {
|
||||
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) {
|
||||
Exception faweException = FaweException.get(e);
|
||||
@ -496,7 +497,7 @@ public final class CommandManager {
|
||||
} else {
|
||||
actor.printError(BBC.getPrefix() + "There was an error handling a FAWE command: [See console]");
|
||||
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 {
|
||||
final EditSession editSession = locals.get(EditSession.class);
|
||||
|
@ -36,6 +36,8 @@ import com.google.common.io.Files;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -61,7 +61,7 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public class BlockTransformExtent extends ResettableExtent {
|
||||
|
||||
private final Transform transform;
|
||||
private Transform transform;
|
||||
|
||||
|
||||
public BlockTransformExtent(Extent parent) {
|
||||
@ -138,9 +138,6 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
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");
|
||||
|
||||
/**
|
||||
|
@ -150,8 +150,7 @@ public class Deform implements Contextual<Operation> {
|
||||
}
|
||||
|
||||
LocalSession session = context.getSession();
|
||||
return new DeformOperation(context.getDestination(), region, zero, unit, expression,
|
||||
session == null ? WorldEdit.getInstance().getConfiguration().calculationTimeout : session.getTimeout());
|
||||
return new DeformOperation(context.getDestination(), region, zero, unit, expression);
|
||||
}
|
||||
|
||||
private static final class DeformOperation implements Operation {
|
||||
@ -160,7 +159,6 @@ public class Deform implements Contextual<Operation> {
|
||||
private final Vector3 zero;
|
||||
private final Vector3 unit;
|
||||
private final String expression;
|
||||
private final int timeout;
|
||||
|
||||
private DeformOperation(Extent destination, Region region, Vector3 zero, Vector3 unit, String expression) {
|
||||
this.destination = destination;
|
||||
@ -168,7 +166,6 @@ public class Deform implements Contextual<Operation> {
|
||||
this.zero = zero;
|
||||
this.unit = unit;
|
||||
this.expression = expression;
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,6 +12,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -20,6 +20,8 @@
|
||||
package com.sk89q.worldedit.world.biome;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Stores a list of common Biome String IDs.
|
||||
@ -121,4 +123,8 @@ public class BiomeTypes {
|
||||
public static BiomeType get(int parseInt) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
public static List<BiomeType> values() {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.pattern.FawePattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@ -52,29 +53,15 @@ import java.util.Set;
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
||||
private final BlockType blockType;
|
||||
private BlockMaterial material;
|
||||
private BlockType blockType;
|
||||
private int internalId, ordinal;
|
||||
private BaseBlock emptyBaseBlock;
|
||||
|
||||
BlockState(BlockType blockType) {
|
||||
BlockState(BlockType blockType, int internalId, int ordinal) {
|
||||
this.blockType = blockType;
|
||||
this.emptyBaseBlock = new BaseBlock(this);
|
||||
}
|
||||
|
||||
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;
|
||||
this.internalId = internalId;
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -364,13 +351,22 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
||||
|
||||
@Override
|
||||
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
|
||||
public int getOrdinal() {
|
||||
get ordinal
|
||||
return this.ordinal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method used for creating the initial BlockState.
|
||||
*
|
||||
@ -399,8 +395,6 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
||||
return equalsFuzzy((BlockState) obj);
|
||||
}
|
||||
|
||||
private Integer hashCodeCache = null;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getOrdinal();
|
||||
|
@ -21,14 +21,13 @@ package com.sk89q.worldedit.world.block;
|
||||
|
||||
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.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.SingleBlockTypeMask;
|
||||
import com.sk89q.worldedit.function.pattern.FawePattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
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.PropertyKey;
|
||||
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 javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
@ -55,33 +49,50 @@ public class BlockType implements FawePattern {
|
||||
public static final NamespacedRegistry<BlockType> REGISTRY = new NamespacedRegistry<>("block type");
|
||||
|
||||
private final @Nonnull String id;
|
||||
private ArrayList<BlockState> states;
|
||||
public final Function<BlockState, BlockState> defaultValue;
|
||||
private final BlockTypeEnum typeEnum;
|
||||
private BlockTypes.Settings settings;
|
||||
private BlockMaterial material;
|
||||
|
||||
public BlockType(@Nonnull String id) {
|
||||
this(id, null);
|
||||
// private ArrayList<BlockState> states;
|
||||
// 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) {
|
||||
this.id = id;
|
||||
this.defaultValue = defaultValue;
|
||||
public BlockTypeEnum getTypeEnum() {
|
||||
return typeEnum;
|
||||
}
|
||||
|
||||
public void setStates(ArrayList<BlockState> states) {
|
||||
private void init(String id, int internalId, List<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;
|
||||
}
|
||||
|
||||
public void setSettings(BlockTypes.Settings settings) {
|
||||
public void setSettings(BlockTypes.Settings settings) { //
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
public BlockTypes.Settings getSettings(){
|
||||
public BlockTypes.Settings getSettings(){ //
|
||||
return settings;
|
||||
}
|
||||
|
||||
public ArrayList<BlockState> updateStates(){
|
||||
public ArrayList<BlockState> updateStates(){ //
|
||||
if(settings != null) {
|
||||
return settings.localStates = new ArrayList<>(settings.localStates.stream()
|
||||
.map(state -> new BlockStateImpl(this, state.getInternalId(), state.getOrdinal())).collect(Collectors.toList()));
|
||||
@ -130,13 +141,13 @@ public class BlockType implements FawePattern {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public BlockState withPropertyId(int propertyId) {
|
||||
if (settings.stateOrdinals == null) return settings.defaultState;
|
||||
return states.get(settings.stateOrdinals[propertyId]);
|
||||
public BlockState withPropertyId(int internalPropertiesId) {
|
||||
if (internalPropertiesId == 0) return getDefaultState();
|
||||
return BlockState.getFromInternalId(getInternalId() + (internalPropertiesId << BlockTypes.BIT_OFFSET));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public BlockState withStateId(int internalStateId) {
|
||||
public BlockState withStateId(int internalStateId) { //
|
||||
return this.withPropertyId(internalStateId >> BlockTypes.BIT_OFFSET);
|
||||
}
|
||||
|
||||
@ -145,7 +156,7 @@ public class BlockType implements FawePattern {
|
||||
* @param properties
|
||||
* @return
|
||||
*/
|
||||
public BlockState withProperties(String properties) {
|
||||
public BlockState withProperties(String properties) { //
|
||||
int id = getInternalId();
|
||||
for (String keyPair : properties.split(",")) {
|
||||
String[] split = keyPair.split("=");
|
||||
@ -190,7 +201,6 @@ public class BlockType implements FawePattern {
|
||||
*/
|
||||
@Deprecated
|
||||
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);
|
||||
}
|
||||
|
||||
@ -213,18 +223,14 @@ public class BlockType implements FawePattern {
|
||||
* @return The default state
|
||||
*/
|
||||
public BlockState getDefaultState() {
|
||||
BlockState defaultState = this.settings.defaultState;
|
||||
if (defaultValue != null) {
|
||||
defaultState = defaultValue.apply(defaultState);
|
||||
}
|
||||
return defaultState;
|
||||
return this.settings.defaultState;
|
||||
}
|
||||
|
||||
public FuzzyBlockState getFuzzyMatcher() {
|
||||
public FuzzyBlockState getFuzzyMatcher() { //
|
||||
return new FuzzyBlockState(this);
|
||||
}
|
||||
|
||||
public FuzzyBlockState getFuzzyMatcher() {
|
||||
public FuzzyBlockState getFuzzyMatcher() { //
|
||||
return updateField(emptyFuzzy, () -> new FuzzyBlockState(this));
|
||||
}
|
||||
|
||||
@ -235,7 +241,7 @@ public class BlockType implements FawePattern {
|
||||
@Deprecated
|
||||
public List<BlockState> getAllStates() {
|
||||
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
|
||||
*/
|
||||
public BlockState getState(Map<Property<?>, Object> key) {
|
||||
public BlockState getState(Map<Property<?>, Object> key) { //
|
||||
int id = getInternalId();
|
||||
for (Map.Entry<Property<?>, Object> iter : key.entrySet()) {
|
||||
Property<?> prop = iter.getKey();
|
||||
@ -278,7 +284,7 @@ public class BlockType implements FawePattern {
|
||||
*/
|
||||
@Nullable
|
||||
public ItemType getItemType() {
|
||||
return ItemTypes.get(this);
|
||||
return settings.itemType;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -287,9 +293,7 @@ public class BlockType implements FawePattern {
|
||||
* @return The material
|
||||
*/
|
||||
public BlockMaterial getMaterial() {
|
||||
return this.material == null ?
|
||||
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getMaterial(this)
|
||||
: this.material;
|
||||
return this.settings.blockMaterial;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -317,12 +321,12 @@ public class BlockType implements FawePattern {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.getSettings().defaultState.ordinal();
|
||||
return settings.internalId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof BlockType && this.id.equals(((BlockType) obj).id);
|
||||
return obj == this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -347,7 +351,7 @@ public class BlockType implements FawePattern {
|
||||
|
||||
|
||||
@Deprecated
|
||||
public int getLegacyId() {
|
||||
public int getLegacyId() { //
|
||||
Integer id = LegacyMapper.getInstance().getLegacyCombined(this.getDefaultState());
|
||||
if (id != null) {
|
||||
return id >> 4;
|
||||
|
@ -0,0 +1,5 @@
|
||||
package com.sk89q.worldedit.world.block;
|
||||
|
||||
public enum BlockTypeEnum {
|
||||
|
||||
}
|
@ -20,6 +20,7 @@
|
||||
package com.sk89q.worldedit.world.item;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
|
@ -872,6 +872,10 @@ public final class ItemTypes {
|
||||
return ItemType.REGISTRY.register(type.getId(), type);
|
||||
}
|
||||
|
||||
public static final @Nullable ItemType get(String id) {
|
||||
|
||||
}
|
||||
|
||||
public static final @Nullable ItemType get(BlockType type) {
|
||||
ItemType item = get(type.getId());
|
||||
if (item != null && item.getBlockType() == null) {
|
||||
|
@ -51,11 +51,4 @@ public class BundledItemRegistry implements ItemRegistry {
|
||||
public Collection<String> registerItems() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getName(ItemType itemType) {
|
||||
BundledItemData.ItemEntry itemEntry = BundledItemData.getInstance().findById(itemType.getId());
|
||||
return itemEntry != null ? itemEntry.localizedName : null;
|
||||
}
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ public class LegacyMapper {
|
||||
try {
|
||||
return BlockTypes.get(plotBlock.toString()).getDefaultState().toBaseBlock();
|
||||
}catch(Throwable failed) {
|
||||
log.severe("Unable to convert StringPlotBlock " + plotBlock + " to BaseBlock!");
|
||||
log.error("Unable to convert StringPlotBlock " + plotBlock + " to BaseBlock!");
|
||||
failed.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
@ -241,12 +241,12 @@ public class LegacyMapper {
|
||||
try {
|
||||
return new BaseBlock(((LegacyPlotBlock)plotBlock).getId(), ((LegacyPlotBlock)plotBlock).getData());
|
||||
}catch(Throwable failed) {
|
||||
log.severe("Unable to convert LegacyPlotBlock " + plotBlock + " to BaseBlock!");
|
||||
log.error("Unable to convert LegacyPlotBlock " + plotBlock + " to BaseBlock!");
|
||||
failed.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}else {
|
||||
log.severe("Unable to convert LegacyPlotBlock " + plotBlock + " to BaseBlock!");
|
||||
log.error("Unable to convert LegacyPlotBlock " + plotBlock + " to BaseBlock!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user