Feature/propagate diff and object cleanup (#1190)

* Feature/main/propagate diff annotations (#1187)

* 25% done

* More work

* More work

* 50%

* More work

* 75%

* 100% & cleanup

* Update adapters

* Squish squash, applesauce

commit 275ba9bd84
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Sat Jul 17 01:10:20 2021 +0200

    Update dependency com.comphenix.protocol:ProtocolLib to v4.7.0 (#1173)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>

commit 9fd8984804
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Sat Jul 17 01:09:29 2021 +0200

    Update dependency org.checkerframework:checker-qual to v3.16.0 (#1184)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>

commit 861fb45e5c
Author: dordsor21 <dordsor21@gmail.com>
Date:   Fri Jul 16 19:07:02 2021 +0100

    Fix #1075

commit 420c45a29a
Author: dordsor21 <dordsor21@gmail.com>
Date:   Fri Jul 16 18:48:21 2021 +0100

    Entity removal should be on the main thread as we're just passing through rather than doing chunk operations
     - Fixes #1164
     - Not working: butcher/remove history

commit 4d4db7dcd0
Author: SirYwell <hannesgreule@outlook.de>
Date:   Fri Jul 16 17:52:44 2021 +0200

    Make sure leaves category is loaded for heightmaps (fixes #1176)

commit c98f6e4f37
Author: dordsor21 <dordsor21@gmail.com>
Date:   Fri Jul 16 10:44:52 2021 +0100

    Do not allow generation commands to generate outside selection

commit 2485f5eccc
Author: dordsor21 <dordsor21@gmail.com>
Date:   Fri Jul 16 10:43:15 2021 +0100

    EditSession needs to override some Extent methods to ensure block changes are correctly set through the various extents
    Fixes #1152

commit d9418ec8ae
Author: dordsor21 <dordsor21@gmail.com>
Date:   Fri Jul 16 09:52:44 2021 +0100

    Undo part of 41073bb1a0
    Fixes #1178

* Update Upstream

fb1fb84 Fixed typo and grammar

* We don't support custom heights yet

* Casing inconsistency

* Address a few comments

* Address comments

* Don't refactor to AP classpath

* Document annotation style

* Refactoring & shade cleanup

* Address a few comments

* More work

* Resolve comments not being resolved yet

* Feature/main/propagate diff annotations (#1187) (#1194)

* Remove beta package, fix history packages, move classes out of object package

* Resolve comments not being resolved yet

* Remove beta package, fix history packages, move classes out of object package

Co-authored-by: NotMyFault <mc.cache@web.de>

* brushes should be under brush

* More refactoring
 - Filters/processors should be in the same place and are related to extents
 - Transforms are in `extent.transform` in upstream

* Move history classes under history

* Update adapters

Co-authored-by: dordsor21 <dordsor21@gmail.com>
This commit is contained in:
NotMyFault
2021-07-23 17:48:51 +02:00
committed by GitHub
parent ad102ab7a9
commit 50ab8ad5c7
799 changed files with 4916 additions and 10589 deletions

View File

@ -23,7 +23,7 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
import com.fastasyncworldedit.core.function.mask.BlockMaskBuilder;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.math.BlockVector2;
@ -76,7 +76,9 @@ public abstract class AbstractWorld implements World {
@Override
public Mask createLiquidMask() {
//FAWE start - use BlockMaskBuilder
return new BlockMaskBuilder().addTypes(BlockTypes.LAVA, BlockTypes.WATER).build(this);
//FAWE end
}
@Override

View File

@ -43,9 +43,12 @@ public interface NbtValued {
*/
@Deprecated
default boolean hasNbtData() {
//FAWE start - return & deprecation
return getNbt() != null;
//FAWE end
}
//FAWE start
/**
* Get the object's NBT data (tile entity data). The returned tag, if
* modified in any way, should be sent to {@link #setNbtData(CompoundTag)}
@ -139,5 +142,6 @@ public interface NbtValued {
default void setNbt(@Nullable CompoundBinaryTag nbtData) {
setNbtReference(nbtData == null ? null : LazyReference.computed(nbtData));
}
//FAWE end
}

View File

@ -19,9 +19,9 @@
package com.sk89q.worldedit.world;
import com.fastasyncworldedit.core.beta.IChunkGet;
import com.fastasyncworldedit.core.beta.implementation.blocks.NullChunkGet;
import com.fastasyncworldedit.core.beta.implementation.packet.ChunkPacket;
import com.fastasyncworldedit.core.queue.IChunkGet;
import com.fastasyncworldedit.core.queue.implementation.blocks.NullChunkGet;
import com.fastasyncworldedit.core.queue.implementation.packet.ChunkPacket;
import com.google.common.collect.ImmutableSet;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession;
@ -160,6 +160,7 @@ public class NullWorld extends AbstractWorld {
return BlockVector3.ZERO;
}
//FAWE start
@Override
public void refreshChunk(int chunkX, int chunkZ) {
@ -169,6 +170,7 @@ public class NullWorld extends AbstractWorld {
public IChunkGet get(int x, int z) {
return NullChunkGet.getInstance();
}
//FAWE end
@Override
public BlockState getBlock(BlockVector3 position) {
@ -190,10 +192,12 @@ public class NullWorld extends AbstractWorld {
return false;
}
//FAWE start
@Override
public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException {
return false;
}
//FAWE end
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
@ -225,6 +229,7 @@ public class NullWorld extends AbstractWorld {
return INSTANCE;
}
//FAWE start
@Override
public void sendFakeChunk(@Nullable Player player, ChunkPacket packet) {
}
@ -236,4 +241,5 @@ public class NullWorld extends AbstractWorld {
@Override
public void flush() {}
//FAWE end
}

View File

@ -39,7 +39,9 @@ public abstract class RegenOptions {
* @return the builder
*/
public static Builder builder() {
//FAWE start - biomeType
return new AutoValue_RegenOptions.Builder().seed(OptionalLong.empty()).regenBiomes(false).biomeType(null);
//FAWE end
}
@AutoValue.Builder
@ -70,12 +72,14 @@ public abstract class RegenOptions {
*/
public abstract Builder regenBiomes(boolean regenBiomes);
//FAWE start
/**
* Defines the {@code BiomeType} the regenerator should use for regeneration. Defaults to {@code null}.
* @param biomeType the {@code BiomeType} to be used for regeneration
* @return this builder
*/
public abstract Builder biomeType(@Nullable BiomeType biomeType);
//FAWE end
/**
* Build the options object.
@ -107,10 +111,12 @@ public abstract class RegenOptions {
return isRegenBiomes();
}
//FAWE start
@Nullable public abstract BiomeType getBiomeType();
public boolean hasBiomeType() {
return getBiomeType() != null;
}
//FAWE end
}

View File

@ -1,158 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General default License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General default License
* for more details.
*
* You should have received a copy of the GNU Lesser General default License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.world;
import com.fastasyncworldedit.core.Fawe;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.weather.WeatherType;
import com.sk89q.worldedit.world.weather.WeatherTypes;
import java.nio.file.Path;
import java.util.function.Supplier;
import javax.annotation.Nullable;
/**
* An abstract implementation of {@link World}.
* Added by FAWE.
*/
public interface SimpleWorld extends World {
@Override
default boolean useItem(BlockVector3 position, BaseItem item, Direction face) {
return false;
}
@Override
default <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException {
return setBlock(position, block);
}
@Override
default BaseBlock getFullBlock(BlockVector3 position) {
return getBlock(position).toBaseBlock();
}
@Override
<B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 pt, B block) throws WorldEditException;
@Nullable @Override default Path getStoragePath() {
return null;
}
@Override
default int getMaxY() {
return getMaximumPoint().getBlockY();
}
@Override
default Mask createLiquidMask() {
return new BlockMask(this).add(BlockTypes.LAVA, BlockTypes.WATER);
}
@Override
default void dropItem(Vector3 pt, BaseItemStack item, int times) {
for (int i = 0; i < times; ++i) {
dropItem(pt, item);
}
}
@Override
default void checkLoadedChunk(BlockVector3 pt) {
}
@Override
default void fixAfterFastMode(Iterable<BlockVector2> chunks) {
}
@Override
default void fixLighting(Iterable<BlockVector2> chunks) {
}
// @Override
default boolean playEffect(BlockVector3 position, int type, int data) {
return false;
}
@Override
default boolean queueBlockBreakEffect(Platform server, BlockVector3 position, BlockType blockType, double priority) {
Fawe.get().getQueueHandler().sync((Supplier<Boolean>) () -> playEffect(position, 2001, blockType.getLegacyCombinedId() >> 4));
return true;
}
@Override
default BlockVector3 getMinimumPoint() {
return BlockVector3.at(-30000000, 0, -30000000);
}
@Override
default BlockVector3 getMaximumPoint() {
return BlockVector3.at(30000000, 255, 30000000);
}
@Override
default boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException {
return false;
}
@Override
default void simulateBlockMine(BlockVector3 position) {
try {
setBlock(position, BlockTypes.AIR.getDefaultState());
} catch (WorldEditException e) {
throw new RuntimeException(e);
}
}
@Override
default WeatherType getWeather() {
return WeatherTypes.CLEAR;
}
@Override
default long getRemainingWeatherDuration() {
return 0;
}
@Override
default void setWeather(WeatherType weatherType) {
}
@Override
default void setWeather(WeatherType weatherType, long duration) {
}
}

View File

@ -19,9 +19,9 @@
package com.sk89q.worldedit.world;
import com.fastasyncworldedit.core.beta.IChunkCache;
import com.fastasyncworldedit.core.beta.IChunkGet;
import com.fastasyncworldedit.core.beta.implementation.packet.ChunkPacket;
import com.fastasyncworldedit.core.queue.IChunkCache;
import com.fastasyncworldedit.core.queue.IChunkGet;
import com.fastasyncworldedit.core.queue.implementation.packet.ChunkPacket;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEditException;
@ -56,7 +56,9 @@ import javax.annotation.Nullable;
/**
* Represents a world (dimension).
*/
//FAWE start - IChunkCache<IChunkGet>
public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
//FAWE end
/**
* Get the name of the world.
@ -371,6 +373,7 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
@Override
int hashCode();
//FAWE start
@Override
default boolean isWorld() {
return true;
@ -414,4 +417,5 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
}
void flush();
//FAWE end
}

View File

@ -23,12 +23,14 @@ import com.sk89q.worldedit.function.pattern.BiomePattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import com.sk89q.worldedit.registry.RegistryItem;
import com.fastasyncworldedit.core.registry.RegistryItem;
/**
* All the types of biomes in the game.
*/
//FAWE start - RegistryItem
public class BiomeType implements RegistryItem, Keyed, BiomePattern {
//FAWE end
public static final NamespacedRegistry<BiomeType> REGISTRY = new NamespacedRegistry<>("biome type");
@ -36,6 +38,7 @@ public class BiomeType implements RegistryItem, Keyed, BiomePattern {
private int legacyId = -1;
private int internalId;
//FAWE start
public BiomeType(String id) {
this.id = id;
}
@ -57,6 +60,7 @@ public class BiomeType implements RegistryItem, Keyed, BiomePattern {
public int getInternalId() {
return internalId;
}
//FAWE end
/**
* Gets the ID of this biome.
@ -75,7 +79,9 @@ public class BiomeType implements RegistryItem, Keyed, BiomePattern {
@Override
public int hashCode() {
//FAWE start - internalId > hashCode
return this.internalId; // stop changing this
//FAWE end
}
@Override

View File

@ -115,6 +115,15 @@ public final class BiomeTypes {
private BiomeTypes() {
}
/**
* Gets the {@link BiomeType} associated with the given id.
*/
@Nullable
public static BiomeType get(String id) {
return BiomeType.REGISTRY.get(id);
}
//FAWE start
private static BiomeType register(final String id) {
return register(new BiomeType(id));
}
@ -136,14 +145,6 @@ public final class BiomeTypes {
return BiomeType.REGISTRY.getByInternalId(internalId);
}
/**
* Gets the {@link BiomeType} associated with the given id.
*/
@Nullable
public static BiomeType get(String id) {
return BiomeType.REGISTRY.get(id);
}
public static Collection<BiomeType> values() {
return BiomeType.REGISTRY.values();
}
@ -157,4 +158,5 @@ public final class BiomeTypes {
}
return maxBiomeId;
}
//FAWE end
}

View File

@ -27,7 +27,7 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.OutputExtent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.sk89q.worldedit.util.concurrency.LazyReference;
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
import com.sk89q.worldedit.util.nbt.TagStringIO;
@ -54,8 +54,11 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
private final BlockState blockState;
@Nullable
//FAWE start - LR<CBT> instead of CompoundTat
private final LazyReference<CompoundBinaryTag> nbtData;
//FAWE end
//FAWE start
/**
* Construct a block with the given type and default data.
* @deprecated Just use the BlockType.getDefaultState()
@ -65,7 +68,9 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
public BaseBlock(BlockType blockType) {
this(blockType.getDefaultState());
}
//FAWE end
//FAWE start - made public from protected
/**
* Construct a block with a state.
*
@ -75,7 +80,9 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
this.blockState = blockState;
this.nbtData = null;
}
//FAWE end
//FAWE start - deprecated upstream method and replaced CompoundTag with LR
/**
* Construct a block with the given ID, data value and NBT data structure.
*
@ -86,6 +93,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
public BaseBlock(BlockState state, CompoundTag nbtData) {
this(state, LazyReference.from(checkNotNull(nbtData)::asBinaryTag));
}
//FAWE end
/**
@ -100,6 +108,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
this.nbtData = nbtData;
}
//FAWE start
/**
* Construct a block with the given ID and data value.
*
@ -118,6 +127,8 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
}
return blockState;
}
//FAWE end
/**
* Gets a map of state to state values.
*
@ -151,13 +162,16 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
@Override
public String getNbtId() {
//FAWE start - LR<CBT> > CompoundTag
LazyReference<CompoundBinaryTag> nbtData = this.nbtData;
if (nbtData == null) {
return "";
}
return nbtData.getValue().getString("id");
//FAWE end
}
//FAWE start
@Nullable
@Override
public LazyReference<CompoundBinaryTag> getNbtReference() {
@ -168,6 +182,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
public void setNbtReference(@Nullable LazyReference<CompoundBinaryTag> nbtData) {
throw new UnsupportedOperationException("This class is immutable.");
}
//FAWE end
/**
* Checks whether the type ID and data value are equal.
@ -186,6 +201,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
return this.blockState.equalsFuzzy(otherBlock.blockState) && Objects.equals(getNbt(), otherBlock.getNbt());
}
//FAWE start
@Override
public int getInternalId() {
return blockState.getInternalId();
@ -201,6 +217,12 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
return blockState.getOrdinal();
}
@Override
public final char getOrdinalChar() {
return blockState.getOrdinalChar();
}
//FAWE end
/**
* Checks if the type is the same, and if the matched states are the same.
*
@ -217,16 +239,12 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
return this.blockState;
}
@Override
public final char getOrdinalChar() {
return blockState.getOrdinalChar();
}
@Override
public BaseBlock toBaseBlock() {
return this;
}
//FAWE start
@Override
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
set.setFullBlock(extent, this);
@ -277,16 +295,16 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
return toImmutableState().getState(property);
}
// Fawe start
@Override
public int hashCode() {
return getOrdinal();
}
// Fawe end
//FAWE end
@Override
public String toString() {
String nbtString = "";
//FAWE start - use CBT
CompoundBinaryTag nbtData = getNbt();
if (nbtData != null) {
try {
@ -302,4 +320,5 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
public BlockState toBlockState() {
return blockState;
}
//FAWE end
}

View File

@ -1,26 +0,0 @@
package com.sk89q.worldedit.world.block;
import com.sk89q.jnbt.CompoundTag;
import org.jetbrains.annotations.NotNull;
/**
* BaseBlock that when parsed to masks represents all BlockStates of a BlockType, whilst allowing for NBT storage
*/
public final class BlanketBaseBlock extends BaseBlock {
public BlanketBaseBlock(BlockState blockState) {
super(blockState);
}
public BlanketBaseBlock(BlockState blockState, @NotNull CompoundTag tile) {
super(blockState, tile);
}
@Override
public BaseBlock toBaseBlock(CompoundTag compoundTag) {
if (compoundTag != null) {
return new BaseBlock(this.toImmutableState(), compoundTag);
}
return this;
}
}

View File

@ -156,7 +156,9 @@ public final class BlockCategories {
BlockCategory entry = BlockCategory.REGISTRY.get(id);
if (entry == null) {
BlockCategory blockCategory = new BlockCategory(id);
//FAWE start
blockCategory.load();
//FAWE end
return blockCategory;
}
return entry;

View File

@ -32,7 +32,9 @@ import java.util.Set;
* blocks such as wool into separate ids.
*/
public class BlockCategory extends Category<BlockType> implements Keyed {
private boolean[] flat_map;
//FAWE start
private boolean[] flatMap;
//FAWE end
public static final NamespacedRegistry<BlockCategory> REGISTRY = new NamespacedRegistry<>("block tag");
public BlockCategory(final String id) {
@ -45,15 +47,17 @@ public class BlockCategory extends Category<BlockType> implements Keyed {
.queryCapability(Capability.GAME_HOOKS).getRegistries()
.getBlockCategoryRegistry().getAll(this);
//FAWE start
int max = -1;
for (BlockType type : result) {
max = Math.max(max, type.getInternalId());
}
this.flat_map = new boolean[max + 1];
this.flatMap = new boolean[max + 1];
for (BlockType type : result) {
this.flat_map[type.getInternalId()] = true;
this.flatMap[type.getInternalId()] = true;
}
return result;
//FAWE end
}
/**
@ -64,7 +68,9 @@ public class BlockCategory extends Category<BlockType> implements Keyed {
* @return If it's a part of this category
*/
public <B extends BlockStateHolder<B>> boolean contains(B blockStateHolder) {
//FAWE start - use internal id
int typeId = blockStateHolder.getBlockType().getInternalId();
return flat_map.length > typeId && flat_map[typeId];
return flatMap.length > typeId && flatMap[typeId];
//FAWE end
}
}

View File

@ -1,688 +0,0 @@
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 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_SIGN = 501;
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_WALL_SIGN = 565;
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 ANDESITE_SLAB = 599;
public static final int ANDESITE_STAIRS = 600;
public static final int ANDESITE_WALL = 601;
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 BAMBOO = 602;
public static final int BAMBOO_SAPLING = 603;
public static final int BARREL = 604;
public static final int BARRIER = 24;
public static final int BEACON = 25;
public static final int BEDROCK = 26;
public static final int BEE_NEST = 677;
public static final int BEEHIVE = 678; // highest
public static final int BEETROOTS = 27;
public static final int BELL = 605;
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_SIGN = 606;
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_WALL_SIGN = 607;
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 BLAST_FURNACE = 608;
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 BRICK_WALL = 609;
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 CAMPFIRE = 610;
public static final int CARROTS = 98;
public static final int CARTOGRAPHY_TABLE = 611;
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 COMPOSTER = 612;
public static final int CONDUIT = 122;
public static final int CORNFLOWER = 613;
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_RED_SANDSTONE_SLAB = 614;
public static final int CUT_SANDSTONE = 128;
public static final int CUT_SANDSTONE_SLAB = 615;
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_SIGN = 616;
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_WALL_SIGN = 617;
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 DIORITE_SLAB = 618;
public static final int DIORITE_STAIRS = 619;
public static final int DIORITE_WALL = 620;
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_BRICK_SLAB = 621;
public static final int END_STONE_BRICK_STAIRS = 622;
public static final int END_STONE_BRICK_WALL = 623;
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 FLETCHING_TABLE = 624;
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 GRANITE_SLAB = 625;
public static final int GRANITE_STAIRS = 626;
public static final int GRANITE_WALL = 627;
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 GRINDSTONE = 628;
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 JIGSAW = 629;
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_SIGN = 630;
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_WALL_SIGN = 631;
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 LANTERN = 632;
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 LECTERN = 633;
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_OF_THE_VALLEY = 634;
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 LOOM = 635;
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_SLAB = 636;
public static final int MOSSY_COBBLESTONE_STAIRS = 637;
public static final int MOSSY_COBBLESTONE_WALL = 343;
public static final int MOSSY_STONE_BRICK_SLAB = 638;
public static final int MOSSY_STONE_BRICK_STAIRS = 639;
public static final int MOSSY_STONE_BRICK_WALL = 640;
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_BRICK_WALL = 641;
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_SIGN = 642;
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_WALL_SIGN = 643;
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_ANDESITE_SLAB = 644;
public static final int POLISHED_ANDESITE_STAIRS = 645;
public static final int POLISHED_DIORITE = 409;
public static final int POLISHED_DIORITE_SLAB = 646;
public static final int POLISHED_DIORITE_STAIRS = 647;
public static final int POLISHED_GRANITE = 410;
public static final int POLISHED_GRANITE_SLAB = 648;
public static final int POLISHED_GRANITE_STAIRS = 649;
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_BAMBOO = 650;
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_CORNFLOWER = 651;
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_LILY_OF_THE_VALLEY = 652;
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 POTTED_WITHER_ROSE = 653;
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 PRISMARINE_WALL = 654;
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_BRICK_SLAB = 655;
public static final int RED_NETHER_BRICK_STAIRS = 656;
public static final int RED_NETHER_BRICK_WALL = 657;
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_SANDSTONE_WALL = 658;
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 SANDSTONE_WALL = 659;
public static final int SCAFFOLDING = 660;
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 SKELETON_SKULL = 502;
public static final int SKELETON_WALL_SKULL = 503;
public static final int SLIME_BLOCK = 504;
public static final int SMITHING_TABLE = 661;
public static final int SMOKER = 662;
public static final int SMOOTH_QUARTZ = 505;
public static final int SMOOTH_QUARTZ_SLAB = 663;
public static final int SMOOTH_QUARTZ_STAIRS = 664;
public static final int SMOOTH_RED_SANDSTONE = 506;
public static final int SMOOTH_RED_SANDSTONE_SLAB = 665;
public static final int SMOOTH_RED_SANDSTONE_STAIRS = 666;
public static final int SMOOTH_SANDSTONE = 507;
public static final int SMOOTH_SANDSTONE_SLAB = 667;
public static final int SMOOTH_SANDSTONE_STAIRS = 668;
public static final int SMOOTH_STONE = 508;
public static final int SMOOTH_STONE_SLAB = 669;
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_SIGN = 670;
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_WALL_SIGN = 671;
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_BRICK_WALL = 672;
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 STONE_STAIRS = 673;
public static final int STONECUTTER = 674;
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 SWEET_BERRY_BUSH = 675;
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_TORCH = 566;
public static final int WATER = 567;
public static final int WET_SPONGE = 568;
public static final int WHEAT = 569;
public static final int WHITE_BANNER = 570;
public static final int WHITE_BED = 571;
public static final int WHITE_CARPET = 572;
public static final int WHITE_CONCRETE = 573;
public static final int WHITE_CONCRETE_POWDER = 574;
public static final int WHITE_GLAZED_TERRACOTTA = 575;
public static final int WHITE_SHULKER_BOX = 576;
public static final int WHITE_STAINED_GLASS = 577;
public static final int WHITE_STAINED_GLASS_PANE = 578;
public static final int WHITE_TERRACOTTA = 579;
public static final int WHITE_TULIP = 580;
public static final int WHITE_WALL_BANNER = 581;
public static final int WHITE_WOOL = 582;
public static final int WITHER_ROSE = 676;
public static final int WITHER_SKELETON_SKULL = 583;
public static final int WITHER_SKELETON_WALL_SKULL = 584;
public static final int YELLOW_BANNER = 585;
public static final int YELLOW_BED = 586;
public static final int YELLOW_CARPET = 587;
public static final int YELLOW_CONCRETE = 588;
public static final int YELLOW_CONCRETE_POWDER = 589;
public static final int YELLOW_GLAZED_TERRACOTTA = 590;
public static final int YELLOW_SHULKER_BOX = 591;
public static final int YELLOW_STAINED_GLASS = 592;
public static final int YELLOW_STAINED_GLASS_PANE = 593;
public static final int YELLOW_TERRACOTTA = 594;
public static final int YELLOW_WALL_BANNER = 595;
public static final int YELLOW_WOOL = 596;
public static final int ZOMBIE_HEAD = 597;
public static final int ZOMBIE_WALL_HEAD = 598;
// Deprecated
public static final int SIGN = OAK_SIGN;
public static final int WALL_SIGN = OAK_WALL_SIGN;
}

View File

@ -19,10 +19,12 @@
package com.sk89q.worldedit.world.block;
import com.fastasyncworldedit.core.beta.ITileInput;
import com.fastasyncworldedit.core.queue.ITileInput;
import com.fastasyncworldedit.core.command.SuggestInputParseException;
import com.fastasyncworldedit.core.object.string.MutableCharSequence;
import com.fastasyncworldedit.core.util.MutableCharSequence;
import com.fastasyncworldedit.core.util.StringMan;
import com.fastasyncworldedit.core.world.block.BlanketBaseBlock;
import com.fastasyncworldedit.core.world.block.CompoundInput;
import com.google.common.base.Function;
import com.google.common.collect.Maps;
import com.sk89q.jnbt.CompoundTag;
@ -34,12 +36,12 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.NullExtent;
import com.sk89q.worldedit.extent.OutputExtent;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.SingleBlockStateMask;
import com.fastasyncworldedit.core.function.mask.SingleBlockStateMask;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.AbstractProperty;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.sk89q.worldedit.util.concurrency.LazyReference;
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
import com.sk89q.worldedit.world.registry.BlockMaterial;
@ -57,15 +59,19 @@ import javax.annotation.Nullable;
*/
@SuppressWarnings("unchecked")
public class BlockState implements BlockStateHolder<BlockState>, Pattern {
//FAWE start
private final int internalId;
private final int ordinal;
private final char ordinalChar;
private final BlockType blockType;
private BlockMaterial material;
private final BaseBlock emptyBaseBlock;
private CompoundInput compoundInput = CompoundInput.NULL;
//FAWE end
private final BlockType blockType;
protected BlockState(BlockType blockType, int internalId, int ordinal) {
//FAWE start
public BlockState(BlockType blockType, int internalId, int ordinal) {
this.blockType = blockType;
this.internalId = internalId;
this.ordinal = ordinal;
@ -73,7 +79,7 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
this.emptyBaseBlock = new BlanketBaseBlock(this);
}
protected BlockState(BlockType blockType, int internalId, int ordinal, @NotNull CompoundTag tile) {
public BlockState(BlockType blockType, int internalId, int ordinal, @NotNull CompoundTag tile) {
this.blockType = blockType;
this.internalId = internalId;
this.ordinal = ordinal;
@ -329,6 +335,7 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
Map<? extends Property, Object> map = Maps.asMap(type.getPropertiesSet(), (Function<Property, Object>) this::getState);
return Collections.unmodifiableMap((Map<Property<?>, Object>) map);
}
//FAWE end
@Override
public boolean equalsFuzzy(BlockStateHolder<?> o) {
@ -361,11 +368,13 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
return getState(getBlockType().getProperty(key));
}
//FAWE start
@Deprecated
@Override
public CompoundTag getNbtData() {
return getBlockType().getMaterial().isTile() ? getBlockType().getMaterial().getDefaultTile() : null;
}
//FAWE end
@Override
public BaseBlock toBaseBlock(LazyReference<CompoundBinaryTag> compoundTag) {
@ -375,6 +384,7 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
return new BaseBlock(this, compoundTag);
}
//FAWE start
@Override
public int getInternalId() {
return internalId;
@ -431,4 +441,5 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
public BaseBlock toBaseBlock(ITileInput input, int x, int y, int z) {
return compoundInput.get(this, input, x, y, z);
}
//FAWE end
}

View File

@ -19,7 +19,7 @@
package com.sk89q.worldedit.world.block;
import com.fastasyncworldedit.core.beta.ITileInput;
import com.fastasyncworldedit.core.queue.ITileInput;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.blocks.TileEntityBlock;
import com.sk89q.worldedit.extent.OutputExtent;
@ -28,7 +28,7 @@ import com.sk89q.worldedit.internal.util.DeprecationUtil;
import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.sk89q.worldedit.util.concurrency.LazyReference;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
@ -37,7 +37,9 @@ import java.util.Locale;
import java.util.Map;
import java.util.stream.Collectors;
//FAWE start - TileEntityBlock
public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEntityBlock, Pattern {
//FAWE end
/**
* Get the block type.
@ -46,6 +48,7 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEnt
*/
BlockType getBlockType();
//FAWE start
/**
* Magic number (legacy uses).
*/
@ -77,6 +80,7 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEnt
*/
@Deprecated
int getInternalPropertiesId();
//FAWE end
/**
* Returns a BlockState with the given state and value applied.
@ -141,6 +145,7 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEnt
*/
BaseBlock toBaseBlock();
//FAWE start
/**
* Gets a {@link BaseBlock} from this BlockStateHolder.
*
@ -191,6 +196,7 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEnt
default BaseBlock toBaseBlock(ITileInput input, int x, int y, int z) {
throw new UnsupportedOperationException("State is immutable");
}
//FAWE end
default String getAsString() {
if (getStates().isEmpty()) {

View File

@ -24,7 +24,7 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.NullExtent;
import com.sk89q.worldedit.function.mask.SingleBlockTypeMask;
import com.fastasyncworldedit.core.function.mask.SingleBlockTypeMask;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
import com.sk89q.worldedit.math.BlockVector3;
@ -32,7 +32,7 @@ import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import com.sk89q.worldedit.registry.state.AbstractProperty;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.sk89q.worldedit.util.concurrency.LazyReference;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.world.item.ItemType;
@ -52,7 +52,9 @@ import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkArgument;
//FAWE start - Pattern
public class BlockType implements Keyed, Pattern {
//FAWE end
public static final NamespacedRegistry<BlockType> REGISTRY = new NamespacedRegistry<>("block type");
private static final Logger LOGGER = LogManagerCompat.getLogger();
@ -62,6 +64,7 @@ public class BlockType implements Keyed, Pattern {
private final LazyReference<FuzzyBlockState> emptyFuzzy
= LazyReference.from(() -> new FuzzyBlockState(this));
//FAWE start
private final LazyReference<Integer> legacyId = LazyReference.from(() -> computeLegacy(0));
private final LazyReference<Integer> legacyData = LazyReference.from(() -> computeLegacy(1));
@ -89,6 +92,7 @@ public class BlockType implements Keyed, Pattern {
public int getMaxStateId() {
return settings.permutations;
}
//FAWE end
/**
* Gets the ID of this block.
@ -105,6 +109,7 @@ public class BlockType implements Keyed, Pattern {
.getRegistries().getBlockRegistry().getRichName(this);
}
//FAWE start
public String getNamespace() {
String id = getId();
int i = id.indexOf(':');
@ -137,6 +142,7 @@ public class BlockType implements Keyed, Pattern {
return defaultState;
}
*/
@Deprecated
public BlockState withPropertyId(int propertyId) {
if (settings.stateOrdinals == null) {
@ -157,6 +163,7 @@ public class BlockType implements Keyed, Pattern {
public BlockState withStateId(int internalStateId) { //
return this.withPropertyId(internalStateId >> BlockTypesCache.BIT_OFFSET);
}
//FAWE end
/**
* Gets the properties of this BlockType in a {@code key->property} mapping.
@ -173,13 +180,17 @@ public class BlockType implements Keyed, Pattern {
* @return the properties
*/
public List<? extends Property<?>> getProperties() {
return this.settings.propertiesList; // stop changing this
//FAWE start - Don't use an ImmutableList here
return this.settings.propertiesList;
//FAWE end
}
//FAWE start
@Deprecated
public Set<? extends Property<?>> getPropertiesSet() {
return this.settings.propertiesSet;
}
//FAWE end
/**
* Gets a property by name.
@ -188,9 +199,12 @@ public class BlockType implements Keyed, Pattern {
* @return The property
*/
public <V> Property<V> getProperty(String name) {
return (Property<V>) this.settings.propertiesMap.get(name); // stop changing this (performance)
//FAWE start - use properties map
return (Property<V>) this.settings.propertiesMap.get(name);
//FAWE end
}
//FAWE start
public boolean hasProperty(PropertyKey key) {
int ordinal = key.getId();
return this.settings.propertiesMapArr.length > ordinal && this.settings.propertiesMapArr[ordinal] != null;
@ -203,6 +217,7 @@ public class BlockType implements Keyed, Pattern {
return null;
}
}
//FAWE end
/**
* Gets the default state of this block type.
@ -210,7 +225,9 @@ public class BlockType implements Keyed, Pattern {
* @return The default state
*/
public BlockState getDefaultState() {
//FAWE start - use settings
return this.settings.defaultState;
//FAWE end
}
public FuzzyBlockState getFuzzyMatcher() {
@ -223,10 +240,12 @@ public class BlockType implements Keyed, Pattern {
* @return All possible states
*/
public List<BlockState> getAllStates() {
//FAWE start - use ordinals
if (settings.stateOrdinals == null) {
return Collections.singletonList(getDefaultState());
}
return IntStream.of(settings.stateOrdinals).filter(i -> i != -1).mapToObj(i -> BlockTypesCache.states[i]).collect(Collectors.toList());
//FAWE end
}
/**
@ -234,7 +253,8 @@ public class BlockType implements Keyed, Pattern {
*
* @return The state, if it exists
*/
public BlockState getState(Map<Property<?>, Object> key) { //
public BlockState getState(Map<Property<?>, Object> key) {
//FAWE start - use ids & btp (block type property)
int id = getInternalId();
for (Map.Entry<Property<?>, Object> iter : key.entrySet()) {
Property<?> prop = iter.getKey();
@ -250,6 +270,7 @@ public class BlockType implements Keyed, Pattern {
id = btp.modify(id, btp.getValueFor((String) value));
}
return withStateId(id);
//FAWE end
}
/**
@ -268,11 +289,13 @@ public class BlockType implements Keyed, Pattern {
*/
@Nullable
public ItemType getItemType() {
//FAWE start - init this
if (!initItemType) {
initItemType = true;
itemType = ItemTypes.get(this.id);
}
return itemType;
//FAWE end
}
/**
@ -281,7 +304,9 @@ public class BlockType implements Keyed, Pattern {
* @return The material
*/
public BlockMaterial getMaterial() {
//FAWE start - use settings
return this.settings.blockMaterial;
//FAWE end
}
/**
@ -293,8 +318,10 @@ public class BlockType implements Keyed, Pattern {
*/
@Deprecated
public int getLegacyCombinedId() {
//FAWE start - use LegacyMapper
Integer combinedId = LegacyMapper.getInstance().getLegacyCombined(this);
return combinedId == null ? 0 : combinedId;
//FAWE end
}
/**
@ -306,7 +333,9 @@ public class BlockType implements Keyed, Pattern {
*/
@Deprecated
public int getLegacyId() {
//FAWE start
return computeLegacy(0);
//FAWE end
}
/**
@ -320,16 +349,21 @@ public class BlockType implements Keyed, Pattern {
*/
@Deprecated
public int getLegacyData() {
//FAWE start
return computeLegacy(1);
//FAWE end
}
private int computeLegacy(int index) {
//FAWE start
if (this.legacyCombinedId == null) {
this.legacyCombinedId = LegacyMapper.getInstance().getLegacyCombined(this.getDefaultState());
}
return index == 0 ? legacyCombinedId >> 4 : legacyCombinedId & 15;
//FAWE end
}
//FAWE start
/**
* The internal index of this type.
*
@ -375,4 +409,5 @@ public class BlockType implements Keyed, Pattern {
public SingleBlockTypeMask toMask(Extent extent) {
return new SingleBlockTypeMask(extent, this);
}
//FAWE end
}

View File

@ -1,15 +0,0 @@
package com.sk89q.worldedit.world.block;
import java.util.function.Function;
public class BlockTypeSwitch<T> implements Function<BlockType, T> {
private final T[] tasks;
protected BlockTypeSwitch(T[] tasks) {
this.tasks = tasks;
}
@Override
public T apply(BlockType blockType) {
return this.tasks[blockType.getInternalId()];
}
}

View File

@ -1,41 +0,0 @@
package com.sk89q.worldedit.world.block;
import java.util.function.Predicate;
public class BlockTypeSwitchBuilder<T> {
private final Object[] runnables;
private T defaultTask;
public BlockTypeSwitchBuilder(T defaultTask) {
this.runnables = new Object[BlockTypes.size()];
this.defaultTask = defaultTask;
}
public BlockTypeSwitchBuilder<T> add(BlockType type, T task) {
this.runnables[type.getInternalId()] = task;
return this;
}
public BlockTypeSwitchBuilder<T> add(Predicate<BlockType> predicate, T task) {
for (BlockType type : BlockTypesCache.values) {
if (predicate.test(type)) {
this.runnables[type.getInternalId()] = task;
}
}
return this;
}
public BlockTypeSwitchBuilder<T> setDefaultTask(T defaultTask) {
this.defaultTask = defaultTask;
return this;
}
public BlockTypeSwitch<T> build() {
for (int i = 0; i < runnables.length; i++) {
if (runnables[i] == null) {
runnables[i] = defaultTask;
}
}
return new BlockTypeSwitch(runnables);
}
}

View File

@ -1,242 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.world.block;
import com.sk89q.worldedit.registry.state.PropertyGroup;
import com.sk89q.worldedit.registry.state.PropertyKey;
import static com.google.common.base.Preconditions.checkNotNull;
public class BlockTypeUtil {
public static double centralTopLimit(com.sk89q.worldedit.world.block.BlockType type) {
checkNotNull(type);
return centralTopLimit(type.getDefaultState());
}
public static double centralBottomLimit(BlockStateHolder block) {
checkNotNull(block);
BlockType type = block.getBlockType();
switch (type.getInternalId()) {
case BlockID.CREEPER_WALL_HEAD:
case BlockID.DRAGON_WALL_HEAD:
case BlockID.PLAYER_WALL_HEAD:
case BlockID.ZOMBIE_WALL_HEAD:
return 0.25;
case BlockID.ACACIA_SLAB:
case BlockID.BIRCH_SLAB:
case BlockID.BRICK_SLAB:
case BlockID.COBBLESTONE_SLAB:
case BlockID.DARK_OAK_SLAB:
case BlockID.DARK_PRISMARINE_SLAB:
case BlockID.JUNGLE_SLAB:
case BlockID.NETHER_BRICK_SLAB:
case BlockID.OAK_SLAB:
case BlockID.PETRIFIED_OAK_SLAB:
case BlockID.PRISMARINE_BRICK_SLAB:
case BlockID.PRISMARINE_SLAB:
case BlockID.PURPUR_SLAB:
case BlockID.QUARTZ_SLAB:
case BlockID.RED_SANDSTONE_SLAB:
case BlockID.SANDSTONE_SLAB:
case BlockID.SPRUCE_SLAB:
case BlockID.STONE_BRICK_SLAB:
case BlockID.STONE_SLAB: {
String state = (String) block.getState(PropertyKey.TYPE);
if (state == null) {
return 0;
}
switch (state) {
case "top":
return 0.5;
case "double":
case "bottom":
default:
return 0;
}
}
case BlockID.ACACIA_TRAPDOOR:
case BlockID.BIRCH_TRAPDOOR:
case BlockID.DARK_OAK_TRAPDOOR:
case BlockID.IRON_TRAPDOOR:
case BlockID.JUNGLE_TRAPDOOR:
case BlockID.OAK_TRAPDOOR:
case BlockID.SPRUCE_TRAPDOOR:
if (block.getState(PropertyKey.OPEN) == Boolean.TRUE) {
return 1;
} else if ("bottom".equals(block.getState(PropertyKey.HALF))) {
return 0.8125;
} else {
return 0;
}
case BlockID.ACACIA_FENCE_GATE:
case BlockID.BIRCH_FENCE_GATE:
case BlockID.DARK_OAK_FENCE_GATE:
case BlockID.JUNGLE_FENCE_GATE:
case BlockID.OAK_FENCE_GATE:
case BlockID.SPRUCE_FENCE_GATE:
return block.getState(PropertyKey.OPEN) == Boolean.TRUE ? 1 : 0;
default:
if (type.getMaterial().isMovementBlocker()) {
return 0;
}
return 1;
}
}
/**
* Returns the y offset a player falls to when falling onto the top of a block at xp+0.5/zp+0.5.
*
* @param block the block
* @return the y offset
*/
public static double centralTopLimit(BlockStateHolder block) {
checkNotNull(block);
BlockType type = block.getBlockType();
switch (type.getInternalId()) {
case BlockID.BLACK_BED:
case BlockID.BLUE_BED:
case BlockID.BROWN_BED:
case BlockID.CYAN_BED:
case BlockID.GRAY_BED:
case BlockID.GREEN_BED:
case BlockID.LIGHT_BLUE_BED:
case BlockID.LIGHT_GRAY_BED:
case BlockID.LIME_BED:
case BlockID.MAGENTA_BED:
case BlockID.ORANGE_BED:
case BlockID.PINK_BED:
case BlockID.PURPLE_BED:
case BlockID.RED_BED:
case BlockID.WHITE_BED:
case BlockID.YELLOW_BED:
return 0.5625;
case BlockID.BREWING_STAND:
return 0.875;
case BlockID.CAKE:
return (block.getState(PropertyKey.BITES) == (Integer) 6) ? 0 : 0.4375;
case BlockID.CAULDRON:
return 0.3125;
case BlockID.COCOA:
return 0.750;
case BlockID.ENCHANTING_TABLE:
return 0.75;
case BlockID.END_PORTAL_FRAME:
return block.getState(PropertyKey.EYE) == Boolean.TRUE ? 1 : 0.8125;
case BlockID.CREEPER_HEAD:
case BlockID.DRAGON_HEAD:
case BlockID.PISTON_HEAD:
case BlockID.PLAYER_HEAD:
case BlockID.ZOMBIE_HEAD:
return 0.5;
case BlockID.CREEPER_WALL_HEAD:
case BlockID.DRAGON_WALL_HEAD:
case BlockID.PLAYER_WALL_HEAD:
case BlockID.ZOMBIE_WALL_HEAD:
return 0.75;
case BlockID.ACACIA_FENCE:
case BlockID.BIRCH_FENCE:
case BlockID.DARK_OAK_FENCE:
case BlockID.JUNGLE_FENCE:
case BlockID.NETHER_BRICK_FENCE:
case BlockID.OAK_FENCE:
case BlockID.SPRUCE_FENCE:
return 1.5;
case BlockID.ACACIA_SLAB:
case BlockID.BIRCH_SLAB:
case BlockID.BRICK_SLAB:
case BlockID.COBBLESTONE_SLAB:
case BlockID.DARK_OAK_SLAB:
case BlockID.DARK_PRISMARINE_SLAB:
case BlockID.JUNGLE_SLAB:
case BlockID.NETHER_BRICK_SLAB:
case BlockID.OAK_SLAB:
case BlockID.PETRIFIED_OAK_SLAB:
case BlockID.PRISMARINE_BRICK_SLAB:
case BlockID.PRISMARINE_SLAB:
case BlockID.PURPUR_SLAB:
case BlockID.QUARTZ_SLAB:
case BlockID.RED_SANDSTONE_SLAB:
case BlockID.SANDSTONE_SLAB:
case BlockID.SPRUCE_SLAB:
case BlockID.STONE_BRICK_SLAB:
case BlockID.STONE_SLAB: {
String state = (String) block.getState(PropertyKey.TYPE);
if (state == null) {
return 0.5;
}
switch (state) {
case "bottom":
return 0.5;
case "top":
case "double":
return 1;
}
}
case BlockID.LILY_PAD:
return 0.015625;
case BlockID.REPEATER:
return 0.125;
case BlockID.SOUL_SAND:
return 0.875;
case BlockID.COBBLESTONE_WALL:
case BlockID.MOSSY_COBBLESTONE_WALL:
return 1.5;
case BlockID.FLOWER_POT:
return 0.375;
case BlockID.COMPARATOR:
return 0.125;
case BlockID.DAYLIGHT_DETECTOR:
return 0.375;
case BlockID.HOPPER:
return 0.625;
case BlockID.ACACIA_TRAPDOOR:
case BlockID.BIRCH_TRAPDOOR:
case BlockID.DARK_OAK_TRAPDOOR:
case BlockID.IRON_TRAPDOOR:
case BlockID.JUNGLE_TRAPDOOR:
case BlockID.OAK_TRAPDOOR:
case BlockID.SPRUCE_TRAPDOOR:
if (block.getState(PropertyKey.OPEN) == Boolean.TRUE) {
return 0;
} else if ("top".equals(block.getState(PropertyKey.HALF))) {
return 1;
} else {
return 0.1875;
}
case BlockID.ACACIA_FENCE_GATE:
case BlockID.BIRCH_FENCE_GATE:
case BlockID.DARK_OAK_FENCE_GATE:
case BlockID.JUNGLE_FENCE_GATE:
case BlockID.OAK_FENCE_GATE:
case BlockID.SPRUCE_FENCE_GATE:
return block.getState(PropertyKey.OPEN) == Boolean.TRUE ? 0 : 1.5;
default:
if (type.hasProperty(PropertyKey.LAYERS)) {
return PropertyGroup.LEVEL.get(block) * 0.0625;
}
if (!type.getMaterial().isMovementBlocker()) {
return 0;
}
return 1;
}
}
}

View File

@ -20,7 +20,7 @@
package com.sk89q.worldedit.world.block;
import com.fastasyncworldedit.core.command.SuggestInputParseException;
import com.fastasyncworldedit.core.object.string.JoinedCharSequence;
import com.fastasyncworldedit.core.util.JoinedCharSequence;
import com.fastasyncworldedit.core.util.StringMan;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.world.registry.LegacyMapper;
@ -39,6 +39,7 @@ import javax.annotation.Nullable;
*/
@SuppressWarnings("unused")
public final class BlockTypes {
//FAWE start - init
// Doesn't really matter what the hardcoded values are, as FAWE will update it on load
@Nullable public static final BlockType __RESERVED__ = init(); // Placeholder for null index (i.e. when block types are represented as primitives)
@Nullable public static final BlockType ACACIA_BUTTON = init();
@ -998,6 +999,7 @@ public final class BlockTypes {
public static Set<String> getNameSpaces() {
return BlockTypesCache.$NAMESPACES;
}
//FAWE end
/**
* Gets the {@link BlockType} associated with the given id.
@ -1007,6 +1009,7 @@ public final class BlockTypes {
return BlockType.REGISTRY.get(id);
}
//FAWE start
@Nullable
public static BlockType get(final CharSequence id) {
return BlockType.REGISTRY.get(id.toString());
@ -1030,5 +1033,6 @@ public final class BlockTypes {
public static int size() {
return BlockTypesCache.values.length;
}
//FAWE end
}

View File

@ -1,6 +1,7 @@
package com.sk89q.worldedit.world.block;
import com.fastasyncworldedit.core.util.MathMan;
import com.fastasyncworldedit.core.world.block.BlockID;
import com.google.common.primitives.Booleans;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEdit;
@ -8,7 +9,7 @@ import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.registry.state.AbstractProperty;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.world.registry.BlockRegistry;
import com.sk89q.worldedit.world.registry.Registries;

View File

@ -1,17 +0,0 @@
package com.sk89q.worldedit.world.block;
import com.fastasyncworldedit.core.beta.ITileInput;
public enum CompoundInput {
NULL,
CONTAINER() {
@Override
public BaseBlock get(BlockState state, ITileInput input, int x, int y, int z) {
return state.toBaseBlock(input.getTile(x, y, z));
}
};
public BaseBlock get(BlockState state, ITileInput input, int x, int y, int z) {
return state.toBaseBlock();
}
}

View File

@ -21,7 +21,7 @@ package com.sk89q.worldedit.world.block;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import java.util.Collections;
import java.util.HashMap;
@ -33,10 +33,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* A Fuzzy BlockState. Used for partial matching.
*
* <p>
* Immutable, construct with {@link FuzzyBlockState.Builder}.
* </p>
*/
public class FuzzyBlockState extends BlockState {
//FAWE start
private final Map<PropertyKey, Object> props;
private final Map<Property<?>, Object> values;
@ -47,7 +50,9 @@ public class FuzzyBlockState extends BlockState {
public FuzzyBlockState(BlockState state) {
this(state, null);
}
//FAWE end
//FAWE start - use internal ids
private FuzzyBlockState(BlockState state, Map<Property<?>, Object> values) {
super(state.getBlockType(), state.getInternalId(), state.getOrdinal());
if (values == null || values.isEmpty()) {
@ -62,6 +67,7 @@ public class FuzzyBlockState extends BlockState {
}
}
//FAWE end
/**
* Gets a full BlockState from this fuzzy one, filling in
@ -79,6 +85,7 @@ public class FuzzyBlockState extends BlockState {
return state;
}
//FAWE start
@Override
public boolean equalsFuzzy(BlockStateHolder<?> o) {
if (!getBlockType().equals(o.getBlockType())) {
@ -114,6 +121,7 @@ public class FuzzyBlockState extends BlockState {
public Map<Property<?>, Object> getStates() {
return values;
}
//FAWE end
/**
* Gets an instance of a builder.
@ -124,18 +132,20 @@ public class FuzzyBlockState extends BlockState {
return new Builder();
}
//FAWE start
@Deprecated
@Override
public CompoundTag getNbtData() {
return getBlockType().getMaterial().isTile() ? getBlockType().getMaterial().getDefaultTile() : null;
}
//FAWE end
/**
* Builder for FuzzyBlockState
*/
public static class Builder {
private BlockType type;
private Map<Property<?>, Object> values = new HashMap<>();
private final Map<Property<?>, Object> values = new HashMap<>();
/**
* The type of the Fuzzy BlockState

View File

@ -1,22 +0,0 @@
package com.sk89q.worldedit.world.block;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.registry.ItemRegistry;
import com.sk89q.worldedit.world.registry.Registries;
public final class ItemTypesCache {
public static void init() {}
static {
Platform platform = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS);
Registries registries = platform.getRegistries();
ItemRegistry itemReg = registries.getItemRegistry();
for (String key : itemReg.values()) {
ItemType item = new ItemType(key);
ItemType.REGISTRY.register(key, item);
}
}
}

View File

@ -27,7 +27,7 @@ import com.sk89q.worldedit.util.nbt.BinaryTagTypes;
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
import com.sk89q.worldedit.util.nbt.IntBinaryTag;
import com.sk89q.worldedit.util.nbt.ListBinaryTag;
import com.sk89q.worldedit.util.nbt.NbtUtils;
import com.fastasyncworldedit.core.util.NbtUtils;
import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@ -41,7 +41,9 @@ import javax.annotation.Nullable;
public class AnvilChunk implements Chunk {
//FAWE start - use CBT > CT
private final CompoundBinaryTag rootTag;
//FAWE end
private final byte[][] blocks;
private final byte[][] blocksAdd;
private final byte[][] data;
@ -51,6 +53,7 @@ public class AnvilChunk implements Chunk {
private Map<BlockVector3, CompoundBinaryTag> tileEntities;
//FAWE start
/**
* Construct the chunk with a compound tag.
*
@ -58,9 +61,11 @@ public class AnvilChunk implements Chunk {
* @throws DataException on a data error
* @deprecated Use {@link #AnvilChunk(CompoundBinaryTag)}
*/
@Deprecated
public AnvilChunk(CompoundTag tag) throws DataException {
this(tag.asBinaryTag());
}
//FAWE end
/**
* Construct the chunk with a compound tag.
@ -78,6 +83,7 @@ public class AnvilChunk implements Chunk {
blocksAdd = new byte[16][16 * 16 * 8];
data = new byte[16][16 * 16 * 8];
//FAWE start - use *BinaryTag > *Tag
ListBinaryTag sections = NbtUtils.getChildTag(rootTag, "Sections", BinaryTagTypes.LIST);
for (BinaryTag rawSectionTag : sections) {
@ -125,6 +131,7 @@ public class AnvilChunk implements Chunk {
}
}
}
//FAWE end
private int getBlockID(BlockVector3 position) throws DataException {
int x = position.getX() - rootX * 16;
@ -190,6 +197,7 @@ public class AnvilChunk implements Chunk {
* Used to load the tile entities.
*/
private void populateTileEntities() throws DataException {
//FAWE start - use *BinaryTag > *Tag
ListBinaryTag tags = NbtUtils.getChildTag(rootTag, "TileEntities", BinaryTagTypes.LIST);
tileEntities = new HashMap<>();
@ -236,6 +244,7 @@ public class AnvilChunk implements Chunk {
tileEntities.put(vec, values.build());
}
}
//FAWE end
/**
* Get the map of tags keyed to strings for a block's tile entity data. May
@ -247,6 +256,7 @@ public class AnvilChunk implements Chunk {
* @throws DataException thrown if there is a data error
*/
@Nullable
//FAWE start - use *BinaryTag > * Tag
private CompoundBinaryTag getBlockTileEntity(BlockVector3 position) throws DataException {
if (tileEntities == null) {
populateTileEntities();
@ -278,5 +288,6 @@ public class AnvilChunk implements Chunk {
return state.toBaseBlock();
}
//FAWE end
}

View File

@ -27,7 +27,7 @@ import com.sk89q.worldedit.util.nbt.BinaryTagTypes;
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
import com.sk89q.worldedit.util.nbt.IntBinaryTag;
import com.sk89q.worldedit.util.nbt.ListBinaryTag;
import com.sk89q.worldedit.util.nbt.NbtUtils;
import com.fastasyncworldedit.core.util.NbtUtils;
import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@ -44,14 +44,17 @@ import javax.annotation.Nullable;
*/
public class AnvilChunk13 implements Chunk {
//FAWE start - CBT > CT
private final CompoundBinaryTag rootTag;
private BlockState[][] blocks;
private int rootX;
private int rootZ;
//FAWE end
private final BlockState[][] blocks;
private final int rootX;
private final int rootZ;
private Map<BlockVector3, CompoundBinaryTag> tileEntities;
//FAWE start
/**
* Construct the chunk with a compound tag.
*
@ -63,6 +66,7 @@ public class AnvilChunk13 implements Chunk {
public AnvilChunk13(CompoundTag tag) throws DataException {
this(tag.asBinaryTag());
}
//FAWE end
/**
* Construct the chunk with a compound tag.
@ -78,6 +82,7 @@ public class AnvilChunk13 implements Chunk {
blocks = new BlockState[16][];
//FAWE start - use *BinaryTag > *Tag
ListBinaryTag sections = NbtUtils.getChildTag(rootTag, "Sections", BinaryTagTypes.LIST);
for (BinaryTag rawSectionTag : sections) {
@ -124,6 +129,7 @@ public class AnvilChunk13 implements Chunk {
}
palette[paletteEntryId] = blockState;
}
//FAWE end
// parse block states
long[] blockStatesSerialized = NbtUtils.getChildTag(sectionTag, "BlockStates", BinaryTagTypes.LONG_ARRAY).value();
@ -181,6 +187,7 @@ public class AnvilChunk13 implements Chunk {
if (rootTag.get("TileEntities") == null) {
return;
}
//FAWE start - use *BinaryTag > *Tag
ListBinaryTag tags = NbtUtils.getChildTag(rootTag, "TileEntities", BinaryTagTypes.LIST);
for (BinaryTag tag : tags) {
@ -197,6 +204,7 @@ public class AnvilChunk13 implements Chunk {
BlockVector3 vec = BlockVector3.at(x, y, z);
tileEntities.put(vec, t);
}
//FAWE end
}
/**
@ -209,6 +217,7 @@ public class AnvilChunk13 implements Chunk {
* @throws DataException thrown if there is a data error
*/
@Nullable
//FAWE start - use *BinaryTag > *Tag
private CompoundBinaryTag getBlockTileEntity(BlockVector3 position) throws DataException {
if (tileEntities == null) {
populateTileEntities();
@ -246,5 +255,6 @@ public class AnvilChunk13 implements Chunk {
return state.toBaseBlock();
}
//FAWE end
}

View File

@ -30,6 +30,7 @@ import com.sk89q.worldedit.world.storage.InvalidFormatException;
*/
public class AnvilChunk16 extends AnvilChunk13 {
//FAWE start
/**
* Construct the chunk with a compound tag.
*
@ -51,6 +52,7 @@ public class AnvilChunk16 extends AnvilChunk13 {
public AnvilChunk16(CompoundBinaryTag tag) throws DataException {
super(tag);
}
//FAWE end
@Override
protected void readBlockStates(BlockState[] palette, long[] blockStatesSerialized, BlockState[] chunkSectionBlocks) throws InvalidFormatException {

View File

@ -27,7 +27,7 @@ import com.sk89q.worldedit.util.nbt.BinaryTagTypes;
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
import com.sk89q.worldedit.util.nbt.IntBinaryTag;
import com.sk89q.worldedit.util.nbt.ListBinaryTag;
import com.sk89q.worldedit.util.nbt.NbtUtils;
import com.fastasyncworldedit.core.util.NbtUtils;
import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@ -43,7 +43,9 @@ import java.util.Map;
*/
public class OldChunk implements Chunk {
//FAWE start
private final CompoundBinaryTag rootTag;
//FAWE end
private final byte[] blocks;
private final byte[] data;
private final int rootX;
@ -51,7 +53,7 @@ public class OldChunk implements Chunk {
private Map<BlockVector3, CompoundBinaryTag> tileEntities;
//FAWE start
/**
* Construct the chunk with a compound tag.
*
@ -63,6 +65,7 @@ public class OldChunk implements Chunk {
public OldChunk(CompoundTag tag) throws DataException {
this(tag.asBinaryTag());
}
//FAWE end
/**
* Construct the chunk with a compound tag.
@ -70,6 +73,7 @@ public class OldChunk implements Chunk {
* @param tag the tag
* @throws DataException if there is an error getting the chunk data
*/
//FAWE start - use *BinaryTag > *Tag
public OldChunk(CompoundBinaryTag tag) throws DataException {
rootTag = tag;
@ -209,5 +213,6 @@ public class OldChunk implements Chunk {
return state.toBaseBlock();
}
//FAWE end
}

View File

@ -21,13 +21,15 @@ package com.sk89q.worldedit.world.entity;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import com.sk89q.worldedit.registry.RegistryItem;
import com.fastasyncworldedit.core.registry.RegistryItem;
//FAWE start - implements RegistryItem
public class EntityType implements RegistryItem, Keyed {
//FAWE end
public static final NamespacedRegistry<EntityType> REGISTRY = new NamespacedRegistry<>("entity type");
private String id;
private final String id;
public EntityType(String id) {
// If it has no namespace, assume minecraft.
@ -42,6 +44,7 @@ public class EntityType implements RegistryItem, Keyed {
return this.id;
}
//FAWE start
private int internalId;
@Override
@ -53,6 +56,7 @@ public class EntityType implements RegistryItem, Keyed {
public int getInternalId() {
return internalId;
}
//FAWE end
/**
* Gets the name of this item, or the ID if the name cannot be found.

View File

@ -155,6 +155,7 @@ public final class EntityTypes {
return EntityType.REGISTRY.get(id);
}
//FAWE Start
private static String convertEntityId(String id) {
if (id.startsWith("minecraft:")) {
id = id.substring(10);
@ -265,5 +266,6 @@ public final class EntityTypes {
public static EntityType parse(String id) {
return get(convertEntityId(id));
}
//FAWE end
}

View File

@ -21,17 +21,19 @@ package com.sk89q.worldedit.world.fluid;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import com.sk89q.worldedit.registry.RegistryItem;
import com.fastasyncworldedit.core.registry.RegistryItem;
/**
* Minecraft now has a 'fluid' system. This is a
* stub class to represent what it may be in the future.
*/
//FAWE start - implements RegistryItem
public class FluidType implements RegistryItem, Keyed {
//FAWE end
public static final NamespacedRegistry<FluidType> REGISTRY = new NamespacedRegistry<>("fluid type");
private String id;
private final String id;
public FluidType(String id) {
this.id = id;
@ -47,6 +49,7 @@ public class FluidType implements RegistryItem, Keyed {
return this.id;
}
//FAWE start
private int internalId;
//UNUSED
@ -60,6 +63,7 @@ public class FluidType implements RegistryItem, Keyed {
public int getInternalId() {
return internalId;
}
//FAWE end
@Override
public String toString() {

View File

@ -26,7 +26,7 @@ public class GameMode implements Keyed {
public static final Registry<GameMode> REGISTRY = new Registry<>("game mode");
private String id;
private final String id;
public GameMode(String id) {
this.id = id;

View File

@ -25,7 +25,7 @@ import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import com.sk89q.worldedit.registry.RegistryItem;
import com.fastasyncworldedit.core.registry.RegistryItem;
import com.sk89q.worldedit.util.GuavaUtil;
import com.sk89q.worldedit.util.concurrency.LazyReference;
import com.sk89q.worldedit.util.formatting.text.Component;
@ -35,7 +35,9 @@ import com.sk89q.worldedit.world.registry.ItemMaterial;
import javax.annotation.Nullable;
//FAWE start - implements RegistryItem
public class ItemType implements RegistryItem, Keyed {
//FAWE end
public static final NamespacedRegistry<ItemType> REGISTRY = new NamespacedRegistry<>("item type");
@ -57,9 +59,11 @@ public class ItemType implements RegistryItem, Keyed {
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS)
.getRegistries().getItemRegistry().getMaterial(this)
);
//FAWE start
private BlockType blockType;
private boolean initBlockType;
private BaseItem defaultState;
//FAWE end
public ItemType(String id) {
// If it has no namespace, assume minecraft.
@ -74,6 +78,7 @@ public class ItemType implements RegistryItem, Keyed {
return this.id;
}
//FAWE start
private int internalId;
@Override
@ -89,6 +94,7 @@ public class ItemType implements RegistryItem, Keyed {
public Component getRichName() {
return richName.getValue();
}
//FAWE end
/**
* Gets the name of this item, or the ID if the name cannot be found.
@ -125,12 +131,14 @@ public class ItemType implements RegistryItem, Keyed {
return this.blockType;
}
//FAWE start
public BaseItem getDefaultState() {
if (defaultState == null) {
this.defaultState = new BaseItemStack(this);
}
return this.defaultState;
}
//FAWE end
/**
* Get the material for this ItemType.

View File

@ -19,8 +19,8 @@
package com.sk89q.worldedit.world.item;
import com.fastasyncworldedit.core.object.string.JoinedCharSequence;
import com.sk89q.worldedit.world.block.ItemTypesCache;
import com.fastasyncworldedit.core.util.JoinedCharSequence;
import com.fastasyncworldedit.core.world.block.ItemTypesCache;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import java.lang.reflect.Field;
@ -35,6 +35,7 @@ import javax.annotation.Nullable;
*/
@SuppressWarnings("unused")
public final class ItemTypes {
//FAWE start - init
@Nullable public static final ItemType ACACIA_BOAT = init();
@Nullable public static final ItemType ACACIA_BUTTON = init();
@Nullable public static final ItemType ACACIA_DOOR = init();
@ -1187,6 +1188,7 @@ public final class ItemTypes {
}
return get(input);
}
//FAWE end
/**
* Gets the {@link ItemType} associated with the given id.
@ -1196,6 +1198,7 @@ public final class ItemTypes {
return ItemType.REGISTRY.get(id);
}
//FAWE start
@Deprecated
public static ItemType get(int ordinal) {
return ItemType.REGISTRY.getByInternalId(ordinal);
@ -1208,4 +1211,5 @@ public final class ItemTypes {
public static Collection<ItemType> values() {
return ItemType.REGISTRY.values();
}
//FAWE end
}

View File

@ -97,12 +97,6 @@ public interface BlockMaterial {
*/
int getLightValue();
/**
* Get the opacity of the block.
* @return opacity
*/
int getLightOpacity();
/**
* Get whether this block breaks when it is pushed by a piston.
*
@ -168,6 +162,13 @@ public interface BlockMaterial {
*/
boolean hasContainer();
//FAWE start
/**
* Get the opacity of the block.
* @return opacity
*/
int getLightOpacity();
/**
* Gets whether the block is a tile entity.
*
@ -188,4 +189,5 @@ public interface BlockMaterial {
* @return or 0
*/
int getMapColor();
//FAWE end
}

View File

@ -65,10 +65,12 @@ public interface BlockRegistry {
@Nullable
BlockMaterial getMaterial(BlockType blockType);
//FAWE start
@Nullable
default BlockMaterial getMaterial(BlockState state) {
return getMaterial(state.getBlockType());
}
//FAWE end
/**
* Get an unmodifiable map of states for this block.
@ -86,10 +88,12 @@ public interface BlockRegistry {
*/
OptionalInt getInternalBlockStateId(BlockState state);
//FAWE start
/**
* Register all blocks.
*/
default Collection<String> values() {
return Collections.emptyList();
}
//FAWE end
}

View File

@ -82,6 +82,7 @@ public final class BundledBlockData {
private void loadFromResource() throws IOException {
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter());
//FAWE start
gsonBuilder.registerTypeAdapter(int.class, (JsonDeserializer<Integer>) (json, typeOfT, context) -> {
JsonPrimitive primitive = (JsonPrimitive) json;
if (primitive.isString()) {
@ -93,6 +94,7 @@ public final class BundledBlockData {
}
return primitive.getAsInt();
});
//FAWE end
Gson gson = gsonBuilder.create();
URL url = null;
final int dataVersion = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataVersion();
@ -162,9 +164,11 @@ public final class BundledBlockData {
}
public static class BlockEntry {
//FAWE start - made public
public String id;
public String localizedName;
public SimpleBlockMaterial material = new SimpleBlockMaterial();
//FAWE end
}
}

View File

@ -53,6 +53,16 @@ public class BundledBlockRegistry implements BlockRegistry {
);
}
@Nullable
@Override
@Deprecated
// dumb_intellij.jpg - Ok??
@SuppressWarnings("deprecation")
public String getName(BlockType blockType) {
BundledBlockData.BlockEntry blockEntry = BundledBlockData.getInstance().findById(blockType.getId());
return blockEntry != null ? blockEntry.localizedName : null;
}
@Nullable
@Override
public BlockMaterial getMaterial(BlockType blockType) {

View File

@ -39,15 +39,6 @@ public interface EntityRegistry {
* @return the entity, which may be null if the entity does not exist
*/
@Nullable
default BaseEntity createFromId(String id) {
EntityType entType = EntityTypes.get(id);
return entType == null ? null : new BaseEntity(entType);
}
BaseEntity createFromId(String id);
/**
* Register all entities.
*/
default Collection<String> registerEntities() {
return Collections.emptyList();
}
}

View File

@ -69,10 +69,12 @@ public interface ItemRegistry {
@Nullable
ItemMaterial getMaterial(ItemType itemType);
//FAWE start
/**
* Register all items.
*/
default Collection<String> values() {
return Collections.emptyList();
}
//FAWE end
}

View File

@ -35,7 +35,7 @@ import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.internal.Constants;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.sk89q.worldedit.util.gson.VectorAdapter;
import com.sk89q.worldedit.util.io.ResourceLoader;
import com.sk89q.worldedit.world.DataFixer;
@ -60,15 +60,15 @@ public final class LegacyMapper {
private static LegacyMapper INSTANCE;
private final ResourceLoader resourceLoader;
//FAWE start
private final Int2ObjectArrayMap<Integer> blockStateToLegacyId4Data = new Int2ObjectArrayMap<>();
private final Int2ObjectArrayMap<Integer> extraId4DataToStateId = new Int2ObjectArrayMap<>();
private final int[] blockArr = new int[4096];
private final BiMap<Integer, ItemType> itemMap = HashBiMap.create();
private Map<String, String> blockEntries = new HashMap<>();
private final Map<String, String> blockEntries = new HashMap<>();
//FAWE end
private final Map<String, BlockState> stringToBlockMap = new HashMap<>();
private final Multimap<BlockState, String> blockToStringMap = HashMultimap.create();
private final Map<String, ItemType> stringToItemMap = new HashMap<>();
private final Multimap<ItemType, String> itemToStringMap = HashMultimap.create();
/**
* Create a new instance.
@ -107,11 +107,14 @@ public final class LegacyMapper {
for (Map.Entry<String, String> blockEntry : dataFile.blocks.entrySet()) {
String id = blockEntry.getKey();
Integer combinedId = getCombinedId(blockEntry.getKey());
final String value = blockEntry.getValue();
//FAWE start
Integer combinedId = getCombinedId(blockEntry.getKey());
blockEntries.put(id, value);
//FAWE end
BlockState state = null;
//FAWE start
try {
state = BlockState.get(null, blockEntry.getValue());
BlockType type = state.getBlockType();
@ -120,11 +123,12 @@ public final class LegacyMapper {
}
} catch (InputParseException f) {
BlockFactory blockFactory = WorldEdit.getInstance().getBlockFactory();
//FAWE end
// if fixer is available, try using that first, as some old blocks that were renamed share names with new blocks
if (fixer != null) {
try {
String newEntry = fixer.fixUp(DataFixer.FixTypes.BLOCK_STATE, value, 1631);
String newEntry = fixer.fixUp(DataFixer.FixTypes.BLOCK_STATE, value, Constants.DATA_VERSION_MC_1_13_2);
state = blockFactory.parseFromInput(newEntry, parserContext).toImmutableState();
} catch (InputParseException ignored) {
}
@ -147,6 +151,7 @@ public final class LegacyMapper {
stringToBlockMap.put(id, state);
}
}
//FAWE start
if (state != null) {
blockArr[combinedId] = state.getInternalId();
blockStateToLegacyId4Data.put(state.getInternalId(), (Integer) combinedId);
@ -164,6 +169,7 @@ public final class LegacyMapper {
}
}
}
//FAWE end
for (Map.Entry<String, String> itemEntry : dataFile.items.entrySet()) {
String id = itemEntry.getKey();
@ -184,6 +190,7 @@ public final class LegacyMapper {
}
}
//FAWE start
private int getCombinedId(String input) {
String[] split = input.split(":");
return (Integer.parseInt(split[0]) << 4) + (split.length == 2 ? Integer.parseInt(split[1]) : 0);
@ -200,7 +207,9 @@ public final class LegacyMapper {
}
return itemMap.get(getCombinedId(input));
}
//FAWE end
//FAWE start - use internal ids
public BlockState getBlockFromLegacy(String input) {
if (input.startsWith("minecraft:")) {
input = input.substring(10);
@ -212,6 +221,7 @@ public final class LegacyMapper {
}
return null;
}
//FAWE end
@Nullable
public ItemType getItemFromLegacy(int legacyId, int data) {
@ -233,6 +243,7 @@ public final class LegacyMapper {
}
}
//FAWE start
@Nullable
public BlockState getBlockFromLegacy(int legacyId) {
return getBlock(legacyId << 4);
@ -297,6 +308,7 @@ public final class LegacyMapper {
public Integer getLegacyCombined(BlockType type) {
return blockStateToLegacyId4Data.get(type.getDefaultState().getInternalId());
}
//FAWE end
@Deprecated
public int[] getLegacyFromBlock(BlockState blockState) {

View File

@ -50,6 +50,7 @@ public class PassthroughBlockMaterial implements BlockMaterial {
return blockMaterial.isAir();
}
//FAWE start
@Override
public int getMapColor() {
if (blockMaterial == null) {
@ -58,6 +59,7 @@ public class PassthroughBlockMaterial implements BlockMaterial {
return blockMaterial.getMapColor();
}
}
//FAWE end
@Override
public boolean isFullCube() {
@ -104,10 +106,12 @@ public class PassthroughBlockMaterial implements BlockMaterial {
return blockMaterial.getLightValue();
}
//FAWE start
@Override
public int getLightOpacity() {
return blockMaterial.getLightOpacity();
}
//FAWE end
@Override
public boolean isFragileWhenPushed() {
@ -154,6 +158,7 @@ public class PassthroughBlockMaterial implements BlockMaterial {
return blockMaterial.hasContainer();
}
//FAWE start
@Override
public boolean isTile() {
return blockMaterial.isTile();
@ -163,4 +168,5 @@ public class PassthroughBlockMaterial implements BlockMaterial {
public CompoundTag getDefaultTile() {
return blockMaterial.getDefaultTile();
}
//FAWE end
}

View File

@ -42,16 +42,19 @@ class SimpleBlockMaterial implements BlockMaterial {
private boolean replacedDuringPlacement;
private boolean isTranslucent;
private boolean hasContainer;
//FAWE start
private int lightOpacity;
private int mapColor;
private boolean isTile;
private CompoundTag tile = null;
//FAWE end
@Override
public boolean isAir() {
return this.isAir;
}
//FAWE start
@Override
public int getMapColor() {
return mapColor;
@ -69,6 +72,7 @@ class SimpleBlockMaterial implements BlockMaterial {
public void setLightOpacity(int lightOpacity) {
this.lightOpacity = lightOpacity;
}
//FAWE end
public void setIsAir(boolean isAir) {
this.isAir = isAir;
@ -232,6 +236,7 @@ class SimpleBlockMaterial implements BlockMaterial {
return this.hasContainer;
}
//FAWE start
public void setIsTile(boolean isTile) {
this.isTile = isTile;
}
@ -249,6 +254,7 @@ class SimpleBlockMaterial implements BlockMaterial {
public CompoundTag getDefaultTile() {
return tile;
}
//FAWE end
public void setHasContainer(boolean hasContainer) {
this.hasContainer = hasContainer;

View File

@ -21,8 +21,8 @@ package com.sk89q.worldedit.world.registry;
public class SimpleItemMaterial implements ItemMaterial {
private int maxStackSize;
private int maxDamage;
private final int maxStackSize;
private final int maxDamage;
public SimpleItemMaterial(int maxStackSize, int maxDamage) {
this.maxStackSize = maxStackSize;

View File

@ -19,7 +19,7 @@
package com.sk89q.worldedit.world.snapshot;
import com.fastasyncworldedit.core.object.collection.LocalBlockVectorSet;
import com.fastasyncworldedit.core.math.LocalBlockVectorSet;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.math.BlockVector2;
@ -43,7 +43,9 @@ import java.util.Set;
*/
public class SnapshotRestore {
//FAWE start - Set instead of ArrayList
private final Map<BlockVector2, Set<BlockVector3>> neededChunks = new LinkedHashMap<>();
//FAWE end
private final ChunkStore chunkStore;
private final EditSession editSession;
private ArrayList<BlockVector2> missingChunks;
@ -129,7 +131,7 @@ public class SnapshotRestore {
/**
* Restores to world.
*
* @throws MaxChangedBlocksException
* @throws MaxChangedBlocksException if the max block change limit is exceeded
*/
public void restore() throws MaxChangedBlocksException {

View File

@ -27,7 +27,7 @@ import java.util.regex.Pattern;
public class YYMMDDHHIISSParser implements SnapshotDateParser {
private Pattern datePattern =
private final Pattern datePattern =
Pattern.compile("([0-9]+)[^0-9]?([0-9]+)[^0-9]?([0-9]+)[^0-9]?"
+ "([0-9]+)[^0-9]?([0-9]+)[^0-9]?([0-9]+)(\\..*)?");

View File

@ -127,7 +127,7 @@ public class SnapshotRestore {
/**
* Restores to world.
*
* @throws MaxChangedBlocksException
* @throws MaxChangedBlocksException if the max block change limit is exceeded
*/
public void restore() throws MaxChangedBlocksException {

View File

@ -97,7 +97,9 @@ public class ChunkStoreHelper {
if (tag.getValue().containsKey("Sections") && dataVersion < currentDataVersion) { // only fix up MCA format, DFU doesn't support MCR chunks
final DataFixer dataFixer = platform.getDataFixer();
if (dataFixer != null) {
//FAWE start - use Adventure
tag = (CompoundTag) ((CompoundTag) AdventureNBTConverter.fromAdventure(dataFixer.fixUp(DataFixer.FixTypes.CHUNK, rootTag.asBinaryTag(), dataVersion))).getValue().get("Level");
//FAWE end
dataVersion = currentDataVersion;
}
}

View File

@ -30,7 +30,7 @@ import java.util.regex.Pattern;
public class FileMcRegionChunkStore extends McRegionChunkStore {
private File path;
private final File path;
/**
* Create an instance. The passed path is the folder to read the

View File

@ -92,7 +92,7 @@ public abstract class LegacyChunkStore extends ChunkStore {
* @param f2 the second part of the path
* @param name the name
* @return an input stream
* @throws IOException
* @throws IOException if there is an error getting the chunk data
*/
protected abstract InputStream getInputStream(String f1, String f2, String name) throws IOException, DataException;

View File

@ -78,7 +78,7 @@ public abstract class McRegionChunkStore extends ChunkStore {
* @param name the name of the chunk file
* @param worldName the world name
* @return an input stream
* @throws IOException
* @throws IOException if there is an error getting the chunk data
*/
protected abstract InputStream getInputStream(String name, String worldName) throws IOException, DataException;

View File

@ -87,10 +87,9 @@ public class McRegionReader {
* Construct the reader.
*
* @param stream the stream
* @throws DataException
* @throws IOException
* @throws IOException if there is an error getting the region data
*/
public McRegionReader(InputStream stream) throws DataException, IOException {
public McRegionReader(InputStream stream) throws IOException {
this.stream = new ForwardSeekableInputStream(stream);
this.dataStream = new DataInputStream(this.stream);
@ -100,7 +99,7 @@ public class McRegionReader {
/**
* Read the header.
*
* @throws IOException
* @throws IOException if there is an error getting the header data
*/
private void readHeader() throws IOException {
offsets = new int[SECTOR_INTS];
@ -116,8 +115,8 @@ public class McRegionReader {
*
* @param position chunk position
* @return an input stream
* @throws IOException
* @throws DataException
* @throws IOException if there is an error getting the chunk data
* @throws DataException if there is an error getting the chunk data
*/
public synchronized InputStream getChunkInputStream(BlockVector2 position) throws IOException, DataException {
int x = position.getBlockX() & 31;

View File

@ -45,6 +45,8 @@ public class ZippedLegacyChunkStore extends LegacyChunkStore {
*
* @param zipFile the zip file
* @param folder the folder
* @throws IOException if there is an error opening the zip
* @throws ZipException if there is an error opening the zip
*/
public ZippedLegacyChunkStore(File zipFile, String folder) throws IOException, ZipException {
this.folder = folder;
@ -57,6 +59,8 @@ public class ZippedLegacyChunkStore extends LegacyChunkStore {
* be detected.
*
* @param zipFile the zip file
* @throws IOException if there is an error opening the zip
* @throws ZipException if there is an error opening the zip
*/
public ZippedLegacyChunkStore(File zipFile) throws IOException, ZipException {
zip = new ZipFile(zipFile);
@ -69,6 +73,8 @@ public class ZippedLegacyChunkStore extends LegacyChunkStore {
* @param f2 the second part of the path
* @param name the name of the file
* @return an input stream
* @throws IOException if there is an error getting the chunk data
* @throws DataException if there is an error getting the chunk data
*/
@Override
protected InputStream getInputStream(String f1, String f2, String name) throws IOException, DataException {

View File

@ -48,6 +48,8 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
*
* @param zipFile the ZIP file
* @param folder the folder
* @throws IOException if there is an error opening the zip
* @throws ZipException if there is an error opening the zip
*/
public ZippedMcRegionChunkStore(File zipFile, String folder) throws IOException, ZipException {
this.zipFile = zipFile;
@ -61,6 +63,8 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
* be detected.
*
* @param zipFile the ZIP file
* @throws IOException if there is an error opening the zip
* @throws ZipException if there is an error opening the zip
*/
public ZippedMcRegionChunkStore(File zipFile) throws IOException, ZipException {
this.zipFile = zipFile;
@ -77,12 +81,18 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
}
} else {
Pattern pattern = Pattern.compile(".*\\.mc[ra]$");
Pattern worldPattern = Pattern.compile(worldName + "[\\\\/].*");
for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) {
ZipEntry testEntry = e.nextElement();
// Check for world
if (testEntry.getName().startsWith(worldName + "/")) {
if (pattern.matcher(testEntry.getName()).matches()) { // does entry end in .mca
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf('/'));
String entryName = testEntry.getName();
if (worldPattern.matcher(entryName).matches()) {
if (pattern.matcher(entryName).matches()) { // does entry end in .mca
int endIndex = entryName.lastIndexOf('/');
if (endIndex < 0) {
endIndex = entryName.lastIndexOf('\\');
}
folder = entryName.substring(0, endIndex);
if (folder.endsWith("poi")) {
continue;
}