From eec08c81ad51d0ff32d9d4f7233d8e4373db093f Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 2 May 2019 01:45:18 +1000 Subject: [PATCH] async chunk loading --- .../fawe/bukkit/beta/BukkitChunkHolder.java | 51 +- .../fawe/bukkit/beta/BukkitFullChunk.java | 42 - .../fawe/bukkit/beta/BukkitGetBlocks.java | 24 +- .../boydti/fawe/bukkit/beta/BukkitQueue.java | 203 ++- .../boydti/fawe/bukkit/beta/DelegateLock.java | 78 ++ .../fawe/bukkit/v1_13/BukkitQueue_1_13.java | 151 ++- .../main/java/com/boydti/fawe/FaweCache.java | 19 + .../com/boydti/fawe/beta/CharFilterBlock.java | 75 +- .../java/com/boydti/fawe/beta/IChunk.java | 38 +- .../com/boydti/fawe/beta/IDelegateChunk.java | 11 +- .../java/com/boydti/fawe/beta/IGetBlocks.java | 4 + .../com/boydti/fawe/beta/IQueueExtent.java | 2 +- .../java/com/boydti/fawe/beta/ISetBlocks.java | 4 + .../beta/implementation/QueueHandler.java | 105 +- .../SingleThreadQueueExtent.java | 111 +- .../implementation/blocks/CharGetBlocks.java | 13 +- .../implementation/holder/ChunkHolder.java | 37 +- .../worldedit/command/RegionCommands.java | 3 + .../sk89q/worldedit/world/block/BlockID.java | 1128 ++++++++--------- .../worldedit/world/block/BlockTypes.java | 7 +- 20 files changed, 1224 insertions(+), 882 deletions(-) delete mode 100644 worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitFullChunk.java create mode 100644 worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/DelegateLock.java diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitChunkHolder.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitChunkHolder.java index e36c29777..61d872767 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitChunkHolder.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitChunkHolder.java @@ -6,7 +6,9 @@ import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.implementation.blocks.CharSetBlocks; import com.boydti.fawe.beta.implementation.holder.ChunkHolder; -public class BukkitChunkHolder extends ChunkHolder { +import java.util.concurrent.Future; + +public class BukkitChunkHolder> extends ChunkHolder { @Override public void init(final IQueueExtent extent, final int X, final int Z) { super.init(extent, X, Z); @@ -19,30 +21,37 @@ public class BukkitChunkHolder extends ChunkHolder { } @Override - public boolean applyAsync() { - BukkitGetBlocks get = (BukkitGetBlocks) cachedGet(); - CharSetBlocks set = (CharSetBlocks) cachedSet(); -// - getBlocks -// - set lock -// - synchronize on chunk object -// - verify section is same object as chunk's section -// - merge with setblocks -// - set section -// - verify chunk is same -// - verify section is same -// - Otherwise repeat steps on main thread -// - set status to needs relighting -// - mark as dirty -// - skip verification if main thread + public T call() { + BukkitQueue extent = (BukkitQueue) getExtent(); + BukkitGetBlocks get = (BukkitGetBlocks) getOrCreateGet(); + CharSetBlocks set = (CharSetBlocks) getOrCreateSet(); + + + + /* + + - getBlocks + - set ChunkSection lock with a tracking lock + - synchronize on chunk object (so no other FAWE thread updates it at the same time) + - verify cached section is same object as NMS chunk section + otherwise, fetch the new section, set the tracking lock and reconstruct the getBlocks array + - Merge raw getBlocks and setBlocks array + - Construct the ChunkSection + - In parallel on the main thread + - if the tracking lock has had no updates and the cached ChunkSection == the NMS chunk section + - Otherwise, reconstruct the ChunkSection (TODO: Benchmark if this is a performance concern) + - swap in the new ChunkSection + - Update tile entities/entities (if necessary) + - Merge the biome array (if necessary) + - set chunk status to needs relighting + - mark as dirty + + */ + throw new UnsupportedOperationException("Not implemented"); // return true; } - @Override - public boolean applySync() { - return true; - } - @Override public void set(final Filter filter) { // for each block diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitFullChunk.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitFullChunk.java deleted file mode 100644 index c69c48bdb..000000000 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitFullChunk.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.boydti.fawe.bukkit.beta; - -import com.boydti.fawe.beta.Filter; -import com.boydti.fawe.beta.IQueueExtent; -import com.boydti.fawe.beta.ISetBlocks; -import com.boydti.fawe.beta.implementation.holder.ChunkHolder; - -public class BukkitFullChunk extends ChunkHolder { - public BukkitFullChunk() { - throw new UnsupportedOperationException("Not implemented"); - } - - @Override - public void init(IQueueExtent extent, int X, int Z) { - - } - - @Override - public boolean applyAsync() { - return false; - } - - @Override - public boolean applySync() { - return false; - } - - @Override - public void set(Filter filter) { - - } - - @Override - public Object get() { - return null; - } - - @Override - public ISetBlocks set() { - return null; - } -} diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitGetBlocks.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitGetBlocks.java index d3d4f478d..d1d8d135e 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitGetBlocks.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitGetBlocks.java @@ -24,10 +24,10 @@ import net.minecraft.server.v1_13_R2.World; import static com.boydti.fawe.bukkit.v0.BukkitQueue_0.getAdapter; public class BukkitGetBlocks extends CharGetBlocks { - private ChunkSection[] sections; - private Chunk nmsChunk; - private World nmsWorld; - private int X, Z; + public ChunkSection[] sections; + public Chunk nmsChunk; + public World nmsWorld; + public int X, Z; public BukkitGetBlocks(World nmsWorld, int X, int Z) {/*d*/ this.nmsWorld = nmsWorld; @@ -48,12 +48,12 @@ public class BukkitGetBlocks extends CharGetBlocks { } @Override - protected char[] load(int layer) { + public char[] load(int layer) { return load(layer, null); } @Override - protected char[] load(int layer, char[] data) { + public char[] load(int layer, char[] data) { ChunkSection section = getSections()[layer]; // Section is null, return empty array if (section == null) { @@ -136,7 +136,7 @@ public class BukkitGetBlocks extends CharGetBlocks { return data; } - private ChunkSection[] getSections() { + public ChunkSection[] getSections() { ChunkSection[] tmp = sections; if (tmp == null) { Chunk chunk = getChunk(); @@ -145,16 +145,10 @@ public class BukkitGetBlocks extends CharGetBlocks { return tmp; } - private Chunk getChunk() { + public Chunk getChunk() { Chunk tmp = nmsChunk; if (tmp == null) { - ChunkProviderServer provider = (ChunkProviderServer) nmsWorld.getChunkProvider(); - nmsChunk = tmp = provider.chunks.get(ChunkCoordIntPair.a(X, Z)); - if (tmp == null) { - System.out.println("SYNC"); - // TOOD load with paper - nmsChunk = tmp = TaskManager.IMP.sync(() -> nmsWorld.getChunkAt(X, Z)); - } + nmsChunk = tmp = BukkitQueue.ensureLoaded(nmsWorld, X, Z); } return tmp; } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueue.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueue.java index 616f84c99..5c869bc29 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueue.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueue.java @@ -1,16 +1,43 @@ package com.boydti.fawe.bukkit.beta; +import com.boydti.fawe.Fawe; +import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.implementation.SimpleCharQueueExtent; import com.boydti.fawe.beta.implementation.SingleThreadQueueExtent; import com.boydti.fawe.beta.implementation.WorldChunkCache; +import com.boydti.fawe.bukkit.adapter.v1_13_1.BlockMaterial_1_13; +import com.boydti.fawe.config.Settings; +import com.boydti.fawe.jnbt.anvil.BitArray4096; import com.boydti.fawe.object.collection.IterableThreadLocal; +import com.boydti.fawe.util.MathMan; +import com.boydti.fawe.util.TaskManager; import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.world.World; +import com.sk89q.worldedit.world.block.BlockID; +import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.block.BlockTypes; +import net.minecraft.server.v1_13_R2.Block; +import net.minecraft.server.v1_13_R2.Chunk; +import net.minecraft.server.v1_13_R2.ChunkCoordIntPair; +import net.minecraft.server.v1_13_R2.ChunkProviderServer; +import net.minecraft.server.v1_13_R2.ChunkSection; +import net.minecraft.server.v1_13_R2.DataBits; +import net.minecraft.server.v1_13_R2.DataPalette; +import net.minecraft.server.v1_13_R2.DataPaletteBlock; +import net.minecraft.server.v1_13_R2.DataPaletteLinear; +import net.minecraft.server.v1_13_R2.GameProfileSerializer; +import net.minecraft.server.v1_13_R2.IBlockData; import net.minecraft.server.v1_13_R2.WorldServer; import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_13_R2.CraftChunk; import org.bukkit.craftbukkit.v1_13_R2.CraftWorld; +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + import static com.google.common.base.Preconditions.checkNotNull; public class BukkitQueue extends SimpleCharQueueExtent { @@ -45,19 +72,177 @@ public class BukkitQueue extends SimpleCharQueueExtent { super.reset(); } - private static final IterableThreadLocal FULL_CHUNKS = new IterableThreadLocal() { - @Override - public BukkitFullChunk init() { - return new BukkitFullChunk(); - } - }; +// private static final IterableThreadLocal FULL_CHUNKS = new IterableThreadLocal() { +// @Override +// public BukkitFullChunk init() { +// return new BukkitFullChunk(); +// } +// }; @Override public IChunk create(boolean full) { - if (full) { - // TODO implement +// if (full) { +// //TODO implement // return FULL_CHUNKS.get(); - } +// } return new BukkitChunkHolder(); } + + /* + NMS fields + */ + public final static Field fieldBits; + public final static Field fieldPalette; + public final static Field fieldSize; + + public final static Field fieldFluidCount; + public final static Field fieldTickingBlockCount; + public final static Field fieldNonEmptyBlockCount; + + static { + try { + fieldSize = DataPaletteBlock.class.getDeclaredField("i"); + fieldSize.setAccessible(true); + fieldBits = DataPaletteBlock.class.getDeclaredField("a"); + fieldBits.setAccessible(true); + fieldPalette = DataPaletteBlock.class.getDeclaredField("h"); + fieldPalette.setAccessible(true); + + fieldFluidCount = ChunkSection.class.getDeclaredField("e"); + fieldFluidCount.setAccessible(true); + fieldTickingBlockCount = ChunkSection.class.getDeclaredField("tickingBlockCount"); + fieldTickingBlockCount.setAccessible(true); + fieldNonEmptyBlockCount = ChunkSection.class.getDeclaredField("nonEmptyBlockCount"); + fieldNonEmptyBlockCount.setAccessible(true); + } catch (RuntimeException e) { + throw e; + } catch (Throwable rethrow) { + rethrow.printStackTrace(); + throw new RuntimeException(rethrow); + } + } + + private static boolean PAPER = true; + + public Chunk ensureLoaded(int X, int Z) { + return ensureLoaded(nmsWorld, X, Z); + } + + public static Chunk ensureLoaded(net.minecraft.server.v1_13_R2.World nmsWorld, int X, int Z) { + ChunkProviderServer provider = (ChunkProviderServer) nmsWorld.getChunkProvider(); + Chunk nmsChunk = provider.chunks.get(ChunkCoordIntPair.a(X, Z)); + if (nmsChunk != null) { + return nmsChunk; + } + if (Fawe.isMainThread()) { + return nmsWorld.getChunkAt(X, Z); + } + if (PAPER) { + CraftWorld craftWorld = nmsWorld.getWorld(); + CompletableFuture future = craftWorld.getChunkAtAsync(X, Z, true); + try { + CraftChunk chunk = (CraftChunk) future.get(); + return chunk.getHandle(); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (ExecutionException e) { + e.printStackTrace(); + } catch (Throwable e) { + System.out.println("Error, cannot load chunk async (paper not installed?)"); + PAPER = false; + } + } + // TODO optimize + return TaskManager.IMP.sync(() -> nmsWorld.getChunkAt(X, Z)); + } + + /* + NMS conversion + */ + + public static ChunkSection newChunkSection(final int y2, final boolean flag, final char[] blocks) { + ChunkSection section = new ChunkSection(y2 << 4, flag); + if (blocks == null) { + return section; + } + final int[] blockToPalette = FaweCache.BLOCK_TO_PALETTE.get(); + final int[] paletteToBlock = FaweCache.PALETTE_TO_BLOCK.get(); + final long[] blockstates = FaweCache.BLOCK_STATES.get(); + final int[] blocksCopy = FaweCache.SECTION_BLOCKS.get(); + try { + int num_palette = 0; + int air = 0; + for (int i = 0; i < 4096; i++) { + char ordinal = blocks[i]; + switch (ordinal) { + case 0: + case BlockID.AIR: + case BlockID.CAVE_AIR: + case BlockID.VOID_AIR: + air++; + } + int palette = blockToPalette[ordinal]; + if (palette == Integer.MAX_VALUE) { + blockToPalette[ordinal] = palette = num_palette; + paletteToBlock[num_palette] = ordinal; + num_palette++; + } + blocksCopy[i] = palette; + } + + // BlockStates + int bitsPerEntry = MathMan.log2nlz(num_palette - 1); + if (Settings.IMP.PROTOCOL_SUPPORT_FIX || num_palette != 1) { + bitsPerEntry = Math.max(bitsPerEntry, 4); // Protocol support breaks <4 bits per entry + } else { + bitsPerEntry = Math.max(bitsPerEntry, 1); // For some reason minecraft needs 4096 bits to store 0 entries + } + + final int blockBitArrayEnd = (bitsPerEntry * 4096) >> 6; + if (num_palette == 1) { + for (int i = 0; i < blockBitArrayEnd; i++) blockstates[i] = 0; + } else { + final BitArray4096 bitArray = new BitArray4096(blockstates, bitsPerEntry); + bitArray.fromRaw(blocksCopy); + } + + // set palette & data bits + final DataPaletteBlock dataPaletteBlocks = section.getBlocks(); + // private DataPalette h; + // protected DataBits a; + final long[] bits = Arrays.copyOfRange(blockstates, 0, blockBitArrayEnd); + final DataBits nmsBits = new DataBits(bitsPerEntry, 4096, bits); + final DataPalette palette; +// palette = new DataPaletteHash<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d, GameProfileSerializer::a); + palette = new DataPaletteLinear<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d); + + // set palette + for (int i = 0; i < num_palette; i++) { + final int ordinal = paletteToBlock[i]; + blockToPalette[ordinal] = Integer.MAX_VALUE; + final BlockState state = BlockTypes.states[ordinal]; + final IBlockData ibd = ((BlockMaterial_1_13) state.getMaterial()).getState(); + palette.a(ibd); + } + try { + fieldBits.set(dataPaletteBlocks, nmsBits); + fieldPalette.set(dataPaletteBlocks, palette); + fieldSize.set(dataPaletteBlocks, bitsPerEntry); + setCount(0, 4096 - air, section); + } catch (final IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + + return section; + } catch (final Throwable e){ + Arrays.fill(blockToPalette, Integer.MAX_VALUE); + throw e; + } + } + + public static void setCount(final int tickingBlockCount, final int nonEmptyBlockCount, final ChunkSection section) throws NoSuchFieldException, IllegalAccessException { + fieldFluidCount.set(section, 0); // TODO FIXME + fieldTickingBlockCount.set(section, tickingBlockCount); + fieldNonEmptyBlockCount.set(section, nonEmptyBlockCount); + } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/DelegateLock.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/DelegateLock.java new file mode 100644 index 000000000..59bfccd3b --- /dev/null +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/DelegateLock.java @@ -0,0 +1,78 @@ +package com.boydti.fawe.bukkit.beta; + +import java.util.Collection; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.Condition; +import java.util.concurrent.locks.ReentrantLock; + +public class DelegateLock extends ReentrantLock { + private final ReentrantLock parent; + private volatile boolean modified; + + public DelegateLock(ReentrantLock parent) { + this.parent = parent; + } + + @Override + public void lock() { + modified = true; + parent.lock(); + } + + @Override + public synchronized void lockInterruptibly() throws InterruptedException { + parent.lockInterruptibly(); + } + + @Override + public synchronized boolean tryLock() { + return parent.tryLock(); + } + + @Override + public synchronized boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException { + return parent.tryLock(timeout, unit); + } + + @Override + public synchronized void unlock() { + modified = true; + parent.unlock(); + this.notifyAll(); + } + + @Override + public synchronized Condition newCondition() { + return parent.newCondition(); + } + + @Override + public synchronized int getHoldCount() { + return parent.getHoldCount(); + } + + @Override + public synchronized boolean isHeldByCurrentThread() { + return parent.isHeldByCurrentThread(); + } + + @Override + public synchronized boolean isLocked() { + return parent.isLocked(); + } + + @Override + public synchronized boolean hasWaiters(Condition condition) { + return parent.hasWaiters(condition); + } + + @Override + public synchronized int getWaitQueueLength(Condition condition) { + return parent.getWaitQueueLength(condition); + } + + @Override + public synchronized String toString() { + return parent.toString(); + } +} diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java index 8f0f188b6..0f86e37c7 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java @@ -70,7 +70,6 @@ public class BukkitQueue_1_13 extends BukkitQueue_0> 6; - if (num_palette == 1) { - for (int i = 0; i < blockBitArrayEnd; i++) blockstates[i] = 0; - } else { - final BitArray4096 bitArray = new BitArray4096(blockstates, bitsPerEntry); - bitArray.fromRaw(blocksCopy); - } - - // set palette & data bits - final DataPaletteBlock dataPaletteBlocks = section.getBlocks(); - // private DataPalette h; - // protected DataBits a; - final long[] bits = Arrays.copyOfRange(blockstates, 0, blockBitArrayEnd); - final DataBits nmsBits = new DataBits(bitsPerEntry, 4096, bits); - final DataPalette palette; -// palette = new DataPaletteHash<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d, GameProfileSerializer::a); - palette = new DataPaletteLinear<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d); - - // set palette - for (int i = 0; i < num_palette; i++) { - final int ordinal = paletteToBlock[i]; - blockToPalette[ordinal] = Integer.MAX_VALUE; - final BlockState state = BlockTypes.states[ordinal]; - final IBlockData ibd = ((BlockMaterial_1_13) state.getMaterial()).getState(); - palette.a(ibd); - } - try { - fieldBits.set(dataPaletteBlocks, nmsBits); - fieldPalette.set(dataPaletteBlocks, palette); - fieldSize.set(dataPaletteBlocks, bitsPerEntry); - setCount(0, 4096 - air, section); - } catch (final IllegalAccessException | NoSuchFieldException e) { - throw new RuntimeException(e); - } - - return section; - } catch (final Throwable e){ - Arrays.fill(blockToPalette, Integer.MAX_VALUE); - throw e; + blocksCopy[i] = palette; } + + // BlockStates + int bitsPerEntry = MathMan.log2nlz(num_palette - 1); + if (Settings.IMP.PROTOCOL_SUPPORT_FIX || num_palette != 1) { + bitsPerEntry = Math.max(bitsPerEntry, 4); // Protocol support breaks <4 bits per entry + } else { + bitsPerEntry = Math.max(bitsPerEntry, 1); // For some reason minecraft needs 4096 bits to store 0 entries + } + + final int blockBitArrayEnd = (bitsPerEntry * 4096) >> 6; + if (num_palette == 1) { + for (int i = 0; i < blockBitArrayEnd; i++) blockstates[i] = 0; + } else { + final BitArray4096 bitArray = new BitArray4096(blockstates, bitsPerEntry); + bitArray.fromRaw(blocksCopy); + } + + // set palette & data bits + final DataPaletteBlock dataPaletteBlocks = section.getBlocks(); + // private DataPalette h; + // protected DataBits a; + final long[] bits = Arrays.copyOfRange(blockstates, 0, blockBitArrayEnd); + final DataBits nmsBits = new DataBits(bitsPerEntry, 4096, bits); + final DataPalette palette; +// palette = new DataPaletteHash<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d, GameProfileSerializer::a); + palette = new DataPaletteLinear<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d); + + // set palette + for (int i = 0; i < num_palette; i++) { + final int ordinal = paletteToBlock[i]; + blockToPalette[ordinal] = Integer.MAX_VALUE; + final BlockState state = BlockTypes.states[ordinal]; + final IBlockData ibd = ((BlockMaterial_1_13) state.getMaterial()).getState(); + palette.a(ibd); + } + try { + fieldBits.set(dataPaletteBlocks, nmsBits); + fieldPalette.set(dataPaletteBlocks, palette); + fieldSize.set(dataPaletteBlocks, bitsPerEntry); + setCount(0, 4096 - air, section); + } catch (final IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + + return section; + } catch (final Throwable e){ + Arrays.fill(blockToPalette, Integer.MAX_VALUE); + throw e; } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java index 6b4820e0c..7dba8eb3e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java @@ -1,6 +1,7 @@ package com.boydti.fawe; import com.boydti.fawe.beta.Trimable; +import com.boydti.fawe.config.Settings; import com.boydti.fawe.jnbt.anvil.BitArray4096; import com.boydti.fawe.object.collection.IterableThreadLocal; import com.boydti.fawe.util.MathMan; @@ -11,6 +12,12 @@ import com.sk89q.worldedit.world.block.BlockTypes; import java.lang.reflect.Field; import java.util.*; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; public class FaweCache implements Trimable { public static final char[] EMPTY_CHAR_4096 = new char[4096]; @@ -326,4 +333,16 @@ public class FaweCache implements Trimable { if (clazz == null) clazz = EndTag.class; return new ListTag(clazz, list); } + + /* + Thread stuff + */ + public static ThreadPoolExecutor newBlockingExecutor() { + int nThreads = Settings.IMP.QUEUE.PARALLEL_THREADS; + ArrayBlockingQueue queue = new ArrayBlockingQueue<>(nThreads); + return new ThreadPoolExecutor(nThreads, nThreads, + 0L, TimeUnit.MILLISECONDS, queue + , Executors.defaultThreadFactory(), + new ThreadPoolExecutor.CallerRunsPolicy()); + } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/CharFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/CharFilterBlock.java index b0f8ac231..1d9809d42 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/CharFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/CharFilterBlock.java @@ -13,12 +13,12 @@ public class CharFilterBlock implements FilterBlock { private char[] section; @Override - public void init(IQueueExtent queue) { + public final void init(IQueueExtent queue) { this.queue = queue; } @Override - public void init(int X, int Z, IGetBlocks chunk) { + public final void init(int X, int Z, IGetBlocks chunk) { this.chunk = (CharGetBlocks) chunk; this.X = X; this.Z = Z; @@ -26,68 +26,85 @@ public class CharFilterBlock implements FilterBlock { this.zz = Z << 4; } - public void init(char[] section, int layer) { - this.section = section; - this.layer = layer; - this.yy = layer << 4; + // local + private int layer, index, x, y, z, xx, yy, zz, X, Z; + + public final void filter(CharGetBlocks blocks, Filter filter) { + for (int layer = 0; layer < 16; layer++) { + if (!blocks.hasSection(layer)) continue; + char[] arr = blocks.sections[layer].get(blocks, layer); + + this.section = arr; + this.layer = layer; + this.yy = layer << 4; + + for (y = 0, index = 0; y < 16; y++) { + for (z = 0; z < 16; z++) { + for (x = 0; x < 16; x++, index++) { + filter.applyBlock(this); + } + } + } + } } - // local - public int layer, index, x, y, z, xx, yy, zz, X, Z; - @Override - public int getX() { + public final int getX() { return xx + x; } @Override - public int getY() { + public final int getY() { return yy + y; } @Override - public int getZ() { + public final int getZ() { return zz + z; } @Override - public int getLocalX() { + public final int getLocalX() { return x; } @Override - public int getLocalY() { + public final int getLocalY() { return y; } @Override - public int getLocalZ() { + public final int getLocalZ() { return z; } @Override - public int getChunkX() { + public final int getChunkX() { return X; } @Override - public int getChunkZ() { + public final int getChunkZ() { return Z; } - @Override - public int getOrdinal() { + public final char getOrdinalChar() { return section[index]; } @Override - public BlockState getState() { + public final int getOrdinal() { + return section[index]; + } + + @Override + public final BlockState getState() { int ordinal = section[index]; return BlockTypes.states[ordinal]; } @Override - public BaseBlock getBaseBlock() { + public final BaseBlock getBaseBlock() { BlockState state = getState(); BlockMaterial material = state.getMaterial(); if (material.hasContainer()) { @@ -98,11 +115,11 @@ public class CharFilterBlock implements FilterBlock { } @Override - public CompoundTag getTag() { + public final CompoundTag getTag() { return null; } - public BlockState getOrdinalBelow() { + public final BlockState getOrdinalBelow() { if (y > 0) { return states[section[index - 256]]; } @@ -114,7 +131,7 @@ public class CharFilterBlock implements FilterBlock { return BlockTypes.__RESERVED__.getDefaultState(); } - public BlockState getStateAbove() { + public final BlockState getStateAbove() { if (y < 16) { return states[section[index + 256]]; } @@ -126,7 +143,7 @@ public class CharFilterBlock implements FilterBlock { return BlockTypes.__RESERVED__.getDefaultState(); } - public BlockState getStateRelativeY(int y) { + public final BlockState getStateRelativeY(int y) { int newY = this.y + y; int layerAdd = newY >> 4; switch (layerAdd) { @@ -180,7 +197,7 @@ public class CharFilterBlock implements FilterBlock { return BlockTypes.__RESERVED__.getDefaultState(); } - public BlockState getStateRelative(final int x, final int y, final int z) { + public final BlockState getStateRelative(final int x, final int y, final int z) { int newX = this.x + x; if (newX >> 4 == 0) { int newZ = this.z + z; @@ -189,7 +206,7 @@ public class CharFilterBlock implements FilterBlock { int layerAdd = newY >> 4; switch (layerAdd) { case 0: - return states[section[this.index + ((y << 8) | (z << 4) | x)]]; + return states[section[this.index + ((y << 8) + (z << 4) + x)]]; case 1: case 2: case 3: @@ -207,7 +224,7 @@ public class CharFilterBlock implements FilterBlock { case 15: { int newLayer = layer + layerAdd; if (newLayer < 16) { - int index = this.index + (((y & 15) << 8) | (z << 4) | x); + int index = ((newY & 15) << 8) + (newZ << 4) + newX; return states[chunk.sections[newLayer].get(chunk, newLayer, index)]; } break; @@ -229,7 +246,7 @@ public class CharFilterBlock implements FilterBlock { case -15: { int newLayer = layer + layerAdd; if (newLayer >= 0) { - int index = this.index + (((y & 15) << 8) | (z << 4) | x); + int index = ((newY & 15) << 8) + (newZ << 4) + newX; return states[chunk.sections[newLayer].get(chunk, newLayer, index)]; } break; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java index dcd9fbf6c..eb6afbd84 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java @@ -5,11 +5,16 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.function.Supplier; + /** * Represents a chunk in the queue {@link IQueueExtent} * Used for getting and setting blocks / biomes / entities */ -public interface IChunk extends Trimable { +public interface IChunk> extends Trimable, Callable { /** * Initialize at the location * @param extent @@ -22,6 +27,8 @@ public interface IChunk extends Trimable { int getZ(); + + /** * If the chunk is a delegate, returns it's paren'ts root * @return root IChunk @@ -36,16 +43,33 @@ public interface IChunk extends Trimable { boolean isEmpty(); /** - * Apply the queued async changes to the world - * @return false if applySync needs to run + * Spend time optimizing for apply
+ * default behavior: do nothing */ - boolean applyAsync(); + default void optimize() { + + } /** - * Apply the queued sync changes to the world - * @return true + * Apply the queued changes to the world
+ * The future returned may return another future
+ * To ensure completion keep calling {@link Future#get()} on each result + * @return Futures */ - boolean applySync(); + T call(); + + /** + * Call and join + * @throws ExecutionException + * @throws InterruptedException + */ + default void join() throws ExecutionException, InterruptedException { + T future = call(); + while (future != null) { + future = future.get(); + } + return; + } /* set - queues a change */ boolean setBiome(int x, int y, int z, BiomeType biome); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java index 62786336f..1cb14e2af 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java @@ -5,6 +5,9 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; + /** * Delegate for IChunk * @param parent class @@ -67,13 +70,13 @@ public interface IDelegateChunk extends IChunk { } @Override - default boolean applySync() { - return getParent().applySync(); + default Future call() { + return getParent().call(); } @Override - default boolean applyAsync() { - return getParent().applyAsync(); + default void join() throws ExecutionException, InterruptedException { + getParent().join(); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IGetBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IGetBlocks.java index bdddaff22..b49a8bb79 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IGetBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IGetBlocks.java @@ -21,4 +21,8 @@ public interface IGetBlocks extends IBlocks, Trimable { boolean trim(boolean aggressive); void filter(Filter filter, FilterBlock block); + + default void optimize() { + + } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java index 4e6c35a01..7725810e5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java @@ -34,7 +34,7 @@ public interface IQueueExtent extends Flushable, Trimable { * @param chunk * @return result */ - Future submit(IChunk chunk); + > T submit(IChunk chunk); default boolean setBlock(final int x, final int y, final int z, final BlockStateHolder state) { final IChunk chunk = getCachedChunk(x >> 4, z >> 4); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/ISetBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/ISetBlocks.java index f06a4fd6d..f7dfd1bd8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/ISetBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/ISetBlocks.java @@ -12,4 +12,8 @@ public interface ISetBlocks extends IBlocks { boolean setBlock(int x, int y, int z, BlockStateHolder holder); boolean isEmpty(); + + default void optimize() { + + } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java index a78bfddc9..972a2cd15 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java @@ -1,6 +1,6 @@ package com.boydti.fawe.beta.implementation; -import com.boydti.fawe.Fawe; +import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.FilterBlock; import com.boydti.fawe.beta.IChunk; @@ -8,9 +8,9 @@ import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.Trimable; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.collection.IterableThreadLocal; -import com.boydti.fawe.util.MathMan; -import com.boydti.fawe.util.TaskManager; +import com.boydti.fawe.util.MemUtil; import com.boydti.fawe.wrappers.WorldWrapper; +import com.google.common.util.concurrent.Futures; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.World; @@ -20,32 +20,36 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.ExecutorService; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ForkJoinTask; import java.util.concurrent.Future; +import java.util.concurrent.ThreadPoolExecutor; /** * Class which handles all the queues {@link IQueueExtent} */ public abstract class QueueHandler implements Trimable { - private Map> chunkCache = new HashMap<>(); + private ForkJoinPool forkJoinPoolPrimary = new ForkJoinPool(); + private ForkJoinPool forkJoinPoolSecondary = new ForkJoinPool(); + private ThreadPoolExecutor blockingExecutor = FaweCache.newBlockingExecutor(); + private ConcurrentLinkedQueue syncTasks = new ConcurrentLinkedQueue(); - private IterableThreadLocal pool = new IterableThreadLocal() { + private Map> chunkCache = new HashMap<>(); + private IterableThreadLocal queuePool = new IterableThreadLocal() { @Override public IQueueExtent init() { return create(); } }; - public Future submit(IChunk chunk) { - if (Fawe.isMainThread()) { - if (!chunk.applyAsync()) { - chunk.applySync(); - } - return null; + public > T submit(IChunk chunk) { + if (MemUtil.isMemoryFree()) { +// return (T) forkJoinPoolSecondary.submit(chunk); } - // TODO return future - return null; + return (T) blockingExecutor.submit(chunk); + } /** @@ -73,7 +77,7 @@ public abstract class QueueHandler implements Trimable { public abstract IQueueExtent create(); public IQueueExtent getQueue(World world) { - IQueueExtent queue = pool.get(); + IQueueExtent queue = queuePool.get(); queue.init(getOrCreate(world)); return queue; } @@ -103,62 +107,63 @@ public abstract class QueueHandler implements Trimable { final Iterator chunksIter = chunks.iterator(); // Get a pool, to operate on the chunks in parallel - final ForkJoinPool pool = TaskManager.IMP.getPublicForkJoinPool(); final int size = Math.min(chunks.size(), Settings.IMP.QUEUE.PARALLEL_THREADS); - final ForkJoinTask[] tasks = new ForkJoinTask[size]; - + ForkJoinTask[] tasks = new ForkJoinTask[size]; for (int i = 0; i < size; i++) { - tasks[i] = pool.submit(new Runnable() { + tasks[i] = forkJoinPoolPrimary.submit(new Runnable() { @Override public void run() { Filter newFilter = filter.fork(); // Create a chunk that we will reuse/reset for each operation IQueueExtent queue = getQueue(world); - FilterBlock block = null; + synchronized (queue) { + FilterBlock block = null; - while (true) { - // Get the next chunk pos - final BlockVector2 pos; - synchronized (chunksIter) { - if (!chunksIter.hasNext()) return; - pos = chunksIter.next(); - } - final int X = pos.getX(); - final int Z = pos.getZ(); - // TODO create full - IChunk chunk = queue.getCachedChunk(X, Z); - // Initialize - chunk.init(queue, X, Z); - try { - if (!newFilter.appliesChunk(X, Z)) { - continue; + while (true) { + // Get the next chunk pos + final BlockVector2 pos; + synchronized (chunksIter) { + if (!chunksIter.hasNext()) break; + pos = chunksIter.next(); } - chunk = newFilter.applyChunk(chunk); + final int X = pos.getX(); + final int Z = pos.getZ(); + IChunk chunk = queue.getCachedChunk(X, Z); + // Initialize + chunk.init(queue, X, Z); + try { + if (!newFilter.appliesChunk(X, Z)) { + continue; + } + chunk = newFilter.applyChunk(chunk); - if (chunk == null) continue; + if (chunk == null) continue; - if (block == null) block = queue.initFilterBlock(); - chunk.filter(newFilter, block); + if (block == null) block = queue.initFilterBlock(); + chunk.filter(newFilter, block); - newFilter.finishChunk(chunk); + newFilter.finishChunk(chunk); - queue.submit(chunk); - } finally - { - if (filter != newFilter) { - synchronized (filter) { - newFilter.join(filter); + queue.submit(chunk); + } finally { + if (filter != newFilter) { + synchronized (filter) { + newFilter.join(filter); + } } } } + queue.flush(); } } }); } - - // Join the tasks - for (final ForkJoinTask task : tasks) { - task.join(); + // Join filters + for (int i = 0; i < tasks.length; i++) { + ForkJoinTask task = tasks[i]; + if (task != null) { + task.quietlyJoin(); + } } } } \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java index 1e0809a75..9da4c0f3e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java @@ -5,17 +5,12 @@ import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.implementation.holder.ReferenceChunk; import com.boydti.fawe.config.Settings; -import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MemUtil; -import com.boydti.fawe.util.SetQueue; -import com.boydti.fawe.util.TaskManager; +import com.google.common.util.concurrent.Futures; import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; -import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ExecutionException; -import java.util.concurrent.ForkJoinPool; -import java.util.concurrent.ForkJoinTask; import java.util.concurrent.Future; import static com.google.common.base.Preconditions.checkNotNull; @@ -29,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull; public abstract class SingleThreadQueueExtent implements IQueueExtent { private WorldChunkCache cache; private Thread currentThread; + private ConcurrentLinkedQueue submissions = new ConcurrentLinkedQueue<>(); /** * Safety check to ensure that the thread being used matches the one being initialized on @@ -66,7 +62,7 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { */ @Override public synchronized void init(final WorldChunkCache cache) { - if (cache != null) { + if (this.cache != null) { reset(); } currentThread = Thread.currentThread(); @@ -83,19 +79,17 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { private static final ConcurrentLinkedQueue CHUNK_POOL = new ConcurrentLinkedQueue<>(); @Override - public Future submit(final IChunk chunk) { + public > T submit(final IChunk chunk) { if (chunk.isEmpty()) { CHUNK_POOL.add(chunk); - return null; + return (T) (Future) Futures.immediateFuture(null); } + if (Fawe.isMainThread()) { - if (!chunk.applyAsync()) { - chunk.applySync(); - } - return null; + return chunk.call(); } - QueueHandler handler = Fawe.get().getQueueHandler(); - return handler.submit(chunk); + + return Fawe.get().getQueueHandler().submit(chunk); } @Override @@ -107,6 +101,13 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { lastPair = Long.MAX_VALUE; return chunks.isEmpty(); } + if (!submissions.isEmpty()) { + if (aggressive) { + pollSubmissions(0, aggressive); + } else { + pollSubmissions(Settings.IMP.QUEUE.PARALLEL_THREADS, aggressive); + } + } synchronized (this) { return currentThread == null; } @@ -121,7 +122,10 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { */ private IChunk poolOrCreate(final int X, final int Z) { IChunk next = CHUNK_POOL.poll(); - if (next == null) next = create(false); + if (next == null) { + System.out.println("Create"); + next = create(false); + } next.init(this, X, Z); return next; } @@ -145,10 +149,19 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { checkThread(); final int size = chunks.size(); - if (size > Settings.IMP.QUEUE.TARGET_SIZE || MemUtil.isMemoryLimited()) { - if (size > Settings.IMP.QUEUE.PARALLEL_THREADS * 2 + 16) { - chunk = chunks.removeFirst(); - submit(chunk); + boolean lowMem = MemUtil.isMemoryLimited(); + if (lowMem || size > Settings.IMP.QUEUE.TARGET_SIZE) { + chunk = chunks.removeFirst(); + Future future = submit(chunk); + if (future != null && !future.isDone()) { + int targetSize; + if (lowMem) { + targetSize = Settings.IMP.QUEUE.PARALLEL_THREADS; + } else { + targetSize = Settings.IMP.QUEUE.TARGET_SIZE; + } + pollSubmissions(targetSize, true); + submissions.add(future); } } chunk = poolOrCreate(X, Z); @@ -161,27 +174,59 @@ public abstract class SingleThreadQueueExtent implements IQueueExtent { return chunk; } + private void pollSubmissions(int targetSize, boolean aggressive) { + int overflow = submissions.size() - targetSize; + if (aggressive) { + for (int i = 0; i < overflow; i++) { + Future first = submissions.poll(); + try { + while ((first = (Future) first.get()) != null) ; + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + } else { + for (int i = 0; i < overflow; i++) { + Future next = submissions.peek(); + while (next != null) { + if (next.isDone()) { + try { + next = (Future) next.get(); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } else { + return; + } + } + submissions.poll(); + } + } + } + @Override public synchronized void flush() { checkThread(); if (!chunks.isEmpty()) { - final Future[] tasks = new ForkJoinTask[chunks.size()]; - int i = 0; - for (final IChunk chunk : chunks.values()) { - tasks[i++] = submit(chunk); - } - chunks.clear(); - for (final Future task : tasks) { - if (task != null) { - try { - task.get(); - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - throw new RuntimeException(e); + if (MemUtil.isMemoryLimited()) { + for (IChunk chunk : chunks.values()) { + Future future = submit(chunk); + if (future != null && !future.isDone()) { + pollSubmissions(Settings.IMP.QUEUE.PARALLEL_THREADS, true); + submissions.add(future); + } + } + } else { + for (final IChunk chunk : chunks.values()) { + Future future = submit(chunk); + if (future != null && !future.isDone()) { + submissions.add(future); } } } + chunks.clear(); } + pollSubmissions(0, true); reset(); } } \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java index 1bed28997..fede5719c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java @@ -22,18 +22,7 @@ public abstract class CharGetBlocks extends CharBlocks implements IGetBlocks { @Override public void filter(Filter filter, FilterBlock block) { CharFilterBlock b = (CharFilterBlock) block; - for (int layer = 0; layer < 16; layer++) { - if (!hasSection(layer)) continue; - char[] arr = sections[layer].get(this, layer); - b.init(arr, layer); - for (b.y = 0, b.index = 0; b.y < 16; b.y++) { - for (b.z = 0; b.z < 16; b.z++) { - for (b.x = 0; b.x < 16; b.x++, b.index++) { - filter.applyBlock(b); - } - } - } - } + b.filter(this, filter); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java index efed7128a..7ff757113 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java @@ -1,10 +1,8 @@ package com.boydti.fawe.beta.implementation.holder; -import com.boydti.fawe.beta.CharFilterBlock; import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.FilterBlock; import com.boydti.fawe.beta.IQueueExtent; -import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks; import com.boydti.fawe.beta.implementation.blocks.CharSetBlocks; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IGetBlocks; @@ -22,7 +20,7 @@ import java.util.function.Supplier; /** * Abstract IChunk class that implements basic get/set blocks */ -public abstract class ChunkHolder implements IChunk, Supplier { +public abstract class ChunkHolder implements IChunk, Supplier { private IGetBlocks get; private ISetBlocks set; private IBlockDelegate delegate; @@ -40,7 +38,7 @@ public abstract class ChunkHolder implements IChunk, Supplier { @Override public void filter(Filter filter, FilterBlock block) { block.init(X, Z, get); - IGetBlocks get = cachedGet(); + IGetBlocks get = getOrCreateGet(); get.filter(filter, block); } @@ -73,12 +71,12 @@ public abstract class ChunkHolder implements IChunk, Supplier { return set == null || set.isEmpty(); } - public final IGetBlocks cachedGet() { + public final IGetBlocks getOrCreateGet() { if (get == null) get = newGet(); return get; } - public final ISetBlocks cachedSet() { + public final ISetBlocks getOrCreateSet() { if (set == null) set = set(); return set; } @@ -95,6 +93,13 @@ public abstract class ChunkHolder implements IChunk, Supplier { return get(); } + @Override + public void optimize() { + if (set != null) { + set.optimize(); + } + } + @Override public void init(IQueueExtent extent, final int X, final int Z) { this.extent = extent; @@ -163,35 +168,35 @@ public abstract class ChunkHolder implements IChunk, Supplier { public static final IBlockDelegate NULL = new IBlockDelegate() { @Override public boolean setBiome(final ChunkHolder chunk, final int x, final int y, final int z, final BiomeType biome) { - chunk.cachedSet(); + chunk.getOrCreateSet(); chunk.delegate = SET; return chunk.setBiome(x, y, z, biome); } @Override public boolean setBlock(final ChunkHolder chunk, final int x, final int y, final int z, final BlockStateHolder block) { - chunk.cachedSet(); + chunk.getOrCreateSet(); chunk.delegate = SET; return chunk.setBlock(x, y, z, block); } @Override public BiomeType getBiome(final ChunkHolder chunk, final int x, final int z) { - chunk.cachedGet(); + chunk.getOrCreateGet(); chunk.delegate = GET; return chunk.getBiome(x, z); } @Override public BlockState getBlock(final ChunkHolder chunk, final int x, final int y, final int z) { - chunk.cachedGet(); + chunk.getOrCreateGet(); chunk.delegate = GET; return chunk.getBlock(x, y, z); } @Override public BaseBlock getFullBlock(final ChunkHolder chunk, final int x, final int y, final int z) { - chunk.cachedGet(); + chunk.getOrCreateGet(); chunk.delegate = GET; return chunk.getFullBlock(x, y, z); } @@ -200,14 +205,14 @@ public abstract class ChunkHolder implements IChunk, Supplier { public static final IBlockDelegate GET = new IBlockDelegate() { @Override public boolean setBiome(final ChunkHolder chunk, final int x, final int y, final int z, final BiomeType biome) { - chunk.cachedSet(); + chunk.getOrCreateSet(); chunk.delegate = BOTH; return chunk.setBiome(x, y, z, biome); } @Override public boolean setBlock(final ChunkHolder chunk, final int x, final int y, final int z, final BlockStateHolder block) { - chunk.cachedSet(); + chunk.getOrCreateSet(); chunk.delegate = BOTH; return chunk.setBlock(x, y, z, block); } @@ -241,21 +246,21 @@ public abstract class ChunkHolder implements IChunk, Supplier { @Override public BiomeType getBiome(final ChunkHolder chunk, final int x, final int z) { - chunk.cachedGet(); + chunk.getOrCreateGet(); chunk.delegate = BOTH; return chunk.getBiome(x, z); } @Override public BlockState getBlock(final ChunkHolder chunk, final int x, final int y, final int z) { - chunk.cachedGet(); + chunk.getOrCreateGet(); chunk.delegate = BOTH; return chunk.getBlock(x, y, z); } @Override public BaseBlock getFullBlock(final ChunkHolder chunk, final int x, final int y, final int z) { - chunk.cachedGet(); + chunk.getOrCreateGet(); chunk.delegate = BOTH; return chunk.getFullBlock(x, y, z); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index 3fefa6ab9..695c730fb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -281,7 +281,10 @@ public class RegionCommands extends MethodCommands { QueueHandler queueHandler = Fawe.get().getQueueHandler(); World world = player.getWorld(); CountFilter filter = new CountFilter(); + long start = System.currentTimeMillis(); queueHandler.apply(world, region, filter); + long diff = System.currentTimeMillis() - start; + System.out.println(diff); } @Command( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockID.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockID.java index 82f5c2979..1e9c5afa4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockID.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockID.java @@ -3,570 +3,570 @@ package com.sk89q.worldedit.world.block; public class BlockID { // Used for switch statements on blocks public static final int __RESERVED__ = 0; - public static final int ACACIA_BUTTON = 1; - public static final int ACACIA_DOOR = 2; - public static final int ACACIA_FENCE = 3; - public static final int ACACIA_FENCE_GATE = 4; - public static final int ACACIA_LEAVES = 5; - public static final int ACACIA_LOG = 6; - public static final int ACACIA_PLANKS = 7; - public static final int ACACIA_PRESSURE_PLATE = 8; - public static final int ACACIA_SAPLING = 9; - public static final int ACACIA_SLAB = 10; - public static final int ACACIA_STAIRS = 11; - public static final int ACACIA_TRAPDOOR = 12; - public static final int ACACIA_WOOD = 13; - public static final int ACTIVATOR_RAIL = 14; - public static final int AIR = 15; - public static final int ALLIUM = 16; - public static final int ANDESITE = 17; - public static final int ANVIL = 18; - public static final int ATTACHED_MELON_STEM = 19; - public static final int ATTACHED_PUMPKIN_STEM = 20; - public static final int AZURE_BLUET = 21; - public static final int BARRIER = 22; - public static final int BEACON = 23; - public static final int BEDROCK = 24; - public static final int BEETROOTS = 25; - public static final int BIRCH_BUTTON = 26; - public static final int BIRCH_DOOR = 27; - public static final int BIRCH_FENCE = 28; - public static final int BIRCH_FENCE_GATE = 29; - public static final int BIRCH_LEAVES = 30; - public static final int BIRCH_LOG = 31; - public static final int BIRCH_PLANKS = 32; - public static final int BIRCH_PRESSURE_PLATE = 33; - public static final int BIRCH_SAPLING = 34; - public static final int BIRCH_SLAB = 35; - public static final int BIRCH_STAIRS = 36; - public static final int BIRCH_TRAPDOOR = 37; - public static final int BIRCH_WOOD = 38; - public static final int BLACK_BANNER = 39; - public static final int BLACK_BED = 40; - public static final int BLACK_CARPET = 41; - public static final int BLACK_CONCRETE = 42; - public static final int BLACK_CONCRETE_POWDER = 43; - public static final int BLACK_GLAZED_TERRACOTTA = 44; - public static final int BLACK_SHULKER_BOX = 45; - public static final int BLACK_STAINED_GLASS = 46; - public static final int BLACK_STAINED_GLASS_PANE = 47; - public static final int BLACK_TERRACOTTA = 48; - public static final int BLACK_WALL_BANNER = 49; - public static final int BLACK_WOOL = 50; - public static final int BLUE_BANNER = 51; - public static final int BLUE_BED = 52; - public static final int BLUE_CARPET = 53; - public static final int BLUE_CONCRETE = 54; - public static final int BLUE_CONCRETE_POWDER = 55; - public static final int BLUE_GLAZED_TERRACOTTA = 56; - public static final int BLUE_ICE = 57; - public static final int BLUE_ORCHID = 58; - public static final int BLUE_SHULKER_BOX = 59; - public static final int BLUE_STAINED_GLASS = 60; - public static final int BLUE_STAINED_GLASS_PANE = 61; - public static final int BLUE_TERRACOTTA = 62; - public static final int BLUE_WALL_BANNER = 63; - public static final int BLUE_WOOL = 64; - public static final int BONE_BLOCK = 65; - public static final int BOOKSHELF = 66; - public static final int BRAIN_CORAL = 67; - public static final int BRAIN_CORAL_BLOCK = 68; - public static final int BRAIN_CORAL_FAN = 69; - public static final int BRAIN_CORAL_WALL_FAN = 70; - public static final int BREWING_STAND = 71; - public static final int BRICK_SLAB = 72; - public static final int BRICK_STAIRS = 73; - public static final int BRICKS = 74; - public static final int BROWN_BANNER = 75; - public static final int BROWN_BED = 76; - public static final int BROWN_CARPET = 77; - public static final int BROWN_CONCRETE = 78; - public static final int BROWN_CONCRETE_POWDER = 79; - public static final int BROWN_GLAZED_TERRACOTTA = 80; - public static final int BROWN_MUSHROOM = 81; - public static final int BROWN_MUSHROOM_BLOCK = 82; - public static final int BROWN_SHULKER_BOX = 83; - public static final int BROWN_STAINED_GLASS = 84; - public static final int BROWN_STAINED_GLASS_PANE = 85; - public static final int BROWN_TERRACOTTA = 86; - public static final int BROWN_WALL_BANNER = 87; - public static final int BROWN_WOOL = 88; - public static final int BUBBLE_COLUMN = 89; - public static final int BUBBLE_CORAL = 90; - public static final int BUBBLE_CORAL_BLOCK = 91; - public static final int BUBBLE_CORAL_FAN = 92; - public static final int BUBBLE_CORAL_WALL_FAN = 93; - public static final int CACTUS = 94; - public static final int CAKE = 95; - public static final int CARROTS = 96; - public static final int CARVED_PUMPKIN = 97; - public static final int CAULDRON = 98; - public static final int CAVE_AIR = 99; - public static final int CHAIN_COMMAND_BLOCK = 100; - public static final int CHEST = 101; - public static final int CHIPPED_ANVIL = 102; - public static final int CHISELED_QUARTZ_BLOCK = 103; - public static final int CHISELED_RED_SANDSTONE = 104; - public static final int CHISELED_SANDSTONE = 105; - public static final int CHISELED_STONE_BRICKS = 106; - public static final int CHORUS_FLOWER = 107; - public static final int CHORUS_PLANT = 108; - public static final int CLAY = 109; - public static final int COAL_BLOCK = 110; - public static final int COAL_ORE = 111; - public static final int COARSE_DIRT = 112; - public static final int COBBLESTONE = 113; - public static final int COBBLESTONE_SLAB = 114; - public static final int COBBLESTONE_STAIRS = 115; - public static final int COBBLESTONE_WALL = 116; - public static final int COBWEB = 117; - public static final int COCOA = 118; - public static final int COMMAND_BLOCK = 119; - public static final int COMPARATOR = 120; - public static final int CONDUIT = 121; - public static final int CRACKED_STONE_BRICKS = 122; - public static final int CRAFTING_TABLE = 123; - public static final int CREEPER_HEAD = 124; - public static final int CREEPER_WALL_HEAD = 125; - public static final int CUT_RED_SANDSTONE = 126; - public static final int CUT_SANDSTONE = 127; - public static final int CYAN_BANNER = 128; - public static final int CYAN_BED = 129; - public static final int CYAN_CARPET = 130; - public static final int CYAN_CONCRETE = 131; - public static final int CYAN_CONCRETE_POWDER = 132; - public static final int CYAN_GLAZED_TERRACOTTA = 133; - public static final int CYAN_SHULKER_BOX = 134; - public static final int CYAN_STAINED_GLASS = 135; - public static final int CYAN_STAINED_GLASS_PANE = 136; - public static final int CYAN_TERRACOTTA = 137; - public static final int CYAN_WALL_BANNER = 138; - public static final int CYAN_WOOL = 139; - public static final int DAMAGED_ANVIL = 140; - public static final int DANDELION = 141; - public static final int DARK_OAK_BUTTON = 142; - public static final int DARK_OAK_DOOR = 143; - public static final int DARK_OAK_FENCE = 144; - public static final int DARK_OAK_FENCE_GATE = 145; - public static final int DARK_OAK_LEAVES = 146; - public static final int DARK_OAK_LOG = 147; - public static final int DARK_OAK_PLANKS = 148; - public static final int DARK_OAK_PRESSURE_PLATE = 149; - public static final int DARK_OAK_SAPLING = 150; - public static final int DARK_OAK_SLAB = 151; - public static final int DARK_OAK_STAIRS = 152; - public static final int DARK_OAK_TRAPDOOR = 153; - public static final int DARK_OAK_WOOD = 154; - public static final int DARK_PRISMARINE = 155; - public static final int DARK_PRISMARINE_SLAB = 156; - public static final int DARK_PRISMARINE_STAIRS = 157; - public static final int DAYLIGHT_DETECTOR = 158; - public static final int DEAD_BRAIN_CORAL = 159; - public static final int DEAD_BRAIN_CORAL_BLOCK = 160; - public static final int DEAD_BRAIN_CORAL_FAN = 161; - public static final int DEAD_BRAIN_CORAL_WALL_FAN = 162; - public static final int DEAD_BUBBLE_CORAL = 163; - public static final int DEAD_BUBBLE_CORAL_BLOCK = 164; - public static final int DEAD_BUBBLE_CORAL_FAN = 165; - public static final int DEAD_BUBBLE_CORAL_WALL_FAN = 166; - public static final int DEAD_BUSH = 167; - public static final int DEAD_FIRE_CORAL = 168; - public static final int DEAD_FIRE_CORAL_BLOCK = 169; - public static final int DEAD_FIRE_CORAL_FAN = 170; - public static final int DEAD_FIRE_CORAL_WALL_FAN = 171; - public static final int DEAD_HORN_CORAL = 172; - public static final int DEAD_HORN_CORAL_BLOCK = 173; - public static final int DEAD_HORN_CORAL_FAN = 174; - public static final int DEAD_HORN_CORAL_WALL_FAN = 175; - public static final int DEAD_TUBE_CORAL = 176; - public static final int DEAD_TUBE_CORAL_BLOCK = 177; - public static final int DEAD_TUBE_CORAL_FAN = 178; - public static final int DEAD_TUBE_CORAL_WALL_FAN = 179; - public static final int DETECTOR_RAIL = 180; - public static final int DIAMOND_BLOCK = 181; - public static final int DIAMOND_ORE = 182; - public static final int DIORITE = 183; - public static final int DIRT = 184; - public static final int DISPENSER = 185; - public static final int DRAGON_EGG = 186; - public static final int DRAGON_HEAD = 187; - public static final int DRAGON_WALL_HEAD = 188; - public static final int DRIED_KELP_BLOCK = 189; - public static final int DROPPER = 190; - public static final int EMERALD_BLOCK = 191; - public static final int EMERALD_ORE = 192; - public static final int ENCHANTING_TABLE = 193; - public static final int END_GATEWAY = 194; - public static final int END_PORTAL = 195; - public static final int END_PORTAL_FRAME = 196; - public static final int END_ROD = 197; - public static final int END_STONE = 198; - public static final int END_STONE_BRICKS = 199; - public static final int ENDER_CHEST = 200; - public static final int FARMLAND = 201; - public static final int FERN = 202; - public static final int FIRE = 203; - public static final int FIRE_CORAL = 204; - public static final int FIRE_CORAL_BLOCK = 205; - public static final int FIRE_CORAL_FAN = 206; - public static final int FIRE_CORAL_WALL_FAN = 207; - public static final int FLOWER_POT = 208; - public static final int FROSTED_ICE = 209; - public static final int FURNACE = 210; - public static final int GLASS = 211; - public static final int GLASS_PANE = 212; - public static final int GLOWSTONE = 213; - public static final int GOLD_BLOCK = 214; - public static final int GOLD_ORE = 215; - public static final int GRANITE = 216; - public static final int GRASS = 217; - public static final int GRASS_BLOCK = 218; - public static final int GRASS_PATH = 219; - public static final int GRAVEL = 220; - public static final int GRAY_BANNER = 221; - public static final int GRAY_BED = 222; - public static final int GRAY_CARPET = 223; - public static final int GRAY_CONCRETE = 224; - public static final int GRAY_CONCRETE_POWDER = 225; - public static final int GRAY_GLAZED_TERRACOTTA = 226; - public static final int GRAY_SHULKER_BOX = 227; - public static final int GRAY_STAINED_GLASS = 228; - public static final int GRAY_STAINED_GLASS_PANE = 229; - public static final int GRAY_TERRACOTTA = 230; - public static final int GRAY_WALL_BANNER = 231; - public static final int GRAY_WOOL = 232; - public static final int GREEN_BANNER = 233; - public static final int GREEN_BED = 234; - public static final int GREEN_CARPET = 235; - public static final int GREEN_CONCRETE = 236; - public static final int GREEN_CONCRETE_POWDER = 237; - public static final int GREEN_GLAZED_TERRACOTTA = 238; - public static final int GREEN_SHULKER_BOX = 239; - public static final int GREEN_STAINED_GLASS = 240; - public static final int GREEN_STAINED_GLASS_PANE = 241; - public static final int GREEN_TERRACOTTA = 242; - public static final int GREEN_WALL_BANNER = 243; - public static final int GREEN_WOOL = 244; - public static final int HAY_BLOCK = 245; - public static final int HEAVY_WEIGHTED_PRESSURE_PLATE = 246; - public static final int HOPPER = 247; - public static final int HORN_CORAL = 248; - public static final int HORN_CORAL_BLOCK = 249; - public static final int HORN_CORAL_FAN = 250; - public static final int HORN_CORAL_WALL_FAN = 251; - public static final int ICE = 252; - public static final int INFESTED_CHISELED_STONE_BRICKS = 253; - public static final int INFESTED_COBBLESTONE = 254; - public static final int INFESTED_CRACKED_STONE_BRICKS = 255; - public static final int INFESTED_MOSSY_STONE_BRICKS = 256; - public static final int INFESTED_STONE = 257; - public static final int INFESTED_STONE_BRICKS = 258; - public static final int IRON_BARS = 259; - public static final int IRON_BLOCK = 260; - public static final int IRON_DOOR = 261; - public static final int IRON_ORE = 262; - public static final int IRON_TRAPDOOR = 263; - public static final int JACK_O_LANTERN = 264; - public static final int JUKEBOX = 265; - public static final int JUNGLE_BUTTON = 266; - public static final int JUNGLE_DOOR = 267; - public static final int JUNGLE_FENCE = 268; - public static final int JUNGLE_FENCE_GATE = 269; - public static final int JUNGLE_LEAVES = 270; - public static final int JUNGLE_LOG = 271; - public static final int JUNGLE_PLANKS = 272; - public static final int JUNGLE_PRESSURE_PLATE = 273; - public static final int JUNGLE_SAPLING = 274; - public static final int JUNGLE_SLAB = 275; - public static final int JUNGLE_STAIRS = 276; - public static final int JUNGLE_TRAPDOOR = 277; - public static final int JUNGLE_WOOD = 278; - public static final int KELP = 279; - public static final int KELP_PLANT = 280; - public static final int LADDER = 281; - public static final int LAPIS_BLOCK = 282; - public static final int LAPIS_ORE = 283; - public static final int LARGE_FERN = 284; - public static final int LAVA = 285; - public static final int LEVER = 286; - public static final int LIGHT_BLUE_BANNER = 287; - public static final int LIGHT_BLUE_BED = 288; - public static final int LIGHT_BLUE_CARPET = 289; - public static final int LIGHT_BLUE_CONCRETE = 290; - public static final int LIGHT_BLUE_CONCRETE_POWDER = 291; - public static final int LIGHT_BLUE_GLAZED_TERRACOTTA = 292; - public static final int LIGHT_BLUE_SHULKER_BOX = 293; - public static final int LIGHT_BLUE_STAINED_GLASS = 294; - public static final int LIGHT_BLUE_STAINED_GLASS_PANE = 295; - public static final int LIGHT_BLUE_TERRACOTTA = 296; - public static final int LIGHT_BLUE_WALL_BANNER = 297; - public static final int LIGHT_BLUE_WOOL = 298; - public static final int LIGHT_GRAY_BANNER = 299; - public static final int LIGHT_GRAY_BED = 300; - public static final int LIGHT_GRAY_CARPET = 301; - public static final int LIGHT_GRAY_CONCRETE = 302; - public static final int LIGHT_GRAY_CONCRETE_POWDER = 303; - public static final int LIGHT_GRAY_GLAZED_TERRACOTTA = 304; - public static final int LIGHT_GRAY_SHULKER_BOX = 305; - public static final int LIGHT_GRAY_STAINED_GLASS = 306; - public static final int LIGHT_GRAY_STAINED_GLASS_PANE = 307; - public static final int LIGHT_GRAY_TERRACOTTA = 308; - public static final int LIGHT_GRAY_WALL_BANNER = 309; - public static final int LIGHT_GRAY_WOOL = 310; - public static final int LIGHT_WEIGHTED_PRESSURE_PLATE = 311; - public static final int LILAC = 312; - public static final int LILY_PAD = 313; - public static final int LIME_BANNER = 314; - public static final int LIME_BED = 315; - public static final int LIME_CARPET = 316; - public static final int LIME_CONCRETE = 317; - public static final int LIME_CONCRETE_POWDER = 318; - public static final int LIME_GLAZED_TERRACOTTA = 319; - public static final int LIME_SHULKER_BOX = 320; - public static final int LIME_STAINED_GLASS = 321; - public static final int LIME_STAINED_GLASS_PANE = 322; - public static final int LIME_TERRACOTTA = 323; - public static final int LIME_WALL_BANNER = 324; - public static final int LIME_WOOL = 325; - public static final int MAGENTA_BANNER = 326; - public static final int MAGENTA_BED = 327; - public static final int MAGENTA_CARPET = 328; - public static final int MAGENTA_CONCRETE = 329; - public static final int MAGENTA_CONCRETE_POWDER = 330; - public static final int MAGENTA_GLAZED_TERRACOTTA = 331; - public static final int MAGENTA_SHULKER_BOX = 332; - public static final int MAGENTA_STAINED_GLASS = 333; - public static final int MAGENTA_STAINED_GLASS_PANE = 334; - public static final int MAGENTA_TERRACOTTA = 335; - public static final int MAGENTA_WALL_BANNER = 336; - public static final int MAGENTA_WOOL = 337; - public static final int MAGMA_BLOCK = 338; - public static final int MELON = 339; - public static final int MELON_STEM = 340; - public static final int MOSSY_COBBLESTONE = 341; - public static final int MOSSY_COBBLESTONE_WALL = 342; - public static final int MOSSY_STONE_BRICKS = 343; - public static final int MOVING_PISTON = 344; - public static final int MUSHROOM_STEM = 345; - public static final int MYCELIUM = 346; - public static final int NETHER_BRICK_FENCE = 347; - public static final int NETHER_BRICK_SLAB = 348; - public static final int NETHER_BRICK_STAIRS = 349; - public static final int NETHER_BRICKS = 350; - public static final int NETHER_PORTAL = 351; - public static final int NETHER_QUARTZ_ORE = 352; - public static final int NETHER_WART = 353; - public static final int NETHER_WART_BLOCK = 354; - public static final int NETHERRACK = 355; - public static final int NOTE_BLOCK = 356; - public static final int OAK_BUTTON = 357; - public static final int OAK_DOOR = 358; - public static final int OAK_FENCE = 359; - public static final int OAK_FENCE_GATE = 360; - public static final int OAK_LEAVES = 361; - public static final int OAK_LOG = 362; - public static final int OAK_PLANKS = 363; - public static final int OAK_PRESSURE_PLATE = 364; - public static final int OAK_SAPLING = 365; - public static final int OAK_SLAB = 366; - public static final int OAK_STAIRS = 367; - public static final int OAK_TRAPDOOR = 368; - public static final int OAK_WOOD = 369; - public static final int OBSERVER = 370; - public static final int OBSIDIAN = 371; - public static final int ORANGE_BANNER = 372; - public static final int ORANGE_BED = 373; - public static final int ORANGE_CARPET = 374; - public static final int ORANGE_CONCRETE = 375; - public static final int ORANGE_CONCRETE_POWDER = 376; - public static final int ORANGE_GLAZED_TERRACOTTA = 377; - public static final int ORANGE_SHULKER_BOX = 378; - public static final int ORANGE_STAINED_GLASS = 379; - public static final int ORANGE_STAINED_GLASS_PANE = 380; - public static final int ORANGE_TERRACOTTA = 381; - public static final int ORANGE_TULIP = 382; - public static final int ORANGE_WALL_BANNER = 383; - public static final int ORANGE_WOOL = 384; - public static final int OXEYE_DAISY = 385; - public static final int PACKED_ICE = 386; - public static final int PEONY = 387; - public static final int PETRIFIED_OAK_SLAB = 388; - public static final int PINK_BANNER = 389; - public static final int PINK_BED = 390; - public static final int PINK_CARPET = 391; - public static final int PINK_CONCRETE = 392; - public static final int PINK_CONCRETE_POWDER = 393; - public static final int PINK_GLAZED_TERRACOTTA = 394; - public static final int PINK_SHULKER_BOX = 395; - public static final int PINK_STAINED_GLASS = 396; - public static final int PINK_STAINED_GLASS_PANE = 397; - public static final int PINK_TERRACOTTA = 398; - public static final int PINK_TULIP = 399; - public static final int PINK_WALL_BANNER = 400; - public static final int PINK_WOOL = 401; - public static final int PISTON = 402; - public static final int PISTON_HEAD = 403; - public static final int PLAYER_HEAD = 404; - public static final int PLAYER_WALL_HEAD = 405; - public static final int PODZOL = 406; - public static final int POLISHED_ANDESITE = 407; - public static final int POLISHED_DIORITE = 408; - public static final int POLISHED_GRANITE = 409; - public static final int POPPY = 410; - public static final int POTATOES = 411; - public static final int POTTED_ACACIA_SAPLING = 412; - public static final int POTTED_ALLIUM = 413; - public static final int POTTED_AZURE_BLUET = 414; - public static final int POTTED_BIRCH_SAPLING = 415; - public static final int POTTED_BLUE_ORCHID = 416; - public static final int POTTED_BROWN_MUSHROOM = 417; - public static final int POTTED_CACTUS = 418; - public static final int POTTED_DANDELION = 419; - public static final int POTTED_DARK_OAK_SAPLING = 420; - public static final int POTTED_DEAD_BUSH = 421; - public static final int POTTED_FERN = 422; - public static final int POTTED_JUNGLE_SAPLING = 423; - public static final int POTTED_OAK_SAPLING = 424; - public static final int POTTED_ORANGE_TULIP = 425; - public static final int POTTED_OXEYE_DAISY = 426; - public static final int POTTED_PINK_TULIP = 427; - public static final int POTTED_POPPY = 428; - public static final int POTTED_RED_MUSHROOM = 429; - public static final int POTTED_RED_TULIP = 430; - public static final int POTTED_SPRUCE_SAPLING = 431; - public static final int POTTED_WHITE_TULIP = 432; - public static final int POWERED_RAIL = 433; - public static final int PRISMARINE = 434; - public static final int PRISMARINE_BRICK_SLAB = 435; - public static final int PRISMARINE_BRICK_STAIRS = 436; - public static final int PRISMARINE_BRICKS = 437; - public static final int PRISMARINE_SLAB = 438; - public static final int PRISMARINE_STAIRS = 439; - public static final int PUMPKIN = 440; - public static final int PUMPKIN_STEM = 441; - public static final int PURPLE_BANNER = 442; - public static final int PURPLE_BED = 443; - public static final int PURPLE_CARPET = 444; - public static final int PURPLE_CONCRETE = 445; - public static final int PURPLE_CONCRETE_POWDER = 446; - public static final int PURPLE_GLAZED_TERRACOTTA = 447; - public static final int PURPLE_SHULKER_BOX = 448; - public static final int PURPLE_STAINED_GLASS = 449; - public static final int PURPLE_STAINED_GLASS_PANE = 450; - public static final int PURPLE_TERRACOTTA = 451; - public static final int PURPLE_WALL_BANNER = 452; - public static final int PURPLE_WOOL = 453; - public static final int PURPUR_BLOCK = 454; - public static final int PURPUR_PILLAR = 455; - public static final int PURPUR_SLAB = 456; - public static final int PURPUR_STAIRS = 457; - public static final int QUARTZ_BLOCK = 458; - public static final int QUARTZ_PILLAR = 459; - public static final int QUARTZ_SLAB = 460; - public static final int QUARTZ_STAIRS = 461; - public static final int RAIL = 462; - public static final int RED_BANNER = 463; - public static final int RED_BED = 464; - public static final int RED_CARPET = 465; - public static final int RED_CONCRETE = 466; - public static final int RED_CONCRETE_POWDER = 467; - public static final int RED_GLAZED_TERRACOTTA = 468; - public static final int RED_MUSHROOM = 469; - public static final int RED_MUSHROOM_BLOCK = 470; - public static final int RED_NETHER_BRICKS = 471; - public static final int RED_SAND = 472; - public static final int RED_SANDSTONE = 473; - public static final int RED_SANDSTONE_SLAB = 474; - public static final int RED_SANDSTONE_STAIRS = 475; - public static final int RED_SHULKER_BOX = 476; - public static final int RED_STAINED_GLASS = 477; - public static final int RED_STAINED_GLASS_PANE = 478; - public static final int RED_TERRACOTTA = 479; - public static final int RED_TULIP = 480; - public static final int RED_WALL_BANNER = 481; - public static final int RED_WOOL = 482; - public static final int REDSTONE_BLOCK = 483; - public static final int REDSTONE_LAMP = 484; - public static final int REDSTONE_ORE = 485; - public static final int REDSTONE_TORCH = 486; - public static final int REDSTONE_WALL_TORCH = 487; - public static final int REDSTONE_WIRE = 488; - public static final int REPEATER = 489; - public static final int REPEATING_COMMAND_BLOCK = 490; - public static final int ROSE_BUSH = 491; - public static final int SAND = 492; - public static final int SANDSTONE = 493; - public static final int SANDSTONE_SLAB = 494; - public static final int SANDSTONE_STAIRS = 495; - public static final int SEA_LANTERN = 496; - public static final int SEA_PICKLE = 497; - public static final int SEAGRASS = 498; - public static final int SHULKER_BOX = 499; - public static final int SIGN = 500; - public static final int SKELETON_SKULL = 501; - public static final int SKELETON_WALL_SKULL = 502; - public static final int SLIME_BLOCK = 503; - public static final int SMOOTH_QUARTZ = 504; - public static final int SMOOTH_RED_SANDSTONE = 505; - public static final int SMOOTH_SANDSTONE = 506; - public static final int SMOOTH_STONE = 507; - public static final int SNOW = 508; - public static final int SNOW_BLOCK = 509; - public static final int SOUL_SAND = 510; - public static final int SPAWNER = 511; - public static final int SPONGE = 512; - public static final int SPRUCE_BUTTON = 513; - public static final int SPRUCE_DOOR = 514; - public static final int SPRUCE_FENCE = 515; - public static final int SPRUCE_FENCE_GATE = 516; - public static final int SPRUCE_LEAVES = 517; - public static final int SPRUCE_LOG = 518; - public static final int SPRUCE_PLANKS = 519; - public static final int SPRUCE_PRESSURE_PLATE = 520; - public static final int SPRUCE_SAPLING = 521; - public static final int SPRUCE_SLAB = 522; - public static final int SPRUCE_STAIRS = 523; - public static final int SPRUCE_TRAPDOOR = 524; - public static final int SPRUCE_WOOD = 525; - public static final int STICKY_PISTON = 526; - public static final int STONE = 527; - public static final int STONE_BRICK_SLAB = 528; - public static final int STONE_BRICK_STAIRS = 529; - public static final int STONE_BRICKS = 530; - public static final int STONE_BUTTON = 531; - public static final int STONE_PRESSURE_PLATE = 532; - public static final int STONE_SLAB = 533; - public static final int STRIPPED_ACACIA_LOG = 534; - public static final int STRIPPED_ACACIA_WOOD = 535; - public static final int STRIPPED_BIRCH_LOG = 536; - public static final int STRIPPED_BIRCH_WOOD = 537; - public static final int STRIPPED_DARK_OAK_LOG = 538; - public static final int STRIPPED_DARK_OAK_WOOD = 539; - public static final int STRIPPED_JUNGLE_LOG = 540; - public static final int STRIPPED_JUNGLE_WOOD = 541; - public static final int STRIPPED_OAK_LOG = 542; - public static final int STRIPPED_OAK_WOOD = 543; - public static final int STRIPPED_SPRUCE_LOG = 544; - public static final int STRIPPED_SPRUCE_WOOD = 545; - public static final int STRUCTURE_BLOCK = 546; - public static final int STRUCTURE_VOID = 547; - public static final int SUGAR_CANE = 548; - public static final int SUNFLOWER = 549; - public static final int TALL_GRASS = 550; - public static final int TALL_SEAGRASS = 551; - public static final int TERRACOTTA = 552; - public static final int TNT = 553; - public static final int TORCH = 554; - public static final int TRAPPED_CHEST = 555; - public static final int TRIPWIRE = 556; - public static final int TRIPWIRE_HOOK = 557; - public static final int TUBE_CORAL = 558; - public static final int TUBE_CORAL_BLOCK = 559; - public static final int TUBE_CORAL_FAN = 560; - public static final int TUBE_CORAL_WALL_FAN = 561; - public static final int TURTLE_EGG = 562; - public static final int VINE = 563; - public static final int VOID_AIR = 564; + public static final int AIR = 1; + public static final int CAVE_AIR = 2; + public static final int VOID_AIR = 3; + public static final int ACACIA_BUTTON = 4; + public static final int ACACIA_DOOR = 5; + public static final int ACACIA_FENCE = 6; + public static final int ACACIA_FENCE_GATE = 7; + public static final int ACACIA_LEAVES = 8; + public static final int ACACIA_LOG = 9; + public static final int ACACIA_PLANKS = 10; + public static final int ACACIA_PRESSURE_PLATE = 11; + public static final int ACACIA_SAPLING = 12; + public static final int ACACIA_SLAB = 13; + public static final int ACACIA_STAIRS = 14; + public static final int ACACIA_TRAPDOOR = 15; + public static final int ACACIA_WOOD = 16; + public static final int ACTIVATOR_RAIL = 17; + public static final int ALLIUM = 18; + public static final int ANDESITE = 19; + public static final int ANVIL = 20; + public static final int ATTACHED_MELON_STEM = 21; + public static final int ATTACHED_PUMPKIN_STEM = 22; + public static final int AZURE_BLUET = 23; + public static final int BARRIER = 24; + public static final int BEACON = 25; + public static final int BEDROCK = 26; + public static final int BEETROOTS = 27; + public static final int BIRCH_BUTTON = 28; + public static final int BIRCH_DOOR = 29; + public static final int BIRCH_FENCE = 30; + public static final int BIRCH_FENCE_GATE = 31; + public static final int BIRCH_LEAVES = 32; + public static final int BIRCH_LOG = 33; + public static final int BIRCH_PLANKS = 34; + public static final int BIRCH_PRESSURE_PLATE = 35; + public static final int BIRCH_SAPLING = 36; + public static final int BIRCH_SLAB = 37; + public static final int BIRCH_STAIRS = 38; + public static final int BIRCH_TRAPDOOR = 39; + public static final int BIRCH_WOOD = 40; + public static final int BLACK_BANNER = 41; + public static final int BLACK_BED = 42; + public static final int BLACK_CARPET = 43; + public static final int BLACK_CONCRETE = 44; + public static final int BLACK_CONCRETE_POWDER = 45; + public static final int BLACK_GLAZED_TERRACOTTA = 46; + public static final int BLACK_SHULKER_BOX = 47; + public static final int BLACK_STAINED_GLASS = 48; + public static final int BLACK_STAINED_GLASS_PANE = 49; + public static final int BLACK_TERRACOTTA = 50; + public static final int BLACK_WALL_BANNER = 51; + public static final int BLACK_WOOL = 52; + public static final int BLUE_BANNER = 53; + public static final int BLUE_BED = 54; + public static final int BLUE_CARPET = 55; + public static final int BLUE_CONCRETE = 56; + public static final int BLUE_CONCRETE_POWDER = 57; + public static final int BLUE_GLAZED_TERRACOTTA = 58; + public static final int BLUE_ICE = 59; + public static final int BLUE_ORCHID = 60; + public static final int BLUE_SHULKER_BOX = 61; + public static final int BLUE_STAINED_GLASS = 62; + public static final int BLUE_STAINED_GLASS_PANE = 63; + public static final int BLUE_TERRACOTTA = 64; + public static final int BLUE_WALL_BANNER = 65; + public static final int BLUE_WOOL = 66; + public static final int BONE_BLOCK = 67; + public static final int BOOKSHELF = 68; + public static final int BRAIN_CORAL = 69; + public static final int BRAIN_CORAL_BLOCK = 70; + public static final int BRAIN_CORAL_FAN = 71; + public static final int BRAIN_CORAL_WALL_FAN = 72; + public static final int BREWING_STAND = 73; + public static final int BRICK_SLAB = 74; + public static final int BRICK_STAIRS = 75; + public static final int BRICKS = 76; + public static final int BROWN_BANNER = 77; + public static final int BROWN_BED = 78; + public static final int BROWN_CARPET = 79; + public static final int BROWN_CONCRETE = 80; + public static final int BROWN_CONCRETE_POWDER = 81; + public static final int BROWN_GLAZED_TERRACOTTA = 82; + public static final int BROWN_MUSHROOM = 83; + public static final int BROWN_MUSHROOM_BLOCK = 84; + public static final int BROWN_SHULKER_BOX = 85; + public static final int BROWN_STAINED_GLASS = 86; + public static final int BROWN_STAINED_GLASS_PANE = 87; + public static final int BROWN_TERRACOTTA = 88; + public static final int BROWN_WALL_BANNER = 89; + public static final int BROWN_WOOL = 90; + public static final int BUBBLE_COLUMN = 91; + public static final int BUBBLE_CORAL = 92; + public static final int BUBBLE_CORAL_BLOCK = 93; + public static final int BUBBLE_CORAL_FAN = 94; + public static final int BUBBLE_CORAL_WALL_FAN = 95; + public static final int CACTUS = 96; + public static final int CAKE = 97; + public static final int CARROTS = 98; + public static final int CARVED_PUMPKIN = 99; + public static final int CAULDRON = 100; + public static final int CHAIN_COMMAND_BLOCK = 101; + public static final int CHEST = 102; + public static final int CHIPPED_ANVIL = 103; + public static final int CHISELED_QUARTZ_BLOCK = 104; + public static final int CHISELED_RED_SANDSTONE = 105; + public static final int CHISELED_SANDSTONE = 106; + public static final int CHISELED_STONE_BRICKS = 107; + public static final int CHORUS_FLOWER = 108; + public static final int CHORUS_PLANT = 109; + public static final int CLAY = 110; + public static final int COAL_BLOCK = 111; + public static final int COAL_ORE = 112; + public static final int COARSE_DIRT = 113; + public static final int COBBLESTONE = 114; + public static final int COBBLESTONE_SLAB = 115; + public static final int COBBLESTONE_STAIRS = 116; + public static final int COBBLESTONE_WALL = 117; + public static final int COBWEB = 118; + public static final int COCOA = 119; + public static final int COMMAND_BLOCK = 120; + public static final int COMPARATOR = 121; + public static final int CONDUIT = 122; + public static final int CRACKED_STONE_BRICKS = 123; + public static final int CRAFTING_TABLE = 124; + public static final int CREEPER_HEAD = 125; + public static final int CREEPER_WALL_HEAD = 126; + public static final int CUT_RED_SANDSTONE = 127; + public static final int CUT_SANDSTONE = 128; + public static final int CYAN_BANNER = 129; + public static final int CYAN_BED = 130; + public static final int CYAN_CARPET = 131; + public static final int CYAN_CONCRETE = 132; + public static final int CYAN_CONCRETE_POWDER = 133; + public static final int CYAN_GLAZED_TERRACOTTA = 134; + public static final int CYAN_SHULKER_BOX = 135; + public static final int CYAN_STAINED_GLASS = 136; + public static final int CYAN_STAINED_GLASS_PANE = 137; + public static final int CYAN_TERRACOTTA = 138; + public static final int CYAN_WALL_BANNER = 139; + public static final int CYAN_WOOL = 140; + public static final int DAMAGED_ANVIL = 141; + public static final int DANDELION = 142; + public static final int DARK_OAK_BUTTON = 143; + public static final int DARK_OAK_DOOR = 144; + public static final int DARK_OAK_FENCE = 145; + public static final int DARK_OAK_FENCE_GATE = 146; + public static final int DARK_OAK_LEAVES = 147; + public static final int DARK_OAK_LOG = 148; + public static final int DARK_OAK_PLANKS = 149; + public static final int DARK_OAK_PRESSURE_PLATE = 150; + public static final int DARK_OAK_SAPLING = 151; + public static final int DARK_OAK_SLAB = 152; + public static final int DARK_OAK_STAIRS = 153; + public static final int DARK_OAK_TRAPDOOR = 154; + public static final int DARK_OAK_WOOD = 155; + public static final int DARK_PRISMARINE = 156; + public static final int DARK_PRISMARINE_SLAB = 157; + public static final int DARK_PRISMARINE_STAIRS = 158; + public static final int DAYLIGHT_DETECTOR = 159; + public static final int DEAD_BRAIN_CORAL = 160; + public static final int DEAD_BRAIN_CORAL_BLOCK = 161; + public static final int DEAD_BRAIN_CORAL_FAN = 162; + public static final int DEAD_BRAIN_CORAL_WALL_FAN = 163; + public static final int DEAD_BUBBLE_CORAL = 164; + public static final int DEAD_BUBBLE_CORAL_BLOCK = 165; + public static final int DEAD_BUBBLE_CORAL_FAN = 166; + public static final int DEAD_BUBBLE_CORAL_WALL_FAN = 167; + public static final int DEAD_BUSH = 168; + public static final int DEAD_FIRE_CORAL = 169; + public static final int DEAD_FIRE_CORAL_BLOCK = 170; + public static final int DEAD_FIRE_CORAL_FAN = 171; + public static final int DEAD_FIRE_CORAL_WALL_FAN = 172; + public static final int DEAD_HORN_CORAL = 173; + public static final int DEAD_HORN_CORAL_BLOCK = 174; + public static final int DEAD_HORN_CORAL_FAN = 175; + public static final int DEAD_HORN_CORAL_WALL_FAN = 176; + public static final int DEAD_TUBE_CORAL = 177; + public static final int DEAD_TUBE_CORAL_BLOCK = 178; + public static final int DEAD_TUBE_CORAL_FAN = 179; + public static final int DEAD_TUBE_CORAL_WALL_FAN = 180; + public static final int DETECTOR_RAIL = 181; + public static final int DIAMOND_BLOCK = 182; + public static final int DIAMOND_ORE = 183; + public static final int DIORITE = 184; + public static final int DIRT = 185; + public static final int DISPENSER = 186; + public static final int DRAGON_EGG = 187; + public static final int DRAGON_HEAD = 188; + public static final int DRAGON_WALL_HEAD = 189; + public static final int DRIED_KELP_BLOCK = 190; + public static final int DROPPER = 191; + public static final int EMERALD_BLOCK = 192; + public static final int EMERALD_ORE = 193; + public static final int ENCHANTING_TABLE = 194; + public static final int END_GATEWAY = 195; + public static final int END_PORTAL = 196; + public static final int END_PORTAL_FRAME = 197; + public static final int END_ROD = 198; + public static final int END_STONE = 199; + public static final int END_STONE_BRICKS = 200; + public static final int ENDER_CHEST = 201; + public static final int FARMLAND = 202; + public static final int FERN = 203; + public static final int FIRE = 204; + public static final int FIRE_CORAL = 205; + public static final int FIRE_CORAL_BLOCK = 206; + public static final int FIRE_CORAL_FAN = 207; + public static final int FIRE_CORAL_WALL_FAN = 208; + public static final int FLOWER_POT = 209; + public static final int FROSTED_ICE = 210; + public static final int FURNACE = 211; + public static final int GLASS = 212; + public static final int GLASS_PANE = 213; + public static final int GLOWSTONE = 214; + public static final int GOLD_BLOCK = 215; + public static final int GOLD_ORE = 216; + public static final int GRANITE = 217; + public static final int GRASS = 218; + public static final int GRASS_BLOCK = 219; + public static final int GRASS_PATH = 220; + public static final int GRAVEL = 221; + public static final int GRAY_BANNER = 222; + public static final int GRAY_BED = 223; + public static final int GRAY_CARPET = 224; + public static final int GRAY_CONCRETE = 225; + public static final int GRAY_CONCRETE_POWDER = 226; + public static final int GRAY_GLAZED_TERRACOTTA = 227; + public static final int GRAY_SHULKER_BOX = 228; + public static final int GRAY_STAINED_GLASS = 229; + public static final int GRAY_STAINED_GLASS_PANE = 230; + public static final int GRAY_TERRACOTTA = 231; + public static final int GRAY_WALL_BANNER = 232; + public static final int GRAY_WOOL = 233; + public static final int GREEN_BANNER = 234; + public static final int GREEN_BED = 235; + public static final int GREEN_CARPET = 236; + public static final int GREEN_CONCRETE = 237; + public static final int GREEN_CONCRETE_POWDER = 238; + public static final int GREEN_GLAZED_TERRACOTTA = 239; + public static final int GREEN_SHULKER_BOX = 240; + public static final int GREEN_STAINED_GLASS = 241; + public static final int GREEN_STAINED_GLASS_PANE = 242; + public static final int GREEN_TERRACOTTA = 243; + public static final int GREEN_WALL_BANNER = 244; + public static final int GREEN_WOOL = 245; + public static final int HAY_BLOCK = 246; + public static final int HEAVY_WEIGHTED_PRESSURE_PLATE = 247; + public static final int HOPPER = 248; + public static final int HORN_CORAL = 249; + public static final int HORN_CORAL_BLOCK = 250; + public static final int HORN_CORAL_FAN = 251; + public static final int HORN_CORAL_WALL_FAN = 252; + public static final int ICE = 253; + public static final int INFESTED_CHISELED_STONE_BRICKS = 254; + public static final int INFESTED_COBBLESTONE = 255; + public static final int INFESTED_CRACKED_STONE_BRICKS = 256; + public static final int INFESTED_MOSSY_STONE_BRICKS = 257; + public static final int INFESTED_STONE = 258; + public static final int INFESTED_STONE_BRICKS = 259; + public static final int IRON_BARS = 260; + public static final int IRON_BLOCK = 261; + public static final int IRON_DOOR = 262; + public static final int IRON_ORE = 263; + public static final int IRON_TRAPDOOR = 264; + public static final int JACK_O_LANTERN = 265; + public static final int JUKEBOX = 266; + public static final int JUNGLE_BUTTON = 267; + public static final int JUNGLE_DOOR = 268; + public static final int JUNGLE_FENCE = 269; + public static final int JUNGLE_FENCE_GATE = 270; + public static final int JUNGLE_LEAVES = 271; + public static final int JUNGLE_LOG = 272; + public static final int JUNGLE_PLANKS = 273; + public static final int JUNGLE_PRESSURE_PLATE = 274; + public static final int JUNGLE_SAPLING = 275; + public static final int JUNGLE_SLAB = 276; + public static final int JUNGLE_STAIRS = 277; + public static final int JUNGLE_TRAPDOOR = 278; + public static final int JUNGLE_WOOD = 279; + public static final int KELP = 280; + public static final int KELP_PLANT = 281; + public static final int LADDER = 282; + public static final int LAPIS_BLOCK = 283; + public static final int LAPIS_ORE = 284; + public static final int LARGE_FERN = 285; + public static final int LAVA = 286; + public static final int LEVER = 287; + public static final int LIGHT_BLUE_BANNER = 288; + public static final int LIGHT_BLUE_BED = 289; + public static final int LIGHT_BLUE_CARPET = 290; + public static final int LIGHT_BLUE_CONCRETE = 291; + public static final int LIGHT_BLUE_CONCRETE_POWDER = 292; + public static final int LIGHT_BLUE_GLAZED_TERRACOTTA = 293; + public static final int LIGHT_BLUE_SHULKER_BOX = 294; + public static final int LIGHT_BLUE_STAINED_GLASS = 295; + public static final int LIGHT_BLUE_STAINED_GLASS_PANE = 296; + public static final int LIGHT_BLUE_TERRACOTTA = 297; + public static final int LIGHT_BLUE_WALL_BANNER = 298; + public static final int LIGHT_BLUE_WOOL = 299; + public static final int LIGHT_GRAY_BANNER = 300; + public static final int LIGHT_GRAY_BED = 301; + public static final int LIGHT_GRAY_CARPET = 302; + public static final int LIGHT_GRAY_CONCRETE = 303; + public static final int LIGHT_GRAY_CONCRETE_POWDER = 304; + public static final int LIGHT_GRAY_GLAZED_TERRACOTTA = 305; + public static final int LIGHT_GRAY_SHULKER_BOX = 306; + public static final int LIGHT_GRAY_STAINED_GLASS = 307; + public static final int LIGHT_GRAY_STAINED_GLASS_PANE = 308; + public static final int LIGHT_GRAY_TERRACOTTA = 309; + public static final int LIGHT_GRAY_WALL_BANNER = 310; + public static final int LIGHT_GRAY_WOOL = 311; + public static final int LIGHT_WEIGHTED_PRESSURE_PLATE = 312; + public static final int LILAC = 313; + public static final int LILY_PAD = 314; + public static final int LIME_BANNER = 315; + public static final int LIME_BED = 316; + public static final int LIME_CARPET = 317; + public static final int LIME_CONCRETE = 318; + public static final int LIME_CONCRETE_POWDER = 319; + public static final int LIME_GLAZED_TERRACOTTA = 320; + public static final int LIME_SHULKER_BOX = 321; + public static final int LIME_STAINED_GLASS = 322; + public static final int LIME_STAINED_GLASS_PANE = 323; + public static final int LIME_TERRACOTTA = 324; + public static final int LIME_WALL_BANNER = 325; + public static final int LIME_WOOL = 326; + public static final int MAGENTA_BANNER = 327; + public static final int MAGENTA_BED = 328; + public static final int MAGENTA_CARPET = 329; + public static final int MAGENTA_CONCRETE = 330; + public static final int MAGENTA_CONCRETE_POWDER = 331; + public static final int MAGENTA_GLAZED_TERRACOTTA = 332; + public static final int MAGENTA_SHULKER_BOX = 333; + public static final int MAGENTA_STAINED_GLASS = 334; + public static final int MAGENTA_STAINED_GLASS_PANE = 335; + public static final int MAGENTA_TERRACOTTA = 336; + public static final int MAGENTA_WALL_BANNER = 337; + public static final int MAGENTA_WOOL = 338; + public static final int MAGMA_BLOCK = 339; + public static final int MELON = 340; + public static final int MELON_STEM = 341; + public static final int MOSSY_COBBLESTONE = 342; + public static final int MOSSY_COBBLESTONE_WALL = 343; + public static final int MOSSY_STONE_BRICKS = 344; + public static final int MOVING_PISTON = 345; + public static final int MUSHROOM_STEM = 346; + public static final int MYCELIUM = 347; + public static final int NETHER_BRICK_FENCE = 348; + public static final int NETHER_BRICK_SLAB = 349; + public static final int NETHER_BRICK_STAIRS = 350; + public static final int NETHER_BRICKS = 351; + public static final int NETHER_PORTAL = 352; + public static final int NETHER_QUARTZ_ORE = 353; + public static final int NETHER_WART = 354; + public static final int NETHER_WART_BLOCK = 355; + public static final int NETHERRACK = 356; + public static final int NOTE_BLOCK = 357; + public static final int OAK_BUTTON = 358; + public static final int OAK_DOOR = 359; + public static final int OAK_FENCE = 360; + public static final int OAK_FENCE_GATE = 361; + public static final int OAK_LEAVES = 362; + public static final int OAK_LOG = 363; + public static final int OAK_PLANKS = 364; + public static final int OAK_PRESSURE_PLATE = 365; + public static final int OAK_SAPLING = 366; + public static final int OAK_SLAB = 367; + public static final int OAK_STAIRS = 368; + public static final int OAK_TRAPDOOR = 369; + public static final int OAK_WOOD = 370; + public static final int OBSERVER = 371; + public static final int OBSIDIAN = 372; + public static final int ORANGE_BANNER = 373; + public static final int ORANGE_BED = 374; + public static final int ORANGE_CARPET = 375; + public static final int ORANGE_CONCRETE = 376; + public static final int ORANGE_CONCRETE_POWDER = 377; + public static final int ORANGE_GLAZED_TERRACOTTA = 378; + public static final int ORANGE_SHULKER_BOX = 379; + public static final int ORANGE_STAINED_GLASS = 380; + public static final int ORANGE_STAINED_GLASS_PANE = 381; + public static final int ORANGE_TERRACOTTA = 382; + public static final int ORANGE_TULIP = 383; + public static final int ORANGE_WALL_BANNER = 384; + public static final int ORANGE_WOOL = 385; + public static final int OXEYE_DAISY = 386; + public static final int PACKED_ICE = 387; + public static final int PEONY = 388; + public static final int PETRIFIED_OAK_SLAB = 389; + public static final int PINK_BANNER = 390; + public static final int PINK_BED = 391; + public static final int PINK_CARPET = 392; + public static final int PINK_CONCRETE = 393; + public static final int PINK_CONCRETE_POWDER = 394; + public static final int PINK_GLAZED_TERRACOTTA = 395; + public static final int PINK_SHULKER_BOX = 396; + public static final int PINK_STAINED_GLASS = 397; + public static final int PINK_STAINED_GLASS_PANE = 398; + public static final int PINK_TERRACOTTA = 399; + public static final int PINK_TULIP = 400; + public static final int PINK_WALL_BANNER = 401; + public static final int PINK_WOOL = 402; + public static final int PISTON = 403; + public static final int PISTON_HEAD = 404; + public static final int PLAYER_HEAD = 405; + public static final int PLAYER_WALL_HEAD = 406; + public static final int PODZOL = 407; + public static final int POLISHED_ANDESITE = 408; + public static final int POLISHED_DIORITE = 409; + public static final int POLISHED_GRANITE = 410; + public static final int POPPY = 411; + public static final int POTATOES = 412; + public static final int POTTED_ACACIA_SAPLING = 413; + public static final int POTTED_ALLIUM = 414; + public static final int POTTED_AZURE_BLUET = 415; + public static final int POTTED_BIRCH_SAPLING = 416; + public static final int POTTED_BLUE_ORCHID = 417; + public static final int POTTED_BROWN_MUSHROOM = 418; + public static final int POTTED_CACTUS = 419; + public static final int POTTED_DANDELION = 420; + public static final int POTTED_DARK_OAK_SAPLING = 421; + public static final int POTTED_DEAD_BUSH = 422; + public static final int POTTED_FERN = 423; + public static final int POTTED_JUNGLE_SAPLING = 424; + public static final int POTTED_OAK_SAPLING = 425; + public static final int POTTED_ORANGE_TULIP = 426; + public static final int POTTED_OXEYE_DAISY = 427; + public static final int POTTED_PINK_TULIP = 428; + public static final int POTTED_POPPY = 429; + public static final int POTTED_RED_MUSHROOM = 430; + public static final int POTTED_RED_TULIP = 431; + public static final int POTTED_SPRUCE_SAPLING = 432; + public static final int POTTED_WHITE_TULIP = 433; + public static final int POWERED_RAIL = 434; + public static final int PRISMARINE = 435; + public static final int PRISMARINE_BRICK_SLAB = 436; + public static final int PRISMARINE_BRICK_STAIRS = 437; + public static final int PRISMARINE_BRICKS = 438; + public static final int PRISMARINE_SLAB = 439; + public static final int PRISMARINE_STAIRS = 440; + public static final int PUMPKIN = 441; + public static final int PUMPKIN_STEM = 442; + public static final int PURPLE_BANNER = 443; + public static final int PURPLE_BED = 444; + public static final int PURPLE_CARPET = 445; + public static final int PURPLE_CONCRETE = 446; + public static final int PURPLE_CONCRETE_POWDER = 447; + public static final int PURPLE_GLAZED_TERRACOTTA = 448; + public static final int PURPLE_SHULKER_BOX = 449; + public static final int PURPLE_STAINED_GLASS = 450; + public static final int PURPLE_STAINED_GLASS_PANE = 451; + public static final int PURPLE_TERRACOTTA = 452; + public static final int PURPLE_WALL_BANNER = 453; + public static final int PURPLE_WOOL = 454; + public static final int PURPUR_BLOCK = 455; + public static final int PURPUR_PILLAR = 456; + public static final int PURPUR_SLAB = 457; + public static final int PURPUR_STAIRS = 458; + public static final int QUARTZ_BLOCK = 459; + public static final int QUARTZ_PILLAR = 460; + public static final int QUARTZ_SLAB = 461; + public static final int QUARTZ_STAIRS = 462; + public static final int RAIL = 463; + public static final int RED_BANNER = 464; + public static final int RED_BED = 465; + public static final int RED_CARPET = 466; + public static final int RED_CONCRETE = 467; + public static final int RED_CONCRETE_POWDER = 468; + public static final int RED_GLAZED_TERRACOTTA = 469; + public static final int RED_MUSHROOM = 470; + public static final int RED_MUSHROOM_BLOCK = 471; + public static final int RED_NETHER_BRICKS = 472; + public static final int RED_SAND = 473; + public static final int RED_SANDSTONE = 474; + public static final int RED_SANDSTONE_SLAB = 475; + public static final int RED_SANDSTONE_STAIRS = 476; + public static final int RED_SHULKER_BOX = 477; + public static final int RED_STAINED_GLASS = 478; + public static final int RED_STAINED_GLASS_PANE = 479; + public static final int RED_TERRACOTTA = 480; + public static final int RED_TULIP = 481; + public static final int RED_WALL_BANNER = 482; + public static final int RED_WOOL = 483; + public static final int REDSTONE_BLOCK = 484; + public static final int REDSTONE_LAMP = 485; + public static final int REDSTONE_ORE = 486; + public static final int REDSTONE_TORCH = 487; + public static final int REDSTONE_WALL_TORCH = 488; + public static final int REDSTONE_WIRE = 489; + public static final int REPEATER = 490; + public static final int REPEATING_COMMAND_BLOCK = 491; + public static final int ROSE_BUSH = 492; + public static final int SAND = 493; + public static final int SANDSTONE = 494; + public static final int SANDSTONE_SLAB = 495; + public static final int SANDSTONE_STAIRS = 496; + public static final int SEA_LANTERN = 497; + public static final int SEA_PICKLE = 498; + public static final int SEAGRASS = 499; + public static final int SHULKER_BOX = 500; + public static final int SIGN = 501; + public static final int SKELETON_SKULL = 502; + public static final int SKELETON_WALL_SKULL = 503; + public static final int SLIME_BLOCK = 504; + public static final int SMOOTH_QUARTZ = 505; + public static final int SMOOTH_RED_SANDSTONE = 506; + public static final int SMOOTH_SANDSTONE = 507; + public static final int SMOOTH_STONE = 508; + public static final int SNOW = 509; + public static final int SNOW_BLOCK = 510; + public static final int SOUL_SAND = 511; + public static final int SPAWNER = 512; + public static final int SPONGE = 513; + public static final int SPRUCE_BUTTON = 514; + public static final int SPRUCE_DOOR = 515; + public static final int SPRUCE_FENCE = 516; + public static final int SPRUCE_FENCE_GATE = 517; + public static final int SPRUCE_LEAVES = 518; + public static final int SPRUCE_LOG = 519; + public static final int SPRUCE_PLANKS = 520; + public static final int SPRUCE_PRESSURE_PLATE = 521; + public static final int SPRUCE_SAPLING = 522; + public static final int SPRUCE_SLAB = 523; + public static final int SPRUCE_STAIRS = 524; + public static final int SPRUCE_TRAPDOOR = 525; + public static final int SPRUCE_WOOD = 526; + public static final int STICKY_PISTON = 527; + public static final int STONE = 528; + public static final int STONE_BRICK_SLAB = 529; + public static final int STONE_BRICK_STAIRS = 530; + public static final int STONE_BRICKS = 531; + public static final int STONE_BUTTON = 532; + public static final int STONE_PRESSURE_PLATE = 533; + public static final int STONE_SLAB = 534; + public static final int STRIPPED_ACACIA_LOG = 535; + public static final int STRIPPED_ACACIA_WOOD = 536; + public static final int STRIPPED_BIRCH_LOG = 537; + public static final int STRIPPED_BIRCH_WOOD = 538; + public static final int STRIPPED_DARK_OAK_LOG = 539; + public static final int STRIPPED_DARK_OAK_WOOD = 540; + public static final int STRIPPED_JUNGLE_LOG = 541; + public static final int STRIPPED_JUNGLE_WOOD = 542; + public static final int STRIPPED_OAK_LOG = 543; + public static final int STRIPPED_OAK_WOOD = 544; + public static final int STRIPPED_SPRUCE_LOG = 545; + public static final int STRIPPED_SPRUCE_WOOD = 546; + public static final int STRUCTURE_BLOCK = 547; + public static final int STRUCTURE_VOID = 548; + public static final int SUGAR_CANE = 549; + public static final int SUNFLOWER = 550; + public static final int TALL_GRASS = 551; + public static final int TALL_SEAGRASS = 552; + public static final int TERRACOTTA = 553; + public static final int TNT = 554; + public static final int TORCH = 555; + public static final int TRAPPED_CHEST = 556; + public static final int TRIPWIRE = 557; + public static final int TRIPWIRE_HOOK = 558; + public static final int TUBE_CORAL = 559; + public static final int TUBE_CORAL_BLOCK = 560; + public static final int TUBE_CORAL_FAN = 561; + public static final int TUBE_CORAL_WALL_FAN = 562; + public static final int TURTLE_EGG = 563; + public static final int VINE = 564; public static final int WALL_SIGN = 565; public static final int WALL_TORCH = 566; public static final int WATER = 567; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java index a157b2cbe..7d2c77a73 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java @@ -62,6 +62,10 @@ import java.util.stream.Stream; public final class BlockTypes { // Doesn't really matter what the hardcoded values are, as FAWE will update it on load @Nullable public static final BlockType __RESERVED__ = null; + @Nullable public static final BlockType AIR = null; + @Nullable public static final BlockType CAVE_AIR = null; + @Nullable public static final BlockType VOID_AIR = null; + @Nullable public static final BlockType ACACIA_BUTTON = null; @Nullable public static final BlockType ACACIA_DOOR = null; @Nullable public static final BlockType ACACIA_FENCE = null; @@ -76,7 +80,6 @@ public final class BlockTypes { @Nullable public static final BlockType ACACIA_TRAPDOOR = null; @Nullable public static final BlockType ACACIA_WOOD = null; @Nullable public static final BlockType ACTIVATOR_RAIL = null; - @Nullable public static final BlockType AIR = null; @Nullable public static final BlockType ALLIUM = null; @Nullable public static final BlockType ANDESITE = null; @Nullable public static final BlockType ANVIL = null; @@ -160,7 +163,6 @@ public final class BlockTypes { @Nullable public static final BlockType CARROTS = null; @Nullable public static final BlockType CARVED_PUMPKIN = null; @Nullable public static final BlockType CAULDRON = null; - @Nullable public static final BlockType CAVE_AIR = null; @Nullable public static final BlockType CHAIN_COMMAND_BLOCK = null; @Nullable public static final BlockType CHEST = null; @Nullable public static final BlockType CHIPPED_ANVIL = null; @@ -625,7 +627,6 @@ public final class BlockTypes { @Nullable public static final BlockType TUBE_CORAL_WALL_FAN = null; @Nullable public static final BlockType TURTLE_EGG = null; @Nullable public static final BlockType VINE = null; - @Nullable public static final BlockType VOID_AIR = null; @Nullable public static final BlockType WALL_SIGN = null; @Nullable public static final BlockType WALL_TORCH = null; @Nullable public static final BlockType WATER = null;