diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5fb00ae081..66ed7d2b6a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -15,15 +15,15 @@ errorprone = "2.48.0" crankcase = "0.1.0" -fabric-api = "0.156.0+26.2" +fabric-api = "0.160.5+26.3" -neogradle = "7.1.38" -neoforge-minecraft = "26.2" +neogradle = "7.1.39" +neoforge-minecraft = "26.3" -sponge-minecraft = "26.2" +sponge-minecraft = "26.3" # https://repo.spongepowered.org/service/rest/repository/browse/maven-public/org/spongepowered/spongeapi/ sponge-api = "20.0.0-20260726.033647-1" -sponge-api-major = "20" +sponge-api-major = "21" sponge-vanillagradle = "0.3.2" @@ -33,8 +33,8 @@ minimumJdependency = "2.10" minimumTinyRemapper = "0.8.11" # https://repo.enginehub.org/language-files/com/sk89q/worldedit/worldedit-lang/ -lang-worldeditBase = "7.4.5" -lang-version = "2246" +lang-worldeditBase = "7.4.6" +lang-version = "2279" [libraries] neogradle-neoform = { module = "net.neoforged.gradle:neoform", version.ref = "neogradle" } @@ -101,11 +101,11 @@ rhino = "org.mozilla:rhino-runtime:1.7.13" jchronic = "com.sk89q:jchronic:0.2.4a" jlibnoise = "com.sk89q.lib:jlibnoise:1.0.0" -fabric-minecraft = "com.mojang:minecraft:26.2" -fabric-loader = "net.fabricmc:fabric-loader:0.19.3" +fabric-minecraft = "com.mojang:minecraft:26.3" +fabric-loader = "net.fabricmc:fabric-loader:0.19.5" fabric-permissions-api = "me.lucko:fabric-permissions-api:0.7.0" -neoforge = "net.neoforged:neoforge:26.2.0.53-beta" +neoforge = "net.neoforged:neoforge:26.3.0.1-beta" # Mojang-provided libraries, validated by `:worldedit-fabric:verifyMinecraftLibraries` guava = "com.google.guava:guava:33.6.0-jre" @@ -176,13 +176,13 @@ version.ref = "antlr" module = "org.antlr:antlr4-runtime" [libraries.cuiProtocol-common] -module = "org.enginehub.worldeditcui-protocol:worldeditcui-protocol-common-mc26.2" +module = "org.enginehub.worldeditcui-protocol:worldeditcui-protocol-common-mc26.3" version.ref = "cuiProtocol" [libraries.cuiProtocol-fabric] -module = "org.enginehub.worldeditcui-protocol:worldeditcui-protocol-fabric-mc26.2" +module = "org.enginehub.worldeditcui-protocol:worldeditcui-protocol-fabric-mc26.3" version.ref = "cuiProtocol" [libraries.cuiProtocol-neoforge] -module = "org.enginehub.worldeditcui-protocol:worldeditcui-protocol-neoforge-mc26.2" +module = "org.enginehub.worldeditcui-protocol:worldeditcui-protocol-neoforge-mc26.3" version.ref = "cuiProtocol" diff --git a/settings.gradle.kts b/settings.gradle.kts index f7f43333a1..d3b34fd53f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -120,7 +120,7 @@ includeBuild("build-logic") include("worldedit-libs") -listOf("1.21.4", "1.21.5", "1.21.6", "1.21.9", "1.21.11", "26.1", "26.2").forEach { +listOf("1.21.4", "1.21.5", "1.21.6", "1.21.9", "1.21.11", "26.1", "26.2", "26.3").forEach { include("worldedit-bukkit:adapters:adapter-$it") } diff --git a/worldedit-bukkit/adapters/adapter-26.2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_2/PaperweightAdapter.java b/worldedit-bukkit/adapters/adapter-26.2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_2/PaperweightAdapter.java index 5393abeffe..4b784b494c 100644 --- a/worldedit-bukkit/adapters/adapter-26.2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_2/PaperweightAdapter.java +++ b/worldedit-bukkit/adapters/adapter-26.2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_2/PaperweightAdapter.java @@ -236,8 +236,8 @@ public PaperweightAdapter() throws NoSuchFieldException, NoSuchMethodException { int dataVersion = SharedConstants.getCurrentVersion().dataVersion().version(); if (dataVersion != Constants.DATA_VERSION_MC_26_2) { - if (dataVersion <= Constants.DATA_VERSION_MC_26_1_2) { - throw new RuntimeException("Force prevent this loading on <=26.1.2"); + if (dataVersion <= Constants.DATA_VERSION_MC_26_1_2 || dataVersion > Constants.DATA_VERSION_MC_26_2) { + throw new RuntimeException("Force prevent this loading on <=26.1.2 or >26.2"); } logger.warning(WRONG_VERSION); } diff --git a/worldedit-bukkit/adapters/adapter-26.3/build.gradle.kts b/worldedit-bukkit/adapters/adapter-26.3/build.gradle.kts new file mode 100644 index 0000000000..5f22542820 --- /dev/null +++ b/worldedit-bukkit/adapters/adapter-26.3/build.gradle.kts @@ -0,0 +1,10 @@ +import io.papermc.paperweight.userdev.PaperweightUserDependenciesExtension + +plugins { + id("buildlogic.adapter-mojmap") +} + +dependencies { + // https://artifactory.papermc.io/ui/native/universe/io/papermc/paper/dev-bundle/ + the().paperDevBundle("26.3.build.5-alpha") +} diff --git a/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/ComponentConverter.java b/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/ComponentConverter.java new file mode 100644 index 0000000000..03cd877c9c --- /dev/null +++ b/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/ComponentConverter.java @@ -0,0 +1,77 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.bukkit.adapter.impl.v26_3; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonParseException; +import com.google.gson.JsonParser; +import com.google.gson.Strictness; +import com.google.gson.stream.JsonReader; +import com.mojang.serialization.JsonOps; +import net.minecraft.core.HolderLookup; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.ComponentSerialization; +import net.minecraft.network.chat.MutableComponent; + +import java.io.StringReader; +import javax.annotation.Nullable; + +public class ComponentConverter { + + public static class Serializer { + private static final Gson GSON = new GsonBuilder().disableHtmlEscaping().create(); + + private Serializer() { + } + + static MutableComponent deserialize(JsonElement json, HolderLookup.Provider registries) { + return (MutableComponent) ComponentSerialization.CODEC.parse(registries.createSerializationContext(JsonOps.INSTANCE), json).getOrThrow(JsonParseException::new); + } + + static JsonElement serialize(Component text, HolderLookup.Provider registries) { + return ComponentSerialization.CODEC.encodeStart(registries.createSerializationContext(JsonOps.INSTANCE), text).getOrThrow(JsonParseException::new); + } + + public static String toJson(Component text, HolderLookup.Provider registries) { + return GSON.toJson(serialize(text, registries)); + } + + @Nullable + public static MutableComponent fromJson(String json, HolderLookup.Provider registries) { + JsonElement jsonelement = JsonParser.parseString(json); + return jsonelement == null ? null : deserialize(jsonelement, registries); + } + + @Nullable + public static MutableComponent fromJson(@Nullable JsonElement json, HolderLookup.Provider registries) { + return json == null ? null : deserialize(json, registries); + } + + @Nullable + public static MutableComponent fromJsonLenient(String json, HolderLookup.Provider registries) { + JsonReader jsonreader = new JsonReader(new StringReader(json)); + jsonreader.setStrictness(Strictness.LENIENT); + JsonElement jsonelement = JsonParser.parseReader(jsonreader); + return jsonelement == null ? null : deserialize(jsonelement, registries); + } + } +} diff --git a/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightAdapter.java b/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightAdapter.java new file mode 100644 index 0000000000..1daeeb6e83 --- /dev/null +++ b/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightAdapter.java @@ -0,0 +1,1309 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.bukkit.adapter.impl.v26_3; + +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import com.google.common.util.concurrent.Futures; +import com.mojang.serialization.Codec; +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.bukkit.BukkitAdapter; +import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; +import com.sk89q.worldedit.entity.BaseEntity; +import com.sk89q.worldedit.extension.platform.Watchdog; +import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.internal.Constants; +import com.sk89q.worldedit.internal.block.BlockStateIdAccess; +import com.sk89q.worldedit.internal.wna.WorldNativeAccess; +import com.sk89q.worldedit.math.BlockVector2; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.regions.Region; +import com.sk89q.worldedit.registry.state.BooleanProperty; +import com.sk89q.worldedit.registry.state.DirectionalProperty; +import com.sk89q.worldedit.registry.state.EnumProperty; +import com.sk89q.worldedit.registry.state.IntegerProperty; +import com.sk89q.worldedit.registry.state.Property; +import com.sk89q.worldedit.util.Direction; +import com.sk89q.worldedit.util.SideEffect; +import com.sk89q.worldedit.util.concurrency.LazyReference; +import com.sk89q.worldedit.util.formatting.text.Component; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; +import com.sk89q.worldedit.util.formatting.text.serializer.gson.GsonComponentSerializer; +import com.sk89q.worldedit.util.io.file.SafeFiles; +import com.sk89q.worldedit.world.DataFixer; +import com.sk89q.worldedit.world.RegenOptions; +import com.sk89q.worldedit.world.biome.BiomeCategory; +import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.biome.BiomeTypes; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BlockType; +import com.sk89q.worldedit.world.block.BlockTypes; +import com.sk89q.worldedit.world.entity.EntityTypes; +import com.sk89q.worldedit.world.generation.ConfiguredFeatureType; +import com.sk89q.worldedit.world.generation.StructureType; +import com.sk89q.worldedit.world.generation.TreeType; +import com.sk89q.worldedit.world.item.ItemType; +import com.sk89q.worldedit.world.registry.BlockMaterial; +import io.papermc.paper.world.PaperWorldLoader; +import io.papermc.paper.world.saveddata.PaperWorldPDC; +import net.minecraft.SharedConstants; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; +import net.minecraft.core.HolderSet; +import net.minecraft.core.Registry; +import net.minecraft.core.SectionPos; +import net.minecraft.core.component.DataComponentPatch; +import net.minecraft.core.registries.Registries; +import net.minecraft.nbt.ByteArrayTag; +import net.minecraft.nbt.ByteTag; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.DoubleTag; +import net.minecraft.nbt.EndTag; +import net.minecraft.nbt.FloatTag; +import net.minecraft.nbt.IntArrayTag; +import net.minecraft.nbt.IntTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.LongArrayTag; +import net.minecraft.nbt.LongTag; +import net.minecraft.nbt.NbtOps; +import net.minecraft.nbt.ShortTag; +import net.minecraft.nbt.StringTag; +import net.minecraft.nbt.Tag; +import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; +import net.minecraft.network.protocol.game.ClientboundEntityEventPacket; +import net.minecraft.resources.Identifier; +import net.minecraft.resources.ResourceKey; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.dedicated.DedicatedServer; +import net.minecraft.server.level.ChunkResult; +import net.minecraft.server.level.ServerChunkCache; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; +import net.minecraft.util.StringRepresentable; +import net.minecraft.util.Util; +import net.minecraft.util.thread.BlockableEventLoop; +import net.minecraft.world.Clearable; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntitySpawnReason; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.biome.Climate; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.StructureBlockEntity; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.PalettedContainer; +import net.minecraft.world.level.chunk.status.ChunkStatus; +import net.minecraft.world.level.dimension.LevelStem; +import net.minecraft.world.level.levelgen.densityfunction.SamplerContext; +import net.minecraft.world.level.levelgen.feature.CoralTreeFeature; +import net.minecraft.world.level.levelgen.feature.FallenTreeFeature; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.TreeFeature; +import net.minecraft.world.level.levelgen.placement.PlacedFeature; +import net.minecraft.world.level.levelgen.structure.BoundingBox; +import net.minecraft.world.level.levelgen.structure.Structure; +import net.minecraft.world.level.levelgen.structure.StructureStart; +import net.minecraft.world.level.storage.LevelStorageSource; +import net.minecraft.world.level.storage.SavedDataStorage; +import net.minecraft.world.level.storage.TagValueInput; +import net.minecraft.world.level.storage.TagValueOutput; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.World.Environment; +import org.bukkit.block.data.BlockData; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.bukkit.craftbukkit.entity.CraftEntity; +import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.generator.ChunkGenerator; +import org.enginehub.linbus.common.LinTagId; +import org.enginehub.linbus.tree.LinByteArrayTag; +import org.enginehub.linbus.tree.LinByteTag; +import org.enginehub.linbus.tree.LinCompoundTag; +import org.enginehub.linbus.tree.LinDoubleTag; +import org.enginehub.linbus.tree.LinEndTag; +import org.enginehub.linbus.tree.LinFloatTag; +import org.enginehub.linbus.tree.LinIntArrayTag; +import org.enginehub.linbus.tree.LinIntTag; +import org.enginehub.linbus.tree.LinListTag; +import org.enginehub.linbus.tree.LinLongArrayTag; +import org.enginehub.linbus.tree.LinLongTag; +import org.enginehub.linbus.tree.LinShortTag; +import org.enginehub.linbus.tree.LinStringTag; +import org.enginehub.linbus.tree.LinTag; +import org.enginehub.linbus.tree.LinTagType; +import org.spigotmc.SpigotConfig; +import org.spigotmc.WatchdogThread; + +import java.lang.ref.WeakReference; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.OptionalInt; +import java.util.Set; +import java.util.TreeMap; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.stream.Collectors; +import javax.annotation.Nullable; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; + +public final class PaperweightAdapter implements BukkitImplAdapter { + + private final Logger logger = Logger.getLogger(getClass().getCanonicalName()); + + private final Field serverWorldsField; + private final Method getChunkFutureMethod; + private Method asCraftMirror; + private final Field chunkProviderExecutorField; + private final PaperweightDataConverters dataFixer; + private final Watchdog watchdog; + + private static final RandomSource random = RandomSource.create(); + + private static final String WRONG_VERSION = + """ + This version of WorldEdit has not been tested with the current Minecraft version. + While it may work, there might be unexpected issues. + It is recommended to use a version of WorldEdit that supports your Minecraft version. + For more information, see https://worldedit.enginehub.org/en/latest/faq/#bukkit-adapters + """; + + // ------------------------------------------------------------------------ + // Code that may break between versions of Minecraft + // ------------------------------------------------------------------------ + + public PaperweightAdapter() throws NoSuchFieldException, NoSuchMethodException { + // A simple test + var _ = CraftServer.class.cast(Bukkit.getServer()); + + int dataVersion = SharedConstants.getCurrentVersion().dataVersion().version(); + if (dataVersion != Constants.DATA_VERSION_MC_26_3) { + if (dataVersion <= Constants.DATA_VERSION_MC_26_2) { + throw new RuntimeException("Force prevent this loading on <=26.2"); + } + logger.warning(WRONG_VERSION); + } + + serverWorldsField = CraftServer.class.getDeclaredField("worlds"); + serverWorldsField.setAccessible(true); + + getChunkFutureMethod = ServerChunkCache.class.getDeclaredMethod( + StaticRefraction.GET_CHUNK_FUTURE_MAIN_THREAD, + int.class, int.class, ChunkStatus.class, boolean.class + ); + getChunkFutureMethod.setAccessible(true); + + chunkProviderExecutorField = ServerChunkCache.class.getDeclaredField( + StaticRefraction.MAIN_THREAD_PROCESSOR + ); + chunkProviderExecutorField.setAccessible(true); + + this.dataFixer = new PaperweightDataConverters(dataVersion, this); + + Watchdog watchdog; + try { + Class.forName("org.spigotmc.WatchdogThread"); + watchdog = new SpigotWatchdog(); + } catch (ClassNotFoundException | NoSuchFieldException e) { + try { + watchdog = new MojangWatchdog(((CraftServer) Bukkit.getServer()).getServer()); + } catch (NoSuchFieldException ex) { + watchdog = null; + } + } + this.watchdog = watchdog; + + try { + Class.forName("org.spigotmc.SpigotConfig"); + SpigotConfig.config.set("world-settings.worldeditregentempworld.verbose", false); + } catch (ClassNotFoundException ignored) { + // It's fine if we couldn't set it + } + + try { + asCraftMirror = CraftItemStack.class.getMethod("asCraftMirror", ItemStack.class); + } catch (NoSuchMethodException ignored) { + // This is purely for Spigot compatibility. It'll fail on Paper. + asCraftMirror = null; + } + } + + @Override + public DataFixer getDataFixer() { + return this.dataFixer; + } + + /** + * Read the given NBT data into the given tile entity. + * + * @param tileEntity the tile entity + * @param tag the tag + */ + static void readTagIntoTileEntity(net.minecraft.nbt.CompoundTag tag, BlockEntity tileEntity) { + PaperweightLoggingProblemReporter.with(() -> "loading tile entity at " + tileEntity.getBlockPos(), reporter -> { + tileEntity.loadWithComponents(TagValueInput.create(reporter, MinecraftServer.getServer().registryAccess(), tag)); + tileEntity.setChanged(); + return null; + }); + } + + /** + * Get the ID string of the given entity. + * + * @param entity the entity + * @return the entity ID + */ + private static String getEntityId(Entity entity) { + return EntityType.getKey(entity.getType()).toString(); + } + + /** + * Write the entity's NBT data to the given tag. + * + * @param entity the entity + * @param tag the tag + */ + private static boolean readEntityIntoTag(Entity entity, TagValueOutput tag) { + return entity.save(tag); + } + + private static Block getBlockFromType(BlockType blockType) { + return DedicatedServer.getServer().registryAccess().lookupOrThrow(Registries.BLOCK).getValue(Identifier.tryParse(blockType.id())); + } + + private static Item getItemFromType(ItemType itemType) { + return DedicatedServer.getServer().registryAccess().lookupOrThrow(Registries.ITEM).getValue(Identifier.tryParse(itemType.id())); + } + + @Override + public OptionalInt getInternalBlockStateId(BlockData data) { + net.minecraft.world.level.block.state.BlockState state = ((CraftBlockData) data).getState(); + int combinedId = Block.getId(state); + return combinedId == 0 && state.getBlock() != Blocks.AIR ? OptionalInt.empty() : OptionalInt.of(combinedId); + } + + @Override + public OptionalInt getInternalBlockStateId(BlockState state) { + Block mcBlock = getBlockFromType(state.getBlockType()); + net.minecraft.world.level.block.state.BlockState newState = mcBlock.defaultBlockState(); + Map, Object> states = state.getStates(); + newState = applyProperties(mcBlock.getStateDefinition(), newState, states); + final int combinedId = Block.getId(newState); + return combinedId == 0 && state.getBlockType() != BlockTypes.AIR ? OptionalInt.empty() : OptionalInt.of(combinedId); + } + + public BlockState adapt(net.minecraft.world.level.block.state.BlockState blockState) { + int internalId = Block.getId(blockState); + BlockState state = BlockStateIdAccess.getBlockStateById(internalId); + if (state == null) { + state = BukkitAdapter.adapt(CraftBlockData.createData(blockState)); + } + + return state; + } + + public BiomeType adapt(Biome biome) { + var mcBiome = ((CraftServer) Bukkit.getServer()).getServer().registryAccess().lookupOrThrow(Registries.BIOME).getKey(biome); + if (mcBiome == null) { + return null; + } + return BiomeType.REGISTRY.get(mcBiome.toString()); + } + + public net.minecraft.world.level.block.state.BlockState adapt(BlockState blockState) { + int internalId = BlockStateIdAccess.getBlockStateId(blockState); + return Block.stateById(internalId); + } + + @Override + public BlockState getBlock(Location location) { + checkNotNull(location); + + CraftWorld craftWorld = ((CraftWorld) location.getWorld()); + int x = location.getBlockX(); + int y = location.getBlockY(); + int z = location.getBlockZ(); + + final ServerLevel handle = craftWorld.getHandle(); + LevelChunk chunk = handle.getChunk(x >> 4, z >> 4); + final BlockPos blockPos = new BlockPos(x, y, z); + final net.minecraft.world.level.block.state.BlockState blockData = chunk.getBlockState(blockPos); + return adapt(blockData); + } + + @Override + public BaseBlock getFullBlock(Location location) { + BlockState state = getBlock(location); + + CraftWorld craftWorld = ((CraftWorld) location.getWorld()); + int x = location.getBlockX(); + int y = location.getBlockY(); + int z = location.getBlockZ(); + + final ServerLevel handle = craftWorld.getHandle(); + LevelChunk chunk = handle.getChunk(x >> 4, z >> 4); + final BlockPos blockPos = new BlockPos(x, y, z); + + // Read the NBT data + BlockEntity te = chunk.getBlockEntity(blockPos); + if (te != null) { + net.minecraft.nbt.CompoundTag tag = PaperweightLoggingProblemReporter.with( + () -> "serializing block entity at " + blockPos, + reporter -> { + var tagValueOutput = TagValueOutput.createWithContext(reporter, MinecraftServer.getServer().registryAccess()); + te.saveWithId(tagValueOutput); + return tagValueOutput.buildResult(); + } + ); + return state.toBaseBlock(LazyReference.from(() -> (LinCompoundTag) toNative(tag))); + } + + return state.toBaseBlock(); + } + + private static final HashMap> biomeTypeToNMSCache = new HashMap<>(); + private static final HashMap, BiomeType> biomeTypeFromNMSCache = new HashMap<>(); + + @Override + public BiomeType getBiome(Location location) { + checkNotNull(location); + + CraftWorld craftWorld = ((CraftWorld) location.getWorld()); + int x = location.getBlockX(); + int y = location.getBlockY(); + int z = location.getBlockZ(); + + final ServerLevel handle = craftWorld.getHandle(); + LevelChunk chunk = handle.getChunk(x >> 4, z >> 4); + + return biomeTypeFromNMSCache.computeIfAbsent(chunk.getNoiseBiome(x >> 2, y >> 2, z >> 2), b -> BiomeType.REGISTRY.get(b.unwrapKey().orElseThrow().identifier().toString())); + } + + @Override + public void setBiome(Location location, BiomeType biome) { + checkNotNull(location); + checkNotNull(biome); + + CraftWorld craftWorld = ((CraftWorld) location.getWorld()); + int x = location.getBlockX(); + int y = location.getBlockY(); + int z = location.getBlockZ(); + + final ServerLevel handle = craftWorld.getHandle(); + LevelChunk chunk = handle.getChunk(x >> 4, z >> 4); + var biomeArray = (PalettedContainer>) chunk.getSection(chunk.getSectionIndex(y)).getBiomes(); + biomeArray.getAndSetUnchecked( + (x >> 2) & 3, (y >> 2) & 3, (z >> 2) & 3, + biomeTypeToNMSCache.computeIfAbsent(biome, b -> craftWorld.getHandle().registryAccess().lookup(Registries.BIOME) + .orElseThrow() + .getOrThrow(ResourceKey.create(Registries.BIOME, Identifier.parse(b.id())))) + ); + chunk.markUnsaved(); + } + + @Override + public WorldNativeAccess createWorldNativeAccess(World world) { + return new PaperweightWorldNativeAccess(this, new WeakReference<>(((CraftWorld) world).getHandle())); + } + + private static net.minecraft.core.Direction adapt(Direction face) { + return switch (face) { + case NORTH -> net.minecraft.core.Direction.NORTH; + case SOUTH -> net.minecraft.core.Direction.SOUTH; + case WEST -> net.minecraft.core.Direction.WEST; + case EAST -> net.minecraft.core.Direction.EAST; + case DOWN -> net.minecraft.core.Direction.DOWN; + default -> net.minecraft.core.Direction.UP; + }; + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + private net.minecraft.world.level.block.state.BlockState applyProperties( + StateDefinition stateContainer, + net.minecraft.world.level.block.state.BlockState newState, + Map, Object> states + ) { + for (Map.Entry, Object> state : states.entrySet()) { + net.minecraft.world.level.block.state.properties.Property property = + stateContainer.getProperty(state.getKey().name()); + Comparable value = (Comparable) state.getValue(); + // we may need to adapt this value, depending on the source prop + if (property instanceof net.minecraft.world.level.block.state.properties.EnumProperty) { + if (property.getValueClass() == net.minecraft.core.Direction.class) { + value = adapt((Direction) value); + } else { + String enumName = (String) value; + value = ((net.minecraft.world.level.block.state.properties.EnumProperty) property) + .getValue(enumName).orElseThrow(() -> + new IllegalStateException( + "Enum property " + property.getName() + " does not contain " + enumName + ) + ); + } + } + + newState = newState.setValue( + (net.minecraft.world.level.block.state.properties.Property) property, + (Comparable) value + ); + } + return newState; + } + + @Override + public BaseEntity getEntity(org.bukkit.entity.Entity entity) { + checkNotNull(entity); + + CraftEntity craftEntity = ((CraftEntity) entity); + Entity mcEntity = craftEntity.getHandle(); + + String id = getEntityId(mcEntity); + + net.minecraft.nbt.CompoundTag tag = PaperweightLoggingProblemReporter.with( + () -> "serializing entity " + mcEntity.getStringUUID(), + reporter -> { + var tagValueOutput = TagValueOutput.createWithContext(reporter, mcEntity.registryAccess()); + if (!readEntityIntoTag(mcEntity, tagValueOutput)) { + return null; + } + return tagValueOutput.buildResult(); + } + ); + if (tag == null) { + return null; + } + return new BaseEntity( + EntityTypes.get(id), + LazyReference.from(() -> (LinCompoundTag) toNative(tag)) + ); + } + + @Nullable + @Override + public org.bukkit.entity.Entity createEntity(Location location, BaseEntity state) { + checkNotNull(location); + checkNotNull(state); + + CraftWorld craftWorld = ((CraftWorld) location.getWorld()); + ServerLevel worldServer = craftWorld.getHandle(); + + String entityId = state.getType().id(); + final Optional> entityType = worldServer.registryAccess().lookupOrThrow(Registries.ENTITY_TYPE).getOptional(Identifier.parse(entityId)); + if (entityType.isEmpty()) { + return null; + } + + LinCompoundTag nativeTag = state.getNbt(); + net.minecraft.nbt.CompoundTag tag; + if (nativeTag != null) { + tag = (net.minecraft.nbt.CompoundTag) fromNative(nativeTag); + removeUnwantedEntityTagsRecursively(tag); + } else { + tag = new net.minecraft.nbt.CompoundTag(); + } + + tag.putString("id", entityId); + + Entity createdEntity = EntityType.loadEntityRecursive(entityType.get(), tag, craftWorld.getHandle(), EntitySpawnReason.COMMAND, (loadedEntity) -> { + loadedEntity.absSnapTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + return loadedEntity; + }); + + if (createdEntity != null) { + worldServer.addFreshEntityWithPassengers(createdEntity, SpawnReason.CUSTOM); + return createdEntity.getBukkitEntity(); + } else { + return null; + } + } + + // This removes all unwanted tags from the main entity and all its passengers + private void removeUnwantedEntityTagsRecursively(net.minecraft.nbt.CompoundTag tag) { + for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) { + tag.remove(name); + } + + // Adapted from net.minecraft.world.entity.EntityType#loadEntityRecursive + tag.getList("Passengers").ifPresent(nbttaglist -> { + for (int i = 0; i < nbttaglist.size(); ++i) { + removeUnwantedEntityTagsRecursively(nbttaglist.getCompoundOrEmpty(i)); + } + }); + } + + @Override + public Component getRichBlockName(BlockType blockType) { + return TranslatableComponent.of(getBlockFromType(blockType).getDescriptionId()); + } + + @Override + public Component getRichItemName(ItemType itemType) { + return TranslatableComponent.of(getItemFromType(itemType).getDescriptionId()); + } + + @Override + public Component getRichItemName(BaseItemStack itemStack) { + return GsonComponentSerializer.INSTANCE.deserialize( + ComponentConverter.Serializer.toJson( + CraftItemStack.asNMSCopy(BukkitAdapter.adapt(itemStack)).getItemName(), + ((CraftServer) Bukkit.getServer()).getServer().registryAccess() + ) + ); + } + + @Override + public BlockMaterial getBlockMaterial(BlockType blockType) { + net.minecraft.world.level.block.state.BlockState mcBlockState = getBlockFromType(blockType).defaultBlockState(); + return new PaperweightBlockMaterial(mcBlockState); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + private static final LoadingCache> PROPERTY_CACHE = CacheBuilder.newBuilder().build(new CacheLoader<>() { + @Override + public Property load(net.minecraft.world.level.block.state.properties.Property state) { + return switch (state) { + case net.minecraft.world.level.block.state.properties.BooleanProperty ignored -> + new BooleanProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues())); + case net.minecraft.world.level.block.state.properties.EnumProperty ignored -> { + if (state.getValueClass() == net.minecraft.core.Direction.class) { + yield new DirectionalProperty(state.getName(), + (List) state.getPossibleValues().stream().map(e -> Direction.valueOf(((StringRepresentable) e).getSerializedName().toUpperCase(Locale.ROOT))).toList()); + } + yield new EnumProperty(state.getName(), + (List) state.getPossibleValues().stream().map(e -> ((StringRepresentable) e).getSerializedName()).toList()); + } + case net.minecraft.world.level.block.state.properties.IntegerProperty ignored -> + new IntegerProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues())); + default -> + throw new IllegalArgumentException("WorldEdit needs an update to support " + state.getClass().getSimpleName()); + }; + } + }); + + @SuppressWarnings({ "rawtypes" }) + @Override + public Map> getProperties(BlockType blockType) { + Map> properties = new TreeMap<>(); + Block block = getBlockFromType(blockType); + StateDefinition blockStateList = + block.getStateDefinition(); + for (net.minecraft.world.level.block.state.properties.Property state : blockStateList.getProperties()) { + Property property = PROPERTY_CACHE.getUnchecked(state); + properties.put(property.name(), property); + } + return properties; + } + + @Override + public void sendFakeNBT(Player player, BlockVector3 pos, LinCompoundTag nbtData) { + var structureBlock = new StructureBlockEntity( + new BlockPos(pos.x(), pos.y(), pos.z()), + Blocks.STRUCTURE_BLOCK.defaultBlockState() + ); + structureBlock.setLevel(((CraftPlayer) player).getHandle().level()); + ((CraftPlayer) player).getHandle().connection.send(ClientboundBlockEntityDataPacket.create( + structureBlock, + (blockEntity, registryAccess) -> (net.minecraft.nbt.CompoundTag) fromNative(nbtData) + )); + } + + @Override + public void sendFakeOP(Player player) { + ((CraftPlayer) player).getHandle().connection.send(new ClientboundEntityEventPacket( + ((CraftPlayer) player).getHandle(), (byte) 28 + )); + } + + /** + * For serializing and deserializing components. + */ + private static final Codec COMPONENTS_CODEC = DataComponentPatch.CODEC.optionalFieldOf( + "components", DataComponentPatch.EMPTY + ).codec(); + + @Override + public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) { + var registryAccess = DedicatedServer.getServer().registryAccess(); + ItemStack stack = new ItemStack( + registryAccess.lookupOrThrow(Registries.ITEM).getOrThrow(ResourceKey.create( + Registries.ITEM, + Identifier.tryParse(baseItemStack.getType().id()) + )), + baseItemStack.getAmount() + ); + LinCompoundTag nbt = baseItemStack.getNbt(); + if (nbt != null) { + DataComponentPatch componentPatch = COMPONENTS_CODEC.parse( + registryAccess.createSerializationContext(NbtOps.INSTANCE), + fromNative(nbt) + ).getOrThrow(); + stack.applyComponents(componentPatch); + } + if (asCraftMirror != null) { + // Probably Spigot + try { + return (org.bukkit.inventory.ItemStack) asCraftMirror.invoke(null, stack); + } catch (IllegalAccessException | InvocationTargetException e) { + // An issue occurred trying to convert this. + throw new RuntimeException(e); + } + } else { + return CraftItemStack.asBukkitMirror(stack); + } + } + + @Override + public BaseItemStack adapt(org.bukkit.inventory.ItemStack itemStack) { + var registryAccess = DedicatedServer.getServer().registryAccess(); + final ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack); + CompoundTag tag = (CompoundTag) COMPONENTS_CODEC.encodeStart( + registryAccess.createSerializationContext(NbtOps.INSTANCE), + nmsStack.getComponentsPatch() + ).getOrThrow(); + return new BaseItemStack(BukkitAdapter.asItemType(itemStack.getType()), LazyReference.from(() -> (LinCompoundTag) toNative(tag)), itemStack.getAmount()); + } + + private final LoadingCache fakePlayers + = CacheBuilder.newBuilder().weakKeys().softValues().build(CacheLoader.from(PaperweightFakePlayer::new)); + + @Override + public boolean simulateItemUse(World world, BlockVector3 position, BaseItem item, Direction face) { + CraftWorld craftWorld = (CraftWorld) world; + ServerLevel worldServer = craftWorld.getHandle(); + ItemStack stack = CraftItemStack.asNMSCopy(adapt( + item instanceof BaseItemStack baseItemStack + ? baseItemStack + : new BaseItemStack(item.getType(), item.getNbtReference(), 1) + )); + + PaperweightFakePlayer fakePlayer; + try { + fakePlayer = fakePlayers.get(worldServer); + } catch (ExecutionException ignored) { + return false; + } + fakePlayer.setItemInHand(InteractionHand.MAIN_HAND, stack); + fakePlayer.absSnapTo(position.x(), position.y(), position.z(), + (float) face.toVector().toYaw(), (float) face.toVector().toPitch()); + + final BlockPos blockPos = new BlockPos(position.x(), position.y(), position.z()); + final Vec3 blockVec = Vec3.atLowerCornerOf(blockPos); + final net.minecraft.core.Direction enumFacing = adapt(face); + BlockHitResult rayTrace = new BlockHitResult(blockVec, enumFacing, blockPos, false); + UseOnContext context = new UseOnContext(fakePlayer, InteractionHand.MAIN_HAND, rayTrace); + InteractionResult result = stack.useOn(context); + if (result != InteractionResult.SUCCESS) { + if (worldServer.getBlockState(blockPos).useItemOn(stack, worldServer, fakePlayer, InteractionHand.MAIN_HAND, rayTrace).consumesAction()) { + result = InteractionResult.SUCCESS; + } else { + result = stack.getItem().use(worldServer, fakePlayer, InteractionHand.MAIN_HAND); + } + } + + return result == InteractionResult.SUCCESS; + } + + @Override + public boolean canPlaceAt(World world, BlockVector3 position, BlockState blockState) { + int internalId = BlockStateIdAccess.getBlockStateId(blockState); + net.minecraft.world.level.block.state.BlockState blockData = Block.stateById(internalId); + return blockData.canSurvive(((CraftWorld) world).getHandle(), new BlockPos(position.x(), position.y(), position.z())); + } + + @Override + public boolean regenerate(World bukkitWorld, Region region, Extent extent, RegenOptions options) { + if (options.getSeed().isPresent()) { + throw new UnsupportedOperationException("26.1+ worldgen does not support overriding the seed for regen"); + } + + try { + doRegen(bukkitWorld, region, extent, options); + } catch (Exception e) { + throw new IllegalStateException("Regen failed.", e); + } + + return true; + } + + private void doRegen(World bukkitWorld, Region region, Extent extent, RegenOptions options) throws Exception { + Environment env = bukkitWorld.getEnvironment(); + ChunkGenerator gen = bukkitWorld.getGenerator(); + + Path tempDir = Files.createTempDirectory("WorldEditWorldGen"); + LevelStorageSource levelStorage = LevelStorageSource.createDefault(tempDir); + ResourceKey worldDimKey = getWorldDimKey(env); + try (LevelStorageSource.LevelStorageAccess session = levelStorage.createAccess("worldeditregentempworld")) { + ServerLevel originalWorld = ((CraftWorld) bukkitWorld).getHandle(); + + PaperWorldLoader.LoadedWorldData loadedWorldData = new PaperWorldLoader.LoadedWorldData( + "worldeditregentempworld", + UUID.randomUUID(), + new PaperWorldPDC((CraftPersistentDataContainer) bukkitWorld.getPersistentDataContainer()), + originalWorld.serverLevelData + ); + + ServerLevel freshWorld = new ServerLevel( + originalWorld.getServer(), + Util.backgroundExecutor(), + session, + originalWorld.worldGenSettings, + originalWorld.dimension(), + new LevelStem( + originalWorld.dimensionTypeRegistration(), + originalWorld.getChunkSource().getGenerator() + ), + originalWorld.isDebug(), + originalWorld.getSeed(), + List.of(), + false, + worldDimKey, + env, + gen, + bukkitWorld.getBiomeProvider(), + new SavedDataStorage(session.getDimensionPath(originalWorld.dimension()), originalWorld.getServer().getFixerUpper(), originalWorld.registryAccess()), + loadedWorldData + ); + try { + regenForWorld(region, extent, freshWorld, options); + } finally { + freshWorld.getChunkSource().close(false); + } + } finally { + try { + @SuppressWarnings("unchecked") + Map map = (Map) serverWorldsField.get(Bukkit.getServer()); + map.remove("worldeditregentempworld"); + } catch (IllegalAccessException ignored) { + // It's fine if we couldn't remove it + } + SafeFiles.tryHardToDeleteDir(tempDir); + } + } + + private BiomeType adapt(ServerLevel serverWorld, Biome origBiome) { + Identifier key = serverWorld.registryAccess().lookupOrThrow(Registries.BIOME).getKey(origBiome); + if (key == null) { + return null; + } + return BiomeTypes.get(key.toString()); + } + + @SuppressWarnings("unchecked") + private void regenForWorld(Region region, Extent extent, ServerLevel serverWorld, RegenOptions options) throws WorldEditException { + List> chunkLoadings = submitChunkLoadTasks(region, serverWorld); + BlockableEventLoop executor; + try { + executor = (BlockableEventLoop) chunkProviderExecutorField.get(serverWorld.getChunkSource()); + } catch (IllegalAccessException e) { + throw new IllegalStateException("Couldn't get executor for chunk loading.", e); + } + executor.managedBlock(() -> { + // bail out early if a future fails + if (chunkLoadings.stream().anyMatch(ftr -> + ftr.isDone() && Futures.getUnchecked(ftr) == null + )) { + return false; + } + return chunkLoadings.stream().allMatch(CompletableFuture::isDone); + }); + Map chunks = new HashMap<>(); + for (CompletableFuture future : chunkLoadings) { + @Nullable + ChunkAccess chunk = future.getNow(null); + checkState(chunk != null, "Failed to generate a chunk, regen failed."); + chunks.put(chunk.getPos(), chunk); + } + + for (BlockVector3 vec : region) { + BlockPos pos = new BlockPos(vec.x(), vec.y(), vec.z()); + ChunkAccess chunk = chunks.get(ChunkPos.containing(pos)); + final net.minecraft.world.level.block.state.BlockState blockData = chunk.getBlockState(pos); + int internalId = Block.getId(blockData); + BlockStateHolder state = BlockStateIdAccess.getBlockStateById(internalId); + Objects.requireNonNull(state); + BlockEntity blockEntity = chunk.getBlockEntity(pos); + if (blockEntity != null) { + net.minecraft.nbt.CompoundTag tag = PaperweightLoggingProblemReporter.with( + () -> "serializing block entity at " + pos, + reporter -> { + var tagValueOutput = TagValueOutput.createWithContext(reporter, serverWorld.registryAccess()); + blockEntity.saveWithId(tagValueOutput); + return tagValueOutput.buildResult(); + } + ); + state = state.toBaseBlock(LazyReference.from(() -> (LinCompoundTag) toNative(tag))); + } + extent.setBlock(vec, state.toBaseBlock()); + if (options.shouldRegenBiomes()) { + Biome origBiome = chunk.getNoiseBiome(vec.x(), vec.y(), vec.z()).value(); + BiomeType adaptedBiome = adapt(serverWorld, origBiome); + if (adaptedBiome != null) { + extent.setBiome(vec, adaptedBiome); + } + } + } + } + + @SuppressWarnings("unchecked") + private List> submitChunkLoadTasks(Region region, ServerLevel serverWorld) { + ServerChunkCache chunkManager = serverWorld.getChunkSource(); + List> chunkLoadings = new ArrayList<>(); + // Pre-gen all the chunks + for (BlockVector2 chunk : region.getChunks()) { + try { + //noinspection unchecked + chunkLoadings.add( + ((CompletableFuture>) + getChunkFutureMethod.invoke(chunkManager, chunk.x(), chunk.z(), ChunkStatus.FEATURES, true)) + .thenApply(either -> either.orElse(null)) + ); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new IllegalStateException("Couldn't load chunk for regen.", e); + } + } + return chunkLoadings; + } + + private ResourceKey getWorldDimKey(Environment env) { + return switch (env) { + case NETHER -> LevelStem.NETHER; + case THE_END -> LevelStem.END; + default -> LevelStem.OVERWORLD; + }; + } + + private static final Set SUPPORTED_SIDE_EFFECTS = Sets.immutableEnumSet( + SideEffect.NEIGHBORS, + SideEffect.LIGHTING, + SideEffect.VALIDATION, + SideEffect.ENTITY_AI, + SideEffect.EVENTS, + SideEffect.UPDATE + ); + + @Override + public Set getSupportedSideEffects() { + return SUPPORTED_SIDE_EFFECTS; + } + + @Override + public boolean clearContainerBlockContents(World world, BlockVector3 pt) { + ServerLevel originalWorld = ((CraftWorld) world).getHandle(); + + BlockEntity entity = originalWorld.getBlockEntity(new BlockPos(pt.x(), pt.y(), pt.z())); + if (entity instanceof Clearable clearable) { + clearable.clearContent(); + return true; + } + return false; + } + + @Override + public void initializeRegistries() { + DedicatedServer server = ((CraftServer) Bukkit.getServer()).getServer(); + // Biomes + for (Identifier name : server.registryAccess().lookupOrThrow(Registries.BIOME).keySet()) { + if (BiomeType.REGISTRY.get(name.toString()) == null) { + BiomeType.REGISTRY.register(name.toString(), new BiomeType(name.toString())); + } + } + + // Features + for (Identifier name: server.registryAccess().lookupOrThrow(Registries.FEATURE).keySet()) { + if (ConfiguredFeatureType.REGISTRY.get(name.toString()) == null) { + ConfiguredFeatureType.REGISTRY.register(name.toString(), new ConfiguredFeatureType(name.toString())); + } + } + + // Structures + for (Identifier name : server.registryAccess().lookupOrThrow(Registries.STRUCTURE).keySet()) { + if (StructureType.REGISTRY.get(name.toString()) == null) { + StructureType.REGISTRY.register(name.toString(), new StructureType(name.toString())); + } + } + + // Trees + Registry placedFeatureRegistry = server.registryAccess().lookupOrThrow(Registries.PLACED_FEATURE); + for (Identifier name : placedFeatureRegistry.keySet()) { + // Do some hackery to make sure this is a tree + var underlyingFeature = placedFeatureRegistry.get(name).get().value().feature().value(); + if (underlyingFeature instanceof TreeFeature || underlyingFeature instanceof FallenTreeFeature || underlyingFeature instanceof CoralTreeFeature) { + String key = name.toString(); + if (TreeType.REGISTRY.get(key) == null) { + TreeType.REGISTRY.register(key, new TreeType(key)); + } + } + } + + // BiomeCategories + Registry biomeRegistry = server.registryAccess().lookupOrThrow(Registries.BIOME); + biomeRegistry.getTags().forEach(tag -> { + String key = tag.key().location().toString(); + if (BiomeCategory.REGISTRY.get(key) == null) { + BiomeCategory.REGISTRY.register(key, new BiomeCategory( + key, + () -> biomeRegistry.get(tag.key()) + .stream() + .flatMap(HolderSet.Named::stream) + .map(Holder::value) + .map(this::adapt) + .collect(Collectors.toSet())) + ); + } + }); + } + + @Override + public boolean generateTree(TreeType treeType, World world, EditSession session, BlockVector3 pt) throws MaxChangedBlocksException { + ServerLevel originalWorld = ((CraftWorld) world).getHandle(); + PlacedFeature feature = originalWorld.registryAccess().lookupOrThrow(Registries.PLACED_FEATURE).getValue(Identifier.tryParse(treeType.id())); + ServerChunkCache chunkManager = originalWorld.getChunkSource(); + try (PaperweightServerLevelDelegateProxy.LevelAndProxy proxyLevel = + PaperweightServerLevelDelegateProxy.newInstance(session, originalWorld, this)) { + return feature != null && feature.place(proxyLevel.level(), chunkManager.getGenerator(), random, new BlockPos(pt.x(), pt.y(), pt.z())); + } + } + + @Override + public boolean generateFeature(ConfiguredFeatureType type, World world, EditSession session, BlockVector3 pt) { + ServerLevel originalWorld = ((CraftWorld) world).getHandle(); + Feature feature = originalWorld.registryAccess().lookupOrThrow(Registries.FEATURE).getValue(Identifier.tryParse(type.id())); + ServerChunkCache chunkManager = originalWorld.getChunkSource(); + try (PaperweightServerLevelDelegateProxy.LevelAndProxy proxyLevel = + PaperweightServerLevelDelegateProxy.newInstance(session, originalWorld, this)) { + return feature != null && feature.place(proxyLevel.level(), chunkManager.getGenerator(), random, new BlockPos(pt.x(), pt.y(), pt.z())); + } catch (MaxChangedBlocksException e) { + throw new RuntimeException(e); + } + } + + @Override + public boolean generateStructure(StructureType type, World world, EditSession session, BlockVector3 pt) { + ServerLevel originalWorld = ((CraftWorld) world).getHandle(); + Registry structureRegistry = originalWorld.registryAccess().lookupOrThrow(Registries.STRUCTURE); + Structure structure = structureRegistry.getValue(Identifier.tryParse(type.id())); + if (structure == null) { + return false; + } + + ServerChunkCache chunkManager = originalWorld.getChunkSource(); + Climate.Sampler climateSampler = chunkManager.randomState().createClimateSampler( + SamplerContext.builder().enableCaches().build() + ); + try (PaperweightServerLevelDelegateProxy.LevelAndProxy proxyLevel = + PaperweightServerLevelDelegateProxy.newInstance(session, originalWorld, this)) { + ChunkPos chunkPos = ChunkPos.containing(new BlockPos(pt.x(), pt.y(), pt.z())); + StructureStart structureStart = structure.generate( + structureRegistry.wrapAsHolder(structure), originalWorld.dimension(), originalWorld.registryAccess(), + chunkManager.getGenerator(), chunkManager.getGenerator().getBiomeSource(), climateSampler, chunkManager.randomState(), + originalWorld.getStructureTemplateManager(), originalWorld.getSeed(), chunkPos, 0, + proxyLevel.level(), _ -> true + ); + + if (!structureStart.isValid()) { + return false; + } else { + BoundingBox boundingBox = structureStart.getBoundingBox(); + ChunkPos min = new ChunkPos(SectionPos.blockToSectionCoord(boundingBox.minX()), SectionPos.blockToSectionCoord(boundingBox.minZ())); + ChunkPos max = new ChunkPos(SectionPos.blockToSectionCoord(boundingBox.maxX()), SectionPos.blockToSectionCoord(boundingBox.maxZ())); + ChunkPos.rangeClosed(min, max).forEach((chunkPosx) -> + structureStart.placeInChunk( + proxyLevel.level(), originalWorld.structureManager(), chunkManager.getGenerator(), + originalWorld.getRandom(), + new BoundingBox( + chunkPosx.getMinBlockX(), originalWorld.getMinY(), chunkPosx.getMinBlockZ(), + chunkPosx.getMaxBlockX(), originalWorld.getMaxY(), chunkPosx.getMaxBlockZ() + ), chunkPosx + ) + ); + return true; + } + } catch (MaxChangedBlocksException e) { + throw new RuntimeException(e); + } + } + + @Override + public void sendBiomeUpdates(World world, Iterable chunks) { + ServerLevel originalWorld = ((CraftWorld) world).getHandle(); + + List nativeChunks = chunks instanceof Collection chunkCollection ? Lists.newArrayListWithCapacity(chunkCollection.size()) : Lists.newArrayList(); + for (BlockVector2 chunk : chunks) { + nativeChunks.add(originalWorld.getChunk(chunk.x(), chunk.z(), ChunkStatus.BIOMES, false)); + } + originalWorld.getChunkSource().chunkMap.resendBiomesForChunks(nativeChunks); + } + + // ------------------------------------------------------------------------ + // Code that is less likely to break + // ------------------------------------------------------------------------ + + /** + * Converts from a non-native NMS NBT structure to a native WorldEdit NBT + * structure. + * + * @param foreign non-native NMS NBT structure + * @return native WorldEdit NBT structure + */ + LinTag toNative(net.minecraft.nbt.Tag foreign) { + if (foreign == null) { + return null; + } + if (foreign instanceof net.minecraft.nbt.CompoundTag compoundTag) { + LinCompoundTag.Builder builder = LinCompoundTag.builder(); + for (var entry : compoundTag.keySet()) { + builder.put(entry, toNative(compoundTag.get(entry))); + } + return builder.build(); + } else if (foreign instanceof net.minecraft.nbt.ByteTag byteTag) { + return LinByteTag.of(byteTag.byteValue()); + } else if (foreign instanceof net.minecraft.nbt.ByteArrayTag byteArrayTag) { + return LinByteArrayTag.of(byteArrayTag.getAsByteArray()); + } else if (foreign instanceof net.minecraft.nbt.DoubleTag doubleTag) { + return LinDoubleTag.of(doubleTag.doubleValue()); + } else if (foreign instanceof net.minecraft.nbt.FloatTag floatTag) { + return LinFloatTag.of(floatTag.floatValue()); + } else if (foreign instanceof net.minecraft.nbt.IntTag intTag) { + return LinIntTag.of(intTag.intValue()); + } else if (foreign instanceof net.minecraft.nbt.IntArrayTag intArrayTag) { + return LinIntArrayTag.of(intArrayTag.getAsIntArray()); + } else if (foreign instanceof net.minecraft.nbt.LongArrayTag longArrayTag) { + return LinLongArrayTag.of(longArrayTag.getAsLongArray()); + } else if (foreign instanceof net.minecraft.nbt.ListTag listTag) { + try { + return toNativeList(listTag); + } catch (Throwable e) { + logger.log(Level.WARNING, "Failed to convert net.minecraft.nbt.ListTag", e); + return LinListTag.empty(LinTagType.endTag()); + } + } else if (foreign instanceof net.minecraft.nbt.LongTag longTag) { + return LinLongTag.of(longTag.longValue()); + } else if (foreign instanceof net.minecraft.nbt.ShortTag shortTag) { + return LinShortTag.of(shortTag.shortValue()); + } else if (foreign instanceof net.minecraft.nbt.StringTag stringTag) { + return LinStringTag.of(stringTag.value()); + } else if (foreign instanceof net.minecraft.nbt.EndTag) { + return LinEndTag.instance(); + } else { + throw new IllegalArgumentException("Don't know how to make native " + foreign.getClass().getCanonicalName()); + } + } + + private static byte identifyRawElementType(net.minecraft.nbt.ListTag list) { + byte b = 0; + + for (Tag tag : list) { + byte c = tag.getId(); + if (b == 0) { + b = c; + } else if (b != c) { + return 10; + } + } + + return b; + } + + private static net.minecraft.nbt.CompoundTag wrapTag(net.minecraft.nbt.Tag tag) { + if (tag instanceof net.minecraft.nbt.CompoundTag compoundTag) { + return compoundTag; + } + var compoundTag = new net.minecraft.nbt.CompoundTag(); + compoundTag.put("", tag); + return compoundTag; + } + + /** + * Convert a foreign NBT list tag into a native WorldEdit one. + * + * @param foreign the foreign tag + * @return the converted tag + * @throws SecurityException on error + * @throws IllegalArgumentException on error + */ + private LinListTag toNativeList(net.minecraft.nbt.ListTag foreign) throws SecurityException, IllegalArgumentException { + byte rawType = identifyRawElementType(foreign); + LinListTag.Builder> builder = LinListTag.builder(LinTagType.fromId( + LinTagId.fromId(rawType) + )); + for (net.minecraft.nbt.Tag tag : foreign) { + if (rawType == LinTagId.COMPOUND.id() && !(tag instanceof net.minecraft.nbt.CompoundTag)) { + builder.add(toNative(wrapTag(tag))); + } else { + builder.add(toNative(tag)); + } + } + return builder.build(); + } + + /** + * Converts a WorldEdit-native NBT structure to a NMS structure. + * + * @param foreign structure to convert + * @return non-native structure + */ + Tag fromNative(LinTag foreign) { + if (foreign == null) { + return null; + } + if (foreign instanceof LinCompoundTag compoundTag) { + net.minecraft.nbt.CompoundTag tag = new CompoundTag(); + for (var entry : compoundTag.value().entrySet()) { + tag.put(entry.getKey(), fromNative(entry.getValue())); + } + return tag; + } else if (foreign instanceof LinByteTag byteTag) { + return ByteTag.valueOf(byteTag.valueAsByte()); + } else if (foreign instanceof LinByteArrayTag byteArrayTag) { + return new ByteArrayTag(byteArrayTag.value()); + } else if (foreign instanceof LinDoubleTag doubleTag) { + return DoubleTag.valueOf(doubleTag.valueAsDouble()); + } else if (foreign instanceof LinFloatTag floatTag) { + return FloatTag.valueOf(floatTag.valueAsFloat()); + } else if (foreign instanceof LinIntTag intTag) { + return IntTag.valueOf(intTag.valueAsInt()); + } else if (foreign instanceof LinIntArrayTag intArrayTag) { + return new IntArrayTag(intArrayTag.value()); + } else if (foreign instanceof LinLongArrayTag longArrayTag) { + return new LongArrayTag(longArrayTag.value()); + } else if (foreign instanceof LinListTag listTag) { + net.minecraft.nbt.ListTag tag = new ListTag(); + for (var t : listTag.value()) { + tag.addAndUnwrap(fromNative(t)); + } + return tag; + } else if (foreign instanceof LinLongTag longTag) { + return LongTag.valueOf(longTag.valueAsLong()); + } else if (foreign instanceof LinShortTag shortTag) { + return ShortTag.valueOf(shortTag.valueAsShort()); + } else if (foreign instanceof LinStringTag stringTag) { + return StringTag.valueOf(stringTag.value()); + } else if (foreign instanceof LinEndTag) { + return EndTag.INSTANCE; + } else { + throw new IllegalArgumentException("Don't know how to make NMS " + foreign.getClass().getCanonicalName()); + } + } + + @Override + public boolean supportsWatchdog() { + return watchdog != null; + } + + @Override + public void tickWatchdog() { + watchdog.tick(); + } + + private class SpigotWatchdog implements Watchdog { + private final Field instanceField; + private final Field lastTickField; + + SpigotWatchdog() throws NoSuchFieldException { + Field instanceField = WatchdogThread.class.getDeclaredField("instance"); + instanceField.setAccessible(true); + this.instanceField = instanceField; + + Field lastTickField = WatchdogThread.class.getDeclaredField("lastTick"); + lastTickField.setAccessible(true); + this.lastTickField = lastTickField; + } + + @Override + public void tick() { + try { + WatchdogThread instance = (WatchdogThread) this.instanceField.get(null); + if ((long) lastTickField.get(instance) != 0) { + WatchdogThread.tick(); + } + } catch (IllegalAccessException e) { + logger.log(Level.WARNING, "Failed to tick watchdog", e); + } + } + } + + private static class MojangWatchdog implements Watchdog { + private final DedicatedServer server; + private final Field tickField; + + MojangWatchdog(DedicatedServer server) throws NoSuchFieldException { + this.server = server; + Field tickField = MinecraftServer.class.getDeclaredField(StaticRefraction.NEXT_TICK_TIME); + if (tickField.getType() != long.class) { + throw new IllegalStateException("nextTickTime is not a long field, mapping is likely incorrect"); + } + tickField.setAccessible(true); + this.tickField = tickField; + } + + @Override + public void tick() { + try { + tickField.set(server, Util.getMillis()); + } catch (IllegalAccessException ignored) { + // It's fine if we couldn't set it + } + } + } +} diff --git a/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightBlockMaterial.java b/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightBlockMaterial.java new file mode 100644 index 0000000000..858435ebc6 --- /dev/null +++ b/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightBlockMaterial.java @@ -0,0 +1,138 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.bukkit.adapter.impl.v26_3; + +import com.sk89q.worldedit.world.registry.BlockMaterial; +import net.minecraft.core.BlockPos; +import net.minecraft.world.Clearable; +import net.minecraft.world.level.EmptyBlockGetter; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.EntityBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.PushReaction; + +public class PaperweightBlockMaterial implements BlockMaterial { + + private final BlockState block; + + public PaperweightBlockMaterial(BlockState block) { + this.block = block; + } + + @Override + public boolean isAir() { + return block.isAir(); + } + + @Override + public boolean isFullCube() { + return Block.isShapeFullBlock(block.getShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO)); + } + + @Override + public boolean isOpaque() { + return block.canOcclude(); + } + + @Override + public boolean isPowerSource() { + return block.isSignalSource(); + } + + @Override + @SuppressWarnings("deprecation") + public boolean isLiquid() { + return block.liquid(); + } + + @Override + @SuppressWarnings("deprecation") + public boolean isSolid() { + return block.isSolid(); + } + + @Override + public float getHardness() { + return block.getDestroySpeed(EmptyBlockGetter.INSTANCE, BlockPos.ZERO); + } + + @Override + public float getResistance() { + return block.getBlock().getExplosionResistance(); + } + + @Override + public float getSlipperiness() { + return block.getBlock().getFriction(); + } + + @Override + public int getLightValue() { + return block.getLightEmission(); + } + + @Override + public boolean isFragileWhenPushed() { + return block.getPistonPushReaction() == PushReaction.POPPED; + } + + @Override + public boolean isUnpushable() { + return block.getPistonPushReaction() == PushReaction.IMMOVEABLE; + } + + @Override + public boolean isTicksRandomly() { + return block.isRandomlyTicking(); + } + + @Override + @SuppressWarnings("deprecation") + public boolean isMovementBlocker() { + return block.isSolid(); + } + + @Override + public boolean isBurnable() { + return block.ignitedByLava(); + } + + @Override + public boolean isToolRequired() { + return block.requiresCorrectToolForDrops(); + } + + @Override + public boolean isReplacedDuringPlacement() { + return block.canBeReplaced(); + } + + @Override + public boolean isTranslucent() { + return !block.canOcclude(); + } + + @Override + public boolean hasContainer() { + return block.getBlock() instanceof EntityBlock entityBlock + && entityBlock.newBlockEntity(BlockPos.ZERO, block) instanceof Clearable; + } + +} diff --git a/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightDataConverters.java b/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightDataConverters.java new file mode 100644 index 0000000000..de950231af --- /dev/null +++ b/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightDataConverters.java @@ -0,0 +1,2766 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.bukkit.adapter.impl.v26_3; + +import com.google.common.base.Strings; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonParseException; +import com.mojang.datafixers.DSL.TypeReference; +import com.mojang.datafixers.DataFixer; +import com.mojang.datafixers.schemas.Schema; +import com.mojang.serialization.Dynamic; +import net.minecraft.core.Direction; +import net.minecraft.core.UUIDUtil; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.FloatTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.NbtOps; +import net.minecraft.nbt.StringTag; +import net.minecraft.nbt.Tag; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.resources.Identifier; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.GsonHelper; +import net.minecraft.util.datafix.DataFixers; +import net.minecraft.util.datafix.fixes.References; +import net.minecraft.world.item.DyeColor; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.enginehub.linbus.tree.LinCompoundTag; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Optional; +import java.util.Random; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; +import javax.annotation.Nullable; + +/** + * Handles converting all Pre 1.13.2 data using the Legacy DataFix System (ported to 1.13.2) + * + *

