@@ -26,7 +26,7 @@ public class ArtTest {
|
||||
List<Art> arts = Lists.newArrayList(Art.values());
|
||||
|
||||
for (ResourceKey<PaintingVariant> key : CraftRegistry.getMinecraftRegistry(Registries.PAINTING_VARIANT).registryKeySet()) {
|
||||
Holder<PaintingVariant> enumArt = CraftRegistry.getMinecraftRegistry(Registries.PAINTING_VARIANT).getHolderOrThrow(key);
|
||||
Holder<PaintingVariant> enumArt = CraftRegistry.getMinecraftRegistry(Registries.PAINTING_VARIANT).getOrThrow(key);
|
||||
String name = key.location().getPath();
|
||||
int width = enumArt.value().width();
|
||||
int height = enumArt.value().height();
|
||||
|
||||
@@ -15,7 +15,7 @@ public class EnchantmentTest {
|
||||
@Test
|
||||
public void verifyMapping() {
|
||||
for (MinecraftKey key : CraftRegistry.getMinecraftRegistry(Registries.ENCHANTMENT).keySet()) {
|
||||
net.minecraft.world.item.enchantment.Enchantment nms = CraftRegistry.getMinecraftRegistry(Registries.ENCHANTMENT).get(key);
|
||||
net.minecraft.world.item.enchantment.Enchantment nms = CraftRegistry.getMinecraftRegistry(Registries.ENCHANTMENT).getValue(key);
|
||||
|
||||
Enchantment bukkitById = Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(key));
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import java.util.Map;
|
||||
import net.minecraft.world.flag.FeatureFlags;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.support.environment.Normal;
|
||||
@@ -23,7 +24,7 @@ public class GameRuleTest {
|
||||
|
||||
@Test
|
||||
public void testMinecraftRules() {
|
||||
Map<String, GameRules.GameRuleKey<?>> minecraftRules = CraftWorld.getGameRulesNMS();
|
||||
Map<String, GameRules.GameRuleKey<?>> minecraftRules = CraftWorld.getGameRulesNMS(new GameRules(FeatureFlags.REGISTRY.allFlags()));
|
||||
|
||||
for (Map.Entry<String, GameRules.GameRuleKey<?>> entry : minecraftRules.entrySet()) {
|
||||
GameRule<?> bukkitRule = GameRule.getByName(entry.getKey());
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.core.particles.ParticleParamRedstone;
|
||||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraft.core.particles.SculkChargeParticleOptions;
|
||||
import net.minecraft.core.particles.ShriekParticleOption;
|
||||
import net.minecraft.core.particles.TargetColorParticleOption;
|
||||
import net.minecraft.core.particles.VibrationParticleOption;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.nbt.DynamicOpsNBT;
|
||||
@@ -112,6 +113,11 @@ public class ParticleTest {
|
||||
return;
|
||||
}
|
||||
|
||||
if (bukkit.getDataType().equals(Particle.TargetColor.class)) {
|
||||
testTargetColor(bukkit, minecraft);
|
||||
return;
|
||||
}
|
||||
|
||||
fail(String.format("""
|
||||
No test found for particle %s.
|
||||
Please add a test case for it here.
|
||||
@@ -242,6 +248,28 @@ public class ParticleTest {
|
||||
""", bukkit.getKey(), expected, actual)); // Print expected and got since we use assert true
|
||||
}
|
||||
|
||||
private <T extends ParticleParam> void testTargetColor(Particle bukkit, net.minecraft.core.particles.Particle<T> minecraft) {
|
||||
Color color = Color.fromRGB(236, 28, 36);
|
||||
Particle.TargetColor targetColor = new Particle.TargetColor(new Location(null, 1, 5, 9), color);
|
||||
|
||||
TargetColorParticleOption param = createAndTest(bukkit, minecraft, targetColor, TargetColorParticleOption.class);
|
||||
|
||||
Vec3D pos = param.target();
|
||||
assertEquals(new Vec3D(1.0, 5.0, 9.0), pos, String.format("""
|
||||
Vibration position for particle %s do not match.
|
||||
Did something change in the implementation or minecraft?
|
||||
""", bukkit.getKey()));
|
||||
|
||||
int actual = param.color();
|
||||
int expected = color.asRGB();
|
||||
assertEquals(expected, actual, String.format("""
|
||||
Color for particle %s do not match.
|
||||
Did something change in the implementation or minecraft?
|
||||
Expected: %s.
|
||||
Got: %s.
|
||||
""", bukkit.getKey(), expected, actual)); // Print expected and got since we use assert true
|
||||
}
|
||||
|
||||
private <D extends ParticleParam, T extends ParticleParam> D createAndTest(Particle bukkit, net.minecraft.core.particles.Particle<T> minecraft, Object data, Class<D> paramClass) {
|
||||
@SuppressWarnings("unchecked")
|
||||
T particleParam = (T) assertDoesNotThrow(() -> CraftParticle.createParticleParam(bukkit, data), String.format("""
|
||||
|
||||
@@ -9,14 +9,13 @@ import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.world.EnumHand;
|
||||
import net.minecraft.world.entity.EnumItemSlot;
|
||||
import net.minecraft.world.entity.player.EntityHuman;
|
||||
import net.minecraft.world.item.Equipable;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.equipment.Equippable;
|
||||
import net.minecraft.world.level.BlockAccessAir;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.BlockFire;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.Fallable;
|
||||
import net.minecraft.world.level.block.entity.TileEntityFurnace;
|
||||
import net.minecraft.world.level.block.state.BlockBase;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.phys.MovingObjectPositionBlock;
|
||||
@@ -149,16 +148,6 @@ public class PerMaterialTest {
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@EnumSource(value = Material.class, names = "LEGACY_.*", mode = EnumSource.Mode.MATCH_NONE)
|
||||
public void isFuel(Material material) {
|
||||
if (material.isItem()) {
|
||||
assertThat(material.isFuel(), is(TileEntityFurnace.isFuel(new net.minecraft.world.item.ItemStack(CraftMagicNumbers.getItem(material)))));
|
||||
} else {
|
||||
assertFalse(material.isFuel());
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@EnumSource(value = Material.class, names = "LEGACY_.*", mode = EnumSource.Mode.MATCH_NONE)
|
||||
public void isOccluding(Material material) {
|
||||
@@ -299,8 +288,8 @@ public class PerMaterialTest {
|
||||
@EnumSource(value = Material.class, names = "LEGACY_.*", mode = EnumSource.Mode.MATCH_NONE)
|
||||
public void testCraftingRemainingItem(Material material) {
|
||||
if (material.isItem()) {
|
||||
Item expectedItem = CraftMagicNumbers.getItem(material).getCraftingRemainingItem();
|
||||
Material expected = expectedItem == null ? null : CraftMagicNumbers.getMaterial(expectedItem);
|
||||
net.minecraft.world.item.ItemStack expectedItem = CraftMagicNumbers.getItem(material).getCraftingRemainder();
|
||||
Material expected = expectedItem.isEmpty() ? null : CraftMagicNumbers.getMaterial(expectedItem.getItem());
|
||||
|
||||
assertThat(material.getCraftingRemainingItem(), is(expected));
|
||||
}
|
||||
@@ -310,8 +299,8 @@ public class PerMaterialTest {
|
||||
@EnumSource(value = Material.class, names = "LEGACY_.*", mode = EnumSource.Mode.MATCH_NONE)
|
||||
public void testEquipmentSlot(Material material) {
|
||||
if (material.isItem()) {
|
||||
Equipable equipable = Equipable.get(CraftItemStack.asNMSCopy(new ItemStack(material)));
|
||||
EquipmentSlot expected = CraftEquipmentSlot.getSlot(equipable != null ? equipable.getEquipmentSlot() : EnumItemSlot.MAINHAND);
|
||||
Equippable equipable = CraftItemStack.asNMSCopy(new ItemStack(material)).get(DataComponents.EQUIPPABLE);
|
||||
EquipmentSlot expected = CraftEquipmentSlot.getSlot(equipable != null ? equipable.slot() : EnumItemSlot.MAINHAND);
|
||||
assertThat(material.getEquipmentSlot(), is(expected));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public class PatternTypeTest {
|
||||
|
||||
@Test
|
||||
public void testToBukkit() {
|
||||
for (EnumBannerPatternType nms : MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.BANNER_PATTERN)) {
|
||||
for (EnumBannerPatternType nms : MinecraftServer.getDefaultRegistryAccess().lookupOrThrow(Registries.BANNER_PATTERN)) {
|
||||
PatternType bukkit = Registry.BANNER_PATTERN.get(CraftNamespacedKey.fromMinecraft(nms.assetId()));
|
||||
|
||||
assertNotNull(bukkit, "No Bukkit banner pattern for " + nms + " " + nms);
|
||||
@@ -25,7 +25,7 @@ public class PatternTypeTest {
|
||||
|
||||
@Test
|
||||
public void testToNMS() {
|
||||
IRegistry<EnumBannerPatternType> registry = MinecraftServer.getDefaultRegistryAccess().registryOrThrow(Registries.BANNER_PATTERN);
|
||||
IRegistry<EnumBannerPatternType> registry = MinecraftServer.getDefaultRegistryAccess().lookupOrThrow(Registries.BANNER_PATTERN);
|
||||
for (PatternType bukkit : PatternType.values()) {
|
||||
EnumBannerPatternType found = null;
|
||||
for (EnumBannerPatternType nms : registry) {
|
||||
|
||||
@@ -18,8 +18,10 @@ import org.bukkit.entity.AbstractWindCharge;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.Ambient;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.Boss;
|
||||
import org.bukkit.entity.Breedable;
|
||||
import org.bukkit.entity.ChestBoat;
|
||||
import org.bukkit.entity.ChestedHorse;
|
||||
import org.bukkit.entity.ComplexEntityPart;
|
||||
import org.bukkit.entity.ComplexLivingEntity;
|
||||
@@ -78,8 +80,10 @@ public class EntityTypesTest {
|
||||
Ageable.class,
|
||||
Ambient.class,
|
||||
Animals.class,
|
||||
Breedable.class,
|
||||
Boat.class,
|
||||
Boss.class,
|
||||
Breedable.class,
|
||||
ChestBoat.class,
|
||||
ChestedHorse.class,
|
||||
ComplexEntityPart.class,
|
||||
ComplexLivingEntity.class,
|
||||
|
||||
@@ -126,6 +126,12 @@ public class LegacyTest {
|
||||
Material.FLOW_ARMOR_TRIM_SMITHING_TEMPLATE, Material.BOLT_ARMOR_TRIM_SMITHING_TEMPLATE, Material.FLOW_POTTERY_SHERD, Material.GUSTER_POTTERY_SHERD, Material.SCRAPE_POTTERY_SHERD, Material.BREEZE_ROD, Material.OMINOUS_TRIAL_KEY, Material.OMINOUS_BOTTLE,
|
||||
// 1.21
|
||||
Material.MUSIC_DISC_CREATOR, Material.MUSIC_DISC_CREATOR_MUSIC_BOX, Material.MUSIC_DISC_PRECIPICE,
|
||||
// 1.21.2
|
||||
Material.FIELD_MASONED_BANNER_PATTERN, Material.BORDURE_INDENTED_BANNER_PATTERN, Material.WHITE_BUNDLE, Material.ORANGE_BUNDLE, Material.MAGENTA_BUNDLE, Material.LIGHT_BLUE_BUNDLE, Material.YELLOW_BUNDLE, Material.LIME_BUNDLE, Material.PINK_BUNDLE,
|
||||
Material.GRAY_BUNDLE, Material.LIGHT_GRAY_BUNDLE, Material.CYAN_BUNDLE, Material.PURPLE_BUNDLE, Material.BLUE_BUNDLE, Material.BROWN_BUNDLE, Material.GREEN_BUNDLE, Material.RED_BUNDLE, Material.BLACK_BUNDLE, Material.CREAKING_HEART,
|
||||
Material.CREAKING_SPAWN_EGG, Material.PALE_HANGING_MOSS, Material.PALE_MOSS_BLOCK, Material.PALE_MOSS_CARPET, Material.PALE_OAK_BOAT, Material.PALE_OAK_BUTTON, Material.PALE_OAK_CHEST_BOAT, Material.PALE_OAK_DOOR, Material.PALE_OAK_FENCE,
|
||||
Material.PALE_OAK_FENCE_GATE, Material.PALE_OAK_HANGING_SIGN, Material.PALE_OAK_LEAVES, Material.PALE_OAK_LOG, Material.PALE_OAK_PLANKS, Material.PALE_OAK_PRESSURE_PLATE, Material.PALE_OAK_SAPLING, Material.PALE_OAK_SIGN, Material.PALE_OAK_SLAB,
|
||||
Material.PALE_OAK_STAIRS, Material.PALE_OAK_TRAPDOOR, Material.PALE_OAK_WALL_SIGN, Material.PALE_OAK_WALL_HANGING_SIGN, Material.PALE_OAK_WOOD, Material.POTTED_PALE_OAK_SAPLING, Material.STRIPPED_PALE_OAK_LOG, Material.STRIPPED_PALE_OAK_WOOD,
|
||||
//
|
||||
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));
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package org.bukkit.entity;
|
||||
|
||||
import net.minecraft.world.entity.vehicle.EntityBoat;
|
||||
import org.bukkit.craftbukkit.entity.CraftBoat;
|
||||
import org.bukkit.support.environment.Normal;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Normal
|
||||
public class BoatTest {
|
||||
|
||||
@Test
|
||||
public void testTypes() {
|
||||
for (EntityBoat.EnumBoatType enumBoatType : EntityBoat.EnumBoatType.values()) {
|
||||
CraftBoat.boatTypeFromNms(enumBoatType);
|
||||
}
|
||||
|
||||
for (Boat.Type enumBoatType : Boat.Type.values()) {
|
||||
CraftBoat.boatTypeToNms(enumBoatType);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStatus() {
|
||||
for (EntityBoat.EnumStatus enumStatus : EntityBoat.EnumStatus.values()) {
|
||||
CraftBoat.boatStatusFromNms(enumStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -339,7 +339,7 @@ public class RegistryClassTest {
|
||||
continue;
|
||||
}
|
||||
|
||||
IRegistry<?> registry = vanilla_registry.registryOrThrow(registryKey);
|
||||
IRegistry<?> registry = vanilla_registry.lookupOrThrow(registryKey);
|
||||
|
||||
Optional<?> optionalValue = registry.getOptional(CraftNamespacedKey.toMinecraft(((Keyed) fieldData.field().get(null)).getKey()));
|
||||
|
||||
@@ -368,7 +368,7 @@ public class RegistryClassTest {
|
||||
@ParameterizedTest
|
||||
@MethodSource("fieldData")
|
||||
public <T extends Keyed> void testMissingExperimentalAnnotation(Class<T> type, ResourceKey<IRegistry<?>> registryKey, List<FieldData> fieldDataList) throws IllegalAccessException {
|
||||
IRegistry<?> registry = vanilla_registry.registryOrThrow(registryKey);
|
||||
IRegistry<?> registry = vanilla_registry.lookupOrThrow(registryKey);
|
||||
List<Field> missing = new ArrayList<>();
|
||||
|
||||
for (FieldData fieldData : fieldDataList) {
|
||||
@@ -403,7 +403,7 @@ public class RegistryClassTest {
|
||||
@ParameterizedTest
|
||||
@MethodSource("fieldData")
|
||||
public <T extends Keyed> void testExcessNullCheck(Class<T> type, ResourceKey<IRegistry<?>> registryKey, List<FieldData> fieldDataList) throws IllegalAccessException {
|
||||
IRegistry<?> registry = vanilla_registry.registryOrThrow(registryKey);
|
||||
IRegistry<?> registry = vanilla_registry.lookupOrThrow(registryKey);
|
||||
List<Field> excess = new ArrayList<>();
|
||||
Data data = INIT_DATA.get(type);
|
||||
|
||||
@@ -434,7 +434,7 @@ public class RegistryClassTest {
|
||||
@ParameterizedTest
|
||||
@MethodSource("fieldData")
|
||||
public <T extends Keyed> void testMissingNullCheck(Class<T> type, ResourceKey<IRegistry<?>> registryKey, List<FieldData> fieldDataList) throws IllegalAccessException {
|
||||
IRegistry<?> registry = vanilla_registry.registryOrThrow(registryKey);
|
||||
IRegistry<?> registry = vanilla_registry.lookupOrThrow(registryKey);
|
||||
List<Field> missing = new ArrayList<>();
|
||||
Data data = INIT_DATA.get(type);
|
||||
|
||||
@@ -491,7 +491,7 @@ public class RegistryClassTest {
|
||||
@ParameterizedTest
|
||||
@MethodSource("fieldData")
|
||||
public <T extends Keyed> void testMissingConstants(Class<T> type, ResourceKey<IRegistry<?>> registryKey) throws IllegalAccessException {
|
||||
IRegistry<Object> registry = RegistryHelper.getRegistry().registryOrThrow(registryKey);
|
||||
IRegistry<Object> registry = RegistryHelper.getRegistry().lookupOrThrow(registryKey);
|
||||
List<MinecraftKey> missingKeys = new ArrayList<>();
|
||||
|
||||
for (Object nmsObject : registry) {
|
||||
|
||||
@@ -64,7 +64,7 @@ public class RegistryConstantsTest {
|
||||
private <T extends Keyed, M> void testMissingConstants(Class<T> clazz, ResourceKey<IRegistry<M>> nmsRegistryKey) {
|
||||
List<MinecraftKey> missingKeys = new ArrayList<>();
|
||||
|
||||
IRegistry<M> nmsRegistry = RegistryHelper.getRegistry().registryOrThrow(nmsRegistryKey);
|
||||
IRegistry<M> nmsRegistry = RegistryHelper.getRegistry().lookupOrThrow(nmsRegistryKey);
|
||||
for (M nmsObject : nmsRegistry) {
|
||||
MinecraftKey minecraftKey = nmsRegistry.getKey(nmsObject);
|
||||
|
||||
|
||||
@@ -56,28 +56,28 @@ public final class DummyServerHelper {
|
||||
case org.bukkit.Tag.REGISTRY_BLOCKS -> {
|
||||
Preconditions.checkArgument(clazz == Material.class, "Block namespace must have block type");
|
||||
TagKey<Block> blockTagKey = TagKey.create(Registries.BLOCK, key);
|
||||
if (BuiltInRegistries.BLOCK.getTag(blockTagKey).isPresent()) {
|
||||
if (BuiltInRegistries.BLOCK.get(blockTagKey).isPresent()) {
|
||||
return new CraftBlockTag(BuiltInRegistries.BLOCK, blockTagKey);
|
||||
}
|
||||
}
|
||||
case org.bukkit.Tag.REGISTRY_ITEMS -> {
|
||||
Preconditions.checkArgument(clazz == Material.class, "Item namespace must have item type");
|
||||
TagKey<Item> itemTagKey = TagKey.create(Registries.ITEM, key);
|
||||
if (BuiltInRegistries.ITEM.getTag(itemTagKey).isPresent()) {
|
||||
if (BuiltInRegistries.ITEM.get(itemTagKey).isPresent()) {
|
||||
return 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(Registries.FLUID, key);
|
||||
if (BuiltInRegistries.FLUID.getTag(fluidTagKey).isPresent()) {
|
||||
if (BuiltInRegistries.FLUID.get(fluidTagKey).isPresent()) {
|
||||
return 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(Registries.ENTITY_TYPE, key);
|
||||
if (BuiltInRegistries.ENTITY_TYPE.getTag(entityTagKey).isPresent()) {
|
||||
if (BuiltInRegistries.ENTITY_TYPE.get(entityTagKey).isPresent()) {
|
||||
return new CraftEntityTag(BuiltInRegistries.ENTITY_TYPE, entityTagKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package org.bukkit.support;
|
||||
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.commands.CommandDispatcher;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.core.IRegistryCustom;
|
||||
import net.minecraft.core.LayeredRegistryAccess;
|
||||
@@ -12,12 +14,13 @@ 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.repository.ResourcePackLoader;
|
||||
import net.minecraft.server.packs.repository.ResourcePackRepository;
|
||||
import net.minecraft.server.packs.repository.ResourcePackSourceVanilla;
|
||||
import net.minecraft.server.packs.resources.IResourceManager;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.tags.TagDataPack;
|
||||
import net.minecraft.world.flag.FeatureFlagSet;
|
||||
import net.minecraft.world.level.biome.BiomeBase;
|
||||
import org.bukkit.Keyed;
|
||||
@@ -54,22 +57,37 @@ public final class RegistryHelper {
|
||||
}
|
||||
|
||||
public static IRegistryCustom.Dimension createRegistry(FeatureFlagSet featureFlagSet) {
|
||||
return createLayers(createResourceManager(featureFlagSet)).compositeAccess().freeze();
|
||||
ResourceManager ireloadableresourcemanager = createResourceManager(featureFlagSet);
|
||||
// add tags and loot tables for unit tests
|
||||
LayeredRegistryAccess<RegistryLayer> layeredregistryaccess = RegistryLayer.createRegistryAccess();
|
||||
List<IRegistry.a<?>> list = TagDataPack.loadTagsForExistingRegistries(ireloadableresourcemanager, layeredregistryaccess.getLayer(RegistryLayer.STATIC));
|
||||
IRegistryCustom.Dimension iregistrycustom_dimension = layeredregistryaccess.getAccessForLoading(RegistryLayer.WORLDGEN);
|
||||
List<HolderLookup.b<?>> list1 = TagDataPack.buildUpdatedLookups(iregistrycustom_dimension, list);
|
||||
IRegistryCustom.Dimension iregistrycustom_dimension1 = RegistryDataLoader.load((IResourceManager) ireloadableresourcemanager, list1, RegistryDataLoader.WORLDGEN_REGISTRIES);
|
||||
LayeredRegistryAccess<RegistryLayer> layers = layeredregistryaccess.replaceFrom(RegistryLayer.WORLDGEN, iregistrycustom_dimension1);
|
||||
|
||||
return layers.compositeAccess().freeze();
|
||||
}
|
||||
|
||||
public static void setup(FeatureFlagSet featureFlagSet) {
|
||||
SharedConstants.tryDetectVersion();
|
||||
DispenserRegistry.bootStrap();
|
||||
|
||||
ResourceManager resourceManager = createResourceManager(featureFlagSet);
|
||||
LayeredRegistryAccess<RegistryLayer> layers = createLayers(resourceManager);
|
||||
ResourceManager ireloadableresourcemanager = createResourceManager(featureFlagSet);
|
||||
// add tags and loot tables for unit tests
|
||||
LayeredRegistryAccess<RegistryLayer> layeredregistryaccess = RegistryLayer.createRegistryAccess();
|
||||
List<IRegistry.a<?>> list = TagDataPack.loadTagsForExistingRegistries(ireloadableresourcemanager, layeredregistryaccess.getLayer(RegistryLayer.STATIC));
|
||||
IRegistryCustom.Dimension iregistrycustom_dimension = layeredregistryaccess.getAccessForLoading(RegistryLayer.WORLDGEN);
|
||||
List<HolderLookup.b<?>> list1 = TagDataPack.buildUpdatedLookups(iregistrycustom_dimension, list);
|
||||
IRegistryCustom.Dimension iregistrycustom_dimension1 = RegistryDataLoader.load((IResourceManager) ireloadableresourcemanager, list1, RegistryDataLoader.WORLDGEN_REGISTRIES);
|
||||
LayeredRegistryAccess<RegistryLayer> layers = layeredregistryaccess.replaceFrom(RegistryLayer.WORLDGEN, iregistrycustom_dimension1);
|
||||
registry = layers.compositeAccess().freeze();
|
||||
// Register vanilla pack
|
||||
dataPack = DataPackResources.loadResources(resourceManager, layers, featureFlagSet, CommandDispatcher.ServerType.DEDICATED, 0, MoreExecutors.directExecutor(), MoreExecutors.directExecutor()).join();
|
||||
dataPack = DataPackResources.loadResources(ireloadableresourcemanager, layers, list, featureFlagSet, CommandDispatcher.ServerType.DEDICATED, 0, MoreExecutors.directExecutor(), MoreExecutors.directExecutor()).join();
|
||||
// Bind tags
|
||||
dataPack.updateRegistryTags();
|
||||
dataPack.updateStaticRegistryTags();
|
||||
// Biome shortcut
|
||||
biomes = registry.registryOrThrow(Registries.BIOME);
|
||||
biomes = registry.lookupOrThrow(Registries.BIOME);
|
||||
}
|
||||
|
||||
public static <T extends Keyed> Class<T> updateClass(Class<T> aClass, NamespacedKey key) {
|
||||
@@ -94,14 +112,6 @@ public final class RegistryHelper {
|
||||
return new ResourceManager(EnumResourcePackType.SERVER_DATA, resourceRepository.getAvailablePacks().stream().filter(pack -> pack.getRequestedFeatures().isSubsetOf(featureFlagSet)).map(ResourcePackLoader::open).toList());
|
||||
}
|
||||
|
||||
private static LayeredRegistryAccess<RegistryLayer> createLayers(ResourceManager resourceManager) {
|
||||
// add tags and loot tables for unit tests
|
||||
LayeredRegistryAccess<RegistryLayer> layers = RegistryLayer.createRegistryAccess();
|
||||
layers = WorldLoader.loadAndReplaceLayer(resourceManager, layers, RegistryLayer.WORLDGEN, RegistryDataLoader.WORLDGEN_REGISTRIES);
|
||||
|
||||
return layers;
|
||||
}
|
||||
|
||||
private static void throwError(String field) {
|
||||
throw new IllegalStateException(String.format("""
|
||||
Trying to access %s will it is not setup.
|
||||
|
||||
@@ -72,8 +72,8 @@ public class RegistriesArgumentProvider implements ArgumentsProvider {
|
||||
register(StructureType.class, Registries.STRUCTURE_TYPE, CraftStructureType.class, net.minecraft.world.level.levelgen.structure.StructureType.class);
|
||||
register(Villager.Type.class, Registries.VILLAGER_TYPE, CraftVillager.CraftType.class, VillagerType.class);
|
||||
register(Villager.Profession.class, Registries.VILLAGER_PROFESSION, CraftVillager.CraftProfession.class, VillagerProfession.class);
|
||||
register(TrimMaterial.class, Registries.TRIM_MATERIAL, CraftTrimMaterial.class, net.minecraft.world.item.armortrim.TrimMaterial.class);
|
||||
register(TrimPattern.class, Registries.TRIM_PATTERN, CraftTrimPattern.class, net.minecraft.world.item.armortrim.TrimPattern.class);
|
||||
register(TrimMaterial.class, Registries.TRIM_MATERIAL, CraftTrimMaterial.class, net.minecraft.world.item.equipment.trim.TrimMaterial.class);
|
||||
register(TrimPattern.class, Registries.TRIM_PATTERN, CraftTrimPattern.class, net.minecraft.world.item.equipment.trim.TrimPattern.class);
|
||||
register(DamageType.class, Registries.DAMAGE_TYPE, CraftDamageType.class, net.minecraft.world.damagesource.DamageType.class);
|
||||
register(JukeboxSong.class, Registries.JUKEBOX_SONG, CraftJukeboxSong.class, net.minecraft.world.item.JukeboxSong.class);
|
||||
register(Wolf.Variant.class, Registries.WOLF_VARIANT, CraftWolf.CraftVariant.class, WolfVariant.class);
|
||||
|
||||
Reference in New Issue
Block a user