Major command changes that don't work yet.

This commit is contained in:
MattBDev
2019-07-05 20:46:48 -04:00
parent ffc2092d93
commit 8108d0a936
399 changed files with 13558 additions and 7985 deletions

View File

@ -36,6 +36,7 @@ import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import javax.annotation.Nullable;
import java.nio.file.Path;
import java.util.PriorityQueue;
/**
@ -56,6 +57,11 @@ public abstract class AbstractWorld implements World {
return setBlock(pt, block, true);
}
@Override
public Path getStoragePath() {
return null;
}
@Override
public int getMaxY() {
return getMaximumPoint().getBlockY();

View File

@ -0,0 +1,53 @@
/*
* 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 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.world;
import com.google.common.annotations.Beta;
import com.sk89q.jnbt.CompoundTag;
/**
* This entire class is subject to heavy changes. Do not use this as API.
*/
@Beta
public interface DataFixer {
final class FixType<T> {
private FixType() {
}
}
final class FixTypes {
private FixTypes() {
}
public static FixType<CompoundTag> CHUNK = new FixType<>();
public static FixType<CompoundTag> BLOCK_ENTITY = new FixType<>();
public static FixType<CompoundTag> ENTITY = new FixType<>();
public static FixType<String> BLOCK_STATE = new FixType<>();
public static FixType<String> BIOME = new FixType<>();
public static FixType<String> ITEM_TYPE = new FixType<>();
}
default <T> T fixUp(FixType<T> type, T original) {
return fixUp(type, original, -1);
}
<T> T fixUp(FixType<T> type, T original, int srcVer);
}

View File

