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

@@ -9,7 +9,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.craftbukkit.CraftArt;
@@ -23,8 +23,8 @@ public class ArtTest extends AbstractTestingBase {
public void verifyMapping() {
List<Art> arts = Lists.newArrayList(Art.values());
for (ResourceKey<PaintingVariant> key : IRegistry.PAINTING_VARIANT.registryKeySet()) {
Holder<PaintingVariant> enumArt = IRegistry.PAINTING_VARIANT.getHolderOrThrow(key);
for (ResourceKey<PaintingVariant> key : BuiltInRegistries.PAINTING_VARIANT.registryKeySet()) {
Holder<PaintingVariant> enumArt = BuiltInRegistries.PAINTING_VARIANT.getHolderOrThrow(key);
String name = key.location().getPath();
int width = enumArt.value().getWidth() / UNIT_MULTIPLIER;
int height = enumArt.value().getHeight() / UNIT_MULTIPLIER;
@@ -57,7 +57,7 @@ public class ArtTest extends AbstractTestingBase {
@Test
public void testCraftArtToBukkit() {
Map<Art, Holder<PaintingVariant>> cache = new EnumMap(Art.class);
for (Holder<PaintingVariant> enumArt : IRegistry.PAINTING_VARIANT.asHolderIdMap()) {
for (Holder<PaintingVariant> enumArt : BuiltInRegistries.PAINTING_VARIANT.asHolderIdMap()) {
Art art = CraftArt.NotchToBukkit(enumArt);
assertNotNull("Could not CraftArt.NotchToBukkit " + enumArt, art);
assertThat("Duplicate artwork " + enumArt, cache.put(art, enumArt), is(nullValue()));

View File

@@ -1,6 +1,5 @@
package org.bukkit;
import net.minecraft.data.RegistryGeneration;
import net.minecraft.world.level.biome.BiomeBase;
import org.bukkit.block.Biome;
import org.bukkit.craftbukkit.block.CraftBlock;
@@ -17,14 +16,14 @@ public class BiomeTest extends AbstractTestingBase {
continue;
}
Assert.assertNotNull("No NMS mapping for " + biome, CraftBlock.biomeToBiomeBase(RegistryGeneration.BIOME, biome));
Assert.assertNotNull("No NMS mapping for " + biome, CraftBlock.biomeToBiomeBase(BIOMES, biome));
}
}
@Test
public void testMinecraftToBukkit() {
for (BiomeBase biomeBase : RegistryGeneration.BIOME) {
Biome biome = CraftBlock.biomeBaseToBiome(RegistryGeneration.BIOME, biomeBase);
for (BiomeBase biomeBase : BIOMES) {
Biome biome = CraftBlock.biomeBaseToBiome(BIOMES, biomeBase);
Assert.assertTrue("No Bukkit mapping for " + biomeBase, biome != null && biome != Biome.CUSTOM);
}
}

View File

@@ -2,7 +2,7 @@ package org.bukkit;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.IBlockData;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
@@ -13,7 +13,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
/**
* This test class ensures that all Blocks (as registered in IRegistry.BLOCK)
* This test class ensures that all Blocks (as registered in BuiltInRegistries.BLOCK)
* can be converted into their CraftBlockData equivalent.
*/
@RunWith(Parameterized.class)
@@ -22,7 +22,7 @@ public class BlockDataConversionTest extends AbstractTestingBase {
@Parameterized.Parameters(name = "{index}: {0}")
public static List<Object[]> args() {
List<Object[]> list = new ArrayList<>();
for (Block block : (Iterable<Block>) IRegistry.BLOCK) {
for (Block block : (Iterable<Block>) BuiltInRegistries.BLOCK) {
list.add(new Object[]{block.defaultBlockState()});
}
return list;

View File

@@ -1,6 +1,6 @@
package org.bukkit;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.MinecraftKey;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.enchantments.Enchantment;
@@ -12,8 +12,8 @@ public class EnchantmentTest extends AbstractTestingBase {
@Test
public void verifyMapping() {
for (MinecraftKey key : IRegistry.ENCHANTMENT.keySet()) {
net.minecraft.world.item.enchantment.Enchantment nms = IRegistry.ENCHANTMENT.get(key);
for (MinecraftKey key : BuiltInRegistries.ENCHANTMENT.keySet()) {
net.minecraft.world.item.enchantment.Enchantment nms = BuiltInRegistries.ENCHANTMENT.get(key);
Enchantment bukkitById = Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(key));

View File

@@ -1,6 +1,6 @@
package org.bukkit;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.support.AbstractTestingBase;
import org.junit.Assert;
@@ -10,8 +10,8 @@ public class GameEventTest extends AbstractTestingBase {
@Test
public void toBukkit() {
for (net.minecraft.world.level.gameevent.GameEvent nms : IRegistry.GAME_EVENT) {
GameEvent bukkit = GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.GAME_EVENT.getKey(nms)));
for (net.minecraft.world.level.gameevent.GameEvent nms : BuiltInRegistries.GAME_EVENT) {
GameEvent bukkit = GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.GAME_EVENT.getKey(nms)));
Assert.assertNotNull("Bukkit should not be null " + nms, bukkit);
}

View File

@@ -11,7 +11,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.stream.StreamSupport;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.world.item.Item;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
@@ -31,13 +31,13 @@ public class MaterialTest extends AbstractTestingBase {
materials.put(CraftMagicNumbers.key(material), material);
}
Iterator<Item> items = IRegistry.ITEM.iterator();
Iterator<Item> items = BuiltInRegistries.ITEM.iterator();
while (items.hasNext()) {
Item item = items.next();
if (item == null) continue;
MinecraftKey id = IRegistry.ITEM.getKey(item);
MinecraftKey id = BuiltInRegistries.ITEM.getKey(item);
String name = item.getDescriptionId();
Material material = materials.remove(id);
@@ -53,13 +53,13 @@ public class MaterialTest extends AbstractTestingBase {
public void verifyMaterialOrder() {
List<Material> expectedOrder = new ArrayList<>(Material.values().length);
// Start with items in the same order as IRegistry.ITEM
StreamSupport.stream(IRegistry.ITEM.spliterator(), false)
// Start with items in the same order as BuiltInRegistries.ITEM
StreamSupport.stream(BuiltInRegistries.ITEM.spliterator(), false)
.map(CraftMagicNumbers::getMaterial)
.forEach(expectedOrder::add);
// Then non-item blocks in the same order as IRegistry.BLOCK
StreamSupport.stream(IRegistry.BLOCK.spliterator(), false)
// Then non-item blocks in the same order as BuiltInRegistries.BLOCK
StreamSupport.stream(BuiltInRegistries.BLOCK.spliterator(), false)
.map(CraftMagicNumbers::getMaterial)
.filter(block -> !block.isItem())
.forEach(expectedOrder::add);

View File

@@ -1,6 +1,6 @@
package org.bukkit;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.CraftParticle;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
@@ -36,8 +36,8 @@ public class ParticleTest extends AbstractTestingBase {
Assert.assertNotNull("Missing Bukkit->NMS particle mapping for " + bukkit, CraftParticle.toNMS(bukkit, data));
}
for (net.minecraft.core.particles.Particle nms : IRegistry.PARTICLE_TYPE) {
Assert.assertNotNull("Missing NMS->Bukkit particle mapping for " + IRegistry.PARTICLE_TYPE.getKey(nms), CraftParticle.toBukkit(nms));
for (net.minecraft.core.particles.Particle nms : BuiltInRegistries.PARTICLE_TYPE) {
Assert.assertNotNull("Missing NMS->Bukkit particle mapping for " + BuiltInRegistries.PARTICLE_TYPE.getKey(nms), CraftParticle.toBukkit(nms));
}
}
}

View File

@@ -5,7 +5,7 @@ import static org.junit.Assert.*;
import com.google.common.collect.Lists;
import java.util.Collections;
import java.util.List;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.MinecraftKey;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.potion.PotionEffectType;
@@ -18,7 +18,7 @@ public class PotionEffectTypeTest extends AbstractTestingBase {
public void verifyMapping() {
List<PotionEffectType> effects = Lists.newArrayList(PotionEffectType.values());
for (MinecraftKey key : IRegistry.MOB_EFFECT.keySet()) {
for (MinecraftKey key : BuiltInRegistries.MOB_EFFECT.keySet()) {
String name = key.getPath();
PotionEffectType effect = PotionEffectType.getByKey(CraftNamespacedKey.fromMinecraft(key));

View File

@@ -2,7 +2,7 @@ package org.bukkit;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.MinecraftKey;
import org.bukkit.craftbukkit.CraftSound;
import org.bukkit.support.AbstractTestingBase;
@@ -19,7 +19,7 @@ public class SoundTest extends AbstractTestingBase {
@Test
public void testReverse() {
for (MinecraftKey effect : IRegistry.SOUND_EVENT.keySet()) {
for (MinecraftKey effect : BuiltInRegistries.SOUND_EVENT.keySet()) {
assertNotNull(effect + "", Sound.valueOf(effect.getPath().replace('.', '_').toUpperCase(java.util.Locale.ENGLISH)));
}
}

View File

@@ -3,7 +3,7 @@ package org.bukkit;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import com.google.common.collect.HashMultiset;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.stats.StatisticWrapper;
import net.minecraft.world.entity.EntityTypes;
import org.bukkit.craftbukkit.CraftStatistic;
@@ -31,7 +31,7 @@ public class StatisticsAndAchievementsTest extends AbstractTestingBase {
@SuppressWarnings("unchecked")
public void verifyStatisticMapping() throws Throwable {
HashMultiset<Statistic> statistics = HashMultiset.create();
for (StatisticWrapper wrapper : IRegistry.STAT_TYPE) {
for (StatisticWrapper wrapper : BuiltInRegistries.STAT_TYPE) {
for (Object child : wrapper.getRegistry()) {
net.minecraft.stats.Statistic<?> statistic = wrapper.get(child);
String message = String.format("org.bukkit.Statistic is missing: '%s'", statistic);
@@ -39,9 +39,9 @@ public class StatisticsAndAchievementsTest extends AbstractTestingBase {
Statistic subject = CraftStatistic.getBukkitStatistic(statistic);
assertThat(message, subject, is(not(nullValue())));
if (wrapper.getRegistry() == IRegistry.BLOCK || wrapper.getRegistry() == IRegistry.ITEM) {
if (wrapper.getRegistry() == BuiltInRegistries.BLOCK || wrapper.getRegistry() == BuiltInRegistries.ITEM) {
assertNotNull("Material type map missing for " + wrapper.getRegistry().getKey(child), CraftStatistic.getMaterialFromStatistic(statistic));
} else if (wrapper.getRegistry() == IRegistry.ENTITY_TYPE) {
} else if (wrapper.getRegistry() == BuiltInRegistries.ENTITY_TYPE) {
assertNotNull("Entity type map missing for " + EntityTypes.getKey((EntityTypes<?>) child), CraftStatistic.getEntityTypeFromStatistic((net.minecraft.stats.Statistic<EntityTypes<?>>) statistic));
}

View File

@@ -1,7 +1,7 @@
package org.bukkit.block.banner;
import junit.framework.Assert;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.level.block.entity.EnumBannerPatternType;
import org.bukkit.support.AbstractTestingBase;
import org.junit.Test;
@@ -10,7 +10,7 @@ public class PatternTypeTest extends AbstractTestingBase {
@Test
public void testToBukkit() {
for (EnumBannerPatternType nms : IRegistry.BANNER_PATTERN) {
for (EnumBannerPatternType nms : BuiltInRegistries.BANNER_PATTERN) {
PatternType bukkit = PatternType.getByIdentifier(nms.getHashname());
Assert.assertNotNull("No Bukkit banner for " + nms + " " + nms.getHashname(), bukkit);
@@ -21,7 +21,7 @@ public class PatternTypeTest extends AbstractTestingBase {
public void testToNMS() {
for (PatternType bukkit : PatternType.values()) {
EnumBannerPatternType found = null;
for (EnumBannerPatternType nms : IRegistry.BANNER_PATTERN) {
for (EnumBannerPatternType nms : BuiltInRegistries.BANNER_PATTERN) {
if (bukkit.getIdentifier().equals(nms.getHashname())) {
found = nms;
break;

View File

@@ -1,6 +1,6 @@
package org.bukkit.craftbukkit.attribute;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.world.entity.ai.attributes.AttributeBase;
import org.bukkit.attribute.Attribute;
@@ -12,7 +12,7 @@ public class AttributeTest extends AbstractTestingBase {
@Test
public void testToBukkit() {
for (MinecraftKey nms : IRegistry.ATTRIBUTE.keySet()) {
for (MinecraftKey nms : BuiltInRegistries.ATTRIBUTE.keySet()) {
Attribute bukkit = CraftAttributeMap.fromMinecraft(nms.toString());
Assert.assertNotNull(nms.toString(), bukkit);

View File

@@ -5,7 +5,7 @@ import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.ITileEntity;
import net.minecraft.world.level.block.entity.TileEntity;
@@ -18,7 +18,7 @@ public class BlockStateTest extends AbstractTestingBase {
@Test
public void testTileEntityBlockStates() {
for (Block block : IRegistry.BLOCK) {
for (Block block : BuiltInRegistries.BLOCK) {
Material material = CraftMagicNumbers.getMaterial(block);
Class<?> blockStateType = CraftBlockStates.getBlockStateType(material);
boolean isCraftBlockEntityState = CraftBlockEntityState.class.isAssignableFrom(blockStateType);

View File

@@ -1,9 +1,6 @@
package org.bukkit.craftbukkit.generator;
import static org.junit.Assert.*;
import net.minecraft.core.IRegistry;
import net.minecraft.data.RegistryGeneration;
import net.minecraft.world.level.biome.BiomeBase;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.support.AbstractTestingBase;
@@ -13,7 +10,6 @@ public class ChunkDataTest extends AbstractTestingBase {
private static final BlockData RED_WOOL = Material.RED_WOOL.createBlockData();
private static final BlockData AIR = Material.AIR.createBlockData();
private static final IRegistry<BiomeBase> BIOMES = RegistryGeneration.BIOME;
private boolean testSetBlock(OldCraftChunkData data, int x, int y, int z, BlockData type, BlockData expected) {
data.setBlock(x, y, z, type);

View File

@@ -6,7 +6,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemBlock;
@@ -151,7 +151,7 @@ public class ItemMetaTest extends AbstractTestingBase {
public void testBlockStateMeta() {
List<Block> queue = new ArrayList<>();
for (Item item : IRegistry.ITEM) {
for (Item item : BuiltInRegistries.ITEM) {
if (item instanceof ItemBlock) {
queue.add(((ItemBlock) item).getBlock());
}

View File

@@ -92,6 +92,13 @@ public class LegacyTest extends AbstractTestingBase {
Material.MANGROVE_WOOD, Material.MUD, Material.MUDDY_MANGROVE_ROOTS, Material.MUD_BRICKS, Material.MUD_BRICK_SLAB, Material.MUD_BRICK_STAIRS, Material.MUD_BRICK_WALL, Material.MUSIC_DISC_5, Material.OAK_CHEST_BOAT, Material.OCHRE_FROGLIGHT,
Material.PACKED_MUD, Material.PEARLESCENT_FROGLIGHT, Material.POTTED_MANGROVE_PROPAGULE, Material.RECOVERY_COMPASS, Material.REINFORCED_DEEPSLATE, Material.SCULK, Material.SCULK_CATALYST, Material.SCULK_SHRIEKER, Material.SCULK_VEIN,
Material.SPRUCE_CHEST_BOAT, Material.STRIPPED_MANGROVE_LOG, Material.STRIPPED_MANGROVE_WOOD, Material.TADPOLE_BUCKET, Material.TADPOLE_SPAWN_EGG, Material.VERDANT_FROGLIGHT, Material.WARDEN_SPAWN_EGG,
// 1.19.3
Material.ACACIA_HANGING_SIGN, Material.ACACIA_WALL_HANGING_SIGN, Material.BAMBOO_BLOCK, Material.BAMBOO_BUTTON, Material.BAMBOO_CHEST_RAFT, Material.BAMBOO_DOOR, Material.BAMBOO_FENCE, Material.BAMBOO_FENCE_GATE, Material.BAMBOO_HANGING_SIGN,
Material.BAMBOO_MOSAIC, Material.BAMBOO_MOSAIC_SLAB, Material.BAMBOO_MOSAIC_STAIRS, Material.BAMBOO_PLANKS, Material.BAMBOO_PRESSURE_PLATE, Material.BAMBOO_RAFT, Material.BAMBOO_SIGN, Material.BAMBOO_SLAB, Material.BAMBOO_STAIRS, Material.BAMBOO_TRAPDOOR,
Material.BAMBOO_WALL_HANGING_SIGN, Material.BAMBOO_WALL_SIGN, Material.BIRCH_HANGING_SIGN, Material.BIRCH_WALL_HANGING_SIGN, Material.CAMEL_SPAWN_EGG, Material.CHISELED_BOOKSHELF, Material.CRIMSON_HANGING_SIGN, Material.CRIMSON_WALL_HANGING_SIGN,
Material.DARK_OAK_HANGING_SIGN, Material.DARK_OAK_WALL_HANGING_SIGN, Material.ENDER_DRAGON_SPAWN_EGG, Material.IRON_GOLEM_SPAWN_EGG, 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.PIGLIN_HEAD, Material.PIGLIN_WALL_HEAD, Material.SNOW_GOLEM_SPAWN_EGG, Material.SPRUCE_HANGING_SIGN, Material.SPRUCE_WALL_HANGING_SIGN,
Material.STRIPPED_BAMBOO_BLOCK, Material.WARPED_HANGING_SIGN, Material.WARPED_WALL_HANGING_SIGN, Material.WITHER_SPAWN_EGG,
//
Material.LEGACY_AIR, Material.LEGACY_DEAD_BUSH, Material.LEGACY_BURNING_FURNACE, Material.LEGACY_WALL_SIGN, Material.LEGACY_REDSTONE_TORCH_OFF, Material.LEGACY_SKULL, Material.LEGACY_REDSTONE_COMPARATOR_ON, Material.LEGACY_WALL_BANNER, Material.LEGACY_MONSTER_EGG));

View File

@@ -1,6 +1,6 @@
package org.bukkit.enchantments;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.enchantment.EnchantmentSlotType;
import org.bukkit.Material;
@@ -28,7 +28,7 @@ public class EnchantmentTargetTest {
Assert.assertNotNull("No bukkit target for slot " + nmsSlot, bukkitTarget);
for (Item item : IRegistry.ITEM) {
for (Item item : BuiltInRegistries.ITEM) {
Material material = CraftMagicNumbers.getMaterial(item);
boolean nms = nmsSlot.canEnchant(item);

View File

@@ -3,7 +3,7 @@ package org.bukkit.entity;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.world.entity.EntityTypes;
import org.bukkit.support.AbstractTestingBase;
@@ -16,7 +16,7 @@ public class EntityTypesTest extends AbstractTestingBase {
public void testMaps() {
Set<EntityType> allBukkit = Arrays.stream(EntityType.values()).filter((b) -> b.getName() != null).collect(Collectors.toSet());
for (EntityTypes<?> nms : IRegistry.ENTITY_TYPE) {
for (EntityTypes<?> nms : BuiltInRegistries.ENTITY_TYPE) {
MinecraftKey key = EntityTypes.getKey(nms);
EntityType bukkit = EntityType.fromName(key.getPath());

View File

@@ -1,7 +1,7 @@
package org.bukkit.entity.memory;
import net.minecraft.core.GlobalPos;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
import org.bukkit.Location;
import org.bukkit.craftbukkit.entity.memory.CraftMemoryKey;
@@ -56,7 +56,7 @@ public class CraftMemoryKeyTest extends AbstractTestingBase {
@Test
public void shouldReturnNullWhenBukkitRepresentationOfKeyisNotAvailableAndSerializerIsNotPresent() {
for (MemoryModuleType<?> memoryModuleType : IRegistry.MEMORY_MODULE_TYPE) {
for (MemoryModuleType<?> memoryModuleType : BuiltInRegistries.MEMORY_MODULE_TYPE) {
if (!memoryModuleType.getCodec().isPresent()) {
MemoryKey bukkitNoKey = CraftMemoryKey.toMemoryKey(memoryModuleType);
Assert.assertNull("MemoryModuleType should be null", bukkitNoKey);
@@ -67,10 +67,10 @@ public class CraftMemoryKeyTest extends AbstractTestingBase {
@Test
@Ignore("Unit type not yet implemented")
public void shouldReturnAnInstanceOfMemoryKeyWhenBukkitRepresentationOfKeyisAvailableAndSerializerIsPresent() {
for (MemoryModuleType<?> memoryModuleType : IRegistry.MEMORY_MODULE_TYPE) {
for (MemoryModuleType<?> memoryModuleType : BuiltInRegistries.MEMORY_MODULE_TYPE) {
if (memoryModuleType.getCodec().isPresent()) {
MemoryKey bukkitNoKey = CraftMemoryKey.toMemoryKey(memoryModuleType);
Assert.assertNotNull("MemoryModuleType should not be null " + IRegistry.MEMORY_MODULE_TYPE.getKey(memoryModuleType), bukkitNoKey);
Assert.assertNotNull("MemoryModuleType should not be null " + BuiltInRegistries.MEMORY_MODULE_TYPE.getKey(memoryModuleType), bukkitNoKey);
}
}
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.generator.structure;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.MinecraftKey;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
@@ -30,9 +31,9 @@ public class StructureTest extends AbstractTestingBase {
@Test
public void testMinecraftToBukkitFieldName() {
IRegistry<net.minecraft.world.level.levelgen.structure.Structure> structureIRegistry = AbstractTestingBase.REGISTRY_CUSTOM.registryOrThrow(IRegistry.STRUCTURE_REGISTRY);
for (net.minecraft.world.level.levelgen.structure.Structure structure : structureIRegistry) {
MinecraftKey minecraftKey = structureIRegistry.getKey(structure);
IRegistry<net.minecraft.world.level.levelgen.structure.Structure> structureBuiltInRegistries = AbstractTestingBase.REGISTRY_CUSTOM.registryOrThrow(Registries.STRUCTURE);
for (net.minecraft.world.level.levelgen.structure.Structure structure : structureBuiltInRegistries) {
MinecraftKey minecraftKey = structureBuiltInRegistries.getKey(structure);
try {
Structure bukkit = (Structure) Structure.class.getField(minecraftKey.getPath().toUpperCase()).get(null);

View File

@@ -2,7 +2,7 @@ package org.bukkit.generator.structure;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.MinecraftKey;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
@@ -30,8 +30,8 @@ public class StructureTypeTest extends AbstractTestingBase {
@Test
public void testMinecraftToBukkitFieldName() {
for (net.minecraft.world.level.levelgen.structure.StructureType<?> structureType : IRegistry.STRUCTURE_TYPES) {
MinecraftKey minecraftKey = IRegistry.STRUCTURE_TYPES.getKey(structureType);
for (net.minecraft.world.level.levelgen.structure.StructureType<?> structureType : BuiltInRegistries.STRUCTURE_TYPE) {
MinecraftKey minecraftKey = BuiltInRegistries.STRUCTURE_TYPE.getKey(structureType);
try {
StructureType bukkit = (StructureType) StructureType.class.getField(minecraftKey.getPath().toUpperCase()).get(null);

View File

@@ -4,7 +4,7 @@ import static org.junit.Assert.*;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectList;
@@ -16,7 +16,7 @@ public class PotionTest extends AbstractTestingBase {
@Test
public void testEffectCompleteness() throws Throwable {
Map<PotionType, String> effects = new EnumMap(PotionType.class);
for (Object reg : IRegistry.POTION) {
for (Object reg : BuiltInRegistries.POTION) {
List<MobEffect> eff = ((PotionRegistry) reg).getEffects();
if (eff.size() != 1) continue;
int id = MobEffectList.getId(eff.get(0).getEffect());
@@ -34,8 +34,8 @@ public class PotionTest extends AbstractTestingBase {
@Test
public void testEffectType() {
for (MobEffectList nms : IRegistry.MOB_EFFECT) {
MinecraftKey key = IRegistry.MOB_EFFECT.getKey(nms);
for (MobEffectList nms : BuiltInRegistries.MOB_EFFECT) {
MinecraftKey key = BuiltInRegistries.MOB_EFFECT.getKey(nms);
int id = MobEffectList.getId(nms);
PotionEffectType bukkit = PotionEffectType.getById(id);

View File

@@ -6,13 +6,20 @@ import java.util.Collections;
import java.util.List;
import net.minecraft.SharedConstants;
import net.minecraft.commands.CommandDispatcher;
import net.minecraft.core.IRegistry;
import net.minecraft.core.IRegistryCustom;
import net.minecraft.core.LayeredRegistryAccess;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.RegistryDataLoader;
import net.minecraft.server.DataPackResources;
import net.minecraft.server.DispenserRegistry;
import net.minecraft.server.RegistryLayer;
import net.minecraft.server.WorldLoader;
import net.minecraft.server.packs.EnumResourcePackType;
import net.minecraft.server.packs.ResourcePackVanilla;
import net.minecraft.server.packs.repository.ResourcePackSourceVanilla;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.world.flag.FeatureFlags;
import net.minecraft.world.level.biome.BiomeBase;
import org.bukkit.Material;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.junit.Assert;
@@ -31,18 +38,23 @@ public abstract class AbstractTestingBase {
public static final DataPackResources DATA_PACK;
public static final IRegistryCustom.Dimension REGISTRY_CUSTOM;
public static final IRegistry<BiomeBase> BIOMES;
static {
SharedConstants.tryDetectVersion();
DispenserRegistry.bootStrap();
// Set up resource manager
ResourceManager resourceManager = new ResourceManager(EnumResourcePackType.SERVER_DATA, Collections.singletonList(new ResourcePackVanilla(ResourcePackSourceVanilla.BUILT_IN_METADATA, "minecraft")));
ResourceManager resourceManager = new ResourceManager(EnumResourcePackType.SERVER_DATA, Collections.singletonList(new ResourcePackSourceVanilla().getVanillaPack()));
// add tags and loot tables for unit tests
REGISTRY_CUSTOM = IRegistryCustom.builtinCopy().freeze();
LayeredRegistryAccess<RegistryLayer> layers = RegistryLayer.createRegistryAccess();
layers = WorldLoader.loadAndReplaceLayer(resourceManager, layers, RegistryLayer.WORLDGEN, RegistryDataLoader.WORLDGEN_REGISTRIES);
REGISTRY_CUSTOM = layers.compositeAccess().freeze();
// Register vanilla pack
DATA_PACK = DataPackResources.loadResources(resourceManager, REGISTRY_CUSTOM, CommandDispatcher.ServerType.DEDICATED, 0, MoreExecutors.directExecutor(), MoreExecutors.directExecutor()).join();
DATA_PACK = DataPackResources.loadResources(resourceManager, REGISTRY_CUSTOM, FeatureFlags.REGISTRY.allFlags(), CommandDispatcher.ServerType.DEDICATED, 0, MoreExecutors.directExecutor(), MoreExecutors.directExecutor()).join();
// Bind tags
DATA_PACK.updateRegistryTags(REGISTRY_CUSTOM);
// Biome shortcut
BIOMES = REGISTRY_CUSTOM.registryOrThrow(Registries.BIOME);
DummyServer.setup();
DummyEnchantments.setup();
@@ -54,6 +66,6 @@ public abstract class AbstractTestingBase {
}
}
INVALIDATED_MATERIALS = builder.build();
Assert.assertEquals("Expected 592 invalidated materials (got " + INVALIDATED_MATERIALS.size() + ")", 592, INVALIDATED_MATERIALS.size());
Assert.assertEquals("Expected 604 invalidated materials (got " + INVALIDATED_MATERIALS.size() + ")", 604, INVALIDATED_MATERIALS.size());
}
}