Update to Minecraft 1.19.3

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2022-12-08 03:00:00 +11:00
parent a13136ada2
commit 8b26bb8f3e
305 changed files with 3331 additions and 2864 deletions

View File

@@ -4,7 +4,7 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap;
import net.minecraft.core.Holder;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.entity.decoration.PaintingVariant;
import org.bukkit.Art;
@@ -14,8 +14,8 @@ public class CraftArt {
static {
ImmutableBiMap.Builder<Holder<PaintingVariant>, Art> artworkBuilder = ImmutableBiMap.builder();
for (ResourceKey<PaintingVariant> key : IRegistry.PAINTING_VARIANT.registryKeySet()) {
artworkBuilder.put(IRegistry.PAINTING_VARIANT.getHolderOrThrow(key), Art.getByName(key.location().getPath()));
for (ResourceKey<PaintingVariant> key : BuiltInRegistries.PAINTING_VARIANT.registryKeySet()) {
artworkBuilder.put(BuiltInRegistries.PAINTING_VARIANT.getHolderOrThrow(key), Art.getByName(key.location().getPath()));
}
artwork = artworkBuilder.build();

View File

@@ -14,6 +14,7 @@ import net.minecraft.core.BlockPosition;
import net.minecraft.core.Holder;
import net.minecraft.core.IRegistry;
import net.minecraft.core.SectionPosition;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.DynamicOpsNBT;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.level.WorldServer;
@@ -296,7 +297,7 @@ public class CraftChunk implements Chunk {
boolean[] sectionEmpty = new boolean[cs.length];
PalettedContainerRO<Holder<BiomeBase>>[] biome = (includeBiome || includeBiomeTempRain) ? new DataPaletteBlock[cs.length] : null;
IRegistry<BiomeBase> iregistry = worldServer.registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY);
IRegistry<BiomeBase> iregistry = worldServer.registryAccess().registryOrThrow(Registries.BIOME);
Codec<PalettedContainerRO<Holder<BiomeBase>>> biomeCodec = DataPaletteBlock.codecRO(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.d.SECTION_BIOMES, iregistry.getHolderOrThrow(Biomes.PLAINS));
for (int i = 0; i < cs.length; i++) {
@@ -352,7 +353,7 @@ public class CraftChunk implements Chunk {
byte[][] skyLight = new byte[hSection][];
byte[][] emitLight = new byte[hSection][];
boolean[] empty = new boolean[hSection];
IRegistry<BiomeBase> iregistry = world.getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY);
IRegistry<BiomeBase> iregistry = world.getHandle().registryAccess().registryOrThrow(Registries.BIOME);
DataPaletteBlock<Holder<BiomeBase>>[] biome = (includeBiome || includeBiomeTempRain) ? new DataPaletteBlock[hSection] : null;
Codec<PalettedContainerRO<Holder<BiomeBase>>> biomeCodec = DataPaletteBlock.codecRO(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.d.SECTION_BIOMES, iregistry.getHolderOrThrow(Biomes.PLAINS));

View File

@@ -3,11 +3,9 @@ package org.bukkit.craftbukkit;
import com.google.common.base.Preconditions;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.mojang.math.Vector3fa;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.IRegistry;
import net.minecraft.core.particles.DustColorTransitionOptions;
import net.minecraft.core.particles.ParticleParam;
import net.minecraft.core.particles.ParticleParamBlock;
@@ -17,6 +15,7 @@ import net.minecraft.core.particles.ParticleType;
import net.minecraft.core.particles.SculkChargeParticleOptions;
import net.minecraft.core.particles.ShriekParticleOption;
import net.minecraft.core.particles.VibrationParticleOption;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.gameevent.BlockPositionSource;
@@ -33,6 +32,7 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import org.joml.Vector3f;
public enum CraftParticle {
@@ -171,7 +171,7 @@ public enum CraftParticle {
canonical = aliases.get(particle);
}
net.minecraft.core.particles.Particle nms = IRegistry.PARTICLE_TYPE.get(particles.get(canonical));
net.minecraft.core.particles.Particle nms = BuiltInRegistries.PARTICLE_TYPE.get(particles.get(canonical));
Preconditions.checkArgument(nms != null, "No NMS particle %s", particle);
if (particle.getDataType().equals(Void.class)) {
@@ -193,13 +193,13 @@ public enum CraftParticle {
if (particle.getDataType() == Particle.DustOptions.class) {
Particle.DustOptions data = (Particle.DustOptions) obj;
Color color = data.getColor();
return new ParticleParamRedstone(new Vector3fa(color.getRed() / 255.0f, color.getGreen() / 255.0f, color.getBlue() / 255.0f), data.getSize());
return new ParticleParamRedstone(new Vector3f(color.getRed() / 255.0f, color.getGreen() / 255.0f, color.getBlue() / 255.0f), data.getSize());
}
if (particle.getDataType() == Particle.DustTransition.class) {
Particle.DustTransition data = (Particle.DustTransition) obj;
Color from = data.getColor();
Color to = data.getToColor();
return new DustColorTransitionOptions(new Vector3fa(from.getRed() / 255.0f, from.getGreen() / 255.0f, from.getBlue() / 255.0f), new Vector3fa(to.getRed() / 255.0f, to.getGreen() / 255.0f, to.getBlue() / 255.0f), data.getSize());
return new DustColorTransitionOptions(new Vector3f(from.getRed() / 255.0f, from.getGreen() / 255.0f, from.getBlue() / 255.0f), new Vector3f(to.getRed() / 255.0f, to.getGreen() / 255.0f, to.getBlue() / 255.0f), data.getSize());
}
if (particle.getDataType() == Vibration.class) {
Vibration vibration = (Vibration) obj;
@@ -232,6 +232,6 @@ public enum CraftParticle {
}
public static Particle toBukkit(net.minecraft.core.particles.Particle nms) {
return particles.inverse().get(IRegistry.PARTICLE_TYPE.getKey(nms));
return particles.inverse().get(BuiltInRegistries.PARTICLE_TYPE.getKey(nms));
}
}

View File

@@ -11,7 +11,10 @@ import net.minecraft.core.BlockPosition;
import net.minecraft.core.EnumDirection;
import net.minecraft.core.Holder;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.features.TreeFeatures;
import net.minecraft.resources.ResourceKey;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.EntityAreaEffectCloud;
import net.minecraft.world.entity.EntityExperienceOrb;
@@ -79,6 +82,7 @@ import org.bukkit.entity.Bat;
import org.bukkit.entity.Bee;
import org.bukkit.entity.Blaze;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Camel;
import org.bukkit.entity.Cat;
import org.bukkit.entity.CaveSpider;
import org.bukkit.entity.ChestBoat;
@@ -221,7 +225,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
@Override
public Biome getBiome(int x, int y, int z) {
return CraftBlock.biomeBaseToBiome(getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY), getHandle().getNoiseBiome(x >> 2, y >> 2, z >> 2));
return CraftBlock.biomeBaseToBiome(getHandle().registryAccess().registryOrThrow(Registries.BIOME), getHandle().getNoiseBiome(x >> 2, y >> 2, z >> 2));
}
@Override
@@ -232,7 +236,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
@Override
public void setBiome(int x, int y, int z, Biome biome) {
Preconditions.checkArgument(biome != Biome.CUSTOM, "Cannot set the biome to %s", biome);
Holder<BiomeBase> biomeBase = CraftBlock.biomeToBiomeBase(getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY), biome);
Holder<BiomeBase> biomeBase = CraftBlock.biomeToBiomeBase(getHandle().registryAccess().registryOrThrow(Registries.BIOME), biome);
setBiome(x, y, z, biomeBase);
}
@@ -327,7 +331,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
}
public boolean generateTree(GeneratorAccessSeed access, ChunkGenerator chunkGenerator, BlockPosition pos, RandomSource random, TreeType treeType) {
Holder<?> gen;
ResourceKey<WorldGenFeatureConfigured<?, ?>> gen;
switch (treeType) {
case BIG_TREE:
gen = TreeFeatures.FANCY_OAK;
@@ -398,7 +402,8 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
break;
}
return ((WorldGenFeatureConfigured<?, ?>) gen.value()).place(access, chunkGenerator, random, pos);
Holder<WorldGenFeatureConfigured<?, ?>> holder = access.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).getHolder(gen).orElse(null);
return (holder != null) ? holder.value().place(access, chunkGenerator, random, pos) : false;
}
@Override
@@ -694,6 +699,8 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
entity = EntityTypes.SKELETON_HORSE.create(world);
} else if (ZombieHorse.class.isAssignableFrom(clazz)) {
entity = EntityTypes.ZOMBIE_HORSE.create(world);
} else if (Camel.class.isAssignableFrom(clazz)) {
entity = EntityTypes.CAMEL.create(world);
} else {
entity = EntityTypes.HORSE.create(world);
}

View File

@@ -7,6 +7,8 @@ import java.util.function.BiFunction;
import java.util.stream.Stream;
import net.minecraft.core.IRegistry;
import net.minecraft.core.IRegistryCustom;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
@@ -20,10 +22,10 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
public static <B extends Keyed> Registry<?> createRegistry(Class<B> bukkitClass, IRegistryCustom registryHolder) {
if (bukkitClass == Structure.class) {
return new CraftRegistry<>(registryHolder.registryOrThrow(IRegistry.STRUCTURE_REGISTRY), CraftStructure::new);
return new CraftRegistry<>(registryHolder.registryOrThrow(Registries.STRUCTURE), CraftStructure::new);
}
if (bukkitClass == StructureType.class) {
return new CraftRegistry<>(IRegistry.STRUCTURE_TYPES, CraftStructureType::new);
return new CraftRegistry<>(BuiltInRegistries.STRUCTURE_TYPE, CraftStructureType::new);
}
return null;

View File

@@ -7,11 +7,14 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.google.common.collect.MapMaker;
import com.google.gson.JsonObject;
import com.mojang.authlib.GameProfile;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode;
import com.mojang.datafixers.util.Pair;
import com.mojang.serialization.DynamicOps;
import com.mojang.serialization.Lifecycle;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufOutputStream;
@@ -51,11 +54,18 @@ import net.minecraft.commands.CommandDispatcher;
import net.minecraft.commands.CommandListenerWrapper;
import net.minecraft.commands.arguments.ArgumentEntity;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.DynamicOpsNBT;
import net.minecraft.nbt.NBTBase;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.resources.RegistryOps;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.ServerCommand;
import net.minecraft.server.WorldLoader;
import net.minecraft.server.bossevents.BossBattleCustom;
import net.minecraft.server.commands.CommandReload;
import net.minecraft.server.dedicated.DedicatedPlayerList;
@@ -101,10 +111,14 @@ import net.minecraft.world.level.dimension.WorldDimension;
import net.minecraft.world.level.levelgen.GeneratorSettings;
import net.minecraft.world.level.levelgen.MobSpawnerPatrol;
import net.minecraft.world.level.levelgen.MobSpawnerPhantom;
import net.minecraft.world.level.levelgen.WorldDimensions;
import net.minecraft.world.level.levelgen.WorldOptions;
import net.minecraft.world.level.levelgen.presets.WorldPresets;
import net.minecraft.world.level.material.FluidType;
import net.minecraft.world.level.saveddata.maps.MapIcon;
import net.minecraft.world.level.saveddata.maps.WorldMap;
import net.minecraft.world.level.storage.Convertable;
import net.minecraft.world.level.storage.SaveData;
import net.minecraft.world.level.storage.WorldDataServer;
import net.minecraft.world.level.storage.WorldNBTStorage;
import net.minecraft.world.level.storage.loot.LootTableRegistry;
@@ -644,7 +658,7 @@ public final class CraftServer implements Server {
@Override
public boolean getGenerateStructures() {
return this.getProperties().getWorldGenSettings(this.getServer().registryAccess()).generateStructures();
return this.getServer().getWorldData().worldGenOptions().generateStructures();
}
@Override
@@ -1037,16 +1051,28 @@ public final class CraftServer implements Server {
boolean hardcore = creator.hardcore();
WorldDataServer worlddata = (WorldDataServer) worldSession.getDataTag(console.registryreadops, console.datapackconfiguration, console.registryHolder.allElementsLifecycle());
WorldDataServer worlddata;
WorldLoader.a worldloader_a = console.worldLoader;
IRegistry<WorldDimension> iregistry = worldloader_a.datapackDimensions().registryOrThrow(Registries.LEVEL_STEM);
DynamicOps<NBTBase> dynamicops = RegistryOps.create(DynamicOpsNBT.INSTANCE, (HolderLookup.b) worldloader_a.datapackWorldgen());
Pair<SaveData, WorldDimensions.b> pair = worldSession.getDataTag(dynamicops, worldloader_a.dataConfiguration(), iregistry, worldloader_a.datapackWorldgen().allRegistriesLifecycle());
WorldSettings worldSettings;
// See MinecraftServer.a(String, String, long, WorldType, JsonElement)
if (worlddata == null) {
DedicatedServerProperties.a properties = new DedicatedServerProperties.a(Objects.toString(creator.seed()), ChatDeserializer.parse((creator.generatorSettings().isEmpty()) ? "{}" : creator.generatorSettings()), creator.generateStructures(), creator.type().name().toLowerCase(Locale.ROOT));
if (pair != null) {
worlddata = (WorldDataServer) pair.getFirst();
} else {
WorldSettings worldsettings;
WorldOptions worldoptions = new WorldOptions(creator.seed(), creator.generateStructures(), false);
WorldDimensions worlddimensions;
GeneratorSettings generatorsettings = properties.create(console.registryAccess());
worldSettings = new WorldSettings(name, EnumGamemode.byId(getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), console.datapackconfiguration);
worlddata = new WorldDataServer(worldSettings, generatorsettings, Lifecycle.stable());
DedicatedServerProperties.WorldDimensionData properties = new DedicatedServerProperties.WorldDimensionData(ChatDeserializer.parse((creator.generatorSettings().isEmpty()) ? "{}" : creator.generatorSettings()), creator.type().name().toLowerCase(Locale.ROOT));
worldsettings = new WorldSettings(name, EnumGamemode.byId(getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), worldloader_a.dataConfiguration());
worlddimensions = properties.create(worldloader_a.datapackWorldgen());
WorldDimensions.b worlddimensions_b = worlddimensions.bake(iregistry);
Lifecycle lifecycle = worlddimensions_b.lifecycle().add(worldloader_a.datapackWorldgen().allRegistriesLifecycle());
worlddata = new WorldDataServer(worldsettings, worldoptions, worlddimensions_b.specialWorldProperty(), lifecycle);
}
worlddata.checkName(name);
worlddata.setModdedInfo(console.getServerModName(), console.getModdedStatus().shouldReportAsModified());
@@ -1054,15 +1080,14 @@ public final class CraftServer implements Server {
if (console.options.has("forceUpgrade")) {
net.minecraft.server.Main.forceUpgrade(worldSession, DataConverterRegistry.getDataFixer(), console.options.has("eraseCache"), () -> {
return true;
}, worlddata.worldGenSettings());
}, iregistry);
}
long j = BiomeManager.obfuscateSeed(creator.seed());
List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(worlddata));
IRegistry<WorldDimension> iregistry = worlddata.worldGenSettings().dimensions();
WorldDimension worlddimension = (WorldDimension) iregistry.get(actualDimension);
WorldInfo worldInfo = new CraftWorldInfo(worlddata, worldSession, creator.environment(), worlddimension.typeHolder().value());
WorldInfo worldInfo = new CraftWorldInfo(worlddata, worldSession, creator.environment(), worlddimension.type().value());
if (biomeProvider == null && generator != null) {
biomeProvider = generator.getDefaultBiomeProvider(worldInfo);
}
@@ -1074,17 +1099,17 @@ public final class CraftServer implements Server {
} else if (name.equals(levelName + "_the_end")) {
worldKey = net.minecraft.world.level.World.END;
} else {
worldKey = ResourceKey.create(IRegistry.DIMENSION_REGISTRY, new MinecraftKey(name.toLowerCase(java.util.Locale.ENGLISH)));
worldKey = ResourceKey.create(Registries.DIMENSION, new MinecraftKey(name.toLowerCase(java.util.Locale.ENGLISH)));
}
WorldServer internal = (WorldServer) new WorldServer(console, console.executor, worldSession, worlddata, worldKey, worlddimension, getServer().progressListenerFactory.create(11),
worlddata.worldGenSettings().isDebug(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, creator.environment(), generator, biomeProvider);
worlddata.isDebugWorld(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, creator.environment(), generator, biomeProvider);
if (!(worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) {
return null;
}
console.initWorld(internal, worlddata, worlddata, worlddata.worldGenSettings());
console.initWorld(internal, worlddata, worlddata, worlddata.worldGenOptions());
internal.setSpawnSettings(true, true);
console.addLevel(internal);
@@ -1409,7 +1434,7 @@ public final class CraftServer implements Server {
@Override
public boolean shouldSendChatPreviews() {
return this.getServer().previewsChat();
return false;
}
@Override
@@ -2046,7 +2071,7 @@ public final class CraftServer implements Server {
public ChunkGenerator.ChunkData createChunkData(World world) {
Validate.notNull(world, "World cannot be null");
WorldServer handle = ((CraftWorld) world).getHandle();
return new OldCraftChunkData(world.getMinHeight(), world.getMaxHeight(), handle.registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY));
return new OldCraftChunkData(world.getMinHeight(), world.getMaxHeight(), handle.registryAccess().registryOrThrow(Registries.BIOME));
}
@Override
@@ -2176,30 +2201,30 @@ public final class CraftServer implements Server {
switch (registry) {
case org.bukkit.Tag.REGISTRY_BLOCKS -> {
Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Block namespace must have material type");
TagKey<Block> blockTagKey = TagKey.create(IRegistry.BLOCK_REGISTRY, key);
if (IRegistry.BLOCK.isKnownTagName(blockTagKey)) {
return (org.bukkit.Tag<T>) new CraftBlockTag(IRegistry.BLOCK, blockTagKey);
TagKey<Block> blockTagKey = TagKey.create(Registries.BLOCK, key);
if (BuiltInRegistries.BLOCK.getTag(blockTagKey).isPresent()) {
return (org.bukkit.Tag<T>) new CraftBlockTag(BuiltInRegistries.BLOCK, blockTagKey);
}
}
case org.bukkit.Tag.REGISTRY_ITEMS -> {
Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Item namespace must have material type");
TagKey<Item> itemTagKey = TagKey.create(IRegistry.ITEM_REGISTRY, key);
if (IRegistry.ITEM.isKnownTagName(itemTagKey)) {
return (org.bukkit.Tag<T>) new CraftItemTag(IRegistry.ITEM, itemTagKey);
TagKey<Item> itemTagKey = TagKey.create(Registries.ITEM, key);
if (BuiltInRegistries.ITEM.getTag(itemTagKey).isPresent()) {
return (org.bukkit.Tag<T>) new CraftItemTag(BuiltInRegistries.ITEM, itemTagKey);
}
}
case org.bukkit.Tag.REGISTRY_FLUIDS -> {
Preconditions.checkArgument(clazz == org.bukkit.Fluid.class, "Fluid namespace must have fluid type");
TagKey<FluidType> fluidTagKey = TagKey.create(IRegistry.FLUID_REGISTRY, key);
if (IRegistry.FLUID.isKnownTagName(fluidTagKey)) {
return (org.bukkit.Tag<T>) new CraftFluidTag(IRegistry.FLUID, fluidTagKey);
TagKey<FluidType> fluidTagKey = TagKey.create(Registries.FLUID, key);
if (BuiltInRegistries.FLUID.getTag(fluidTagKey).isPresent()) {
return (org.bukkit.Tag<T>) new CraftFluidTag(BuiltInRegistries.FLUID, fluidTagKey);
}
}
case org.bukkit.Tag.REGISTRY_ENTITY_TYPES -> {
Preconditions.checkArgument(clazz == org.bukkit.entity.EntityType.class, "Entity type namespace must have entity type");
TagKey<EntityTypes<?>> entityTagKey = TagKey.create(IRegistry.ENTITY_TYPE_REGISTRY, key);
if (IRegistry.ENTITY_TYPE.isKnownTagName(entityTagKey)) {
return (org.bukkit.Tag<T>) new CraftEntityTag(IRegistry.ENTITY_TYPE, entityTagKey);
TagKey<EntityTypes<?>> entityTagKey = TagKey.create(Registries.ENTITY_TYPE, key);
if (BuiltInRegistries.ENTITY_TYPE.getTag(entityTagKey).isPresent()) {
return (org.bukkit.Tag<T>) new CraftEntityTag(BuiltInRegistries.ENTITY_TYPE, entityTagKey);
}
}
default -> throw new IllegalArgumentException();
@@ -2216,22 +2241,22 @@ public final class CraftServer implements Server {
switch (registry) {
case org.bukkit.Tag.REGISTRY_BLOCKS -> {
Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Block namespace must have material type");
IRegistry<Block> blockTags = IRegistry.BLOCK;
IRegistry<Block> blockTags = BuiltInRegistries.BLOCK;
return blockTags.getTags().map(pair -> (org.bukkit.Tag<T>) new CraftBlockTag(blockTags, pair.getFirst())).collect(ImmutableList.toImmutableList());
}
case org.bukkit.Tag.REGISTRY_ITEMS -> {
Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Item namespace must have material type");
IRegistry<Item> itemTags = IRegistry.ITEM;
IRegistry<Item> itemTags = BuiltInRegistries.ITEM;
return itemTags.getTags().map(pair -> (org.bukkit.Tag<T>) new CraftItemTag(itemTags, pair.getFirst())).collect(ImmutableList.toImmutableList());
}
case org.bukkit.Tag.REGISTRY_FLUIDS -> {
Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Fluid namespace must have fluid type");
IRegistry<FluidType> fluidTags = IRegistry.FLUID;
IRegistry<FluidType> fluidTags = BuiltInRegistries.FLUID;
return fluidTags.getTags().map(pair -> (org.bukkit.Tag<T>) new CraftFluidTag(fluidTags, pair.getFirst())).collect(ImmutableList.toImmutableList());
}
case org.bukkit.Tag.REGISTRY_ENTITY_TYPES -> {
Preconditions.checkArgument(clazz == org.bukkit.entity.EntityType.class, "Entity type namespace must have entity type");
IRegistry<EntityTypes<?>> entityTags = IRegistry.ENTITY_TYPE;
IRegistry<EntityTypes<?>> entityTags = BuiltInRegistries.ENTITY_TYPE;
return entityTags.getTags().map(pair -> (org.bukkit.Tag<T>) new CraftEntityTag(entityTags, pair.getFirst())).collect(ImmutableList.toImmutableList());
}
default -> throw new IllegalArgumentException();
@@ -2272,7 +2297,7 @@ public final class CraftServer implements Server {
@Override
public <T extends Keyed> Registry<T> getRegistry(Class<T> aClass) {
return (Registry<T>) registries.computeIfAbsent(aClass, key -> CraftRegistry.createRegistry(aClass, console.registryHolder));
return (Registry<T>) registries.computeIfAbsent(aClass, key -> CraftRegistry.createRegistry(aClass, console.registryAccess()));
}
@Deprecated

View File

@@ -1,7 +1,7 @@
package org.bukkit.craftbukkit;
import com.google.common.base.Preconditions;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.sounds.SoundEffect;
import org.bukkit.Registry;
@@ -11,20 +11,20 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey;
public class CraftSound {
public static SoundEffect getSoundEffect(String s) {
SoundEffect effect = IRegistry.SOUND_EVENT.get(new MinecraftKey(s));
SoundEffect effect = BuiltInRegistries.SOUND_EVENT.get(new MinecraftKey(s));
Preconditions.checkArgument(effect != null, "Sound effect %s does not exist", s);
return effect;
}
public static SoundEffect getSoundEffect(Sound s) {
SoundEffect effect = IRegistry.SOUND_EVENT.get(CraftNamespacedKey.toMinecraft(s.getKey()));
SoundEffect effect = BuiltInRegistries.SOUND_EVENT.get(CraftNamespacedKey.toMinecraft(s.getKey()));
Preconditions.checkArgument(effect != null, "Sound effect %s does not exist", s);
return effect;
}
public static Sound getBukkit(SoundEffect soundEffect) {
return Registry.SOUNDS.get(CraftNamespacedKey.fromMinecraft(IRegistry.SOUND_EVENT.getKey(soundEffect)));
return Registry.SOUNDS.get(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.SOUND_EVENT.getKey(soundEffect)));
}
}

View File

@@ -4,6 +4,7 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.stats.ServerStatisticManager;
import net.minecraft.stats.StatisticList;
@@ -123,9 +124,9 @@ public enum CraftStatistic {
public static org.bukkit.Statistic getBukkitStatistic(net.minecraft.stats.Statistic<?> statistic) {
IRegistry statRegistry = statistic.getType().getRegistry();
MinecraftKey nmsKey = IRegistry.STAT_TYPE.getKey(statistic.getType());
MinecraftKey nmsKey = BuiltInRegistries.STAT_TYPE.getKey(statistic.getType());
if (statRegistry == IRegistry.CUSTOM_STAT) {
if (statRegistry == BuiltInRegistries.CUSTOM_STAT) {
nmsKey = (MinecraftKey) statistic.getValue();
}
@@ -169,7 +170,7 @@ public enum CraftStatistic {
public static net.minecraft.stats.Statistic getEntityStatistic(org.bukkit.Statistic stat, EntityType entity) {
if (entity.getName() != null) {
EntityTypes<?> nmsEntity = IRegistry.ENTITY_TYPE.get(new MinecraftKey(entity.getName()));
EntityTypes<?> nmsEntity = BuiltInRegistries.ENTITY_TYPE.get(new MinecraftKey(entity.getName()));
if (stat == org.bukkit.Statistic.KILL_ENTITY) {
return net.minecraft.stats.StatisticList.ENTITY_KILLED.get(nmsEntity);

View File

@@ -9,7 +9,6 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -27,11 +26,12 @@ import java.util.stream.Collectors;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.Holder;
import net.minecraft.core.HolderSet;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
import net.minecraft.network.protocol.game.PacketPlayOutCustomSoundEffect;
import net.minecraft.network.protocol.game.PacketPlayOutEntitySound;
import net.minecraft.network.protocol.game.PacketPlayOutNamedSoundEffect;
import net.minecraft.network.protocol.game.PacketPlayOutUpdateTime;
import net.minecraft.network.protocol.game.PacketPlayOutWorldEvent;
import net.minecraft.resources.MinecraftKey;
@@ -43,7 +43,7 @@ import net.minecraft.server.level.Ticket;
import net.minecraft.server.level.TicketType;
import net.minecraft.server.level.WorldServer;
import net.minecraft.sounds.SoundCategory;
import net.minecraft.tags.TagKey;
import net.minecraft.sounds.SoundEffect;
import net.minecraft.util.ArraySetSorted;
import net.minecraft.util.Unit;
import net.minecraft.world.EnumDifficulty;
@@ -56,7 +56,6 @@ import net.minecraft.world.entity.projectile.EntityArrow;
import net.minecraft.world.entity.projectile.EntityTippedArrow;
import net.minecraft.world.entity.raid.PersistentRaid;
import net.minecraft.world.level.ChunkCoordIntPair;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.RayTrace;
import net.minecraft.world.level.biome.BiomeBase;
@@ -661,7 +660,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source) {
return !world.explode(source == null ? null : ((CraftEntity) source).getHandle(), x, y, z, power, setFire, breakBlocks ? Explosion.Effect.BREAK : Explosion.Effect.NONE).wasCanceled;
return !world.explode(source == null ? null : ((CraftEntity) source).getHandle(), x, y, z, power, setFire, breakBlocks ? net.minecraft.world.level.World.a.MOB : net.minecraft.world.level.World.a.NONE).wasCanceled;
}
@Override
@@ -1321,7 +1320,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public boolean canGenerateStructures() {
return world.serverLevelData.worldGenSettings().generateStructures();
return world.serverLevelData.worldGenOptions().generateStructures();
}
@Override
@@ -1563,7 +1562,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
double y = loc.getY();
double z = loc.getZ();
PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), SoundCategory.valueOf(category.name()), new Vec3D(x, y, z), volume, pitch, getHandle().getRandom().nextLong());
PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(Holder.direct(SoundEffect.createVariableRangeEvent(new MinecraftKey(sound))), SoundCategory.valueOf(category.name()), x, y, z, volume, pitch, getHandle().getRandom().nextLong());
world.getServer().getPlayerList().broadcast(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.dimension(), packet);
}
@@ -1576,7 +1575,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
public void playSound(Entity entity, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) {
if (!(entity instanceof CraftEntity craftEntity) || entity.getWorld() != this || sound == null || category == null) return;
PacketPlayOutEntitySound packet = new PacketPlayOutEntitySound(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, getHandle().getRandom().nextLong());
PacketPlayOutEntitySound packet = new PacketPlayOutEntitySound(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(CraftSound.getSoundEffect(sound)), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, getHandle().getRandom().nextLong());
PlayerChunkMap.EntityTracker entityTracker = getHandle().getChunkSource().chunkMap.entityMap.get(entity.getEntityId());
if (entityTracker != null) {
entityTracker.broadcastAndSend(packet);

View File

@@ -183,11 +183,11 @@ public class Main {
useConsole = false;
}
if (false && Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
Date buildDate = new Date(Integer.parseInt(Main.class.getPackage().getImplementationVendor()) * 1000L);
Calendar deadline = Calendar.getInstance();
deadline.add(Calendar.DAY_OF_YEAR, -28);
deadline.add(Calendar.DAY_OF_YEAR, -3);
if (buildDate.before(deadline.getTime())) {
System.err.println("*** Error, this build is outdated ***");
System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***");

View File

@@ -1,7 +1,7 @@
package org.bukkit.craftbukkit.attribute;
import com.google.common.base.Preconditions;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.ai.attributes.AttributeBase;
import net.minecraft.world.entity.ai.attributes.AttributeMapBase;
import org.bukkit.Registry;
@@ -27,7 +27,7 @@ public class CraftAttributeMap implements Attributable {
}
public static AttributeBase toMinecraft(Attribute attribute) {
return IRegistry.ATTRIBUTE.get(CraftNamespacedKey.toMinecraft(attribute.getKey()));
return BuiltInRegistries.ATTRIBUTE.get(CraftNamespacedKey.toMinecraft(attribute.getKey()));
}
public static Attribute fromMinecraft(String nms) {

View File

@@ -11,6 +11,8 @@ import net.minecraft.core.BlockPosition;
import net.minecraft.core.EnumDirection;
import net.minecraft.core.Holder;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.WorldServer;
import net.minecraft.world.EnumHand;
@@ -360,7 +362,7 @@ public class CraftBlock implements Block {
return null;
}
return registry.getHolderOrThrow(ResourceKey.create(IRegistry.BIOME_REGISTRY, CraftNamespacedKey.toMinecraft(bio.getKey())));
return registry.getHolderOrThrow(ResourceKey.create(Registries.BIOME, CraftNamespacedKey.toMinecraft(bio.getKey())));
}
@Override

View File

@@ -11,6 +11,8 @@ import javax.annotation.Nullable;
import net.minecraft.core.BlockPosition;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.level.GeneratorAccess;
import net.minecraft.world.level.block.entity.ChiseledBookShelfBlockEntity;
import net.minecraft.world.level.block.entity.HangingSignBlockEntity;
import net.minecraft.world.level.block.entity.SculkCatalystBlockEntity;
import net.minecraft.world.level.block.entity.SculkSensorBlockEntity;
import net.minecraft.world.level.block.entity.SculkShriekerBlockEntity;
@@ -124,6 +126,8 @@ public final class CraftBlockStates {
Arrays.asList(
Material.ACACIA_SIGN,
Material.ACACIA_WALL_SIGN,
Material.BAMBOO_SIGN,
Material.BAMBOO_WALL_SIGN,
Material.BIRCH_SIGN,
Material.BIRCH_WALL_SIGN,
Material.CRIMSON_SIGN,
@@ -143,12 +147,39 @@ public final class CraftBlockStates {
), CraftSign.class, CraftSign::new, TileEntitySign::new
);
register(
Arrays.asList(
Material.ACACIA_HANGING_SIGN,
Material.ACACIA_WALL_HANGING_SIGN,
Material.BAMBOO_HANGING_SIGN,
Material.BAMBOO_WALL_HANGING_SIGN,
Material.BIRCH_HANGING_SIGN,
Material.BIRCH_WALL_HANGING_SIGN,
Material.CRIMSON_HANGING_SIGN,
Material.CRIMSON_WALL_HANGING_SIGN,
Material.DARK_OAK_HANGING_SIGN,
Material.DARK_OAK_WALL_HANGING_SIGN,
Material.JUNGLE_HANGING_SIGN,
Material.JUNGLE_WALL_HANGING_SIGN,
Material.MANGROVE_HANGING_SIGN,
Material.MANGROVE_WALL_HANGING_SIGN,
Material.OAK_HANGING_SIGN,
Material.OAK_WALL_HANGING_SIGN,
Material.SPRUCE_HANGING_SIGN,
Material.SPRUCE_WALL_HANGING_SIGN,
Material.WARPED_HANGING_SIGN,
Material.WARPED_WALL_HANGING_SIGN
), CraftHangingSign.class, CraftHangingSign::new, HangingSignBlockEntity::new
);
register(
Arrays.asList(
Material.CREEPER_HEAD,
Material.CREEPER_WALL_HEAD,
Material.DRAGON_HEAD,
Material.DRAGON_WALL_HEAD,
Material.PIGLIN_HEAD,
Material.PIGLIN_WALL_HEAD,
Material.PLAYER_HEAD,
Material.PLAYER_WALL_HEAD,
Material.SKELETON_SKULL,
@@ -268,6 +299,7 @@ public final class CraftBlockStates {
register(Material.BLAST_FURNACE, CraftBlastFurnace.class, CraftBlastFurnace::new, TileEntityBlastFurnace::new);
register(Material.BREWING_STAND, CraftBrewingStand.class, CraftBrewingStand::new, TileEntityBrewingStand::new);
register(Material.CHEST, CraftChest.class, CraftChest::new, TileEntityChest::new);
register(Material.CHISELED_BOOKSHELF, CraftChiseledBookshelf.class, CraftChiseledBookshelf::new, ChiseledBookShelfBlockEntity::new);
register(Material.COMPARATOR, CraftComparator.class, CraftComparator::new, TileEntityComparator::new);
register(Material.CONDUIT, CraftConduit.class, CraftConduit::new, TileEntityConduit::new);
register(Material.DAYLIGHT_DETECTOR, CraftDaylightDetector.class, CraftDaylightDetector::new, TileEntityLightDetector::new);

View File

@@ -0,0 +1,38 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.entity.ChiseledBookShelfBlockEntity;
import org.bukkit.World;
import org.bukkit.block.ChiseledBookshelf;
import org.bukkit.craftbukkit.inventory.CraftInventoryChiseledBookshelf;
import org.bukkit.inventory.ChiseledBookshelfInventory;
public class CraftChiseledBookshelf extends CraftBlockEntityState<ChiseledBookShelfBlockEntity> implements ChiseledBookshelf {
public CraftChiseledBookshelf(World world, ChiseledBookShelfBlockEntity tileEntity) {
super(world, tileEntity);
}
@Override
public int getLastInteractedSlot() {
return getSnapshot().getLastInteractedSlot();
}
@Override
public void setLastInteractedSlot(int lastInteractedSlot) {
getSnapshot().lastInteractedSlot = lastInteractedSlot;
}
@Override
public ChiseledBookshelfInventory getSnapshotInventory() {
return new CraftInventoryChiseledBookshelf(this.getSnapshot());
}
@Override
public ChiseledBookshelfInventory getInventory() {
if (!this.isPlaced()) {
return this.getSnapshotInventory();
}
return new CraftInventoryChiseledBookshelf(this.getTileEntity());
}
}

View File

@@ -26,7 +26,7 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpa
throw new IllegalArgumentException("Can't spawn EntityType " + entityType + " from mobspawners!");
}
this.getSnapshot().getSpawner().setEntityId(EntityTypes.byString(entityType.getName()).get());
this.getSnapshot().setEntityId(EntityTypes.byString(entityType.getName()).get(), this.getWorldHandle().getRandom());
}
@Override

View File

@@ -0,0 +1,12 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.entity.HangingSignBlockEntity;
import org.bukkit.World;
import org.bukkit.block.HangingSign;
public class CraftHangingSign extends CraftSign<HangingSignBlockEntity> implements HangingSign {
public CraftHangingSign(World world, HangingSignBlockEntity tileEntity) {
super(world, tileEntity);
}
}

View File

@@ -11,13 +11,13 @@ import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.util.CraftChatMessage;
import org.bukkit.entity.Player;
public class CraftSign extends CraftBlockEntityState<TileEntitySign> implements Sign {
public class CraftSign<T extends TileEntitySign> extends CraftBlockEntityState<T> implements Sign {
// Lazily initialized only if requested:
private String[] originalLines = null;
private String[] lines = null;
public CraftSign(World world, TileEntitySign tileEntity) {
public CraftSign(World world, T tileEntity) {
super(world, tileEntity);
}
@@ -75,7 +75,7 @@ public class CraftSign extends CraftBlockEntityState<TileEntitySign> implements
}
@Override
public void applyTo(TileEntitySign sign) {
public void applyTo(T sign) {
super.applyTo(sign);
if (lines != null) {
@@ -94,7 +94,7 @@ public class CraftSign extends CraftBlockEntityState<TileEntitySign> implements
Preconditions.checkArgument(sign.isPlaced(), "Sign must be placed");
Preconditions.checkArgument(sign.getWorld() == player.getWorld(), "Sign must be in same world as Player");
TileEntitySign handle = ((CraftSign) sign).getTileEntity();
TileEntitySign handle = ((CraftSign<?>) sign).getTileEntity();
handle.isEditable = true;
((CraftPlayer) player).getHandle().openTextEdit(handle);

View File

@@ -149,6 +149,9 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
case ZOMBIE_HEAD:
case ZOMBIE_WALL_HEAD:
return SkullType.ZOMBIE;
case PIGLIN_HEAD:
case PIGLIN_WALL_HEAD:
return SkullType.PIGLIN;
case PLAYER_HEAD:
case PLAYER_WALL_HEAD:
return SkullType.PLAYER;

View File

@@ -12,7 +12,7 @@ import java.util.stream.Collectors;
import net.minecraft.commands.arguments.blocks.ArgumentBlock;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.EnumDirection;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.INamable;
import net.minecraft.world.level.BlockAccessAir;
@@ -227,7 +227,7 @@ public class CraftBlockData implements BlockData {
// Mimicked from BlockDataAbstract#toString()
public String toString(Map<IBlockState<?>, Comparable<?>> states) {
StringBuilder stateString = new StringBuilder(IRegistry.BLOCK.getKey(state.getBlock()).toString());
StringBuilder stateString = new StringBuilder(BuiltInRegistries.BLOCK.getKey(state.getBlock()).toString());
if (!states.isEmpty()) {
stateString.append('[');
@@ -306,7 +306,7 @@ public class CraftBlockData implements BlockData {
private static IBlockState<?> getState(Class<? extends Block> block, String name, boolean optional) {
IBlockState<?> state = null;
for (Block instance : IRegistry.BLOCK) {
for (Block instance : BuiltInRegistries.BLOCK) {
if (instance.getClass() == block) {
if (state == null) {
state = instance.getStateDefinition().getProperty(name);
@@ -363,6 +363,7 @@ public class CraftBlockData implements BlockData {
register(net.minecraft.world.level.block.BlockBlastFurnace.class, org.bukkit.craftbukkit.block.impl.CraftBlastFurnace::new);
register(net.minecraft.world.level.block.BlockBrewingStand.class, org.bukkit.craftbukkit.block.impl.CraftBrewingStand::new);
register(net.minecraft.world.level.block.BlockBubbleColumn.class, org.bukkit.craftbukkit.block.impl.CraftBubbleColumn::new);
register(net.minecraft.world.level.block.BlockButtonAbstract.class, org.bukkit.craftbukkit.block.impl.CraftButtonAbstract::new);
register(net.minecraft.world.level.block.BlockCactus.class, org.bukkit.craftbukkit.block.impl.CraftCactus::new);
register(net.minecraft.world.level.block.BlockCake.class, org.bukkit.craftbukkit.block.impl.CraftCake::new);
register(net.minecraft.world.level.block.BlockCampfire.class, org.bukkit.craftbukkit.block.impl.CraftCampfire::new);
@@ -453,7 +454,6 @@ public class CraftBlockData implements BlockData {
register(net.minecraft.world.level.block.BlockStem.class, org.bukkit.craftbukkit.block.impl.CraftStem::new);
register(net.minecraft.world.level.block.BlockStemAttached.class, org.bukkit.craftbukkit.block.impl.CraftStemAttached::new);
register(net.minecraft.world.level.block.BlockStepAbstract.class, org.bukkit.craftbukkit.block.impl.CraftStepAbstract::new);
register(net.minecraft.world.level.block.BlockStoneButton.class, org.bukkit.craftbukkit.block.impl.CraftStoneButton::new);
register(net.minecraft.world.level.block.BlockStonecutter.class, org.bukkit.craftbukkit.block.impl.CraftStonecutter::new);
register(net.minecraft.world.level.block.BlockStructure.class, org.bukkit.craftbukkit.block.impl.CraftStructure::new);
register(net.minecraft.world.level.block.BlockSweetBerryBush.class, org.bukkit.craftbukkit.block.impl.CraftSweetBerryBush::new);
@@ -472,11 +472,12 @@ public class CraftBlockData implements BlockData {
register(net.minecraft.world.level.block.BlockWeepingVines.class, org.bukkit.craftbukkit.block.impl.CraftWeepingVines::new);
register(net.minecraft.world.level.block.BlockWitherSkull.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkull::new);
register(net.minecraft.world.level.block.BlockWitherSkullWall.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkullWall::new);
register(net.minecraft.world.level.block.BlockWoodButton.class, org.bukkit.craftbukkit.block.impl.CraftWoodButton::new);
register(net.minecraft.world.level.block.CandleBlock.class, org.bukkit.craftbukkit.block.impl.CraftCandle::new);
register(net.minecraft.world.level.block.CandleCakeBlock.class, org.bukkit.craftbukkit.block.impl.CraftCandleCake::new);
register(net.minecraft.world.level.block.CaveVinesBlock.class, org.bukkit.craftbukkit.block.impl.CraftCaveVines::new);
register(net.minecraft.world.level.block.CaveVinesPlantBlock.class, org.bukkit.craftbukkit.block.impl.CraftCaveVinesPlant::new);
register(net.minecraft.world.level.block.CeilingHangingSignBlock.class, org.bukkit.craftbukkit.block.impl.CraftCeilingHangingSign::new);
register(net.minecraft.world.level.block.ChiseledBookShelfBlock.class, org.bukkit.craftbukkit.block.impl.CraftChiseledBookShelf::new);
register(net.minecraft.world.level.block.GlowLichenBlock.class, org.bukkit.craftbukkit.block.impl.CraftGlowLichen::new);
register(net.minecraft.world.level.block.HangingRootsBlock.class, org.bukkit.craftbukkit.block.impl.CraftHangingRoots::new);
register(net.minecraft.world.level.block.InfestedRotatedPillarBlock.class, org.bukkit.craftbukkit.block.impl.CraftInfestedRotatedPillar::new);
@@ -486,6 +487,7 @@ public class CraftBlockData implements BlockData {
register(net.minecraft.world.level.block.MangroveLeavesBlock.class, org.bukkit.craftbukkit.block.impl.CraftMangroveLeaves::new);
register(net.minecraft.world.level.block.MangrovePropaguleBlock.class, org.bukkit.craftbukkit.block.impl.CraftMangrovePropagule::new);
register(net.minecraft.world.level.block.MangroveRootsBlock.class, org.bukkit.craftbukkit.block.impl.CraftMangroveRoots::new);
register(net.minecraft.world.level.block.PiglinWallSkullBlock.class, org.bukkit.craftbukkit.block.impl.CraftPiglinWallSkull::new);
register(net.minecraft.world.level.block.PointedDripstoneBlock.class, org.bukkit.craftbukkit.block.impl.CraftPointedDripstone::new);
register(net.minecraft.world.level.block.PowderSnowCauldronBlock.class, org.bukkit.craftbukkit.block.impl.CraftPowderSnowCauldron::new);
register(net.minecraft.world.level.block.SculkCatalystBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkCatalyst::new);
@@ -494,6 +496,7 @@ public class CraftBlockData implements BlockData {
register(net.minecraft.world.level.block.SculkVeinBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkVein::new);
register(net.minecraft.world.level.block.SmallDripleafBlock.class, org.bukkit.craftbukkit.block.impl.CraftSmallDripleaf::new);
register(net.minecraft.world.level.block.TallSeagrassBlock.class, org.bukkit.craftbukkit.block.impl.CraftTallSeagrass::new);
register(net.minecraft.world.level.block.WallHangingSignBlock.class, org.bukkit.craftbukkit.block.impl.CraftWallHangingSign::new);
register(net.minecraft.world.level.block.WeatheringCopperSlabBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperSlab::new);
register(net.minecraft.world.level.block.WeatheringCopperStairBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperStair::new);
register(net.minecraft.world.level.block.piston.BlockPiston.class, org.bukkit.craftbukkit.block.impl.CraftPiston::new);
@@ -518,11 +521,11 @@ public class CraftBlockData implements BlockData {
try {
// Material provided, force that material in
if (block != null) {
data = IRegistry.BLOCK.getKey(block) + data;
data = BuiltInRegistries.BLOCK.getKey(block) + data;
}
StringReader reader = new StringReader(data);
ArgumentBlock.a arg = ArgumentBlock.parseForBlock(IRegistry.BLOCK, reader, false);
ArgumentBlock.a arg = ArgumentBlock.parseForBlock(BuiltInRegistries.BLOCK.asLookup(), reader, false);
Preconditions.checkArgument(!reader.canRead(), "Spurious trailing data: " + data);
blockData = arg.blockState();

View File

@@ -0,0 +1,40 @@
package org.bukkit.craftbukkit.block.data.type;
import org.bukkit.block.data.type.ChiseledBookshelf;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftChiseledBookshelf extends CraftBlockData implements ChiseledBookshelf {
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean[] SLOT_OCCUPIED = new net.minecraft.world.level.block.state.properties.BlockStateBoolean[]{
getBoolean("slot_0_occupied"), getBoolean("slot_1_occupied"), getBoolean("slot_2_occupied"),
getBoolean("slot_3_occupied"), getBoolean("slot_4_occupied"), getBoolean("slot_5_occupied")
};
@Override
public boolean isSlotOccupied(int slot) {
return get(SLOT_OCCUPIED[slot]);
}
@Override
public void setSlotOccupied(int slot, boolean has) {
set(SLOT_OCCUPIED[slot], has);
}
@Override
public java.util.Set<Integer> getOccupiedSlots() {
com.google.common.collect.ImmutableSet.Builder<Integer> slots = com.google.common.collect.ImmutableSet.builder();
for (int index = 0; index < getMaximumOccupiedSlots(); index++) {
if (isSlotOccupied(index)) {
slots.add(index);
}
}
return slots.build();
}
@Override
public int getMaximumOccupiedSlots() {
return SLOT_OCCUPIED.length;
}
}

View File

@@ -3,19 +3,19 @@
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftStoneButton extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Switch, org.bukkit.block.data.Directional, org.bukkit.block.data.FaceAttachable, org.bukkit.block.data.Powerable {
public final class CraftButtonAbstract extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Switch, org.bukkit.block.data.Directional, org.bukkit.block.data.FaceAttachable, org.bukkit.block.data.Powerable {
public CraftStoneButton() {
public CraftButtonAbstract() {
super();
}
public CraftStoneButton(net.minecraft.world.level.block.state.IBlockData state) {
public CraftButtonAbstract(net.minecraft.world.level.block.state.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.type.CraftSwitch
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> FACE = getEnum(net.minecraft.world.level.block.BlockStoneButton.class, "face");
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> FACE = getEnum(net.minecraft.world.level.block.BlockButtonAbstract.class, "face");
@Override
public org.bukkit.block.data.type.Switch.Face getFace() {
@@ -29,7 +29,7 @@ public final class CraftStoneButton extends org.bukkit.craftbukkit.block.data.Cr
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> FACING = getEnum(net.minecraft.world.level.block.BlockStoneButton.class, "facing");
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> FACING = getEnum(net.minecraft.world.level.block.BlockButtonAbstract.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
@@ -48,7 +48,7 @@ public final class CraftStoneButton extends org.bukkit.craftbukkit.block.data.Cr
// org.bukkit.craftbukkit.block.data.CraftFaceAttachable
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> ATTACH_FACE = getEnum(net.minecraft.world.level.block.BlockStoneButton.class, "face");
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> ATTACH_FACE = getEnum(net.minecraft.world.level.block.BlockButtonAbstract.class, "face");
@Override
public org.bukkit.block.data.FaceAttachable.AttachedFace getAttachedFace() {
@@ -62,7 +62,7 @@ public final class CraftStoneButton extends org.bukkit.craftbukkit.block.data.Cr
// org.bukkit.craftbukkit.block.data.CraftPowerable
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean POWERED = getBoolean(net.minecraft.world.level.block.BlockStoneButton.class, "powered");
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean POWERED = getBoolean(net.minecraft.world.level.block.BlockButtonAbstract.class, "powered");
@Override
public boolean isPowered() {

View File

@@ -0,0 +1,146 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftCeilingHangingSign extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.HangingSign, org.bukkit.block.data.Attachable, org.bukkit.block.data.Rotatable, org.bukkit.block.data.Waterlogged {
public CraftCeilingHangingSign() {
super();
}
public CraftCeilingHangingSign(net.minecraft.world.level.block.state.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftAttachable
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean ATTACHED = getBoolean(net.minecraft.world.level.block.CeilingHangingSignBlock.class, "attached");
@Override
public boolean isAttached() {
return get(ATTACHED);
}
@Override
public void setAttached(boolean attached) {
set(ATTACHED, attached);
}
// org.bukkit.craftbukkit.block.data.CraftRotatable
private static final net.minecraft.world.level.block.state.properties.BlockStateInteger ROTATION = getInteger(net.minecraft.world.level.block.CeilingHangingSignBlock.class, "rotation");
@Override
public org.bukkit.block.BlockFace getRotation() {
int data = get(ROTATION);
switch (data) {
case 0x0:
return org.bukkit.block.BlockFace.SOUTH;
case 0x1:
return org.bukkit.block.BlockFace.SOUTH_SOUTH_WEST;
case 0x2:
return org.bukkit.block.BlockFace.SOUTH_WEST;
case 0x3:
return org.bukkit.block.BlockFace.WEST_SOUTH_WEST;
case 0x4:
return org.bukkit.block.BlockFace.WEST;
case 0x5:
return org.bukkit.block.BlockFace.WEST_NORTH_WEST;
case 0x6:
return org.bukkit.block.BlockFace.NORTH_WEST;
case 0x7:
return org.bukkit.block.BlockFace.NORTH_NORTH_WEST;
case 0x8:
return org.bukkit.block.BlockFace.NORTH;
case 0x9:
return org.bukkit.block.BlockFace.NORTH_NORTH_EAST;
case 0xA:
return org.bukkit.block.BlockFace.NORTH_EAST;
case 0xB:
return org.bukkit.block.BlockFace.EAST_NORTH_EAST;
case 0xC:
return org.bukkit.block.BlockFace.EAST;
case 0xD:
return org.bukkit.block.BlockFace.EAST_SOUTH_EAST;
case 0xE:
return org.bukkit.block.BlockFace.SOUTH_EAST;
case 0xF:
return org.bukkit.block.BlockFace.SOUTH_SOUTH_EAST;
default:
throw new IllegalArgumentException("Unknown rotation " + data);
}
}
@Override
public void setRotation(org.bukkit.block.BlockFace rotation) {
int val;
switch (rotation) {
case SOUTH:
val = 0x0;
break;
case SOUTH_SOUTH_WEST:
val = 0x1;
break;
case SOUTH_WEST:
val = 0x2;
break;
case WEST_SOUTH_WEST:
val = 0x3;
break;
case WEST:
val = 0x4;
break;
case WEST_NORTH_WEST:
val = 0x5;
break;
case NORTH_WEST:
val = 0x6;
break;
case NORTH_NORTH_WEST:
val = 0x7;
break;
case NORTH:
val = 0x8;
break;
case NORTH_NORTH_EAST:
val = 0x9;
break;
case NORTH_EAST:
val = 0xA;
break;
case EAST_NORTH_EAST:
val = 0xB;
break;
case EAST:
val = 0xC;
break;
case EAST_SOUTH_EAST:
val = 0xD;
break;
case SOUTH_EAST:
val = 0xE;
break;
case SOUTH_SOUTH_EAST:
val = 0xF;
break;
default:
throw new IllegalArgumentException("Illegal rotation " + rotation);
}
set(ROTATION, val);
}
// org.bukkit.craftbukkit.block.data.CraftWaterlogged
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.CeilingHangingSignBlock.class, "waterlogged");
@Override
public boolean isWaterlogged() {
return get(WATERLOGGED);
}
@Override
public void setWaterlogged(boolean waterlogged) {
set(WATERLOGGED, waterlogged);
}
}

View File

@@ -0,0 +1,69 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftChiseledBookShelf extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.ChiseledBookshelf, org.bukkit.block.data.Directional {
public CraftChiseledBookShelf() {
super();
}
public CraftChiseledBookShelf(net.minecraft.world.level.block.state.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.type.CraftChiseledBookshelf
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean[] SLOT_OCCUPIED = new net.minecraft.world.level.block.state.properties.BlockStateBoolean[]{
getBoolean(net.minecraft.world.level.block.ChiseledBookShelfBlock.class, "slot_0_occupied"), getBoolean(net.minecraft.world.level.block.ChiseledBookShelfBlock.class, "slot_1_occupied"), getBoolean(net.minecraft.world.level.block.ChiseledBookShelfBlock.class, "slot_2_occupied"),
getBoolean(net.minecraft.world.level.block.ChiseledBookShelfBlock.class, "slot_3_occupied"), getBoolean(net.minecraft.world.level.block.ChiseledBookShelfBlock.class, "slot_4_occupied"), getBoolean(net.minecraft.world.level.block.ChiseledBookShelfBlock.class, "slot_5_occupied")
};
@Override
public boolean isSlotOccupied(int slot) {
return get(SLOT_OCCUPIED[slot]);
}
@Override
public void setSlotOccupied(int slot, boolean has) {
set(SLOT_OCCUPIED[slot], has);
}
@Override
public java.util.Set<Integer> getOccupiedSlots() {
com.google.common.collect.ImmutableSet.Builder<Integer> slots = com.google.common.collect.ImmutableSet.builder();
for (int index = 0; index < getMaximumOccupiedSlots(); index++) {
if (isSlotOccupied(index)) {
slots.add(index);
}
}
return slots.build();
}
@Override
public int getMaximumOccupiedSlots() {
return SLOT_OCCUPIED.length;
}
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> FACING = getEnum(net.minecraft.world.level.block.ChiseledBookShelfBlock.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
return get(FACING, org.bukkit.block.BlockFace.class);
}
@Override
public void setFacing(org.bukkit.block.BlockFace facing) {
set(FACING, facing);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
return getValues(FACING, org.bukkit.block.BlockFace.class);
}
}

View File

@@ -0,0 +1,34 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftPiglinWallSkull extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional {
public CraftPiglinWallSkull() {
super();
}
public CraftPiglinWallSkull(net.minecraft.world.level.block.state.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> FACING = getEnum(net.minecraft.world.level.block.PiglinWallSkullBlock.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
return get(FACING, org.bukkit.block.BlockFace.class);
}
@Override
public void setFacing(org.bukkit.block.BlockFace facing) {
set(FACING, facing);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
return getValues(FACING, org.bukkit.block.BlockFace.class);
}
}

View File

@@ -0,0 +1,48 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftWallHangingSign extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.WallHangingSign, org.bukkit.block.data.Directional, org.bukkit.block.data.Waterlogged {
public CraftWallHangingSign() {
super();
}
public CraftWallHangingSign(net.minecraft.world.level.block.state.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> FACING = getEnum(net.minecraft.world.level.block.WallHangingSignBlock.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
return get(FACING, org.bukkit.block.BlockFace.class);
}
@Override
public void setFacing(org.bukkit.block.BlockFace facing) {
set(FACING, facing);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
return getValues(FACING, org.bukkit.block.BlockFace.class);
}
// org.bukkit.craftbukkit.block.data.CraftWaterlogged
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.world.level.block.WallHangingSignBlock.class, "waterlogged");
@Override
public boolean isWaterlogged() {
return get(WATERLOGGED);
}
@Override
public void setWaterlogged(boolean waterlogged) {
set(WATERLOGGED, waterlogged);
}
}

View File

@@ -1,76 +0,0 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftWoodButton extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Switch, org.bukkit.block.data.Directional, org.bukkit.block.data.FaceAttachable, org.bukkit.block.data.Powerable {
public CraftWoodButton() {
super();
}
public CraftWoodButton(net.minecraft.world.level.block.state.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.type.CraftSwitch
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> FACE = getEnum(net.minecraft.world.level.block.BlockWoodButton.class, "face");
@Override
public org.bukkit.block.data.type.Switch.Face getFace() {
return get(FACE, org.bukkit.block.data.type.Switch.Face.class);
}
@Override
public void setFace(org.bukkit.block.data.type.Switch.Face face) {
set(FACE, face);
}
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> FACING = getEnum(net.minecraft.world.level.block.BlockWoodButton.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
return get(FACING, org.bukkit.block.BlockFace.class);
}
@Override
public void setFacing(org.bukkit.block.BlockFace facing) {
set(FACING, facing);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
return getValues(FACING, org.bukkit.block.BlockFace.class);
}
// org.bukkit.craftbukkit.block.data.CraftFaceAttachable
private static final net.minecraft.world.level.block.state.properties.BlockStateEnum<?> ATTACH_FACE = getEnum(net.minecraft.world.level.block.BlockWoodButton.class, "face");
@Override
public org.bukkit.block.data.FaceAttachable.AttachedFace getAttachedFace() {
return get(ATTACH_FACE, org.bukkit.block.data.FaceAttachable.AttachedFace.class);
}
@Override
public void setAttachedFace(org.bukkit.block.data.FaceAttachable.AttachedFace face) {
set(ATTACH_FACE, face);
}
// org.bukkit.craftbukkit.block.data.CraftPowerable
private static final net.minecraft.world.level.block.state.properties.BlockStateBoolean POWERED = getBoolean(net.minecraft.world.level.block.BlockWoodButton.class, "powered");
@Override
public boolean isPowered() {
return get(POWERED);
}
@Override
public void setPowered(boolean powered) {
set(POWERED, powered);
}
}

View File

@@ -1,6 +1,7 @@
package org.bukkit.craftbukkit.enchantments;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.item.enchantment.EnchantmentBinding;
import net.minecraft.world.item.enchantment.EnchantmentVanishing;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
@@ -14,7 +15,7 @@ public class CraftEnchantment extends Enchantment {
private final net.minecraft.world.item.enchantment.Enchantment target;
public CraftEnchantment(net.minecraft.world.item.enchantment.Enchantment target) {
super(CraftNamespacedKey.fromMinecraft(IRegistry.ENCHANTMENT.getKey(target)));
super(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.ENCHANTMENT.getKey(target)));
this.target = target;
}
@@ -82,7 +83,7 @@ public class CraftEnchantment extends Enchantment {
@Override
public String getName() {
// PAIL: migration paths
switch (IRegistry.ENCHANTMENT.getId(target)) {
switch (BuiltInRegistries.ENCHANTMENT.getId(target)) {
case 0:
return "PROTECTION_ENVIRONMENTAL";
case 1:
@@ -162,7 +163,7 @@ public class CraftEnchantment extends Enchantment {
case 38:
return "VANISHING_CURSE";
default:
return "UNKNOWN_ENCHANT_" + IRegistry.ENCHANTMENT.getId(target);
return "UNKNOWN_ENCHANT_" + BuiltInRegistries.ENCHANTMENT.getId(target);
}
}

View File

@@ -45,6 +45,6 @@ public class CraftAxolotl extends CraftAnimals implements Axolotl {
public void setVariant(Variant variant) {
Preconditions.checkArgument(variant != null, "variant");
getHandle().setVariant(net.minecraft.world.entity.animal.axolotl.Axolotl.Variant.BY_ID[variant.ordinal()]);
getHandle().setVariant(net.minecraft.world.entity.animal.axolotl.Axolotl.Variant.byId(variant.ordinal()));
}
}

View File

@@ -17,24 +17,24 @@ public class CraftBoat extends CraftVehicle implements Boat {
@Override
public TreeSpecies getWoodType() {
return getTreeSpecies(getHandle().getBoatType());
return getTreeSpecies(getHandle().getVariant());
}
@Override
public void setWoodType(TreeSpecies species) {
getHandle().setType(getBoatType(species));
getHandle().setVariant(getBoatType(species));
}
@Override
public Type getBoatType() {
return boatTypeFromNms(getHandle().getBoatType());
return boatTypeFromNms(getHandle().getVariant());
}
@Override
public void setBoatType(Type type) {
Preconditions.checkArgument(type != null, "Boat.Type cannot be null");
getHandle().setType(boatTypeToNms(type));
getHandle().setVariant(boatTypeToNms(type));
}
@Override
@@ -111,12 +111,14 @@ public class CraftBoat extends CraftVehicle implements Boat {
case SPRUCE -> Type.SPRUCE;
case DARK_OAK -> Type.DARK_OAK;
case MANGROVE -> Type.MANGROVE;
case BAMBOO -> Type.BAMBOO;
};
}
public static EntityBoat.EnumBoatType boatTypeToNms(Boat.Type type) {
return switch (type) {
default -> throw new EnumConstantNotPresentException(EntityBoat.EnumBoatType.class, type.name());
case BAMBOO -> EntityBoat.EnumBoatType.BAMBOO;
case MANGROVE -> EntityBoat.EnumBoatType.MANGROVE;
case SPRUCE -> EntityBoat.EnumBoatType.SPRUCE;
case DARK_OAK -> EntityBoat.EnumBoatType.DARK_OAK;

View File

@@ -0,0 +1,43 @@
package org.bukkit.craftbukkit.entity;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Camel;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Horse;
public class CraftCamel extends CraftAbstractHorse implements Camel {
public CraftCamel(CraftServer server, net.minecraft.world.entity.animal.camel.Camel entity) {
super(server, entity);
}
@Override
public net.minecraft.world.entity.animal.camel.Camel getHandle() {
return (net.minecraft.world.entity.animal.camel.Camel) super.getHandle();
}
@Override
public String toString() {
return "CraftCamel";
}
@Override
public EntityType getType() {
return EntityType.CAMEL;
}
@Override
public Horse.Variant getVariant() {
return Horse.Variant.CAMEL;
}
@Override
public boolean isDashing() {
return getHandle().isDashing();
}
@Override
public void setDashing(boolean dashing) {
getHandle().setDashing(dashing);
}
}

View File

@@ -1,8 +1,7 @@
package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import net.minecraft.core.IRegistry;
import net.minecraft.world.entity.animal.CatVariant;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.animal.EntityCat;
import net.minecraft.world.item.EnumColor;
import org.bukkit.DyeColor;
@@ -34,14 +33,14 @@ public class CraftCat extends CraftTameableAnimal implements Cat {
@Override
public Type getCatType() {
return Type.values()[IRegistry.CAT_VARIANT.getId(getHandle().getCatVariant())];
return Type.values()[BuiltInRegistries.CAT_VARIANT.getId(getHandle().getVariant())];
}
@Override
public void setCatType(Type type) {
Preconditions.checkArgument(type != null, "Cannot have null Type");
getHandle().setCatVariant(IRegistry.CAT_VARIANT.byId(type.ordinal()));
getHandle().setVariant(BuiltInRegistries.CAT_VARIANT.byId(type.ordinal()));
}
@Override

View File

@@ -58,6 +58,7 @@ import net.minecraft.world.entity.animal.EntityWaterAnimal;
import net.minecraft.world.entity.animal.EntityWolf;
import net.minecraft.world.entity.animal.allay.Allay;
import net.minecraft.world.entity.animal.axolotl.Axolotl;
import net.minecraft.world.entity.animal.camel.Camel;
import net.minecraft.world.entity.animal.frog.Frog;
import net.minecraft.world.entity.animal.frog.Tadpole;
import net.minecraft.world.entity.animal.goat.Goat;
@@ -257,6 +258,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
} else if (entity instanceof EntityHorse) { return new CraftHorse(server, (EntityHorse) entity); }
else if (entity instanceof EntityHorseSkeleton) { return new CraftSkeletonHorse(server, (EntityHorseSkeleton) entity); }
else if (entity instanceof EntityHorseZombie) { return new CraftZombieHorse(server, (EntityHorseZombie) entity); }
else if (entity instanceof Camel) { return new CraftCamel(server, (Camel) entity); }
}
else if (entity instanceof EntityRabbit) { return new CraftRabbit(server, (EntityRabbit) entity); }
else if (entity instanceof EntityPolarBear) { return new CraftPolarBear(server, (EntityPolarBear) entity); }

View File

@@ -33,14 +33,14 @@ public class CraftFox extends CraftAnimals implements Fox {
@Override
public Type getFoxType() {
return Type.values()[getHandle().getFoxType().ordinal()];
return Type.values()[getHandle().getVariant().ordinal()];
}
@Override
public void setFoxType(Type type) {
Preconditions.checkArgument(type != null, "type");
getHandle().setFoxType(EntityFox.Type.values()[type.ordinal()]);
getHandle().setVariant(EntityFox.Type.values()[type.ordinal()]);
}
@Override

View File

@@ -1,7 +1,7 @@
package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.animal.frog.Frog;
import org.bukkit.Registry;
import org.bukkit.craftbukkit.CraftServer;
@@ -46,13 +46,13 @@ public class CraftFrog extends CraftAnimals implements org.bukkit.entity.Frog {
@Override
public Variant getVariant() {
return Registry.FROG_VARIANT.get(CraftNamespacedKey.fromMinecraft(IRegistry.FROG_VARIANT.getKey(getHandle().getVariant())));
return Registry.FROG_VARIANT.get(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.FROG_VARIANT.getKey(getHandle().getVariant())));
}
@Override
public void setVariant(Variant variant) {
Preconditions.checkArgument(variant != null, "variant");
getHandle().setVariant(IRegistry.FROG_VARIANT.get(CraftNamespacedKey.toMinecraft(variant.getKey())));
getHandle().setVariant(BuiltInRegistries.FROG_VARIANT.get(CraftNamespacedKey.toMinecraft(variant.getKey())));
}
}

View File

@@ -2,7 +2,6 @@ package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import net.minecraft.core.EnumDirection;
import net.minecraft.network.syncher.DataWatcher;
import net.minecraft.world.entity.decoration.EntityHanging;
import net.minecraft.world.entity.decoration.EntityItemFrame;
import net.minecraft.world.level.block.Blocks;
@@ -44,9 +43,8 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame {
super.update();
// mark dirty, so that the client gets updated with item and rotation
for (DataWatcher.Item<?> dataItem : getHandle().getEntityData().getAll()) {
getHandle().getEntityData().markDirty(dataItem.getAccessor());
}
getHandle().getEntityData().markDirty(EntityItemFrame.DATA_ITEM);
getHandle().getEntityData().markDirty(EntityItemFrame.DATA_ROTATION);
// update redstone
if (!getHandle().generation) {

View File

@@ -23,14 +23,14 @@ public class CraftLlama extends CraftChestedHorse implements Llama {
@Override
public Color getColor() {
return Color.values()[getHandle().getVariant()];
return Color.values()[getHandle().getVariant().ordinal()];
}
@Override
public void setColor(Color color) {
Preconditions.checkArgument(color != null, "color");
getHandle().setVariant(color.ordinal());
getHandle().setVariant(EntityLlama.Variant.byId(color.ordinal()));
}
@Override

View File

@@ -19,14 +19,14 @@ public class CraftMushroomCow extends CraftCow implements MushroomCow {
@Override
public Variant getVariant() {
return Variant.values()[getHandle().getMushroomType().ordinal()];
return Variant.values()[getHandle().getVariant().ordinal()];
}
@Override
public void setVariant(Variant variant) {
Preconditions.checkArgument(variant != null, "variant");
getHandle().setMushroomType(EntityMushroomCow.Type.values()[variant.ordinal()]);
getHandle().setVariant(EntityMushroomCow.Type.values()[variant.ordinal()]);
}
@Override

View File

@@ -20,14 +20,14 @@ public class CraftParrot extends CraftTameableAnimal implements Parrot {
@Override
public Variant getVariant() {
return Variant.values()[getHandle().getVariant()];
return Variant.values()[getHandle().getVariant().ordinal()];
}
@Override
public void setVariant(Variant variant) {
Preconditions.checkArgument(variant != null, "variant");
getHandle().setVariant(variant.ordinal());
getHandle().setVariant(EntityParrot.Variant.byId(variant.ordinal()));
}
@Override

View File

@@ -30,13 +30,16 @@ import java.util.logging.Logger;
import javax.annotation.Nullable;
import net.minecraft.advancements.AdvancementProgress;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.Holder;
import net.minecraft.core.SectionPosition;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketDataSerializer;
import net.minecraft.network.chat.ChatMessageContent;
import net.minecraft.network.chat.IChatBaseComponent;
import net.minecraft.network.chat.PlayerChatMessage;
import net.minecraft.network.protocol.game.ClientboundClearTitlesPacket;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
import net.minecraft.network.protocol.game.ClientboundSetBorderCenterPacket;
import net.minecraft.network.protocol.game.ClientboundSetBorderLerpSizePacket;
import net.minecraft.network.protocol.game.ClientboundSetBorderSizePacket;
@@ -48,7 +51,6 @@ import net.minecraft.network.protocol.game.ClientboundSetTitlesAnimationPacket;
import net.minecraft.network.protocol.game.PacketPlayOutBlockBreakAnimation;
import net.minecraft.network.protocol.game.PacketPlayOutBlockChange;
import net.minecraft.network.protocol.game.PacketPlayOutCustomPayload;
import net.minecraft.network.protocol.game.PacketPlayOutCustomSoundEffect;
import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment;
import net.minecraft.network.protocol.game.PacketPlayOutEntitySound;
import net.minecraft.network.protocol.game.PacketPlayOutExperience;
@@ -56,7 +58,6 @@ import net.minecraft.network.protocol.game.PacketPlayOutGameStateChange;
import net.minecraft.network.protocol.game.PacketPlayOutMap;
import net.minecraft.network.protocol.game.PacketPlayOutMultiBlockChange;
import net.minecraft.network.protocol.game.PacketPlayOutNamedSoundEffect;
import net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo;
import net.minecraft.network.protocol.game.PacketPlayOutPlayerListHeaderFooter;
import net.minecraft.network.protocol.game.PacketPlayOutSpawnPosition;
import net.minecraft.network.protocol.game.PacketPlayOutStopSound;
@@ -71,6 +72,7 @@ import net.minecraft.server.level.PlayerChunkMap;
import net.minecraft.server.level.WorldServer;
import net.minecraft.server.network.PlayerConnection;
import net.minecraft.server.players.WhiteListEntry;
import net.minecraft.sounds.SoundEffect;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityLiving;
import net.minecraft.world.entity.EnumItemSlot;
@@ -299,7 +301,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
getHandle().listName = name.equals(getName()) ? null : CraftChatMessage.fromStringOrNull(name);
for (EntityPlayer player : (List<EntityPlayer>) server.getHandle().players) {
if (player.getBukkitEntity().canSee(this)) {
player.connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_DISPLAY_NAME, getHandle()));
player.connection.send(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.a.UPDATE_DISPLAY_NAME, getHandle()));
}
}
}
@@ -387,7 +389,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void chat(String msg) {
if (getHandle().connection == null) return;
getHandle().connection.chat(msg, PlayerChatMessage.system(new ChatMessageContent(msg)), false);
getHandle().connection.chat(msg, PlayerChatMessage.system(msg), false);
}
@Override
@@ -434,7 +436,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
float f = (float) Math.pow(2.0D, (note - 12.0D) / 12.0D);
getHandle().connection.send(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f, getHandle().getRandom().nextLong()));
getHandle().connection.send(new PacketPlayOutNamedSoundEffect(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(CraftSound.getSoundEffect("block.note_block." + instrumentName)), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f, getHandle().getRandom().nextLong()));
}
@Override
@@ -496,7 +498,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
break;
}
float f = (float) Math.pow(2.0D, (note.getId() - 12.0D) / 12.0D);
getHandle().connection.send(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f, getHandle().getRandom().nextLong()));
getHandle().connection.send(new PacketPlayOutNamedSoundEffect(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(CraftSound.getSoundEffect("block.note_block." + instrumentName)), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f, getHandle().getRandom().nextLong()));
}
@Override
@@ -513,7 +515,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void playSound(Location loc, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) {
if (loc == null || sound == null || category == null || getHandle().connection == null) return;
PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), loc.getX(), loc.getY(), loc.getZ(), volume, pitch, getHandle().getRandom().nextLong());
PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(CraftSound.getSoundEffect(sound)), net.minecraft.sounds.SoundCategory.valueOf(category.name()), loc.getX(), loc.getY(), loc.getZ(), volume, pitch, getHandle().getRandom().nextLong());
getHandle().connection.send(packet);
}
@@ -521,7 +523,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void playSound(Location loc, String sound, org.bukkit.SoundCategory category, float volume, float pitch) {
if (loc == null || sound == null || category == null || getHandle().connection == null) return;
PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), new Vec3D(loc.getX(), loc.getY(), loc.getZ()), volume, pitch, getHandle().getRandom().nextLong());
PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(Holder.direct(SoundEffect.createVariableRangeEvent(new MinecraftKey(sound))), net.minecraft.sounds.SoundCategory.valueOf(category.name()), loc.getX(), loc.getY(), loc.getZ(), volume, pitch, getHandle().getRandom().nextLong());
getHandle().connection.send(packet);
}
@@ -534,7 +536,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void playSound(org.bukkit.entity.Entity entity, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) {
if (!(entity instanceof CraftEntity craftEntity) || sound == null || category == null || getHandle().connection == null) return;
PacketPlayOutEntitySound packet = new PacketPlayOutEntitySound(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, getHandle().getRandom().nextLong());
PacketPlayOutEntitySound packet = new PacketPlayOutEntitySound(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(CraftSound.getSoundEffect(sound)), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, getHandle().getRandom().nextLong());
getHandle().connection.send(packet);
}
@@ -1267,7 +1269,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (other instanceof EntityPlayer) {
EntityPlayer otherPlayer = (EntityPlayer) other;
if (otherPlayer.sentListPacket) {
getHandle().connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, otherPlayer));
getHandle().connection.send(new ClientboundPlayerInfoRemovePacket(List.of(otherPlayer.getUUID())));
}
}
@@ -1313,7 +1315,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (other instanceof EntityPlayer) {
EntityPlayer otherPlayer = (EntityPlayer) other;
getHandle().connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, otherPlayer));
getHandle().connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(otherPlayer)));
}
PlayerChunkMap.EntityTracker entry = tracker.entityMap.get(other.getId());

View File

@@ -32,8 +32,7 @@ public class CraftRabbit extends CraftAnimals implements Rabbit {
@Override
public Type getRabbitType() {
int type = getHandle().getRabbitType();
return CraftMagicMapping.fromMagic(type);
return Type.values()[getHandle().getVariant().ordinal()];
}
@Override
@@ -48,43 +47,6 @@ public class CraftRabbit extends CraftAnimals implements Rabbit {
entity.initializePathFinderGoals();
}
entity.setRabbitType(CraftMagicMapping.toMagic(type));
}
private static class CraftMagicMapping {
private static final int[] types = new int[Type.values().length];
private static final Type[] reverse = new Type[Type.values().length];
static {
set(Type.BROWN, 0);
set(Type.WHITE, 1);
set(Type.BLACK, 2);
set(Type.BLACK_AND_WHITE, 3);
set(Type.GOLD, 4);
set(Type.SALT_AND_PEPPER, 5);
set(Type.THE_KILLER_BUNNY, 99);
}
private static void set(Type type, int value) {
types[type.ordinal()] = value;
if (value < reverse.length) {
reverse[value] = type;
}
}
public static Type fromMagic(int magic) {
if (magic >= 0 && magic < reverse.length) {
return reverse[magic];
} else if (magic == 99) {
return Type.THE_KILLER_BUNNY;
} else {
return null;
}
}
public static int toMagic(Type type) {
return types[type.ordinal()];
}
entity.setVariant(EntityRabbit.Variant.values()[type.ordinal()]);
}
}

View File

@@ -32,32 +32,32 @@ public class CraftTropicalFish extends CraftFish implements TropicalFish {
@Override
public DyeColor getPatternColor() {
return getPatternColor(getHandle().getVariant());
return getPatternColor(getHandle().getPackedVariant());
}
@Override
public void setPatternColor(DyeColor color) {
getHandle().setVariant(getData(color, getBodyColor(), getPattern()));
getHandle().setPackedVariant(getData(color, getBodyColor(), getPattern()));
}
@Override
public DyeColor getBodyColor() {
return getBodyColor(getHandle().getVariant());
return getBodyColor(getHandle().getPackedVariant());
}
@Override
public void setBodyColor(DyeColor color) {
getHandle().setVariant(getData(getPatternColor(), color, getPattern()));
getHandle().setPackedVariant(getData(getPatternColor(), color, getPattern()));
}
@Override
public Pattern getPattern() {
return getPattern(getHandle().getVariant());
return getPattern(getHandle().getPackedVariant());
}
@Override
public void setPattern(Pattern pattern) {
getHandle().setVariant(getData(getPatternColor(), getBodyColor(), pattern));
getHandle().setPackedVariant(getData(getPatternColor(), getBodyColor(), pattern));
}
public static enum CraftPattern {

View File

@@ -3,7 +3,7 @@ package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import java.util.Locale;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.monster.EntityZombie;
import net.minecraft.world.entity.monster.EntityZombieVillager;
import net.minecraft.world.entity.npc.EntityVillager;
@@ -60,13 +60,13 @@ public class CraftVillager extends CraftAbstractVillager implements Villager {
@Override
public Type getVillagerType() {
return Type.valueOf(IRegistry.VILLAGER_TYPE.getKey(getHandle().getVillagerData().getType()).getPath().toUpperCase(Locale.ROOT));
return Type.valueOf(BuiltInRegistries.VILLAGER_TYPE.getKey(getHandle().getVillagerData().getType()).getPath().toUpperCase(Locale.ROOT));
}
@Override
public void setVillagerType(Type type) {
Validate.notNull(type);
getHandle().setVillagerData(getHandle().getVillagerData().setType(IRegistry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey()))));
getHandle().setVillagerData(getHandle().getVillagerData().setType(BuiltInRegistries.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey()))));
}
@Override
@@ -130,10 +130,10 @@ public class CraftVillager extends CraftAbstractVillager implements Villager {
}
public static Profession nmsToBukkitProfession(VillagerProfession nms) {
return Profession.valueOf(IRegistry.VILLAGER_PROFESSION.getKey(nms).getPath().toUpperCase(Locale.ROOT));
return Profession.valueOf(BuiltInRegistries.VILLAGER_PROFESSION.getKey(nms).getPath().toUpperCase(Locale.ROOT));
}
public static VillagerProfession bukkitToNmsProfession(Profession bukkit) {
return IRegistry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(bukkit.getKey()));
return BuiltInRegistries.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(bukkit.getKey()));
}
}

View File

@@ -3,7 +3,7 @@ package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import java.util.Locale;
import java.util.UUID;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.monster.EntityZombieVillager;
@@ -39,24 +39,24 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager {
@Override
public Villager.Profession getVillagerProfession() {
return Villager.Profession.valueOf(IRegistry.VILLAGER_PROFESSION.getKey(getHandle().getVillagerData().getProfession()).getPath().toUpperCase(Locale.ROOT));
return Villager.Profession.valueOf(BuiltInRegistries.VILLAGER_PROFESSION.getKey(getHandle().getVillagerData().getProfession()).getPath().toUpperCase(Locale.ROOT));
}
@Override
public void setVillagerProfession(Villager.Profession profession) {
Validate.notNull(profession);
getHandle().setVillagerData(getHandle().getVillagerData().setProfession(IRegistry.VILLAGER_PROFESSION.get(new MinecraftKey(profession.name().toLowerCase(Locale.ROOT)))));
getHandle().setVillagerData(getHandle().getVillagerData().setProfession(BuiltInRegistries.VILLAGER_PROFESSION.get(new MinecraftKey(profession.name().toLowerCase(Locale.ROOT)))));
}
@Override
public Villager.Type getVillagerType() {
return Villager.Type.valueOf(IRegistry.VILLAGER_TYPE.getKey(getHandle().getVillagerData().getType()).getPath().toUpperCase(Locale.ROOT));
return Villager.Type.valueOf(BuiltInRegistries.VILLAGER_TYPE.getKey(getHandle().getVillagerData().getType()).getPath().toUpperCase(Locale.ROOT));
}
@Override
public void setVillagerType(Villager.Type type) {
Validate.notNull(type);
getHandle().setVillagerData(getHandle().getVillagerData().setType(IRegistry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey()))));
getHandle().setVillagerData(getHandle().getVillagerData().setType(BuiltInRegistries.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey()))));
}
@Override

View File

@@ -1,6 +1,6 @@
package org.bukkit.craftbukkit.entity.memory;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.entity.memory.MemoryKey;
@@ -10,10 +10,10 @@ public final class CraftMemoryKey {
private CraftMemoryKey() {}
public static <T, U> MemoryModuleType<U> fromMemoryKey(MemoryKey<T> memoryKey) {
return (MemoryModuleType<U>) IRegistry.MEMORY_MODULE_TYPE.get(CraftNamespacedKey.toMinecraft(memoryKey.getKey()));
return (MemoryModuleType<U>) BuiltInRegistries.MEMORY_MODULE_TYPE.get(CraftNamespacedKey.toMinecraft(memoryKey.getKey()));
}
public static <T, U> MemoryKey<U> toMemoryKey(MemoryModuleType<T> memoryModuleType) {
return MemoryKey.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.MEMORY_MODULE_TYPE.getKey(memoryModuleType)));
return MemoryKey.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.MEMORY_MODULE_TYPE.getKey(memoryModuleType)));
}
}

View File

@@ -840,8 +840,8 @@ public class CraftEventFactory {
/**
* Server methods
*/
public static ServerListPingEvent callServerListPingEvent(Server craftServer, InetAddress address, String motd, boolean shouldSendChatPreviews, int numPlayers, int maxPlayers) {
ServerListPingEvent event = new ServerListPingEvent(address, motd, shouldSendChatPreviews, numPlayers, maxPlayers);
public static ServerListPingEvent callServerListPingEvent(Server craftServer, InetAddress address, String motd, int numPlayers, int maxPlayers) {
ServerListPingEvent event = new ServerListPingEvent("", address, motd, numPlayers, maxPlayers);
craftServer.getPluginManager().callEvent(event);
return event;
}
@@ -924,7 +924,7 @@ public class CraftEventFactory {
} else if (blockDamage != null) {
DamageCause cause = null;
Block damager = blockDamage;
if (source == DamageSource.CACTUS || source == DamageSource.SWEET_BERRY_BUSH || source == DamageSource.STALAGMITE || source == DamageSource.FALLING_STALACTITE || source == DamageSource.ANVIL) {
if (source == DamageSource.CACTUS || source == DamageSource.SWEET_BERRY_BUSH || source == DamageSource.STALAGMITE || "fallingStalactite".equals(source.msgId) || "anvil".equals(source.msgId)) {
cause = DamageCause.CONTACT;
} else if (source == DamageSource.HOT_FLOOR) {
cause = DamageCause.HOT_FLOOR;
@@ -952,7 +952,7 @@ public class CraftEventFactory {
DamageCause cause = null;
CraftEntity damager = entityDamage.getBukkitEntity();
entityDamage = null;
if (source == DamageSource.ANVIL || source == DamageSource.FALLING_BLOCK || source == DamageSource.FALLING_STALACTITE) {
if ("fallingStalactite".equals(source.msgId) || "fallingBlock".equals(source.msgId) || "anvil".equals(source.msgId)) {
cause = DamageCause.FALLING_BLOCK;
} else if (damager instanceof LightningStrike) {
cause = DamageCause.LIGHTNING;
@@ -1046,7 +1046,7 @@ public class CraftEventFactory {
Map<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<DamageModifier, Function<? super Double, Double>>(DamageModifier.class);
modifiers.put(DamageModifier.BASE, rawDamage);
modifierFunctions.put(DamageModifier.BASE, ZERO);
if (source == DamageSource.FALLING_BLOCK || source == DamageSource.ANVIL) {
if ("fallingBlock".equals(source.msgId) || "anvil".equals(source.msgId)) {
modifiers.put(DamageModifier.HARD_HAT, hardHatModifier);
modifierFunctions.put(DamageModifier.HARD_HAT, hardHat);
}

View File

@@ -22,7 +22,7 @@ public class CraftWorldInfo implements WorldInfo {
this.name = worldDataServer.getLevelName();
this.uuid = WorldUUID.getUUID(session.levelDirectory.path().toFile());
this.environment = environment;
this.seed = ((WorldDataServer) worldDataServer).worldGenSettings().seed();
this.seed = ((WorldDataServer) worldDataServer).worldGenOptions().seed();
this.minHeight = dimensionManager.minY();
this.maxHeight = dimensionManager.minY() + dimensionManager.height();
}

View File

@@ -25,6 +25,7 @@ import net.minecraft.world.level.biome.WorldChunkManager;
import net.minecraft.world.level.block.ITileEntity;
import net.minecraft.world.level.block.entity.TileEntity;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.chunk.ChunkGeneratorStructureState;
import net.minecraft.world.level.chunk.ChunkSection;
import net.minecraft.world.level.chunk.IChunkAccess;
import net.minecraft.world.level.chunk.ProtoChunk;
@@ -86,7 +87,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
}
public CustomChunkGenerator(WorldServer world, net.minecraft.world.level.chunk.ChunkGenerator delegate, ChunkGenerator generator) {
super(delegate.structureSets, delegate.structureOverrides, delegate.getBiomeSource());
super(delegate.getBiomeSource(), delegate.generationSettingsGetter);
this.world = world;
this.delegate = delegate;
@@ -117,14 +118,14 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
}
@Override
public void createStructures(IRegistryCustom iregistrycustom, RandomState randomstate, StructureManager structuremanager, IChunkAccess ichunkaccess, StructureTemplateManager structuretemplatemanager, long i) {
public void createStructures(IRegistryCustom iregistrycustom, ChunkGeneratorStructureState chunkgeneratorstructurestate, StructureManager structuremanager, IChunkAccess ichunkaccess, StructureTemplateManager structuretemplatemanager) {
SeededRandom random = getSeededRandom();
int x = ichunkaccess.getPos().x;
int z = ichunkaccess.getPos().z;
random.setSeed(MathHelper.getSeed(x, "should-structures".hashCode(), z) ^ i);
random.setSeed(MathHelper.getSeed(x, "should-structures".hashCode(), z) ^ world.getSeed());
if (generator.shouldGenerateStructures(this.world.getWorld(), new RandomSourceWrapper.RandomWrapper(random), x, z)) {
super.createStructures(iregistrycustom, randomstate, structuremanager, ichunkaccess, structuretemplatemanager, i);
super.createStructures(iregistrycustom, chunkgeneratorstructurestate, structuremanager, ichunkaccess, structuretemplatemanager);
}
}

View File

@@ -1,15 +1,15 @@
package org.bukkit.craftbukkit.generator;
import java.util.Optional;
import net.minecraft.core.HolderSet;
import net.minecraft.core.IRegistry;
import java.util.function.Function;
import net.minecraft.core.Holder;
import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.biome.BiomeSettingsGeneration;
import net.minecraft.world.level.biome.WorldChunkManager;
import net.minecraft.world.level.levelgen.structure.StructureSet;
// Do not implement functions to this class, add to NormalChunkGenerator
public abstract class InternalChunkGenerator extends net.minecraft.world.level.chunk.ChunkGenerator {
public InternalChunkGenerator(IRegistry<StructureSet> iregistry, Optional<HolderSet<StructureSet>> optional, WorldChunkManager worldchunkmanager) {
super(iregistry, optional, worldchunkmanager);
public InternalChunkGenerator(WorldChunkManager worldchunkmanager, Function<Holder<BiomeBase>, BiomeSettingsGeneration> function) {
super(worldchunkmanager, function);
}
}

View File

@@ -1,7 +1,7 @@
package org.bukkit.craftbukkit.generator.strucutre;
import net.minecraft.core.IRegistry;
import net.minecraft.core.IRegistryCustom;
import net.minecraft.core.registries.Registries;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
@@ -15,7 +15,7 @@ public class CraftStructure extends Structure {
return null;
}
return Registry.STRUCTURE.get(CraftNamespacedKey.fromMinecraft(registryHolder.registryOrThrow(IRegistry.STRUCTURE_REGISTRY).getKey(minecraft)));
return Registry.STRUCTURE.get(CraftNamespacedKey.fromMinecraft(registryHolder.registryOrThrow(Registries.STRUCTURE).getKey(minecraft)));
}
public static net.minecraft.world.level.levelgen.structure.Structure bukkitToMinecraft(Structure bukkit) {

View File

@@ -1,6 +1,6 @@
package org.bukkit.craftbukkit.generator.strucutre;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
@@ -13,7 +13,7 @@ public class CraftStructureType extends StructureType {
return null;
}
return Registry.STRUCTURE_TYPE.get(CraftNamespacedKey.fromMinecraft(IRegistry.STRUCTURE_TYPES.getKey(minecraft)));
return Registry.STRUCTURE_TYPE.get(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.STRUCTURE_TYPE.getKey(minecraft)));
}
public static net.minecraft.world.level.levelgen.structure.StructureType<?> bukkitToMinecraft(StructureType bukkit) {

View File

@@ -18,6 +18,7 @@ public class CraftBlastingRecipe extends BlastingRecipe implements CraftRecipe {
}
CraftBlastingRecipe ret = new CraftBlastingRecipe(recipe.getKey(), recipe.getResult(), recipe.getInputChoice(), recipe.getExperience(), recipe.getCookingTime());
ret.setGroup(recipe.getGroup());
ret.setCategory(recipe.getCategory());
return ret;
}
@@ -25,6 +26,6 @@ public class CraftBlastingRecipe extends BlastingRecipe implements CraftRecipe {
public void addToCraftingManager() {
ItemStack result = this.getResult();
MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.RecipeBlasting(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime()));
MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.RecipeBlasting(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftRecipe.getCategory(this.getCategory()), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime()));
}
}

View File

@@ -18,6 +18,7 @@ public class CraftCampfireRecipe extends CampfireRecipe implements CraftRecipe {
}
CraftCampfireRecipe ret = new CraftCampfireRecipe(recipe.getKey(), recipe.getResult(), recipe.getInputChoice(), recipe.getExperience(), recipe.getCookingTime());
ret.setGroup(recipe.getGroup());
ret.setCategory(recipe.getCategory());
return ret;
}
@@ -25,6 +26,6 @@ public class CraftCampfireRecipe extends CampfireRecipe implements CraftRecipe {
public void addToCraftingManager() {
ItemStack result = this.getResult();
MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.RecipeCampfire(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime()));
MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.RecipeCampfire(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftRecipe.getCategory(this.getCategory()), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime()));
}
}

View File

@@ -1,34 +0,0 @@
package org.bukkit.craftbukkit.inventory;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import net.minecraft.world.item.CreativeModeTab;
import org.bukkit.inventory.CreativeCategory;
public final class CraftCreativeCategory {
private static final Map<CreativeModeTab, CreativeCategory> NMS_TO_BUKKIT = ImmutableMap.<CreativeModeTab, CreativeCategory>builder()
.put(CreativeModeTab.TAB_BUILDING_BLOCKS, CreativeCategory.BUILDING_BLOCKS)
.put(CreativeModeTab.TAB_DECORATIONS, CreativeCategory.DECORATIONS)
.put(CreativeModeTab.TAB_REDSTONE, CreativeCategory.REDSTONE)
.put(CreativeModeTab.TAB_TRANSPORTATION, CreativeCategory.TRANSPORTATION)
.put(CreativeModeTab.TAB_MISC, CreativeCategory.MISC) // Interchangeable with TAB_MATERIALS, same instance
.put(CreativeModeTab.TAB_FOOD, CreativeCategory.FOOD)
.put(CreativeModeTab.TAB_TOOLS, CreativeCategory.TOOLS)
.put(CreativeModeTab.TAB_COMBAT, CreativeCategory.COMBAT)
.put(CreativeModeTab.TAB_BREWING, CreativeCategory.BREWING)
.build();
public static CreativeCategory fromNMS(CreativeModeTab tab) {
if (tab == null) {
return null;
}
CreativeCategory bukkit = NMS_TO_BUKKIT.get(tab);
if (bukkit == null) {
throw new UnsupportedOperationException("Item is not present in any known CreativeModeTab. This is a bug.");
}
return bukkit;
}
}

View File

@@ -18,6 +18,7 @@ public class CraftFurnaceRecipe extends FurnaceRecipe implements CraftRecipe {
}
CraftFurnaceRecipe ret = new CraftFurnaceRecipe(recipe.getKey(), recipe.getResult(), recipe.getInputChoice(), recipe.getExperience(), recipe.getCookingTime());
ret.setGroup(recipe.getGroup());
ret.setCategory(recipe.getCategory());
return ret;
}
@@ -25,6 +26,6 @@ public class CraftFurnaceRecipe extends FurnaceRecipe implements CraftRecipe {
public void addToCraftingManager() {
ItemStack result = this.getResult();
MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.FurnaceRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime()));
MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.FurnaceRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftRecipe.getCategory(this.getCategory()), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime()));
}
}

View File

@@ -9,6 +9,7 @@ import net.minecraft.world.inventory.InventoryCrafting;
import net.minecraft.world.inventory.InventoryEnderChest;
import net.minecraft.world.inventory.InventoryMerchant;
import net.minecraft.world.level.block.BlockComposter;
import net.minecraft.world.level.block.entity.ChiseledBookShelfBlockEntity;
import net.minecraft.world.level.block.entity.IHopper;
import net.minecraft.world.level.block.entity.TileEntityBarrel;
import net.minecraft.world.level.block.entity.TileEntityBlastFurnace;
@@ -489,6 +490,8 @@ public class CraftInventory implements Inventory {
return InventoryType.BARREL;
} else if (inventory instanceof TileEntityLectern.LecternInventory) {
return InventoryType.LECTERN;
} else if (inventory instanceof ChiseledBookShelfBlockEntity) {
return InventoryType.CHISELED_BOOKSHELF;
} else if (this instanceof CraftInventoryLoom) {
return InventoryType.LOOM;
} else if (this instanceof CraftInventoryCartography) {

View File

@@ -0,0 +1,18 @@
package org.bukkit.craftbukkit.inventory;
import net.minecraft.world.level.block.entity.ChiseledBookShelfBlockEntity;
import org.bukkit.block.ChiseledBookshelf;
import org.bukkit.inventory.ChiseledBookshelfInventory;
public class CraftInventoryChiseledBookshelf extends CraftInventory implements ChiseledBookshelfInventory {
public CraftInventoryChiseledBookshelf(ChiseledBookShelfBlockEntity inventory) {
super(inventory);
}
@Override
public ChiseledBookshelf getHolder() {
return (ChiseledBookshelf) inventory.getOwner();
}
}

View File

@@ -4,7 +4,7 @@ import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.commands.arguments.item.ArgumentParserItemStack;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.item.Item;
import org.apache.commons.lang.Validate;
@@ -68,6 +68,8 @@ public final class CraftItemFactory implements ItemFactory {
case CREEPER_WALL_HEAD:
case DRAGON_HEAD:
case DRAGON_WALL_HEAD:
case PIGLIN_HEAD:
case PIGLIN_WALL_HEAD:
case PLAYER_HEAD:
case PLAYER_WALL_HEAD:
case SKELETON_SKULL:
@@ -207,23 +209,45 @@ public final class CraftItemFactory implements ItemFactory {
case JUKEBOX:
case DISPENSER:
case DROPPER:
case ACACIA_HANGING_SIGN:
case ACACIA_SIGN:
case ACACIA_WALL_HANGING_SIGN:
case ACACIA_WALL_SIGN:
case BAMBOO_HANGING_SIGN:
case BAMBOO_SIGN:
case BAMBOO_WALL_HANGING_SIGN:
case BAMBOO_WALL_SIGN:
case BIRCH_HANGING_SIGN:
case BIRCH_SIGN:
case BIRCH_WALL_HANGING_SIGN:
case BIRCH_WALL_SIGN:
case CRIMSON_HANGING_SIGN:
case CRIMSON_SIGN:
case CRIMSON_WALL_HANGING_SIGN:
case CRIMSON_WALL_SIGN:
case DARK_OAK_HANGING_SIGN:
case DARK_OAK_SIGN:
case DARK_OAK_WALL_HANGING_SIGN:
case DARK_OAK_WALL_SIGN:
case JUNGLE_HANGING_SIGN:
case JUNGLE_SIGN:
case JUNGLE_WALL_HANGING_SIGN:
case JUNGLE_WALL_SIGN:
case MANGROVE_HANGING_SIGN:
case MANGROVE_SIGN:
case MANGROVE_WALL_HANGING_SIGN:
case MANGROVE_WALL_SIGN:
case OAK_HANGING_SIGN:
case OAK_SIGN:
case OAK_WALL_HANGING_SIGN:
case OAK_WALL_SIGN:
case SPRUCE_HANGING_SIGN:
case SPRUCE_SIGN:
case SPRUCE_WALL_HANGING_SIGN:
case SPRUCE_WALL_SIGN:
case WARPED_HANGING_SIGN:
case WARPED_SIGN:
case WARPED_WALL_HANGING_SIGN:
case WARPED_WALL_SIGN:
case SPAWNER:
case BREWING_STAND:
@@ -268,6 +292,7 @@ public final class CraftItemFactory implements ItemFactory {
case SCULK_CATALYST:
case SCULK_SHRIEKER:
case SCULK_SENSOR:
case CHISELED_BOOKSHELF:
return new CraftMetaBlockState(meta, material);
case TROPICAL_FISH_BUCKET:
return meta instanceof CraftMetaTropicalFishBucket ? meta : new CraftMetaTropicalFishBucket(meta);
@@ -354,7 +379,7 @@ public final class CraftItemFactory implements ItemFactory {
@Override
public ItemStack createItemStack(String input) throws IllegalArgumentException {
try {
ArgumentParserItemStack.a arg = ArgumentParserItemStack.parseForItem(HolderLookup.forRegistry(IRegistry.ITEM), new StringReader(input));
ArgumentParserItemStack.a arg = ArgumentParserItemStack.parseForItem(BuiltInRegistries.ITEM.asLookup(), new StringReader(input));
Item item = arg.item().value();
net.minecraft.world.item.ItemStack nmsItemStack = new net.minecraft.world.item.ItemStack(item);

View File

@@ -331,6 +331,8 @@ public final class CraftItemStack extends ItemStack {
case CREEPER_WALL_HEAD:
case DRAGON_HEAD:
case DRAGON_WALL_HEAD:
case PIGLIN_HEAD:
case PIGLIN_WALL_HEAD:
case PLAYER_HEAD:
case PLAYER_WALL_HEAD:
case SKELETON_SKULL:
@@ -470,23 +472,45 @@ public final class CraftItemStack extends ItemStack {
case JUKEBOX:
case DISPENSER:
case DROPPER:
case ACACIA_HANGING_SIGN:
case ACACIA_SIGN:
case ACACIA_WALL_HANGING_SIGN:
case ACACIA_WALL_SIGN:
case BAMBOO_HANGING_SIGN:
case BAMBOO_SIGN:
case BAMBOO_WALL_HANGING_SIGN:
case BAMBOO_WALL_SIGN:
case BIRCH_HANGING_SIGN:
case BIRCH_SIGN:
case BIRCH_WALL_HANGING_SIGN:
case BIRCH_WALL_SIGN:
case CRIMSON_HANGING_SIGN:
case CRIMSON_SIGN:
case CRIMSON_WALL_HANGING_SIGN:
case CRIMSON_WALL_SIGN:
case DARK_OAK_HANGING_SIGN:
case DARK_OAK_SIGN:
case DARK_OAK_WALL_HANGING_SIGN:
case DARK_OAK_WALL_SIGN:
case JUNGLE_HANGING_SIGN:
case JUNGLE_SIGN:
case JUNGLE_WALL_HANGING_SIGN:
case JUNGLE_WALL_SIGN:
case MANGROVE_HANGING_SIGN:
case MANGROVE_SIGN:
case MANGROVE_WALL_HANGING_SIGN:
case MANGROVE_WALL_SIGN:
case OAK_HANGING_SIGN:
case OAK_SIGN:
case OAK_WALL_HANGING_SIGN:
case OAK_WALL_SIGN:
case SPRUCE_HANGING_SIGN:
case SPRUCE_SIGN:
case SPRUCE_WALL_HANGING_SIGN:
case SPRUCE_WALL_SIGN:
case WARPED_HANGING_SIGN:
case WARPED_SIGN:
case WARPED_WALL_HANGING_SIGN:
case WARPED_WALL_SIGN:
case SPAWNER:
case BREWING_STAND:
@@ -531,6 +555,7 @@ public final class CraftItemStack extends ItemStack {
case SCULK_CATALYST:
case SCULK_SHRIEKER:
case SCULK_SENSOR:
case CHISELED_BOOKSHELF:
return new CraftMetaBlockState(item.getTag(), CraftMagicNumbers.getMaterial(item.getItem()));
case TROPICAL_FISH_BUCKET:
return new CraftMetaTropicalFishBucket(item.getTag());

View File

@@ -47,23 +47,45 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
Material.JUKEBOX,
Material.DISPENSER,
Material.DROPPER,
Material.ACACIA_HANGING_SIGN,
Material.ACACIA_SIGN,
Material.ACACIA_WALL_HANGING_SIGN,
Material.ACACIA_WALL_SIGN,
Material.BAMBOO_HANGING_SIGN,
Material.BAMBOO_SIGN,
Material.BAMBOO_WALL_HANGING_SIGN,
Material.BAMBOO_WALL_SIGN,
Material.BIRCH_HANGING_SIGN,
Material.BIRCH_SIGN,
Material.BIRCH_WALL_HANGING_SIGN,
Material.BIRCH_WALL_SIGN,
Material.CRIMSON_HANGING_SIGN,
Material.CRIMSON_SIGN,
Material.CRIMSON_WALL_HANGING_SIGN,
Material.CRIMSON_WALL_SIGN,
Material.DARK_OAK_HANGING_SIGN,
Material.DARK_OAK_SIGN,
Material.DARK_OAK_WALL_HANGING_SIGN,
Material.DARK_OAK_WALL_SIGN,
Material.JUNGLE_HANGING_SIGN,
Material.JUNGLE_SIGN,
Material.JUNGLE_WALL_HANGING_SIGN,
Material.JUNGLE_WALL_SIGN,
Material.MANGROVE_HANGING_SIGN,
Material.MANGROVE_SIGN,
Material.MANGROVE_WALL_HANGING_SIGN,
Material.MANGROVE_WALL_SIGN,
Material.OAK_HANGING_SIGN,
Material.OAK_SIGN,
Material.OAK_WALL_HANGING_SIGN,
Material.OAK_WALL_SIGN,
Material.SPRUCE_HANGING_SIGN,
Material.SPRUCE_SIGN,
Material.SPRUCE_WALL_HANGING_SIGN,
Material.SPRUCE_WALL_SIGN,
Material.WARPED_HANGING_SIGN,
Material.WARPED_SIGN,
Material.WARPED_WALL_HANGING_SIGN,
Material.WARPED_WALL_SIGN,
Material.SPAWNER,
Material.BREWING_STAND,
@@ -90,7 +112,8 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
Material.BEE_NEST,
Material.SCULK_CATALYST,
Material.SCULK_SHRIEKER,
Material.SCULK_SENSOR
Material.SCULK_SENSOR,
Material.CHISELED_BOOKSHELF
);
static {

View File

@@ -28,6 +28,8 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
Material.CREEPER_WALL_HEAD,
Material.DRAGON_HEAD,
Material.DRAGON_WALL_HEAD,
Material.PIGLIN_HEAD,
Material.PIGLIN_WALL_HEAD,
Material.PLAYER_HEAD,
Material.PLAYER_WALL_HEAD,
Material.SKELETON_SKULL,

View File

@@ -7,6 +7,8 @@ import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.RecipeChoice;
import org.bukkit.inventory.recipe.CookingBookCategory;
import org.bukkit.inventory.recipe.CraftingBookCategory;
public interface CraftRecipe extends Recipe {
@@ -26,7 +28,7 @@ public interface CraftRecipe extends Recipe {
throw new IllegalArgumentException("Unknown recipe stack instance " + bukkit);
}
stack.dissolve();
stack.getItems();
if (requireNotEmpty && stack.itemStacks.length == 0) {
throw new IllegalArgumentException("Recipe requires at least one non-air choice!");
}
@@ -35,7 +37,7 @@ public interface CraftRecipe extends Recipe {
}
public static RecipeChoice toBukkit(RecipeItemStack list) {
list.dissolve();
list.getItems();
if (list.itemStacks.length == 0) {
return null;
@@ -58,4 +60,20 @@ public interface CraftRecipe extends Recipe {
return new RecipeChoice.MaterialChoice(choices);
}
}
public static net.minecraft.world.item.crafting.CraftingBookCategory getCategory(CraftingBookCategory bukkit) {
return net.minecraft.world.item.crafting.CraftingBookCategory.valueOf(bukkit.name());
}
public static CraftingBookCategory getCategory(net.minecraft.world.item.crafting.CraftingBookCategory nms) {
return CraftingBookCategory.valueOf(nms.name());
}
public static net.minecraft.world.item.crafting.CookingBookCategory getCategory(CookingBookCategory bukkit) {
return net.minecraft.world.item.crafting.CookingBookCategory.valueOf(bukkit.name());
}
public static CookingBookCategory getCategory(net.minecraft.world.item.crafting.CookingBookCategory nms) {
return CookingBookCategory.valueOf(nms.name());
}
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.craftbukkit.inventory;
import java.util.Map;
import net.minecraft.core.NonNullList;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.item.crafting.CraftingBookCategory;
import net.minecraft.world.item.crafting.RecipeItemStack;
import net.minecraft.world.item.crafting.ShapedRecipes;
import org.bukkit.NamespacedKey;
@@ -30,6 +31,7 @@ public class CraftShapedRecipe extends ShapedRecipe implements CraftRecipe {
}
CraftShapedRecipe ret = new CraftShapedRecipe(recipe.getKey(), recipe.getResult());
ret.setGroup(recipe.getGroup());
ret.setCategory(recipe.getCategory());
String[] shape = recipe.getShape();
ret.shape(shape);
Map<Character, RecipeChoice> ingredientMap = recipe.getChoiceMap();
@@ -55,7 +57,6 @@ public class CraftShapedRecipe extends ShapedRecipe implements CraftRecipe {
data.set(i * width + j, toNMS(ingred.get(row.charAt(j)), false));
}
}
MinecraftServer.getServer().getRecipeManager().addRecipe(new ShapedRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), width, shape.length, data, CraftItemStack.asNMSCopy(this.getResult())));
MinecraftServer.getServer().getRecipeManager().addRecipe(new ShapedRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftRecipe.getCategory(this.getCategory()), width, shape.length, data, CraftItemStack.asNMSCopy(this.getResult())));
}
}

View File

@@ -30,6 +30,7 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe
}
CraftShapelessRecipe ret = new CraftShapelessRecipe(recipe.getKey(), recipe.getResult());
ret.setGroup(recipe.getGroup());
ret.setCategory(recipe.getCategory());
for (RecipeChoice ingred : recipe.getChoiceList()) {
ret.addIngredient(ingred);
}
@@ -44,6 +45,6 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe
data.set(i, toNMS(ingred.get(i), true));
}
MinecraftServer.getServer().getRecipeManager().addRecipe(new ShapelessRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftItemStack.asNMSCopy(this.getResult()), data));
MinecraftServer.getServer().getRecipeManager().addRecipe(new ShapelessRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data));
}
}

View File

@@ -18,6 +18,7 @@ public class CraftSmokingRecipe extends SmokingRecipe implements CraftRecipe {
}
CraftSmokingRecipe ret = new CraftSmokingRecipe(recipe.getKey(), recipe.getResult(), recipe.getInputChoice(), recipe.getExperience(), recipe.getCookingTime());
ret.setGroup(recipe.getGroup());
ret.setCategory(recipe.getCategory());
return ret;
}
@@ -25,6 +26,6 @@ public class CraftSmokingRecipe extends SmokingRecipe implements CraftRecipe {
public void addToCraftingManager() {
ItemStack result = this.getResult();
MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.RecipeSmoking(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime()));
MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.RecipeSmoking(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftRecipe.getCategory(this.getCategory()), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime()));
}
}

View File

@@ -10,6 +10,7 @@ import java.util.Optional;
import java.util.Set;
import net.minecraft.SharedConstants;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.DynamicOpsNBT;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
@@ -333,7 +334,7 @@ public final class CraftLegacy {
}
String name = blockTag.get("Name").asString("");
Block block = IRegistry.BLOCK.get(new MinecraftKey(name));
Block block = BuiltInRegistries.BLOCK.get(new MinecraftKey(name));
if (block == null) {
continue;
}
@@ -411,7 +412,7 @@ public final class CraftLegacy {
}
// Preconditions.checkState(newId.contains("minecraft:"), "Unknown new material for " + matData);
Item newMaterial = IRegistry.ITEM.get(new MinecraftKey(newId));
Item newMaterial = BuiltInRegistries.ITEM.get(new MinecraftKey(newId));
if (newMaterial == Items.AIR) {
continue;

View File

@@ -74,22 +74,22 @@ public final class CraftMapView implements MapView {
@Override
public int getCenterX() {
return worldMap.x;
return worldMap.centerX;
}
@Override
public int getCenterZ() {
return worldMap.z;
return worldMap.centerZ;
}
@Override
public void setCenterX(int x) {
worldMap.x = x;
worldMap.centerX = x;
}
@Override
public void setCenterZ(int z) {
worldMap.z = z;
worldMap.centerZ = z;
}
@Override

View File

@@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.potion;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.effect.MobEffectList;
import org.bukkit.Color;
import org.bukkit.potion.PotionEffectType;
@@ -8,7 +9,7 @@ public class CraftPotionEffectType extends PotionEffectType {
private final MobEffectList handle;
public CraftPotionEffectType(MobEffectList handle) {
super(MobEffectList.getId(handle), org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(net.minecraft.core.IRegistry.MOB_EFFECT.getKey(handle)));
super(MobEffectList.getId(handle), org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(BuiltInRegistries.MOB_EFFECT.getKey(handle)));
this.handle = handle;
}

View File

@@ -1,10 +1,10 @@
package org.bukkit.craftbukkit.tag;
import java.util.Collections;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.EntityTypes;
@@ -20,7 +20,7 @@ public class CraftEntityTag extends CraftTag<EntityTypes<?>, EntityType> {
@Override
public boolean isTagged(EntityType entity) {
return registry.getHolderOrThrow(ResourceKey.create(IRegistry.ENTITY_TYPE_REGISTRY, CraftNamespacedKey.toMinecraft(entity.getKey()))).is(tag);
return registry.getHolderOrThrow(ResourceKey.create(Registries.ENTITY_TYPE, CraftNamespacedKey.toMinecraft(entity.getKey()))).is(tag);
}
@Override

View File

@@ -23,7 +23,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.SharedConstants;
import net.minecraft.advancements.critereon.LootDeserializationContext;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.DynamicOpsNBT;
import net.minecraft.nbt.MojangsonParser;
import net.minecraft.nbt.NBTBase;
@@ -36,7 +36,6 @@ import net.minecraft.util.ChatDeserializer;
import net.minecraft.util.datafix.DataConverterRegistry;
import net.minecraft.util.datafix.fixes.DataConverterTypes;
import net.minecraft.world.entity.ai.attributes.AttributeBase;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.IBlockData;
@@ -56,7 +55,6 @@ import org.bukkit.craftbukkit.CraftEquipmentSlot;
import org.bukkit.craftbukkit.attribute.CraftAttributeInstance;
import org.bukkit.craftbukkit.attribute.CraftAttributeMap;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.bukkit.craftbukkit.inventory.CraftCreativeCategory;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.legacy.CraftLegacy;
import org.bukkit.inventory.CreativeCategory;
@@ -105,16 +103,16 @@ public final class CraftMagicNumbers implements UnsafeValues {
private static final Map<Material, FluidType> MATERIAL_FLUID = new HashMap<>();
static {
for (Block block : IRegistry.BLOCK) {
BLOCK_MATERIAL.put(block, Material.getMaterial(IRegistry.BLOCK.getKey(block).getPath().toUpperCase(Locale.ROOT)));
for (Block block : BuiltInRegistries.BLOCK) {
BLOCK_MATERIAL.put(block, Material.getMaterial(BuiltInRegistries.BLOCK.getKey(block).getPath().toUpperCase(Locale.ROOT)));
}
for (Item item : IRegistry.ITEM) {
ITEM_MATERIAL.put(item, Material.getMaterial(IRegistry.ITEM.getKey(item).getPath().toUpperCase(Locale.ROOT)));
for (Item item : BuiltInRegistries.ITEM) {
ITEM_MATERIAL.put(item, Material.getMaterial(BuiltInRegistries.ITEM.getKey(item).getPath().toUpperCase(Locale.ROOT)));
}
for (FluidType fluid : IRegistry.FLUID) {
FLUID_MATERIAL.put(fluid, Registry.FLUID.get(CraftNamespacedKey.fromMinecraft(IRegistry.FLUID.getKey(fluid))));
for (FluidType fluid : BuiltInRegistries.FLUID) {
FLUID_MATERIAL.put(fluid, Registry.FLUID.get(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.FLUID.getKey(fluid))));
}
for (Material material : Material.values()) {
@@ -123,13 +121,13 @@ public final class CraftMagicNumbers implements UnsafeValues {
}
MinecraftKey key = key(material);
IRegistry.ITEM.getOptional(key).ifPresent((item) -> {
BuiltInRegistries.ITEM.getOptional(key).ifPresent((item) -> {
MATERIAL_ITEM.put(material, item);
});
IRegistry.BLOCK.getOptional(key).ifPresent((block) -> {
BuiltInRegistries.BLOCK.getOptional(key).ifPresent((block) -> {
MATERIAL_BLOCK.put(material, block);
});
IRegistry.FLUID.getOptional(key).ifPresent((fluid) -> {
BuiltInRegistries.FLUID.getOptional(key).ifPresent((fluid) -> {
MATERIAL_FLUID.put(material, fluid);
});
}
@@ -237,7 +235,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
* @return string
*/
public String getMappingsVersion() {
return "69c84c88aeb92ce9fa9525438b93f4fe";
return "1afe2ffe8a9d7fc510442a168b3d4338";
}
@Override
@@ -351,7 +349,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
Multimap<AttributeBase, net.minecraft.world.entity.ai.attributes.AttributeModifier> nmsDefaultAttributes = getItem(material).getDefaultAttributeModifiers(CraftEquipmentSlot.getNMS(slot));
for (Entry<AttributeBase, net.minecraft.world.entity.ai.attributes.AttributeModifier> mapEntry : nmsDefaultAttributes.entries()) {
Attribute attribute = CraftAttributeMap.fromMinecraft(IRegistry.ATTRIBUTE.getKey(mapEntry.getKey()).toString());
Attribute attribute = CraftAttributeMap.fromMinecraft(BuiltInRegistries.ATTRIBUTE.getKey(mapEntry.getKey()).toString());
defaultAttributes.put(attribute, CraftAttributeInstance.convert(mapEntry.getValue(), slot));
}
@@ -360,8 +358,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
@Override
public CreativeCategory getCreativeCategory(Material material) {
CreativeModeTab category = getItem(material).getItemCategory();
return CraftCreativeCategory.fromNMS(category);
return CreativeCategory.BUILDING_BLOCKS; // TODO: Figure out what to do with this
}
/**

View File

@@ -1,7 +1,6 @@
package org.bukkit.craftbukkit.util;
import java.util.List;
import java.util.Random;
import java.util.function.Predicate;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.EnumDirection;
@@ -16,6 +15,7 @@ import net.minecraft.util.RandomSource;
import net.minecraft.world.DifficultyDamageScaler;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.EntityHuman;
import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.level.GeneratorAccessSeed;
import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.biome.BiomeManager;
@@ -124,11 +124,6 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public IRegistryCustom registryAccess() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<Entity> getEntities(Entity entity, AxisAlignedBB aabb, Predicate<? super Entity> prdct) {
throw new UnsupportedOperationException("Not supported yet.");
@@ -184,6 +179,16 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public IRegistryCustom registryAccess() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public FeatureFlagSet enabledFeatures() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public float getShade(EnumDirection ed, boolean bln) {
throw new UnsupportedOperationException("Not supported yet.");