@ -20,28 +20,26 @@
package com.sk89q.worldedit.world;
import com.boydti.fawe.util.SetQueue;
import com.sk89q.worldedit.*;
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.function.mask.BlockTypeMask;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.block.*;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operation;
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.util.HashMap;
import java.util.PriorityQueue;
import javax.annotation.Nullable;
/**

View File

@ -38,6 +38,9 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.weather.WeatherType;
import javax.annotation.Nullable;
import java.nio.file.Path;
/**
* Represents a world (dimension).
*/
@ -50,6 +53,15 @@ public interface World extends Extent {
*/
String getName();
/**
* Get the folder in which this world is stored. May return null if unknown
* or if this world is not serialized to disk.
*
* @return world storage path
*/
@Nullable
Path getStoragePath();
/**
* Get the maximum Y.
*

View File

@ -19,16 +19,18 @@
package com.sk89q.worldedit.world.biome;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.RegistryItem;
import com.sk89q.worldedit.registry.NamespacedRegistry;
/**
* All the types of biomes in the game.
*/
public class BiomeType implements RegistryItem {
public class BiomeType implements RegistryItem, Keyed {
public static final NamespacedRegistry<BiomeType> REGISTRY = new NamespacedRegistry<>("biome type");
private final String id;
private String id;
public BiomeType(String id) {
this.id = id;
@ -51,6 +53,7 @@ public class BiomeType implements RegistryItem {
*
* @return The id
*/
@Override
public String getId() {
return this.id;
}
@ -62,7 +65,7 @@ public class BiomeType implements RegistryItem {
@Override
public int hashCode() {
return this.internalId;
return this.id.hashCode();
}
@Override

View File

@ -20,15 +20,16 @@
package com.sk89q.worldedit.world.biome;
import javax.annotation.Nullable;
import java.util.Collection;
/**
* Stores a list of common Biome String IDs.
*/
public class BiomeTypes {
public final class BiomeTypes {
@Nullable public static final BiomeType BADLANDS = get("minecraft:badlands");
@Nullable public static final BiomeType BADLANDS_PLATEAU = get("minecraft:badlands_plateau");
@Nullable public static final BiomeType BAMBOO_JUNGLE = get("minecraft:bamboo_jungle");
@Nullable public static final BiomeType BAMBOO_JUNGLE_HILLS = get("minecraft:bamboo_jungle_hills");
@Nullable public static final BiomeType BEACH = get("minecraft:beach");
@Nullable public static final BiomeType BIRCH_FOREST = get("minecraft:birch_forest");
@Nullable public static final BiomeType BIRCH_FOREST_HILLS = get("minecraft:birch_forest_hills");
@ -104,15 +105,15 @@ public class BiomeTypes {
private BiomeTypes() {
}
private static BiomeType register(final String id) {
return register(new BiomeType(id));
}
public static BiomeType register(final BiomeType biome) {
return BiomeType.REGISTRY.register(biome.getId(), biome);
}
public static @Nullable BiomeType get(final String id) {
return BiomeType.REGISTRY.get(id);
}
public static BiomeType get(int internalId) {
return BiomeType.REGISTRY.getByInternalId(internalId);
}
public static Collection<BiomeType> values() {
return BiomeType.REGISTRY.values();
}
}

View File

@ -24,6 +24,7 @@ import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.TileEntityBlock;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property;
@ -44,7 +45,7 @@ import java.util.Objects;
* snapshot of blocks correctly, so, for example, the NBT data for a block
* may be missing.</p>
*/
public class BaseBlock implements BlockStateHolder<BaseBlock> {
public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
private BlockState blockState;
@Nullable protected CompoundTag nbtData;
@ -236,22 +237,6 @@ public class BaseBlock implements BlockStateHolder<BaseBlock> {
return this;
}
@Override
public BaseBlock toBaseBlock(CompoundTag compoundTag) {
if (compoundTag == null) {
return this.blockState.toBaseBlock();
} else if (compoundTag == this.nbtData) {
return this;
} else {
return new BaseBlock(this.blockState, compoundTag);
}
}
@Override
public int hashCode() {
return getOrdinal();
}
@Override
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
return extent.setBlock(set, this);
@ -277,18 +262,38 @@ public class BaseBlock implements BlockStateHolder<BaseBlock> {
return toImmutableState().with(property, value).toBaseBlock(getNbtData());
}
@Override
public <V> V getState(PropertyKey property) {
return toImmutableState().getState(property);
}
@Override
public String toString() {
if (getNbtData() != null) {
return getAsString() + " {" + String.valueOf(getNbtData()) + "}";
public BaseBlock toBaseBlock(CompoundTag compoundTag) {
if (compoundTag == null) {
return this.blockState.toBaseBlock();
} else if (compoundTag == this.nbtData) {
return this;
} else {
return getAsString();
return new BaseBlock(this.blockState, compoundTag);
}
}
@Override
public <V> V getState(PropertyKey property) {
return toImmutableState().getState(property);
}
@Override
public int hashCode() {
int ret = toImmutableState().hashCode() << 3;
if (hasNbtData()) {
ret += getNbtData().hashCode();
}
return ret;
}
@Override
public String toString() {
// if (getNbtData() != null) { // TODO Maybe make some JSON serialiser to make this not awful.
// return blockState.getAsString() + " {" + String.valueOf(getNbtData()) + "}";
// } else {
return blockState.getAsString();
// }
}
}

View File

@ -26,17 +26,24 @@ public final class BlockCategories {
public static final BlockCategory ACACIA_LOGS = get("minecraft:acacia_logs");
public static final BlockCategory ANVIL = get("minecraft:anvil");
public static final BlockCategory BAMBOO_PLANTABLE_ON = get("minecraft:bamboo_plantable_on");
public static final BlockCategory BANNERS = get("minecraft:banners");
public static final BlockCategory BEDS = get("minecraft:beds");
public static final BlockCategory BIRCH_LOGS = get("minecraft:birch_logs");
public static final BlockCategory BUTTONS = get("minecraft:buttons");
public static final BlockCategory CARPETS = get("minecraft:carpets");
public static final BlockCategory CORALS = get("minecraft:corals");
public static final BlockCategory CORAL_BLOCKS = get("minecraft:coral_blocks");
public static final BlockCategory CORAL_PLANTS = get("minecraft:coral_plants");
public static final BlockCategory CORALS = get("minecraft:corals");
public static final BlockCategory DARK_OAK_LOGS = get("minecraft:dark_oak_logs");
public static final BlockCategory DIRT_LIKE = get("minecraft:dirt_like");
public static final BlockCategory DOORS = get("minecraft:doors");
public static final BlockCategory DRAGON_IMMUNE = get("minecraft:dragon_immune");
public static final BlockCategory ENDERMAN_HOLDABLE = get("minecraft:enderman_holdable");
public static final BlockCategory FENCES = get("minecraft:fences");
public static final BlockCategory FLOWER_POTS = get("minecraft:flower_pots");
public static final BlockCategory ICE = get("minecraft:ice");
public static final BlockCategory IMPERMEABLE = get("minecraft:impermeable");
public static final BlockCategory JUNGLE_LOGS = get("minecraft:jungle_logs");
public static final BlockCategory LEAVES = get("minecraft:leaves");
public static final BlockCategory LOGS = get("minecraft:logs");
@ -45,16 +52,27 @@ public final class BlockCategories {
public static final BlockCategory RAILS = get("minecraft:rails");
public static final BlockCategory SAND = get("minecraft:sand");
public static final BlockCategory SAPLINGS = get("minecraft:saplings");
public static final BlockCategory SIGNS = get("minecraft:signs");
public static final BlockCategory SLABS = get("minecraft:slabs");
public static final BlockCategory SMALL_FLOWERS = get("minecraft:small_flowers");
public static final BlockCategory SPRUCE_LOGS = get("minecraft:spruce_logs");
public static final BlockCategory STAIRS = get("minecraft:stairs");
public static final BlockCategory STANDING_SIGNS = get("minecraft:standing_signs");
public static final BlockCategory STONE_BRICKS = get("minecraft:stone_bricks");
public static final BlockCategory TRAPDOORS = get("minecraft:trapdoors");
public static final BlockCategory UNDERWATER_BONEMEALS = get("minecraft:underwater_bonemeals");
public static final BlockCategory VALID_SPAWN = get("minecraft:valid_spawn");
public static final BlockCategory WALL_CORALS = get("minecraft:wall_corals");
public static final BlockCategory WALL_SIGNS = get("minecraft:wall_signs");
public static final BlockCategory WALLS = get("minecraft:walls");
public static final BlockCategory WITHER_IMMUNE = get("minecraft:wither_immune");
public static final BlockCategory WOODEN_BUTTONS = get("minecraft:wooden_buttons");
public static final BlockCategory WOODEN_DOORS = get("minecraft:wooden_doors");
public static final BlockCategory WOODEN_FENCES = get("minecraft:wooden_fences");
public static final BlockCategory WOODEN_PRESSURE_PLATES = get("minecraft:wooden_pressure_plates");
public static final BlockCategory WOODEN_SLABS = get("minecraft:wooden_slabs");
public static final BlockCategory WOODEN_STAIRS = get("minecraft:wooden_stairs");
public static final BlockCategory WOODEN_TRAPDOORS = get("minecraft:wooden_trapdoors");
public static final BlockCategory WOOL = get("minecraft:wool");
private BlockCategories() {

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.world.block;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.registry.Category;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import java.util.Set;
@ -30,7 +31,7 @@ import java.util.Set;
* A category of blocks. This is due to the splitting up of
* blocks such as wool into separate ids.
*/
public class BlockCategory extends Category<BlockType> {
public class BlockCategory extends Category<BlockType> implements Keyed {
public static final NamespacedRegistry<BlockCategory> REGISTRY = new NamespacedRegistry<>("block tag");

View File

@ -66,7 +66,7 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
* @deprecated magic number
* @return BlockState
*/
@Deprecated
public static BlockState getFromInternalId(int combinedId) throws InputParseException {
return BlockTypes.getFromStateId(combinedId).withStateId(combinedId);
@ -208,7 +208,6 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
return getBlockType().withPropertyId(propertyId);
}
@Override
public BlockType getBlockType() {
return this.blockType;
@ -250,6 +249,16 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
}
}
@Override
public <V> V getState(final Property<V> property) {
try {
AbstractProperty ap = (AbstractProperty) property;
return (V) ap.getValue(this.getInternalId());
} catch (ClassCastException e) {
throw new IllegalArgumentException("Property not found: " + property);
}
}
@Override
public <V> BlockState with(final PropertyKey property, final V value) {
try {
@ -262,7 +271,7 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
}
@Override
public final Map<Property<?>, Object> getStates() {
public Map<Property<?>, Object> getStates() {
BlockType type = this.getBlockType();
// Lazily initialize the map
Map<? extends Property, Object> map = Maps.asMap(type.getPropertiesSet(), (Function<Property, Object>) this::getState);
@ -270,13 +279,19 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
}
@Override
public final <V> V getState(final Property<V> property) {
try {
AbstractProperty ap = (AbstractProperty) property;
return (V) ap.getValue(this.getInternalId());
} catch (ClassCastException e) {
throw new IllegalArgumentException("Property not found: " + property);
public boolean equalsFuzzy(BlockStateHolder<?> o) {
if (null == o) {
return false;
}
if (this == o) {
// Added a reference equality check for speediness
return true;
}
if (o.getClass() == BlockState.class) {
return o.getOrdinal() == this.getOrdinal();
}
return o.equalsFuzzy(this);
}
@Override
@ -291,7 +306,7 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
@Deprecated
@Override
public final <V> V getState(final PropertyKey key) {
public <V> V getState(PropertyKey key) {
return getState(getBlockType().getProperty(key));
}
@ -303,14 +318,6 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
return new BaseBlock(this, compoundTag);
}
@Override
public boolean equalsFuzzy(BlockStateHolder<?> o) {
if (o.getClass() == BlockState.class) {
return o.getOrdinal() == this.getOrdinal();
}
return o.equalsFuzzy(this);
}
@Override
public int getInternalId() {
return internalId;

View File

@ -21,30 +21,30 @@ package com.sk89q.worldedit.world.block;
import static com.google.common.base.Preconditions.checkArgument;
import com.boydti.fawe.util.ReflectionUtils;
import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.SingleBlockTypeMask;
import com.sk89q.worldedit.function.pattern.FawePattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.extension.platform.Capability;
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.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import javax.annotation.Nullable;
public class BlockType implements FawePattern, Keyed {
private final String id;
@ -71,7 +71,7 @@ public class BlockType implements FawePattern, Keyed {
*/
@Override
public String getId() {
return this.id;
return this.id;
}
public String getNamespace() {
@ -104,35 +104,17 @@ public class BlockType implements FawePattern, Keyed {
if (settings.stateOrdinals == null) return settings.defaultState;
return BlockTypes.states[settings.stateOrdinals[propertyId]];
}
@Deprecated
public BlockState withStateId(int internalStateId) { //
return this.withPropertyId(internalStateId >> BlockTypes.BIT_OFFSET);
}
/**
* Properties string in the form property1=foo,prop2=bar
* @param properties
* @return
*/
public BlockState withProperties(String properties) { //
int id = getInternalId();
for (String keyPair : properties.split(",")) {
String[] split = keyPair.split("=");
String name = split[0];
String value = split[1];
AbstractProperty btp = settings.propertiesMap.get(name);
id = btp.modify(id, btp.getValueFor(value));
}
return withStateId(id);
}
/**
* Gets the properties of this BlockType in a key->property mapping.
* Gets the properties of this BlockType in a {@code key->property} mapping.
*
* @return The properties map
*/
@Deprecated
public Map<String, ? extends Property<?>> getPropertyMap() {
return this.settings.propertiesMap;
}
@ -142,9 +124,8 @@ public class BlockType implements FawePattern, Keyed {
*
* @return the properties
*/
@Deprecated
public List<? extends Property<?>> getProperties() {
return this.settings.propertiesList;
return ImmutableList.copyOf(this.getPropertyMap().values());
}
@Deprecated
@ -158,16 +139,19 @@ public class BlockType implements FawePattern, Keyed {
* @param name The name
* @return The property
*/
@Deprecated
public <V> Property<V> getProperty(String name) {
return (Property<V>) this.settings.propertiesMap.get(name);
// Assume it works, CCE later at runtime if not.
@SuppressWarnings("unchecked")
Property<V> property = (Property<V>) getPropertyMap().get(name);
checkArgument(property != null, "%s has no property named %s", this, name);
return property;
}
public boolean hasProperty(PropertyKey key) {
int ordinal = key.ordinal();
return this.settings.propertiesMapArr.length > ordinal ? this.settings.propertiesMapArr[ordinal] != null : false;
}
public <V> Property<V> getProperty(PropertyKey key) {
try {
return (Property<V>) this.settings.propertiesMapArr[key.ordinal()];
@ -185,7 +169,7 @@ public class BlockType implements FawePattern, Keyed {
return this.settings.defaultState;
}
public FuzzyBlockState getFuzzyMatcher() { //
public FuzzyBlockState getFuzzyMatcher() {
return new FuzzyBlockState(this);
}
@ -222,7 +206,6 @@ public class BlockType implements FawePattern, Keyed {
return withStateId(id);
}
/**
* Gets whether this block type has an item representation.
*
@ -262,6 +245,7 @@ public class BlockType implements FawePattern, Keyed {
*
* @return legacy id or 0, if unknown
*/
@Deprecated
public int getLegacyCombinedId() {
Integer combinedId = LegacyMapper.getInstance().getLegacyCombined(this);
return combinedId == null ? 0 : combinedId;
@ -278,21 +262,21 @@ public class BlockType implements FawePattern, Keyed {
return this.settings.internalId;
}
@Override
public String toString() {
return getId();
}
@Override
public int hashCode() {
return settings.internalId;
return this.id.hashCode();
}
@Override
public boolean equals(Object obj) {
return obj == this;
return obj instanceof BlockType && this.id.equals(((BlockType) obj).id);
}
@Override
public String toString() {
return getId();
}
@Override
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
@ -310,7 +294,7 @@ public class BlockType implements FawePattern, Keyed {
@Deprecated
public int getLegacyId() { //
public int getLegacyId() {
Integer id = LegacyMapper.getInstance().getLegacyCombined(this.getDefaultState());
if (id != null) {
return id >> 4;

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.world.block;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.registry.state.PropertyKey;
@ -38,11 +39,7 @@ public class FuzzyBlockState extends BlockState {
private final Map<PropertyKey, Object> props;
FuzzyBlockState(BlockType blockType) {
this(blockType.getDefaultState(), null);
}
public FuzzyBlockState(BlockState state) {
this(state, null);
super(blockType);
}
private FuzzyBlockState(BlockState state, Map<Property<?>, Object> values) {

View File

@ -83,18 +83,17 @@ public class AnvilChunk13 implements Chunk {
continue;
}
int blocksPerChunkSection = 16 * 16 * 16;
BlockState[] chunkSectionBlocks = new BlockState[blocksPerChunkSection];
blocks[y] = chunkSectionBlocks;
// parse palette
List<CompoundTag> paletteEntries = sectionTag.getList("Palette", CompoundTag.class);
int paletteSize = paletteEntries.size();
if (paletteSize == 0) {
continue;
}
BlockState[] palette = new BlockState[paletteSize];
for (int paletteEntryId = 0; paletteEntryId < paletteSize; paletteEntryId++) {
CompoundTag paletteEntry = paletteEntries.get(paletteEntryId);
BlockType type = BlockTypes.get(paletteEntry.getString("Name"));
if(type == null) {
if (type == null) {
throw new InvalidFormatException("Invalid block type: " + paletteEntry.getString("Name"));
}
BlockState blockState = type.getDefaultState();
@ -121,11 +120,16 @@ public class AnvilChunk13 implements Chunk {
// parse block states
long[] blockStatesSerialized = NBTUtils.getChildTag(sectionTag.getValue(), "BlockStates", LongArrayTag.class).getValue();
int blocksPerChunkSection = 16 * 16 * 16;
BlockState[] chunkSectionBlocks = new BlockState[blocksPerChunkSection];
blocks[y] = chunkSectionBlocks;
long currentSerializedValue = 0;
int nextSerializedItem = 0;
int remainingBits = 0;
for (int blockPos = 0; blockPos < blocksPerChunkSection; blockPos++) {
int localBlockId = 0;
int localBlockId;
if (remainingBits < paletteBits) {
int bitsNextLong = paletteBits - remainingBits;
localBlockId = (int) currentSerializedValue;
@ -159,14 +163,13 @@ public class AnvilChunk13 implements Chunk {
* @throws DataException
*/
private void populateTileEntities() throws DataException {
tileEntities = new HashMap<>();
if (!rootTag.getValue().containsKey("TileEntities")) {
return;
}
List<Tag> tags = NBTUtils.getChildTag(rootTag.getValue(),
"TileEntities", ListTag.class).getValue();
tileEntities = new HashMap<>();
for (Tag tag : tags) {
if (!(tag instanceof CompoundTag)) {
throw new InvalidFormatException("CompoundTag expected in TileEntities");
@ -225,6 +228,7 @@ public class AnvilChunk13 implements Chunk {
if (state.getMaterial().hasContainer()) {
CompoundTag tileEntity = getBlockTileEntity(position);
return state.toBaseBlock(tileEntity);
}

View File

@ -187,6 +187,7 @@ public class OldChunk implements Chunk {
}
if (state.getBlockType().getMaterial().hasContainer()) {
CompoundTag tileEntity = getBlockTileEntity(position);
if (tileEntity != null) {
return state.toBaseBlock(tileEntity);
}

View File

@ -19,10 +19,11 @@
package com.sk89q.worldedit.world.entity;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.RegistryItem;
import com.sk89q.worldedit.registry.NamespacedRegistry;
public class EntityType implements RegistryItem {
public class EntityType implements RegistryItem, Keyed {
public static final NamespacedRegistry<EntityType> REGISTRY = new NamespacedRegistry<>("entity type");
@ -36,6 +37,7 @@ public class EntityType implements RegistryItem {
this.id = id;
}
@Override
public String getId() {
return this.id;
}

View File

@ -29,6 +29,7 @@ public class EntityTypes {
@Nullable public static final EntityType BAT = get("minecraft:bat");
@Nullable public static final EntityType BLAZE = get("minecraft:blaze");
@Nullable public static final EntityType BOAT = get("minecraft:boat");
@Nullable public static final EntityType CAT = get("minecraft:cat");
@Nullable public static final EntityType CAVE_SPIDER = get("minecraft:cave_spider");
@Nullable public static final EntityType CHEST_MINECART = get("minecraft:chest_minecart");
@Nullable public static final EntityType CHICKEN = get("minecraft:chicken");
@ -56,6 +57,7 @@ public class EntityTypes {
@Nullable public static final EntityType FIREBALL = get("minecraft:fireball");
@Nullable public static final EntityType FIREWORK_ROCKET = get("minecraft:firework_rocket");
@Nullable public static final EntityType FISHING_BOBBER = get("minecraft:fishing_bobber");
@Nullable public static final EntityType FOX = get("minecraft:fox");
@Nullable public static final EntityType FURNACE_MINECART = get("minecraft:furnace_minecart");
@Nullable public static final EntityType GHAST = get("minecraft:ghast");
@Nullable public static final EntityType GIANT = get("minecraft:giant");
@ -77,14 +79,17 @@ public class EntityTypes {
@Nullable public static final EntityType MULE = get("minecraft:mule");
@Nullable public static final EntityType OCELOT = get("minecraft:ocelot");
@Nullable public static final EntityType PAINTING = get("minecraft:painting");
@Nullable public static final EntityType PANDA = get("minecraft:panda");
@Nullable public static final EntityType PARROT = get("minecraft:parrot");
@Nullable public static final EntityType PHANTOM = get("minecraft:phantom");
@Nullable public static final EntityType PIG = get("minecraft:pig");
@Nullable public static final EntityType PILLAGER = get("minecraft:pillager");
@Nullable public static final EntityType PLAYER = get("minecraft:player");
@Nullable public static final EntityType POLAR_BEAR = get("minecraft:polar_bear");
@Nullable public static final EntityType POTION = get("minecraft:potion");
@Nullable public static final EntityType PUFFERFISH = get("minecraft:pufferfish");
@Nullable public static final EntityType RABBIT = get("minecraft:rabbit");
@Nullable public static final EntityType RAVAGER = get("minecraft:ravager");
@Nullable public static final EntityType SALMON = get("minecraft:salmon");
@Nullable public static final EntityType SHEEP = get("minecraft:sheep");
@Nullable public static final EntityType SHULKER = get("minecraft:shulker");
@ -103,12 +108,14 @@ public class EntityTypes {
@Nullable public static final EntityType STRAY = get("minecraft:stray");
@Nullable public static final EntityType TNT = get("minecraft:tnt");
@Nullable public static final EntityType TNT_MINECART = get("minecraft:tnt_minecart");
@Nullable public static final EntityType TRADER_LLAMA = get("minecraft:trader_llama");
@Nullable public static final EntityType TRIDENT = get("minecraft:trident");
@Nullable public static final EntityType TROPICAL_FISH = get("minecraft:tropical_fish");
@Nullable public static final EntityType TURTLE = get("minecraft:turtle");
@Nullable public static final EntityType VEX = get("minecraft:vex");
@Nullable public static final EntityType VILLAGER = get("minecraft:villager");
@Nullable public static final EntityType VINDICATOR = get("minecraft:vindicator");
@Nullable public static final EntityType WANDERING_TRADER = get("minecraft:wandering_trader");
@Nullable public static final EntityType WITCH = get("minecraft:witch");
@Nullable public static final EntityType WITHER = get("minecraft:wither");
@Nullable public static final EntityType WITHER_SKELETON = get("minecraft:wither_skeleton");
@ -125,7 +132,7 @@ public class EntityTypes {
public static @Nullable EntityType get(final String id) {
return EntityType.REGISTRY.get(id);
}
public static EntityType parse(String id) {
if (id.startsWith("minecraft:")) id = id.substring(10);
switch (id) {

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.world.fluid;
import com.sk89q.worldedit.registry.Category;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import java.util.Collections;
@ -29,7 +30,7 @@ import java.util.Set;
* A category of fluids. This is due to the splitting up of
* blocks such as wool into separate ids.
*/
public class FluidCategory extends Category<FluidType> {
public class FluidCategory extends Category<FluidType> implements Keyed {
public static final NamespacedRegistry<FluidCategory> REGISTRY = new NamespacedRegistry<>("fluid tag");

View File

@ -19,14 +19,15 @@
package com.sk89q.worldedit.world.fluid;
import com.sk89q.worldedit.registry.RegistryItem;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import com.sk89q.worldedit.registry.RegistryItem;
/**
* Minecraft now has a 'fluid' system. This is a
* stub class to represent what it may be in the future.
*/
public class FluidType implements RegistryItem {
public class FluidType implements RegistryItem, Keyed {
public static final NamespacedRegistry<FluidType> REGISTRY = new NamespacedRegistry<>("fluid type");
@ -41,17 +42,20 @@ public class FluidType implements RegistryItem {
*
* @return The id
*/
@Override
public String getId() {
return this.id;
}
private int internalId;
//UNUSED
@Override
public void setInternalId(int internalId) {
this.internalId = internalId;
}
//UNUSED
@Override
public int getInternalId() {
return internalId;

View File

@ -19,9 +19,10 @@
package com.sk89q.worldedit.world.gamemode;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.Registry;
public class GameMode {
public class GameMode implements Keyed {
public static final Registry<GameMode> REGISTRY = new Registry<>("game mode");
@ -31,6 +32,7 @@ public class GameMode {
this.id = id;
}
@Override
public String getId() {
return this.id;
}

View File

@ -21,9 +21,8 @@ package com.sk89q.worldedit.world.gamemode;
import javax.annotation.Nullable;
public class GameModes {
public final class GameModes {
public static final GameMode NOT_SET = register("");
public static final GameMode SURVIVAL = register("survival");
public static final GameMode CREATIVE = register("creative");
public static final GameMode ADVENTURE = register("adventure");
@ -40,7 +39,8 @@ public class GameModes {
return GameMode.REGISTRY.register(gameMode.getId(), gameMode);
}
public static @Nullable GameMode get(final String id) {
@Nullable
public static GameMode get(final String id) {
return GameMode.REGISTRY.get(id);
}

View File

@ -26,33 +26,42 @@ public final class ItemCategories {
public static final ItemCategory ACACIA_LOGS = get("minecraft:acacia_logs");
public static final ItemCategory ANVIL = get("minecraft:anvil");
public static final ItemCategory ARROWS = get("minecraft:arrows");
public static final ItemCategory BANNERS = get("minecraft:banners");
public static final ItemCategory BEDS = get("minecraft:beds");
public static final ItemCategory BIRCH_LOGS = get("minecraft:birch_logs");
public static final ItemCategory BOATS = get("minecraft:boats");
public static final ItemCategory BUTTONS = get("minecraft:buttons");
public static final ItemCategory CARPETS = get("minecraft:carpets");
public static final ItemCategory CORAL = get("minecraft:coral");
public static final ItemCategory CORAL_PLANTS = get("minecraft:coral_plants");
public static final ItemCategory COALS = get("minecraft:coals");
public static final ItemCategory DARK_OAK_LOGS = get("minecraft:dark_oak_logs");
public static final ItemCategory DOORS = get("minecraft:doors");
public static final ItemCategory FENCES = get("minecraft:fences");
public static final ItemCategory FISHES = get("minecraft:fishes");
public static final ItemCategory JUNGLE_LOGS = get("minecraft:jungle_logs");
public static final ItemCategory LEAVES = get("minecraft:leaves");
public static final ItemCategory LOGS = get("minecraft:logs");
public static final ItemCategory MUSIC_DISCS = get("minecraft:music_discs");
public static final ItemCategory OAK_LOGS = get("minecraft:oak_logs");
public static final ItemCategory PLANKS = get("minecraft:planks");
public static final ItemCategory RAILS = get("minecraft:rails");
public static final ItemCategory SAND = get("minecraft:sand");
public static final ItemCategory SAPLINGS = get("minecraft:saplings");
public static final ItemCategory SIGNS = get("minecraft:signs");
public static final ItemCategory SLABS = get("minecraft:slabs");
public static final ItemCategory SMALL_FLOWERS = get("minecraft:small_flowers");
public static final ItemCategory SPRUCE_LOGS = get("minecraft:spruce_logs");
public static final ItemCategory STAIRS = get("minecraft:stairs");
public static final ItemCategory STONE_BRICKS = get("minecraft:stone_bricks");
public static final ItemCategory TRAPDOORS = get("minecraft:trapdoors");
public static final ItemCategory WALLS = get("minecraft:walls");
public static final ItemCategory WOODEN_BUTTONS = get("minecraft:wooden_buttons");
public static final ItemCategory WOODEN_DOORS = get("minecraft:wooden_doors");
public static final ItemCategory WOODEN_FENCES = get("minecraft:wooden_fences");
public static final ItemCategory WOODEN_PRESSURE_PLATES = get("minecraft:wooden_pressure_plates");
public static final ItemCategory WOODEN_SLABS = get("minecraft:wooden_slabs");
public static final ItemCategory WOODEN_STAIRS = get("minecraft:wooden_stairs");
public static final ItemCategory WOODEN_TRAPDOORS = get("minecraft:wooden_trapdoors");
public static final ItemCategory WOOL = get("minecraft:wool");
private ItemCategories() {

View File

@ -23,6 +23,7 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.registry.Category;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import java.util.Set;
@ -31,7 +32,7 @@ import java.util.Set;
* A category of items. This is due to the splitting up of
* items such as wool into separate ids.
*/
public class ItemCategory extends Category<ItemType> {
public class ItemCategory extends Category<ItemType> implements Keyed {
public static final NamespacedRegistry<ItemCategory> REGISTRY = new NamespacedRegistry<>("item tag");

View File

@ -23,18 +23,20 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.registry.RegistryItem;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import com.sk89q.worldedit.registry.RegistryItem;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import javax.annotation.Nullable;
public class ItemType implements RegistryItem {
public class ItemType implements RegistryItem, Keyed {
public static final NamespacedRegistry<ItemType> REGISTRY = new NamespacedRegistry<>("item type");
private String id;
private String name;
private BlockType blockType;
private boolean initBlockType;
private BaseItem defaultState;
@ -47,6 +49,7 @@ public class ItemType implements RegistryItem {
this.id = id;
}
@Override
public String getId() {
return this.id;
}
@ -69,12 +72,14 @@ public class ItemType implements RegistryItem {
* @return The name, or ID
*/
public String getName() {
String name = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getItemRegistry().getName(this);
if (name == null) {
return getId();
} else {
return name;
name = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries()
.getItemRegistry().getName(this);
if (name == null) {
name = "";
}
}
return name.isEmpty() ? getId() : name;
}

View File

@ -19,11 +19,11 @@
package com.sk89q.worldedit.world.item;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Optional;
public final class ItemTypes {
@ -37,6 +37,7 @@ public final class ItemTypes {
@Nullable public static final ItemType ACACIA_PLANKS = get("minecraft:acacia_planks");
@Nullable public static final ItemType ACACIA_PRESSURE_PLATE = get("minecraft:acacia_pressure_plate");
@Nullable public static final ItemType ACACIA_SAPLING = get("minecraft:acacia_sapling");
@Nullable public static final ItemType ACACIA_SIGN = get("minecraft:acacia_sign");
@Nullable public static final ItemType ACACIA_SLAB = get("minecraft:acacia_slab");
@Nullable public static final ItemType ACACIA_STAIRS = get("minecraft:acacia_stairs");
@Nullable public static final ItemType ACACIA_TRAPDOOR = get("minecraft:acacia_trapdoor");
@ -45,12 +46,17 @@ public final class ItemTypes {
@Nullable public static final ItemType AIR = get("minecraft:air");
@Nullable public static final ItemType ALLIUM = get("minecraft:allium");
@Nullable public static final ItemType ANDESITE = get("minecraft:andesite");
@Nullable public static final ItemType ANDESITE_SLAB = get("minecraft:andesite_slab");
@Nullable public static final ItemType ANDESITE_STAIRS = get("minecraft:andesite_stairs");
@Nullable public static final ItemType ANDESITE_WALL = get("minecraft:andesite_wall");
@Nullable public static final ItemType ANVIL = get("minecraft:anvil");
@Nullable public static final ItemType APPLE = get("minecraft:apple");
@Nullable public static final ItemType ARMOR_STAND = get("minecraft:armor_stand");
@Nullable public static final ItemType ARROW = get("minecraft:arrow");
@Nullable public static final ItemType AZURE_BLUET = get("minecraft:azure_bluet");
@Nullable public static final ItemType BAKED_POTATO = get("minecraft:baked_potato");
@Nullable public static final ItemType BAMBOO = get("minecraft:bamboo");
@Nullable public static final ItemType BARREL = get("minecraft:barrel");
@Nullable public static final ItemType BARRIER = get("minecraft:barrier");
@Nullable public static final ItemType BAT_SPAWN_EGG = get("minecraft:bat_spawn_egg");
@Nullable public static final ItemType BEACON = get("minecraft:beacon");
@ -59,6 +65,7 @@ public final class ItemTypes {
@Nullable public static final ItemType BEETROOT = get("minecraft:beetroot");
@Nullable public static final ItemType BEETROOT_SEEDS = get("minecraft:beetroot_seeds");
@Nullable public static final ItemType BEETROOT_SOUP = get("minecraft:beetroot_soup");
@Nullable public static final ItemType BELL = get("minecraft:bell");
@Nullable public static final ItemType BIRCH_BOAT = get("minecraft:birch_boat");
@Nullable public static final ItemType BIRCH_BUTTON = get("minecraft:birch_button");
@Nullable public static final ItemType BIRCH_DOOR = get("minecraft:birch_door");
@ -69,6 +76,7 @@ public final class ItemTypes {
@Nullable public static final ItemType BIRCH_PLANKS = get("minecraft:birch_planks");
@Nullable public static final ItemType BIRCH_PRESSURE_PLATE = get("minecraft:birch_pressure_plate");
@Nullable public static final ItemType BIRCH_SAPLING = get("minecraft:birch_sapling");
@Nullable public static final ItemType BIRCH_SIGN = get("minecraft:birch_sign");
@Nullable public static final ItemType BIRCH_SLAB = get("minecraft:birch_slab");
@Nullable public static final ItemType BIRCH_STAIRS = get("minecraft:birch_stairs");
@Nullable public static final ItemType BIRCH_TRAPDOOR = get("minecraft:birch_trapdoor");
@ -78,12 +86,14 @@ public final class ItemTypes {
@Nullable public static final ItemType BLACK_CARPET = get("minecraft:black_carpet");
@Nullable public static final ItemType BLACK_CONCRETE = get("minecraft:black_concrete");
@Nullable public static final ItemType BLACK_CONCRETE_POWDER = get("minecraft:black_concrete_powder");
@Nullable public static final ItemType BLACK_DYE = get("minecraft:black_dye");
@Nullable public static final ItemType BLACK_GLAZED_TERRACOTTA = get("minecraft:black_glazed_terracotta");
@Nullable public static final ItemType BLACK_SHULKER_BOX = get("minecraft:black_shulker_box");
@Nullable public static final ItemType BLACK_STAINED_GLASS = get("minecraft:black_stained_glass");
@Nullable public static final ItemType BLACK_STAINED_GLASS_PANE = get("minecraft:black_stained_glass_pane");
@Nullable public static final ItemType BLACK_TERRACOTTA = get("minecraft:black_terracotta");
@Nullable public static final ItemType BLACK_WOOL = get("minecraft:black_wool");
@Nullable public static final ItemType BLAST_FURNACE = get("minecraft:blast_furnace");
@Nullable public static final ItemType BLAZE_POWDER = get("minecraft:blaze_powder");
@Nullable public static final ItemType BLAZE_ROD = get("minecraft:blaze_rod");
@Nullable public static final ItemType BLAZE_SPAWN_EGG = get("minecraft:blaze_spawn_egg");
@ -92,6 +102,7 @@ public final class ItemTypes {
@Nullable public static final ItemType BLUE_CARPET = get("minecraft:blue_carpet");
@Nullable public static final ItemType BLUE_CONCRETE = get("minecraft:blue_concrete");
@Nullable public static final ItemType BLUE_CONCRETE_POWDER = get("minecraft:blue_concrete_powder");
@Nullable public static final ItemType BLUE_DYE = get("minecraft:blue_dye");
@Nullable public static final ItemType BLUE_GLAZED_TERRACOTTA = get("minecraft:blue_glazed_terracotta");
@Nullable public static final ItemType BLUE_ICE = get("minecraft:blue_ice");
@Nullable public static final ItemType BLUE_ORCHID = get("minecraft:blue_orchid");
@ -115,12 +126,14 @@ public final class ItemTypes {
@Nullable public static final ItemType BRICK = get("minecraft:brick");
@Nullable public static final ItemType BRICK_SLAB = get("minecraft:brick_slab");
@Nullable public static final ItemType BRICK_STAIRS = get("minecraft:brick_stairs");
@Nullable public static final ItemType BRICK_WALL = get("minecraft:brick_wall");
@Nullable public static final ItemType BRICKS = get("minecraft:bricks");
@Nullable public static final ItemType BROWN_BANNER = get("minecraft:brown_banner");
@Nullable public static final ItemType BROWN_BED = get("minecraft:brown_bed");
@Nullable public static final ItemType BROWN_CARPET = get("minecraft:brown_carpet");
@Nullable public static final ItemType BROWN_CONCRETE = get("minecraft:brown_concrete");
@Nullable public static final ItemType BROWN_CONCRETE_POWDER = get("minecraft:brown_concrete_powder");
@Nullable public static final ItemType BROWN_DYE = get("minecraft:brown_dye");
@Nullable public static final ItemType BROWN_GLAZED_TERRACOTTA = get("minecraft:brown_glazed_terracotta");
@Nullable public static final ItemType BROWN_MUSHROOM = get("minecraft:brown_mushroom");
@Nullable public static final ItemType BROWN_MUSHROOM_BLOCK = get("minecraft:brown_mushroom_block");
@ -134,11 +147,14 @@ public final class ItemTypes {
@Nullable public static final ItemType BUBBLE_CORAL_FAN = get("minecraft:bubble_coral_fan");
@Nullable public static final ItemType BUCKET = get("minecraft:bucket");
@Nullable public static final ItemType CACTUS = get("minecraft:cactus");
@Nullable public static final ItemType CACTUS_GREEN = get("minecraft:cactus_green");
@Deprecated @Nullable public static final ItemType CACTUS_GREEN = Optional.ofNullable(get("minecraft:cactus_green")).orElseGet(() -> get("minecraft:green_dye"));
@Nullable public static final ItemType CAKE = get("minecraft:cake");
@Nullable public static final ItemType CAMPFIRE = get("minecraft:campfire");
@Nullable public static final ItemType CARROT = get("minecraft:carrot");
@Nullable public static final ItemType CARROT_ON_A_STICK = get("minecraft:carrot_on_a_stick");
@Nullable public static final ItemType CARTOGRAPHY_TABLE = get("minecraft:cartography_table");
@Nullable public static final ItemType CARVED_PUMPKIN = get("minecraft:carved_pumpkin");
@Nullable public static final ItemType CAT_SPAWN_EGG = get("minecraft:cat_spawn_egg");
@Nullable public static final ItemType CAULDRON = get("minecraft:cauldron");
@Nullable public static final ItemType CAVE_SPIDER_SPAWN_EGG = get("minecraft:cave_spider_spawn_egg");
@Nullable public static final ItemType CHAIN_COMMAND_BLOCK = get("minecraft:chain_command_block");
@ -179,6 +195,7 @@ public final class ItemTypes {
@Nullable public static final ItemType COMMAND_BLOCK_MINECART = get("minecraft:command_block_minecart");
@Nullable public static final ItemType COMPARATOR = get("minecraft:comparator");
@Nullable public static final ItemType COMPASS = get("minecraft:compass");
@Nullable public static final ItemType COMPOSTER = get("minecraft:composter");
@Nullable public static final ItemType CONDUIT = get("minecraft:conduit");
@Nullable public static final ItemType COOKED_BEEF = get("minecraft:cooked_beef");
@Nullable public static final ItemType COOKED_CHICKEN = get("minecraft:cooked_chicken");
@ -188,13 +205,18 @@ public final class ItemTypes {
@Nullable public static final ItemType COOKED_RABBIT = get("minecraft:cooked_rabbit");
@Nullable public static final ItemType COOKED_SALMON = get("minecraft:cooked_salmon");
@Nullable public static final ItemType COOKIE = get("minecraft:cookie");
@Nullable public static final ItemType CORNFLOWER = get("minecraft:cornflower");
@Nullable public static final ItemType COW_SPAWN_EGG = get("minecraft:cow_spawn_egg");
@Nullable public static final ItemType CRACKED_STONE_BRICKS = get("minecraft:cracked_stone_bricks");
@Nullable public static final ItemType CRAFTING_TABLE = get("minecraft:crafting_table");
@Nullable public static final ItemType CREEPER_BANNER_PATTERN = get("minecraft:creeper_banner_pattern");
@Nullable public static final ItemType CREEPER_HEAD = get("minecraft:creeper_head");
@Nullable public static final ItemType CREEPER_SPAWN_EGG = get("minecraft:creeper_spawn_egg");
@Nullable public static final ItemType CROSSBOW = get("minecraft:crossbow");
@Nullable public static final ItemType CUT_RED_SANDSTONE = get("minecraft:cut_red_sandstone");
@Nullable public static final ItemType CUT_RED_SANDSTONE_SLAB = get("minecraft:cut_red_sandstone_slab");
@Nullable public static final ItemType CUT_SANDSTONE = get("minecraft:cut_sandstone");
@Nullable public static final ItemType CUT_SANDSTONE_SLAB = get("minecraft:cut_sandstone_slab");
@Nullable public static final ItemType CYAN_BANNER = get("minecraft:cyan_banner");
@Nullable public static final ItemType CYAN_BED = get("minecraft:cyan_bed");
@Nullable public static final ItemType CYAN_CARPET = get("minecraft:cyan_carpet");
@ -209,7 +231,7 @@ public final class ItemTypes {
@Nullable public static final ItemType CYAN_WOOL = get("minecraft:cyan_wool");
@Nullable public static final ItemType DAMAGED_ANVIL = get("minecraft:damaged_anvil");
@Nullable public static final ItemType DANDELION = get("minecraft:dandelion");
@Nullable public static final ItemType DANDELION_YELLOW = get("minecraft:dandelion_yellow");
@Deprecated @Nullable public static final ItemType DANDELION_YELLOW = Optional.ofNullable(get("minecraft:dandelion_yellow")).orElseGet(() -> (get("minecraft:yellow_dye")));
@Nullable public static final ItemType DARK_OAK_BOAT = get("minecraft:dark_oak_boat");
@Nullable public static final ItemType DARK_OAK_BUTTON = get("minecraft:dark_oak_button");
@Nullable public static final ItemType DARK_OAK_DOOR = get("minecraft:dark_oak_door");
@ -220,6 +242,7 @@ public final class ItemTypes {
@Nullable public static final ItemType DARK_OAK_PLANKS = get("minecraft:dark_oak_planks");
@Nullable public static final ItemType DARK_OAK_PRESSURE_PLATE = get("minecraft:dark_oak_pressure_plate");
@Nullable public static final ItemType DARK_OAK_SAPLING = get("minecraft:dark_oak_sapling");
@Nullable public static final ItemType DARK_OAK_SIGN = get("minecraft:dark_oak_sign");
@Nullable public static final ItemType DARK_OAK_SLAB = get("minecraft:dark_oak_slab");
@Nullable public static final ItemType DARK_OAK_STAIRS = get("minecraft:dark_oak_stairs");
@Nullable public static final ItemType DARK_OAK_TRAPDOOR = get("minecraft:dark_oak_trapdoor");
@ -260,6 +283,9 @@ public final class ItemTypes {
@Nullable public static final ItemType DIAMOND_SHOVEL = get("minecraft:diamond_shovel");
@Nullable public static final ItemType DIAMOND_SWORD = get("minecraft:diamond_sword");
@Nullable public static final ItemType DIORITE = get("minecraft:diorite");
@Nullable public static final ItemType DIORITE_SLAB = get("minecraft:diorite_slab");
@Nullable public static final ItemType DIORITE_STAIRS = get("minecraft:diorite_stairs");
@Nullable public static final ItemType DIORITE_WALL = get("minecraft:diorite_wall");
@Nullable public static final ItemType DIRT = get("minecraft:dirt");
@Nullable public static final ItemType DISPENSER = get("minecraft:dispenser");
@Nullable public static final ItemType DOLPHIN_SPAWN_EGG = get("minecraft:dolphin_spawn_egg");
@ -284,6 +310,9 @@ public final class ItemTypes {
@Nullable public static final ItemType END_PORTAL_FRAME = get("minecraft:end_portal_frame");
@Nullable public static final ItemType END_ROD = get("minecraft:end_rod");
@Nullable public static final ItemType END_STONE = get("minecraft:end_stone");
@Nullable public static final ItemType END_STONE_BRICK_SLAB = get("minecraft:end_stone_brick_slab");
@Nullable public static final ItemType END_STONE_BRICK_STAIRS = get("minecraft:end_stone_brick_stairs");
@Nullable public static final ItemType END_STONE_BRICK_WALL = get("minecraft:end_stone_brick_wall");
@Nullable public static final ItemType END_STONE_BRICKS = get("minecraft:end_stone_bricks");
@Nullable public static final ItemType ENDER_CHEST = get("minecraft:ender_chest");
@Nullable public static final ItemType ENDER_EYE = get("minecraft:ender_eye");
@ -304,9 +333,12 @@ public final class ItemTypes {
@Nullable public static final ItemType FIREWORK_ROCKET = get("minecraft:firework_rocket");
@Nullable public static final ItemType FIREWORK_STAR = get("minecraft:firework_star");
@Nullable public static final ItemType FISHING_ROD = get("minecraft:fishing_rod");
@Nullable public static final ItemType FLETCHING_TABLE = get("minecraft:fletching_table");
@Nullable public static final ItemType FLINT = get("minecraft:flint");
@Nullable public static final ItemType FLINT_AND_STEEL = get("minecraft:flint_and_steel");
@Nullable public static final ItemType FLOWER_BANNER_PATTERN = get("minecraft:flower_banner_pattern");
@Nullable public static final ItemType FLOWER_POT = get("minecraft:flower_pot");
@Nullable public static final ItemType FOX_SPAWN_EGG = get("minecraft:fox_spawn_egg");
@Nullable public static final ItemType FURNACE = get("minecraft:furnace");
@Nullable public static final ItemType FURNACE_MINECART = get("minecraft:furnace_minecart");
@Nullable public static final ItemType GHAST_SPAWN_EGG = get("minecraft:ghast_spawn_egg");
@ -315,6 +347,7 @@ public final class ItemTypes {
@Nullable public static final ItemType GLASS_BOTTLE = get("minecraft:glass_bottle");
@Nullable public static final ItemType GLASS_PANE = get("minecraft:glass_pane");
@Nullable public static final ItemType GLISTERING_MELON_SLICE = get("minecraft:glistering_melon_slice");
@Nullable public static final ItemType GLOBE_BANNER_PATTERN = get("minecraft:globe_banner_pattern");
@Nullable public static final ItemType GLOWSTONE = get("minecraft:glowstone");
@Nullable public static final ItemType GLOWSTONE_DUST = get("minecraft:glowstone_dust");
@Nullable public static final ItemType GOLD_BLOCK = get("minecraft:gold_block");
@ -334,6 +367,9 @@ public final class ItemTypes {
@Nullable public static final ItemType GOLDEN_SHOVEL = get("minecraft:golden_shovel");
@Nullable public static final ItemType GOLDEN_SWORD = get("minecraft:golden_sword");
@Nullable public static final ItemType GRANITE = get("minecraft:granite");
@Nullable public static final ItemType GRANITE_SLAB = get("minecraft:granite_slab");
@Nullable public static final ItemType GRANITE_STAIRS = get("minecraft:granite_stairs");
@Nullable public static final ItemType GRANITE_WALL = get("minecraft:granite_wall");
@Nullable public static final ItemType GRASS = get("minecraft:grass");
@Nullable public static final ItemType GRASS_BLOCK = get("minecraft:grass_block");
@Nullable public static final ItemType GRASS_PATH = get("minecraft:grass_path");
@ -355,12 +391,14 @@ public final class ItemTypes {
@Nullable public static final ItemType GREEN_CARPET = get("minecraft:green_carpet");
@Nullable public static final ItemType GREEN_CONCRETE = get("minecraft:green_concrete");
@Nullable public static final ItemType GREEN_CONCRETE_POWDER = get("minecraft:green_concrete_powder");
@Nullable public static final ItemType GREEN_DYE = get("minecraft:green_dye");
@Nullable public static final ItemType GREEN_GLAZED_TERRACOTTA = get("minecraft:green_glazed_terracotta");
@Nullable public static final ItemType GREEN_SHULKER_BOX = get("minecraft:green_shulker_box");
@Nullable public static final ItemType GREEN_STAINED_GLASS = get("minecraft:green_stained_glass");
@Nullable public static final ItemType GREEN_STAINED_GLASS_PANE = get("minecraft:green_stained_glass_pane");
@Nullable public static final ItemType GREEN_TERRACOTTA = get("minecraft:green_terracotta");
@Nullable public static final ItemType GREEN_WOOL = get("minecraft:green_wool");
@Nullable public static final ItemType GRINDSTONE = get("minecraft:grindstone");
@Nullable public static final ItemType GUARDIAN_SPAWN_EGG = get("minecraft:guardian_spawn_egg");
@Nullable public static final ItemType GUNPOWDER = get("minecraft:gunpowder");
@Nullable public static final ItemType HAY_BLOCK = get("minecraft:hay_block");
@ -400,6 +438,7 @@ public final class ItemTypes {
@Nullable public static final ItemType IRON_TRAPDOOR = get("minecraft:iron_trapdoor");
@Nullable public static final ItemType ITEM_FRAME = get("minecraft:item_frame");
@Nullable public static final ItemType JACK_O_LANTERN = get("minecraft:jack_o_lantern");
@Nullable public static final ItemType JIGSAW = get("minecraft:jigsaw");
@Nullable public static final ItemType JUKEBOX = get("minecraft:jukebox");
@Nullable public static final ItemType JUNGLE_BOAT = get("minecraft:jungle_boat");
@Nullable public static final ItemType JUNGLE_BUTTON = get("minecraft:jungle_button");
@ -411,6 +450,7 @@ public final class ItemTypes {
@Nullable public static final ItemType JUNGLE_PLANKS = get("minecraft:jungle_planks");
@Nullable public static final ItemType JUNGLE_PRESSURE_PLATE = get("minecraft:jungle_pressure_plate");
@Nullable public static final ItemType JUNGLE_SAPLING = get("minecraft:jungle_sapling");
@Nullable public static final ItemType JUNGLE_SIGN = get("minecraft:jungle_sign");
@Nullable public static final ItemType JUNGLE_SLAB = get("minecraft:jungle_slab");
@Nullable public static final ItemType JUNGLE_STAIRS = get("minecraft:jungle_stairs");
@Nullable public static final ItemType JUNGLE_TRAPDOOR = get("minecraft:jungle_trapdoor");
@ -418,6 +458,7 @@ public final class ItemTypes {
@Nullable public static final ItemType KELP = get("minecraft:kelp");
@Nullable public static final ItemType KNOWLEDGE_BOOK = get("minecraft:knowledge_book");
@Nullable public static final ItemType LADDER = get("minecraft:ladder");
@Nullable public static final ItemType LANTERN = get("minecraft:lantern");
@Nullable public static final ItemType LAPIS_BLOCK = get("minecraft:lapis_block");
@Nullable public static final ItemType LAPIS_LAZULI = get("minecraft:lapis_lazuli");
@Nullable public static final ItemType LAPIS_ORE = get("minecraft:lapis_ore");
@ -428,7 +469,9 @@ public final class ItemTypes {
@Nullable public static final ItemType LEATHER_BOOTS = get("minecraft:leather_boots");
@Nullable public static final ItemType LEATHER_CHESTPLATE = get("minecraft:leather_chestplate");
@Nullable public static final ItemType LEATHER_HELMET = get("minecraft:leather_helmet");
@Nullable public static final ItemType LEATHER_HORSE_ARMOR = get("minecraft:leather_horse_armor");
@Nullable public static final ItemType LEATHER_LEGGINGS = get("minecraft:leather_leggings");
@Nullable public static final ItemType LECTERN = get("minecraft:lectern");
@Nullable public static final ItemType LEVER = get("minecraft:lever");
@Nullable public static final ItemType LIGHT_BLUE_BANNER = get("minecraft:light_blue_banner");
@Nullable public static final ItemType LIGHT_BLUE_BED = get("minecraft:light_blue_bed");
@ -456,6 +499,7 @@ public final class ItemTypes {
@Nullable public static final ItemType LIGHT_GRAY_WOOL = get("minecraft:light_gray_wool");
@Nullable public static final ItemType LIGHT_WEIGHTED_PRESSURE_PLATE = get("minecraft:light_weighted_pressure_plate");
@Nullable public static final ItemType LILAC = get("minecraft:lilac");
@Nullable public static final ItemType LILY_OF_THE_VALLEY = get("minecraft:lily_of_the_valley");
@Nullable public static final ItemType LILY_PAD = get("minecraft:lily_pad");
@Nullable public static final ItemType LIME_BANNER = get("minecraft:lime_banner");
@Nullable public static final ItemType LIME_BED = get("minecraft:lime_bed");
@ -471,6 +515,7 @@ public final class ItemTypes {
@Nullable public static final ItemType LIME_WOOL = get("minecraft:lime_wool");
@Nullable public static final ItemType LINGERING_POTION = get("minecraft:lingering_potion");
@Nullable public static final ItemType LLAMA_SPAWN_EGG = get("minecraft:llama_spawn_egg");
@Nullable public static final ItemType LOOM = get("minecraft:loom");
@Nullable public static final ItemType MAGENTA_BANNER = get("minecraft:magenta_banner");
@Nullable public static final ItemType MAGENTA_BED = get("minecraft:magenta_bed");
@Nullable public static final ItemType MAGENTA_CARPET = get("minecraft:magenta_carpet");
@ -492,9 +537,15 @@ public final class ItemTypes {
@Nullable public static final ItemType MELON_SLICE = get("minecraft:melon_slice");
@Nullable public static final ItemType MILK_BUCKET = get("minecraft:milk_bucket");
@Nullable public static final ItemType MINECART = get("minecraft:minecart");
@Nullable public static final ItemType MOJANG_BANNER_PATTERN = get("minecraft:mojang_banner_pattern");
@Nullable public static final ItemType MOOSHROOM_SPAWN_EGG = get("minecraft:mooshroom_spawn_egg");
@Nullable public static final ItemType MOSSY_COBBLESTONE = get("minecraft:mossy_cobblestone");
@Nullable public static final ItemType MOSSY_COBBLESTONE_SLAB = get("minecraft:mossy_cobblestone_slab");
@Nullable public static final ItemType MOSSY_COBBLESTONE_STAIRS = get("minecraft:mossy_cobblestone_stairs");
@Nullable public static final ItemType MOSSY_COBBLESTONE_WALL = get("minecraft:mossy_cobblestone_wall");
@Nullable public static final ItemType MOSSY_STONE_BRICK_SLAB = get("minecraft:mossy_stone_brick_slab");
@Nullable public static final ItemType MOSSY_STONE_BRICK_STAIRS = get("minecraft:mossy_stone_brick_stairs");
@Nullable public static final ItemType MOSSY_STONE_BRICK_WALL = get("minecraft:mossy_stone_brick_wall");
@Nullable public static final ItemType MOSSY_STONE_BRICKS = get("minecraft:mossy_stone_bricks");
@Nullable public static final ItemType MULE_SPAWN_EGG = get("minecraft:mule_spawn_egg");
@Nullable public static final ItemType MUSHROOM_STEM = get("minecraft:mushroom_stem");
@ -519,6 +570,7 @@ public final class ItemTypes {
@Nullable public static final ItemType NETHER_BRICK_FENCE = get("minecraft:nether_brick_fence");
@Nullable public static final ItemType NETHER_BRICK_SLAB = get("minecraft:nether_brick_slab");
@Nullable public static final ItemType NETHER_BRICK_STAIRS = get("minecraft:nether_brick_stairs");
@Nullable public static final ItemType NETHER_BRICK_WALL = get("minecraft:nether_brick_wall");
@Nullable public static final ItemType NETHER_BRICKS = get("minecraft:nether_bricks");
@Nullable public static final ItemType NETHER_QUARTZ_ORE = get("minecraft:nether_quartz_ore");
@Nullable public static final ItemType NETHER_STAR = get("minecraft:nether_star");
@ -536,6 +588,7 @@ public final class ItemTypes {
@Nullable public static final ItemType OAK_PLANKS = get("minecraft:oak_planks");
@Nullable public static final ItemType OAK_PRESSURE_PLATE = get("minecraft:oak_pressure_plate");
@Nullable public static final ItemType OAK_SAPLING = get("minecraft:oak_sapling");
@Nullable public static final ItemType OAK_SIGN = get("minecraft:oak_sign");
@Nullable public static final ItemType OAK_SLAB = get("minecraft:oak_slab");
@Nullable public static final ItemType OAK_STAIRS = get("minecraft:oak_stairs");
@Nullable public static final ItemType OAK_TRAPDOOR = get("minecraft:oak_trapdoor");
@ -559,6 +612,7 @@ public final class ItemTypes {
@Nullable public static final ItemType OXEYE_DAISY = get("minecraft:oxeye_daisy");
@Nullable public static final ItemType PACKED_ICE = get("minecraft:packed_ice");
@Nullable public static final ItemType PAINTING = get("minecraft:painting");
@Nullable public static final ItemType PANDA_SPAWN_EGG = get("minecraft:panda_spawn_egg");
@Nullable public static final ItemType PAPER = get("minecraft:paper");
@Nullable public static final ItemType PARROT_SPAWN_EGG = get("minecraft:parrot_spawn_egg");
@Nullable public static final ItemType PEONY = get("minecraft:peony");
@ -566,6 +620,7 @@ public final class ItemTypes {
@Nullable public static final ItemType PHANTOM_MEMBRANE = get("minecraft:phantom_membrane");
@Nullable public static final ItemType PHANTOM_SPAWN_EGG = get("minecraft:phantom_spawn_egg");
@Nullable public static final ItemType PIG_SPAWN_EGG = get("minecraft:pig_spawn_egg");
@Nullable public static final ItemType PILLAGER_SPAWN_EGG = get("minecraft:pillager_spawn_egg");
@Nullable public static final ItemType PINK_BANNER = get("minecraft:pink_banner");
@Nullable public static final ItemType PINK_BED = get("minecraft:pink_bed");
@Nullable public static final ItemType PINK_CARPET = get("minecraft:pink_carpet");
@ -585,8 +640,14 @@ public final class ItemTypes {
@Nullable public static final ItemType POISONOUS_POTATO = get("minecraft:poisonous_potato");
@Nullable public static final ItemType POLAR_BEAR_SPAWN_EGG = get("minecraft:polar_bear_spawn_egg");
@Nullable public static final ItemType POLISHED_ANDESITE = get("minecraft:polished_andesite");
@Nullable public static final ItemType POLISHED_ANDESITE_SLAB = get("minecraft:polished_andesite_slab");
@Nullable public static final ItemType POLISHED_ANDESITE_STAIRS = get("minecraft:polished_andesite_stairs");
@Nullable public static final ItemType POLISHED_DIORITE = get("minecraft:polished_diorite");
@Nullable public static final ItemType POLISHED_DIORITE_SLAB = get("minecraft:polished_diorite_slab");
@Nullable public static final ItemType POLISHED_DIORITE_STAIRS = get("minecraft:polished_diorite_stairs");
@Nullable public static final ItemType POLISHED_GRANITE = get("minecraft:polished_granite");
@Nullable public static final ItemType POLISHED_GRANITE_SLAB = get("minecraft:polished_granite_slab");
@Nullable public static final ItemType POLISHED_GRANITE_STAIRS = get("minecraft:polished_granite_stairs");
@Nullable public static final ItemType POPPED_CHORUS_FRUIT = get("minecraft:popped_chorus_fruit");
@Nullable public static final ItemType POPPY = get("minecraft:poppy");
@Nullable public static final ItemType PORKCHOP = get("minecraft:porkchop");
@ -601,6 +662,7 @@ public final class ItemTypes {
@Nullable public static final ItemType PRISMARINE_SHARD = get("minecraft:prismarine_shard");
@Nullable public static final ItemType PRISMARINE_SLAB = get("minecraft:prismarine_slab");
@Nullable public static final ItemType PRISMARINE_STAIRS = get("minecraft:prismarine_stairs");
@Nullable public static final ItemType PRISMARINE_WALL = get("minecraft:prismarine_wall");
@Nullable public static final ItemType PUFFERFISH = get("minecraft:pufferfish");
@Nullable public static final ItemType PUFFERFISH_BUCKET = get("minecraft:pufferfish_bucket");
@Nullable public static final ItemType PUFFERFISH_SPAWN_EGG = get("minecraft:pufferfish_spawn_egg");
@ -634,19 +696,25 @@ public final class ItemTypes {
@Nullable public static final ItemType RABBIT_SPAWN_EGG = get("minecraft:rabbit_spawn_egg");
@Nullable public static final ItemType RABBIT_STEW = get("minecraft:rabbit_stew");
@Nullable public static final ItemType RAIL = get("minecraft:rail");
@Nullable public static final ItemType RAVAGER_SPAWN_EGG = get("minecraft:ravager_spawn_egg");
@Nullable public static final ItemType RED_BANNER = get("minecraft:red_banner");
@Nullable public static final ItemType RED_BED = get("minecraft:red_bed");
@Nullable public static final ItemType RED_CARPET = get("minecraft:red_carpet");
@Nullable public static final ItemType RED_CONCRETE = get("minecraft:red_concrete");
@Nullable public static final ItemType RED_CONCRETE_POWDER = get("minecraft:red_concrete_powder");
@Nullable public static final ItemType RED_DYE = get("minecraft:red_dye");
@Nullable public static final ItemType RED_GLAZED_TERRACOTTA = get("minecraft:red_glazed_terracotta");
@Nullable public static final ItemType RED_MUSHROOM = get("minecraft:red_mushroom");
@Nullable public static final ItemType RED_MUSHROOM_BLOCK = get("minecraft:red_mushroom_block");
@Nullable public static final ItemType RED_NETHER_BRICK_SLAB = get("minecraft:red_nether_brick_slab");
@Nullable public static final ItemType RED_NETHER_BRICK_STAIRS = get("minecraft:red_nether_brick_stairs");
@Nullable public static final ItemType RED_NETHER_BRICK_WALL = get("minecraft:red_nether_brick_wall");
@Nullable public static final ItemType RED_NETHER_BRICKS = get("minecraft:red_nether_bricks");
@Nullable public static final ItemType RED_SAND = get("minecraft:red_sand");
@Nullable public static final ItemType RED_SANDSTONE = get("minecraft:red_sandstone");
@Nullable public static final ItemType RED_SANDSTONE_SLAB = get("minecraft:red_sandstone_slab");
@Nullable public static final ItemType RED_SANDSTONE_STAIRS = get("minecraft:red_sandstone_stairs");
@Nullable public static final ItemType RED_SANDSTONE_WALL = get("minecraft:red_sandstone_wall");
@Nullable public static final ItemType RED_SHULKER_BOX = get("minecraft:red_shulker_box");
@Nullable public static final ItemType RED_STAINED_GLASS = get("minecraft:red_stained_glass");
@Nullable public static final ItemType RED_STAINED_GLASS_PANE = get("minecraft:red_stained_glass_pane");
@ -661,7 +729,7 @@ public final class ItemTypes {
@Nullable public static final ItemType REPEATER = get("minecraft:repeater");
@Nullable public static final ItemType REPEATING_COMMAND_BLOCK = get("minecraft:repeating_command_block");
@Nullable public static final ItemType ROSE_BUSH = get("minecraft:rose_bush");
@Nullable public static final ItemType ROSE_RED = get("minecraft:rose_red");
@Deprecated @Nullable public static final ItemType ROSE_RED = Optional.ofNullable(get("minecraft:rose_red")).orElseGet(() -> (get("minecraft:red_dye")));
@Nullable public static final ItemType ROTTEN_FLESH = get("minecraft:rotten_flesh");
@Nullable public static final ItemType SADDLE = get("minecraft:saddle");
@Nullable public static final ItemType SALMON = get("minecraft:salmon");
@ -671,6 +739,8 @@ public final class ItemTypes {
@Nullable public static final ItemType SANDSTONE = get("minecraft:sandstone");
@Nullable public static final ItemType SANDSTONE_SLAB = get("minecraft:sandstone_slab");
@Nullable public static final ItemType SANDSTONE_STAIRS = get("minecraft:sandstone_stairs");
@Nullable public static final ItemType SANDSTONE_WALL = get("minecraft:sandstone_wall");
@Nullable public static final ItemType SCAFFOLDING = get("minecraft:scaffolding");
@Nullable public static final ItemType SCUTE = get("minecraft:scute");
@Nullable public static final ItemType SEA_LANTERN = get("minecraft:sea_lantern");
@Nullable public static final ItemType SEA_PICKLE = get("minecraft:sea_pickle");
@ -681,18 +751,28 @@ public final class ItemTypes {
@Nullable public static final ItemType SHULKER_BOX = get("minecraft:shulker_box");
@Nullable public static final ItemType SHULKER_SHELL = get("minecraft:shulker_shell");
@Nullable public static final ItemType SHULKER_SPAWN_EGG = get("minecraft:shulker_spawn_egg");
@Nullable public static final ItemType SIGN = get("minecraft:sign");
@Deprecated @Nullable public static final ItemType SIGN = Optional.ofNullable(get("minecraft:sign")).orElseGet(() -> (get("minecraft:oak_sign")));
@Nullable public static final ItemType SILVERFISH_SPAWN_EGG = get("minecraft:silverfish_spawn_egg");
@Nullable public static final ItemType SKELETON_HORSE_SPAWN_EGG = get("minecraft:skeleton_horse_spawn_egg");
@Nullable public static final ItemType SKELETON_SKULL = get("minecraft:skeleton_skull");
@Nullable public static final ItemType SKELETON_SPAWN_EGG = get("minecraft:skeleton_spawn_egg");
@Nullable public static final ItemType SKULL_BANNER_PATTERN = get("minecraft:skull_banner_pattern");
@Nullable public static final ItemType SLIME_BALL = get("minecraft:slime_ball");
@Nullable public static final ItemType SLIME_BLOCK = get("minecraft:slime_block");
@Nullable public static final ItemType SLIME_SPAWN_EGG = get("minecraft:slime_spawn_egg");
@Nullable public static final ItemType SMITHING_TABLE = get("minecraft:smithing_table");
@Nullable public static final ItemType SMOKER = get("minecraft:smoker");
@Nullable public static final ItemType SMOOTH_QUARTZ = get("minecraft:smooth_quartz");
@Nullable public static final ItemType SMOOTH_QUARTZ_SLAB = get("minecraft:smooth_quartz_slab");
@Nullable public static final ItemType SMOOTH_QUARTZ_STAIRS = get("minecraft:smooth_quartz_stairs");
@Nullable public static final ItemType SMOOTH_RED_SANDSTONE = get("minecraft:smooth_red_sandstone");
@Nullable public static final ItemType SMOOTH_RED_SANDSTONE_SLAB = get("minecraft:smooth_red_sandstone_slab");
@Nullable public static final ItemType SMOOTH_RED_SANDSTONE_STAIRS = get("minecraft:smooth_red_sandstone_stairs");
@Nullable public static final ItemType SMOOTH_SANDSTONE = get("minecraft:smooth_sandstone");
@Nullable public static final ItemType SMOOTH_SANDSTONE_SLAB = get("minecraft:smooth_sandstone_slab");
@Nullable public static final ItemType SMOOTH_SANDSTONE_STAIRS = get("minecraft:smooth_sandstone_stairs");
@Nullable public static final ItemType SMOOTH_STONE = get("minecraft:smooth_stone");
@Nullable public static final ItemType SMOOTH_STONE_SLAB = get("minecraft:smooth_stone_slab");
@Nullable public static final ItemType SNOW = get("minecraft:snow");
@Nullable public static final ItemType SNOW_BLOCK = get("minecraft:snow_block");
@Nullable public static final ItemType SNOWBALL = get("minecraft:snowball");
@ -713,6 +793,7 @@ public final class ItemTypes {
@Nullable public static final ItemType SPRUCE_PLANKS = get("minecraft:spruce_planks");
@Nullable public static final ItemType SPRUCE_PRESSURE_PLATE = get("minecraft:spruce_pressure_plate");
@Nullable public static final ItemType SPRUCE_SAPLING = get("minecraft:spruce_sapling");
@Nullable public static final ItemType SPRUCE_SIGN = get("minecraft:spruce_sign");
@Nullable public static final ItemType SPRUCE_SLAB = get("minecraft:spruce_slab");
@Nullable public static final ItemType SPRUCE_STAIRS = get("minecraft:spruce_stairs");
@Nullable public static final ItemType SPRUCE_TRAPDOOR = get("minecraft:spruce_trapdoor");
@ -724,6 +805,7 @@ public final class ItemTypes {
@Nullable public static final ItemType STONE_AXE = get("minecraft:stone_axe");
@Nullable public static final ItemType STONE_BRICK_SLAB = get("minecraft:stone_brick_slab");
@Nullable public static final ItemType STONE_BRICK_STAIRS = get("minecraft:stone_brick_stairs");
@Nullable public static final ItemType STONE_BRICK_WALL = get("minecraft:stone_brick_wall");
@Nullable public static final ItemType STONE_BRICKS = get("minecraft:stone_bricks");
@Nullable public static final ItemType STONE_BUTTON = get("minecraft:stone_button");
@Nullable public static final ItemType STONE_HOE = get("minecraft:stone_hoe");
@ -731,7 +813,9 @@ public final class ItemTypes {
@Nullable public static final ItemType STONE_PRESSURE_PLATE = get("minecraft:stone_pressure_plate");
@Nullable public static final ItemType STONE_SHOVEL = get("minecraft:stone_shovel");
@Nullable public static final ItemType STONE_SLAB = get("minecraft:stone_slab");
@Nullable public static final ItemType STONE_STAIRS = get("minecraft:stone_stairs");
@Nullable public static final ItemType STONE_SWORD = get("minecraft:stone_sword");
@Nullable public static final ItemType STONECUTTER = get("minecraft:stonecutter");
@Nullable public static final ItemType STRAY_SPAWN_EGG = get("minecraft:stray_spawn_egg");
@Nullable public static final ItemType STRING = get("minecraft:string");
@Nullable public static final ItemType STRIPPED_ACACIA_LOG = get("minecraft:stripped_acacia_log");
@ -751,6 +835,8 @@ public final class ItemTypes {
@Nullable public static final ItemType SUGAR = get("minecraft:sugar");
@Nullable public static final ItemType SUGAR_CANE = get("minecraft:sugar_cane");
@Nullable public static final ItemType SUNFLOWER = get("minecraft:sunflower");
@Nullable public static final ItemType SUSPICIOUS_STEW = get("minecraft:suspicious_stew");
@Nullable public static final ItemType SWEET_BERRIES = get("minecraft:sweet_berries");
@Nullable public static final ItemType TALL_GRASS = get("minecraft:tall_grass");
@Nullable public static final ItemType TERRACOTTA = get("minecraft:terracotta");
@Nullable public static final ItemType TIPPED_ARROW = get("minecraft:tipped_arrow");
@ -758,6 +844,7 @@ public final class ItemTypes {
@Nullable public static final ItemType TNT_MINECART = get("minecraft:tnt_minecart");
@Nullable public static final ItemType TORCH = get("minecraft:torch");
@Nullable public static final ItemType TOTEM_OF_UNDYING = get("minecraft:totem_of_undying");
@Nullable public static final ItemType TRADER_LLAMA_SPAWN_EGG = get("minecraft:trader_llama_spawn_egg");
@Nullable public static final ItemType TRAPPED_CHEST = get("minecraft:trapped_chest");
@Nullable public static final ItemType TRIDENT = get("minecraft:trident");
@Nullable public static final ItemType TRIPWIRE_HOOK = get("minecraft:tripwire_hook");
@ -774,6 +861,7 @@ public final class ItemTypes {
@Nullable public static final ItemType VILLAGER_SPAWN_EGG = get("minecraft:villager_spawn_egg");
@Nullable public static final ItemType VINDICATOR_SPAWN_EGG = get("minecraft:vindicator_spawn_egg");
@Nullable public static final ItemType VINE = get("minecraft:vine");
@Nullable public static final ItemType WANDERING_TRADER_SPAWN_EGG = get("minecraft:wandering_trader_spawn_egg");
@Nullable public static final ItemType WATER_BUCKET = get("minecraft:water_bucket");
@Nullable public static final ItemType WET_SPONGE = get("minecraft:wet_sponge");
@Nullable public static final ItemType WHEAT = get("minecraft:wheat");
@ -783,6 +871,7 @@ public final class ItemTypes {
@Nullable public static final ItemType WHITE_CARPET = get("minecraft:white_carpet");
@Nullable public static final ItemType WHITE_CONCRETE = get("minecraft:white_concrete");
@Nullable public static final ItemType WHITE_CONCRETE_POWDER = get("minecraft:white_concrete_powder");
@Nullable public static final ItemType WHITE_DYE = get("minecraft:white_dye");
@Nullable public static final ItemType WHITE_GLAZED_TERRACOTTA = get("minecraft:white_glazed_terracotta");
@Nullable public static final ItemType WHITE_SHULKER_BOX = get("minecraft:white_shulker_box");
@Nullable public static final ItemType WHITE_STAINED_GLASS = get("minecraft:white_stained_glass");
@ -791,6 +880,7 @@ public final class ItemTypes {
@Nullable public static final ItemType WHITE_TULIP = get("minecraft:white_tulip");
@Nullable public static final ItemType WHITE_WOOL = get("minecraft:white_wool");
@Nullable public static final ItemType WITCH_SPAWN_EGG = get("minecraft:witch_spawn_egg");
@Nullable public static final ItemType WITHER_ROSE = get("minecraft:wither_rose");
@Nullable public static final ItemType WITHER_SKELETON_SKULL = get("minecraft:wither_skeleton_skull");
@Nullable public static final ItemType WITHER_SKELETON_SPAWN_EGG = get("minecraft:wither_skeleton_spawn_egg");
@Nullable public static final ItemType WOLF_SPAWN_EGG = get("minecraft:wolf_spawn_egg");
@ -806,6 +896,7 @@ public final class ItemTypes {
@Nullable public static final ItemType YELLOW_CARPET = get("minecraft:yellow_carpet");
@Nullable public static final ItemType YELLOW_CONCRETE = get("minecraft:yellow_concrete");
@Nullable public static final ItemType YELLOW_CONCRETE_POWDER = get("minecraft:yellow_concrete_powder");
@Nullable public static final ItemType YELLOW_DYE = get("minecraft:yellow_dye");
@Nullable public static final ItemType YELLOW_GLAZED_TERRACOTTA = get("minecraft:yellow_glazed_terracotta");
@Nullable public static final ItemType YELLOW_SHULKER_BOX = get("minecraft:yellow_shulker_box");
@Nullable public static final ItemType YELLOW_STAINED_GLASS = get("minecraft:yellow_stained_glass");

View File

@ -23,6 +23,8 @@ import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import java.util.OptionalInt;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Collections;
@ -64,6 +66,14 @@ public interface BlockRegistry {
*/
Map<String, ? extends Property<?>> getProperties(BlockType blockType);
/**
* Retrieve the internal ID for a given state, if possible.
*
* @param state The block state
* @return the internal ID of the state
*/
OptionalInt getInternalBlockStateId(BlockState state);
/**
* Register all blocks
*/

View File

@ -20,16 +20,19 @@
package com.sk89q.worldedit.world.registry;
import com.google.common.io.Resources;
import com.google.gson.*;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.gson.VectorAdapter;
import com.sk89q.worldedit.util.io.ResourceLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import java.io.IOException;
import java.lang.reflect.Type;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.HashMap;
@ -47,7 +50,7 @@ import java.util.Map;
* reading fails (which occurs when this class is first instantiated), then
* the methods will return {@code null}s for all blocks.</p>
*/
public class BundledBlockData {
public final class BundledBlockData {
private static final Logger log = LoggerFactory.getLogger(BundledBlockData.class);
private static BundledBlockData INSTANCE;
@ -73,20 +76,19 @@ public class BundledBlockData {
private void loadFromResource() throws IOException {
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter());
gsonBuilder.registerTypeAdapter(int.class, (JsonDeserializer<Integer>) (json, typeOfT, context) -> {
JsonPrimitive primitive = (JsonPrimitive) json;
if (primitive.isString()) {
String value = primitive.getAsString();
if (value.charAt(0) == '#') return Integer.parseInt(value.substring(1), 16);
return Integer.parseInt(value);
}
return primitive.getAsInt();
});
Gson gson = gsonBuilder.create();
URL url = BundledBlockData.class.getResource("blocks.json");
URL url = null;
final int dataVersion = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataVersion();
if (dataVersion > 1900) { // > MC 1.13
url = ResourceLoader.getResource(BundledBlockData.class, "blocks.114.json");
}
if (url == null) {
url = ResourceLoader.getResource(BundledBlockData.class, "blocks.json");
}
if (url == null) {
throw new IOException("Could not find blocks.json");
}
log.debug("Using {} for bundled block data.", url);
String data = Resources.toString(url, Charset.defaultCharset());
List<BlockEntry> entries = gson.fromJson(data, new TypeToken<List<BlockEntry>>() {}.getType());

View File

@ -20,12 +20,13 @@
package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.Map;
import javax.annotation.Nullable;
import java.util.OptionalInt;
/**
* A block registry that uses {@link BundledBlockData} to serve information
@ -52,4 +53,9 @@ public class BundledBlockRegistry implements BlockRegistry {
return Collections.emptyMap(); // Oof
}
@Override
public OptionalInt getInternalBlockStateId(BlockState state) {
return OptionalInt.empty();
}
}

View File

@ -23,8 +23,11 @@ import com.google.common.io.Resources;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.gson.VectorAdapter;
import com.sk89q.worldedit.util.io.ResourceLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -47,7 +50,7 @@ import java.util.Map;
* reading fails (which occurs when this class is first instantiated), then
* the methods will return {@code null}s for all items.</p>
*/
public class BundledItemData {
public final class BundledItemData {
private static final Logger log = LoggerFactory.getLogger(BundledItemData.class);
private static BundledItemData INSTANCE;
@ -74,10 +77,18 @@ public class BundledItemData {
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter());
Gson gson = gsonBuilder.create();
URL url = BundledItemData.class.getResource("items.json");
URL url = null;
final int dataVersion = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataVersion();
if (dataVersion > 1900) { // > MC 1.13
url = ResourceLoader.getResource(BundledBlockData.class, "items.114.json");
}
if (url == null) {
url = ResourceLoader.getResource(BundledBlockData.class, "items.json");
}
if (url == null) {
throw new IOException("Could not find items.json");
}
log.debug("Using {} for bundled item data.", url);
String data = Resources.toString(url, Charset.defaultCharset());
List<ItemEntry> entries = gson.fromJson(data, new TypeToken<List<ItemEntry>>() {}.getType());

View File

@ -20,13 +20,14 @@
package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.registry.Category;
import com.sk89q.worldedit.registry.Keyed;
import java.util.Set;
/**
* A registry of categories. Minecraft internally calls these 'Tags'.
*/
public interface CategoryRegistry<T> {
public interface CategoryRegistry<T extends Keyed> {
/**
* Gets a set of values with a given category.

View File

@ -19,13 +19,9 @@
package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.world.entity.EntityType;
import com.sk89q.worldedit.world.entity.EntityTypes;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
import javax.annotation.Nullable;
import java.util.Collection;

View File

@ -28,10 +28,15 @@ import com.google.common.io.Resources;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.util.gson.VectorAdapter;
import com.sk89q.worldedit.util.io.ResourceLoader;
import com.sk89q.worldedit.world.DataFixer;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -49,7 +54,7 @@ import java.net.URL;
import java.nio.charset.Charset;
import java.util.Map;
public class LegacyMapper {
public final class LegacyMapper {
private static final Logger log = LoggerFactory.getLogger(LegacyMapper.class);
private static LegacyMapper INSTANCE;
@ -66,7 +71,6 @@ public class LegacyMapper {
try {
loadFromResource();
} catch (Throwable e) {
e.printStackTrace();
log.warn("Failed to load the built-in legacy id registry", e);
}
}
@ -80,12 +84,14 @@ public class LegacyMapper {
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter());
Gson gson = gsonBuilder.disableHtmlEscaping().create();
URL url = LegacyMapper.class.getResource("legacy.json");
URL url = ResourceLoader.getResource(LegacyMapper.class, "legacy.json");
if (url == null) {
throw new IOException("Could not find legacy.json");
}
String source = Resources.toString(url, Charset.defaultCharset());
LegacyDataFile dataFile = gson.fromJson(source, new TypeToken<LegacyDataFile>() {}.getType());
DataFixer fixer = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataFixer();
ParserContext parserContext = new ParserContext();
parserContext.setPreferringWildcard(false);
parserContext.setRestricted(false);
@ -93,7 +99,7 @@ public class LegacyMapper {
for (Map.Entry<String, String> blockEntry : dataFile.blocks.entrySet()) {
try {
BlockStateHolder blockState = BlockState.get(null, blockEntry.getValue());
BlockState blockState = BlockState.get(null, blockEntry.getValue());
BlockType type = blockState.getBlockType();
if (type.hasProperty(PropertyKey.WATERLOGGED)) {
blockState = blockState.with(PropertyKey.WATERLOGGED, false);
@ -103,7 +109,7 @@ public class LegacyMapper {
blockStateToLegacyId4Data.put(blockState.getInternalId(), (Integer) combinedId);
blockStateToLegacyId4Data.putIfAbsent(blockState.getInternalBlockTypeId(), combinedId);
} catch (Exception e) {
} catch (InputParseException e) {
log.warn("Unknown block: " + blockEntry.getValue());
}
}
@ -143,7 +149,12 @@ public class LegacyMapper {
public BlockState getBlockFromLegacy(String input) {
if (input.startsWith("minecraft:")) input = input.substring(10);
return BlockState.getFromInternalId(blockArr[getCombinedId(input)]);
try {
return BlockState.getFromInternalId(blockArr[getCombinedId(input)]);
} catch (InputParseException e) {
e.printStackTrace();
}
return null;
}
@Nullable
@ -186,7 +197,11 @@ public class LegacyMapper {
try {
int internalId = blockArr[combinedId];
if (internalId == 0) return null;
return BlockState.getFromInternalId(internalId);
try {
return BlockState.getFromInternalId(internalId);
} catch (InputParseException e) {
e.printStackTrace();
}
} catch (IndexOutOfBoundsException ignore) {
return null;
}
@ -196,14 +211,18 @@ public class LegacyMapper {
extra = extraId4DataToStateId.get(combinedId & 0xFF0);
}
if (extra != null) {
return BlockState.getFromInternalId(extra);
try {
return BlockState.getFromInternalId(extra);
} catch (InputParseException e) {
e.printStackTrace();
}
}
return null;
}
public void register(int id, int data, BlockStateHolder state) {
int combinedId = ((id << 4) + data);
extraId4DataToStateId.put((int) combinedId, (Integer) state.getInternalId());
extraId4DataToStateId.put(combinedId, (Integer) state.getInternalId());
blockStateToLegacyId4Data.putIfAbsent(state.getInternalId(), combinedId);
}
@ -229,7 +248,7 @@ public class LegacyMapper {
if(plotBlock instanceof StringPlotBlock) {
try {
return BlockTypes.get(plotBlock.toString()).getDefaultState().toBaseBlock();
}catch(Throwable failed) {
} catch (Throwable failed) {
log.error("Unable to convert StringPlotBlock " + plotBlock + " to BaseBlock!");
failed.printStackTrace();
return null;
@ -237,7 +256,7 @@ public class LegacyMapper {
}else if(plotBlock instanceof LegacyPlotBlock) {
try {
return BaseBlock.getState(((LegacyPlotBlock)plotBlock).getId(), ((LegacyPlotBlock)plotBlock).getData()).toBaseBlock();
}catch(Throwable failed) {
} catch (Throwable failed) {
log.error("Unable to convert LegacyPlotBlock " + plotBlock + " to BaseBlock!");
failed.printStackTrace();
return null;

View File

@ -178,7 +178,7 @@ public class PassthroughBlockMaterial implements BlockMaterial {
if (blockMaterial == null) {
return true;
} else {
return blockMaterial.isOpaque();
return blockMaterial.isBurnable();
}
}

View File

@ -45,7 +45,7 @@ class SimpleBlockMaterial implements BlockMaterial {
@Override
public boolean isAir() {
return isAir;
return this.isAir;
}
@Override

View File

@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.util.Calendar;
import java.time.ZonedDateTime;
import java.util.Locale;
import java.util.zip.ZipFile;
@ -47,7 +47,7 @@ public class Snapshot implements Comparable<Snapshot> {
protected File file;
protected String name;
protected Calendar date;
protected ZonedDateTime date;
/**
* Construct a snapshot restoration operation.
@ -188,7 +188,7 @@ public class Snapshot implements Comparable<Snapshot> {
*
* @return date for the snapshot
*/
public Calendar getDate() {
public ZonedDateTime getDate() {
return date;
}
@ -197,7 +197,7 @@ public class Snapshot implements Comparable<Snapshot> {
*
* @param date the date of the snapshot
*/
public void setDate(Calendar date) {
public void setDate(ZonedDateTime date) {
this.date = date;
}

View File

@ -23,14 +23,16 @@ package com.sk89q.worldedit.world.snapshot;
import com.sk89q.worldedit.world.storage.MissingWorldException;
import javax.annotation.Nullable;
import java.io.File;
import java.io.FilenameFilter;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
import java.util.Locale;
/**
* A repository contains zero or more snapshots.
@ -115,12 +117,12 @@ public class SnapshotRepository {
* @return a snapshot or null
*/
@Nullable
public Snapshot getSnapshotAfter(Calendar date, String world) throws MissingWorldException {
public Snapshot getSnapshotAfter(ZonedDateTime date, String world) throws MissingWorldException {
List<Snapshot> snapshots = getSnapshots(true, world);
Snapshot last = null;
for (Snapshot snapshot : snapshots) {
if (snapshot.getDate() != null && snapshot.getDate().before(date)) {
if (snapshot.getDate() != null && snapshot.getDate().compareTo(date) < 0) {
return last;
}
@ -137,12 +139,12 @@ public class SnapshotRepository {
* @return a snapshot or null
*/
@Nullable
public Snapshot getSnapshotBefore(Calendar date, String world) throws MissingWorldException {
public Snapshot getSnapshotBefore(ZonedDateTime date, String world) throws MissingWorldException {
List<Snapshot> snapshots = getSnapshots(false, world);
Snapshot last = null;
for (Snapshot snapshot : snapshots) {
if (snapshot.getDate().after(date)) {
if (snapshot.getDate().compareTo(date) > 0) {
return last;
}
@ -161,7 +163,7 @@ public class SnapshotRepository {
for (SnapshotDateParser parser : dateParsers) {
Calendar date = parser.detectDate(snapshot.getFile());
if (date != null) {
snapshot.setDate(date);
snapshot.setDate(date.toInstant().atZone(ZoneOffset.UTC));
return;
}
}
@ -207,11 +209,17 @@ public class SnapshotRepository {
return false;
}
return (file.isDirectory() && (new File(file, "level.dat")).exists())
|| (file.isFile() && (file.getName().toLowerCase().endsWith(".zip")
|| file.getName().toLowerCase().endsWith(".tar.bz2")
|| file.getName().toLowerCase().endsWith(".tar.gz")
|| file.getName().toLowerCase().endsWith(".tar")));
if (file.isDirectory() && new File(file, "level.dat").exists()) {
return true;
}
if (file.isFile()) {
String lowerCaseFileName = file.getName().toLowerCase(Locale.ROOT);
return lowerCaseFileName.endsWith(".zip")
|| lowerCaseFileName.endsWith(".tar.bz2")
|| lowerCaseFileName.endsWith(".tar.gz")
|| lowerCaseFileName.endsWith(".tar");
}
return false;
}
/**

View File

@ -27,13 +27,13 @@ import java.util.regex.Pattern;
public class YYMMDDHHIISSParser implements SnapshotDateParser {
protected Pattern patt =
private 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]+)");
+ "([0-9]+)[^0-9]?([0-9]+)[^0-9]?([0-9]+)(\\..*)?");
@Override
public Calendar detectDate(File file) {
Matcher matcher = patt.matcher(file.getName());
Matcher matcher = datePattern.matcher(file.getName());
if (matcher.matches()) {
int year = Integer.parseInt(matcher.group(1));
int month = Integer.parseInt(matcher.group(2));

View File

@ -21,9 +21,13 @@ package com.sk89q.worldedit.world.storage;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.world.DataFixer;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.chunk.AnvilChunk;
import com.sk89q.worldedit.world.chunk.AnvilChunk13;
@ -42,7 +46,7 @@ public abstract class ChunkStore implements Closeable {
/**
* The DataVersion for Minecraft 1.13
*/
public static final int DATA_VERSION_MC_1_13 = 1519;
private static final int DATA_VERSION_MC_1_13 = 1519;
/**
* {@code >>} - to chunk
@ -102,6 +106,15 @@ public abstract class ChunkStore implements Closeable {
}
int dataVersion = rootTag.getInt("DataVersion");
if (dataVersion == 0) dataVersion = -1;
final Platform platform = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING);
final int currentDataVersion = platform.getDataVersion();
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) {
return new AnvilChunk13((CompoundTag) dataFixer.fixUp(DataFixer.FixTypes.CHUNK, rootTag, dataVersion).getValue().get("Level"));
}
}
if (dataVersion >= DATA_VERSION_MC_1_13) {
return new AnvilChunk13(tag);
}
@ -114,6 +127,7 @@ public abstract class ChunkStore implements Closeable {
return new OldChunk(world, tag);
}
@Override
public void close() throws IOException {
}

View File

@ -36,7 +36,7 @@ public abstract class McRegionChunkStore extends ChunkStore {
/**
* Get the filename of a region file.
*
*
* @param position chunk position
* @return the filename
*/
@ -78,13 +78,13 @@ public abstract class McRegionChunkStore extends ChunkStore {
throw new ChunkStoreException("CompoundTag expected for chunk; got " + tag.getClass().getName());
}
return (CompoundTag)tag;
return (CompoundTag) tag;
}
}
/**
* Get the input stream for a chunk file.
*
*
* @param name the name of the chunk file
* @param worldName the world name
* @return an input stream

View File

@ -85,7 +85,7 @@ public class McRegionReader {
/**
* Construct the reader.
*
*
* @param stream the stream
* @throws DataException
* @throws IOException
@ -99,11 +99,10 @@ public class McRegionReader {
/**
* Read the header.
*
* @throws DataException
*
* @throws IOException
*/
private void readHeader() throws DataException, IOException {
private void readHeader() throws IOException {
offsets = new int[SECTOR_INTS];
for (int i = 0; i < SECTOR_INTS; ++i) {
@ -114,7 +113,7 @@ public class McRegionReader {
/**
* Gets the uncompressed data input stream for a chunk.
*
*
* @param position chunk position
* @return an input stream
* @throws IOException
@ -138,7 +137,7 @@ public class McRegionReader {
int sectorNumber = offset >> 8;
int numSectors = offset & 0xFF;
stream.seek(sectorNumber * SECTOR_BYTES);
stream.seek((long) sectorNumber * SECTOR_BYTES);
int length = dataStream.readInt();
if (length > SECTOR_BYTES * numSectors) {
@ -170,7 +169,7 @@ public class McRegionReader {
/**
* Get the offset for a chunk. May return 0 if it doesn't exist.
*
*
* @param x the X coordinate
* @param z the Z coordinate
* @return the offset

View File

@ -52,7 +52,7 @@ public final class NBTConversions {
return new Location(
extent,
positionTag.asDouble(0), positionTag.asDouble(1), positionTag.asDouble(2),
(float) directionTag.asDouble(0), (float) directionTag.asDouble(1));
directionTag.getFloat(0), directionTag.getFloat(1));
}
}

View File

@ -50,7 +50,7 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
* @param zipFile the ZIP file
* @param folder the folder to look into
* @throws IOException
* @throws ZipException
* @throws ZipException
*/
public TrueZipMcRegionChunkStore(File zipFile, String folder) throws IOException, ZipException {
this.zipFile = zipFile;
@ -101,6 +101,7 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
// Check for file
if (pattern.matcher(testEntry.getName()).matches()) {
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf('/'));
if (folder.endsWith("poi")) continue;
name = folder + "/" + name;
break;
}
@ -115,7 +116,14 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
ZipEntry entry = getEntry(name);
if (entry == null) {
throw new MissingChunkException();
if (name.endsWith(".mca")) { // try old mcr format
entry = getEntry(name.replace(".mca", ".mcr"));
if (entry == null) {
throw new MissingChunkException();
}
} else {
throw new MissingChunkException();
}
}
try {
return zip.getInputStream(entry);
@ -126,7 +134,7 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
/**
* Get an entry from the ZIP, trying both types of slashes.
*
*
* @param file the file
* @return an entry
*/
@ -150,7 +158,7 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
ZipEntry testEntry = e.nextElement();
if (testEntry.getName().matches(".*\\.mcr$") || testEntry.getName().matches(".*\\.mca$")) { // TODO: does this need a separate class?
if (testEntry.getName().matches(".*\\.mcr$") || testEntry.getName().matches(".*\\.mca$")) {
return true;
}
}

View File

@ -87,6 +87,7 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
if (testEntry.getName().startsWith(worldName + "/")) {
if (pattern.matcher(testEntry.getName()).matches()) { // does entry end in .mca
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf('/'));
if (folder.endsWith("poi")) continue;
name = folder + "/" + name;
break;
}
@ -102,7 +103,14 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
ZipEntry entry = getEntry(name);
if (entry == null) {
throw new MissingChunkException();
if (name.endsWith(".mca")) { // try old mcr format
entry = getEntry(name.replace(".mca", ".mcr"));
if (entry == null) {
throw new MissingChunkException();
}
} else {
throw new MissingChunkException();
}
}
try {
return zip.getInputStream(entry);
@ -113,7 +121,7 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
/**
* Get an entry from the ZIP, trying both types of slashes.
*
*
* @param file the file
* @return a ZIP entry
*/
@ -136,7 +144,7 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
ZipEntry testEntry = e.nextElement();
if (testEntry.getName().matches(".*\\.mcr$") || testEntry.getName().matches(".*\\.mca$")) { // TODO: does this need a separate class?
if (testEntry.getName().matches(".*\\.mcr$") || testEntry.getName().matches(".*\\.mca$")) {
return true;
}
}

View File

@ -19,9 +19,10 @@
package com.sk89q.worldedit.world.weather;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.Registry;
public class WeatherType {
public class WeatherType implements Keyed {
public static final Registry<WeatherType> REGISTRY = new Registry<>("weather type");
@ -31,6 +32,7 @@ public class WeatherType {
this.id = id;
}
@Override
public String getId() {
return this.id;
}

View File

@ -21,23 +21,25 @@ package com.sk89q.worldedit.world.weather;
import javax.annotation.Nullable;
public class WeatherTypes {
public final class WeatherTypes {
static {
// This isn't really a proper registry - so inject these before they're obtained.
WeatherType.REGISTRY.register("clear", new WeatherType("clear"));
WeatherType.REGISTRY.register("rain", new WeatherType("rain"));
WeatherType.REGISTRY.register("thunder_storm", new WeatherType("thunder_storm"));
}
@Nullable public static final WeatherType CLEAR = get("clear");
@Nullable public static final WeatherType RAIN = get("rain");
@Nullable public static final WeatherType THUNDER_STORM = get("thunder_storm");
public static final WeatherType CLEAR = register("clear");
public static final WeatherType RAIN = register("rain");
public static final WeatherType THUNDER_STORM = register("thunder_storm");
private WeatherTypes() {
}
public static @Nullable WeatherType get(final String id) {
private static WeatherType register(String id) {
return register(new WeatherType(id));
}
public static WeatherType register(WeatherType weather) {
return WeatherType.REGISTRY.register(weather.getId(), weather);
}
@Nullable
public static WeatherType get(final String id) {
return WeatherType.REGISTRY.get(id);
}
}