+ * We register a DFU Fixer per Legacy Data Version and apply the fixes using legacy strategy + * which is safer, faster and cleaner code. + *

+ * + *

+ * The pre DFU code did not fail when the Source version was unknown. + *

+ * + *

+ * This class also provides util methods for converting compounds to wrap the update call to + * receive the source version in the compound + *

+ */ +@SuppressWarnings({ + "UnnecessarilyQualifiedStaticUsage", + "StringSplitter", + "ImmutableEnumChecker", + "MissingOverride", + "StaticAssignmentInConstructor", + "EffectivelyPrivate", + "FallThrough", + "MutablePublicArray", + "unused", + "unchecked", + "rawtypes" +}) +class PaperweightDataConverters implements com.sk89q.worldedit.world.DataFixer { + + @SuppressWarnings("unchecked") + @Override + public T fixUp(FixType type, T original, int srcVer) { + if (type == FixTypes.CHUNK) { + return (T) fixChunk((LinCompoundTag) original, srcVer); + } else if (type == FixTypes.BLOCK_ENTITY) { + return (T) fixBlockEntity((LinCompoundTag) original, srcVer); + } else if (type == FixTypes.ENTITY) { + return (T) fixEntity((LinCompoundTag) original, srcVer); + } else if (type == FixTypes.BLOCK_STATE) { + return (T) fixBlockState((String) original, srcVer); + } else if (type == FixTypes.ITEM_TYPE) { + return (T) fixItemType((String) original, srcVer); + } else if (type == FixTypes.BIOME) { + return (T) fixBiome((String) original, srcVer); + } + return original; + } + + private LinCompoundTag fixChunk(LinCompoundTag originalChunk, int srcVer) { + CompoundTag tag = (CompoundTag) adapter.fromNative(originalChunk); + CompoundTag fixed = convert(LegacyType.CHUNK, tag, srcVer); + return (LinCompoundTag) adapter.toNative(fixed); + } + + private LinCompoundTag fixBlockEntity(LinCompoundTag origTileEnt, int srcVer) { + CompoundTag tag = (CompoundTag) adapter.fromNative(origTileEnt); + CompoundTag fixed = convert(LegacyType.BLOCK_ENTITY, tag, srcVer); + return (LinCompoundTag) adapter.toNative(fixed); + } + + private LinCompoundTag fixEntity(LinCompoundTag origEnt, int srcVer) { + CompoundTag tag = (CompoundTag) adapter.fromNative(origEnt); + CompoundTag fixed = convert(LegacyType.ENTITY, tag, srcVer); + return (LinCompoundTag) adapter.toNative(fixed); + } + + private String fixBlockState(String blockState, int srcVer) { + CompoundTag stateNBT = stateToNBT(blockState); + Dynamic dynamic = new Dynamic<>(OPS_NBT, stateNBT); + CompoundTag fixed = (CompoundTag) INSTANCE.fixer.update(References.BLOCK_STATE, dynamic, srcVer, DATA_VERSION).getValue(); + return nbtToState(fixed); + } + + private String nbtToState(net.minecraft.nbt.CompoundTag tagCompound) { + StringBuilder sb = new StringBuilder(); + sb.append(tagCompound.getString("Name").get()); + tagCompound.getCompound("Properties").ifPresent(props -> { + sb.append('['); + sb.append(props.keySet().stream().map(k -> k + "=" + props.getString(k).get().replace("\"", "")).collect(Collectors.joining(","))); + sb.append(']'); + }); + return sb.toString(); + } + + private static CompoundTag stateToNBT(String blockState) { + int propIdx = blockState.indexOf('['); + CompoundTag tag = new CompoundTag(); + if (propIdx < 0) { + tag.putString("Name", blockState); + } else { + tag.putString("Name", blockState.substring(0, propIdx)); + CompoundTag propTag = new CompoundTag(); + String props = blockState.substring(propIdx + 1, blockState.length() - 1); + String[] propArr = props.split(","); + for (String pair : propArr) { + final String[] split = pair.split("="); + propTag.putString(split[0], split[1]); + } + tag.put("Properties", propTag); + } + return tag; + } + + private String fixBiome(String key, int srcVer) { + return fixName(key, srcVer, References.BIOME); + } + + private String fixItemType(String key, int srcVer) { + return fixName(key, srcVer, References.ITEM_NAME); + } + + private static String fixName(String key, int srcVer, TypeReference type) { + return INSTANCE.fixer.update(type, new Dynamic<>(OPS_NBT, StringTag.valueOf(key)), srcVer, DATA_VERSION) + .asString().result().orElse(key); + } + + private final PaperweightAdapter adapter; + + private static final NbtOps OPS_NBT = NbtOps.INSTANCE; + private static final int LEGACY_VERSION = 1343; + private static int DATA_VERSION; + static PaperweightDataConverters INSTANCE; + + private final Map> converters = new EnumMap<>(LegacyType.class); + private final Map> inspectors = new EnumMap<>(LegacyType.class); + + // Set on build + private DataFixer fixer; + private static final Map DFU_TO_LEGACY = new HashMap<>(); + + public enum LegacyType { + LEVEL(References.LEVEL), + PLAYER(References.PLAYER), + CHUNK(References.CHUNK), + BLOCK_ENTITY(References.BLOCK_ENTITY), + ENTITY(References.ENTITY), + ITEM_INSTANCE(References.ITEM_STACK), + OPTIONS(References.OPTIONS), + STRUCTURE(References.STRUCTURE); + + private final TypeReference type; + + LegacyType(TypeReference type) { + this.type = type; + DFU_TO_LEGACY.put(type.typeName(), this); + } + + public TypeReference getDFUType() { + return type; + } + } + + PaperweightDataConverters(int dataVersion, PaperweightAdapter adapter) { + DATA_VERSION = dataVersion; + INSTANCE = this; + this.adapter = adapter; + registerConverters(); + registerInspectors(); + this.fixer = new WrappedDataFixer(DataFixers.getDataFixer()); + } + + @SuppressWarnings("unchecked") + private class WrappedDataFixer implements DataFixer { + private final DataFixer realFixer; + + WrappedDataFixer(DataFixer realFixer) { + this.realFixer = realFixer; + } + + @Override + public Dynamic update(TypeReference type, Dynamic dynamic, int sourceVer, int targetVer) { + LegacyType legacyType = DFU_TO_LEGACY.get(type.typeName()); + if (sourceVer < LEGACY_VERSION && legacyType != null) { + CompoundTag cmp = (CompoundTag) dynamic.getValue(); + int desiredVersion = Math.min(targetVer, LEGACY_VERSION); + + cmp = convert(legacyType, cmp, sourceVer, desiredVersion); + sourceVer = desiredVersion; + dynamic = new Dynamic(OPS_NBT, cmp); + } + return realFixer.update(type, dynamic, sourceVer, targetVer); + } + + private CompoundTag convert(LegacyType type, CompoundTag cmp, int sourceVer, int desiredVersion) { + List converters = PaperweightDataConverters.this.converters.get(type); + if (converters != null && !converters.isEmpty()) { + for (DataConverter converter : converters) { + int dataVersion = converter.getDataVersion(); + if (dataVersion > sourceVer && dataVersion <= desiredVersion) { + cmp = converter.convert(cmp); + } + } + } + + List inspectors = PaperweightDataConverters.this.inspectors.get(type); + if (inspectors != null && !inspectors.isEmpty()) { + for (DataInspector inspector : inspectors) { + cmp = inspector.inspect(cmp, sourceVer, desiredVersion); + } + } + + return cmp; + } + + @Override + public Schema getSchema(int i) { + return realFixer.getSchema(i); + } + } + + public static CompoundTag convert(LegacyType type, CompoundTag cmp) { + return convert(type.getDFUType(), cmp); + } + + public static CompoundTag convert(LegacyType type, CompoundTag cmp, int sourceVer) { + return convert(type.getDFUType(), cmp, sourceVer); + } + + public static CompoundTag convert(LegacyType type, CompoundTag cmp, int sourceVer, int targetVer) { + return convert(type.getDFUType(), cmp, sourceVer, targetVer); + } + + public static CompoundTag convert(TypeReference type, CompoundTag cmp) { + int i = cmp.getIntOr("DataVersion", -1); + return convert(type, cmp, i); + } + + public static CompoundTag convert(TypeReference type, CompoundTag cmp, int sourceVer) { + return convert(type, cmp, sourceVer, DATA_VERSION); + } + + public static CompoundTag convert(TypeReference type, CompoundTag cmp, int sourceVer, int targetVer) { + if (sourceVer >= targetVer) { + return cmp; + } + return (CompoundTag) INSTANCE.fixer.update(type, new Dynamic<>(OPS_NBT, cmp), sourceVer, targetVer).getValue(); + } + + + public interface DataInspector { + CompoundTag inspect(CompoundTag cmp, int sourceVer, int targetVer); + } + + public interface DataConverter { + + int getDataVersion(); + + CompoundTag convert(CompoundTag cmp); + } + + + private void registerInspector(LegacyType type, DataInspector inspector) { + this.inspectors.computeIfAbsent(type, k -> new ArrayList<>()).add(inspector); + } + + private void registerConverter(LegacyType type, DataConverter converter) { + int version = converter.getDataVersion(); + + List list = this.converters.computeIfAbsent(type, k -> new ArrayList<>()); + if (!list.isEmpty() && list.get(list.size() - 1).getDataVersion() > version) { + for (int j = 0; j < list.size(); ++j) { + if (list.get(j).getDataVersion() > version) { + list.add(j, converter); + break; + } + } + } else { + list.add(converter); + } + } + + private void registerInspectors() { + registerEntityItemList("EntityHorseDonkey", "SaddleItem", "Items"); + registerEntityItemList("EntityHorseMule", "Items"); + registerEntityItemList("EntityMinecartChest", "Items"); + registerEntityItemList("EntityMinecartHopper", "Items"); + registerEntityItemList("EntityVillager", "Inventory"); + registerEntityItemListEquipment("EntityArmorStand"); + registerEntityItemListEquipment("EntityBat"); + registerEntityItemListEquipment("EntityBlaze"); + registerEntityItemListEquipment("EntityCaveSpider"); + registerEntityItemListEquipment("EntityChicken"); + registerEntityItemListEquipment("EntityCow"); + registerEntityItemListEquipment("EntityCreeper"); + registerEntityItemListEquipment("EntityEnderDragon"); + registerEntityItemListEquipment("EntityEnderman"); + registerEntityItemListEquipment("EntityEndermite"); + registerEntityItemListEquipment("EntityEvoker"); + registerEntityItemListEquipment("EntityGhast"); + registerEntityItemListEquipment("EntityGiantZombie"); + registerEntityItemListEquipment("EntityGuardian"); + registerEntityItemListEquipment("EntityGuardianElder"); + registerEntityItemListEquipment("EntityHorse"); + registerEntityItemListEquipment("EntityHorseDonkey"); + registerEntityItemListEquipment("EntityHorseMule"); + registerEntityItemListEquipment("EntityHorseSkeleton"); + registerEntityItemListEquipment("EntityHorseZombie"); + registerEntityItemListEquipment("EntityIronGolem"); + registerEntityItemListEquipment("EntityMagmaCube"); + registerEntityItemListEquipment("EntityMushroomCow"); + registerEntityItemListEquipment("EntityOcelot"); + registerEntityItemListEquipment("EntityPig"); + registerEntityItemListEquipment("EntityPigZombie"); + registerEntityItemListEquipment("EntityRabbit"); + registerEntityItemListEquipment("EntitySheep"); + registerEntityItemListEquipment("EntityShulker"); + registerEntityItemListEquipment("EntitySilverfish"); + registerEntityItemListEquipment("EntitySkeleton"); + registerEntityItemListEquipment("EntitySkeletonStray"); + registerEntityItemListEquipment("EntitySkeletonWither"); + registerEntityItemListEquipment("EntitySlime"); + registerEntityItemListEquipment("EntitySnowman"); + registerEntityItemListEquipment("EntitySpider"); + registerEntityItemListEquipment("EntitySquid"); + registerEntityItemListEquipment("EntityVex"); + registerEntityItemListEquipment("EntityVillager"); + registerEntityItemListEquipment("EntityVindicator"); + registerEntityItemListEquipment("EntityWitch"); + registerEntityItemListEquipment("EntityWither"); + registerEntityItemListEquipment("EntityWolf"); + registerEntityItemListEquipment("EntityZombie"); + registerEntityItemListEquipment("EntityZombieHusk"); + registerEntityItemListEquipment("EntityZombieVillager"); + registerEntityItemSingle("EntityFireworks", "FireworksItem"); + registerEntityItemSingle("EntityHorse", "ArmorItem"); + registerEntityItemSingle("EntityHorse", "SaddleItem"); + registerEntityItemSingle("EntityHorseMule", "SaddleItem"); + registerEntityItemSingle("EntityHorseSkeleton", "SaddleItem"); + registerEntityItemSingle("EntityHorseZombie", "SaddleItem"); + registerEntityItemSingle("EntityItem", "Item"); + registerEntityItemSingle("EntityItemFrame", "Item"); + registerEntityItemSingle("EntityPotion", "Potion"); + + registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItem("TileEntityRecordPlayer", "RecordItem")); + registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityBrewingStand", "Items")); + registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityChest", "Items")); + registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityDispenser", "Items")); + registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityDropper", "Items")); + registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityFurnace", "Items")); + registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityHopper", "Items")); + registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorItemList("TileEntityShulkerBox", "Items")); + registerInspector(LegacyType.BLOCK_ENTITY, new DataInspectorMobSpawnerMobs()); + registerInspector(LegacyType.CHUNK, new DataInspectorChunks()); + registerInspector(LegacyType.ENTITY, new DataInspectorCommandBlock()); + registerInspector(LegacyType.ENTITY, new DataInspectorEntityPassengers()); + registerInspector(LegacyType.ENTITY, new DataInspectorMobSpawnerMinecart()); + registerInspector(LegacyType.ENTITY, new DataInspectorVillagers()); + registerInspector(LegacyType.ITEM_INSTANCE, new DataInspectorBlockEntity()); + registerInspector(LegacyType.ITEM_INSTANCE, new DataInspectorEntity()); + registerInspector(LegacyType.LEVEL, new DataInspectorLevelPlayer()); + registerInspector(LegacyType.PLAYER, new DataInspectorPlayer()); + registerInspector(LegacyType.PLAYER, new DataInspectorPlayerVehicle()); + registerInspector(LegacyType.STRUCTURE, new DataInspectorStructure()); + } + + private void registerConverters() { + registerConverter(LegacyType.ENTITY, new DataConverterEquipment()); + registerConverter(LegacyType.BLOCK_ENTITY, new DataConverterSignText()); + registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterMaterialId()); + registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterPotionId()); + registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterSpawnEgg()); + registerConverter(LegacyType.ENTITY, new DataConverterMinecart()); + registerConverter(LegacyType.BLOCK_ENTITY, new DataConverterMobSpawner()); + registerConverter(LegacyType.ENTITY, new DataConverterUUID()); + registerConverter(LegacyType.ENTITY, new DataConverterHealth()); + registerConverter(LegacyType.ENTITY, new DataConverterSaddle()); + registerConverter(LegacyType.ENTITY, new DataConverterHanging()); + registerConverter(LegacyType.ENTITY, new DataConverterDropChances()); + registerConverter(LegacyType.ENTITY, new DataConverterRiding()); + registerConverter(LegacyType.ENTITY, new DataConverterArmorStand()); + registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterBook()); + registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterCookedFish()); + registerConverter(LegacyType.ENTITY, new DataConverterZombie()); + registerConverter(LegacyType.OPTIONS, new DataConverterVBO()); + registerConverter(LegacyType.ENTITY, new DataConverterGuardian()); + registerConverter(LegacyType.ENTITY, new DataConverterSkeleton()); + registerConverter(LegacyType.ENTITY, new DataConverterZombieType()); + registerConverter(LegacyType.ENTITY, new DataConverterHorse()); + registerConverter(LegacyType.BLOCK_ENTITY, new DataConverterTileEntity()); + registerConverter(LegacyType.ENTITY, new DataConverterEntity()); + registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterBanner()); + registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterPotionWater()); + registerConverter(LegacyType.ENTITY, new DataConverterShulker()); + registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterShulkerBoxItem()); + registerConverter(LegacyType.BLOCK_ENTITY, new DataConverterShulkerBoxBlock()); + registerConverter(LegacyType.OPTIONS, new DataConverterLang()); + registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterTotem()); + registerConverter(LegacyType.CHUNK, new DataConverterBedBlock()); + registerConverter(LegacyType.ITEM_INSTANCE, new DataConverterBedItem()); + } + + private void registerEntityItemList(String type, String... keys) { + registerInspector(LegacyType.ENTITY, new DataInspectorItemList(type, keys)); + } + + private void registerEntityItemSingle(String type, String key) { + registerInspector(LegacyType.ENTITY, new DataInspectorItem(type, key)); + } + + private void registerEntityItemListEquipment(String type) { + registerEntityItemList(type, "ArmorItems", "HandItems"); + } + + private static final Map OLD_ID_TO_KEY_MAP = new HashMap<>(); + + static { + final Map map = OLD_ID_TO_KEY_MAP; + map.put("EntityItem", Identifier.parse("item")); + map.put("EntityExperienceOrb", Identifier.parse("xp_orb")); + map.put("EntityAreaEffectCloud", Identifier.parse("area_effect_cloud")); + map.put("EntityGuardianElder", Identifier.parse("elder_guardian")); + map.put("EntitySkeletonWither", Identifier.parse("wither_skeleton")); + map.put("EntitySkeletonStray", Identifier.parse("stray")); + map.put("EntityEgg", Identifier.parse("egg")); + map.put("EntityLeash", Identifier.parse("leash_knot")); + map.put("EntityPainting", Identifier.parse("painting")); + map.put("EntityTippedArrow", Identifier.parse("arrow")); + map.put("EntitySnowball", Identifier.parse("snowball")); + map.put("EntityLargeFireball", Identifier.parse("fireball")); + map.put("EntitySmallFireball", Identifier.parse("small_fireball")); + map.put("EntityEnderPearl", Identifier.parse("ender_pearl")); + map.put("EntityEnderSignal", Identifier.parse("eye_of_ender_signal")); + map.put("EntityPotion", Identifier.parse("potion")); + map.put("EntityThrownExpBottle", Identifier.parse("xp_bottle")); + map.put("EntityItemFrame", Identifier.parse("item_frame")); + map.put("EntityWitherSkull", Identifier.parse("wither_skull")); + map.put("EntityTNTPrimed", Identifier.parse("tnt")); + map.put("EntityFallingBlock", Identifier.parse("falling_block")); + map.put("EntityFireworks", Identifier.parse("fireworks_rocket")); + map.put("EntityZombieHusk", Identifier.parse("husk")); + map.put("EntitySpectralArrow", Identifier.parse("spectral_arrow")); + map.put("EntityShulkerBullet", Identifier.parse("shulker_bullet")); + map.put("EntityDragonFireball", Identifier.parse("dragon_fireball")); + map.put("EntityZombieVillager", Identifier.parse("zombie_villager")); + map.put("EntityHorseSkeleton", Identifier.parse("skeleton_horse")); + map.put("EntityHorseZombie", Identifier.parse("zombie_horse")); + map.put("EntityArmorStand", Identifier.parse("armor_stand")); + map.put("EntityHorseDonkey", Identifier.parse("donkey")); + map.put("EntityHorseMule", Identifier.parse("mule")); + map.put("EntityEvokerFangs", Identifier.parse("evocation_fangs")); + map.put("EntityEvoker", Identifier.parse("evocation_illager")); + map.put("EntityVex", Identifier.parse("vex")); + map.put("EntityVindicator", Identifier.parse("vindication_illager")); + map.put("EntityIllagerIllusioner", Identifier.parse("illusion_illager")); + map.put("EntityMinecartCommandBlock", Identifier.parse("commandblock_minecart")); + map.put("EntityBoat", Identifier.parse("boat")); + map.put("EntityMinecartRideable", Identifier.parse("minecart")); + map.put("EntityMinecartChest", Identifier.parse("chest_minecart")); + map.put("EntityMinecartFurnace", Identifier.parse("furnace_minecart")); + map.put("EntityMinecartTNT", Identifier.parse("tnt_minecart")); + map.put("EntityMinecartHopper", Identifier.parse("hopper_minecart")); + map.put("EntityMinecartMobSpawner", Identifier.parse("spawner_minecart")); + map.put("EntityCreeper", Identifier.parse("creeper")); + map.put("EntitySkeleton", Identifier.parse("skeleton")); + map.put("EntitySpider", Identifier.parse("spider")); + map.put("EntityGiantZombie", Identifier.parse("giant")); + map.put("EntityZombie", Identifier.parse("zombie")); + map.put("EntitySlime", Identifier.parse("slime")); + map.put("EntityGhast", Identifier.parse("ghast")); + map.put("EntityPigZombie", Identifier.parse("zombie_pigman")); + map.put("EntityEnderman", Identifier.parse("enderman")); + map.put("EntityCaveSpider", Identifier.parse("cave_spider")); + map.put("EntitySilverfish", Identifier.parse("silverfish")); + map.put("EntityBlaze", Identifier.parse("blaze")); + map.put("EntityMagmaCube", Identifier.parse("magma_cube")); + map.put("EntityEnderDragon", Identifier.parse("ender_dragon")); + map.put("EntityWither", Identifier.parse("wither")); + map.put("EntityBat", Identifier.parse("bat")); + map.put("EntityWitch", Identifier.parse("witch")); + map.put("EntityEndermite", Identifier.parse("endermite")); + map.put("EntityGuardian", Identifier.parse("guardian")); + map.put("EntityShulker", Identifier.parse("shulker")); + map.put("EntityPig", Identifier.parse("pig")); + map.put("EntitySheep", Identifier.parse("sheep")); + map.put("EntityCow", Identifier.parse("cow")); + map.put("EntityChicken", Identifier.parse("chicken")); + map.put("EntitySquid", Identifier.parse("squid")); + map.put("EntityWolf", Identifier.parse("wolf")); + map.put("EntityMushroomCow", Identifier.parse("mooshroom")); + map.put("EntitySnowman", Identifier.parse("snowman")); + map.put("EntityOcelot", Identifier.parse("ocelot")); + map.put("EntityIronGolem", Identifier.parse("villager_golem")); + map.put("EntityHorse", Identifier.parse("horse")); + map.put("EntityRabbit", Identifier.parse("rabbit")); + map.put("EntityPolarBear", Identifier.parse("polar_bear")); + map.put("EntityLlama", Identifier.parse("llama")); + map.put("EntityLlamaSpit", Identifier.parse("llama_spit")); + map.put("EntityParrot", Identifier.parse("parrot")); + map.put("EntityVillager", Identifier.parse("villager")); + map.put("EntityEnderCrystal", Identifier.parse("ender_crystal")); + map.put("TileEntityFurnace", Identifier.parse("furnace")); + map.put("TileEntityChest", Identifier.parse("chest")); + map.put("TileEntityEnderChest", Identifier.parse("ender_chest")); + map.put("TileEntityRecordPlayer", Identifier.parse("jukebox")); + map.put("TileEntityDispenser", Identifier.parse("dispenser")); + map.put("TileEntityDropper", Identifier.parse("dropper")); + map.put("TileEntitySign", Identifier.parse("sign")); + map.put("TileEntityMobSpawner", Identifier.parse("mob_spawner")); + map.put("TileEntityNote", Identifier.parse("noteblock")); + map.put("TileEntityPiston", Identifier.parse("piston")); + map.put("TileEntityBrewingStand", Identifier.parse("brewing_stand")); + map.put("TileEntityEnchantTable", Identifier.parse("enchanting_table")); + map.put("TileEntityEnderPortal", Identifier.parse("end_portal")); + map.put("TileEntityBeacon", Identifier.parse("beacon")); + map.put("TileEntitySkull", Identifier.parse("skull")); + map.put("TileEntityLightDetector", Identifier.parse("daylight_detector")); + map.put("TileEntityHopper", Identifier.parse("hopper")); + map.put("TileEntityComparator", Identifier.parse("comparator")); + map.put("TileEntityFlowerPot", Identifier.parse("flower_pot")); + map.put("TileEntityBanner", Identifier.parse("banner")); + map.put("TileEntityStructure", Identifier.parse("structure_block")); + map.put("TileEntityEndGateway", Identifier.parse("end_gateway")); + map.put("TileEntityCommand", Identifier.parse("command_block")); + map.put("TileEntityShulkerBox", Identifier.parse("shulker_box")); + map.put("TileEntityBed", Identifier.parse("bed")); + } + + private static Identifier getKey(String type) { + final Identifier key = OLD_ID_TO_KEY_MAP.get(type); + if (key == null) { + throw new IllegalArgumentException("Unknown mapping for " + type); + } + return key; + } + + private static void convertCompound(LegacyType type, net.minecraft.nbt.CompoundTag cmp, String key, int sourceVer, int targetVer) { + cmp.put(key, convert(type, cmp.getCompoundOrEmpty(key), sourceVer, targetVer)); + } + + private static void convertItem(net.minecraft.nbt.CompoundTag nbttagcompound, String key, int sourceVer, int targetVer) { + if (nbttagcompound.getCompound(key).isPresent()) { + convertCompound(LegacyType.ITEM_INSTANCE, nbttagcompound, key, sourceVer, targetVer); + } + } + + private static void convertItems(net.minecraft.nbt.CompoundTag nbttagcompound, String key, int sourceVer, int targetVer) { + nbttagcompound.getList(key).ifPresent(nbttaglist -> { + for (int j = 0; j < nbttaglist.size(); ++j) { + nbttaglist.set(j, convert(LegacyType.ITEM_INSTANCE, nbttaglist.getCompoundOrEmpty(j), sourceVer, targetVer)); + } + }); + } + + private static class DataConverterEquipment implements DataConverter { + + DataConverterEquipment() { + } + + @Override + public int getDataVersion() { + return 100; + } + + @Override + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + ListTag nbttaglist = cmp.getListOrEmpty("Equipment"); + + if (!nbttaglist.isEmpty() && cmp.getCompound("HandItems").isEmpty()) { + ListTag nbttaglist1 = new ListTag(); + nbttaglist1.add(nbttaglist.get(0)); + nbttaglist1.add(new net.minecraft.nbt.CompoundTag()); + cmp.put("HandItems", nbttaglist1); + } + + if (nbttaglist.size() > 1 && cmp.getCompound("ArmorItem").isEmpty()) { + ListTag nbttaglist1 = new ListTag(); + nbttaglist1.add(nbttaglist.get(1)); + nbttaglist1.add(nbttaglist.get(2)); + nbttaglist1.add(nbttaglist.get(3)); + nbttaglist1.add(nbttaglist.get(4)); + cmp.put("ArmorItems", nbttaglist1); + } + + cmp.remove("Equipment"); + cmp.getList("DropChances").ifPresent(nbttaglist1 -> { + ListTag nbttaglist2; + + if (cmp.getCompound("HandDropChances").isEmpty()) { + nbttaglist2 = new ListTag(); + nbttaglist2.add(FloatTag.valueOf(nbttaglist1.getFloatOr(0, 0F))); + nbttaglist2.add(FloatTag.valueOf(0.0F)); + cmp.put("HandDropChances", nbttaglist2); + } + + if (cmp.getCompound("ArmorDropChances").isEmpty()) { + nbttaglist2 = new ListTag(); + nbttaglist2.add(FloatTag.valueOf(nbttaglist1.getFloatOr(1, 0F))); + nbttaglist2.add(FloatTag.valueOf(nbttaglist1.getFloatOr(2, 0F))); + nbttaglist2.add(FloatTag.valueOf(nbttaglist1.getFloatOr(3, 0F))); + nbttaglist2.add(FloatTag.valueOf(nbttaglist1.getFloatOr(4, 0F))); + cmp.put("ArmorDropChances", nbttaglist2); + } + + cmp.remove("DropChances"); + }); + + return cmp; + } + } + + private static class DataInspectorBlockEntity implements DataInspector { + + private static final Map b = Maps.newHashMap(); + private static final Map c = Maps.newHashMap(); + + DataInspectorBlockEntity() { + } + + @Nullable + private static String convertEntityId(int i, String s) { + String key = Identifier.parse(s).toString(); + if (i < 515 && DataInspectorBlockEntity.b.containsKey(key)) { + return DataInspectorBlockEntity.b.get(key); + } else { + return DataInspectorBlockEntity.c.get(key); + } + } + + @Override + public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { + Optional nbttagcompound1Optional = cmp.getCompound("tag"); + + if (nbttagcompound1Optional.isPresent()) { + var nbttagcompound1 = nbttagcompound1Optional.get(); + + nbttagcompound1.getCompound("BlockEntityTag").ifPresent(nbttagcompound2 -> { + String s = cmp.getString("id").get(); + String s1 = convertEntityId(sourceVer, s); + boolean flag; + + if (s1 == null) { + // CraftBukkit - Remove unnecessary warning (occurs when deserializing a Shulker Box item) + // DataInspectorBlockEntity.a.warn("Unable to resolve BlockEntity for ItemInstance: {}", s); + flag = false; + } else { + flag = !nbttagcompound2.contains("id"); + nbttagcompound2.putString("id", s1); + } + + convert(LegacyType.BLOCK_ENTITY, nbttagcompound2, sourceVer, targetVer); + if (flag) { + nbttagcompound2.remove("id"); + } + }); + } + + return cmp; + } + + static { + Map map = DataInspectorBlockEntity.b; + + map.put("minecraft:furnace", "Furnace"); + map.put("minecraft:lit_furnace", "Furnace"); + map.put("minecraft:chest", "Chest"); + map.put("minecraft:trapped_chest", "Chest"); + map.put("minecraft:ender_chest", "EnderChest"); + map.put("minecraft:jukebox", "RecordPlayer"); + map.put("minecraft:dispenser", "Trap"); + map.put("minecraft:dropper", "Dropper"); + map.put("minecraft:sign", "Sign"); + map.put("minecraft:mob_spawner", "MobSpawner"); + map.put("minecraft:noteblock", "Music"); + map.put("minecraft:brewing_stand", "Cauldron"); + map.put("minecraft:enhanting_table", "EnchantTable"); + map.put("minecraft:command_block", "CommandBlock"); + map.put("minecraft:beacon", "Beacon"); + map.put("minecraft:skull", "Skull"); + map.put("minecraft:daylight_detector", "DLDetector"); + map.put("minecraft:hopper", "Hopper"); + map.put("minecraft:banner", "Banner"); + map.put("minecraft:flower_pot", "FlowerPot"); + map.put("minecraft:repeating_command_block", "CommandBlock"); + map.put("minecraft:chain_command_block", "CommandBlock"); + map.put("minecraft:standing_sign", "Sign"); + map.put("minecraft:wall_sign", "Sign"); + map.put("minecraft:piston_head", "Piston"); + map.put("minecraft:daylight_detector_inverted", "DLDetector"); + map.put("minecraft:unpowered_comparator", "Comparator"); + map.put("minecraft:powered_comparator", "Comparator"); + map.put("minecraft:wall_banner", "Banner"); + map.put("minecraft:standing_banner", "Banner"); + map.put("minecraft:structure_block", "Structure"); + map.put("minecraft:end_portal", "Airportal"); + map.put("minecraft:end_gateway", "EndGateway"); + map.put("minecraft:shield", "Shield"); + map = DataInspectorBlockEntity.c; + map.put("minecraft:furnace", "minecraft:furnace"); + map.put("minecraft:lit_furnace", "minecraft:furnace"); + map.put("minecraft:chest", "minecraft:chest"); + map.put("minecraft:trapped_chest", "minecraft:chest"); + map.put("minecraft:ender_chest", "minecraft:enderchest"); + map.put("minecraft:jukebox", "minecraft:jukebox"); + map.put("minecraft:dispenser", "minecraft:dispenser"); + map.put("minecraft:dropper", "minecraft:dropper"); + map.put("minecraft:sign", "minecraft:sign"); + map.put("minecraft:mob_spawner", "minecraft:mob_spawner"); + map.put("minecraft:noteblock", "minecraft:noteblock"); + map.put("minecraft:brewing_stand", "minecraft:brewing_stand"); + map.put("minecraft:enhanting_table", "minecraft:enchanting_table"); + map.put("minecraft:command_block", "minecraft:command_block"); + map.put("minecraft:beacon", "minecraft:beacon"); + map.put("minecraft:skull", "minecraft:skull"); + map.put("minecraft:daylight_detector", "minecraft:daylight_detector"); + map.put("minecraft:hopper", "minecraft:hopper"); + map.put("minecraft:banner", "minecraft:banner"); + map.put("minecraft:flower_pot", "minecraft:flower_pot"); + map.put("minecraft:repeating_command_block", "minecraft:command_block"); + map.put("minecraft:chain_command_block", "minecraft:command_block"); + map.put("minecraft:shulker_box", "minecraft:shulker_box"); + map.put("minecraft:white_shulker_box", "minecraft:shulker_box"); + map.put("minecraft:orange_shulker_box", "minecraft:shulker_box"); + map.put("minecraft:magenta_shulker_box", "minecraft:shulker_box"); + map.put("minecraft:light_blue_shulker_box", "minecraft:shulker_box"); + map.put("minecraft:yellow_shulker_box", "minecraft:shulker_box"); + map.put("minecraft:lime_shulker_box", "minecraft:shulker_box"); + map.put("minecraft:pink_shulker_box", "minecraft:shulker_box"); + map.put("minecraft:gray_shulker_box", "minecraft:shulker_box"); + map.put("minecraft:silver_shulker_box", "minecraft:shulker_box"); + map.put("minecraft:cyan_shulker_box", "minecraft:shulker_box"); + map.put("minecraft:purple_shulker_box", "minecraft:shulker_box"); + map.put("minecraft:blue_shulker_box", "minecraft:shulker_box"); + map.put("minecraft:brown_shulker_box", "minecraft:shulker_box"); + map.put("minecraft:green_shulker_box", "minecraft:shulker_box"); + map.put("minecraft:red_shulker_box", "minecraft:shulker_box"); + map.put("minecraft:black_shulker_box", "minecraft:shulker_box"); + map.put("minecraft:bed", "minecraft:bed"); + map.put("minecraft:standing_sign", "minecraft:sign"); + map.put("minecraft:wall_sign", "minecraft:sign"); + map.put("minecraft:piston_head", "minecraft:piston"); + map.put("minecraft:daylight_detector_inverted", "minecraft:daylight_detector"); + map.put("minecraft:unpowered_comparator", "minecraft:comparator"); + map.put("minecraft:powered_comparator", "minecraft:comparator"); + map.put("minecraft:wall_banner", "minecraft:banner"); + map.put("minecraft:standing_banner", "minecraft:banner"); + map.put("minecraft:structure_block", "minecraft:structure_block"); + map.put("minecraft:end_portal", "minecraft:end_portal"); + map.put("minecraft:end_gateway", "minecraft:end_gateway"); + map.put("minecraft:shield", "minecraft:shield"); + } + } + + private static class DataInspectorEntity implements DataInspector { + + private static final Logger a = LogManager.getLogger(PaperweightDataConverters.class); + + DataInspectorEntity() { + } + + @Override + public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { + cmp.getCompound("tag").flatMap(nbttagcompound1 -> nbttagcompound1.getCompound("EntityTag")).ifPresent(nbttagcompound2 -> { + String s = cmp.getString("id").orElse(null); + String s1; + + if ("minecraft:armor_stand".equals(s)) { + s1 = sourceVer < 515 ? "ArmorStand" : "minecraft:armor_stand"; + } else { + if (!"minecraft:spawn_egg".equals(s)) { + return; + } + + s1 = nbttagcompound2.getString("id").orElse(null); + } + + boolean flag; + + if (s1 == null) { + DataInspectorEntity.a.warn("Unable to resolve Entity for ItemInstance: {}", s); + flag = false; + } else { + flag = nbttagcompound2.getString("id").isEmpty(); + nbttagcompound2.putString("id", s1); + } + + convert(LegacyType.ENTITY, nbttagcompound2, sourceVer, targetVer); + if (flag) { + nbttagcompound2.remove("id"); + } + }); + + return cmp; + } + } + + + private abstract static class DataInspectorTagged implements DataInspector { + + private final Identifier key; + + DataInspectorTagged(String type) { + this.key = getKey(type); + } + + public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { + if (cmp.getString("id").isPresent() && this.key.equals(Identifier.parse(cmp.getString("id").get()))) { + cmp = this.inspectChecked(cmp, sourceVer, targetVer); + } + + return cmp; + } + + abstract net.minecraft.nbt.CompoundTag inspectChecked(net.minecraft.nbt.CompoundTag nbttagcompound, int sourceVer, int targetVer); + } + + private static class DataInspectorItemList extends DataInspectorTagged { + + private final String[] keys; + + DataInspectorItemList(String oclass, String... astring) { + super(oclass); + this.keys = astring; + } + + net.minecraft.nbt.CompoundTag inspectChecked(net.minecraft.nbt.CompoundTag nbttagcompound, int sourceVer, int targetVer) { + for (String s : this.keys) { + PaperweightDataConverters.convertItems(nbttagcompound, s, sourceVer, targetVer); + } + + return nbttagcompound; + } + } + + private static class DataInspectorItem extends DataInspectorTagged { + + private final String[] keys; + + DataInspectorItem(String oclass, String... astring) { + super(oclass); + this.keys = astring; + } + + net.minecraft.nbt.CompoundTag inspectChecked(net.minecraft.nbt.CompoundTag nbttagcompound, int sourceVer, int targetVer) { + for (String key : this.keys) { + PaperweightDataConverters.convertItem(nbttagcompound, key, sourceVer, targetVer); + } + + return nbttagcompound; + } + } + + private static class DataConverterMaterialId implements DataConverter { + + private static final String[] materials = new String[2268]; + + DataConverterMaterialId() { + } + + public int getDataVersion() { + return 102; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + cmp.getShort("id").ifPresent(short0 -> { + if (short0 > 0 && short0 < materials.length && materials[short0] != null) { + cmp.putString("id", materials[short0]); + } + }); + + return cmp; + } + + static { + materials[1] = "minecraft:stone"; + materials[2] = "minecraft:grass"; + materials[3] = "minecraft:dirt"; + materials[4] = "minecraft:cobblestone"; + materials[5] = "minecraft:planks"; + materials[6] = "minecraft:sapling"; + materials[7] = "minecraft:bedrock"; + materials[8] = "minecraft:flowing_water"; + materials[9] = "minecraft:water"; + materials[10] = "minecraft:flowing_lava"; + materials[11] = "minecraft:lava"; + materials[12] = "minecraft:sand"; + materials[13] = "minecraft:gravel"; + materials[14] = "minecraft:gold_ore"; + materials[15] = "minecraft:iron_ore"; + materials[16] = "minecraft:coal_ore"; + materials[17] = "minecraft:log"; + materials[18] = "minecraft:leaves"; + materials[19] = "minecraft:sponge"; + materials[20] = "minecraft:glass"; + materials[21] = "minecraft:lapis_ore"; + materials[22] = "minecraft:lapis_block"; + materials[23] = "minecraft:dispenser"; + materials[24] = "minecraft:sandstone"; + materials[25] = "minecraft:noteblock"; + materials[27] = "minecraft:golden_rail"; + materials[28] = "minecraft:detector_rail"; + materials[29] = "minecraft:sticky_piston"; + materials[30] = "minecraft:web"; + materials[31] = "minecraft:tallgrass"; + materials[32] = "minecraft:deadbush"; + materials[33] = "minecraft:piston"; + materials[35] = "minecraft:wool"; + materials[37] = "minecraft:yellow_flower"; + materials[38] = "minecraft:red_flower"; + materials[39] = "minecraft:brown_mushroom"; + materials[40] = "minecraft:red_mushroom"; + materials[41] = "minecraft:gold_block"; + materials[42] = "minecraft:iron_block"; + materials[43] = "minecraft:double_stone_slab"; + materials[44] = "minecraft:stone_slab"; + materials[45] = "minecraft:brick_block"; + materials[46] = "minecraft:tnt"; + materials[47] = "minecraft:bookshelf"; + materials[48] = "minecraft:mossy_cobblestone"; + materials[49] = "minecraft:obsidian"; + materials[50] = "minecraft:torch"; + materials[51] = "minecraft:fire"; + materials[52] = "minecraft:mob_spawner"; + materials[53] = "minecraft:oak_stairs"; + materials[54] = "minecraft:chest"; + materials[56] = "minecraft:diamond_ore"; + materials[57] = "minecraft:diamond_block"; + materials[58] = "minecraft:crafting_table"; + materials[60] = "minecraft:farmland"; + materials[61] = "minecraft:furnace"; + materials[62] = "minecraft:lit_furnace"; + materials[65] = "minecraft:ladder"; + materials[66] = "minecraft:rail"; + materials[67] = "minecraft:stone_stairs"; + materials[69] = "minecraft:lever"; + materials[70] = "minecraft:stone_pressure_plate"; + materials[72] = "minecraft:wooden_pressure_plate"; + materials[73] = "minecraft:redstone_ore"; + materials[76] = "minecraft:redstone_torch"; + materials[77] = "minecraft:stone_button"; + materials[78] = "minecraft:snow_layer"; + materials[79] = "minecraft:ice"; + materials[80] = "minecraft:snow"; + materials[81] = "minecraft:cactus"; + materials[82] = "minecraft:clay"; + materials[84] = "minecraft:jukebox"; + materials[85] = "minecraft:fence"; + materials[86] = "minecraft:pumpkin"; + materials[87] = "minecraft:netherrack"; + materials[88] = "minecraft:soul_sand"; + materials[89] = "minecraft:glowstone"; + materials[90] = "minecraft:portal"; + materials[91] = "minecraft:lit_pumpkin"; + materials[95] = "minecraft:stained_glass"; + materials[96] = "minecraft:trapdoor"; + materials[97] = "minecraft:monster_egg"; + materials[98] = "minecraft:stonebrick"; + materials[99] = "minecraft:brown_mushroom_block"; + materials[100] = "minecraft:red_mushroom_block"; + materials[101] = "minecraft:iron_bars"; + materials[102] = "minecraft:glass_pane"; + materials[103] = "minecraft:melon_block"; + materials[106] = "minecraft:vine"; + materials[107] = "minecraft:fence_gate"; + materials[108] = "minecraft:brick_stairs"; + materials[109] = "minecraft:stone_brick_stairs"; + materials[110] = "minecraft:mycelium"; + materials[111] = "minecraft:waterlily"; + materials[112] = "minecraft:nether_brick"; + materials[113] = "minecraft:nether_brick_fence"; + materials[114] = "minecraft:nether_brick_stairs"; + materials[116] = "minecraft:enchanting_table"; + materials[119] = "minecraft:end_portal"; + materials[120] = "minecraft:end_portal_frame"; + materials[121] = "minecraft:end_stone"; + materials[122] = "minecraft:dragon_egg"; + materials[123] = "minecraft:redstone_lamp"; + materials[125] = "minecraft:double_wooden_slab"; + materials[126] = "minecraft:wooden_slab"; + materials[127] = "minecraft:cocoa"; + materials[128] = "minecraft:sandstone_stairs"; + materials[129] = "minecraft:emerald_ore"; + materials[130] = "minecraft:ender_chest"; + materials[131] = "minecraft:tripwire_hook"; + materials[133] = "minecraft:emerald_block"; + materials[134] = "minecraft:spruce_stairs"; + materials[135] = "minecraft:birch_stairs"; + materials[136] = "minecraft:jungle_stairs"; + materials[137] = "minecraft:command_block"; + materials[138] = "minecraft:beacon"; + materials[139] = "minecraft:cobblestone_wall"; + materials[141] = "minecraft:carrots"; + materials[142] = "minecraft:potatoes"; + materials[143] = "minecraft:wooden_button"; + materials[145] = "minecraft:anvil"; + materials[146] = "minecraft:trapped_chest"; + materials[147] = "minecraft:light_weighted_pressure_plate"; + materials[148] = "minecraft:heavy_weighted_pressure_plate"; + materials[151] = "minecraft:daylight_detector"; + materials[152] = "minecraft:redstone_block"; + materials[153] = "minecraft:quartz_ore"; + materials[154] = "minecraft:hopper"; + materials[155] = "minecraft:quartz_block"; + materials[156] = "minecraft:quartz_stairs"; + materials[157] = "minecraft:activator_rail"; + materials[158] = "minecraft:dropper"; + materials[159] = "minecraft:stained_hardened_clay"; + materials[160] = "minecraft:stained_glass_pane"; + materials[161] = "minecraft:leaves2"; + materials[162] = "minecraft:log2"; + materials[163] = "minecraft:acacia_stairs"; + materials[164] = "minecraft:dark_oak_stairs"; + materials[170] = "minecraft:hay_block"; + materials[171] = "minecraft:carpet"; + materials[172] = "minecraft:hardened_clay"; + materials[173] = "minecraft:coal_block"; + materials[174] = "minecraft:packed_ice"; + materials[175] = "minecraft:double_plant"; + materials[256] = "minecraft:iron_shovel"; + materials[257] = "minecraft:iron_pickaxe"; + materials[258] = "minecraft:iron_axe"; + materials[259] = "minecraft:flint_and_steel"; + materials[260] = "minecraft:apple"; + materials[261] = "minecraft:bow"; + materials[262] = "minecraft:arrow"; + materials[263] = "minecraft:coal"; + materials[264] = "minecraft:diamond"; + materials[265] = "minecraft:iron_ingot"; + materials[266] = "minecraft:gold_ingot"; + materials[267] = "minecraft:iron_sword"; + materials[268] = "minecraft:wooden_sword"; + materials[269] = "minecraft:wooden_shovel"; + materials[270] = "minecraft:wooden_pickaxe"; + materials[271] = "minecraft:wooden_axe"; + materials[272] = "minecraft:stone_sword"; + materials[273] = "minecraft:stone_shovel"; + materials[274] = "minecraft:stone_pickaxe"; + materials[275] = "minecraft:stone_axe"; + materials[276] = "minecraft:diamond_sword"; + materials[277] = "minecraft:diamond_shovel"; + materials[278] = "minecraft:diamond_pickaxe"; + materials[279] = "minecraft:diamond_axe"; + materials[280] = "minecraft:stick"; + materials[281] = "minecraft:bowl"; + materials[282] = "minecraft:mushroom_stew"; + materials[283] = "minecraft:golden_sword"; + materials[284] = "minecraft:golden_shovel"; + materials[285] = "minecraft:golden_pickaxe"; + materials[286] = "minecraft:golden_axe"; + materials[287] = "minecraft:string"; + materials[288] = "minecraft:feather"; + materials[289] = "minecraft:gunpowder"; + materials[290] = "minecraft:wooden_hoe"; + materials[291] = "minecraft:stone_hoe"; + materials[292] = "minecraft:iron_hoe"; + materials[293] = "minecraft:diamond_hoe"; + materials[294] = "minecraft:golden_hoe"; + materials[295] = "minecraft:wheat_seeds"; + materials[296] = "minecraft:wheat"; + materials[297] = "minecraft:bread"; + materials[298] = "minecraft:leather_helmet"; + materials[299] = "minecraft:leather_chestplate"; + materials[300] = "minecraft:leather_leggings"; + materials[301] = "minecraft:leather_boots"; + materials[302] = "minecraft:chainmail_helmet"; + materials[303] = "minecraft:chainmail_chestplate"; + materials[304] = "minecraft:chainmail_leggings"; + materials[305] = "minecraft:chainmail_boots"; + materials[306] = "minecraft:iron_helmet"; + materials[307] = "minecraft:iron_chestplate"; + materials[308] = "minecraft:iron_leggings"; + materials[309] = "minecraft:iron_boots"; + materials[310] = "minecraft:diamond_helmet"; + materials[311] = "minecraft:diamond_chestplate"; + materials[312] = "minecraft:diamond_leggings"; + materials[313] = "minecraft:diamond_boots"; + materials[314] = "minecraft:golden_helmet"; + materials[315] = "minecraft:golden_chestplate"; + materials[316] = "minecraft:golden_leggings"; + materials[317] = "minecraft:golden_boots"; + materials[318] = "minecraft:flint"; + materials[319] = "minecraft:porkchop"; + materials[320] = "minecraft:cooked_porkchop"; + materials[321] = "minecraft:painting"; + materials[322] = "minecraft:golden_apple"; + materials[323] = "minecraft:sign"; + materials[324] = "minecraft:wooden_door"; + materials[325] = "minecraft:bucket"; + materials[326] = "minecraft:water_bucket"; + materials[327] = "minecraft:lava_bucket"; + materials[328] = "minecraft:minecart"; + materials[329] = "minecraft:saddle"; + materials[330] = "minecraft:iron_door"; + materials[331] = "minecraft:redstone"; + materials[332] = "minecraft:snowball"; + materials[333] = "minecraft:boat"; + materials[334] = "minecraft:leather"; + materials[335] = "minecraft:milk_bucket"; + materials[336] = "minecraft:brick"; + materials[337] = "minecraft:clay_ball"; + materials[338] = "minecraft:reeds"; + materials[339] = "minecraft:paper"; + materials[340] = "minecraft:book"; + materials[341] = "minecraft:slime_ball"; + materials[342] = "minecraft:chest_minecart"; + materials[343] = "minecraft:furnace_minecart"; + materials[344] = "minecraft:egg"; + materials[345] = "minecraft:compass"; + materials[346] = "minecraft:fishing_rod"; + materials[347] = "minecraft:clock"; + materials[348] = "minecraft:glowstone_dust"; + materials[349] = "minecraft:fish"; + materials[350] = "minecraft:cooked_fish"; // Paper - cooked_fished -> cooked_fish + materials[351] = "minecraft:dye"; + materials[352] = "minecraft:bone"; + materials[353] = "minecraft:sugar"; + materials[354] = "minecraft:cake"; + materials[355] = "minecraft:bed"; + materials[356] = "minecraft:repeater"; + materials[357] = "minecraft:cookie"; + materials[358] = "minecraft:filled_map"; + materials[359] = "minecraft:shears"; + materials[360] = "minecraft:melon"; + materials[361] = "minecraft:pumpkin_seeds"; + materials[362] = "minecraft:melon_seeds"; + materials[363] = "minecraft:beef"; + materials[364] = "minecraft:cooked_beef"; + materials[365] = "minecraft:chicken"; + materials[366] = "minecraft:cooked_chicken"; + materials[367] = "minecraft:rotten_flesh"; + materials[368] = "minecraft:ender_pearl"; + materials[369] = "minecraft:blaze_rod"; + materials[370] = "minecraft:ghast_tear"; + materials[371] = "minecraft:gold_nugget"; + materials[372] = "minecraft:nether_wart"; + materials[373] = "minecraft:potion"; + materials[374] = "minecraft:glass_bottle"; + materials[375] = "minecraft:spider_eye"; + materials[376] = "minecraft:fermented_spider_eye"; + materials[377] = "minecraft:blaze_powder"; + materials[378] = "minecraft:magma_cream"; + materials[379] = "minecraft:brewing_stand"; + materials[380] = "minecraft:cauldron"; + materials[381] = "minecraft:ender_eye"; + materials[382] = "minecraft:speckled_melon"; + materials[383] = "minecraft:spawn_egg"; + materials[384] = "minecraft:experience_bottle"; + materials[385] = "minecraft:fire_charge"; + materials[386] = "minecraft:writable_book"; + materials[387] = "minecraft:written_book"; + materials[388] = "minecraft:emerald"; + materials[389] = "minecraft:item_frame"; + materials[390] = "minecraft:flower_pot"; + materials[391] = "minecraft:carrot"; + materials[392] = "minecraft:potato"; + materials[393] = "minecraft:baked_potato"; + materials[394] = "minecraft:poisonous_potato"; + materials[395] = "minecraft:map"; + materials[396] = "minecraft:golden_carrot"; + materials[397] = "minecraft:skull"; + materials[398] = "minecraft:carrot_on_a_stick"; + materials[399] = "minecraft:nether_star"; + materials[400] = "minecraft:pumpkin_pie"; + materials[401] = "minecraft:fireworks"; + materials[402] = "minecraft:firework_charge"; + materials[403] = "minecraft:enchanted_book"; + materials[404] = "minecraft:comparator"; + materials[405] = "minecraft:netherbrick"; + materials[406] = "minecraft:quartz"; + materials[407] = "minecraft:tnt_minecart"; + materials[408] = "minecraft:hopper_minecart"; + materials[417] = "minecraft:iron_horse_armor"; + materials[418] = "minecraft:golden_horse_armor"; + materials[419] = "minecraft:diamond_horse_armor"; + materials[420] = "minecraft:lead"; + materials[421] = "minecraft:name_tag"; + materials[422] = "minecraft:command_block_minecart"; + materials[2256] = "minecraft:record_13"; + materials[2257] = "minecraft:record_cat"; + materials[2258] = "minecraft:record_blocks"; + materials[2259] = "minecraft:record_chirp"; + materials[2260] = "minecraft:record_far"; + materials[2261] = "minecraft:record_mall"; + materials[2262] = "minecraft:record_mellohi"; + materials[2263] = "minecraft:record_stal"; + materials[2264] = "minecraft:record_strad"; + materials[2265] = "minecraft:record_ward"; + materials[2266] = "minecraft:record_11"; + materials[2267] = "minecraft:record_wait"; + // Paper start + materials[409] = "minecraft:prismarine_shard"; + materials[410] = "minecraft:prismarine_crystals"; + materials[411] = "minecraft:rabbit"; + materials[412] = "minecraft:cooked_rabbit"; + materials[413] = "minecraft:rabbit_stew"; + materials[414] = "minecraft:rabbit_foot"; + materials[415] = "minecraft:rabbit_hide"; + materials[416] = "minecraft:armor_stand"; + materials[423] = "minecraft:mutton"; + materials[424] = "minecraft:cooked_mutton"; + materials[425] = "minecraft:banner"; + materials[426] = "minecraft:end_crystal"; + materials[427] = "minecraft:spruce_door"; + materials[428] = "minecraft:birch_door"; + materials[429] = "minecraft:jungle_door"; + materials[430] = "minecraft:acacia_door"; + materials[431] = "minecraft:dark_oak_door"; + materials[432] = "minecraft:chorus_fruit"; + materials[433] = "minecraft:chorus_fruit_popped"; + materials[434] = "minecraft:beetroot"; + materials[435] = "minecraft:beetroot_seeds"; + materials[436] = "minecraft:beetroot_soup"; + materials[437] = "minecraft:dragon_breath"; + materials[438] = "minecraft:splash_potion"; + materials[439] = "minecraft:spectral_arrow"; + materials[440] = "minecraft:tipped_arrow"; + materials[441] = "minecraft:lingering_potion"; + materials[442] = "minecraft:shield"; + materials[443] = "minecraft:elytra"; + materials[444] = "minecraft:spruce_boat"; + materials[445] = "minecraft:birch_boat"; + materials[446] = "minecraft:jungle_boat"; + materials[447] = "minecraft:acacia_boat"; + materials[448] = "minecraft:dark_oak_boat"; + materials[449] = "minecraft:totem_of_undying"; + materials[450] = "minecraft:shulker_shell"; + materials[452] = "minecraft:iron_nugget"; + materials[453] = "minecraft:knowledge_book"; + // Paper end + } + } + + private static class DataConverterArmorStand implements DataConverter { + + DataConverterArmorStand() { + } + + public int getDataVersion() { + return 147; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if ("ArmorStand".equals(cmp.getString("id").orElse(null)) && cmp.getBoolean("Silent").orElse(false) && !cmp.getBoolean("Marker").orElse(false)) { + cmp.remove("Silent"); + } + + return cmp; + } + } + + private static class DataConverterBanner implements DataConverter { + + DataConverterBanner() { + } + + public int getDataVersion() { + return 804; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if ("minecraft:banner".equals(cmp.getString("id").orElse(null))) { + cmp.getCompound("tag").ifPresent(nbttagcompound1 -> nbttagcompound1.getCompound("BlockEntityTag").ifPresent(nbttagcompound2 -> { + if (nbttagcompound2.getShort("Base").isPresent()) { + cmp.putShort("Damage", (short) (nbttagcompound2.getShort("Base").get() & 15)); + if (nbttagcompound1.getCompound("display").isPresent()) { + CompoundTag nbttagcompound3 = nbttagcompound1.getCompound("display").get(); + + if (nbttagcompound3.getList("Lore").isPresent()) { + ListTag nbttaglist = nbttagcompound3.getList("Lore").get(); + + if (nbttaglist.size() == 1 && "(+NBT)".equals(nbttaglist.getString(0).orElse(null))) { + return; + } + } + } + + nbttagcompound2.remove("Base"); + if (nbttagcompound2.isEmpty()) { + nbttagcompound1.remove("BlockEntityTag"); + } + + if (nbttagcompound1.isEmpty()) { + cmp.remove("tag"); + } + } + })); + } + + return cmp; + } + } + + private static class DataConverterPotionId implements DataConverter { + + private static final String[] potions = new String[128]; + + DataConverterPotionId() { + } + + public int getDataVersion() { + return 102; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if ("minecraft:potion".equals(cmp.getString("id").orElse(null))) { + net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompoundOrEmpty("tag"); + short short0 = cmp.getShortOr("Damage", (short) 0); + + if (nbttagcompound1.getString("Potion").isEmpty()) { + String s = DataConverterPotionId.potions[short0 & 127]; + + nbttagcompound1.putString("Potion", s == null ? "minecraft:water" : s); + cmp.put("tag", nbttagcompound1); + if ((short0 & 16384) == 16384) { + cmp.putString("id", "minecraft:splash_potion"); + } + } + + if (short0 != 0) { + cmp.putShort("Damage", (short) 0); + } + } + + return cmp; + } + + static { + DataConverterPotionId.potions[0] = "minecraft:water"; + DataConverterPotionId.potions[1] = "minecraft:regeneration"; + DataConverterPotionId.potions[2] = "minecraft:swiftness"; + DataConverterPotionId.potions[3] = "minecraft:fire_resistance"; + DataConverterPotionId.potions[4] = "minecraft:poison"; + DataConverterPotionId.potions[5] = "minecraft:healing"; + DataConverterPotionId.potions[6] = "minecraft:night_vision"; + DataConverterPotionId.potions[7] = null; + DataConverterPotionId.potions[8] = "minecraft:weakness"; + DataConverterPotionId.potions[9] = "minecraft:strength"; + DataConverterPotionId.potions[10] = "minecraft:slowness"; + DataConverterPotionId.potions[11] = "minecraft:leaping"; + DataConverterPotionId.potions[12] = "minecraft:harming"; + DataConverterPotionId.potions[13] = "minecraft:water_breathing"; + DataConverterPotionId.potions[14] = "minecraft:invisibility"; + DataConverterPotionId.potions[15] = null; + DataConverterPotionId.potions[16] = "minecraft:awkward"; + DataConverterPotionId.potions[17] = "minecraft:regeneration"; + DataConverterPotionId.potions[18] = "minecraft:swiftness"; + DataConverterPotionId.potions[19] = "minecraft:fire_resistance"; + DataConverterPotionId.potions[20] = "minecraft:poison"; + DataConverterPotionId.potions[21] = "minecraft:healing"; + DataConverterPotionId.potions[22] = "minecraft:night_vision"; + DataConverterPotionId.potions[23] = null; + DataConverterPotionId.potions[24] = "minecraft:weakness"; + DataConverterPotionId.potions[25] = "minecraft:strength"; + DataConverterPotionId.potions[26] = "minecraft:slowness"; + DataConverterPotionId.potions[27] = "minecraft:leaping"; + DataConverterPotionId.potions[28] = "minecraft:harming"; + DataConverterPotionId.potions[29] = "minecraft:water_breathing"; + DataConverterPotionId.potions[30] = "minecraft:invisibility"; + DataConverterPotionId.potions[31] = null; + DataConverterPotionId.potions[32] = "minecraft:thick"; + DataConverterPotionId.potions[33] = "minecraft:strong_regeneration"; + DataConverterPotionId.potions[34] = "minecraft:strong_swiftness"; + DataConverterPotionId.potions[35] = "minecraft:fire_resistance"; + DataConverterPotionId.potions[36] = "minecraft:strong_poison"; + DataConverterPotionId.potions[37] = "minecraft:strong_healing"; + DataConverterPotionId.potions[38] = "minecraft:night_vision"; + DataConverterPotionId.potions[39] = null; + DataConverterPotionId.potions[40] = "minecraft:weakness"; + DataConverterPotionId.potions[41] = "minecraft:strong_strength"; + DataConverterPotionId.potions[42] = "minecraft:slowness"; + DataConverterPotionId.potions[43] = "minecraft:strong_leaping"; + DataConverterPotionId.potions[44] = "minecraft:strong_harming"; + DataConverterPotionId.potions[45] = "minecraft:water_breathing"; + DataConverterPotionId.potions[46] = "minecraft:invisibility"; + DataConverterPotionId.potions[47] = null; + DataConverterPotionId.potions[48] = null; + DataConverterPotionId.potions[49] = "minecraft:strong_regeneration"; + DataConverterPotionId.potions[50] = "minecraft:strong_swiftness"; + DataConverterPotionId.potions[51] = "minecraft:fire_resistance"; + DataConverterPotionId.potions[52] = "minecraft:strong_poison"; + DataConverterPotionId.potions[53] = "minecraft:strong_healing"; + DataConverterPotionId.potions[54] = "minecraft:night_vision"; + DataConverterPotionId.potions[55] = null; + DataConverterPotionId.potions[56] = "minecraft:weakness"; + DataConverterPotionId.potions[57] = "minecraft:strong_strength"; + DataConverterPotionId.potions[58] = "minecraft:slowness"; + DataConverterPotionId.potions[59] = "minecraft:strong_leaping"; + DataConverterPotionId.potions[60] = "minecraft:strong_harming"; + DataConverterPotionId.potions[61] = "minecraft:water_breathing"; + DataConverterPotionId.potions[62] = "minecraft:invisibility"; + DataConverterPotionId.potions[63] = null; + DataConverterPotionId.potions[64] = "minecraft:mundane"; + DataConverterPotionId.potions[65] = "minecraft:long_regeneration"; + DataConverterPotionId.potions[66] = "minecraft:long_swiftness"; + DataConverterPotionId.potions[67] = "minecraft:long_fire_resistance"; + DataConverterPotionId.potions[68] = "minecraft:long_poison"; + DataConverterPotionId.potions[69] = "minecraft:healing"; + DataConverterPotionId.potions[70] = "minecraft:long_night_vision"; + DataConverterPotionId.potions[71] = null; + DataConverterPotionId.potions[72] = "minecraft:long_weakness"; + DataConverterPotionId.potions[73] = "minecraft:long_strength"; + DataConverterPotionId.potions[74] = "minecraft:long_slowness"; + DataConverterPotionId.potions[75] = "minecraft:long_leaping"; + DataConverterPotionId.potions[76] = "minecraft:harming"; + DataConverterPotionId.potions[77] = "minecraft:long_water_breathing"; + DataConverterPotionId.potions[78] = "minecraft:long_invisibility"; + DataConverterPotionId.potions[79] = null; + DataConverterPotionId.potions[80] = "minecraft:awkward"; + DataConverterPotionId.potions[81] = "minecraft:long_regeneration"; + DataConverterPotionId.potions[82] = "minecraft:long_swiftness"; + DataConverterPotionId.potions[83] = "minecraft:long_fire_resistance"; + DataConverterPotionId.potions[84] = "minecraft:long_poison"; + DataConverterPotionId.potions[85] = "minecraft:healing"; + DataConverterPotionId.potions[86] = "minecraft:long_night_vision"; + DataConverterPotionId.potions[87] = null; + DataConverterPotionId.potions[88] = "minecraft:long_weakness"; + DataConverterPotionId.potions[89] = "minecraft:long_strength"; + DataConverterPotionId.potions[90] = "minecraft:long_slowness"; + DataConverterPotionId.potions[91] = "minecraft:long_leaping"; + DataConverterPotionId.potions[92] = "minecraft:harming"; + DataConverterPotionId.potions[93] = "minecraft:long_water_breathing"; + DataConverterPotionId.potions[94] = "minecraft:long_invisibility"; + DataConverterPotionId.potions[95] = null; + DataConverterPotionId.potions[96] = "minecraft:thick"; + DataConverterPotionId.potions[97] = "minecraft:regeneration"; + DataConverterPotionId.potions[98] = "minecraft:swiftness"; + DataConverterPotionId.potions[99] = "minecraft:long_fire_resistance"; + DataConverterPotionId.potions[100] = "minecraft:poison"; + DataConverterPotionId.potions[101] = "minecraft:strong_healing"; + DataConverterPotionId.potions[102] = "minecraft:long_night_vision"; + DataConverterPotionId.potions[103] = null; + DataConverterPotionId.potions[104] = "minecraft:long_weakness"; + DataConverterPotionId.potions[105] = "minecraft:strength"; + DataConverterPotionId.potions[106] = "minecraft:long_slowness"; + DataConverterPotionId.potions[107] = "minecraft:leaping"; + DataConverterPotionId.potions[108] = "minecraft:strong_harming"; + DataConverterPotionId.potions[109] = "minecraft:long_water_breathing"; + DataConverterPotionId.potions[110] = "minecraft:long_invisibility"; + DataConverterPotionId.potions[111] = null; + DataConverterPotionId.potions[112] = null; + DataConverterPotionId.potions[113] = "minecraft:regeneration"; + DataConverterPotionId.potions[114] = "minecraft:swiftness"; + DataConverterPotionId.potions[115] = "minecraft:long_fire_resistance"; + DataConverterPotionId.potions[116] = "minecraft:poison"; + DataConverterPotionId.potions[117] = "minecraft:strong_healing"; + DataConverterPotionId.potions[118] = "minecraft:long_night_vision"; + DataConverterPotionId.potions[119] = null; + DataConverterPotionId.potions[120] = "minecraft:long_weakness"; + DataConverterPotionId.potions[121] = "minecraft:strength"; + DataConverterPotionId.potions[122] = "minecraft:long_slowness"; + DataConverterPotionId.potions[123] = "minecraft:leaping"; + DataConverterPotionId.potions[124] = "minecraft:strong_harming"; + DataConverterPotionId.potions[125] = "minecraft:long_water_breathing"; + DataConverterPotionId.potions[126] = "minecraft:long_invisibility"; + DataConverterPotionId.potions[127] = null; + } + } + + private static class DataConverterSpawnEgg implements DataConverter { + + private static final String[] eggs = new String[256]; + + DataConverterSpawnEgg() { + } + + public int getDataVersion() { + return 105; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if ("minecraft:spawn_egg".equals(cmp.getString("id").orElse(null))) { + net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompoundOrEmpty("tag"); + net.minecraft.nbt.CompoundTag nbttagcompound2 = nbttagcompound1.getCompoundOrEmpty("EntityTag"); + short short0 = cmp.getShortOr("Damage", (short) 0); + + if (nbttagcompound2.getString("id").isEmpty()) { + String s = DataConverterSpawnEgg.eggs[short0 & 255]; + + if (s != null) { + nbttagcompound2.putString("id", s); + nbttagcompound1.put("EntityTag", nbttagcompound2); + cmp.put("tag", nbttagcompound1); + } + } + + if (short0 != 0) { + cmp.putShort("Damage", (short) 0); + } + } + + return cmp; + } + + static { + + DataConverterSpawnEgg.eggs[1] = "Item"; + DataConverterSpawnEgg.eggs[2] = "XPOrb"; + DataConverterSpawnEgg.eggs[7] = "ThrownEgg"; + DataConverterSpawnEgg.eggs[8] = "LeashKnot"; + DataConverterSpawnEgg.eggs[9] = "Painting"; + DataConverterSpawnEgg.eggs[10] = "Arrow"; + DataConverterSpawnEgg.eggs[11] = "Snowball"; + DataConverterSpawnEgg.eggs[12] = "Fireball"; + DataConverterSpawnEgg.eggs[13] = "SmallFireball"; + DataConverterSpawnEgg.eggs[14] = "ThrownEnderpearl"; + DataConverterSpawnEgg.eggs[15] = "EyeOfEnderSignal"; + DataConverterSpawnEgg.eggs[16] = "ThrownPotion"; + DataConverterSpawnEgg.eggs[17] = "ThrownExpBottle"; + DataConverterSpawnEgg.eggs[18] = "ItemFrame"; + DataConverterSpawnEgg.eggs[19] = "WitherSkull"; + DataConverterSpawnEgg.eggs[20] = "PrimedTnt"; + DataConverterSpawnEgg.eggs[21] = "FallingSand"; + DataConverterSpawnEgg.eggs[22] = "FireworksRocketEntity"; + DataConverterSpawnEgg.eggs[23] = "TippedArrow"; + DataConverterSpawnEgg.eggs[24] = "SpectralArrow"; + DataConverterSpawnEgg.eggs[25] = "ShulkerBullet"; + DataConverterSpawnEgg.eggs[26] = "DragonFireball"; + DataConverterSpawnEgg.eggs[30] = "ArmorStand"; + DataConverterSpawnEgg.eggs[41] = "Boat"; + DataConverterSpawnEgg.eggs[42] = "MinecartRideable"; + DataConverterSpawnEgg.eggs[43] = "MinecartChest"; + DataConverterSpawnEgg.eggs[44] = "MinecartFurnace"; + DataConverterSpawnEgg.eggs[45] = "MinecartTNT"; + DataConverterSpawnEgg.eggs[46] = "MinecartHopper"; + DataConverterSpawnEgg.eggs[47] = "MinecartSpawner"; + DataConverterSpawnEgg.eggs[40] = "MinecartCommandBlock"; + DataConverterSpawnEgg.eggs[48] = "Mob"; + DataConverterSpawnEgg.eggs[49] = "Monster"; + DataConverterSpawnEgg.eggs[50] = "Creeper"; + DataConverterSpawnEgg.eggs[51] = "Skeleton"; + DataConverterSpawnEgg.eggs[52] = "Spider"; + DataConverterSpawnEgg.eggs[53] = "Giant"; + DataConverterSpawnEgg.eggs[54] = "Zombie"; + DataConverterSpawnEgg.eggs[55] = "Slime"; + DataConverterSpawnEgg.eggs[56] = "Ghast"; + DataConverterSpawnEgg.eggs[57] = "PigZombie"; + DataConverterSpawnEgg.eggs[58] = "Enderman"; + DataConverterSpawnEgg.eggs[59] = "CaveSpider"; + DataConverterSpawnEgg.eggs[60] = "Silverfish"; + DataConverterSpawnEgg.eggs[61] = "Blaze"; + DataConverterSpawnEgg.eggs[62] = "LavaSlime"; + DataConverterSpawnEgg.eggs[63] = "EnderDragon"; + DataConverterSpawnEgg.eggs[64] = "WitherBoss"; + DataConverterSpawnEgg.eggs[65] = "Bat"; + DataConverterSpawnEgg.eggs[66] = "Witch"; + DataConverterSpawnEgg.eggs[67] = "Endermite"; + DataConverterSpawnEgg.eggs[68] = "Guardian"; + DataConverterSpawnEgg.eggs[69] = "Shulker"; + DataConverterSpawnEgg.eggs[90] = "Pig"; + DataConverterSpawnEgg.eggs[91] = "Sheep"; + DataConverterSpawnEgg.eggs[92] = "Cow"; + DataConverterSpawnEgg.eggs[93] = "Chicken"; + DataConverterSpawnEgg.eggs[94] = "Squid"; + DataConverterSpawnEgg.eggs[95] = "Wolf"; + DataConverterSpawnEgg.eggs[96] = "MushroomCow"; + DataConverterSpawnEgg.eggs[97] = "SnowMan"; + DataConverterSpawnEgg.eggs[98] = "Ozelot"; + DataConverterSpawnEgg.eggs[99] = "VillagerGolem"; + DataConverterSpawnEgg.eggs[100] = "EntityHorse"; + DataConverterSpawnEgg.eggs[101] = "Rabbit"; + DataConverterSpawnEgg.eggs[120] = "Villager"; + DataConverterSpawnEgg.eggs[200] = "EnderCrystal"; + } + } + + private static class DataConverterMinecart implements DataConverter { + + private static final List a = List.of("MinecartRideable", "MinecartChest", "MinecartFurnace", "MinecartTNT", "MinecartSpawner", "MinecartHopper", "MinecartCommandBlock"); + + DataConverterMinecart() { + } + + public int getDataVersion() { + return 106; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if ("Minecart".equals(cmp.getString("id").orElse(null))) { + String s = "MinecartRideable"; + int i = cmp.getIntOr("Type", 0); + + if (i > 0 && i < DataConverterMinecart.a.size()) { + s = DataConverterMinecart.a.get(i); + } + + cmp.putString("id", s); + cmp.remove("Type"); + } + + return cmp; + } + } + + private static class DataConverterMobSpawner implements DataConverter { + + DataConverterMobSpawner() { + } + + public int getDataVersion() { + return 107; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if ("MobSpawner".equals(cmp.getString("id").orElse(null))) { + cmp.getString("EntityId").ifPresent(s -> { + CompoundTag nbttagcompound1 = cmp.getCompoundOrEmpty("SpawnData"); + + nbttagcompound1.putString("id", s.isEmpty() ? "Pig" : s); + cmp.put("SpawnData", nbttagcompound1); + cmp.remove("EntityId"); + }); + + cmp.getList("SpawnPotentials").ifPresent(nbttaglist -> { + for (int i = 0; i < nbttaglist.size(); ++i) { + CompoundTag nbttagcompound2 = nbttaglist.getCompoundOrEmpty(i); + + if (nbttagcompound2.getString("Type").isPresent()) { + CompoundTag nbttagcompound3 = nbttagcompound2.getCompoundOrEmpty("Properties"); + + nbttagcompound3.putString("id", nbttagcompound2.getString("Type").get()); + nbttagcompound2.put("Entity", nbttagcompound3); + nbttagcompound2.remove("Type"); + nbttagcompound2.remove("Properties"); + } + } + }); + + } + + return cmp; + } + } + + private static class DataConverterUUID implements DataConverter { + + DataConverterUUID() { + } + + public int getDataVersion() { + return 108; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + cmp.getString("UUID").ifPresent(uuid -> { + cmp.putIntArray("UUID", UUIDUtil.uuidToIntArray(UUID.fromString(uuid))); + }); + + return cmp; + } + } + + private static class DataConverterHealth implements DataConverter { + + private static final Set a = Sets.newHashSet("ArmorStand", "Bat", "Blaze", "CaveSpider", "Chicken", "Cow", "Creeper", "EnderDragon", "Enderman", "Endermite", "EntityHorse", "Ghast", "Giant", "Guardian", "LavaSlime", "MushroomCow", "Ozelot", "Pig", "PigZombie", "Rabbit", "Sheep", "Shulker", "Silverfish", "Skeleton", "Slime", "SnowMan", "Spider", "Squid", "Villager", "VillagerGolem", "Witch", "WitherBoss", "Wolf", "Zombie"); + + DataConverterHealth() { + } + + public int getDataVersion() { + return 109; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if (DataConverterHealth.a.contains(cmp.getString("id").orElse(null))) { + float f; + + if (cmp.getFloat("HealF").isPresent()) { + f = cmp.getFloat("HealF").get(); + cmp.remove("HealF"); + } else { + if (cmp.getFloat("Health").isEmpty()) { + return cmp; + } + + f = cmp.getFloat("Health").get(); + } + + cmp.putFloat("Health", f); + } + + return cmp; + } + } + + private static class DataConverterSaddle implements DataConverter { + + DataConverterSaddle() { + } + + public int getDataVersion() { + return 110; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if ("EntityHorse".equals(cmp.getString("id").orElse(null)) && cmp.getCompound("SaddleItem").isEmpty() && cmp.getBoolean("Saddle").orElse(false)) { + net.minecraft.nbt.CompoundTag nbttagcompound1 = new net.minecraft.nbt.CompoundTag(); + + nbttagcompound1.putString("id", "minecraft:saddle"); + nbttagcompound1.putByte("Count", (byte) 1); + nbttagcompound1.putShort("Damage", (short) 0); + cmp.put("SaddleItem", nbttagcompound1); + cmp.remove("Saddle"); + } + + return cmp; + } + } + + private static class DataConverterHanging implements DataConverter { + + DataConverterHanging() { + } + + public int getDataVersion() { + return 111; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + String s = cmp.getString("id").orElse(null); + boolean flag = "Painting".equals(s); + boolean flag1 = "ItemFrame".equals(s); + + if ((flag || flag1) && cmp.getByte("Facing").isEmpty()) { + Direction enumdirection; + + if (cmp.getByte("Direction").isPresent()) { + enumdirection = Direction.from2DDataValue(cmp.getByte("Direction").get()); + cmp.putInt("TileX", cmp.getIntOr("TileX", 0) + enumdirection.getStepX()); + cmp.putInt("TileY", cmp.getIntOr("TileY", 0) + enumdirection.getStepY()); + cmp.putInt("TileZ", cmp.getIntOr("TileZ", 0) + enumdirection.getStepZ()); + cmp.remove("Direction"); + if (flag1 && cmp.getByte("ItemRotation").isPresent()) { + cmp.putByte("ItemRotation", (byte) (cmp.getByte("ItemRotation").get() * 2)); + } + } else { + enumdirection = Direction.from2DDataValue(cmp.getByte("Dir").get()); + cmp.remove("Dir"); + } + + cmp.putByte("Facing", (byte) enumdirection.get2DDataValue()); + } + + return cmp; + } + } + + private static class DataConverterDropChances implements DataConverter { + + DataConverterDropChances() { + } + + public int getDataVersion() { + return 113; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + cmp.getList("HandDropChances").ifPresent(nbttaglist -> { + if (nbttaglist.size() == 2 && nbttaglist.getFloatOr(0, 0.0F) == 0.0F && nbttaglist.getFloatOr(1, 0.0F) == 0.0F) { + cmp.remove("HandDropChances"); + } + }); + + cmp.getList("ArmorDropChances").ifPresent(nbttaglist -> { + if (nbttaglist.size() == 4 && nbttaglist.getFloatOr(0, 0.0F) == 0.0F && nbttaglist.getFloatOr(1, 0.0F) == 0.0F && nbttaglist.getFloatOr(2, 0.0F) == 0.0F && nbttaglist.getFloatOr(3, 0.0F) == 0.0F) { + cmp.remove("ArmorDropChances"); + } + }); + + return cmp; + } + } + + private static class DataConverterRiding implements DataConverter { + + DataConverterRiding() { + } + + public int getDataVersion() { + return 135; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + while (cmp.getCompound("Riding").isPresent()) { + net.minecraft.nbt.CompoundTag nbttagcompound1 = this.b(cmp); + + this.convert(cmp, nbttagcompound1); + cmp = nbttagcompound1; + } + + return cmp; + } + + protected void convert(net.minecraft.nbt.CompoundTag nbttagcompound, net.minecraft.nbt.CompoundTag nbttagcompound1) { + ListTag nbttaglist = new ListTag(); + + nbttaglist.add(nbttagcompound); + nbttagcompound1.put("Passengers", nbttaglist); + } + + protected net.minecraft.nbt.CompoundTag b(net.minecraft.nbt.CompoundTag nbttagcompound) { + net.minecraft.nbt.CompoundTag nbttagcompound1 = nbttagcompound.getCompoundOrEmpty("Riding"); + + nbttagcompound.remove("Riding"); + return nbttagcompound1; + } + } + + private static class DataConverterBook implements DataConverter { + + DataConverterBook() { + } + + public int getDataVersion() { + return 165; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if ("minecraft:written_book".equals(cmp.getString("id").orElse(null))) { + net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompoundOrEmpty("tag"); + + nbttagcompound1.getList("pages").ifPresent(nbttaglist -> { + for (int i = 0; i < nbttaglist.size(); ++i) { + String s = nbttaglist.getString(i).orElse(null); + Object object = null; + + if (!"null".equals(s) && !Strings.isNullOrEmpty(s)) { + if ((s.charAt(0) != 34 || s.charAt(s.length() - 1) != 34) && (s.charAt(0) != 123 || s.charAt(s.length() - 1) != 125)) { + object = Component.literal(s); + } else { + try { + object = GsonHelper.fromJson(DataConverterSignText.a, s, Component.class); + if (object == null) { + object = Component.literal(""); + } + } catch (JsonParseException jsonparseexception) { + ; + } + + if (object == null) { + try { + object = ComponentConverter.Serializer.fromJson(s, MinecraftServer.getServer().registryAccess()); + } catch (JsonParseException jsonparseexception1) { + ; + } + } + + if (object == null) { + try { + object = ComponentConverter.Serializer.fromJsonLenient(s, MinecraftServer.getServer().registryAccess()); + } catch (JsonParseException jsonparseexception2) { + ; + } + } + + if (object == null) { + object = Component.literal(s); + } + } + } else { + object = Component.literal(""); + } + + nbttaglist.set(i, StringTag.valueOf(ComponentConverter.Serializer.toJson((Component) object, MinecraftServer.getServer().registryAccess()))); + } + + nbttagcompound1.put("pages", nbttaglist); + }); + } + + return cmp; + } + } + + private static class DataConverterCookedFish implements DataConverter { + + private static final Identifier a = Identifier.parse("cooked_fished"); + + DataConverterCookedFish() { + } + + public int getDataVersion() { + return 502; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if (cmp.getString("id").isPresent() && DataConverterCookedFish.a.equals(Identifier.parse(cmp.getString("id").get()))) { + cmp.putString("id", "minecraft:cooked_fish"); + } + + return cmp; + } + } + + private static class DataConverterZombie implements DataConverter { + + private static final Random a = new Random(); + + DataConverterZombie() { + } + + public int getDataVersion() { + return 502; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if ("Zombie".equals(cmp.getString("id").orElse(null)) && cmp.getBoolean("IsVillager").orElse(false)) { + if (!cmp.contains("ZombieType")) { + int i = -1; + + i = cmp.getInt("VillagerProfession").flatMap(profession -> { + try { + return Optional.of(this.convert(profession)); + } catch (RuntimeException runtimeexception) { + return Optional.empty(); + } + }).orElse(i); + + if (i == -1) { + i = this.convert(DataConverterZombie.a.nextInt(6)); + } + + cmp.putInt("ZombieType", i); + } + + cmp.remove("IsVillager"); + } + + return cmp; + } + + private int convert(int i) { + return i >= 0 && i < 6 ? i : -1; + } + } + + private static class DataConverterVBO implements DataConverter { + + DataConverterVBO() { + } + + public int getDataVersion() { + return 505; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + cmp.putString("useVbo", "true"); + return cmp; + } + } + + private static class DataConverterGuardian implements DataConverter { + + DataConverterGuardian() { + } + + public int getDataVersion() { + return 700; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if ("Guardian".equals(cmp.getString("id").orElse(null))) { + if (cmp.getBoolean("Elder").orElse(false)) { + cmp.putString("id", "ElderGuardian"); + } + + cmp.remove("Elder"); + } + + return cmp; + } + } + + private static class DataConverterSkeleton implements DataConverter { + + DataConverterSkeleton() { + } + + public int getDataVersion() { + return 701; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + String s = cmp.getString("id").orElse(null); + + if ("Skeleton".equals(s)) { + int i = cmp.getIntOr("SkeletonType", 0); + + if (i == 1) { + cmp.putString("id", "WitherSkeleton"); + } else if (i == 2) { + cmp.putString("id", "Stray"); + } + + cmp.remove("SkeletonType"); + } + + return cmp; + } + } + + private static class DataConverterZombieType implements DataConverter { + + DataConverterZombieType() { + } + + public int getDataVersion() { + return 702; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if ("Zombie".equals(cmp.getString("id").orElse(null))) { + int i = cmp.getIntOr("ZombieType", 0); + + switch (i) { + case 1: + case 2: + case 3: + case 4: + case 5: + cmp.putString("id", "ZombieVillager"); + cmp.putInt("Profession", i - 1); + break; + case 6: + cmp.putString("id", "Husk"); + case 0: + default: + break; + } + + cmp.remove("ZombieType"); + } + + return cmp; + } + } + + private static class DataConverterHorse implements DataConverter { + + DataConverterHorse() { + } + + public int getDataVersion() { + return 703; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if ("EntityHorse".equals(cmp.getString("id").orElse(null))) { + int i = cmp.getIntOr("Type", 0); + + switch (i) { + case 1: + cmp.putString("id", "Donkey"); + break; + + case 2: + cmp.putString("id", "Mule"); + break; + + case 3: + cmp.putString("id", "ZombieHorse"); + break; + + case 4: + cmp.putString("id", "SkeletonHorse"); + break; + + case 0: + default: + cmp.putString("id", "Horse"); + break; + } + + cmp.remove("Type"); + } + + return cmp; + } + } + + private static class DataConverterTileEntity implements DataConverter { + + private static final Map a = Maps.newHashMap(); + + DataConverterTileEntity() { + } + + public int getDataVersion() { + return 704; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + String s = DataConverterTileEntity.a.get(cmp.getString("id").orElse(null)); + + if (s != null) { + cmp.putString("id", s); + } + + return cmp; + } + + static { + DataConverterTileEntity.a.put("Airportal", "minecraft:end_portal"); + DataConverterTileEntity.a.put("Banner", "minecraft:banner"); + DataConverterTileEntity.a.put("Beacon", "minecraft:beacon"); + DataConverterTileEntity.a.put("Cauldron", "minecraft:brewing_stand"); + DataConverterTileEntity.a.put("Chest", "minecraft:chest"); + DataConverterTileEntity.a.put("Comparator", "minecraft:comparator"); + DataConverterTileEntity.a.put("Control", "minecraft:command_block"); + DataConverterTileEntity.a.put("DLDetector", "minecraft:daylight_detector"); + DataConverterTileEntity.a.put("Dropper", "minecraft:dropper"); + DataConverterTileEntity.a.put("EnchantTable", "minecraft:enchanting_table"); + DataConverterTileEntity.a.put("EndGateway", "minecraft:end_gateway"); + DataConverterTileEntity.a.put("EnderChest", "minecraft:ender_chest"); + DataConverterTileEntity.a.put("FlowerPot", "minecraft:flower_pot"); + DataConverterTileEntity.a.put("Furnace", "minecraft:furnace"); + DataConverterTileEntity.a.put("Hopper", "minecraft:hopper"); + DataConverterTileEntity.a.put("MobSpawner", "minecraft:mob_spawner"); + DataConverterTileEntity.a.put("Music", "minecraft:noteblock"); + DataConverterTileEntity.a.put("Piston", "minecraft:piston"); + DataConverterTileEntity.a.put("RecordPlayer", "minecraft:jukebox"); + DataConverterTileEntity.a.put("Sign", "minecraft:sign"); + DataConverterTileEntity.a.put("Skull", "minecraft:skull"); + DataConverterTileEntity.a.put("Structure", "minecraft:structure_block"); + DataConverterTileEntity.a.put("Trap", "minecraft:dispenser"); + } + } + + private static class DataConverterEntity implements DataConverter { + + private static final Map a = Maps.newHashMap(); + + DataConverterEntity() { + } + + public int getDataVersion() { + return 704; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + String s = DataConverterEntity.a.get(cmp.getString("id").orElse(null)); + + if (s != null) { + cmp.putString("id", s); + } + + return cmp; + } + + static { + DataConverterEntity.a.put("AreaEffectCloud", "minecraft:area_effect_cloud"); + DataConverterEntity.a.put("ArmorStand", "minecraft:armor_stand"); + DataConverterEntity.a.put("Arrow", "minecraft:arrow"); + DataConverterEntity.a.put("Bat", "minecraft:bat"); + DataConverterEntity.a.put("Blaze", "minecraft:blaze"); + DataConverterEntity.a.put("Boat", "minecraft:boat"); + DataConverterEntity.a.put("CaveSpider", "minecraft:cave_spider"); + DataConverterEntity.a.put("Chicken", "minecraft:chicken"); + DataConverterEntity.a.put("Cow", "minecraft:cow"); + DataConverterEntity.a.put("Creeper", "minecraft:creeper"); + DataConverterEntity.a.put("Donkey", "minecraft:donkey"); + DataConverterEntity.a.put("DragonFireball", "minecraft:dragon_fireball"); + DataConverterEntity.a.put("ElderGuardian", "minecraft:elder_guardian"); + DataConverterEntity.a.put("EnderCrystal", "minecraft:ender_crystal"); + DataConverterEntity.a.put("EnderDragon", "minecraft:ender_dragon"); + DataConverterEntity.a.put("Enderman", "minecraft:enderman"); + DataConverterEntity.a.put("Endermite", "minecraft:endermite"); + DataConverterEntity.a.put("EyeOfEnderSignal", "minecraft:eye_of_ender_signal"); + DataConverterEntity.a.put("FallingSand", "minecraft:falling_block"); + DataConverterEntity.a.put("Fireball", "minecraft:fireball"); + DataConverterEntity.a.put("FireworksRocketEntity", "minecraft:fireworks_rocket"); + DataConverterEntity.a.put("Ghast", "minecraft:ghast"); + DataConverterEntity.a.put("Giant", "minecraft:giant"); + DataConverterEntity.a.put("Guardian", "minecraft:guardian"); + DataConverterEntity.a.put("Horse", "minecraft:horse"); + DataConverterEntity.a.put("Husk", "minecraft:husk"); + DataConverterEntity.a.put("Item", "minecraft:item"); + DataConverterEntity.a.put("ItemFrame", "minecraft:item_frame"); + DataConverterEntity.a.put("LavaSlime", "minecraft:magma_cube"); + DataConverterEntity.a.put("LeashKnot", "minecraft:leash_knot"); + DataConverterEntity.a.put("MinecartChest", "minecraft:chest_minecart"); + DataConverterEntity.a.put("MinecartCommandBlock", "minecraft:commandblock_minecart"); + DataConverterEntity.a.put("MinecartFurnace", "minecraft:furnace_minecart"); + DataConverterEntity.a.put("MinecartHopper", "minecraft:hopper_minecart"); + DataConverterEntity.a.put("MinecartRideable", "minecraft:minecart"); + DataConverterEntity.a.put("MinecartSpawner", "minecraft:spawner_minecart"); + DataConverterEntity.a.put("MinecartTNT", "minecraft:tnt_minecart"); + DataConverterEntity.a.put("Mule", "minecraft:mule"); + DataConverterEntity.a.put("MushroomCow", "minecraft:mooshroom"); + DataConverterEntity.a.put("Ozelot", "minecraft:ocelot"); + DataConverterEntity.a.put("Painting", "minecraft:painting"); + DataConverterEntity.a.put("Pig", "minecraft:pig"); + DataConverterEntity.a.put("PigZombie", "minecraft:zombie_pigman"); + DataConverterEntity.a.put("PolarBear", "minecraft:polar_bear"); + DataConverterEntity.a.put("PrimedTnt", "minecraft:tnt"); + DataConverterEntity.a.put("Rabbit", "minecraft:rabbit"); + DataConverterEntity.a.put("Sheep", "minecraft:sheep"); + DataConverterEntity.a.put("Shulker", "minecraft:shulker"); + DataConverterEntity.a.put("ShulkerBullet", "minecraft:shulker_bullet"); + DataConverterEntity.a.put("Silverfish", "minecraft:silverfish"); + DataConverterEntity.a.put("Skeleton", "minecraft:skeleton"); + DataConverterEntity.a.put("SkeletonHorse", "minecraft:skeleton_horse"); + DataConverterEntity.a.put("Slime", "minecraft:slime"); + DataConverterEntity.a.put("SmallFireball", "minecraft:small_fireball"); + DataConverterEntity.a.put("SnowMan", "minecraft:snowman"); + DataConverterEntity.a.put("Snowball", "minecraft:snowball"); + DataConverterEntity.a.put("SpectralArrow", "minecraft:spectral_arrow"); + DataConverterEntity.a.put("Spider", "minecraft:spider"); + DataConverterEntity.a.put("Squid", "minecraft:squid"); + DataConverterEntity.a.put("Stray", "minecraft:stray"); + DataConverterEntity.a.put("ThrownEgg", "minecraft:egg"); + DataConverterEntity.a.put("ThrownEnderpearl", "minecraft:ender_pearl"); + DataConverterEntity.a.put("ThrownExpBottle", "minecraft:xp_bottle"); + DataConverterEntity.a.put("ThrownPotion", "minecraft:potion"); + DataConverterEntity.a.put("Villager", "minecraft:villager"); + DataConverterEntity.a.put("VillagerGolem", "minecraft:villager_golem"); + DataConverterEntity.a.put("Witch", "minecraft:witch"); + DataConverterEntity.a.put("WitherBoss", "minecraft:wither"); + DataConverterEntity.a.put("WitherSkeleton", "minecraft:wither_skeleton"); + DataConverterEntity.a.put("WitherSkull", "minecraft:wither_skull"); + DataConverterEntity.a.put("Wolf", "minecraft:wolf"); + DataConverterEntity.a.put("XPOrb", "minecraft:xp_orb"); + DataConverterEntity.a.put("Zombie", "minecraft:zombie"); + DataConverterEntity.a.put("ZombieHorse", "minecraft:zombie_horse"); + DataConverterEntity.a.put("ZombieVillager", "minecraft:zombie_villager"); + } + } + + private static class DataConverterPotionWater implements DataConverter { + + DataConverterPotionWater() { + } + + public int getDataVersion() { + return 806; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + String s = cmp.getString("id").orElse(null); + + if ("minecraft:potion".equals(s) || "minecraft:splash_potion".equals(s) || "minecraft:lingering_potion".equals(s) || "minecraft:tipped_arrow".equals(s)) { + net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompoundOrEmpty("tag"); + + if (nbttagcompound1.getString("Potion").isEmpty()) { + nbttagcompound1.putString("Potion", "minecraft:water"); + } + + if (cmp.getCompound("tag").isEmpty()) { + cmp.put("tag", nbttagcompound1); + } + } + + return cmp; + } + } + + private static class DataConverterShulker implements DataConverter { + + DataConverterShulker() { + } + + public int getDataVersion() { + return 808; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if ("minecraft:shulker".equals(cmp.getString("id").orElse(null)) && cmp.getByte("Color").isEmpty()) { + cmp.putByte("Color", (byte) 10); + } + + return cmp; + } + } + + private static class DataConverterShulkerBoxItem implements DataConverter { + + public static final String[] a = new String[] { "minecraft:white_shulker_box", "minecraft:orange_shulker_box", "minecraft:magenta_shulker_box", "minecraft:light_blue_shulker_box", "minecraft:yellow_shulker_box", "minecraft:lime_shulker_box", "minecraft:pink_shulker_box", "minecraft:gray_shulker_box", "minecraft:silver_shulker_box", "minecraft:cyan_shulker_box", "minecraft:purple_shulker_box", "minecraft:blue_shulker_box", "minecraft:brown_shulker_box", "minecraft:green_shulker_box", "minecraft:red_shulker_box", "minecraft:black_shulker_box" }; + + DataConverterShulkerBoxItem() { + } + + public int getDataVersion() { + return 813; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if ("minecraft:shulker_box".equals(cmp.getString("id").orElse(null)) ) { + cmp.getCompound("tag").ifPresent(nbttagcompound1 -> { + nbttagcompound1.getCompound("BlockEntityTag").ifPresent(nbttagcompound2 -> { + if (nbttagcompound2.getList("Items").map(ListTag::isEmpty).orElse(true)) { + nbttagcompound2.remove("Items"); + } + + int i = nbttagcompound2.getIntOr("Color", 0); + + nbttagcompound2.remove("Color"); + if (nbttagcompound2.isEmpty()) { + nbttagcompound1.remove("BlockEntityTag"); + } + + if (nbttagcompound1.isEmpty()) { + cmp.remove("tag"); + } + + cmp.putString("id", DataConverterShulkerBoxItem.a[i % 16]); + }); + }); + } + + return cmp; + } + } + + private static class DataConverterShulkerBoxBlock implements DataConverter { + + DataConverterShulkerBoxBlock() { + } + + public int getDataVersion() { + return 813; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if ("minecraft:shulker".equals(cmp.getString("id").orElse(null))) { + cmp.remove("Color"); + } + + return cmp; + } + } + + private static class DataConverterLang implements DataConverter { + + DataConverterLang() { + } + + public int getDataVersion() { + return 816; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + cmp.getString("lang").ifPresent(lang -> { + cmp.putString("lang", lang.toLowerCase(Locale.ROOT)); + }); + + return cmp; + } + } + + private static class DataConverterTotem implements DataConverter { + + DataConverterTotem() { + } + + public int getDataVersion() { + return 820; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if ("minecraft:totem".equals(cmp.getString("id").orElse(null))) { + cmp.putString("id", "minecraft:totem_of_undying"); + } + + return cmp; + } + } + + private static class DataConverterBedBlock implements DataConverter { + + private static final Logger a = LogManager.getLogger(PaperweightDataConverters.class); + + DataConverterBedBlock() { + } + + public int getDataVersion() { + return 1125; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + boolean flag = true; + + try { + net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompoundOrEmpty("Level"); + int i = nbttagcompound1.getIntOr("xPos", 0); + int j = nbttagcompound1.getIntOr("zPos", 0); + ListTag nbttaglist = nbttagcompound1.getListOrEmpty("TileEntities"); + ListTag nbttaglist1 = nbttagcompound1.getListOrEmpty("Sections"); + + for (int k = 0; k < nbttaglist1.size(); ++k) { + net.minecraft.nbt.CompoundTag nbttagcompound2 = nbttaglist1.getCompoundOrEmpty(k); + byte b0 = nbttagcompound2.getByteOr("Y", (byte) 0); + byte[] abyte = nbttagcompound2.getByteArray("Blocks").orElse(new byte[]{}); + + for (int l = 0; l < abyte.length; ++l) { + if (416 == (abyte[l] & 255) << 4) { + int i1 = l & 15; + int j1 = l >> 8 & 15; + int k1 = l >> 4 & 15; + net.minecraft.nbt.CompoundTag nbttagcompound3 = new net.minecraft.nbt.CompoundTag(); + + nbttagcompound3.putString("id", "bed"); + nbttagcompound3.putInt("x", i1 + (i << 4)); + nbttagcompound3.putInt("y", j1 + (b0 << 4)); + nbttagcompound3.putInt("z", k1 + (j << 4)); + nbttaglist.add(nbttagcompound3); + } + } + } + } catch (Exception exception) { + DataConverterBedBlock.a.warn("Unable to datafix Bed blocks, level format may be missing tags."); + } + + return cmp; + } + } + + private static class DataConverterBedItem implements DataConverter { + + DataConverterBedItem() { + } + + public int getDataVersion() { + return 1125; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if ("minecraft:bed".equals(cmp.getString("id").orElse(null)) && cmp.getShortOr("Damage", (short) 0) == 0) { + cmp.putShort("Damage", (short) DyeColor.RED.getId()); + } + + return cmp; + } + } + + private static class DataConverterSignText implements DataConverter { + + public static final Gson a = new GsonBuilder().registerTypeAdapter(Component.class, new JsonDeserializer() { + MutableComponent a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException { + if (jsonelement.isJsonPrimitive()) { + return Component.literal(jsonelement.getAsString()); + } else if (jsonelement.isJsonArray()) { + JsonArray jsonarray = jsonelement.getAsJsonArray(); + MutableComponent iTextComponent = null; + Iterator iterator = jsonarray.iterator(); + + while (iterator.hasNext()) { + JsonElement jsonelement1 = iterator.next(); + MutableComponent iTextComponent1 = this.a(jsonelement1, jsonelement1.getClass(), jsondeserializationcontext); + + if (iTextComponent == null) { + iTextComponent = iTextComponent1; + } else { + iTextComponent.append(iTextComponent1); + } + } + + return iTextComponent; + } else { + throw new JsonParseException("Don't know how to turn " + jsonelement + " into a Component"); + } + } + + public Object deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException { + return this.a(jsonelement, type, jsondeserializationcontext); + } + }).create(); + + DataConverterSignText() { + } + + public int getDataVersion() { + return 101; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if ("Sign".equals(cmp.getString("id").orElse(null))) { + this.convert(cmp, "Text1"); + this.convert(cmp, "Text2"); + this.convert(cmp, "Text3"); + this.convert(cmp, "Text4"); + } + + return cmp; + } + + private void convert(net.minecraft.nbt.CompoundTag nbttagcompound, String s) { + String s1 = nbttagcompound.getString(s).orElse(null); + Object object = null; + + if (!"null".equals(s1) && !Strings.isNullOrEmpty(s1)) { + if ((s1.charAt(0) != 34 || s1.charAt(s1.length() - 1) != 34) && (s1.charAt(0) != 123 || s1.charAt(s1.length() - 1) != 125)) { + object = Component.literal(s1); + } else { + try { + object = GsonHelper.fromJson(DataConverterSignText.a, s1, Component.class); + if (object == null) { + object = Component.literal(""); + } + } catch (JsonParseException jsonparseexception) { + ; + } + + if (object == null) { + try { + object = ComponentConverter.Serializer.fromJson(s1, MinecraftServer.getServer().registryAccess()); + } catch (JsonParseException jsonparseexception1) { + ; + } + } + + if (object == null) { + try { + object = ComponentConverter.Serializer.fromJsonLenient(s1, MinecraftServer.getServer().registryAccess()); + } catch (JsonParseException jsonparseexception2) { + ; + } + } + + if (object == null) { + object = Component.literal(s1); + } + } + } else { + object = Component.literal(""); + } + + nbttagcompound.putString(s, ComponentConverter.Serializer.toJson((Component) object, MinecraftServer.getServer().registryAccess())); + } + } + + private static class DataInspectorPlayerVehicle implements DataInspector { + @Override + public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { + cmp.getCompound("RootVehicle").ifPresent(nbttagcompound1 -> { + if (nbttagcompound1.getCompound("Entity").isPresent()) { + convertCompound(LegacyType.ENTITY, nbttagcompound1, "Entity", sourceVer, targetVer); + } + }); + + return cmp; + } + } + + private static class DataInspectorLevelPlayer implements DataInspector { + @Override + public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { + if (cmp.getCompound("Player").isPresent()) { + convertCompound(LegacyType.PLAYER, cmp, "Player", sourceVer, targetVer); + } + + return cmp; + } + } + + private static class DataInspectorStructure implements DataInspector { + @Override + public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { + cmp.getList("entities").ifPresent(nbttaglist -> { + for (int j = 0; j < nbttaglist.size(); ++j) { + net.minecraft.nbt.CompoundTag nbttagcompound1 = (net.minecraft.nbt.CompoundTag) nbttaglist.get(j); + if (nbttagcompound1.getCompound("nbt").isPresent()) { + convertCompound(LegacyType.ENTITY, nbttagcompound1, "nbt", sourceVer, targetVer); + } + } + }); + + cmp.getList("blocks").ifPresent(nbttaglist -> { + for (int j = 0; j < nbttaglist.size(); ++j) { + net.minecraft.nbt.CompoundTag nbttagcompound1 = (net.minecraft.nbt.CompoundTag) nbttaglist.get(j); + if (nbttagcompound1.getCompound("nbt").isPresent()) { + convertCompound(LegacyType.BLOCK_ENTITY, nbttagcompound1, "nbt", sourceVer, targetVer); + } + } + }); + + return cmp; + } + } + + private static class DataInspectorChunks implements DataInspector { + @Override + public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { + cmp.getCompound("Level").ifPresent(nbttagcompound1 -> { + nbttagcompound1.getList("Entities").ifPresent(nbttaglist -> { + for (int j = 0; j < nbttaglist.size(); ++j) { + nbttaglist.set(j, convert(LegacyType.ENTITY, (net.minecraft.nbt.CompoundTag) nbttaglist.get(j), sourceVer, targetVer)); + } + }); + + nbttagcompound1.getList("TileEntities").ifPresent(nbttaglist -> { + for (int j = 0; j < nbttaglist.size(); ++j) { + nbttaglist.set(j, convert(LegacyType.BLOCK_ENTITY, (net.minecraft.nbt.CompoundTag) nbttaglist.get(j), sourceVer, targetVer)); + } + }); + }); + + return cmp; + } + } + + private static class DataInspectorEntityPassengers implements DataInspector { + @Override + public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { + cmp.getList("Passengers").ifPresent(nbttaglist -> { + for (int j = 0; j < nbttaglist.size(); ++j) { + nbttaglist.set(j, convert(LegacyType.ENTITY, nbttaglist.getCompoundOrEmpty(j), sourceVer, targetVer)); + } + }); + + return cmp; + } + } + + private static class DataInspectorPlayer implements DataInspector { + @Override + public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { + convertItems(cmp, "Inventory", sourceVer, targetVer); + convertItems(cmp, "EnderItems", sourceVer, targetVer); + if (cmp.getCompound("ShoulderEntityLeft").isPresent()) { + convertCompound(LegacyType.ENTITY, cmp, "ShoulderEntityLeft", sourceVer, targetVer); + } + + if (cmp.getCompound("ShoulderEntityRight").isPresent()) { + convertCompound(LegacyType.ENTITY, cmp, "ShoulderEntityRight", sourceVer, targetVer); + } + + return cmp; + } + } + + private static class DataInspectorVillagers implements DataInspector { + Identifier entityVillager = getKey("EntityVillager"); + + @Override + public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { + if (cmp.getString("id").isPresent() && entityVillager.equals(Identifier.parse(cmp.getString("id").get()))) { + cmp.getCompound("Offers").flatMap(nbttagcompound1 -> nbttagcompound1.getList("Recipes")).ifPresent(nbttaglist -> { + for (int j = 0; j < nbttaglist.size(); ++j) { + CompoundTag nbttagcompound2 = nbttaglist.getCompoundOrEmpty(j); + + convertItem(nbttagcompound2, "buy", sourceVer, targetVer); + convertItem(nbttagcompound2, "buyB", sourceVer, targetVer); + convertItem(nbttagcompound2, "sell", sourceVer, targetVer); + nbttaglist.set(j, nbttagcompound2); + } + }); + } + + return cmp; + } + } + + private static class DataInspectorMobSpawnerMinecart implements DataInspector { + Identifier entityMinecartMobSpawner = getKey("EntityMinecartMobSpawner"); + Identifier tileEntityMobSpawner = getKey("TileEntityMobSpawner"); + + @Override + public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { + String s = cmp.getString("id").get(); + if (entityMinecartMobSpawner.equals(Identifier.parse(s))) { + cmp.putString("id", tileEntityMobSpawner.toString()); + convert(LegacyType.BLOCK_ENTITY, cmp, sourceVer, targetVer); + cmp.putString("id", s); + } + + return cmp; + } + } + + private static class DataInspectorMobSpawnerMobs implements DataInspector { + Identifier tileEntityMobSpawner = getKey("TileEntityMobSpawner"); + + @Override + public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { + if (cmp.getString("id").isPresent() && tileEntityMobSpawner.equals(Identifier.parse(cmp.getString("id").get()))) { + cmp.getList("SpawnPotentials").ifPresent(nbttaglist -> { + for (int j = 0; j < nbttaglist.size(); ++j) { + net.minecraft.nbt.CompoundTag nbttagcompound1 = nbttaglist.getCompoundOrEmpty(j); + + convertCompound(LegacyType.ENTITY, nbttagcompound1, "Entity", sourceVer, targetVer); + } + }); + + convertCompound(LegacyType.ENTITY, cmp, "SpawnData", sourceVer, targetVer); + } + + return cmp; + } + } + + private static class DataInspectorCommandBlock implements DataInspector { + Identifier tileEntityCommand = getKey("TileEntityCommand"); + + @Override + public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { + if (cmp.getString("id").isPresent() && tileEntityCommand.equals(Identifier.parse(cmp.getString("id").get()))) { + cmp.putString("id", "Control"); + convert(LegacyType.BLOCK_ENTITY, cmp, sourceVer, targetVer); + cmp.putString("id", "MinecartCommandBlock"); + } + + return cmp; + } + } +} diff --git a/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightFakePlayer.java b/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightFakePlayer.java new file mode 100644 index 0000000000..d71e535ef7 --- /dev/null +++ b/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightFakePlayer.java @@ -0,0 +1,81 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.bukkit.adapter.impl.v26_3; + +import com.mojang.authlib.GameProfile; +import net.minecraft.server.level.ClientInformation; +import net.minecraft.server.level.ParticleStatus; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.stats.Stat; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.HumanoidArm; +import net.minecraft.world.entity.player.ChatVisiblity; +import net.minecraft.world.phys.Vec3; + +import java.nio.charset.StandardCharsets; +import java.util.OptionalInt; +import java.util.UUID; + +class PaperweightFakePlayer extends ServerPlayer { + private static final GameProfile FAKE_WORLDEDIT_PROFILE = new GameProfile( + UUID.nameUUIDFromBytes("worldedit".getBytes(StandardCharsets.UTF_8)), + "[WorldEdit]" + ); + private static final Vec3 ORIGIN = new Vec3(0.0D, 0.0D, 0.0D); + private static final ClientInformation FAKE_CLIENT_INFO = new ClientInformation( + "en_US", 16, ChatVisiblity.FULL, true, 0, HumanoidArm.LEFT, false, false, ParticleStatus.MINIMAL + ); + + PaperweightFakePlayer(ServerLevel world) { + super(world.getServer(), world, FAKE_WORLDEDIT_PROFILE, FAKE_CLIENT_INFO); + } + + @Override + public Vec3 position() { + return ORIGIN; + } + + @Override + public void tick() { + } + + @Override + public void die(DamageSource damagesource) { + } + + @Override + public OptionalInt openMenu(MenuProvider factory) { + return OptionalInt.empty(); + } + + @Override + public void updateOptions(ClientInformation clientOptions) { + } + + @Override + public void awardStat(Stat stat, int amount) { + } + + @Override + public void awardStat(Stat stat) { + } +} diff --git a/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightLoggingProblemReporter.java b/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightLoggingProblemReporter.java new file mode 100644 index 0000000000..d7a54ff980 --- /dev/null +++ b/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightLoggingProblemReporter.java @@ -0,0 +1,61 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.bukkit.adapter.impl.v26_3; + +import net.minecraft.util.ProblemReporter; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.function.Function; +import java.util.function.Supplier; + +final class PaperweightLoggingProblemReporter implements ProblemReporter, AutoCloseable { + private static final Logger LOGGER = LogManager.getLogger(); + + static T with(Supplier contextSupplier, Function consumer) { + try (var problemReporter = new PaperweightLoggingProblemReporter(contextSupplier)) { + return consumer.apply(problemReporter); + } + } + + PaperweightLoggingProblemReporter(Supplier contextSupplier) { + this.contextSupplier = contextSupplier; + } + + private final Collector delegate = new Collector(); + private final Supplier contextSupplier; + + @Override + public ProblemReporter forChild(PathElement child) { + return delegate.forChild(child); + } + + @Override + public void report(Problem problem) { + delegate.report(problem); + } + + @Override + public void close() { + if (!delegate.isEmpty()) { + LOGGER.warn("Problems were reported during {}: {}", contextSupplier.get(), delegate.getTreeReport()); + } + } +} diff --git a/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightServerLevelDelegateProxy.java b/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightServerLevelDelegateProxy.java new file mode 100644 index 0000000000..40d54e12fd --- /dev/null +++ b/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightServerLevelDelegateProxy.java @@ -0,0 +1,313 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.bukkit.adapter.impl.v26_3; + +import com.google.common.collect.ImmutableTable; +import com.google.common.collect.Table; +import com.google.errorprone.annotations.Keep; +import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.MaxChangedBlocksException; +import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.entity.BaseEntity; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.util.concurrency.LazyReference; +import com.sk89q.worldedit.world.entity.EntityTypes; +import net.minecraft.core.BlockPos; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.Identifier; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.WorldGenLevel; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.EntityBlock; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.storage.TagValueOutput; +import net.minecraft.world.phys.Vec3; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.enginehub.linbus.tree.LinCompoundTag; +import org.jetbrains.annotations.Nullable; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Predicate; + +public class PaperweightServerLevelDelegateProxy implements InvocationHandler, AutoCloseable { + + private static BlockVector3 adapt(BlockPos blockPos) { + return BlockVector3.at(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + } + + private final EditSession editSession; + private final ServerLevel serverLevel; + private final PaperweightAdapter adapter; + private final Map createdBlockEntities = new HashMap<>(); + + private PaperweightServerLevelDelegateProxy(EditSession editSession, ServerLevel serverLevel, PaperweightAdapter adapter) { + this.editSession = editSession; + this.serverLevel = serverLevel; + this.adapter = adapter; + } + + public record LevelAndProxy(WorldGenLevel level, PaperweightServerLevelDelegateProxy proxy) implements AutoCloseable { + @Override + public void close() throws MaxChangedBlocksException { + proxy.close(); + } + } + + public static LevelAndProxy newInstance(EditSession editSession, ServerLevel serverLevel, PaperweightAdapter adapter) { + PaperweightServerLevelDelegateProxy proxy = new PaperweightServerLevelDelegateProxy(editSession, serverLevel, adapter); + return new LevelAndProxy( + (WorldGenLevel) Proxy.newProxyInstance( + serverLevel.getClass().getClassLoader(), + serverLevel.getClass().getInterfaces(), + proxy + ), + proxy + ); + } + + @Keep + @Nullable + private BlockEntity getBlockEntity(BlockPos blockPos) { + // This doesn't synthesize or load from world. I think editing existing block entities without setting the block + // (in the context of features) should not be supported in the first place. + BlockVector3 pos = adapt(blockPos); + return createdBlockEntities.get(pos); + } + + private BlockState getBlockState(BlockPos blockPos) { + return adapter.adapt(this.editSession.getBlockWithBuffer(adapt(blockPos))); + } + + @Keep + private boolean isStateAtPosition(BlockPos blockPos, Predicate predicate) { + return predicate.test(getBlockState(blockPos)); + } + + private boolean setBlock(BlockPos blockPos, BlockState blockState) { + try { + handleBlockEntity(blockPos, blockState); + return editSession.setBlock(adapt(blockPos), adapter.adapt(blockState)); + } catch (MaxChangedBlocksException e) { + throw new RuntimeException(e); + } + } + + // For BlockEntity#setBlockState, not sure why it's deprecated + @SuppressWarnings("deprecation") + private void handleBlockEntity(BlockPos blockPos, BlockState blockState) { + BlockVector3 pos = adapt(blockPos); + if (blockState.hasBlockEntity()) { + if (!(blockState.getBlock() instanceof EntityBlock entityBlock)) { + // This will probably never happen, as Mojang's own code assumes that + // hasBlockEntity implies instanceof EntityBlock, but just to be safe... + throw new AssertionError("BlockState has block entity but block is not an EntityBlock: " + blockState); + } + BlockEntity newEntity = entityBlock.newBlockEntity(blockPos, blockState); + if (newEntity != null) { + newEntity.setBlockState(blockState); + createdBlockEntities.put(pos, newEntity); + // Should we load existing NBT here? This is for feature / structure gen so it seems unnecessary. + // But it would align with the behavior of the real setBlock method. + return; + } + } + // Discard any block entity that was previously created if new block is set without block entity + createdBlockEntities.remove(pos); + } + + @Keep + private boolean removeBlock(BlockPos blockPos) { + return setBlock(blockPos, Blocks.AIR.defaultBlockState()); + } + + @Keep + private boolean addEntity(Entity entity) { + Vec3 pos = entity.getPosition(0.0f); + Location location = new Location(BukkitAdapter.adapt(serverLevel.getWorld()), pos.x(), pos.y(), pos.z()); + + Identifier id = serverLevel.registryAccess().lookupOrThrow(Registries.ENTITY_TYPE).getKey(entity.getType()); + + net.minecraft.nbt.CompoundTag tag = PaperweightLoggingProblemReporter.with( + () -> "serializing entity " + entity.getStringUUID(), + reporter -> { + var tagValueOutput = TagValueOutput.createWithContext(reporter, serverLevel.registryAccess()); + entity.saveWithoutId(tagValueOutput); + return tagValueOutput.buildResult(); + } + ); + + BaseEntity baseEntity = new BaseEntity(EntityTypes.get(id.toString()), LazyReference.from(() -> (LinCompoundTag) adapter.toNative(tag))); + + return editSession.createEntity(location, baseEntity) != null; + } + + @Override + public void close() throws MaxChangedBlocksException { + for (Map.Entry entry : createdBlockEntities.entrySet()) { + BlockVector3 blockPos = entry.getKey(); + BlockEntity blockEntity = entry.getValue(); + + net.minecraft.nbt.CompoundTag tag = PaperweightLoggingProblemReporter.with( + () -> "saving block entity at " + blockPos, + reporter -> { + var tagValueOutput = TagValueOutput.createWithContext(reporter, serverLevel.registryAccess()); + blockEntity.saveWithId(tagValueOutput); + return tagValueOutput.buildResult(); + } + ); + editSession.setBlock( + blockPos, + adapter.adapt(blockEntity.getBlockState()) + .toBaseBlock(LazyReference.from(() -> (LinCompoundTag) adapter.toNative(tag))) + ); + } + } + + private static void addMethodHandleToTable( + ImmutableTable.Builder table, + String methodName, + MethodHandle methodHandle + ) { + // We want to call these with Object[] args, not plain args + // We skip the first argument, which is our receiver + MethodHandle spreader = methodHandle.asSpreader( + 1, Object[].class, methodHandle.type().parameterCount() - 1 + ); + // We drop the first argument, which is our receiver + // We also drop the return type, which is not important + table.put(methodName, methodHandle.type().dropParameterTypes(0, 1).changeReturnType(void.class), spreader); + } + + private static final Table METHOD_MAP; + + static { + var lookup = MethodHandles.lookup(); + var builder = ImmutableTable.builder(); + try { + addMethodHandleToTable( + builder, + StaticRefraction.GET_BLOCK_STATE, + lookup.unreflect(PaperweightServerLevelDelegateProxy.class.getDeclaredMethod("getBlockState", BlockPos.class)) + ); + + addMethodHandleToTable( + builder, + StaticRefraction.IS_STATE_AT_POSITION, + lookup.unreflect(PaperweightServerLevelDelegateProxy.class.getDeclaredMethod("isStateAtPosition", BlockPos.class, Predicate.class)) + ); + + MethodHandle addEntity = lookup.unreflect(PaperweightServerLevelDelegateProxy.class.getDeclaredMethod("addEntity", Entity.class)); + addMethodHandleToTable( + builder, + StaticRefraction.ADD_FRESH_ENTITY_WITH_PASSENGERS_ENTITY, + addEntity + ); + addMethodHandleToTable( + builder, + StaticRefraction.ADD_FRESH_ENTITY_WITH_PASSENGERS_ENTITY_SPAWN_REASON, + // 0 - this, 1 - entity, 2 - reason + MethodHandles.dropArguments(addEntity, 2, CreatureSpawnEvent.SpawnReason.class) + ); + addMethodHandleToTable( + builder, + StaticRefraction.ADD_FRESH_ENTITY, + addEntity + ); + addMethodHandleToTable( + builder, + StaticRefraction.ADD_FRESH_ENTITY_SPAWN_REASON, + // 0 - this, 1 - entity, 2 - reason + MethodHandles.dropArguments(addEntity, 2, CreatureSpawnEvent.SpawnReason.class) + ); + + addMethodHandleToTable( + builder, + StaticRefraction.GET_BLOCK_ENTITY, + lookup.unreflect(PaperweightServerLevelDelegateProxy.class.getDeclaredMethod("getBlockEntity", BlockPos.class)) + ); + + MethodHandle setBlock = lookup.unreflect(PaperweightServerLevelDelegateProxy.class.getDeclaredMethod("setBlock", BlockPos.class, BlockState.class)); + addMethodHandleToTable( + builder, + StaticRefraction.SET_BLOCK, + // 0 - this, 1 - blockPos, 2 - blockState, 3 - flags + MethodHandles.dropArguments(setBlock, 3, int.class) + ); + addMethodHandleToTable( + builder, + StaticRefraction.SET_BLOCK_MAX_UPDATE, + // 0 - this, 1 - blockPos, 2 - blockState, 3 - flags, 4 - maxUpdateDepth + MethodHandles.dropArguments(setBlock, 3, int.class, int.class) + ); + + MethodHandle removeBlock = lookup.unreflect(PaperweightServerLevelDelegateProxy.class.getDeclaredMethod("removeBlock", BlockPos.class)); + addMethodHandleToTable( + builder, + StaticRefraction.REMOVE_BLOCK, + // 0 - this, 1 - blockPos, 2 - move + MethodHandles.dropArguments(removeBlock, 2, boolean.class) + ); + addMethodHandleToTable( + builder, + StaticRefraction.DESTROY_BLOCK, + // 0 - this, 1 - blockPos, 2 - drop + MethodHandles.dropArguments(removeBlock, 2, boolean.class) + ); + addMethodHandleToTable( + builder, + StaticRefraction.DESTROY_BLOCK_BREAKING_ENTITY, + // 0 - this, 1 - blockPos, 2 - drop, 3 - breakingEntity + MethodHandles.dropArguments(removeBlock, 2, boolean.class, Entity.class) + ); + addMethodHandleToTable( + builder, + StaticRefraction.DESTROY_BLOCK_BREAKING_ENTITY_MAX_UPDATE, + // 0 - this, 1 - blockPos, 2 - drop, 3 - breakingEntity, 4 - maxUpdateDepth + MethodHandles.dropArguments(removeBlock, 2, boolean.class, Entity.class, int.class) + ); + } catch (IllegalAccessException | NoSuchMethodException e) { + throw new RuntimeException("Failed to bind to own methods", e); + } + METHOD_MAP = builder.build(); + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + MethodHandle delegate = METHOD_MAP.get( + // ignore return type, we only need the parameter types + method.getName(), MethodType.methodType(void.class, method.getParameterTypes()) + ); + if (delegate != null) { + return delegate.invoke(this, args); + } + return method.invoke(this.serverLevel, args); + } + +} diff --git a/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightWorldNativeAccess.java b/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightWorldNativeAccess.java new file mode 100644 index 0000000000..26a00784ec --- /dev/null +++ b/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/PaperweightWorldNativeAccess.java @@ -0,0 +1,187 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.bukkit.adapter.impl.v26_3; + +import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.internal.block.BlockStateIdAccess; +import com.sk89q.worldedit.internal.wna.WorldNativeAccess; +import com.sk89q.worldedit.util.SideEffect; +import com.sk89q.worldedit.util.SideEffectSet; +import com.sk89q.worldedit.world.block.BlockState; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.Tag; +import net.minecraft.server.level.FullChunkStatus; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.redstone.ExperimentalRedstoneUtils; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.enginehub.linbus.tree.LinCompoundTag; + +import java.lang.ref.WeakReference; +import java.util.Objects; +import javax.annotation.Nullable; + +public class PaperweightWorldNativeAccess implements WorldNativeAccess { + private static final int UPDATE = 1; + private static final int NOTIFY = 2; + + private final PaperweightAdapter adapter; + private final WeakReference world; + private SideEffectSet sideEffectSet; + + public PaperweightWorldNativeAccess(PaperweightAdapter adapter, WeakReference world) { + this.adapter = adapter; + this.world = world; + } + + private ServerLevel getWorld() { + return Objects.requireNonNull(world.get(), "The reference to the world was lost"); + } + + @Override + public void setCurrentSideEffectSet(SideEffectSet sideEffectSet) { + this.sideEffectSet = sideEffectSet; + } + + @Override + public LevelChunk getChunk(int x, int z) { + return getWorld().getChunk(x, z); + } + + @Override + public net.minecraft.world.level.block.state.BlockState toNative(BlockState state) { + int stateId = BlockStateIdAccess.getBlockStateId(state); + return BlockStateIdAccess.isValidInternalId(stateId) + ? Block.stateById(stateId) + : ((CraftBlockData) BukkitAdapter.adapt(state)).getState(); + } + + @Override + public net.minecraft.world.level.block.state.BlockState getBlockState(LevelChunk chunk, BlockPos position) { + return chunk.getBlockState(position); + } + + @Nullable + @Override + public net.minecraft.world.level.block.state.BlockState setBlockState(LevelChunk chunk, BlockPos position, net.minecraft.world.level.block.state.BlockState state) { + return chunk.setBlockState(position, state, this.sideEffectSet.shouldApply(SideEffect.UPDATE) ? 0 : 512); + } + + @Override + public net.minecraft.world.level.block.state.BlockState getValidBlockForPosition(net.minecraft.world.level.block.state.BlockState block, BlockPos position) { + return Block.updateFromNeighbourShapes(block, getWorld(), position); + } + + @Override + public BlockPos getPosition(int x, int y, int z) { + return new BlockPos(x, y, z); + } + + @Override + public void updateLightingForBlock(BlockPos position) { + getWorld().getChunkSource().getLightEngine().checkBlock(position); + } + + @Override + public boolean updateTileEntity(BlockPos position, LinCompoundTag tag) { + // We will assume that the tile entity was created for us + BlockEntity tileEntity = getWorld().getBlockEntity(position); + if (tileEntity == null) { + return false; + } + Tag nativeTag = adapter.fromNative(tag); + PaperweightAdapter.readTagIntoTileEntity((net.minecraft.nbt.CompoundTag) nativeTag, tileEntity); + return true; + } + + @Override + public void notifyBlockUpdate(LevelChunk chunk, BlockPos position, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) { + if (chunk.getSections()[getWorld().getSectionIndex(position.getY())] != null) { + getWorld().sendBlockUpdated(position, oldState, newState, UPDATE | NOTIFY); + } + } + + @Override + public boolean isChunkTicking(LevelChunk chunk) { + return chunk.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING); + } + + @Override + public void markBlockChanged(LevelChunk chunk, BlockPos position) { + if (chunk.getSections()[getWorld().getSectionIndex(position.getY())] != null) { + getWorld().getChunkSource().blockChanged(position); + } + } + + @Override + public void notifyNeighbors(BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) { + ServerLevel world = getWorld(); + if (sideEffectSet.shouldApply(SideEffect.EVENTS)) { + world.updateNeighborsAt(pos, oldState.getBlock()); + } else { + // When we don't want events, manually run the physics without them. + Block block = oldState.getBlock(); + fireNeighborChanged(world, block, pos.west()); + fireNeighborChanged(world, block, pos.east()); + fireNeighborChanged(world, block, pos.below()); + fireNeighborChanged(world, block, pos.above()); + fireNeighborChanged(world, block, pos.north()); + fireNeighborChanged(world, block, pos.south()); + } + if (newState.hasAnalogOutputSignal()) { + world.updateNeighbourForOutputSignal(pos, newState.getBlock()); + } + } + + @Override + public void updateBlock(BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) { + ServerLevel world = getWorld(); + newState.onPlace(world, pos, oldState, false); + } + + private void fireNeighborChanged(ServerLevel world, Block block, BlockPos neighborPos) { + world.getBlockState(neighborPos).handleNeighborChanged(world, neighborPos, block, ExperimentalRedstoneUtils.initialOrientation(world, null, null), false); + } + + @Override + public void updateNeighbors(BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState, int recursionLimit) { + ServerLevel world = getWorld(); + oldState.updateIndirectNeighbourShapes(world, pos, NOTIFY, recursionLimit); + if (sideEffectSet.shouldApply(SideEffect.EVENTS)) { + CraftWorld craftWorld = world.getWorld(); + BlockPhysicsEvent event = new BlockPhysicsEvent(craftWorld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()), newState.asBlockData()); + world.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } + } + newState.updateNeighbourShapes(world, pos, NOTIFY, recursionLimit); + newState.updateIndirectNeighbourShapes(world, pos, NOTIFY, recursionLimit); + } + + @Override + public void onBlockStateChange(BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) { + getWorld().updatePOIOnBlockStateChange(pos, oldState, newState); + } +} diff --git a/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/StaticRefraction.java b/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/StaticRefraction.java new file mode 100644 index 0000000000..9f201f205a --- /dev/null +++ b/worldedit-bukkit/adapters/adapter-26.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v26_3/StaticRefraction.java @@ -0,0 +1,94 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.bukkit.adapter.impl.v26_3; + +import com.sk89q.worldedit.bukkit.adapter.Refraction; + +/** + * Dedicated class to map all names that we use. + * + *

+ * Overloads are split into multiple fields, as they CAN have different obfuscated names. + *

+ */ +public final class StaticRefraction { + public static final String GET_CHUNK_FUTURE_MAIN_THREAD = Refraction.pickName( + "getChunkFutureMainThread", "c" + ); + public static final String MAIN_THREAD_PROCESSOR = Refraction.pickName( + "mainThreadProcessor", "g" + ); + public static final String NEXT_TICK_TIME = Refraction.pickName("nextTickTimeNanos", "am"); + public static final String GET_BLOCK_STATE = Refraction.pickName("getBlockState", "a_"); + public static final String IS_STATE_AT_POSITION = Refraction.pickName("isStateAtPosition", "a"); + /** + * {@code addFreshEntityWithPassengers(Entity entity)}. + */ + public static final String ADD_FRESH_ENTITY_WITH_PASSENGERS_ENTITY = Refraction.pickName( + "addFreshEntityWithPassengers", "a_" + ); + /** + * {@code addFreshEntityWithPassengers(Entity entity, CreatureSpawnEvent.SpawnReason reason)}. + */ + public static final String ADD_FRESH_ENTITY_WITH_PASSENGERS_ENTITY_SPAWN_REASON = + Refraction.pickName("addFreshEntityWithPassengers", "a_"); + /** + * {@code addFreshEntity(Entity entity)}. + */ + public static final String ADD_FRESH_ENTITY = Refraction.pickName("addFreshEntity", "b"); + /** + * {@code addFreshEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason)}. + */ + public static final String ADD_FRESH_ENTITY_SPAWN_REASON = Refraction.pickName( + "addFreshEntity", "b" + ); + /** + * {@code getBlockEntity(BlockPos blockPos)}. + */ + public static final String GET_BLOCK_ENTITY = Refraction.pickName("getBlockEntity", "c_"); + /** + * {@code setBlock(BlockPos blockPos, BlockState blockState, int flags)}. + */ + public static final String SET_BLOCK = Refraction.pickName("setBlock", "a"); + /** + * {@code setBlock(BlockPos blockPos, BlockState blockState, int flags, int maxUpdateDepth)}. + */ + public static final String SET_BLOCK_MAX_UPDATE = Refraction.pickName("setBlock", "a"); + public static final String REMOVE_BLOCK = Refraction.pickName("removeBlock", "a"); + /** + * {@code destroyBlock(BlockPos blockPos, boolean drop)}. + */ + public static final String DESTROY_BLOCK = Refraction.pickName("destroyBlock", "b"); + /** + * {@code destroyBlock(BlockPos blockPos, boolean drop, Entity breakingEntity)}. + */ + public static final String DESTROY_BLOCK_BREAKING_ENTITY = Refraction.pickName( + "destroyBlock", "a" + ); + /** + * {@code destroyBlock(BlockPos blockPos, boolean drop, Entity breakingEntity, int maxUpdateDepth)}. + */ + public static final String DESTROY_BLOCK_BREAKING_ENTITY_MAX_UPDATE = Refraction.pickName( + "destroyBlock", "a" + ); + + private StaticRefraction() { + } +} diff --git a/worldedit-core-mc/src/main/java/com/sk89q/worldedit/coremc/internal/CoreMcBlockMaterial.java b/worldedit-core-mc/src/main/java/com/sk89q/worldedit/coremc/internal/CoreMcBlockMaterial.java index 16c5f731b5..a8d6a0b89d 100644 --- a/worldedit-core-mc/src/main/java/com/sk89q/worldedit/coremc/internal/CoreMcBlockMaterial.java +++ b/worldedit-core-mc/src/main/java/com/sk89q/worldedit/coremc/internal/CoreMcBlockMaterial.java @@ -94,12 +94,12 @@ public int getLightValue() { @Override public boolean isFragileWhenPushed() { - return block.getPistonPushReaction() == PushReaction.DESTROY; + return block.getPistonPushReaction() == PushReaction.POPPED; } @Override public boolean isUnpushable() { - return block.getPistonPushReaction() == PushReaction.BLOCK; + return block.getPistonPushReaction() == PushReaction.IMMOVEABLE; } @Override @@ -110,7 +110,7 @@ public boolean isTicksRandomly() { @Override @SuppressWarnings("deprecation") public boolean isMovementBlocker() { - return block.blocksMotion(); + return block.isSolid(); } @Override diff --git a/worldedit-core-mc/src/main/java/com/sk89q/worldedit/coremc/internal/CoreMcMod.java b/worldedit-core-mc/src/main/java/com/sk89q/worldedit/coremc/internal/CoreMcMod.java index e86bd55427..a24405b9f2 100644 --- a/worldedit-core-mc/src/main/java/com/sk89q/worldedit/coremc/internal/CoreMcMod.java +++ b/worldedit-core-mc/src/main/java/com/sk89q/worldedit/coremc/internal/CoreMcMod.java @@ -175,7 +175,7 @@ protected void setupRegistries(MinecraftServer server) { } }); // Features - for (Identifier name : server.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).keySet()) { + for (Identifier name : server.registryAccess().lookupOrThrow(Registries.FEATURE).keySet()) { String key = name.toString(); if (ConfiguredFeatureType.REGISTRY.get(key) == null) { ConfiguredFeatureType.REGISTRY.register(key, new ConfiguredFeatureType(key)); @@ -192,7 +192,7 @@ protected void setupRegistries(MinecraftServer server) { Registry placedFeatureRegistry = server.registryAccess().lookupOrThrow(Registries.PLACED_FEATURE); for (Identifier name : placedFeatureRegistry.keySet()) { // Do some hackery to make sure this is a tree - var underlyingFeature = placedFeatureRegistry.get(name).get().value().feature().value().feature(); + var underlyingFeature = placedFeatureRegistry.get(name).get().value().feature().value(); if (underlyingFeature instanceof TreeFeature || underlyingFeature instanceof FallenTreeFeature || underlyingFeature instanceof CoralTreeFeature) { String key = name.toString(); if (TreeType.REGISTRY.get(key) == null) { diff --git a/worldedit-core-mc/src/main/java/com/sk89q/worldedit/coremc/internal/CoreMcWorld.java b/worldedit-core-mc/src/main/java/com/sk89q/worldedit/coremc/internal/CoreMcWorld.java index 7a926786ed..c382c04070 100644 --- a/worldedit-core-mc/src/main/java/com/sk89q/worldedit/coremc/internal/CoreMcWorld.java +++ b/worldedit-core-mc/src/main/java/com/sk89q/worldedit/coremc/internal/CoreMcWorld.java @@ -91,6 +91,7 @@ import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.biome.Climate; import net.minecraft.world.level.block.LiquidBlock; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.chunk.ChunkAccess; @@ -98,7 +99,8 @@ import net.minecraft.world.level.chunk.PalettedContainer; import net.minecraft.world.level.chunk.status.ChunkStatus; import net.minecraft.world.level.dimension.LevelStem; -import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.levelgen.densityfunction.SamplerContext; +import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.placement.PlacedFeature; import net.minecraft.world.level.levelgen.structure.BoundingBox; import net.minecraft.world.level.levelgen.structure.Structure; @@ -490,7 +492,7 @@ public boolean generateTree(TreeType type, EditSession editSession, BlockVector3 @Override public boolean generateFeature(ConfiguredFeatureType type, EditSession editSession, BlockVector3 position) { ServerLevel world = getWorld(); - ConfiguredFeature feature = world.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).getValue(Identifier.tryParse(type.id())); + Feature feature = world.registryAccess().lookupOrThrow(Registries.FEATURE).getValue(Identifier.tryParse(type.id())); ServerChunkCache chunkManager = world.getChunkSource(); try (CoreMcServerLevelDelegateProxy.LevelAndProxy proxyLevel = CoreMcServerLevelDelegateProxy.newInstance(platform, editSession, world)) { return feature != null && feature.place( @@ -512,13 +514,16 @@ public boolean generateStructure(StructureType type, EditSession editSession, Bl } ServerChunkCache chunkManager = world.getChunkSource(); + Climate.Sampler climateSampler = chunkManager.randomState().createClimateSampler( + SamplerContext.builder().enableCaches().build() + ); try (CoreMcServerLevelDelegateProxy.LevelAndProxy proxyLevel = CoreMcServerLevelDelegateProxy.newInstance(platform, editSession, world)) { ChunkPos chunkPos = ChunkPos.containing(new BlockPos(position.x(), position.y(), position.z())); StructureStart structureStart = structure.generate( structureRegistry.wrapAsHolder(structure), world.dimension(), world.registryAccess(), - chunkManager.getGenerator(), chunkManager.getGenerator().getBiomeSource(), chunkManager.randomState(), - world.getStructureManager(), world.getSeed(), chunkPos, 0, proxyLevel.level(), - biome -> true + chunkManager.getGenerator(), chunkManager.getGenerator().getBiomeSource(), climateSampler, chunkManager.randomState(), + world.getStructureTemplateManager(), world.getSeed(), chunkPos, 0, proxyLevel.level(), + _ -> true ); if (!structureStart.isValid()) { diff --git a/worldedit-core-mc/src/main/java/com/sk89q/worldedit/coremc/mixin/MixinServerGamePacketListenerImpl.java b/worldedit-core-mc/src/main/java/com/sk89q/worldedit/coremc/mixin/MixinServerGamePacketListenerImpl.java index 3cfb931060..d32ff4e6a5 100644 --- a/worldedit-core-mc/src/main/java/com/sk89q/worldedit/coremc/mixin/MixinServerGamePacketListenerImpl.java +++ b/worldedit-core-mc/src/main/java/com/sk89q/worldedit/coremc/mixin/MixinServerGamePacketListenerImpl.java @@ -27,9 +27,10 @@ import com.sk89q.worldedit.util.lifecycle.Lifecycled; import com.sk89q.worldedit.util.lifecycle.SimpleLifecycled; import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket; -import net.minecraft.network.protocol.game.ServerboundSwingPacket; +import net.minecraft.network.protocol.game.ServerboundPunchPacket; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.network.ServerGamePacketListenerImpl; +import net.minecraft.world.InteractionHand; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -59,16 +60,16 @@ public class MixinServerGamePacketListenerImpl { @Keep @Inject( - method = "handleAnimate", - at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayer;swing(Lnet/minecraft/world/InteractionHand;)V") + method = "handlePunch", + at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayer;swing(Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/item/component/SwingAnimation;Z)Z") ) - private void onAnimate(ServerboundSwingPacket packet, @SuppressWarnings("UnusedVariable") CallbackInfo ci) { + private void handlePunch(@SuppressWarnings("UnusedVariable") ServerboundPunchPacket packet, @SuppressWarnings("UnusedVariable") CallbackInfo ci) { if (!((AccessorServerPlayerGameMode) this.player.gameMode).isDestroyingBlock()) { if (this.ignoreSwingPackets > 0) { this.ignoreSwingPackets--; } else { WORLD_EDITING_PLATFORM.value().ifPresent(platform -> - platform.getMod().onLeftClickAir(this.player, packet.getHand()) + platform.getMod().onLeftClickAir(this.player, InteractionHand.MAIN_HAND) ); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index a9f367791f..b34878e117 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -775,7 +775,7 @@ public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) for (int y = maxY; y >= minY; --y) { BlockVector3 pt = BlockVector3.at(x, y, z); if (filter == null - ? getBlock(pt).getBlockType().getMaterial().isMovementBlocker() + ? getBlock(pt).getBlockType().getMaterial().isSolid() : filter.test(pt)) { return y; } @@ -2238,7 +2238,7 @@ public int green(BlockVector3 position, double radius, int height, boolean onlyN break; } else if (block.getBlockType() == BlockTypes.WATER || block.getBlockType() == BlockTypes.LAVA) { break; - } else if (block.getBlockType().getMaterial().isMovementBlocker()) { + } else if (block.getBlockType().getMaterial().isSolid()) { break; } } @@ -2946,7 +2946,7 @@ private void recurseHollow(Region region, BlockVector3 origin, Set while (!queue.isEmpty()) { final BlockVector3 current = queue.removeFirst(); final BlockState block = getBlock(current); - if (block.getBlockType().getMaterial().isMovementBlocker()) { + if (block.getBlockType().getMaterial().isSolid()) { continue; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java index ef4ba0ae02..37dd275de8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java @@ -121,7 +121,7 @@ public void findFreePosition(Location searchPos) { byte free = 0; while (y <= maxY) { - if (!world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { + if (!world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isSolid()) { ++free; } else { free = 0; @@ -158,7 +158,7 @@ public void setOnGround(Location searchPos) { while (y >= minY) { final BlockVector3 pos = BlockVector3.at(x, y, z); final BlockState id = world.getBlock(pos); - if (id.getBlockType().getMaterial().isMovementBlocker() + if (id.getBlockType().getMaterial().isSolid() && trySetPosition(Vector3.at(x + 0.5, y + 1, z + 0.5))) { return; } @@ -178,7 +178,7 @@ public void findFreePosition() { */ private boolean isPlayerHarmingBlock(BlockVector3 location) { BlockType type = getWorld().getBlock(location).getBlockType(); - return type.getMaterial().isMovementBlocker() || type == BlockTypes.LAVA + return type.getMaterial().isSolid() || type == BlockTypes.LAVA || BlockCategories.FIRE.contains(type); } @@ -196,7 +196,7 @@ private boolean isLocationGoodForStanding(BlockVector3 location) { return false; } return getWorld().getBlock(location.add(0, -1, 0)).getBlockType().getMaterial() - .isMovementBlocker(); + .isSolid(); } @Override @@ -267,7 +267,7 @@ public boolean ascendToCeiling(int clearance, boolean alwaysGlass) { while (y <= maxY) { // Found a ceiling! - if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { + if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isSolid()) { int platformY = Math.max(initialY, y - 3 - clearance); if (platformY < initialY) { // if ==, they already have the given clearance, if <, clearance is too large return false; @@ -300,7 +300,7 @@ public boolean ascendUpwards(int distance, boolean alwaysGlass) { final int maxY = Math.min(world.getMaxY() + 1, initialY + distance); while (y <= world.getMaxY() + 2) { - if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) { + if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isSolid()) { break; // Hit something } else if (y > maxY + 1) { break; @@ -320,7 +320,7 @@ public void floatAt(int x, int y, int z, boolean alwaysGlass) { if (alwaysGlass || !isAllowedToFly()) { BlockVector3 spot = BlockVector3.at(x, y - 1, z); final World world = getWorld(); - if (!world.getBlock(spot).getBlockType().getMaterial().isMovementBlocker()) { + if (!world.getBlock(spot).getBlockType().getMaterial().isSolid()) { try (EditSession session = WorldEdit.getInstance().newEditSession(this)) { session.setBlock(spot, BlockTypes.GLASS.getDefaultState()); } catch (MaxChangedBlocksException ignored) { @@ -431,7 +431,7 @@ public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException { private boolean canPassThroughBlock(Location curBlock) { BlockVector3 blockPos = curBlock.toVector().toBlockPoint(); BlockState block = curBlock.getExtent().getBlock(blockPos); - return !block.getBlockType().getMaterial().isMovementBlocker(); + return !block.getBlockType().getMaterial().isSolid(); } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/SnowSimulator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/SnowSimulator.java index ce8618ff5f..d67be3b9e7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/SnowSimulator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/SnowSimulator.java @@ -77,8 +77,8 @@ public boolean isGround(BlockVector3 position) { return true; } - // Stop searching when we hit a movement blocker - return block.getBlockType().getMaterial().isMovementBlocker(); + // Stop searching when we hit a solid block + return block.getBlockType().getMaterial().isSolid(); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SolidBlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SolidBlockMask.java index 24ec5e7809..34a02c662c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SolidBlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SolidBlockMask.java @@ -33,7 +33,7 @@ public SolidBlockMask(Extent extent) { public boolean test(BlockVector3 vector) { Extent extent = getExtent(); BlockState block = extent.getBlock(vector); - return block.getBlockType().getMaterial().isMovementBlocker(); + return block.getBlockType().getMaterial().isSolid(); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/Constants.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/Constants.java index 482c84cdeb..7fbde6d638 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/Constants.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/Constants.java @@ -154,4 +154,9 @@ private Constants() { * The DataVersion for Minecraft 26.2. */ public static final int DATA_VERSION_MC_26_2 = 4903; + + /** + * The DataVersion for Minecraft 26.3. + */ + public static final int DATA_VERSION_MC_26_3 = 5023; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeCategories.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeCategories.java index 52398348b2..bcc89da027 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeCategories.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeCategories.java @@ -29,6 +29,24 @@ public final class BiomeCategories { public static final BiomeCategory ALLOWS_SURFACE_SLIME_SPAWNS = get("minecraft:allows_surface_slime_spawns"); public static final BiomeCategory ALLOWS_TROPICAL_FISH_SPAWNS_AT_ANY_HEIGHT = get("minecraft:allows_tropical_fish_spawns_at_any_height"); @Deprecated public static final BiomeCategory HAS_CLOSER_WATER_FOG = get("minecraft:has_closer_water_fog"); + public static final BiomeCategory HAS_STRUCTURE_ABANDONED_CAMP_BAMBOO_JUNGLE = get("minecraft:has_structure/abandoned_camp_bamboo_jungle"); + public static final BiomeCategory HAS_STRUCTURE_ABANDONED_CAMP_BIRCH_FOREST = get("minecraft:has_structure/abandoned_camp_birch_forest"); + public static final BiomeCategory HAS_STRUCTURE_ABANDONED_CAMP_CHERRY_GROVE = get("minecraft:has_structure/abandoned_camp_cherry_grove"); + public static final BiomeCategory HAS_STRUCTURE_ABANDONED_CAMP_DAPPLED_FOREST = get("minecraft:has_structure/abandoned_camp_dappled_forest"); + public static final BiomeCategory HAS_STRUCTURE_ABANDONED_CAMP_FLOWER_FOREST = get("minecraft:has_structure/abandoned_camp_flower_forest"); + public static final BiomeCategory HAS_STRUCTURE_ABANDONED_CAMP_FOREST = get("minecraft:has_structure/abandoned_camp_forest"); + public static final BiomeCategory HAS_STRUCTURE_ABANDONED_CAMP_MEADOW = get("minecraft:has_structure/abandoned_camp_meadow"); + public static final BiomeCategory HAS_STRUCTURE_ABANDONED_CAMP_OLD_GROWTH_BIRCH_FOREST = get("minecraft:has_structure/abandoned_camp_old_growth_birch_forest"); + public static final BiomeCategory HAS_STRUCTURE_ABANDONED_CAMP_OLD_GROWTH_PINE_TAIGA = get("minecraft:has_structure/abandoned_camp_old_growth_pine_taiga"); + public static final BiomeCategory HAS_STRUCTURE_ABANDONED_CAMP_OLD_GROWTH_SPRUCE_TAIGA = get("minecraft:has_structure/abandoned_camp_old_growth_spruce_taiga"); + public static final BiomeCategory HAS_STRUCTURE_ABANDONED_CAMP_PALE_GARDEN = get("minecraft:has_structure/abandoned_camp_pale_garden"); + public static final BiomeCategory HAS_STRUCTURE_ABANDONED_CAMP_SAVANNA = get("minecraft:has_structure/abandoned_camp_savanna"); + public static final BiomeCategory HAS_STRUCTURE_ABANDONED_CAMP_SNOWY_TAIGA = get("minecraft:has_structure/abandoned_camp_snowy_taiga"); + public static final BiomeCategory HAS_STRUCTURE_ABANDONED_CAMP_SPARSE_JUNGLE = get("minecraft:has_structure/abandoned_camp_sparse_jungle"); + public static final BiomeCategory HAS_STRUCTURE_ABANDONED_CAMP_SWAMP = get("minecraft:has_structure/abandoned_camp_swamp"); + public static final BiomeCategory HAS_STRUCTURE_ABANDONED_CAMP_TAIGA = get("minecraft:has_structure/abandoned_camp_taiga"); + public static final BiomeCategory HAS_STRUCTURE_ABANDONED_CAMP_WINDSWEPT_FOREST = get("minecraft:has_structure/abandoned_camp_windswept_forest"); + public static final BiomeCategory HAS_STRUCTURE_ABANDONED_CAMP_WOODED_BADLANDS = get("minecraft:has_structure/abandoned_camp_wooded_badlands"); public static final BiomeCategory HAS_STRUCTURE_ANCIENT_CITY = get("minecraft:has_structure/ancient_city"); public static final BiomeCategory HAS_STRUCTURE_BASTION_REMNANT = get("minecraft:has_structure/bastion_remnant"); public static final BiomeCategory HAS_STRUCTURE_BURIED_TREASURE = get("minecraft:has_structure/buried_treasure"); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeTypes.java index 64d28b6d2f..fbe2f87f4d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeTypes.java @@ -39,6 +39,7 @@ public final class BiomeTypes { @Nullable public static final BiomeType CHERRY_GROVE = get("minecraft:cherry_grove"); @Nullable public static final BiomeType COLD_OCEAN = get("minecraft:cold_ocean"); @Nullable public static final BiomeType CRIMSON_FOREST = get("minecraft:crimson_forest"); + @Nullable public static final BiomeType DAPPLED_FOREST = get("minecraft:dappled_forest"); @Nullable public static final BiomeType DARK_FOREST = get("minecraft:dark_forest"); @Deprecated @Nullable public static final BiomeType DARK_FOREST_HILLS = get("minecraft:dark_forest_hills"); @Nullable public static final BiomeType DEEP_COLD_OCEAN = get("minecraft:deep_cold_ocean"); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java index 924dbda72b..a745815867 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java @@ -54,6 +54,13 @@ public final class BlockCategories { public static final BlockCategory BENEATH_TREE_PODZOL_REPLACEABLE = get("minecraft:beneath_tree_podzol_replaceable"); @Deprecated public static final BlockCategory BIG_DRIPLEAF_PLACEABLE = get("minecraft:big_dripleaf_placeable"); public static final BlockCategory BIRCH_LOGS = get("minecraft:birch_logs"); + public static final BlockCategory BLOCKS_DOLPHIN_JUMP = get("minecraft:blocks_dolphin_jump"); + public static final BlockCategory BLOCKS_FLUID_FLOW = get("minecraft:blocks_fluid_flow"); + public static final BlockCategory BLOCKS_LAVA_FIRE_SPREAD = get("minecraft:blocks_lava_fire_spread"); + public static final BlockCategory BLOCKS_MOTION = get("minecraft:blocks_motion"); + public static final BlockCategory BLOCKS_MOTION_IN_HEIGHTMAP = get("minecraft:blocks_motion_in_heightmap"); + public static final BlockCategory BLOCKS_MOTION_IN_HEIGHTMAP_NO_LEAVES = get("minecraft:blocks_motion_in_heightmap_no_leaves"); + public static final BlockCategory BLOCKS_MOTION_NO_LEAVES = get("minecraft:blocks_motion_no_leaves"); public static final BlockCategory BLOCKS_WIND_CHARGE_EXPLOSIONS = get("minecraft:blocks_wind_charge_explosions"); public static final BlockCategory BUTTONS = get("minecraft:buttons"); public static final BlockCategory CAMEL_SAND_STEP_SOUND_BLOCKS = get("minecraft:camel_sand_step_sound_blocks"); @@ -62,14 +69,19 @@ public final class BlockCategories { public static final BlockCategory CAN_GLIDE_THROUGH = get("minecraft:can_glide_through"); public static final BlockCategory CANDLE_CAKES = get("minecraft:candle_cakes"); public static final BlockCategory CANDLES = get("minecraft:candles"); + public static final BlockCategory CANNOT_PLACE_BASALT_PILLAR_ON = get("minecraft:cannot_place_basalt_pillar_on"); public static final BlockCategory CANNOT_REPLACE_BELOW_TREE_TRUNK = get("minecraft:cannot_replace_below_tree_trunk"); public static final BlockCategory CANNOT_SUPPORT_KELP = get("minecraft:cannot_support_kelp"); public static final BlockCategory CANNOT_SUPPORT_SEAGRASS = get("minecraft:cannot_support_seagrass"); public static final BlockCategory CANNOT_SUPPORT_SNOW_LAYER = get("minecraft:cannot_support_snow_layer"); @Deprecated public static final BlockCategory CARPETS = get("minecraft:carpets"); + public static final BlockCategory CAT_DOES_NOT_TELEPORT_TO = get("minecraft:cat_does_not_teleport_to"); + public static final BlockCategory CATS_CAN_LIE_ON = get("minecraft:cats_can_lie_on"); + public static final BlockCategory CATS_CAN_SIT_ON = get("minecraft:cats_can_sit_on"); public static final BlockCategory CAULDRONS = get("minecraft:cauldrons"); public static final BlockCategory CAUSES_CONTINUOUS_GEYSER_ERUPTIONS = get("minecraft:causes_continuous_geyser_eruptions"); public static final BlockCategory CAUSES_PERIODIC_GEYSER_ERUPTIONS = get("minecraft:causes_periodic_geyser_eruptions"); + public static final BlockCategory CAUSES_SUFFOCATION = get("minecraft:causes_suffocation"); public static final BlockCategory CAVE_VINES = get("minecraft:cave_vines"); public static final BlockCategory CEILING_HANGING_SIGNS = get("minecraft:ceiling_hanging_signs"); public static final BlockCategory CHAINS = get("minecraft:chains"); @@ -81,7 +93,11 @@ public final class BlockCategories { public static final BlockCategory CONCRETE = get("minecraft:concrete"); @Deprecated public static final BlockCategory CONCRETE_POWDER = get("minecraft:concrete_powder"); public static final BlockCategory CONCRETE_POWDERS = get("minecraft:concrete_powders"); - public static final BlockCategory CONVERTABLE_TO_MUD = get("minecraft:convertable_to_mud"); + public static final BlockCategory CONCRETE_SLABS = get("minecraft:concrete_slabs"); + public static final BlockCategory CONCRETE_STAIRS = get("minecraft:concrete_stairs"); + public static final BlockCategory CONDUIT_EFFECT_BLOCK = get("minecraft:conduit_effect_block"); + @Deprecated public static final BlockCategory CONVERTABLE_TO_MUD = get("minecraft:convertable_to_mud"); + public static final BlockCategory CONVERTIBLE_TO_MUD = get("minecraft:convertible_to_mud"); public static final BlockCategory COPPER = get("minecraft:copper"); public static final BlockCategory COPPER_CHESTS = get("minecraft:copper_chests"); public static final BlockCategory COPPER_GOLEM_STATUES = get("minecraft:copper_golem_statues"); @@ -92,7 +108,9 @@ public final class BlockCategories { public static final BlockCategory CRIMSON_STEMS = get("minecraft:crimson_stems"); public static final BlockCategory CROPS = get("minecraft:crops"); public static final BlockCategory CRYSTAL_SOUND_BLOCKS = get("minecraft:crystal_sound_blocks"); + public static final BlockCategory CUSHION_USES_COLLISION_SHAPE = get("minecraft:cushion_uses_collision_shape"); public static final BlockCategory DAMPENS_VIBRATIONS = get("minecraft:dampens_vibrations"); + public static final BlockCategory DANGEROUS_FOR_TELEPORTATION = get("minecraft:dangerous_for_teleportation"); public static final BlockCategory DARK_OAK_LOGS = get("minecraft:dark_oak_logs"); @Deprecated public static final BlockCategory DEAD_BUSH_MAY_PLACE_ON = get("minecraft:dead_bush_may_place_on"); public static final BlockCategory DEEPSLATE_ORE_REPLACEABLES = get("minecraft:deepslate_ore_replaceables"); @@ -112,7 +130,9 @@ public final class BlockCategories { public static final BlockCategory ENABLES_BUBBLE_COLUMN_PUSH_UP = get("minecraft:enables_bubble_column_push_up"); public static final BlockCategory ENCHANTMENT_POWER_PROVIDER = get("minecraft:enchantment_power_provider"); public static final BlockCategory ENCHANTMENT_POWER_TRANSMITTER = get("minecraft:enchantment_power_transmitter"); + public static final BlockCategory ENDERMAN_DOES_NOT_TELEPORT_TO = get("minecraft:enderman_does_not_teleport_to"); public static final BlockCategory ENDERMAN_HOLDABLE = get("minecraft:enderman_holdable"); + public static final BlockCategory ENTITIES_CAN_TELEPORT_TO = get("minecraft:entities_can_teleport_to"); public static final BlockCategory FALL_DAMAGE_RESETTING = get("minecraft:fall_damage_resetting"); public static final BlockCategory FEATURES_CANNOT_REPLACE = get("minecraft:features_cannot_replace"); public static final BlockCategory FENCE_GATES = get("minecraft:fence_gates"); @@ -133,10 +153,12 @@ public final class BlockCategories { public static final BlockCategory GROWS_CROPS = get("minecraft:grows_crops"); public static final BlockCategory GUARDED_BY_PIGLINS = get("minecraft:guarded_by_piglins"); public static final BlockCategory HAPPY_GHAST_AVOIDS = get("minecraft:happy_ghast_avoids"); + public static final BlockCategory HEIGHT_SPECIFIC_ORE_REPLACEABLES = get("minecraft:height_specific_ore_replaceables"); public static final BlockCategory HOGLIN_REPELLENTS = get("minecraft:hoglin_repellents"); public static final BlockCategory HUGE_BROWN_MUSHROOM_CAN_PLACE_ON = get("minecraft:huge_brown_mushroom_can_place_on"); public static final BlockCategory HUGE_RED_MUSHROOM_CAN_PLACE_ON = get("minecraft:huge_red_mushroom_can_place_on"); public static final BlockCategory ICE = get("minecraft:ice"); + public static final BlockCategory ICE_MELTS_WHEN_DESTROYED_ABOVE = get("minecraft:ice_melts_when_destroyed_above"); public static final BlockCategory ICE_SPIKE_REPLACEABLE = get("minecraft:ice_spike_replaceable"); public static final BlockCategory IMPERMEABLE = get("minecraft:impermeable"); public static final BlockCategory INCORRECT_FOR_COPPER_TOOL = get("minecraft:incorrect_for_copper_tool"); @@ -179,13 +201,15 @@ public final class BlockCategories { public static final BlockCategory NEEDS_DIAMOND_TOOL = get("minecraft:needs_diamond_tool"); public static final BlockCategory NEEDS_IRON_TOOL = get("minecraft:needs_iron_tool"); public static final BlockCategory NEEDS_STONE_TOOL = get("minecraft:needs_stone_tool"); - public static final BlockCategory NETHER_CARVER_REPLACEABLES = get("minecraft:nether_carver_replaceables"); + @Deprecated public static final BlockCategory NETHER_CARVER_REPLACEABLES = get("minecraft:nether_carver_replaceables"); + public static final BlockCategory NETHER_PORTAL_FRAME = get("minecraft:nether_portal_frame"); @Deprecated public static final BlockCategory NON_FLAMMABLE_WOOD = get("minecraft:non_flammable_wood"); public static final BlockCategory NYLIUM = get("minecraft:nylium"); public static final BlockCategory OAK_LOGS = get("minecraft:oak_logs"); public static final BlockCategory OCCLUDES_VIBRATION_SIGNALS = get("minecraft:occludes_vibration_signals"); + public static final BlockCategory ORES = get("minecraft:ores"); public static final BlockCategory OVERRIDES_MUSHROOM_LIGHT_REQUIREMENT = get("minecraft:overrides_mushroom_light_requirement"); - public static final BlockCategory OVERWORLD_CARVER_REPLACEABLES = get("minecraft:overworld_carver_replaceables"); + @Deprecated public static final BlockCategory OVERWORLD_CARVER_REPLACEABLES = get("minecraft:overworld_carver_replaceables"); public static final BlockCategory OVERWORLD_NATURAL_LOGS = get("minecraft:overworld_natural_logs"); public static final BlockCategory PALE_OAK_LOGS = get("minecraft:pale_oak_logs"); public static final BlockCategory PARROTS_SPAWNABLE_ON = get("minecraft:parrots_spawnable_on"); @@ -194,6 +218,7 @@ public final class BlockCategories { @Deprecated public static final BlockCategory PLAYS_AMBIENT_DESERT_BLOCK_SOUNDS = get("minecraft:plays_ambient_desert_block_sounds"); public static final BlockCategory POLAR_BEAR_IMMUNE_TO = get("minecraft:polar_bear_immune_to"); public static final BlockCategory POLAR_BEARS_SPAWNABLE_ON_ALTERNATE = get("minecraft:polar_bears_spawnable_on_alternate"); + public static final BlockCategory POPLAR_LOGS = get("minecraft:poplar_logs"); public static final BlockCategory PORTALS = get("minecraft:portals"); public static final BlockCategory PRESSURE_PLATES = get("minecraft:pressure_plates"); public static final BlockCategory PREVENT_MOB_SPAWNING_INSIDE = get("minecraft:prevent_mob_spawning_inside"); @@ -205,15 +230,19 @@ public final class BlockCategories { public static final BlockCategory REPLACEABLE_BY_MUSHROOMS = get("minecraft:replaceable_by_mushrooms"); public static final BlockCategory REPLACEABLE_BY_TREES = get("minecraft:replaceable_by_trees"); @Deprecated public static final BlockCategory REPLACEABLE_PLANTS = get("minecraft:replaceable_plants"); + public static final BlockCategory REQUIRED_FOR_POPLAR_LEAF_AMBIENCE = get("minecraft:required_for_poplar_leaf_ambience"); public static final BlockCategory SAND = get("minecraft:sand"); public static final BlockCategory SAPLINGS = get("minecraft:saplings"); + public static final BlockCategory SCULK_GROWTH_INHIBITORS = get("minecraft:sculk_growth_inhibitors"); public static final BlockCategory SCULK_REPLACEABLE = get("minecraft:sculk_replaceable"); public static final BlockCategory SCULK_REPLACEABLE_WORLD_GEN = get("minecraft:sculk_replaceable_world_gen"); public static final BlockCategory SHEARS_EXTREME_BREAKING_SPEED = get("minecraft:shears_extreme_breaking_speed"); public static final BlockCategory SHEARS_MAJOR_BREAKING_SPEED = get("minecraft:shears_major_breaking_speed"); public static final BlockCategory SHEARS_MINOR_BREAKING_SPEED = get("minecraft:shears_minor_breaking_speed"); public static final BlockCategory SHULKER_BOXES = get("minecraft:shulker_boxes"); + public static final BlockCategory SHULKER_DOES_NOT_TELEPORT_TO = get("minecraft:shulker_does_not_teleport_to"); public static final BlockCategory SIGNS = get("minecraft:signs"); + public static final BlockCategory SKULLS = get("minecraft:skulls"); public static final BlockCategory SLABS = get("minecraft:slabs"); @Deprecated public static final BlockCategory SMALL_DRIPLEAF_PLACEABLE = get("minecraft:small_dripleaf_placeable"); public static final BlockCategory SMALL_FLOWERS = get("minecraft:small_flowers"); @@ -227,6 +256,7 @@ public final class BlockCategories { @Deprecated public static final BlockCategory SNOW_LAYER_CANNOT_SURVIVE_ON = get("minecraft:snow_layer_cannot_survive_on"); public static final BlockCategory SOUL_FIRE_BASE_BLOCKS = get("minecraft:soul_fire_base_blocks"); public static final BlockCategory SOUL_SPEED_BLOCKS = get("minecraft:soul_speed_blocks"); + public static final BlockCategory SPEEDS_UP_ZOMBIE_VILLAGER_CURING = get("minecraft:speeds_up_zombie_villager_curing"); public static final BlockCategory SPELEOTHEMS = get("minecraft:speleothems"); public static final BlockCategory SPRUCE_LOGS = get("minecraft:spruce_logs"); public static final BlockCategory STAIRS = get("minecraft:stairs"); @@ -281,10 +311,15 @@ public final class BlockCategories { public static final BlockCategory TRIGGERS_AMBIENT_DESERT_DRY_VEGETATION_BLOCK_SOUNDS = get("minecraft:triggers_ambient_desert_dry_vegetation_block_sounds"); public static final BlockCategory TRIGGERS_AMBIENT_DESERT_SAND_BLOCK_SOUNDS = get("minecraft:triggers_ambient_desert_sand_block_sounds"); public static final BlockCategory TRIGGERS_AMBIENT_DRIED_GHAST_BLOCK_SOUNDS = get("minecraft:triggers_ambient_dried_ghast_block_sounds"); + public static final BlockCategory TURNS_INTO_DIRT_PATH = get("minecraft:turns_into_dirt_path"); + public static final BlockCategory TURNS_INTO_FARMLAND = get("minecraft:turns_into_farmland"); + public static final BlockCategory UNCARVABLE = get("minecraft:uncarvable"); public static final BlockCategory UNDERWATER_BONEMEALS = get("minecraft:underwater_bonemeals"); public static final BlockCategory UNSTABLE_BOTTOM_CENTER = get("minecraft:unstable_bottom_center"); public static final BlockCategory VALID_SPAWN = get("minecraft:valid_spawn"); public static final BlockCategory VIBRATION_RESONATORS = get("minecraft:vibration_resonators"); + public static final BlockCategory VILLAGER_BABIES_CAN_JUMP_ON_BED = get("minecraft:villager_babies_can_jump_on_bed"); + public static final BlockCategory VILLAGERS_CAN_SLEEP_ON_BED = get("minecraft:villagers_can_sleep_on_bed"); public static final BlockCategory WALL_CORALS = get("minecraft:wall_corals"); public static final BlockCategory WALL_HANGING_SIGNS = get("minecraft:wall_hanging_signs"); public static final BlockCategory WALL_POST_OVERRIDE = get("minecraft:wall_post_override"); @@ -292,6 +327,7 @@ public final class BlockCategories { public static final BlockCategory WALLS = get("minecraft:walls"); public static final BlockCategory WARPED_STEMS = get("minecraft:warped_stems"); public static final BlockCategory WART_BLOCKS = get("minecraft:wart_blocks"); + public static final BlockCategory WASHED_AWAY_BY_FLUIDS = get("minecraft:washed_away_by_fluids"); public static final BlockCategory WITHER_IMMUNE = get("minecraft:wither_immune"); public static final BlockCategory WITHER_IMMUNE_TO = get("minecraft:wither_immune_to"); public static final BlockCategory WITHER_SKELETON_IMMUNE_TO = get("minecraft:wither_skeleton_immune_to"); @@ -307,6 +343,8 @@ public final class BlockCategories { public static final BlockCategory WOODEN_TRAPDOORS = get("minecraft:wooden_trapdoors"); public static final BlockCategory WOOL = get("minecraft:wool"); public static final BlockCategory WOOL_CARPETS = get("minecraft:wool_carpets"); + public static final BlockCategory WOOL_SLABS = get("minecraft:wool_slabs"); + public static final BlockCategory WOOL_STAIRS = get("minecraft:wool_stairs"); private BlockCategories() { } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java index ded0e5f1f5..d707ecc968 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java @@ -118,6 +118,8 @@ public final class BlockTypes { @Nullable public static final BlockType BLACK_CARPET = get("minecraft:black_carpet"); @Nullable public static final BlockType BLACK_CONCRETE = get("minecraft:black_concrete"); @Nullable public static final BlockType BLACK_CONCRETE_POWDER = get("minecraft:black_concrete_powder"); + @Nullable public static final BlockType BLACK_CONCRETE_SLAB = get("minecraft:black_concrete_slab"); + @Nullable public static final BlockType BLACK_CONCRETE_STAIRS = get("minecraft:black_concrete_stairs"); @Nullable public static final BlockType BLACK_GLAZED_TERRACOTTA = get("minecraft:black_glazed_terracotta"); @Nullable public static final BlockType BLACK_SHULKER_BOX = get("minecraft:black_shulker_box"); @Nullable public static final BlockType BLACK_STAINED_GLASS = get("minecraft:black_stained_glass"); @@ -125,6 +127,8 @@ public final class BlockTypes { @Nullable public static final BlockType BLACK_TERRACOTTA = get("minecraft:black_terracotta"); @Nullable public static final BlockType BLACK_WALL_BANNER = get("minecraft:black_wall_banner"); @Nullable public static final BlockType BLACK_WOOL = get("minecraft:black_wool"); + @Nullable public static final BlockType BLACK_WOOL_SLAB = get("minecraft:black_wool_slab"); + @Nullable public static final BlockType BLACK_WOOL_STAIRS = get("minecraft:black_wool_stairs"); @Nullable public static final BlockType BLACKSTONE = get("minecraft:blackstone"); @Nullable public static final BlockType BLACKSTONE_SLAB = get("minecraft:blackstone_slab"); @Nullable public static final BlockType BLACKSTONE_STAIRS = get("minecraft:blackstone_stairs"); @@ -137,6 +141,8 @@ public final class BlockTypes { @Nullable public static final BlockType BLUE_CARPET = get("minecraft:blue_carpet"); @Nullable public static final BlockType BLUE_CONCRETE = get("minecraft:blue_concrete"); @Nullable public static final BlockType BLUE_CONCRETE_POWDER = get("minecraft:blue_concrete_powder"); + @Nullable public static final BlockType BLUE_CONCRETE_SLAB = get("minecraft:blue_concrete_slab"); + @Nullable public static final BlockType BLUE_CONCRETE_STAIRS = get("minecraft:blue_concrete_stairs"); @Nullable public static final BlockType BLUE_GLAZED_TERRACOTTA = get("minecraft:blue_glazed_terracotta"); @Nullable public static final BlockType BLUE_ICE = get("minecraft:blue_ice"); @Nullable public static final BlockType BLUE_ORCHID = get("minecraft:blue_orchid"); @@ -146,6 +152,8 @@ public final class BlockTypes { @Nullable public static final BlockType BLUE_TERRACOTTA = get("minecraft:blue_terracotta"); @Nullable public static final BlockType BLUE_WALL_BANNER = get("minecraft:blue_wall_banner"); @Nullable public static final BlockType BLUE_WOOL = get("minecraft:blue_wool"); + @Nullable public static final BlockType BLUE_WOOL_SLAB = get("minecraft:blue_wool_slab"); + @Nullable public static final BlockType BLUE_WOOL_STAIRS = get("minecraft:blue_wool_stairs"); @Nullable public static final BlockType BONE_BLOCK = get("minecraft:bone_block"); @Nullable public static final BlockType BOOKSHELF = get("minecraft:bookshelf"); @Nullable public static final BlockType BRAIN_CORAL = get("minecraft:brain_coral"); @@ -164,6 +172,8 @@ public final class BlockTypes { @Nullable public static final BlockType BROWN_CARPET = get("minecraft:brown_carpet"); @Nullable public static final BlockType BROWN_CONCRETE = get("minecraft:brown_concrete"); @Nullable public static final BlockType BROWN_CONCRETE_POWDER = get("minecraft:brown_concrete_powder"); + @Nullable public static final BlockType BROWN_CONCRETE_SLAB = get("minecraft:brown_concrete_slab"); + @Nullable public static final BlockType BROWN_CONCRETE_STAIRS = get("minecraft:brown_concrete_stairs"); @Nullable public static final BlockType BROWN_GLAZED_TERRACOTTA = get("minecraft:brown_glazed_terracotta"); @Nullable public static final BlockType BROWN_MUSHROOM = get("minecraft:brown_mushroom"); @Nullable public static final BlockType BROWN_MUSHROOM_BLOCK = get("minecraft:brown_mushroom_block"); @@ -173,6 +183,8 @@ public final class BlockTypes { @Nullable public static final BlockType BROWN_TERRACOTTA = get("minecraft:brown_terracotta"); @Nullable public static final BlockType BROWN_WALL_BANNER = get("minecraft:brown_wall_banner"); @Nullable public static final BlockType BROWN_WOOL = get("minecraft:brown_wool"); + @Nullable public static final BlockType BROWN_WOOL_SLAB = get("minecraft:brown_wool_slab"); + @Nullable public static final BlockType BROWN_WOOL_STAIRS = get("minecraft:brown_wool_stairs"); @Nullable public static final BlockType BUBBLE_COLUMN = get("minecraft:bubble_column"); @Nullable public static final BlockType BUBBLE_CORAL = get("minecraft:bubble_coral"); @Nullable public static final BlockType BUBBLE_CORAL_BLOCK = get("minecraft:bubble_coral_block"); @@ -318,6 +330,8 @@ public final class BlockTypes { @Nullable public static final BlockType CYAN_CARPET = get("minecraft:cyan_carpet"); @Nullable public static final BlockType CYAN_CONCRETE = get("minecraft:cyan_concrete"); @Nullable public static final BlockType CYAN_CONCRETE_POWDER = get("minecraft:cyan_concrete_powder"); + @Nullable public static final BlockType CYAN_CONCRETE_SLAB = get("minecraft:cyan_concrete_slab"); + @Nullable public static final BlockType CYAN_CONCRETE_STAIRS = get("minecraft:cyan_concrete_stairs"); @Nullable public static final BlockType CYAN_GLAZED_TERRACOTTA = get("minecraft:cyan_glazed_terracotta"); @Nullable public static final BlockType CYAN_SHULKER_BOX = get("minecraft:cyan_shulker_box"); @Nullable public static final BlockType CYAN_STAINED_GLASS = get("minecraft:cyan_stained_glass"); @@ -325,6 +339,8 @@ public final class BlockTypes { @Nullable public static final BlockType CYAN_TERRACOTTA = get("minecraft:cyan_terracotta"); @Nullable public static final BlockType CYAN_WALL_BANNER = get("minecraft:cyan_wall_banner"); @Nullable public static final BlockType CYAN_WOOL = get("minecraft:cyan_wool"); + @Nullable public static final BlockType CYAN_WOOL_SLAB = get("minecraft:cyan_wool_slab"); + @Nullable public static final BlockType CYAN_WOOL_STAIRS = get("minecraft:cyan_wool_stairs"); @Nullable public static final BlockType DAMAGED_ANVIL = get("minecraft:damaged_anvil"); @Nullable public static final BlockType DANDELION = get("minecraft:dandelion"); @Nullable public static final BlockType DARK_OAK_BUTTON = get("minecraft:dark_oak_button"); @@ -471,6 +487,8 @@ public final class BlockTypes { @Nullable public static final BlockType GRAY_CARPET = get("minecraft:gray_carpet"); @Nullable public static final BlockType GRAY_CONCRETE = get("minecraft:gray_concrete"); @Nullable public static final BlockType GRAY_CONCRETE_POWDER = get("minecraft:gray_concrete_powder"); + @Nullable public static final BlockType GRAY_CONCRETE_SLAB = get("minecraft:gray_concrete_slab"); + @Nullable public static final BlockType GRAY_CONCRETE_STAIRS = get("minecraft:gray_concrete_stairs"); @Nullable public static final BlockType GRAY_GLAZED_TERRACOTTA = get("minecraft:gray_glazed_terracotta"); @Nullable public static final BlockType GRAY_SHULKER_BOX = get("minecraft:gray_shulker_box"); @Nullable public static final BlockType GRAY_STAINED_GLASS = get("minecraft:gray_stained_glass"); @@ -478,6 +496,8 @@ public final class BlockTypes { @Nullable public static final BlockType GRAY_TERRACOTTA = get("minecraft:gray_terracotta"); @Nullable public static final BlockType GRAY_WALL_BANNER = get("minecraft:gray_wall_banner"); @Nullable public static final BlockType GRAY_WOOL = get("minecraft:gray_wool"); + @Nullable public static final BlockType GRAY_WOOL_SLAB = get("minecraft:gray_wool_slab"); + @Nullable public static final BlockType GRAY_WOOL_STAIRS = get("minecraft:gray_wool_stairs"); @Nullable public static final BlockType GREEN_BANNER = get("minecraft:green_banner"); @Nullable public static final BlockType GREEN_BED = get("minecraft:green_bed"); @Nullable public static final BlockType GREEN_CANDLE = get("minecraft:green_candle"); @@ -485,6 +505,8 @@ public final class BlockTypes { @Nullable public static final BlockType GREEN_CARPET = get("minecraft:green_carpet"); @Nullable public static final BlockType GREEN_CONCRETE = get("minecraft:green_concrete"); @Nullable public static final BlockType GREEN_CONCRETE_POWDER = get("minecraft:green_concrete_powder"); + @Nullable public static final BlockType GREEN_CONCRETE_SLAB = get("minecraft:green_concrete_slab"); + @Nullable public static final BlockType GREEN_CONCRETE_STAIRS = get("minecraft:green_concrete_stairs"); @Nullable public static final BlockType GREEN_GLAZED_TERRACOTTA = get("minecraft:green_glazed_terracotta"); @Nullable public static final BlockType GREEN_SHULKER_BOX = get("minecraft:green_shulker_box"); @Nullable public static final BlockType GREEN_STAINED_GLASS = get("minecraft:green_stained_glass"); @@ -492,6 +514,8 @@ public final class BlockTypes { @Nullable public static final BlockType GREEN_TERRACOTTA = get("minecraft:green_terracotta"); @Nullable public static final BlockType GREEN_WALL_BANNER = get("minecraft:green_wall_banner"); @Nullable public static final BlockType GREEN_WOOL = get("minecraft:green_wool"); + @Nullable public static final BlockType GREEN_WOOL_SLAB = get("minecraft:green_wool_slab"); + @Nullable public static final BlockType GREEN_WOOL_STAIRS = get("minecraft:green_wool_stairs"); @Nullable public static final BlockType GRINDSTONE = get("minecraft:grindstone"); @Nullable public static final BlockType HANGING_ROOTS = get("minecraft:hanging_roots"); @Nullable public static final BlockType HAY_BLOCK = get("minecraft:hay_block"); @@ -560,6 +584,8 @@ public final class BlockTypes { @Nullable public static final BlockType LIGHT_BLUE_CARPET = get("minecraft:light_blue_carpet"); @Nullable public static final BlockType LIGHT_BLUE_CONCRETE = get("minecraft:light_blue_concrete"); @Nullable public static final BlockType LIGHT_BLUE_CONCRETE_POWDER = get("minecraft:light_blue_concrete_powder"); + @Nullable public static final BlockType LIGHT_BLUE_CONCRETE_SLAB = get("minecraft:light_blue_concrete_slab"); + @Nullable public static final BlockType LIGHT_BLUE_CONCRETE_STAIRS = get("minecraft:light_blue_concrete_stairs"); @Nullable public static final BlockType LIGHT_BLUE_GLAZED_TERRACOTTA = get("minecraft:light_blue_glazed_terracotta"); @Nullable public static final BlockType LIGHT_BLUE_SHULKER_BOX = get("minecraft:light_blue_shulker_box"); @Nullable public static final BlockType LIGHT_BLUE_STAINED_GLASS = get("minecraft:light_blue_stained_glass"); @@ -567,6 +593,8 @@ public final class BlockTypes { @Nullable public static final BlockType LIGHT_BLUE_TERRACOTTA = get("minecraft:light_blue_terracotta"); @Nullable public static final BlockType LIGHT_BLUE_WALL_BANNER = get("minecraft:light_blue_wall_banner"); @Nullable public static final BlockType LIGHT_BLUE_WOOL = get("minecraft:light_blue_wool"); + @Nullable public static final BlockType LIGHT_BLUE_WOOL_SLAB = get("minecraft:light_blue_wool_slab"); + @Nullable public static final BlockType LIGHT_BLUE_WOOL_STAIRS = get("minecraft:light_blue_wool_stairs"); @Nullable public static final BlockType LIGHT_GRAY_BANNER = get("minecraft:light_gray_banner"); @Nullable public static final BlockType LIGHT_GRAY_BED = get("minecraft:light_gray_bed"); @Nullable public static final BlockType LIGHT_GRAY_CANDLE = get("minecraft:light_gray_candle"); @@ -574,6 +602,8 @@ public final class BlockTypes { @Nullable public static final BlockType LIGHT_GRAY_CARPET = get("minecraft:light_gray_carpet"); @Nullable public static final BlockType LIGHT_GRAY_CONCRETE = get("minecraft:light_gray_concrete"); @Nullable public static final BlockType LIGHT_GRAY_CONCRETE_POWDER = get("minecraft:light_gray_concrete_powder"); + @Nullable public static final BlockType LIGHT_GRAY_CONCRETE_SLAB = get("minecraft:light_gray_concrete_slab"); + @Nullable public static final BlockType LIGHT_GRAY_CONCRETE_STAIRS = get("minecraft:light_gray_concrete_stairs"); @Nullable public static final BlockType LIGHT_GRAY_GLAZED_TERRACOTTA = get("minecraft:light_gray_glazed_terracotta"); @Nullable public static final BlockType LIGHT_GRAY_SHULKER_BOX = get("minecraft:light_gray_shulker_box"); @Nullable public static final BlockType LIGHT_GRAY_STAINED_GLASS = get("minecraft:light_gray_stained_glass"); @@ -581,6 +611,8 @@ public final class BlockTypes { @Nullable public static final BlockType LIGHT_GRAY_TERRACOTTA = get("minecraft:light_gray_terracotta"); @Nullable public static final BlockType LIGHT_GRAY_WALL_BANNER = get("minecraft:light_gray_wall_banner"); @Nullable public static final BlockType LIGHT_GRAY_WOOL = get("minecraft:light_gray_wool"); + @Nullable public static final BlockType LIGHT_GRAY_WOOL_SLAB = get("minecraft:light_gray_wool_slab"); + @Nullable public static final BlockType LIGHT_GRAY_WOOL_STAIRS = get("minecraft:light_gray_wool_stairs"); @Nullable public static final BlockType LIGHT_WEIGHTED_PRESSURE_PLATE = get("minecraft:light_weighted_pressure_plate"); @Nullable public static final BlockType LIGHTNING_ROD = get("minecraft:lightning_rod"); @Nullable public static final BlockType LILAC = get("minecraft:lilac"); @@ -593,6 +625,8 @@ public final class BlockTypes { @Nullable public static final BlockType LIME_CARPET = get("minecraft:lime_carpet"); @Nullable public static final BlockType LIME_CONCRETE = get("minecraft:lime_concrete"); @Nullable public static final BlockType LIME_CONCRETE_POWDER = get("minecraft:lime_concrete_powder"); + @Nullable public static final BlockType LIME_CONCRETE_SLAB = get("minecraft:lime_concrete_slab"); + @Nullable public static final BlockType LIME_CONCRETE_STAIRS = get("minecraft:lime_concrete_stairs"); @Nullable public static final BlockType LIME_GLAZED_TERRACOTTA = get("minecraft:lime_glazed_terracotta"); @Nullable public static final BlockType LIME_SHULKER_BOX = get("minecraft:lime_shulker_box"); @Nullable public static final BlockType LIME_STAINED_GLASS = get("minecraft:lime_stained_glass"); @@ -600,6 +634,8 @@ public final class BlockTypes { @Nullable public static final BlockType LIME_TERRACOTTA = get("minecraft:lime_terracotta"); @Nullable public static final BlockType LIME_WALL_BANNER = get("minecraft:lime_wall_banner"); @Nullable public static final BlockType LIME_WOOL = get("minecraft:lime_wool"); + @Nullable public static final BlockType LIME_WOOL_SLAB = get("minecraft:lime_wool_slab"); + @Nullable public static final BlockType LIME_WOOL_STAIRS = get("minecraft:lime_wool_stairs"); @Nullable public static final BlockType LODESTONE = get("minecraft:lodestone"); @Nullable public static final BlockType LOOM = get("minecraft:loom"); @Nullable public static final BlockType MAGENTA_BANNER = get("minecraft:magenta_banner"); @@ -609,6 +645,8 @@ public final class BlockTypes { @Nullable public static final BlockType MAGENTA_CARPET = get("minecraft:magenta_carpet"); @Nullable public static final BlockType MAGENTA_CONCRETE = get("minecraft:magenta_concrete"); @Nullable public static final BlockType MAGENTA_CONCRETE_POWDER = get("minecraft:magenta_concrete_powder"); + @Nullable public static final BlockType MAGENTA_CONCRETE_SLAB = get("minecraft:magenta_concrete_slab"); + @Nullable public static final BlockType MAGENTA_CONCRETE_STAIRS = get("minecraft:magenta_concrete_stairs"); @Nullable public static final BlockType MAGENTA_GLAZED_TERRACOTTA = get("minecraft:magenta_glazed_terracotta"); @Nullable public static final BlockType MAGENTA_SHULKER_BOX = get("minecraft:magenta_shulker_box"); @Nullable public static final BlockType MAGENTA_STAINED_GLASS = get("minecraft:magenta_stained_glass"); @@ -616,6 +654,8 @@ public final class BlockTypes { @Nullable public static final BlockType MAGENTA_TERRACOTTA = get("minecraft:magenta_terracotta"); @Nullable public static final BlockType MAGENTA_WALL_BANNER = get("minecraft:magenta_wall_banner"); @Nullable public static final BlockType MAGENTA_WOOL = get("minecraft:magenta_wool"); + @Nullable public static final BlockType MAGENTA_WOOL_SLAB = get("minecraft:magenta_wool_slab"); + @Nullable public static final BlockType MAGENTA_WOOL_STAIRS = get("minecraft:magenta_wool_stairs"); @Nullable public static final BlockType MAGMA_BLOCK = get("minecraft:magma_block"); @Nullable public static final BlockType MANGROVE_BUTTON = get("minecraft:mangrove_button"); @Nullable public static final BlockType MANGROVE_DOOR = get("minecraft:mangrove_door"); @@ -701,7 +741,10 @@ public final class BlockTypes { @Nullable public static final BlockType ORANGE_CARPET = get("minecraft:orange_carpet"); @Nullable public static final BlockType ORANGE_CONCRETE = get("minecraft:orange_concrete"); @Nullable public static final BlockType ORANGE_CONCRETE_POWDER = get("minecraft:orange_concrete_powder"); + @Nullable public static final BlockType ORANGE_CONCRETE_SLAB = get("minecraft:orange_concrete_slab"); + @Nullable public static final BlockType ORANGE_CONCRETE_STAIRS = get("minecraft:orange_concrete_stairs"); @Nullable public static final BlockType ORANGE_GLAZED_TERRACOTTA = get("minecraft:orange_glazed_terracotta"); + @Nullable public static final BlockType ORANGE_POPLAR_LEAVES = get("minecraft:orange_poplar_leaves"); @Nullable public static final BlockType ORANGE_SHULKER_BOX = get("minecraft:orange_shulker_box"); @Nullable public static final BlockType ORANGE_STAINED_GLASS = get("minecraft:orange_stained_glass"); @Nullable public static final BlockType ORANGE_STAINED_GLASS_PANE = get("minecraft:orange_stained_glass_pane"); @@ -709,6 +752,8 @@ public final class BlockTypes { @Nullable public static final BlockType ORANGE_TULIP = get("minecraft:orange_tulip"); @Nullable public static final BlockType ORANGE_WALL_BANNER = get("minecraft:orange_wall_banner"); @Nullable public static final BlockType ORANGE_WOOL = get("minecraft:orange_wool"); + @Nullable public static final BlockType ORANGE_WOOL_SLAB = get("minecraft:orange_wool_slab"); + @Nullable public static final BlockType ORANGE_WOOL_STAIRS = get("minecraft:orange_wool_stairs"); @Nullable public static final BlockType OXEYE_DAISY = get("minecraft:oxeye_daisy"); @Nullable public static final BlockType OXIDIZED_CHISELED_COPPER = get("minecraft:oxidized_chiseled_copper"); @Nullable public static final BlockType OXIDIZED_COPPER = get("minecraft:oxidized_copper"); @@ -760,6 +805,8 @@ public final class BlockTypes { @Nullable public static final BlockType PINK_CARPET = get("minecraft:pink_carpet"); @Nullable public static final BlockType PINK_CONCRETE = get("minecraft:pink_concrete"); @Nullable public static final BlockType PINK_CONCRETE_POWDER = get("minecraft:pink_concrete_powder"); + @Nullable public static final BlockType PINK_CONCRETE_SLAB = get("minecraft:pink_concrete_slab"); + @Nullable public static final BlockType PINK_CONCRETE_STAIRS = get("minecraft:pink_concrete_stairs"); @Nullable public static final BlockType PINK_GLAZED_TERRACOTTA = get("minecraft:pink_glazed_terracotta"); @Nullable public static final BlockType PINK_PETALS = get("minecraft:pink_petals"); @Nullable public static final BlockType PINK_SHULKER_BOX = get("minecraft:pink_shulker_box"); @@ -769,6 +816,8 @@ public final class BlockTypes { @Nullable public static final BlockType PINK_TULIP = get("minecraft:pink_tulip"); @Nullable public static final BlockType PINK_WALL_BANNER = get("minecraft:pink_wall_banner"); @Nullable public static final BlockType PINK_WOOL = get("minecraft:pink_wool"); + @Nullable public static final BlockType PINK_WOOL_SLAB = get("minecraft:pink_wool_slab"); + @Nullable public static final BlockType PINK_WOOL_STAIRS = get("minecraft:pink_wool_stairs"); @Nullable public static final BlockType PISTON = get("minecraft:piston"); @Nullable public static final BlockType PISTON_HEAD = get("minecraft:piston_head"); @Nullable public static final BlockType PITCHER_CROP = get("minecraft:pitcher_crop"); @@ -813,6 +862,23 @@ public final class BlockTypes { @Nullable public static final BlockType POLISHED_TUFF_SLAB = get("minecraft:polished_tuff_slab"); @Nullable public static final BlockType POLISHED_TUFF_STAIRS = get("minecraft:polished_tuff_stairs"); @Nullable public static final BlockType POLISHED_TUFF_WALL = get("minecraft:polished_tuff_wall"); + @Nullable public static final BlockType POPLAR_BUTTON = get("minecraft:poplar_button"); + @Nullable public static final BlockType POPLAR_DOOR = get("minecraft:poplar_door"); + @Nullable public static final BlockType POPLAR_FENCE = get("minecraft:poplar_fence"); + @Nullable public static final BlockType POPLAR_FENCE_GATE = get("minecraft:poplar_fence_gate"); + @Nullable public static final BlockType POPLAR_HANGING_SIGN = get("minecraft:poplar_hanging_sign"); + @Nullable public static final BlockType POPLAR_LOG = get("minecraft:poplar_log"); + @Nullable public static final BlockType POPLAR_PLANKS = get("minecraft:poplar_planks"); + @Nullable public static final BlockType POPLAR_PRESSURE_PLATE = get("minecraft:poplar_pressure_plate"); + @Nullable public static final BlockType POPLAR_SAPLING = get("minecraft:poplar_sapling"); + @Nullable public static final BlockType POPLAR_SHELF = get("minecraft:poplar_shelf"); + @Nullable public static final BlockType POPLAR_SIGN = get("minecraft:poplar_sign"); + @Nullable public static final BlockType POPLAR_SLAB = get("minecraft:poplar_slab"); + @Nullable public static final BlockType POPLAR_STAIRS = get("minecraft:poplar_stairs"); + @Nullable public static final BlockType POPLAR_TRAPDOOR = get("minecraft:poplar_trapdoor"); + @Nullable public static final BlockType POPLAR_WALL_HANGING_SIGN = get("minecraft:poplar_wall_hanging_sign"); + @Nullable public static final BlockType POPLAR_WALL_SIGN = get("minecraft:poplar_wall_sign"); + @Nullable public static final BlockType POPLAR_WOOD = get("minecraft:poplar_wood"); @Nullable public static final BlockType POPPY = get("minecraft:poppy"); @Nullable public static final BlockType POTATOES = get("minecraft:potatoes"); @Nullable public static final BlockType POTENT_SULFUR = get("minecraft:potent_sulfur"); @@ -845,6 +911,7 @@ public final class BlockTypes { @Nullable public static final BlockType POTTED_OXEYE_DAISY = get("minecraft:potted_oxeye_daisy"); @Nullable public static final BlockType POTTED_PALE_OAK_SAPLING = get("minecraft:potted_pale_oak_sapling"); @Nullable public static final BlockType POTTED_PINK_TULIP = get("minecraft:potted_pink_tulip"); + @Nullable public static final BlockType POTTED_POPLAR_SAPLING = get("minecraft:potted_poplar_sapling"); @Nullable public static final BlockType POTTED_POPPY = get("minecraft:potted_poppy"); @Nullable public static final BlockType POTTED_RED_MUSHROOM = get("minecraft:potted_red_mushroom"); @Nullable public static final BlockType POTTED_RED_TULIP = get("minecraft:potted_red_tulip"); @@ -873,6 +940,8 @@ public final class BlockTypes { @Nullable public static final BlockType PURPLE_CARPET = get("minecraft:purple_carpet"); @Nullable public static final BlockType PURPLE_CONCRETE = get("minecraft:purple_concrete"); @Nullable public static final BlockType PURPLE_CONCRETE_POWDER = get("minecraft:purple_concrete_powder"); + @Nullable public static final BlockType PURPLE_CONCRETE_SLAB = get("minecraft:purple_concrete_slab"); + @Nullable public static final BlockType PURPLE_CONCRETE_STAIRS = get("minecraft:purple_concrete_stairs"); @Nullable public static final BlockType PURPLE_GLAZED_TERRACOTTA = get("minecraft:purple_glazed_terracotta"); @Nullable public static final BlockType PURPLE_SHULKER_BOX = get("minecraft:purple_shulker_box"); @Nullable public static final BlockType PURPLE_STAINED_GLASS = get("minecraft:purple_stained_glass"); @@ -880,6 +949,8 @@ public final class BlockTypes { @Nullable public static final BlockType PURPLE_TERRACOTTA = get("minecraft:purple_terracotta"); @Nullable public static final BlockType PURPLE_WALL_BANNER = get("minecraft:purple_wall_banner"); @Nullable public static final BlockType PURPLE_WOOL = get("minecraft:purple_wool"); + @Nullable public static final BlockType PURPLE_WOOL_SLAB = get("minecraft:purple_wool_slab"); + @Nullable public static final BlockType PURPLE_WOOL_STAIRS = get("minecraft:purple_wool_stairs"); @Nullable public static final BlockType PURPUR_BLOCK = get("minecraft:purpur_block"); @Nullable public static final BlockType PURPUR_PILLAR = get("minecraft:purpur_pillar"); @Nullable public static final BlockType PURPUR_SLAB = get("minecraft:purpur_slab"); @@ -900,6 +971,8 @@ public final class BlockTypes { @Nullable public static final BlockType RED_CARPET = get("minecraft:red_carpet"); @Nullable public static final BlockType RED_CONCRETE = get("minecraft:red_concrete"); @Nullable public static final BlockType RED_CONCRETE_POWDER = get("minecraft:red_concrete_powder"); + @Nullable public static final BlockType RED_CONCRETE_SLAB = get("minecraft:red_concrete_slab"); + @Nullable public static final BlockType RED_CONCRETE_STAIRS = get("minecraft:red_concrete_stairs"); @Nullable public static final BlockType RED_GLAZED_TERRACOTTA = get("minecraft:red_glazed_terracotta"); @Nullable public static final BlockType RED_MUSHROOM = get("minecraft:red_mushroom"); @Nullable public static final BlockType RED_MUSHROOM_BLOCK = get("minecraft:red_mushroom_block"); @@ -907,11 +980,13 @@ public final class BlockTypes { @Nullable public static final BlockType RED_NETHER_BRICK_STAIRS = get("minecraft:red_nether_brick_stairs"); @Nullable public static final BlockType RED_NETHER_BRICK_WALL = get("minecraft:red_nether_brick_wall"); @Nullable public static final BlockType RED_NETHER_BRICKS = get("minecraft:red_nether_bricks"); + @Nullable public static final BlockType RED_POPLAR_LEAVES = get("minecraft:red_poplar_leaves"); @Nullable public static final BlockType RED_SAND = get("minecraft:red_sand"); @Nullable public static final BlockType RED_SANDSTONE = get("minecraft:red_sandstone"); @Nullable public static final BlockType RED_SANDSTONE_SLAB = get("minecraft:red_sandstone_slab"); @Nullable public static final BlockType RED_SANDSTONE_STAIRS = get("minecraft:red_sandstone_stairs"); @Nullable public static final BlockType RED_SANDSTONE_WALL = get("minecraft:red_sandstone_wall"); + @Nullable public static final BlockType RED_SHRUB = get("minecraft:red_shrub"); @Nullable public static final BlockType RED_SHULKER_BOX = get("minecraft:red_shulker_box"); @Nullable public static final BlockType RED_STAINED_GLASS = get("minecraft:red_stained_glass"); @Nullable public static final BlockType RED_STAINED_GLASS_PANE = get("minecraft:red_stained_glass_pane"); @@ -919,6 +994,8 @@ public final class BlockTypes { @Nullable public static final BlockType RED_TULIP = get("minecraft:red_tulip"); @Nullable public static final BlockType RED_WALL_BANNER = get("minecraft:red_wall_banner"); @Nullable public static final BlockType RED_WOOL = get("minecraft:red_wool"); + @Nullable public static final BlockType RED_WOOL_SLAB = get("minecraft:red_wool_slab"); + @Nullable public static final BlockType RED_WOOL_STAIRS = get("minecraft:red_wool_stairs"); @Nullable public static final BlockType REDSTONE_BLOCK = get("minecraft:redstone_block"); @Nullable public static final BlockType REDSTONE_LAMP = get("minecraft:redstone_lamp"); @Nullable public static final BlockType REDSTONE_ORE = get("minecraft:redstone_ore"); @@ -951,6 +1028,7 @@ public final class BlockTypes { @Nullable public static final BlockType SEA_LANTERN = get("minecraft:sea_lantern"); @Nullable public static final BlockType SEA_PICKLE = get("minecraft:sea_pickle"); @Nullable public static final BlockType SEAGRASS = get("minecraft:seagrass"); + @Nullable public static final BlockType SHELF_MUSHROOM = get("minecraft:shelf_mushroom"); @Nullable public static final BlockType SHORT_DRY_GRASS = get("minecraft:short_dry_grass"); @Nullable public static final BlockType SHORT_GRASS = get("minecraft:short_grass"); @Nullable public static final BlockType SHROOMLIGHT = get("minecraft:shroomlight"); @@ -1017,6 +1095,7 @@ public final class BlockTypes { @Nullable public static final BlockType STONE_SLAB = get("minecraft:stone_slab"); @Nullable public static final BlockType STONE_STAIRS = get("minecraft:stone_stairs"); @Nullable public static final BlockType STONECUTTER = get("minecraft:stonecutter"); + @Nullable public static final BlockType STRAW_BED = get("minecraft:straw_bed"); @Nullable public static final BlockType STRIPPED_ACACIA_LOG = get("minecraft:stripped_acacia_log"); @Nullable public static final BlockType STRIPPED_ACACIA_WOOD = get("minecraft:stripped_acacia_wood"); @Nullable public static final BlockType STRIPPED_BAMBOO_BLOCK = get("minecraft:stripped_bamboo_block"); @@ -1036,6 +1115,8 @@ public final class BlockTypes { @Nullable public static final BlockType STRIPPED_OAK_WOOD = get("minecraft:stripped_oak_wood"); @Nullable public static final BlockType STRIPPED_PALE_OAK_LOG = get("minecraft:stripped_pale_oak_log"); @Nullable public static final BlockType STRIPPED_PALE_OAK_WOOD = get("minecraft:stripped_pale_oak_wood"); + @Nullable public static final BlockType STRIPPED_POPLAR_LOG = get("minecraft:stripped_poplar_log"); + @Nullable public static final BlockType STRIPPED_POPLAR_WOOD = get("minecraft:stripped_poplar_wood"); @Nullable public static final BlockType STRIPPED_SPRUCE_LOG = get("minecraft:stripped_spruce_log"); @Nullable public static final BlockType STRIPPED_SPRUCE_WOOD = get("minecraft:stripped_spruce_wood"); @Nullable public static final BlockType STRIPPED_WARPED_HYPHAE = get("minecraft:stripped_warped_hyphae"); @@ -1201,6 +1282,8 @@ public final class BlockTypes { @Nullable public static final BlockType WHITE_CARPET = get("minecraft:white_carpet"); @Nullable public static final BlockType WHITE_CONCRETE = get("minecraft:white_concrete"); @Nullable public static final BlockType WHITE_CONCRETE_POWDER = get("minecraft:white_concrete_powder"); + @Nullable public static final BlockType WHITE_CONCRETE_SLAB = get("minecraft:white_concrete_slab"); + @Nullable public static final BlockType WHITE_CONCRETE_STAIRS = get("minecraft:white_concrete_stairs"); @Nullable public static final BlockType WHITE_GLAZED_TERRACOTTA = get("minecraft:white_glazed_terracotta"); @Nullable public static final BlockType WHITE_SHULKER_BOX = get("minecraft:white_shulker_box"); @Nullable public static final BlockType WHITE_STAINED_GLASS = get("minecraft:white_stained_glass"); @@ -1209,6 +1292,8 @@ public final class BlockTypes { @Nullable public static final BlockType WHITE_TULIP = get("minecraft:white_tulip"); @Nullable public static final BlockType WHITE_WALL_BANNER = get("minecraft:white_wall_banner"); @Nullable public static final BlockType WHITE_WOOL = get("minecraft:white_wool"); + @Nullable public static final BlockType WHITE_WOOL_SLAB = get("minecraft:white_wool_slab"); + @Nullable public static final BlockType WHITE_WOOL_STAIRS = get("minecraft:white_wool_stairs"); @Nullable public static final BlockType WILDFLOWERS = get("minecraft:wildflowers"); @Nullable public static final BlockType WITHER_ROSE = get("minecraft:wither_rose"); @Nullable public static final BlockType WITHER_SKELETON_SKULL = get("minecraft:wither_skeleton_skull"); @@ -1220,13 +1305,18 @@ public final class BlockTypes { @Nullable public static final BlockType YELLOW_CARPET = get("minecraft:yellow_carpet"); @Nullable public static final BlockType YELLOW_CONCRETE = get("minecraft:yellow_concrete"); @Nullable public static final BlockType YELLOW_CONCRETE_POWDER = get("minecraft:yellow_concrete_powder"); + @Nullable public static final BlockType YELLOW_CONCRETE_SLAB = get("minecraft:yellow_concrete_slab"); + @Nullable public static final BlockType YELLOW_CONCRETE_STAIRS = get("minecraft:yellow_concrete_stairs"); @Nullable public static final BlockType YELLOW_GLAZED_TERRACOTTA = get("minecraft:yellow_glazed_terracotta"); + @Nullable public static final BlockType YELLOW_POPLAR_LEAVES = get("minecraft:yellow_poplar_leaves"); @Nullable public static final BlockType YELLOW_SHULKER_BOX = get("minecraft:yellow_shulker_box"); @Nullable public static final BlockType YELLOW_STAINED_GLASS = get("minecraft:yellow_stained_glass"); @Nullable public static final BlockType YELLOW_STAINED_GLASS_PANE = get("minecraft:yellow_stained_glass_pane"); @Nullable public static final BlockType YELLOW_TERRACOTTA = get("minecraft:yellow_terracotta"); @Nullable public static final BlockType YELLOW_WALL_BANNER = get("minecraft:yellow_wall_banner"); @Nullable public static final BlockType YELLOW_WOOL = get("minecraft:yellow_wool"); + @Nullable public static final BlockType YELLOW_WOOL_SLAB = get("minecraft:yellow_wool_slab"); + @Nullable public static final BlockType YELLOW_WOOL_STAIRS = get("minecraft:yellow_wool_stairs"); @Nullable public static final BlockType ZOMBIE_HEAD = get("minecraft:zombie_head"); @Nullable public static final BlockType ZOMBIE_WALL_HEAD = get("minecraft:zombie_wall_head"); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityTypes.java index b90e3dab86..cde6b9a0cf 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityTypes.java @@ -64,6 +64,7 @@ public final class EntityTypes { @Nullable public static final EntityType CREAKING = get("minecraft:creaking"); @Deprecated @Nullable public static final EntityType CREAKING_TRANSIENT = get("minecraft:creaking_transient"); @Nullable public static final EntityType CREEPER = get("minecraft:creeper"); + @Nullable public static final EntityType CUSHION = get("minecraft:cushion"); @Nullable public static final EntityType DARK_OAK_BOAT = get("minecraft:dark_oak_boat"); @Nullable public static final EntityType DARK_OAK_CHEST_BOAT = get("minecraft:dark_oak_chest_boat"); @Nullable public static final EntityType DOLPHIN = get("minecraft:dolphin"); @@ -139,6 +140,8 @@ public final class EntityTypes { @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 POPLAR_BOAT = get("minecraft:poplar_boat"); + @Nullable public static final EntityType POPLAR_CHEST_BOAT = get("minecraft:poplar_chest_boat"); @Deprecated @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"); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/generation/ConfiguredFeatureType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/generation/ConfiguredFeatureType.java index 94bae9a0d1..c856aeff5a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/generation/ConfiguredFeatureType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/generation/ConfiguredFeatureType.java @@ -22,6 +22,12 @@ import com.sk89q.worldedit.registry.Keyed; import com.sk89q.worldedit.registry.NamespacedRegistry; +/** + * A configured feature type. + * + * @param id The ID + * @apiNote Due to Minecraft renaming the underlying registry, this will be renamed with the next major version. + */ public record ConfiguredFeatureType(String id) implements Keyed { public static final NamespacedRegistry REGISTRY = new NamespacedRegistry<>("configured feature type", "configured_feature_type", "minecraft"); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategories.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategories.java index ad76815ed9..6d986622ea 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategories.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategories.java @@ -44,7 +44,8 @@ public final class ItemCategories { public static final ItemCategory BOOK_CLONING_TARGET = get("minecraft:book_cloning_target"); public static final ItemCategory BOOKSHELF_BOOKS = get("minecraft:bookshelf_books"); public static final ItemCategory BREAKS_DECORATED_POTS = get("minecraft:breaks_decorated_pots"); - public static final ItemCategory BREWING_FUEL = get("minecraft:brewing_fuel"); + @Deprecated public static final ItemCategory BREWING_FUEL = get("minecraft:brewing_fuel"); + public static final ItemCategory BREWING_POTION_INPUTS = get("minecraft:brewing_potion_inputs"); public static final ItemCategory BUNDLES = get("minecraft:bundles"); public static final ItemCategory BUTTONS = get("minecraft:buttons"); public static final ItemCategory CAMEL_FOOD = get("minecraft:camel_food"); @@ -59,6 +60,7 @@ public final class ItemCategories { public static final ItemCategory CHEST_ARMOR = get("minecraft:chest_armor"); public static final ItemCategory CHEST_BOATS = get("minecraft:chest_boats"); public static final ItemCategory CHICKEN_FOOD = get("minecraft:chicken_food"); + public static final ItemCategory CLONABLE_MAPS = get("minecraft:clonable_maps"); public static final ItemCategory CLUSTER_MAX_HARVESTABLES = get("minecraft:cluster_max_harvestables"); public static final ItemCategory COAL_ORES = get("minecraft:coal_ores"); public static final ItemCategory COALS = get("minecraft:coals"); @@ -66,6 +68,8 @@ public final class ItemCategories { public static final ItemCategory COMPLETES_FIND_TREE_TUTORIAL = get("minecraft:completes_find_tree_tutorial"); public static final ItemCategory CONCRETE = get("minecraft:concrete"); public static final ItemCategory CONCRETE_POWDERS = get("minecraft:concrete_powders"); + public static final ItemCategory CONCRETE_SLABS = get("minecraft:concrete_slabs"); + public static final ItemCategory CONCRETE_STAIRS = get("minecraft:concrete_stairs"); public static final ItemCategory COPPER = get("minecraft:copper"); public static final ItemCategory COPPER_CHESTS = get("minecraft:copper_chests"); public static final ItemCategory COPPER_GOLEM_STATUES = get("minecraft:copper_golem_statues"); @@ -75,6 +79,7 @@ public final class ItemCategories { public static final ItemCategory CREEPER_DROP_MUSIC_DISCS = get("minecraft:creeper_drop_music_discs"); public static final ItemCategory CREEPER_IGNITERS = get("minecraft:creeper_igniters"); public static final ItemCategory CRIMSON_STEMS = get("minecraft:crimson_stems"); + public static final ItemCategory CUSHIONS = get("minecraft:cushions"); public static final ItemCategory DAMPENS_VIBRATIONS = get("minecraft:dampens_vibrations"); public static final ItemCategory DARK_OAK_LOGS = get("minecraft:dark_oak_logs"); public static final ItemCategory DECORATED_POT_INGREDIENTS = get("minecraft:decorated_pot_ingredients"); @@ -83,6 +88,7 @@ public final class ItemCategories { public static final ItemCategory DIAMOND_TOOL_MATERIALS = get("minecraft:diamond_tool_materials"); public static final ItemCategory DIRT = get("minecraft:dirt"); public static final ItemCategory DOORS = get("minecraft:doors"); + public static final ItemCategory DOUSES_CAMPFIRES = get("minecraft:douses_campfires"); public static final ItemCategory DROWNED_PREFERRED_WEAPONS = get("minecraft:drowned_preferred_weapons"); public static final ItemCategory DUPLICATES_ALLAYS = get("minecraft:duplicates_allays"); @Deprecated public static final ItemCategory DYEABLE = get("minecraft:dyeable"); @@ -111,6 +117,7 @@ public final class ItemCategories { public static final ItemCategory ENCHANTABLE_TRIDENT = get("minecraft:enchantable/trident"); public static final ItemCategory ENCHANTABLE_VANISHING = get("minecraft:enchantable/vanishing"); public static final ItemCategory ENCHANTABLE_WEAPON = get("minecraft:enchantable/weapon"); + public static final ItemCategory EXTENDABLE_MAPS = get("minecraft:extendable_maps"); public static final ItemCategory FENCE_GATES = get("minecraft:fence_gates"); public static final ItemCategory FENCES = get("minecraft:fences"); public static final ItemCategory FISHES = get("minecraft:fishes"); @@ -119,6 +126,7 @@ public final class ItemCategories { public static final ItemCategory FOX_FOOD = get("minecraft:fox_food"); public static final ItemCategory FREEZE_IMMUNE_WEARABLES = get("minecraft:freeze_immune_wearables"); public static final ItemCategory FROG_FOOD = get("minecraft:frog_food"); + public static final ItemCategory FURNACE_FUEL_BOTTOM_TAKEABLE = get("minecraft:furnace_fuel_bottom_takeable"); @Deprecated public static final ItemCategory FURNACE_MATERIALS = get("minecraft:furnace_materials"); public static final ItemCategory FURNACE_MINECART_FUEL = get("minecraft:furnace_minecart_fuel"); public static final ItemCategory GAZE_DISGUISE_EQUIPMENT = get("minecraft:gaze_disguise_equipment"); @@ -158,6 +166,7 @@ public final class ItemCategories { public static final ItemCategory METAL_NUGGETS = get("minecraft:metal_nuggets"); public static final ItemCategory MOSS_BLOCKS = get("minecraft:moss_blocks"); public static final ItemCategory MUD = get("minecraft:mud"); + public static final ItemCategory MUSHROOMS = get("minecraft:mushrooms"); @Deprecated public static final ItemCategory MUSIC_DISCS = get("minecraft:music_discs"); public static final ItemCategory NAUTILUS_BUCKET_FOOD = get("minecraft:nautilus_bucket_food"); public static final ItemCategory NAUTILUS_FOOD = get("minecraft:nautilus_food"); @@ -168,6 +177,7 @@ public final class ItemCategories { public static final ItemCategory OAK_LOGS = get("minecraft:oak_logs"); @Deprecated public static final ItemCategory OCCLUDES_VIBRATION_SIGNALS = get("minecraft:occludes_vibration_signals"); public static final ItemCategory OCELOT_FOOD = get("minecraft:ocelot_food"); + public static final ItemCategory ORES = get("minecraft:ores"); @Deprecated public static final ItemCategory OVERWORLD_NATURAL_LOGS = get("minecraft:overworld_natural_logs"); public static final ItemCategory PALE_OAK_LOGS = get("minecraft:pale_oak_logs"); public static final ItemCategory PANDA_EATS_FROM_GROUND = get("minecraft:panda_eats_from_ground"); @@ -183,6 +193,7 @@ public final class ItemCategories { public static final ItemCategory PIGLIN_SAFE_ARMOR = get("minecraft:piglin_safe_armor"); public static final ItemCategory PILLAGER_PREFERRED_WEAPONS = get("minecraft:pillager_preferred_weapons"); public static final ItemCategory PLANKS = get("minecraft:planks"); + public static final ItemCategory POPLAR_LOGS = get("minecraft:poplar_logs"); public static final ItemCategory RABBIT_FOOD = get("minecraft:rabbit_food"); public static final ItemCategory RAILS = get("minecraft:rails"); public static final ItemCategory REDSTONE_ORES = get("minecraft:redstone_ores"); @@ -260,6 +271,8 @@ public final class ItemCategories { public static final ItemCategory WOODEN_TRAPDOORS = get("minecraft:wooden_trapdoors"); public static final ItemCategory WOOL = get("minecraft:wool"); public static final ItemCategory WOOL_CARPETS = get("minecraft:wool_carpets"); + public static final ItemCategory WOOL_SLABS = get("minecraft:wool_slabs"); + public static final ItemCategory WOOL_STAIRS = get("minecraft:wool_stairs"); public static final ItemCategory ZOMBIE_HORSE_FOOD = get("minecraft:zombie_horse_food"); private ItemCategories() { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java index 80612a2a11..a2282a0901 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java @@ -28,6 +28,7 @@ */ @SuppressWarnings("unused") public final class ItemTypes { + @Nullable public static final ItemType ABANDONED_CAMP_MAP = get("minecraft:abandoned_camp_map"); @Nullable public static final ItemType ACACIA_BOAT = get("minecraft:acacia_boat"); @Nullable public static final ItemType ACACIA_BUTTON = get("minecraft:acacia_button"); @Nullable public static final ItemType ACACIA_CHEST_BOAT = get("minecraft:acacia_chest_boat"); @@ -132,6 +133,9 @@ 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_CONCRETE_SLAB = get("minecraft:black_concrete_slab"); + @Nullable public static final ItemType BLACK_CONCRETE_STAIRS = get("minecraft:black_concrete_stairs"); + @Nullable public static final ItemType BLACK_CUSHION = get("minecraft:black_cushion"); @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_HARNESS = get("minecraft:black_harness"); @@ -140,6 +144,8 @@ public final class ItemTypes { @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 BLACK_WOOL_SLAB = get("minecraft:black_wool_slab"); + @Nullable public static final ItemType BLACK_WOOL_STAIRS = get("minecraft:black_wool_stairs"); @Nullable public static final ItemType BLACKSTONE = get("minecraft:blackstone"); @Nullable public static final ItemType BLACKSTONE_SLAB = get("minecraft:blackstone_slab"); @Nullable public static final ItemType BLACKSTONE_STAIRS = get("minecraft:blackstone_stairs"); @@ -156,6 +162,9 @@ 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_CONCRETE_SLAB = get("minecraft:blue_concrete_slab"); + @Nullable public static final ItemType BLUE_CONCRETE_STAIRS = get("minecraft:blue_concrete_stairs"); + @Nullable public static final ItemType BLUE_CUSHION = get("minecraft:blue_cushion"); @Nullable public static final ItemType BLUE_DYE = get("minecraft:blue_dye"); @Nullable public static final ItemType BLUE_EGG = get("minecraft:blue_egg"); @Nullable public static final ItemType BLUE_GLAZED_TERRACOTTA = get("minecraft:blue_glazed_terracotta"); @@ -167,6 +176,8 @@ public final class ItemTypes { @Nullable public static final ItemType BLUE_STAINED_GLASS_PANE = get("minecraft:blue_stained_glass_pane"); @Nullable public static final ItemType BLUE_TERRACOTTA = get("minecraft:blue_terracotta"); @Nullable public static final ItemType BLUE_WOOL = get("minecraft:blue_wool"); + @Nullable public static final ItemType BLUE_WOOL_SLAB = get("minecraft:blue_wool_slab"); + @Nullable public static final ItemType BLUE_WOOL_STAIRS = get("minecraft:blue_wool_stairs"); @Nullable public static final ItemType BOGGED_SPAWN_EGG = get("minecraft:bogged_spawn_egg"); @Nullable public static final ItemType BOLT_ARMOR_TRIM_SMITHING_TEMPLATE = get("minecraft:bolt_armor_trim_smithing_template"); @Nullable public static final ItemType BONE = get("minecraft:bone"); @@ -197,6 +208,9 @@ public final class ItemTypes { @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_CONCRETE_SLAB = get("minecraft:brown_concrete_slab"); + @Nullable public static final ItemType BROWN_CONCRETE_STAIRS = get("minecraft:brown_concrete_stairs"); + @Nullable public static final ItemType BROWN_CUSHION = get("minecraft:brown_cushion"); @Nullable public static final ItemType BROWN_DYE = get("minecraft:brown_dye"); @Nullable public static final ItemType BROWN_EGG = get("minecraft:brown_egg"); @Nullable public static final ItemType BROWN_GLAZED_TERRACOTTA = get("minecraft:brown_glazed_terracotta"); @@ -208,6 +222,8 @@ public final class ItemTypes { @Nullable public static final ItemType BROWN_STAINED_GLASS_PANE = get("minecraft:brown_stained_glass_pane"); @Nullable public static final ItemType BROWN_TERRACOTTA = get("minecraft:brown_terracotta"); @Nullable public static final ItemType BROWN_WOOL = get("minecraft:brown_wool"); + @Nullable public static final ItemType BROWN_WOOL_SLAB = get("minecraft:brown_wool_slab"); + @Nullable public static final ItemType BROWN_WOOL_STAIRS = get("minecraft:brown_wool_stairs"); @Nullable public static final ItemType BRUSH = get("minecraft:brush"); @Nullable public static final ItemType BUBBLE_CORAL = get("minecraft:bubble_coral"); @Nullable public static final ItemType BUBBLE_CORAL_BLOCK = get("minecraft:bubble_coral_block"); @@ -215,6 +231,10 @@ public final class ItemTypes { @Nullable public static final ItemType BUCKET = get("minecraft:bucket"); @Nullable public static final ItemType BUDDING_AMETHYST = get("minecraft:budding_amethyst"); @Nullable public static final ItemType BUNDLE = get("minecraft:bundle"); + @Nullable public static final ItemType BURIED_ANCIENT_CITY_MAP = get("minecraft:buried_ancient_city_map"); + @Nullable public static final ItemType BURIED_MINESHAFT_MAP = get("minecraft:buried_mineshaft_map"); + @Nullable public static final ItemType BURIED_TREASURE_MAP = get("minecraft:buried_treasure_map"); + @Nullable public static final ItemType BURIED_TRIAL_CHAMBERS_MAP = get("minecraft:buried_trial_chambers_map"); @Nullable public static final ItemType BURN_POTTERY_SHERD = get("minecraft:burn_pottery_sherd"); @Nullable public static final ItemType BUSH = get("minecraft:bush"); @Nullable public static final ItemType CACTUS = get("minecraft:cactus"); @@ -399,6 +419,9 @@ public final class ItemTypes { @Nullable public static final ItemType CYAN_CARPET = get("minecraft:cyan_carpet"); @Nullable public static final ItemType CYAN_CONCRETE = get("minecraft:cyan_concrete"); @Nullable public static final ItemType CYAN_CONCRETE_POWDER = get("minecraft:cyan_concrete_powder"); + @Nullable public static final ItemType CYAN_CONCRETE_SLAB = get("minecraft:cyan_concrete_slab"); + @Nullable public static final ItemType CYAN_CONCRETE_STAIRS = get("minecraft:cyan_concrete_stairs"); + @Nullable public static final ItemType CYAN_CUSHION = get("minecraft:cyan_cushion"); @Nullable public static final ItemType CYAN_DYE = get("minecraft:cyan_dye"); @Nullable public static final ItemType CYAN_GLAZED_TERRACOTTA = get("minecraft:cyan_glazed_terracotta"); @Nullable public static final ItemType CYAN_HARNESS = get("minecraft:cyan_harness"); @@ -407,6 +430,8 @@ public final class ItemTypes { @Nullable public static final ItemType CYAN_STAINED_GLASS_PANE = get("minecraft:cyan_stained_glass_pane"); @Nullable public static final ItemType CYAN_TERRACOTTA = get("minecraft:cyan_terracotta"); @Nullable public static final ItemType CYAN_WOOL = get("minecraft:cyan_wool"); + @Nullable public static final ItemType CYAN_WOOL_SLAB = get("minecraft:cyan_wool_slab"); + @Nullable public static final ItemType CYAN_WOOL_STAIRS = get("minecraft:cyan_wool_stairs"); @Nullable public static final ItemType DAMAGED_ANVIL = get("minecraft:damaged_anvil"); @Nullable public static final ItemType DANDELION = get("minecraft:dandelion"); @Deprecated @Nullable public static final ItemType DANDELION_YELLOW = get("minecraft:dandelion_yellow"); @@ -468,6 +493,8 @@ public final class ItemTypes { @Nullable public static final ItemType DEEPSLATE_TILE_STAIRS = get("minecraft:deepslate_tile_stairs"); @Nullable public static final ItemType DEEPSLATE_TILE_WALL = get("minecraft:deepslate_tile_wall"); @Nullable public static final ItemType DEEPSLATE_TILES = get("minecraft:deepslate_tiles"); + @Nullable public static final ItemType DESERT_PYRAMID_MAP = get("minecraft:desert_pyramid_map"); + @Nullable public static final ItemType DESERT_VILLAGE_MAP = get("minecraft:desert_village_map"); @Nullable public static final ItemType DETECTOR_RAIL = get("minecraft:detector_rail"); @Nullable public static final ItemType DIAMOND = get("minecraft:diamond"); @Nullable public static final ItemType DIAMOND_AXE = get("minecraft:diamond_axe"); @@ -628,6 +655,9 @@ public final class ItemTypes { @Nullable public static final ItemType GRAY_CARPET = get("minecraft:gray_carpet"); @Nullable public static final ItemType GRAY_CONCRETE = get("minecraft:gray_concrete"); @Nullable public static final ItemType GRAY_CONCRETE_POWDER = get("minecraft:gray_concrete_powder"); + @Nullable public static final ItemType GRAY_CONCRETE_SLAB = get("minecraft:gray_concrete_slab"); + @Nullable public static final ItemType GRAY_CONCRETE_STAIRS = get("minecraft:gray_concrete_stairs"); + @Nullable public static final ItemType GRAY_CUSHION = get("minecraft:gray_cushion"); @Nullable public static final ItemType GRAY_DYE = get("minecraft:gray_dye"); @Nullable public static final ItemType GRAY_GLAZED_TERRACOTTA = get("minecraft:gray_glazed_terracotta"); @Nullable public static final ItemType GRAY_HARNESS = get("minecraft:gray_harness"); @@ -636,6 +666,8 @@ public final class ItemTypes { @Nullable public static final ItemType GRAY_STAINED_GLASS_PANE = get("minecraft:gray_stained_glass_pane"); @Nullable public static final ItemType GRAY_TERRACOTTA = get("minecraft:gray_terracotta"); @Nullable public static final ItemType GRAY_WOOL = get("minecraft:gray_wool"); + @Nullable public static final ItemType GRAY_WOOL_SLAB = get("minecraft:gray_wool_slab"); + @Nullable public static final ItemType GRAY_WOOL_STAIRS = get("minecraft:gray_wool_stairs"); @Nullable public static final ItemType GREEN_BANNER = get("minecraft:green_banner"); @Nullable public static final ItemType GREEN_BED = get("minecraft:green_bed"); @Nullable public static final ItemType GREEN_BUNDLE = get("minecraft:green_bundle"); @@ -643,6 +675,9 @@ 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_CONCRETE_SLAB = get("minecraft:green_concrete_slab"); + @Nullable public static final ItemType GREEN_CONCRETE_STAIRS = get("minecraft:green_concrete_stairs"); + @Nullable public static final ItemType GREEN_CUSHION = get("minecraft:green_cushion"); @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_HARNESS = get("minecraft:green_harness"); @@ -651,6 +686,8 @@ public final class ItemTypes { @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 GREEN_WOOL_SLAB = get("minecraft:green_wool_slab"); + @Nullable public static final ItemType GREEN_WOOL_STAIRS = get("minecraft:green_wool_stairs"); @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"); @@ -723,6 +760,7 @@ public final class ItemTypes { @Nullable public static final ItemType JUNGLE_LOG = get("minecraft:jungle_log"); @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_PYRAMID_MAP = get("minecraft:jungle_pyramid_map"); @Nullable public static final ItemType JUNGLE_SAPLING = get("minecraft:jungle_sapling"); @Nullable public static final ItemType JUNGLE_SHELF = get("minecraft:jungle_shelf"); @Nullable public static final ItemType JUNGLE_SIGN = get("minecraft:jungle_sign"); @@ -758,6 +796,9 @@ public final class ItemTypes { @Nullable public static final ItemType LIGHT_BLUE_CARPET = get("minecraft:light_blue_carpet"); @Nullable public static final ItemType LIGHT_BLUE_CONCRETE = get("minecraft:light_blue_concrete"); @Nullable public static final ItemType LIGHT_BLUE_CONCRETE_POWDER = get("minecraft:light_blue_concrete_powder"); + @Nullable public static final ItemType LIGHT_BLUE_CONCRETE_SLAB = get("minecraft:light_blue_concrete_slab"); + @Nullable public static final ItemType LIGHT_BLUE_CONCRETE_STAIRS = get("minecraft:light_blue_concrete_stairs"); + @Nullable public static final ItemType LIGHT_BLUE_CUSHION = get("minecraft:light_blue_cushion"); @Nullable public static final ItemType LIGHT_BLUE_DYE = get("minecraft:light_blue_dye"); @Nullable public static final ItemType LIGHT_BLUE_GLAZED_TERRACOTTA = get("minecraft:light_blue_glazed_terracotta"); @Nullable public static final ItemType LIGHT_BLUE_HARNESS = get("minecraft:light_blue_harness"); @@ -766,6 +807,8 @@ public final class ItemTypes { @Nullable public static final ItemType LIGHT_BLUE_STAINED_GLASS_PANE = get("minecraft:light_blue_stained_glass_pane"); @Nullable public static final ItemType LIGHT_BLUE_TERRACOTTA = get("minecraft:light_blue_terracotta"); @Nullable public static final ItemType LIGHT_BLUE_WOOL = get("minecraft:light_blue_wool"); + @Nullable public static final ItemType LIGHT_BLUE_WOOL_SLAB = get("minecraft:light_blue_wool_slab"); + @Nullable public static final ItemType LIGHT_BLUE_WOOL_STAIRS = get("minecraft:light_blue_wool_stairs"); @Nullable public static final ItemType LIGHT_GRAY_BANNER = get("minecraft:light_gray_banner"); @Nullable public static final ItemType LIGHT_GRAY_BED = get("minecraft:light_gray_bed"); @Nullable public static final ItemType LIGHT_GRAY_BUNDLE = get("minecraft:light_gray_bundle"); @@ -773,6 +816,9 @@ public final class ItemTypes { @Nullable public static final ItemType LIGHT_GRAY_CARPET = get("minecraft:light_gray_carpet"); @Nullable public static final ItemType LIGHT_GRAY_CONCRETE = get("minecraft:light_gray_concrete"); @Nullable public static final ItemType LIGHT_GRAY_CONCRETE_POWDER = get("minecraft:light_gray_concrete_powder"); + @Nullable public static final ItemType LIGHT_GRAY_CONCRETE_SLAB = get("minecraft:light_gray_concrete_slab"); + @Nullable public static final ItemType LIGHT_GRAY_CONCRETE_STAIRS = get("minecraft:light_gray_concrete_stairs"); + @Nullable public static final ItemType LIGHT_GRAY_CUSHION = get("minecraft:light_gray_cushion"); @Nullable public static final ItemType LIGHT_GRAY_DYE = get("minecraft:light_gray_dye"); @Nullable public static final ItemType LIGHT_GRAY_GLAZED_TERRACOTTA = get("minecraft:light_gray_glazed_terracotta"); @Nullable public static final ItemType LIGHT_GRAY_HARNESS = get("minecraft:light_gray_harness"); @@ -781,6 +827,8 @@ public final class ItemTypes { @Nullable public static final ItemType LIGHT_GRAY_STAINED_GLASS_PANE = get("minecraft:light_gray_stained_glass_pane"); @Nullable public static final ItemType LIGHT_GRAY_TERRACOTTA = get("minecraft:light_gray_terracotta"); @Nullable public static final ItemType LIGHT_GRAY_WOOL = get("minecraft:light_gray_wool"); + @Nullable public static final ItemType LIGHT_GRAY_WOOL_SLAB = get("minecraft:light_gray_wool_slab"); + @Nullable public static final ItemType LIGHT_GRAY_WOOL_STAIRS = get("minecraft:light_gray_wool_stairs"); @Nullable public static final ItemType LIGHT_WEIGHTED_PRESSURE_PLATE = get("minecraft:light_weighted_pressure_plate"); @Nullable public static final ItemType LIGHTNING_ROD = get("minecraft:lightning_rod"); @Nullable public static final ItemType LILAC = get("minecraft:lilac"); @@ -793,6 +841,9 @@ public final class ItemTypes { @Nullable public static final ItemType LIME_CARPET = get("minecraft:lime_carpet"); @Nullable public static final ItemType LIME_CONCRETE = get("minecraft:lime_concrete"); @Nullable public static final ItemType LIME_CONCRETE_POWDER = get("minecraft:lime_concrete_powder"); + @Nullable public static final ItemType LIME_CONCRETE_SLAB = get("minecraft:lime_concrete_slab"); + @Nullable public static final ItemType LIME_CONCRETE_STAIRS = get("minecraft:lime_concrete_stairs"); + @Nullable public static final ItemType LIME_CUSHION = get("minecraft:lime_cushion"); @Nullable public static final ItemType LIME_DYE = get("minecraft:lime_dye"); @Nullable public static final ItemType LIME_GLAZED_TERRACOTTA = get("minecraft:lime_glazed_terracotta"); @Nullable public static final ItemType LIME_HARNESS = get("minecraft:lime_harness"); @@ -801,6 +852,8 @@ public final class ItemTypes { @Nullable public static final ItemType LIME_STAINED_GLASS_PANE = get("minecraft:lime_stained_glass_pane"); @Nullable public static final ItemType LIME_TERRACOTTA = get("minecraft:lime_terracotta"); @Nullable public static final ItemType LIME_WOOL = get("minecraft:lime_wool"); + @Nullable public static final ItemType LIME_WOOL_SLAB = get("minecraft:lime_wool_slab"); + @Nullable public static final ItemType LIME_WOOL_STAIRS = get("minecraft:lime_wool_stairs"); @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 LODESTONE = get("minecraft:lodestone"); @@ -813,6 +866,9 @@ public final class ItemTypes { @Nullable public static final ItemType MAGENTA_CARPET = get("minecraft:magenta_carpet"); @Nullable public static final ItemType MAGENTA_CONCRETE = get("minecraft:magenta_concrete"); @Nullable public static final ItemType MAGENTA_CONCRETE_POWDER = get("minecraft:magenta_concrete_powder"); + @Nullable public static final ItemType MAGENTA_CONCRETE_SLAB = get("minecraft:magenta_concrete_slab"); + @Nullable public static final ItemType MAGENTA_CONCRETE_STAIRS = get("minecraft:magenta_concrete_stairs"); + @Nullable public static final ItemType MAGENTA_CUSHION = get("minecraft:magenta_cushion"); @Nullable public static final ItemType MAGENTA_DYE = get("minecraft:magenta_dye"); @Nullable public static final ItemType MAGENTA_GLAZED_TERRACOTTA = get("minecraft:magenta_glazed_terracotta"); @Nullable public static final ItemType MAGENTA_HARNESS = get("minecraft:magenta_harness"); @@ -821,6 +877,8 @@ public final class ItemTypes { @Nullable public static final ItemType MAGENTA_STAINED_GLASS_PANE = get("minecraft:magenta_stained_glass_pane"); @Nullable public static final ItemType MAGENTA_TERRACOTTA = get("minecraft:magenta_terracotta"); @Nullable public static final ItemType MAGENTA_WOOL = get("minecraft:magenta_wool"); + @Nullable public static final ItemType MAGENTA_WOOL_SLAB = get("minecraft:magenta_wool_slab"); + @Nullable public static final ItemType MAGENTA_WOOL_STAIRS = get("minecraft:magenta_wool_stairs"); @Nullable public static final ItemType MAGMA_BLOCK = get("minecraft:magma_block"); @Nullable public static final ItemType MAGMA_CREAM = get("minecraft:magma_cream"); @Nullable public static final ItemType MAGMA_CUBE_SPAWN_EGG = get("minecraft:magma_cube_spawn_egg"); @@ -950,6 +1008,7 @@ public final class ItemTypes { @Nullable public static final ItemType OAK_WOOD = get("minecraft:oak_wood"); @Nullable public static final ItemType OBSERVER = get("minecraft:observer"); @Nullable public static final ItemType OBSIDIAN = get("minecraft:obsidian"); + @Nullable public static final ItemType OCEAN_MONUMENT_MAP = get("minecraft:ocean_monument_map"); @Nullable public static final ItemType OCELOT_SPAWN_EGG = get("minecraft:ocelot_spawn_egg"); @Nullable public static final ItemType OCHRE_FROGLIGHT = get("minecraft:ochre_froglight"); @Nullable public static final ItemType OMINOUS_BOTTLE = get("minecraft:ominous_bottle"); @@ -962,15 +1021,21 @@ public final class ItemTypes { @Nullable public static final ItemType ORANGE_CARPET = get("minecraft:orange_carpet"); @Nullable public static final ItemType ORANGE_CONCRETE = get("minecraft:orange_concrete"); @Nullable public static final ItemType ORANGE_CONCRETE_POWDER = get("minecraft:orange_concrete_powder"); + @Nullable public static final ItemType ORANGE_CONCRETE_SLAB = get("minecraft:orange_concrete_slab"); + @Nullable public static final ItemType ORANGE_CONCRETE_STAIRS = get("minecraft:orange_concrete_stairs"); + @Nullable public static final ItemType ORANGE_CUSHION = get("minecraft:orange_cushion"); @Nullable public static final ItemType ORANGE_DYE = get("minecraft:orange_dye"); @Nullable public static final ItemType ORANGE_GLAZED_TERRACOTTA = get("minecraft:orange_glazed_terracotta"); @Nullable public static final ItemType ORANGE_HARNESS = get("minecraft:orange_harness"); + @Nullable public static final ItemType ORANGE_POPLAR_LEAVES = get("minecraft:orange_poplar_leaves"); @Nullable public static final ItemType ORANGE_SHULKER_BOX = get("minecraft:orange_shulker_box"); @Nullable public static final ItemType ORANGE_STAINED_GLASS = get("minecraft:orange_stained_glass"); @Nullable public static final ItemType ORANGE_STAINED_GLASS_PANE = get("minecraft:orange_stained_glass_pane"); @Nullable public static final ItemType ORANGE_TERRACOTTA = get("minecraft:orange_terracotta"); @Nullable public static final ItemType ORANGE_TULIP = get("minecraft:orange_tulip"); @Nullable public static final ItemType ORANGE_WOOL = get("minecraft:orange_wool"); + @Nullable public static final ItemType ORANGE_WOOL_SLAB = get("minecraft:orange_wool_slab"); + @Nullable public static final ItemType ORANGE_WOOL_STAIRS = get("minecraft:orange_wool_stairs"); @Nullable public static final ItemType OXEYE_DAISY = get("minecraft:oxeye_daisy"); @Nullable public static final ItemType OXIDIZED_CHISELED_COPPER = get("minecraft:oxidized_chiseled_copper"); @Nullable public static final ItemType OXIDIZED_COPPER = get("minecraft:oxidized_copper"); @@ -1033,6 +1098,9 @@ public final class ItemTypes { @Nullable public static final ItemType PINK_CARPET = get("minecraft:pink_carpet"); @Nullable public static final ItemType PINK_CONCRETE = get("minecraft:pink_concrete"); @Nullable public static final ItemType PINK_CONCRETE_POWDER = get("minecraft:pink_concrete_powder"); + @Nullable public static final ItemType PINK_CONCRETE_SLAB = get("minecraft:pink_concrete_slab"); + @Nullable public static final ItemType PINK_CONCRETE_STAIRS = get("minecraft:pink_concrete_stairs"); + @Nullable public static final ItemType PINK_CUSHION = get("minecraft:pink_cushion"); @Nullable public static final ItemType PINK_DYE = get("minecraft:pink_dye"); @Nullable public static final ItemType PINK_GLAZED_TERRACOTTA = get("minecraft:pink_glazed_terracotta"); @Nullable public static final ItemType PINK_HARNESS = get("minecraft:pink_harness"); @@ -1043,9 +1111,12 @@ public final class ItemTypes { @Nullable public static final ItemType PINK_TERRACOTTA = get("minecraft:pink_terracotta"); @Nullable public static final ItemType PINK_TULIP = get("minecraft:pink_tulip"); @Nullable public static final ItemType PINK_WOOL = get("minecraft:pink_wool"); + @Nullable public static final ItemType PINK_WOOL_SLAB = get("minecraft:pink_wool_slab"); + @Nullable public static final ItemType PINK_WOOL_STAIRS = get("minecraft:pink_wool_stairs"); @Nullable public static final ItemType PISTON = get("minecraft:piston"); @Nullable public static final ItemType PITCHER_PLANT = get("minecraft:pitcher_plant"); @Nullable public static final ItemType PITCHER_POD = get("minecraft:pitcher_pod"); + @Nullable public static final ItemType PLAINS_VILLAGE_MAP = get("minecraft:plains_village_map"); @Nullable public static final ItemType PLAYER_HEAD = get("minecraft:player_head"); @Nullable public static final ItemType PLENTY_POTTERY_SHERD = get("minecraft:plenty_pottery_sherd"); @Nullable public static final ItemType PODZOL = get("minecraft:podzol"); @@ -1088,6 +1159,23 @@ public final class ItemTypes { @Nullable public static final ItemType POLISHED_TUFF_SLAB = get("minecraft:polished_tuff_slab"); @Nullable public static final ItemType POLISHED_TUFF_STAIRS = get("minecraft:polished_tuff_stairs"); @Nullable public static final ItemType POLISHED_TUFF_WALL = get("minecraft:polished_tuff_wall"); + @Nullable public static final ItemType POPLAR_BOAT = get("minecraft:poplar_boat"); + @Nullable public static final ItemType POPLAR_BUTTON = get("minecraft:poplar_button"); + @Nullable public static final ItemType POPLAR_CHEST_BOAT = get("minecraft:poplar_chest_boat"); + @Nullable public static final ItemType POPLAR_DOOR = get("minecraft:poplar_door"); + @Nullable public static final ItemType POPLAR_FENCE = get("minecraft:poplar_fence"); + @Nullable public static final ItemType POPLAR_FENCE_GATE = get("minecraft:poplar_fence_gate"); + @Nullable public static final ItemType POPLAR_HANGING_SIGN = get("minecraft:poplar_hanging_sign"); + @Nullable public static final ItemType POPLAR_LOG = get("minecraft:poplar_log"); + @Nullable public static final ItemType POPLAR_PLANKS = get("minecraft:poplar_planks"); + @Nullable public static final ItemType POPLAR_PRESSURE_PLATE = get("minecraft:poplar_pressure_plate"); + @Nullable public static final ItemType POPLAR_SAPLING = get("minecraft:poplar_sapling"); + @Nullable public static final ItemType POPLAR_SHELF = get("minecraft:poplar_shelf"); + @Nullable public static final ItemType POPLAR_SIGN = get("minecraft:poplar_sign"); + @Nullable public static final ItemType POPLAR_SLAB = get("minecraft:poplar_slab"); + @Nullable public static final ItemType POPLAR_STAIRS = get("minecraft:poplar_stairs"); + @Nullable public static final ItemType POPLAR_TRAPDOOR = get("minecraft:poplar_trapdoor"); + @Nullable public static final ItemType POPLAR_WOOD = get("minecraft:poplar_wood"); @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"); @@ -1119,6 +1207,9 @@ public final class ItemTypes { @Nullable public static final ItemType PURPLE_CARPET = get("minecraft:purple_carpet"); @Nullable public static final ItemType PURPLE_CONCRETE = get("minecraft:purple_concrete"); @Nullable public static final ItemType PURPLE_CONCRETE_POWDER = get("minecraft:purple_concrete_powder"); + @Nullable public static final ItemType PURPLE_CONCRETE_SLAB = get("minecraft:purple_concrete_slab"); + @Nullable public static final ItemType PURPLE_CONCRETE_STAIRS = get("minecraft:purple_concrete_stairs"); + @Nullable public static final ItemType PURPLE_CUSHION = get("minecraft:purple_cushion"); @Nullable public static final ItemType PURPLE_DYE = get("minecraft:purple_dye"); @Nullable public static final ItemType PURPLE_GLAZED_TERRACOTTA = get("minecraft:purple_glazed_terracotta"); @Nullable public static final ItemType PURPLE_HARNESS = get("minecraft:purple_harness"); @@ -1127,6 +1218,8 @@ public final class ItemTypes { @Nullable public static final ItemType PURPLE_STAINED_GLASS_PANE = get("minecraft:purple_stained_glass_pane"); @Nullable public static final ItemType PURPLE_TERRACOTTA = get("minecraft:purple_terracotta"); @Nullable public static final ItemType PURPLE_WOOL = get("minecraft:purple_wool"); + @Nullable public static final ItemType PURPLE_WOOL_SLAB = get("minecraft:purple_wool_slab"); + @Nullable public static final ItemType PURPLE_WOOL_STAIRS = get("minecraft:purple_wool_stairs"); @Nullable public static final ItemType PURPUR_BLOCK = get("minecraft:purpur_block"); @Nullable public static final ItemType PURPUR_PILLAR = get("minecraft:purpur_pillar"); @Nullable public static final ItemType PURPUR_SLAB = get("minecraft:purpur_slab"); @@ -1159,6 +1252,9 @@ public final class ItemTypes { @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_CONCRETE_SLAB = get("minecraft:red_concrete_slab"); + @Nullable public static final ItemType RED_CONCRETE_STAIRS = get("minecraft:red_concrete_stairs"); + @Nullable public static final ItemType RED_CUSHION = get("minecraft:red_cushion"); @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_HARNESS = get("minecraft:red_harness"); @@ -1168,17 +1264,21 @@ public final class ItemTypes { @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_POPLAR_LEAVES = get("minecraft:red_poplar_leaves"); @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_SHRUB = get("minecraft:red_shrub"); @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"); @Nullable public static final ItemType RED_TERRACOTTA = get("minecraft:red_terracotta"); @Nullable public static final ItemType RED_TULIP = get("minecraft:red_tulip"); @Nullable public static final ItemType RED_WOOL = get("minecraft:red_wool"); + @Nullable public static final ItemType RED_WOOL_SLAB = get("minecraft:red_wool_slab"); + @Nullable public static final ItemType RED_WOOL_STAIRS = get("minecraft:red_wool_stairs"); @Nullable public static final ItemType REDSTONE = get("minecraft:redstone"); @Nullable public static final ItemType REDSTONE_BLOCK = get("minecraft:redstone_block"); @Nullable public static final ItemType REDSTONE_LAMP = get("minecraft:redstone_lamp"); @@ -1209,6 +1309,7 @@ public final class ItemTypes { @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 SAVANNA_VILLAGE_MAP = get("minecraft:savanna_village_map"); @Nullable public static final ItemType SCAFFOLDING = get("minecraft:scaffolding"); @Nullable public static final ItemType SCRAPE_POTTERY_SHERD = get("minecraft:scrape_pottery_sherd"); @Nullable public static final ItemType SCULK = get("minecraft:sculk"); @@ -1225,6 +1326,7 @@ public final class ItemTypes { @Nullable public static final ItemType SHEAF_POTTERY_SHERD = get("minecraft:sheaf_pottery_sherd"); @Nullable public static final ItemType SHEARS = get("minecraft:shears"); @Nullable public static final ItemType SHEEP_SPAWN_EGG = get("minecraft:sheep_spawn_egg"); + @Nullable public static final ItemType SHELF_MUSHROOM = get("minecraft:shelf_mushroom"); @Nullable public static final ItemType SHELTER_POTTERY_SHERD = get("minecraft:shelter_pottery_sherd"); @Nullable public static final ItemType SHIELD = get("minecraft:shield"); @Nullable public static final ItemType SHORT_DRY_GRASS = get("minecraft:short_dry_grass"); @@ -1268,6 +1370,7 @@ public final class ItemTypes { @Nullable public static final ItemType SNOW_BLOCK = get("minecraft:snow_block"); @Nullable public static final ItemType SNOW_GOLEM_SPAWN_EGG = get("minecraft:snow_golem_spawn_egg"); @Nullable public static final ItemType SNOWBALL = get("minecraft:snowball"); + @Nullable public static final ItemType SNOWY_VILLAGE_MAP = get("minecraft:snowy_village_map"); @Nullable public static final ItemType SOUL_CAMPFIRE = get("minecraft:soul_campfire"); @Nullable public static final ItemType SOUL_LANTERN = get("minecraft:soul_lantern"); @Nullable public static final ItemType SOUL_SAND = get("minecraft:soul_sand"); @@ -1319,6 +1422,7 @@ public final class ItemTypes { @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 STRAW_BED = get("minecraft:straw_bed"); @Nullable public static final ItemType STRAY_SPAWN_EGG = get("minecraft:stray_spawn_egg"); @Nullable public static final ItemType STRIDER_SPAWN_EGG = get("minecraft:strider_spawn_egg"); @Nullable public static final ItemType STRING = get("minecraft:string"); @@ -1341,6 +1445,8 @@ public final class ItemTypes { @Nullable public static final ItemType STRIPPED_OAK_WOOD = get("minecraft:stripped_oak_wood"); @Nullable public static final ItemType STRIPPED_PALE_OAK_LOG = get("minecraft:stripped_pale_oak_log"); @Nullable public static final ItemType STRIPPED_PALE_OAK_WOOD = get("minecraft:stripped_pale_oak_wood"); + @Nullable public static final ItemType STRIPPED_POPLAR_LOG = get("minecraft:stripped_poplar_log"); + @Nullable public static final ItemType STRIPPED_POPLAR_WOOD = get("minecraft:stripped_poplar_wood"); @Nullable public static final ItemType STRIPPED_SPRUCE_LOG = get("minecraft:stripped_spruce_log"); @Nullable public static final ItemType STRIPPED_SPRUCE_WOOD = get("minecraft:stripped_spruce_wood"); @Nullable public static final ItemType STRIPPED_WARPED_HYPHAE = get("minecraft:stripped_warped_hyphae"); @@ -1364,9 +1470,11 @@ public final class ItemTypes { @Nullable public static final ItemType SUSPICIOUS_GRAVEL = get("minecraft:suspicious_gravel"); @Nullable public static final ItemType SUSPICIOUS_SAND = get("minecraft:suspicious_sand"); @Nullable public static final ItemType SUSPICIOUS_STEW = get("minecraft:suspicious_stew"); + @Nullable public static final ItemType SWAMP_HUT_MAP = get("minecraft:swamp_hut_map"); @Nullable public static final ItemType SWEET_BERRIES = get("minecraft:sweet_berries"); @Nullable public static final ItemType TADPOLE_BUCKET = get("minecraft:tadpole_bucket"); @Nullable public static final ItemType TADPOLE_SPAWN_EGG = get("minecraft:tadpole_spawn_egg"); + @Nullable public static final ItemType TAIGA_VILLAGE_MAP = get("minecraft:taiga_village_map"); @Nullable public static final ItemType TALL_DRY_GRASS = get("minecraft:tall_dry_grass"); @Nullable public static final ItemType TALL_GRASS = get("minecraft:tall_grass"); @Nullable public static final ItemType TARGET = get("minecraft:target"); @@ -1417,6 +1525,7 @@ public final class ItemTypes { @Nullable public static final ItemType WANDERING_TRADER_SPAWN_EGG = get("minecraft:wandering_trader_spawn_egg"); @Nullable public static final ItemType WARD_ARMOR_TRIM_SMITHING_TEMPLATE = get("minecraft:ward_armor_trim_smithing_template"); @Nullable public static final ItemType WARDEN_SPAWN_EGG = get("minecraft:warden_spawn_egg"); + @Nullable public static final ItemType WARM_OCEAN_RUINS_MAP = get("minecraft:warm_ocean_ruins_map"); @Nullable public static final ItemType WARPED_BUTTON = get("minecraft:warped_button"); @Nullable public static final ItemType WARPED_DOOR = get("minecraft:warped_door"); @Nullable public static final ItemType WARPED_FENCE = get("minecraft:warped_fence"); @@ -1524,6 +1633,9 @@ 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_CONCRETE_SLAB = get("minecraft:white_concrete_slab"); + @Nullable public static final ItemType WHITE_CONCRETE_STAIRS = get("minecraft:white_concrete_stairs"); + @Nullable public static final ItemType WHITE_CUSHION = get("minecraft:white_cushion"); @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_HARNESS = get("minecraft:white_harness"); @@ -1533,6 +1645,8 @@ public final class ItemTypes { @Nullable public static final ItemType WHITE_TERRACOTTA = get("minecraft:white_terracotta"); @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 WHITE_WOOL_SLAB = get("minecraft:white_wool_slab"); + @Nullable public static final ItemType WHITE_WOOL_STAIRS = get("minecraft:white_wool_stairs"); @Nullable public static final ItemType WILD_ARMOR_TRIM_SMITHING_TEMPLATE = get("minecraft:wild_armor_trim_smithing_template"); @Nullable public static final ItemType WILDFLOWERS = get("minecraft:wildflowers"); @Nullable public static final ItemType WIND_CHARGE = get("minecraft:wind_charge"); @@ -1549,6 +1663,7 @@ public final class ItemTypes { @Nullable public static final ItemType WOODEN_SHOVEL = get("minecraft:wooden_shovel"); @Nullable public static final ItemType WOODEN_SPEAR = get("minecraft:wooden_spear"); @Nullable public static final ItemType WOODEN_SWORD = get("minecraft:wooden_sword"); + @Nullable public static final ItemType WOODLAND_MANSION_MAP = get("minecraft:woodland_mansion_map"); @Nullable public static final ItemType WRITABLE_BOOK = get("minecraft:writable_book"); @Nullable public static final ItemType WRITTEN_BOOK = get("minecraft:written_book"); @Nullable public static final ItemType YELLOW_BANNER = get("minecraft:yellow_banner"); @@ -1558,14 +1673,20 @@ 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_CONCRETE_SLAB = get("minecraft:yellow_concrete_slab"); + @Nullable public static final ItemType YELLOW_CONCRETE_STAIRS = get("minecraft:yellow_concrete_stairs"); + @Nullable public static final ItemType YELLOW_CUSHION = get("minecraft:yellow_cushion"); @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_HARNESS = get("minecraft:yellow_harness"); + @Nullable public static final ItemType YELLOW_POPLAR_LEAVES = get("minecraft:yellow_poplar_leaves"); @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"); @Nullable public static final ItemType YELLOW_STAINED_GLASS_PANE = get("minecraft:yellow_stained_glass_pane"); @Nullable public static final ItemType YELLOW_TERRACOTTA = get("minecraft:yellow_terracotta"); @Nullable public static final ItemType YELLOW_WOOL = get("minecraft:yellow_wool"); + @Nullable public static final ItemType YELLOW_WOOL_SLAB = get("minecraft:yellow_wool_slab"); + @Nullable public static final ItemType YELLOW_WOOL_STAIRS = get("minecraft:yellow_wool_stairs"); @Nullable public static final ItemType ZOGLIN_SPAWN_EGG = get("minecraft:zoglin_spawn_egg"); @Nullable public static final ItemType ZOMBIE_HEAD = get("minecraft:zombie_head"); @Nullable public static final ItemType ZOMBIE_HORSE_SPAWN_EGG = get("minecraft:zombie_horse_spawn_egg"); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockMaterial.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockMaterial.java index d280f2cc0e..70682b18e7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockMaterial.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockMaterial.java @@ -119,7 +119,9 @@ public interface BlockMaterial { * Get whether this block prevents movement. * * @return true if this block blocks movement + * @deprecated Minecraft no longer uses this concept. Use {@link #isSolid()} instead. */ + @Deprecated boolean isMovementBlocker(); /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/PassthroughBlockMaterial.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/PassthroughBlockMaterial.java index e868276a63..dc0a52fdab 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/PassthroughBlockMaterial.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/PassthroughBlockMaterial.java @@ -109,6 +109,7 @@ public boolean isTicksRandomly() { } @Override + @SuppressWarnings("deprecation") public boolean isMovementBlocker() { return blockMaterial.isMovementBlocker(); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/SimpleBlockMaterial.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/SimpleBlockMaterial.java index de70a38619..36cab7e784 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/SimpleBlockMaterial.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/SimpleBlockMaterial.java @@ -159,6 +159,7 @@ public void setTicksRandomly(boolean ticksRandomly) { } @Override + @SuppressWarnings("deprecation") public boolean isMovementBlocker() { return movementBlocker; } diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeBlockMaterial.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeBlockMaterial.java index 4dd6622de4..1c6bdb9bbe 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeBlockMaterial.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeBlockMaterial.java @@ -95,12 +95,12 @@ public int getLightValue() { @Override public boolean isFragileWhenPushed() { - return block.getPistonPushReaction() == PushReaction.DESTROY; + return block.getPistonPushReaction() == PushReaction.POPPED; } @Override public boolean isUnpushable() { - return block.getPistonPushReaction() == PushReaction.BLOCK; + return block.getPistonPushReaction() == PushReaction.IMMOVEABLE; } @Override @@ -111,7 +111,7 @@ public boolean isTicksRandomly() { @Override @SuppressWarnings("deprecation") public boolean isMovementBlocker() { - return block.blocksMotion(); + return block.isSolid(); } @Override