From 2cd48452564b1d61115ab205429f1707eb6b5cfc Mon Sep 17 00:00:00 2001 From: apple502j <33279053+apple502j@users.noreply.github.com> Date: Fri, 30 Aug 2024 01:54:21 +0900 Subject: [PATCH] 24w35a (#4062) --- .../test/lookup/FabricApiLookupTest.java | 35 +- .../entity/FabricEntityApiLookupTest.java | 7 +- .../BiomeModificationContextImpl.java | 6 +- .../modification/BiomeModificationImpl.java | 8 +- .../BiomeSelectionContextImpl.java | 16 +- .../modification/BuiltInRegistryKeys.java | 2 +- .../fabric/test/biome/WorldgenProvider.java | 6 +- .../impl/tag/client/ClientTagsImpl.java | 6 +- .../content/registry/ContentRegistryTest.java | 7 +- .../fabric/api/tag/convention/v2/TagUtil.java | 4 +- .../v2/TranslationConventionLogWarnings.java | 2 +- .../test/tag/convention/v2/TagUtilTest.java | 6 +- .../FabricBlockLootTableProvider.java | 12 +- .../FabricDynamicRegistryProvider.java | 6 +- .../v1/provider/FabricLanguageProvider.java | 2 +- .../ConditionBlockLootTableGenerator.java | 2 +- .../loot/BlockLootTableGeneratorAccessor.java | 2 +- .../datagen/DataGeneratorTestContent.java | 4 +- .../datagen/DataGeneratorTestEntrypoint.java | 8 +- .../test/entity/event/EntityEventTests.java | 12 +- .../FabricCreativeGuiComponents.java | 2 +- .../mixin/itemgroup/ItemGroupsMixin.java | 2 +- .../mixin/loot/ReloadableRegistriesMixin.java | 5 - .../fabricmc/fabric/test/loot/LootTest.java | 20 +- .../builder/v1/block/FabricBlockSettings.java | 447 ------------------ .../builder/v1/entity/FabricEntityType.java | 9 - .../v1/entity/FabricEntityTypeBuilder.java | 15 +- .../AbstractBlockSettingsAccessor.java | 180 ------- .../builder/EntityTypeBuilderMixin.java | 10 +- .../fabric-object-builder-v1.mixins.json | 1 - .../object/builder/FabricEntityTypeTest.java | 9 +- .../builder/BlockEntityTypeBuilderTest.java | 33 +- .../EntityTypeBuilderGenericsTest.java | 16 +- .../builder/FabricBlockSettingsTest.java | 57 --- .../builder/ObjectBuilderTestConstants.java | 7 + .../test/object/builder/TealSignTest.java | 26 +- .../src/testmod/resources/fabric.mod.json | 1 - .../test/particle/ParticleTestSetup.java | 28 +- .../registry/sync/FabricRegistryInit.java | 2 +- .../trackers/vanilla/BlockInitTracker.java | 25 +- .../mixin/registry/sync/BootstrapMixin.java | 4 - .../sync/CustomDynamicRegistryTest.java | 5 +- .../test/registry/sync/RegistrySyncTest.java | 7 +- .../client/DynamicRegistryClientTest.java | 6 +- .../fabric/test/renderer/Registration.java | 23 +- .../client/rendering/fluid/TestFluids.java | 41 +- .../rendering/v1/WorldRenderEvents.java | 2 +- .../rendering/ArmorFeatureRendererMixin.java | 2 +- .../CustomColorResolverTestInit.java | 9 +- .../rendering/client/ArmorRenderingTests.java | 2 +- .../client/DimensionalRenderingTest.java | 4 +- .../client/WorldRenderEventsTests.java | 8 +- .../conditions/ResourceConditionsImpl.java | 3 +- .../conditions/RecipeManagerMixin.java | 4 +- .../ServerAdvancementLoaderMixin.java | 4 +- .../conditions/ConditionalResourcesTest.java | 10 +- .../loader/ResourceManagerHelperImpl.java | 2 +- .../fabric-resource-loader-v0.accesswidener | 2 +- .../loader/ResourceReloadListenerTestMod.java | 2 +- ...laBuiltinResourcePackInjectionTestMod.java | 11 +- .../test/screenhandler/ScreenHandlerTest.java | 9 +- .../test/transfer/ingame/FluidChuteBlock.java | 4 +- .../ingame/TransferTestInitializer.java | 28 +- .../ingame/client/FluidVariantRenderTest.java | 4 +- ...ransitive-access-wideners-v1.accesswidener | 18 +- .../test/access/SignBlockEntityTest.java | 19 +- .../template.accesswidener | 16 +- gradle.properties | 4 +- 68 files changed, 334 insertions(+), 967 deletions(-) delete mode 100644 fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/block/FabricBlockSettings.java delete mode 100644 fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java delete mode 100644 fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/FabricBlockSettingsTest.java diff --git a/fabric-api-lookup-api-v1/src/testmod/java/net/fabricmc/fabric/test/lookup/FabricApiLookupTest.java b/fabric-api-lookup-api-v1/src/testmod/java/net/fabricmc/fabric/test/lookup/FabricApiLookupTest.java index f670dda16..e431ea8f3 100644 --- a/fabric-api-lookup-api-v1/src/testmod/java/net/fabricmc/fabric/test/lookup/FabricApiLookupTest.java +++ b/fabric-api-lookup-api-v1/src/testmod/java/net/fabricmc/fabric/test/lookup/FabricApiLookupTest.java @@ -19,11 +19,14 @@ package net.fabricmc.fabric.test.lookup; import org.jetbrains.annotations.NotNull; import net.minecraft.block.AbstractBlock; +import net.minecraft.block.Block; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.util.Identifier; import net.minecraft.util.math.Direction; @@ -41,30 +44,35 @@ public class FabricApiLookupTest implements ModInitializer { public static final String MOD_ID = "fabric-lookup-api-v1-testmod"; // Chute - Block without model that transfers item from the container above to the container below. // It's meant to work with unsided containers: chests, dispensers, droppers and hoppers. - public static final ChuteBlock CHUTE_BLOCK = new ChuteBlock(AbstractBlock.Settings.create()); + public static final RegistryKey CHUTE_BLOCK_KEY = keyOf("chute"); + public static final ChuteBlock CHUTE_BLOCK = new ChuteBlock(AbstractBlock.Settings.create().registryKey(CHUTE_BLOCK_KEY)); public static final BlockItem CHUTE_ITEM = new BlockItem(CHUTE_BLOCK, new Item.Settings()); public static BlockEntityType CHUTE_BLOCK_ENTITY_TYPE; // Cobble gen - Block without model that can generate infinite cobblestone when placed above a chute. // It's meant to test BlockApiLookup#registerSelf. - public static final CobbleGenBlock COBBLE_GEN_BLOCK = new CobbleGenBlock(AbstractBlock.Settings.create()); + public static final RegistryKey COBBLE_GEN_BLOCK_KEY = keyOf("cobble_gen"); + public static final CobbleGenBlock COBBLE_GEN_BLOCK = new CobbleGenBlock(AbstractBlock.Settings.create().registryKey(COBBLE_GEN_BLOCK_KEY)); public static final BlockItem COBBLE_GEN_ITEM = new BlockItem(COBBLE_GEN_BLOCK, new Item.Settings()); public static BlockEntityType COBBLE_GEN_BLOCK_ENTITY_TYPE; // Testing for item api lookups is done in the `item` package. - public static final InspectorBlock INSPECTOR_BLOCK = new InspectorBlock(AbstractBlock.Settings.create()); + public static final RegistryKey INSPECTOR_BLOCK_KEY = keyOf("inspector"); + public static final InspectorBlock INSPECTOR_BLOCK = new InspectorBlock(AbstractBlock.Settings.create().registryKey(INSPECTOR_BLOCK_KEY)); public static final BlockItem INSPECTOR_ITEM = new BlockItem(INSPECTOR_BLOCK, new Item.Settings()); + private static RegistryKey keyOf(String id) { + return RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(MOD_ID, id)); + } + @Override public void onInitialize() { - Identifier chute = Identifier.of(MOD_ID, "chute"); - Registry.register(Registries.BLOCK, chute, CHUTE_BLOCK); - Registry.register(Registries.ITEM, chute, CHUTE_ITEM); - CHUTE_BLOCK_ENTITY_TYPE = Registry.register(Registries.BLOCK_ENTITY_TYPE, chute, FabricBlockEntityTypeBuilder.create(ChuteBlockEntity::new, CHUTE_BLOCK).build()); + Registry.register(Registries.BLOCK, CHUTE_BLOCK_KEY, CHUTE_BLOCK); + Registry.register(Registries.ITEM, CHUTE_BLOCK_KEY.getValue(), CHUTE_ITEM); + CHUTE_BLOCK_ENTITY_TYPE = Registry.register(Registries.BLOCK_ENTITY_TYPE, CHUTE_BLOCK_KEY.getValue(), FabricBlockEntityTypeBuilder.create(ChuteBlockEntity::new, CHUTE_BLOCK).build()); - Identifier cobbleGen = Identifier.of(MOD_ID, "cobble_gen"); - Registry.register(Registries.BLOCK, cobbleGen, COBBLE_GEN_BLOCK); - Registry.register(Registries.ITEM, cobbleGen, COBBLE_GEN_ITEM); - COBBLE_GEN_BLOCK_ENTITY_TYPE = Registry.register(Registries.BLOCK_ENTITY_TYPE, cobbleGen, FabricBlockEntityTypeBuilder.create(CobbleGenBlockEntity::new, COBBLE_GEN_BLOCK).build()); + Registry.register(Registries.BLOCK, COBBLE_GEN_BLOCK_KEY, COBBLE_GEN_BLOCK); + Registry.register(Registries.ITEM, COBBLE_GEN_BLOCK_KEY.getValue(), COBBLE_GEN_ITEM); + COBBLE_GEN_BLOCK_ENTITY_TYPE = Registry.register(Registries.BLOCK_ENTITY_TYPE, COBBLE_GEN_BLOCK_KEY.getValue(), FabricBlockEntityTypeBuilder.create(CobbleGenBlockEntity::new, COBBLE_GEN_BLOCK).build()); InventoryExtractableProvider extractableProvider = new InventoryExtractableProvider(); InventoryInsertableProvider insertableProvider = new InventoryInsertableProvider(); @@ -76,9 +84,8 @@ public class FabricApiLookupTest implements ModInitializer { testLookupRegistry(); testSelfRegistration(); - Identifier inspector = Identifier.of(FabricApiLookupTest.MOD_ID, "inspector"); - Registry.register(Registries.BLOCK, inspector, INSPECTOR_BLOCK); - Registry.register(Registries.ITEM, inspector, INSPECTOR_ITEM); + Registry.register(Registries.BLOCK, INSPECTOR_BLOCK_KEY, INSPECTOR_BLOCK); + Registry.register(Registries.ITEM, INSPECTOR_BLOCK_KEY.getValue(), INSPECTOR_ITEM); FabricItemApiLookupTest.onInitialize(); FabricEntityApiLookupTest.onInitialize(); diff --git a/fabric-api-lookup-api-v1/src/testmod/java/net/fabricmc/fabric/test/lookup/entity/FabricEntityApiLookupTest.java b/fabric-api-lookup-api-v1/src/testmod/java/net/fabricmc/fabric/test/lookup/entity/FabricEntityApiLookupTest.java index 09bb9ace6..ce9fb9895 100644 --- a/fabric-api-lookup-api-v1/src/testmod/java/net/fabricmc/fabric/test/lookup/entity/FabricEntityApiLookupTest.java +++ b/fabric-api-lookup-api-v1/src/testmod/java/net/fabricmc/fabric/test/lookup/entity/FabricEntityApiLookupTest.java @@ -23,6 +23,8 @@ import net.minecraft.entity.mob.CreeperEntity; import net.minecraft.entity.passive.PigEntity; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.text.Text; import net.minecraft.util.Identifier; @@ -33,6 +35,7 @@ import net.fabricmc.fabric.test.lookup.FabricApiLookupTest; import net.fabricmc.fabric.test.lookup.api.Inspectable; public class FabricEntityApiLookupTest { + public static final RegistryKey> INSPECTABLE_PIG_KEY = RegistryKey.of(RegistryKeys.ENTITY_TYPE, Identifier.of(FabricApiLookupTest.MOD_ID, "inspectable_pig")); public static final EntityApiLookup INSPECTABLE = EntityApiLookup.get(Identifier.of(FabricApiLookupTest.MOD_ID, "inspectable"), Inspectable.class, Void.class); @@ -41,10 +44,10 @@ public class FabricEntityApiLookupTest { .entityFactory(InspectablePigEntity::new) .dimensions(EntityDimensions.changing(0.9F, 0.9F)) .trackRangeChunks(10) - .build(); + .build(INSPECTABLE_PIG_KEY); public static void onInitialize() { - Registry.register(Registries.ENTITY_TYPE, Identifier.of(FabricApiLookupTest.MOD_ID, "inspectable_pig"), INSPECTABLE_PIG); + Registry.register(Registries.ENTITY_TYPE, INSPECTABLE_PIG_KEY, INSPECTABLE_PIG); FabricDefaultAttributeRegistry.register(INSPECTABLE_PIG, PigEntity.createPigAttributes()); INSPECTABLE.registerSelf(INSPECTABLE_PIG); diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeModificationContextImpl.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeModificationContextImpl.java index d65c80473..85fce82e5 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeModificationContextImpl.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeModificationContextImpl.java @@ -194,8 +194,8 @@ public class BiomeModificationContextImpl implements BiomeModificationContext { } private class GenerationSettingsContextImpl implements GenerationSettingsContext { - private final Registry> carvers = registries.get(RegistryKeys.CONFIGURED_CARVER); - private final Registry features = registries.get(RegistryKeys.PLACED_FEATURE); + private final Registry> carvers = registries.getOrThrow(RegistryKeys.CONFIGURED_CARVER); + private final Registry features = registries.getOrThrow(RegistryKeys.PLACED_FEATURE); private final GenerationSettings generationSettings = biome.getGenerationSettings(); boolean rebuildFeatures; @@ -316,7 +316,7 @@ public class BiomeModificationContextImpl implements BiomeModificationContext { * forgot to data-gen the JSONs corresponding to their built-in objects. */ private static RegistryEntry.Reference getEntry(Registry registry, RegistryKey key) { - RegistryEntry.Reference entry = registry.getEntry(key).orElse(null); + RegistryEntry.Reference entry = registry.getOptional(key).orElse(null); if (entry == null) { // The key doesn't exist in the data packs diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeModificationImpl.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeModificationImpl.java index 2adaaf425..da7658075 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeModificationImpl.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeModificationImpl.java @@ -114,13 +114,13 @@ public class BiomeModificationImpl { BiomeModificationMarker modificationTracker = (BiomeModificationMarker) impl; modificationTracker.fabric_markModified(); - Registry biomes = impl.get(RegistryKeys.BIOME); + Registry biomes = impl.getOrThrow(RegistryKeys.BIOME); // Build a list of all biome keys in ascending order of their raw-id to get a consistent result in case // someone does something stupid. List> keys = biomes.getEntrySet().stream() .map(Map.Entry::getKey) - .sorted(Comparator.comparingInt(key -> biomes.getRawId(biomes.getOrThrow(key)))) + .sorted(Comparator.comparingInt(key -> biomes.getRawId(biomes.getValueOrThrow(key)))) .toList(); List sortedModifiers = getSortedModifiers(); @@ -130,7 +130,7 @@ public class BiomeModificationImpl { int modifiersApplied = 0; for (RegistryKey key : keys) { - Biome biome = biomes.getOrThrow(key); + Biome biome = biomes.getValueOrThrow(key); biomesProcessed++; @@ -159,7 +159,7 @@ public class BiomeModificationImpl { modificationContext.freeze(); if (modificationContext.shouldRebuildFeatures()) { - impl.get(RegistryKeys.DIMENSION).stream().forEach(dimensionOptions -> { + impl.getOrThrow(RegistryKeys.DIMENSION).stream().forEach(dimensionOptions -> { dimensionOptions.chunkGenerator().indexedFeaturesListSupplier = Suppliers.memoize( () -> PlacedFeatureIndexer.collectIndexedFeatures( List.copyOf(dimensionOptions.chunkGenerator().getBiomeSource().getBiomes()), diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeSelectionContextImpl.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeSelectionContextImpl.java index 98ca24356..f3a58d5f7 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeSelectionContextImpl.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeSelectionContextImpl.java @@ -42,7 +42,7 @@ public class BiomeSelectionContextImpl implements BiomeSelectionContext { this.dynamicRegistries = dynamicRegistries; this.key = key; this.biome = biome; - this.entry = dynamicRegistries.get(RegistryKeys.BIOME).getEntry(this.key).orElseThrow(); + this.entry = dynamicRegistries.getOrThrow(RegistryKeys.BIOME).getOrThrow(this.key); } @Override @@ -62,19 +62,19 @@ public class BiomeSelectionContextImpl implements BiomeSelectionContext { @Override public Optional>> getFeatureKey(ConfiguredFeature configuredFeature) { - Registry> registry = dynamicRegistries.get(RegistryKeys.CONFIGURED_FEATURE); + Registry> registry = dynamicRegistries.getOrThrow(RegistryKeys.CONFIGURED_FEATURE); return registry.getKey(configuredFeature); } @Override public Optional> getPlacedFeatureKey(PlacedFeature placedFeature) { - Registry registry = dynamicRegistries.get(RegistryKeys.PLACED_FEATURE); + Registry registry = dynamicRegistries.getOrThrow(RegistryKeys.PLACED_FEATURE); return registry.getKey(placedFeature); } @Override public boolean validForStructure(RegistryKey key) { - Structure instance = dynamicRegistries.get(RegistryKeys.STRUCTURE).get(key); + Structure instance = dynamicRegistries.getOrThrow(RegistryKeys.STRUCTURE).get(key); if (instance == null) { return false; @@ -85,13 +85,13 @@ public class BiomeSelectionContextImpl implements BiomeSelectionContext { @Override public Optional> getStructureKey(Structure structure) { - Registry registry = dynamicRegistries.get(RegistryKeys.STRUCTURE); + Registry registry = dynamicRegistries.getOrThrow(RegistryKeys.STRUCTURE); return registry.getKey(structure); } @Override public boolean canGenerateIn(RegistryKey dimensionKey) { - DimensionOptions dimension = dynamicRegistries.get(RegistryKeys.DIMENSION).get(dimensionKey); + DimensionOptions dimension = dynamicRegistries.getOrThrow(RegistryKeys.DIMENSION).get(dimensionKey); if (dimension == null) { return false; @@ -102,7 +102,7 @@ public class BiomeSelectionContextImpl implements BiomeSelectionContext { @Override public boolean hasTag(TagKey tag) { - Registry biomeRegistry = dynamicRegistries.get(RegistryKeys.BIOME); - return biomeRegistry.entryOf(getBiomeKey()).isIn(tag); + Registry biomeRegistry = dynamicRegistries.getOrThrow(RegistryKeys.BIOME); + return biomeRegistry.getOrThrow(getBiomeKey()).isIn(tag); } } diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BuiltInRegistryKeys.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BuiltInRegistryKeys.java index 3424ae937..c523909cd 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BuiltInRegistryKeys.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BuiltInRegistryKeys.java @@ -37,6 +37,6 @@ public final class BuiltInRegistryKeys { } public static RegistryEntryLookup biomeRegistryWrapper() { - return vanillaRegistries.getWrapperOrThrow(RegistryKeys.BIOME); + return vanillaRegistries.getOrThrow(RegistryKeys.BIOME); } } diff --git a/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/WorldgenProvider.java b/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/WorldgenProvider.java index 66072fbef..d34372b52 100644 --- a/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/WorldgenProvider.java +++ b/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/WorldgenProvider.java @@ -31,9 +31,9 @@ public class WorldgenProvider extends FabricDynamicRegistryProvider { @Override protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.addAll(registries.getWrapperOrThrow(RegistryKeys.BIOME)); - entries.addAll(registries.getWrapperOrThrow(RegistryKeys.PLACED_FEATURE)); - entries.addAll(registries.getWrapperOrThrow(RegistryKeys.CONFIGURED_FEATURE)); + entries.addAll(registries.getOrThrow(RegistryKeys.BIOME)); + entries.addAll(registries.getOrThrow(RegistryKeys.PLACED_FEATURE)); + entries.addAll(registries.getOrThrow(RegistryKeys.CONFIGURED_FEATURE)); } @Override diff --git a/fabric-client-tags-api-v1/src/client/java/net/fabricmc/fabric/impl/tag/client/ClientTagsImpl.java b/fabric-client-tags-api-v1/src/client/java/net/fabricmc/fabric/impl/tag/client/ClientTagsImpl.java index 170024220..8a6106a90 100644 --- a/fabric-client-tags-api-v1/src/client/java/net/fabricmc/fabric/impl/tag/client/ClientTagsImpl.java +++ b/fabric-client-tags-api-v1/src/client/java/net/fabricmc/fabric/impl/tag/client/ClientTagsImpl.java @@ -50,7 +50,7 @@ public class ClientTagsImpl { if (maybeRegistry.isPresent()) { // Check the synced tag exists and use that - if (maybeRegistry.get().getEntryList(tagKey).isPresent()) { + if (maybeRegistry.get().getOptional(tagKey).isPresent()) { return registryEntry.isIn(tagKey); } } @@ -93,7 +93,7 @@ public class ClientTagsImpl { } } - return (Optional>) Registries.REGISTRIES.getOrEmpty(tagKey.registry().getValue()); + return (Optional>) Registries.REGISTRIES.getOptionalValue(tagKey.registry().getValue()); } @SuppressWarnings("unchecked") @@ -108,7 +108,7 @@ public class ClientTagsImpl { Optional> maybeKey = registry.getKey(entry); - return maybeKey.map(registry::entryOf); + return maybeKey.map(registry::getOrThrow); } public static ClientTagsLoader.LoadedTag getOrCreatePartiallySyncedTag(TagKey tagKey) { diff --git a/fabric-content-registries-v0/src/testmod/java/net/fabricmc/fabric/test/content/registry/ContentRegistryTest.java b/fabric-content-registries-v0/src/testmod/java/net/fabricmc/fabric/test/content/registry/ContentRegistryTest.java index 4e888e29d..56590d07d 100644 --- a/fabric-content-registries-v0/src/testmod/java/net/fabricmc/fabric/test/content/registry/ContentRegistryTest.java +++ b/fabric-content-registries-v0/src/testmod/java/net/fabricmc/fabric/test/content/registry/ContentRegistryTest.java @@ -65,6 +65,7 @@ public final class ContentRegistryTest implements ModInitializer { public static final Logger LOGGER = LoggerFactory.getLogger(ContentRegistryTest.class); public static final Identifier TEST_EVENT_ID = Identifier.of("fabric-content-registries-v0-testmod", "test_event"); + public static final RegistryKey TEST_EVENT_BLOCK_KEY = RegistryKey.of(RegistryKeys.BLOCK, TEST_EVENT_ID); public static final RegistryEntry.Reference TEST_EVENT = Registry.registerReference(Registries.GAME_EVENT, TEST_EVENT_ID, new GameEvent(GameEvent.DEFAULT_RANGE)); @Override @@ -136,7 +137,7 @@ public final class ContentRegistryTest implements ModInitializer { VillagerInteractionRegistries.registerGiftLootTable(VillagerProfession.NITWIT, RegistryKey.of(RegistryKeys.LOOT_TABLE, Identifier.ofVanilla("fake_loot_table"))); - Registry.register(Registries.BLOCK, TEST_EVENT_ID, new TestEventBlock(AbstractBlock.Settings.copy(Blocks.STONE))); + Registry.register(Registries.BLOCK, TEST_EVENT_BLOCK_KEY, new TestEventBlock(AbstractBlock.Settings.copy(Blocks.STONE).registryKey(TEST_EVENT_BLOCK_KEY))); SculkSensorFrequencyRegistry.register(TEST_EVENT.registryKey(), 2); // assert that SculkSensorFrequencyRegistry throws when registering a frequency outside the allowed range @@ -156,8 +157,8 @@ public final class ContentRegistryTest implements ModInitializer { * This testmod uses an accessor due to Loom limitations that prevent TAWs from applying across Gradle subproject boundaries */ FabricBrewingRecipeRegistryBuilder.BUILD.register(builder -> { builder.registerPotionType(dirtyPotion); - builder.registerItemRecipe(Items.POTION, Ingredient.fromTag(Registries.ITEM.getEntryList(ItemTags.DIRT).get()), dirtyPotion); - builder.registerPotionRecipe(Potions.AWKWARD, Ingredient.fromTag(Registries.ITEM.getEntryList(ItemTags.SMALL_FLOWERS).get()), Potions.HEALING); + builder.registerItemRecipe(Items.POTION, Ingredient.fromTag(Registries.ITEM.getOrThrow(ItemTags.DIRT)), dirtyPotion); + builder.registerPotionRecipe(Potions.AWKWARD, Ingredient.fromTag(Registries.ITEM.getOrThrow(ItemTags.SMALL_FLOWERS)), Potions.HEALING); if (builder.getEnabledFeatures().contains(FeatureFlags.BUNDLE)) { builder.registerPotionRecipe(Potions.AWKWARD, Ingredient.ofItems(Items.BUNDLE), Potions.LUCK); diff --git a/fabric-convention-tags-v2/src/main/java/net/fabricmc/fabric/api/tag/convention/v2/TagUtil.java b/fabric-convention-tags-v2/src/main/java/net/fabricmc/fabric/api/tag/convention/v2/TagUtil.java index 98289d65e..7d3a5c686 100644 --- a/fabric-convention-tags-v2/src/main/java/net/fabricmc/fabric/api/tag/convention/v2/TagUtil.java +++ b/fabric-convention-tags-v2/src/main/java/net/fabricmc/fabric/api/tag/convention/v2/TagUtil.java @@ -66,7 +66,7 @@ public final class TagUtil { if (registryManager != null) { maybeRegistry = registryManager.getOptional(tagKey.registry()); } else { - maybeRegistry = Registries.REGISTRIES.getOrEmpty(tagKey.registry().getValue()); + maybeRegistry = Registries.REGISTRIES.getOptionalValue(tagKey.registry().getValue()); } if (maybeRegistry.isPresent()) { @@ -77,7 +77,7 @@ public final class TagUtil { // Check synced tag if (maybeKey.isPresent()) { - return registry.entryOf(maybeKey.get()).isIn(tagKey); + return registry.getOrThrow(maybeKey.get()).isIn(tagKey); } } } diff --git a/fabric-convention-tags-v2/src/main/java/net/fabricmc/fabric/impl/tag/convention/v2/TranslationConventionLogWarnings.java b/fabric-convention-tags-v2/src/main/java/net/fabricmc/fabric/impl/tag/convention/v2/TranslationConventionLogWarnings.java index 2663dbd04..3b1c19667 100644 --- a/fabric-convention-tags-v2/src/main/java/net/fabricmc/fabric/impl/tag/convention/v2/TranslationConventionLogWarnings.java +++ b/fabric-convention-tags-v2/src/main/java/net/fabricmc/fabric/impl/tag/convention/v2/TranslationConventionLogWarnings.java @@ -77,7 +77,7 @@ public class TranslationConventionLogWarnings implements ModInitializer { // Log missing item tag translations only when world is started. ServerLifecycleEvents.SERVER_STARTED.register(server -> { Language language = Language.getInstance(); - Registry itemRegistry = server.getRegistryManager().get(RegistryKeys.ITEM); + Registry itemRegistry = server.getRegistryManager().getOrThrow(RegistryKeys.ITEM); List> untranslatedItemTags = new ObjectArrayList<>(); itemRegistry.streamTags().forEach(itemTagKey -> { // We do not translate vanilla's tags at this moment. diff --git a/fabric-convention-tags-v2/src/testmod/java/net/fabricmc/fabric/test/tag/convention/v2/TagUtilTest.java b/fabric-convention-tags-v2/src/testmod/java/net/fabricmc/fabric/test/tag/convention/v2/TagUtilTest.java index 2fcbbe338..fa50e87dd 100644 --- a/fabric-convention-tags-v2/src/testmod/java/net/fabricmc/fabric/test/tag/convention/v2/TagUtilTest.java +++ b/fabric-convention-tags-v2/src/testmod/java/net/fabricmc/fabric/test/tag/convention/v2/TagUtilTest.java @@ -156,16 +156,16 @@ public class TagUtilTest implements ModInitializer { } ServerLifecycleEvents.SERVER_STARTED.register(server -> { - if (!TagUtil.isIn(server.getRegistryManager(), ConventionalEnchantmentTags.INCREASE_BLOCK_DROPS, server.getRegistryManager().get(RegistryKeys.ENCHANTMENT).get(Enchantments.FORTUNE))) { + if (!TagUtil.isIn(server.getRegistryManager(), ConventionalEnchantmentTags.INCREASE_BLOCK_DROPS, server.getRegistryManager().getOrThrow(RegistryKeys.ENCHANTMENT).get(Enchantments.FORTUNE))) { throw new AssertionError("Failed to find fortune in c:increase_block_drops!"); } - if (TagUtil.isIn(ConventionalBiomeTags.IS_OVERWORLD, server.getRegistryManager().get(RegistryKeys.BIOME).get(BiomeKeys.BADLANDS))) { + if (TagUtil.isIn(ConventionalBiomeTags.IS_OVERWORLD, server.getRegistryManager().getOrThrow(RegistryKeys.BIOME).get(BiomeKeys.BADLANDS))) { throw new AssertionError("Found a dynamic entry in a static registry?!"); } // If this fails, the tag is missing a biome or the util is broken - if (!TagUtil.isIn(server.getRegistryManager(), ConventionalBiomeTags.IS_OVERWORLD, server.getRegistryManager().get(RegistryKeys.BIOME).get(BiomeKeys.BADLANDS))) { + if (!TagUtil.isIn(server.getRegistryManager(), ConventionalBiomeTags.IS_OVERWORLD, server.getRegistryManager().getOrThrow(RegistryKeys.BIOME).get(BiomeKeys.BADLANDS))) { throw new AssertionError("Failed to find an overworld biome (%s) in c:in_overworld!".formatted(BiomeKeys.BADLANDS)); } diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricBlockLootTableProvider.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricBlockLootTableProvider.java index 49e510268..17110b80f 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricBlockLootTableProvider.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricBlockLootTableProvider.java @@ -19,6 +19,7 @@ package net.fabricmc.fabric.api.datagen.v1.provider; import java.util.Collections; import java.util.HashSet; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.function.BiConsumer; @@ -29,7 +30,6 @@ import net.minecraft.block.Block; import net.minecraft.data.DataWriter; import net.minecraft.data.server.loottable.BlockLootTableGenerator; import net.minecraft.loot.LootTable; -import net.minecraft.loot.LootTables; import net.minecraft.loot.context.LootContextTypes; import net.minecraft.registry.Registries; import net.minecraft.registry.RegistryKey; @@ -79,10 +79,6 @@ public abstract class FabricBlockLootTableProvider extends BlockLootTableGenerat for (Map.Entry, LootTable.Builder> entry : lootTables.entrySet()) { RegistryKey registryKey = entry.getKey(); - if (registryKey == LootTables.EMPTY) { - continue; - } - biConsumer.accept(registryKey, entry.getValue()); } @@ -91,10 +87,10 @@ public abstract class FabricBlockLootTableProvider extends BlockLootTableGenerat for (Identifier blockId : Registries.BLOCK.getIds()) { if (blockId.getNamespace().equals(output.getModId())) { - RegistryKey blockLootTableId = Registries.BLOCK.get(blockId).getLootTableKey(); + Optional> blockLootTableId = Registries.BLOCK.get(blockId).getLootTableKey(); - if (blockLootTableId.getValue().getNamespace().equals(output.getModId())) { - if (!lootTables.containsKey(blockLootTableId)) { + if (blockLootTableId.isPresent() && blockLootTableId.get().getValue().getNamespace().equals(output.getModId())) { + if (!lootTables.containsKey(blockLootTableId.get())) { missing.add(blockId); } } diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricDynamicRegistryProvider.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricDynamicRegistryProvider.java index a917d6a45..387f31ed9 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricDynamicRegistryProvider.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricDynamicRegistryProvider.java @@ -85,7 +85,7 @@ public abstract class FabricDynamicRegistryProvider implements DataProvider { this.registries = registries; this.queuedEntries = DynamicRegistries.getDynamicRegistries().stream() // Some modded dynamic registries might not be in the wrapper lookup, filter them out - .filter(e -> registries.getOptionalWrapper(e.key()).isPresent()) + .filter(e -> registries.getOptional(e.key()).isPresent()) .collect(Collectors.toMap( e -> e.key().getValue(), e -> RegistryEntries.create(registries, e) @@ -104,7 +104,7 @@ public abstract class FabricDynamicRegistryProvider implements DataProvider { * Gets a lookup for entries from the given registry. */ public RegistryEntryLookup getLookup(RegistryKey> registryKey) { - return registries.getWrapperOrThrow(registryKey); + return registries.getOrThrow(registryKey); } /** @@ -232,7 +232,7 @@ public abstract class FabricDynamicRegistryProvider implements DataProvider { } static RegistryEntries create(RegistryWrapper.WrapperLookup lookups, RegistryLoader.Entry loaderEntry) { - RegistryWrapper.Impl lookup = lookups.getWrapperOrThrow(loaderEntry.key()); + RegistryWrapper.Impl lookup = lookups.getOrThrow(loaderEntry.key()); return new RegistryEntries<>(lookup, loaderEntry.key(), loaderEntry.elementCodec()); } diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricLanguageProvider.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricLanguageProvider.java index 30d896f57..19ac297c3 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricLanguageProvider.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricLanguageProvider.java @@ -159,7 +159,7 @@ public abstract class FabricLanguageProvider implements DataProvider { * @param value The value of the entry. */ default void add(RegistryKey registryKey, String value) { - final ItemGroup group = Registries.ITEM_GROUP.getOrThrow(registryKey); + final ItemGroup group = Registries.ITEM_GROUP.getValueOrThrow(registryKey); final TextContent content = group.getDisplayName().getContent(); if (content instanceof TranslatableTextContent translatableTextContent) { diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/loot/ConditionBlockLootTableGenerator.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/loot/ConditionBlockLootTableGenerator.java index e50911f28..401a74738 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/loot/ConditionBlockLootTableGenerator.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/loot/ConditionBlockLootTableGenerator.java @@ -32,7 +32,7 @@ public class ConditionBlockLootTableGenerator extends BlockLootTableGenerator { private final ResourceCondition[] conditions; public ConditionBlockLootTableGenerator(BlockLootTableGenerator parent, ResourceCondition[] conditions) { - super(Collections.emptySet(), FeatureFlags.FEATURE_MANAGER.getFeatureSet(), ((BlockLootTableGeneratorAccessor) parent).getRegistryLookup()); + super(Collections.emptySet(), FeatureFlags.FEATURE_MANAGER.getFeatureSet(), ((BlockLootTableGeneratorAccessor) parent).getRegistries()); this.parent = parent; this.conditions = conditions; diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/loot/BlockLootTableGeneratorAccessor.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/loot/BlockLootTableGeneratorAccessor.java index 2ea425f5f..9dbca28e4 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/loot/BlockLootTableGeneratorAccessor.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/loot/BlockLootTableGeneratorAccessor.java @@ -25,5 +25,5 @@ import net.minecraft.registry.RegistryWrapper; @Mixin(BlockLootTableGenerator.class) public interface BlockLootTableGeneratorAccessor { @Accessor() - RegistryWrapper.WrapperLookup getRegistryLookup(); + RegistryWrapper.WrapperLookup getRegistries(); } diff --git a/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestContent.java b/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestContent.java index 7b52736cc..3c99bc692 100644 --- a/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestContent.java +++ b/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestContent.java @@ -69,7 +69,7 @@ public class DataGeneratorTestContent implements ModInitializer { SIMPLE_BLOCK = createBlock("simple_block", true, AbstractBlock.Settings.create()); BLOCK_WITHOUT_ITEM = createBlock("block_without_item", false, AbstractBlock.Settings.create()); BLOCK_WITHOUT_LOOT_TABLE = createBlock("block_without_loot_table", false, AbstractBlock.Settings.create()); - BLOCK_WITH_VANILLA_LOOT_TABLE = createBlock("block_with_vanilla_loot_table", false, AbstractBlock.Settings.create().dropsLike(Blocks.STONE)); + BLOCK_WITH_VANILLA_LOOT_TABLE = createBlock("block_with_vanilla_loot_table", false, AbstractBlock.Settings.create().lootTable(Blocks.STONE.getLootTableKey())); BLOCK_THAT_DROPS_NOTHING = createBlock("block_that_drops_nothing", false, AbstractBlock.Settings.create().dropsNothing()); ItemGroupEvents.modifyEntriesEvent(SIMPLE_ITEM_GROUP).register(entries -> entries.add(SIMPLE_BLOCK)); @@ -85,7 +85,7 @@ public class DataGeneratorTestContent implements ModInitializer { private static Block createBlock(String name, boolean hasItem, AbstractBlock.Settings settings) { Identifier identifier = Identifier.of(MOD_ID, name); - Block block = Registry.register(Registries.BLOCK, identifier, new Block(settings)); + Block block = Registry.register(Registries.BLOCK, identifier, new Block(settings.registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)))); if (hasItem) { Registry.register(Registries.ITEM, identifier, new BlockItem(block, new Item.Settings())); diff --git a/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestEntrypoint.java b/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestEntrypoint.java index 97ac9668b..86af5fd0e 100644 --- a/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestEntrypoint.java +++ b/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestEntrypoint.java @@ -444,7 +444,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint { @Override protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { entries.add( - registries.getWrapperOrThrow(TEST_DATAGEN_DYNAMIC_REGISTRY_KEY), TEST_DYNAMIC_REGISTRY_ITEM_KEY, + registries.getOrThrow(TEST_DATAGEN_DYNAMIC_REGISTRY_KEY), TEST_DYNAMIC_REGISTRY_ITEM_KEY, ResourceConditions.allModsLoaded(MOD_ID) ); } @@ -465,7 +465,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint { @Override protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { - entries.add(registries.getWrapperOrThrow(TEST_DATAGEN_DYNAMIC_REGISTRY_KEY), TEST_DYNAMIC_REGISTRY_EXTRA_ITEM_KEY); + entries.add(registries.getOrThrow(TEST_DATAGEN_DYNAMIC_REGISTRY_KEY), TEST_DYNAMIC_REGISTRY_EXTRA_ITEM_KEY); } @Override @@ -481,7 +481,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint { @Override protected void configure(BiConsumer provider, RegistryWrapper.WrapperLookup lookup) { - RegistryEntryLookup blocks = lookup.createRegistryLookup().getOrThrow(RegistryKeys.BLOCK); + RegistryEntryLookup blocks = lookup.getOrThrow(RegistryKeys.BLOCK); provider.accept(Identifier.of(MOD_ID, "predicate_test"), BlockStatePropertyLootCondition.builder( blocks.getOrThrow(BlockKeys.MELON).value()).build()); // Pretend this actually does something and we cannot access the blocks directly } @@ -499,7 +499,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint { @Override protected void configure(BiConsumer provider, RegistryWrapper.WrapperLookup lookup) { - RegistryEntryLookup biomes = lookup.createRegistryLookup().getOrThrow(RegistryKeys.BIOME); + RegistryEntryLookup biomes = lookup.getOrThrow(RegistryKeys.BIOME); provider.accept(Identifier.of(MOD_ID, "custom_codec_test"), new Entry(biomes.getOrThrow(BiomeKeys.PLAINS))); } diff --git a/fabric-entity-events-v1/src/testmod/java/net/fabricmc/fabric/test/entity/event/EntityEventTests.java b/fabric-entity-events-v1/src/testmod/java/net/fabricmc/fabric/test/entity/event/EntityEventTests.java index f6e1779ed..fee1d4614 100644 --- a/fabric-entity-events-v1/src/testmod/java/net/fabricmc/fabric/test/entity/event/EntityEventTests.java +++ b/fabric-entity-events-v1/src/testmod/java/net/fabricmc/fabric/test/entity/event/EntityEventTests.java @@ -32,6 +32,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.server.command.CommandManager; import net.minecraft.text.Text; import net.minecraft.util.ActionResult; @@ -51,13 +53,17 @@ import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents; public final class EntityEventTests implements ModInitializer { private static final Logger LOGGER = LoggerFactory.getLogger(EntityEventTests.class); - public static final Block TEST_BED = new TestBedBlock(AbstractBlock.Settings.create().strength(1, 1)); + public static final RegistryKey TEST_BED_KEY = RegistryKey.of( + RegistryKeys.BLOCK, + Identifier.of("fabric-entity-events-v1-testmod", "test_bed") + ); + public static final Block TEST_BED = new TestBedBlock(AbstractBlock.Settings.create().strength(1, 1).registryKey(TEST_BED_KEY)); public static final Item DIAMOND_ELYTRA = new DiamondElytraItem(); @Override public void onInitialize() { - Registry.register(Registries.BLOCK, Identifier.of("fabric-entity-events-v1-testmod", "test_bed"), TEST_BED); - Registry.register(Registries.ITEM, Identifier.of("fabric-entity-events-v1-testmod", "test_bed"), new BlockItem(TEST_BED, new Item.Settings())); + Registry.register(Registries.BLOCK, TEST_BED_KEY, TEST_BED); + Registry.register(Registries.ITEM, TEST_BED_KEY.getValue(), new BlockItem(TEST_BED, new Item.Settings())); Registry.register(Registries.ITEM, Identifier.of("fabric-entity-events-v1-testmod", "diamond_elytra"), DIAMOND_ELYTRA); ServerEntityCombatEvents.AFTER_KILLED_OTHER_ENTITY.register((world, entity, killed) -> { diff --git a/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/impl/client/itemgroup/FabricCreativeGuiComponents.java b/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/impl/client/itemgroup/FabricCreativeGuiComponents.java index 63903e3a0..9c63eb652 100644 --- a/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/impl/client/itemgroup/FabricCreativeGuiComponents.java +++ b/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/impl/client/itemgroup/FabricCreativeGuiComponents.java @@ -38,7 +38,7 @@ public class FabricCreativeGuiComponents { private static final Identifier BUTTON_TEX = Identifier.of("fabric", "textures/gui/creative_buttons.png"); private static final double TABS_PER_PAGE = FabricItemGroupImpl.TABS_PER_PAGE; public static final Set COMMON_GROUPS = Set.of(ItemGroups.SEARCH, ItemGroups.INVENTORY, ItemGroups.HOTBAR).stream() - .map(Registries.ITEM_GROUP::getOrThrow) + .map(Registries.ITEM_GROUP::getValueOrThrow) .collect(Collectors.toSet()); public static int getPageCount() { diff --git a/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/mixin/itemgroup/ItemGroupsMixin.java b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/mixin/itemgroup/ItemGroupsMixin.java index 09dbf3c18..d99f7df1f 100644 --- a/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/mixin/itemgroup/ItemGroupsMixin.java +++ b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/mixin/itemgroup/ItemGroupsMixin.java @@ -109,7 +109,7 @@ public class ItemGroupsMixin { var map = new HashMap(); for (RegistryKey registryKey : Registries.ITEM_GROUP.getKeys()) { - final ItemGroup itemGroup = Registries.ITEM_GROUP.getOrThrow(registryKey); + final ItemGroup itemGroup = Registries.ITEM_GROUP.getValueOrThrow(registryKey); final FabricItemGroupImpl fabricItemGroup = (FabricItemGroupImpl) itemGroup; final String displayName = itemGroup.getDisplayName().getString(); final var position = new ItemGroupPosition(itemGroup.getRow(), itemGroup.getColumn(), fabricItemGroup.fabric_getPage()); diff --git a/fabric-loot-api-v3/src/main/java/net/fabricmc/fabric/mixin/loot/ReloadableRegistriesMixin.java b/fabric-loot-api-v3/src/main/java/net/fabricmc/fabric/mixin/loot/ReloadableRegistriesMixin.java index 6d44ed514..f4bf120cd 100644 --- a/fabric-loot-api-v3/src/main/java/net/fabricmc/fabric/mixin/loot/ReloadableRegistriesMixin.java +++ b/fabric-loot-api-v3/src/main/java/net/fabricmc/fabric/mixin/loot/ReloadableRegistriesMixin.java @@ -89,11 +89,6 @@ abstract class ReloadableRegistriesMixin { private static T modifyLootTable(T value, Identifier id, RegistryOps ops) { if (!(value instanceof LootTable table)) return value; - if (table == LootTable.EMPTY) { - // This is a special table and cannot be modified. - return value; - } - RegistryKey key = RegistryKey.of(RegistryKeys.LOOT_TABLE, id); // Populated above. RegistryWrapper.WrapperLookup registries = WRAPPERS.get(ops); diff --git a/fabric-loot-api-v3/src/testmod/java/net/fabricmc/fabric/test/loot/LootTest.java b/fabric-loot-api-v3/src/testmod/java/net/fabricmc/fabric/test/loot/LootTest.java index 292206ab5..cb7dfb9d5 100644 --- a/fabric-loot-api-v3/src/testmod/java/net/fabricmc/fabric/test/loot/LootTest.java +++ b/fabric-loot-api-v3/src/testmod/java/net/fabricmc/fabric/test/loot/LootTest.java @@ -45,7 +45,7 @@ public class LootTest implements ModInitializer { // The LootTable.Builder LootPool.Builder methods here should use // prebuilt entries and pools to test the injected methods. LootTableEvents.REPLACE.register((key, original, source, registries) -> { - if (Blocks.BLACK_WOOL.getLootTableKey() == key) { + if (Blocks.BLACK_WOOL.getLootTableKey().orElse(null) == key) { if (source != LootTableSource.VANILLA) { throw new AssertionError("black wool loot table should have LootTableSource.VANILLA, got " + source); } @@ -63,7 +63,7 @@ public class LootTest implements ModInitializer { // Test that the event is stopped when the loot table is replaced LootTableEvents.REPLACE.register((key, original, source, registries) -> { - if (Blocks.BLACK_WOOL.getLootTableKey() == key) { + if (Blocks.BLACK_WOOL.getLootTableKey().orElse(null) == key) { throw new AssertionError("Event should have been stopped from replaced loot table"); } @@ -71,11 +71,11 @@ public class LootTest implements ModInitializer { }); LootTableEvents.MODIFY.register((key, tableBuilder, source, registries) -> { - if (Blocks.BLACK_WOOL.getLootTableKey() == key && source != LootTableSource.REPLACED) { + if (Blocks.BLACK_WOOL.getLootTableKey().orElse(null) == key && source != LootTableSource.REPLACED) { throw new AssertionError("black wool loot table should have LootTableSource.REPLACED, got " + source); } - if (Blocks.WHITE_WOOL.getLootTableKey() == key) { + if (Blocks.WHITE_WOOL.getLootTableKey().orElse(null) == key) { if (source != LootTableSource.VANILLA) { throw new AssertionError("white wool loot table should have LootTableSource.VANILLA, got " + source); } @@ -91,20 +91,20 @@ public class LootTest implements ModInitializer { } // We modify red wool to drop diamonds in the test mod resources. - if (Blocks.RED_WOOL.getLootTableKey() == key && source != LootTableSource.MOD) { + if (Blocks.RED_WOOL.getLootTableKey().orElse(null) == key && source != LootTableSource.MOD) { throw new AssertionError("red wool loot table should have LootTableSource.MOD, got " + source); } // Modify yellow wool to drop *either* yellow wool or emeralds by adding // emeralds to the same loot pool. - if (Blocks.YELLOW_WOOL.getLootTableKey() == key) { + if (Blocks.YELLOW_WOOL.getLootTableKey().orElse(null) == key) { tableBuilder.modifyPools(poolBuilder -> poolBuilder.with(ItemEntry.builder(Items.EMERALD))); } }); LootTableEvents.MODIFY.register((key, tableBuilder, source, registries) -> { - if (EntityType.SALMON.getLootTableId() == key) { - Optional> lure = registries.getOptionalWrapper(RegistryKeys.ENCHANTMENT).flatMap(registry -> registry.getOptional(Enchantments.LURE)); + if (EntityType.SALMON.getLootTable().orElse(null) == key) { + Optional> lure = registries.getOptional(RegistryKeys.ENCHANTMENT).flatMap(registry -> registry.getOptional(Enchantments.LURE)); lure.ifPresent((lureEnchantment) -> tableBuilder.pool(LootPool.builder().with( ItemEntry.builder(Items.FISHING_ROD) @@ -115,9 +115,9 @@ public class LootTest implements ModInitializer { }); LootTableEvents.ALL_LOADED.register((resourceManager, lootRegistry) -> { - LootTable blackWoolTable = lootRegistry.get(Blocks.BLACK_WOOL.getLootTableKey()); + Optional blackWoolTable = lootRegistry.getOptionalValue(Blocks.BLACK_WOOL.getLootTableKey().orElse(null)); - if (blackWoolTable == LootTable.EMPTY) { + if (blackWoolTable.isEmpty() || blackWoolTable.get() == LootTable.EMPTY) { throw new AssertionError("black wool loot table should not be empty"); } }); diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/block/FabricBlockSettings.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/block/FabricBlockSettings.java deleted file mode 100644 index d1391a88a..000000000 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/block/FabricBlockSettings.java +++ /dev/null @@ -1,447 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.api.object.builder.v1.block; - -import java.util.function.Function; -import java.util.function.ToIntFunction; - -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.MapColor; -import net.minecraft.block.enums.NoteBlockInstrument; -import net.minecraft.block.piston.PistonBehavior; -import net.minecraft.entity.EntityType; -import net.minecraft.loot.LootTable; -import net.minecraft.registry.RegistryKey; -import net.minecraft.resource.featuretoggle.FeatureFlag; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.util.DyeColor; - -import net.fabricmc.fabric.mixin.object.builder.AbstractBlockAccessor; -import net.fabricmc.fabric.mixin.object.builder.AbstractBlockSettingsAccessor; - -/** - * @deprecated replace with {@link AbstractBlock.Settings} - */ -@Deprecated -public class FabricBlockSettings extends AbstractBlock.Settings { - protected FabricBlockSettings() { - super(); - } - - protected FabricBlockSettings(AbstractBlock.Settings settings) { - this(); - // Mostly Copied from vanilla's copy method - // Note: If new methods are added to Block settings, an accessor must be added here - AbstractBlockSettingsAccessor thisAccessor = (AbstractBlockSettingsAccessor) this; - AbstractBlockSettingsAccessor otherAccessor = (AbstractBlockSettingsAccessor) settings; - - // Copied in vanilla: sorted by vanilla copy order - this.hardness(otherAccessor.getHardness()); - this.resistance(otherAccessor.getResistance()); - this.collidable(otherAccessor.getCollidable()); - thisAccessor.setRandomTicks(otherAccessor.getRandomTicks()); - this.luminance(otherAccessor.getLuminance()); - thisAccessor.setMapColorProvider(otherAccessor.getMapColorProvider()); - this.sounds(otherAccessor.getSoundGroup()); - this.slipperiness(otherAccessor.getSlipperiness()); - this.velocityMultiplier(otherAccessor.getVelocityMultiplier()); - thisAccessor.setDynamicBounds(otherAccessor.getDynamicBounds()); - thisAccessor.setOpaque(otherAccessor.getOpaque()); - thisAccessor.setIsAir(otherAccessor.getIsAir()); - thisAccessor.setBurnable(otherAccessor.getBurnable()); - thisAccessor.setLiquid(otherAccessor.getLiquid()); - thisAccessor.setForceNotSolid(otherAccessor.getForceNotSolid()); - thisAccessor.setForceSolid(otherAccessor.getForceSolid()); - this.pistonBehavior(otherAccessor.getPistonBehavior()); - thisAccessor.setToolRequired(otherAccessor.isToolRequired()); - thisAccessor.setOffsetter(otherAccessor.getOffsetter()); - thisAccessor.setBlockBreakParticles(otherAccessor.getBlockBreakParticles()); - thisAccessor.setRequiredFeatures(otherAccessor.getRequiredFeatures()); - this.emissiveLighting(otherAccessor.getEmissiveLightingPredicate()); - this.instrument(otherAccessor.getInstrument()); - thisAccessor.setReplaceable(otherAccessor.getReplaceable()); - - // Vanilla did not copy those fields until 23w45a, which introduced - // copyShallow method (maintaining the behavior previously used by the copy method) - // and the copy method that copies those fields as well. copyShallow is now - // deprecated. To maintain compatibility and since this behavior seems to be the - // more proper way, this copies all the fields, not just the shallow ones. - // Fields are added by field definition order. - this.jumpVelocityMultiplier(otherAccessor.getJumpVelocityMultiplier()); - this.drops(otherAccessor.getLootTableKey()); - this.allowsSpawning(otherAccessor.getAllowsSpawningPredicate()); - this.solidBlock(otherAccessor.getSolidBlockPredicate()); - this.suffocates(otherAccessor.getSuffocationPredicate()); - this.blockVision(otherAccessor.getBlockVisionPredicate()); - this.postProcess(otherAccessor.getPostProcessPredicate()); - } - - /** - * @deprecated replace with {@link AbstractBlock.Settings#create()} - */ - @Deprecated - public static FabricBlockSettings create() { - return new FabricBlockSettings(); - } - - /** - * @deprecated replace with {@link AbstractBlock.Settings#create()} - */ - @Deprecated - public static FabricBlockSettings of() { - return create(); - } - - /** - * @deprecated replace with {@link AbstractBlock.Settings#copy(AbstractBlock)} - */ - @Deprecated - public static FabricBlockSettings copyOf(AbstractBlock block) { - return new FabricBlockSettings(((AbstractBlockAccessor) block).getSettings()); - } - - /** - * @deprecated replace with {@link AbstractBlock.Settings#copy(AbstractBlock)} - */ - @Deprecated - public static FabricBlockSettings copyOf(AbstractBlock.Settings settings) { - return new FabricBlockSettings(settings); - } - - @Deprecated - @Override - public FabricBlockSettings noCollision() { - super.noCollision(); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings nonOpaque() { - super.nonOpaque(); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings slipperiness(float value) { - super.slipperiness(value); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings velocityMultiplier(float velocityMultiplier) { - super.velocityMultiplier(velocityMultiplier); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings jumpVelocityMultiplier(float jumpVelocityMultiplier) { - super.jumpVelocityMultiplier(jumpVelocityMultiplier); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings sounds(BlockSoundGroup group) { - super.sounds(group); - return this; - } - - /** - * @deprecated Please use {@link FabricBlockSettings#luminance(ToIntFunction)}. - */ - @Deprecated - public FabricBlockSettings lightLevel(ToIntFunction levelFunction) { - return this.luminance(levelFunction); - } - - @Deprecated - @Override - public FabricBlockSettings luminance(ToIntFunction luminanceFunction) { - super.luminance(luminanceFunction); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings strength(float hardness, float resistance) { - super.strength(hardness, resistance); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings breakInstantly() { - super.breakInstantly(); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings strength(float strength) { - super.strength(strength); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings ticksRandomly() { - super.ticksRandomly(); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings dynamicBounds() { - super.dynamicBounds(); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings dropsNothing() { - super.dropsNothing(); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings dropsLike(Block block) { - super.dropsLike(block); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings air() { - super.air(); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings allowsSpawning(AbstractBlock.TypedContextPredicate> predicate) { - super.allowsSpawning(predicate); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings solidBlock(AbstractBlock.ContextPredicate predicate) { - super.solidBlock(predicate); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings suffocates(AbstractBlock.ContextPredicate predicate) { - super.suffocates(predicate); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings blockVision(AbstractBlock.ContextPredicate predicate) { - super.blockVision(predicate); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings postProcess(AbstractBlock.ContextPredicate predicate) { - super.postProcess(predicate); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings emissiveLighting(AbstractBlock.ContextPredicate predicate) { - super.emissiveLighting(predicate); - return this; - } - - /** - * Make the block require tool to drop and slows down mining speed if the incorrect tool is used. - */ - @Deprecated - @Override - public FabricBlockSettings requiresTool() { - super.requiresTool(); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings mapColor(MapColor color) { - super.mapColor(color); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings hardness(float hardness) { - super.hardness(hardness); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings resistance(float resistance) { - super.resistance(resistance); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings offset(AbstractBlock.OffsetType offsetType) { - super.offset(offsetType); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings noBlockBreakParticles() { - super.noBlockBreakParticles(); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings requires(FeatureFlag... features) { - super.requires(features); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings mapColor(Function mapColorProvider) { - super.mapColor(mapColorProvider); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings burnable() { - super.burnable(); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings liquid() { - super.liquid(); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings solid() { - super.solid(); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings notSolid() { - super.notSolid(); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings pistonBehavior(PistonBehavior pistonBehavior) { - super.pistonBehavior(pistonBehavior); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings instrument(NoteBlockInstrument instrument) { - super.instrument(instrument); - return this; - } - - @Deprecated - @Override - public FabricBlockSettings replaceable() { - super.replaceable(); - return this; - } - - /* FABRIC ADDITIONS*/ - - /** - * @deprecated Please use {@link FabricBlockSettings#luminance(int)}. - */ - @Deprecated - public FabricBlockSettings lightLevel(int lightLevel) { - this.luminance(lightLevel); - return this; - } - - /** - * @deprecated replace with {@link AbstractBlock.Settings#luminance(ToIntFunction)} - */ - @Deprecated - public FabricBlockSettings luminance(int luminance) { - this.luminance(ignored -> luminance); - return this; - } - - @Deprecated - public FabricBlockSettings drops(RegistryKey dropTableId) { - ((AbstractBlockSettingsAccessor) this).setLootTableKey(dropTableId); - return this; - } - - /* FABRIC DELEGATE WRAPPERS */ - - /** - * @deprecated Please migrate to {@link AbstractBlock.Settings#mapColor(MapColor)} - */ - @Deprecated - public FabricBlockSettings materialColor(MapColor color) { - return this.mapColor(color); - } - - /** - * @deprecated Please migrate to {@link AbstractBlock.Settings#mapColor(DyeColor)} - */ - @Deprecated - public FabricBlockSettings materialColor(DyeColor color) { - return this.mapColor(color); - } - - /** - * @deprecated Please migrate to {@link AbstractBlock.Settings#mapColor(DyeColor)} - */ - @Deprecated - public FabricBlockSettings mapColor(DyeColor color) { - return this.mapColor(color.getMapColor()); - } - - @Deprecated - public FabricBlockSettings collidable(boolean collidable) { - ((AbstractBlockSettingsAccessor) this).setCollidable(collidable); - return this; - } -} diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricEntityType.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricEntityType.java index 69ed4d52b..3ec2aff1c 100644 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricEntityType.java +++ b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricEntityType.java @@ -51,15 +51,6 @@ public interface FabricEntityType { throw new AssertionError("Implemented in Mixin"); } - /** - * Build the entity type from the builder. Same as {@link EntityType.Builder#build(String)} but without an id. - * - * @return the entity type instance - */ - default EntityType build() { - throw new AssertionError("Implemented in Mixin"); - } - /** * Creates an entity type builder for a living entity. * diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricEntityTypeBuilder.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricEntityTypeBuilder.java index d0bcb2964..845ff0785 100644 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricEntityTypeBuilder.java +++ b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricEntityTypeBuilder.java @@ -33,6 +33,7 @@ import net.minecraft.entity.SpawnLocation; import net.minecraft.entity.SpawnRestriction; import net.minecraft.entity.attribute.DefaultAttributeContainer; import net.minecraft.entity.mob.MobEntity; +import net.minecraft.registry.RegistryKey; import net.minecraft.resource.featuretoggle.FeatureFlag; import net.minecraft.world.Heightmap; import net.minecraft.world.World; @@ -306,10 +307,10 @@ public class FabricEntityTypeBuilder { * Creates the entity type. * * @return a new {@link EntityType} - * @deprecated use {@link EntityType.Builder#build()} + * @deprecated use {@link EntityType.Builder#build(net.minecraft.registry.RegistryKey)} */ @Deprecated - public EntityType build() { + public EntityType build(RegistryKey> key) { EntityType.Builder builder = EntityType.Builder.create(this.factory, this.spawnGroup) .allowSpawningInside(specificSpawnBlocks.toArray(Block[]::new)) .maxTrackingRange(this.trackRange) @@ -340,7 +341,7 @@ public class FabricEntityTypeBuilder { builder = builder.alwaysUpdateVelocity(this.forceTrackedVelocityUpdates); } - return builder.build(null); + return builder.build(key); } /** @@ -476,8 +477,8 @@ public class FabricEntityTypeBuilder { @Deprecated @Override - public EntityType build() { - final EntityType type = super.build(); + public EntityType build(RegistryKey> key) { + final EntityType type = super.build(key); if (this.defaultAttributeBuilder != null) { FabricDefaultAttributeRegistry.register(type, this.defaultAttributeBuilder.get()); @@ -617,8 +618,8 @@ public class FabricEntityTypeBuilder { } @Override - public EntityType build() { - EntityType type = super.build(); + public EntityType build(RegistryKey> key) { + EntityType type = super.build(key); if (this.spawnPredicate != null) { SpawnRestriction.register(type, this.spawnLocation, this.restrictionHeightmap, this.spawnPredicate); diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java deleted file mode 100644 index 419f56331..000000000 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsAccessor.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.mixin.object.builder; - -import java.util.function.Function; -import java.util.function.ToIntFunction; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import net.minecraft.block.AbstractBlock; -import net.minecraft.block.BlockState; -import net.minecraft.block.MapColor; -import net.minecraft.block.enums.NoteBlockInstrument; -import net.minecraft.block.piston.PistonBehavior; -import net.minecraft.entity.EntityType; -import net.minecraft.loot.LootTable; -import net.minecraft.registry.RegistryKey; -import net.minecraft.resource.featuretoggle.FeatureSet; -import net.minecraft.sound.BlockSoundGroup; - -@Mixin(AbstractBlock.Settings.class) -public interface AbstractBlockSettingsAccessor { - /* GETTERS */ - @Accessor - float getHardness(); - - @Accessor - float getResistance(); - - @Accessor - boolean getCollidable(); - - @Accessor - boolean getRandomTicks(); - - @Accessor("luminance") - ToIntFunction getLuminance(); - - @Accessor - Function getMapColorProvider(); - - @Accessor - BlockSoundGroup getSoundGroup(); - - @Accessor - float getSlipperiness(); - - @Accessor - float getVelocityMultiplier(); - - @Accessor - float getJumpVelocityMultiplier(); - - @Accessor - boolean getDynamicBounds(); - - @Accessor - boolean getOpaque(); - - @Accessor - boolean getIsAir(); - - @Accessor - boolean isToolRequired(); - - @Accessor - AbstractBlock.TypedContextPredicate> getAllowsSpawningPredicate(); - - @Accessor - AbstractBlock.ContextPredicate getSolidBlockPredicate(); - - @Accessor - AbstractBlock.ContextPredicate getSuffocationPredicate(); - - @Accessor - AbstractBlock.ContextPredicate getBlockVisionPredicate(); - - @Accessor - AbstractBlock.ContextPredicate getPostProcessPredicate(); - - @Accessor - AbstractBlock.ContextPredicate getEmissiveLightingPredicate(); - - @Accessor - AbstractBlock.Offsetter getOffsetter(); - - @Accessor - RegistryKey getLootTableKey(); - - @Accessor - boolean getBlockBreakParticles(); - - @Accessor - FeatureSet getRequiredFeatures(); - - @Accessor - boolean getBurnable(); - - @Accessor - boolean getLiquid(); - - @Accessor - boolean getForceNotSolid(); - - @Accessor - boolean getForceSolid(); - - @Accessor - PistonBehavior getPistonBehavior(); - - @Accessor - NoteBlockInstrument getInstrument(); - - @Accessor - boolean getReplaceable(); - - /* SETTERS */ - @Accessor - void setCollidable(boolean collidable); - - @Accessor - void setRandomTicks(boolean ticksRandomly); - - @Accessor - void setMapColorProvider(Function mapColorProvider); - - @Accessor - void setDynamicBounds(boolean dynamicBounds); - - @Accessor - void setOpaque(boolean opaque); - - @Accessor - void setIsAir(boolean isAir); - - @Accessor - void setLootTableKey(RegistryKey lootTableKey); - - @Accessor - void setToolRequired(boolean toolRequired); - - @Accessor - void setBlockBreakParticles(boolean blockBreakParticles); - - @Accessor - void setRequiredFeatures(FeatureSet requiredFeatures); - - @Accessor - void setOffsetter(AbstractBlock.Offsetter offsetter); - - @Accessor - void setBurnable(boolean burnable); - - @Accessor - void setLiquid(boolean liquid); - - @Accessor - void setForceNotSolid(boolean forceNotSolid); - - @Accessor - void setForceSolid(boolean forceSolid); - - @Accessor - void setReplaceable(boolean replaceable); -} diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/EntityTypeBuilderMixin.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/EntityTypeBuilderMixin.java index 286dfdde1..9c2265449 100644 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/EntityTypeBuilderMixin.java +++ b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/EntityTypeBuilderMixin.java @@ -34,6 +34,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.mob.MobEntity; +import net.minecraft.registry.RegistryKey; import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityType; import net.fabricmc.fabric.impl.object.builder.FabricEntityTypeImpl; @@ -41,7 +42,7 @@ import net.fabricmc.fabric.impl.object.builder.FabricEntityTypeImpl; @Mixin(EntityType.Builder.class) public abstract class EntityTypeBuilderMixin implements FabricEntityType.Builder, FabricEntityTypeImpl.Builder { @Shadow - public abstract EntityType build(String id); + public abstract EntityType build(RegistryKey> registryKey); @Unique private Boolean alwaysUpdateVelocity = null; @@ -57,13 +58,8 @@ public abstract class EntityTypeBuilderMixin implements Fabric return (EntityType.Builder) (Object) this; } - @Override - public EntityType build() { - return build(null); - } - @Inject(method = "build", at = @At("RETURN")) - private void applyChildBuilders(String id, CallbackInfoReturnable> cir) { + private void applyChildBuilders(RegistryKey> registryKey, CallbackInfoReturnable> cir) { if (!(cir.getReturnValue() instanceof FabricEntityTypeImpl entityType)) { throw new IllegalStateException(); } diff --git a/fabric-object-builder-api-v1/src/main/resources/fabric-object-builder-v1.mixins.json b/fabric-object-builder-api-v1/src/main/resources/fabric-object-builder-v1.mixins.json index 7664e138b..649f18201 100644 --- a/fabric-object-builder-api-v1/src/main/resources/fabric-object-builder-v1.mixins.json +++ b/fabric-object-builder-api-v1/src/main/resources/fabric-object-builder-v1.mixins.json @@ -4,7 +4,6 @@ "compatibilityLevel": "JAVA_21", "mixins": [ "AbstractBlockAccessor", - "AbstractBlockSettingsAccessor", "BlockEntityTypeMixin", "DefaultAttributeRegistryAccessor", "DefaultAttributeRegistryMixin", diff --git a/fabric-object-builder-api-v1/src/test/java/net/fabricmc/fabric/test/object/builder/FabricEntityTypeTest.java b/fabric-object-builder-api-v1/src/test/java/net/fabricmc/fabric/test/object/builder/FabricEntityTypeTest.java index fa8f464c7..d82d17f74 100644 --- a/fabric-object-builder-api-v1/src/test/java/net/fabricmc/fabric/test/object/builder/FabricEntityTypeTest.java +++ b/fabric-object-builder-api-v1/src/test/java/net/fabricmc/fabric/test/object/builder/FabricEntityTypeTest.java @@ -36,6 +36,9 @@ import net.minecraft.entity.attribute.DefaultAttributeRegistry; import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.passive.PigEntity; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.util.Identifier; import net.minecraft.world.Heightmap; import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityType; @@ -51,7 +54,7 @@ public class FabricEntityTypeTest { void buildEntityType() { EntityType type = EntityType.Builder.create(SpawnGroup.MISC) .alwaysUpdateVelocity(true) - .build(); + .build(RegistryKey.of(RegistryKeys.ENTITY_TYPE, Identifier.of("test", "test"))); assertNotNull(type); assertTrue(type.alwaysUpdateVelocity()); @@ -61,7 +64,7 @@ public class FabricEntityTypeTest { void buildLivingEntityType() { EntityType type = FabricEntityType.Builder.createLiving((t, w) -> null, SpawnGroup.MISC, living -> living .defaultAttributes(FabricEntityTypeTest::createAttributes) - ).build(); + ).build(RegistryKey.of(RegistryKeys.ENTITY_TYPE, Identifier.of("test", "test2"))); assertNotNull(type); assertNotNull(DefaultAttributeRegistry.get(type)); @@ -72,7 +75,7 @@ public class FabricEntityTypeTest { EntityType type = FabricEntityType.Builder.createMob((t, w) -> null, SpawnGroup.MISC, mob -> mob .spawnRestriction(SpawnLocationTypes.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, PigEntity::canMobSpawn) .defaultAttributes(FabricEntityTypeTest::createAttributes) - ).build(); + ).build(RegistryKey.of(RegistryKeys.ENTITY_TYPE, Identifier.of("test", "test3"))); assertNotNull(type); assertEquals(SpawnLocationTypes.ON_GROUND, SpawnRestriction.getLocation(type)); diff --git a/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/BlockEntityTypeBuilderTest.java b/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/BlockEntityTypeBuilderTest.java index 3c32af58e..43743e1ef 100644 --- a/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/BlockEntityTypeBuilderTest.java +++ b/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/BlockEntityTypeBuilderTest.java @@ -29,6 +29,7 @@ import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Identifier; @@ -40,19 +41,19 @@ import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; public class BlockEntityTypeBuilderTest implements ModInitializer { - private static final Identifier INITIAL_BETRAYAL_BLOCK_ID = ObjectBuilderTestConstants.id("initial_betrayal_block"); - static final Block INITIAL_BETRAYAL_BLOCK = new BetrayalBlock(MapColor.BLUE); + private static final RegistryKey INITIAL_BETRAYAL_BLOCK_ID = ObjectBuilderTestConstants.block("initial_betrayal_block"); + static final Block INITIAL_BETRAYAL_BLOCK = createBetrayalBlock(INITIAL_BETRAYAL_BLOCK_ID, MapColor.BLUE); - private static final Identifier ADDED_BETRAYAL_BLOCK_ID = ObjectBuilderTestConstants.id("added_betrayal_block"); - static final Block ADDED_BETRAYAL_BLOCK = new BetrayalBlock(MapColor.GREEN); + private static final RegistryKey ADDED_BETRAYAL_BLOCK_ID = ObjectBuilderTestConstants.block("added_betrayal_block"); + static final Block ADDED_BETRAYAL_BLOCK = createBetrayalBlock(ADDED_BETRAYAL_BLOCK_ID, MapColor.GREEN); - private static final Identifier FIRST_MULTI_BETRAYAL_BLOCK_ID = ObjectBuilderTestConstants.id("first_multi_betrayal_block"); - static final Block FIRST_MULTI_BETRAYAL_BLOCK = new BetrayalBlock(MapColor.RED); + private static final RegistryKey FIRST_MULTI_BETRAYAL_BLOCK_ID = ObjectBuilderTestConstants.block("first_multi_betrayal_block"); + static final Block FIRST_MULTI_BETRAYAL_BLOCK = createBetrayalBlock(FIRST_MULTI_BETRAYAL_BLOCK_ID, MapColor.RED); - private static final Identifier SECOND_MULTI_BETRAYAL_BLOCK_ID = ObjectBuilderTestConstants.id("second_multi_betrayal_block"); - static final Block SECOND_MULTI_BETRAYAL_BLOCK = new BetrayalBlock(MapColor.YELLOW); + private static final RegistryKey SECOND_MULTI_BETRAYAL_BLOCK_ID = ObjectBuilderTestConstants.block("second_multi_betrayal_block"); + static final Block SECOND_MULTI_BETRAYAL_BLOCK = createBetrayalBlock(SECOND_MULTI_BETRAYAL_BLOCK_ID, MapColor.YELLOW); - private static final Identifier BLOCK_ENTITY_TYPE_ID = ObjectBuilderTestConstants.id("betrayal_block"); + private static final RegistryKey BLOCK_ENTITY_TYPE_ID = ObjectBuilderTestConstants.block("betrayal_block"); public static final BlockEntityType BLOCK_ENTITY_TYPE = FabricBlockEntityTypeBuilder.create(BetrayalBlockEntity::new, INITIAL_BETRAYAL_BLOCK, ADDED_BETRAYAL_BLOCK, FIRST_MULTI_BETRAYAL_BLOCK, SECOND_MULTI_BETRAYAL_BLOCK).build(); @Override @@ -62,19 +63,23 @@ public class BlockEntityTypeBuilderTest implements ModInitializer { register(FIRST_MULTI_BETRAYAL_BLOCK_ID, FIRST_MULTI_BETRAYAL_BLOCK); register(SECOND_MULTI_BETRAYAL_BLOCK_ID, SECOND_MULTI_BETRAYAL_BLOCK); - Registry.register(Registries.BLOCK_ENTITY_TYPE, BLOCK_ENTITY_TYPE_ID, BLOCK_ENTITY_TYPE); + Registry.register(Registries.BLOCK_ENTITY_TYPE, BLOCK_ENTITY_TYPE_ID.getValue(), BLOCK_ENTITY_TYPE); } - private static void register(Identifier id, Block block) { + private static Block createBetrayalBlock(RegistryKey key, MapColor color) { + return new BetrayalBlock(AbstractBlock.Settings.copy(Blocks.STONE).mapColor(color).registryKey(key)); + } + + private static void register(RegistryKey id, Block block) { Registry.register(Registries.BLOCK, id, block); Item item = new BlockItem(block, new Item.Settings()); - Registry.register(Registries.ITEM, id, item); + Registry.register(Registries.ITEM, id.getValue(), item); } private static class BetrayalBlock extends Block implements BlockEntityProvider { - private BetrayalBlock(MapColor color) { - super(AbstractBlock.Settings.copy(Blocks.STONE).mapColor(color)); + private BetrayalBlock(AbstractBlock.Settings settings) { + super(settings); } @Override diff --git a/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/EntityTypeBuilderGenericsTest.java b/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/EntityTypeBuilderGenericsTest.java index 121a0aae7..bfb35cd22 100644 --- a/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/EntityTypeBuilderGenericsTest.java +++ b/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/EntityTypeBuilderGenericsTest.java @@ -25,31 +25,35 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.SpawnGroup; import net.minecraft.entity.mob.MobEntity; import net.minecraft.item.ItemStack; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.util.Arm; +import net.minecraft.util.Identifier; import net.minecraft.world.World; import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder; // This test is intentionally not an entrypoint to verify the generics of the entity type builder propagate properly final class EntityTypeBuilderGenericsTest { - static EntityType ENTITY_1 = FabricEntityTypeBuilder.create().build(); - static EntityType LIVING_ENTITY_1 = FabricEntityTypeBuilder.createLiving().build(); + static RegistryKey> DUMMY = RegistryKey.of(RegistryKeys.ENTITY_TYPE, Identifier.of("test", "dummy")); + static EntityType ENTITY_1 = FabricEntityTypeBuilder.create().build(DUMMY); + static EntityType LIVING_ENTITY_1 = FabricEntityTypeBuilder.createLiving().build(DUMMY); static EntityType TEST_ENTITY_1 = FabricEntityTypeBuilder.createLiving() .entityFactory(TestEntity::new) .spawnGroup(SpawnGroup.CREATURE) - .build(); + .build(DUMMY); static EntityType OLD_TEST = FabricEntityTypeBuilder.createLiving() .entityFactory(TestEntity::new) .spawnGroup(SpawnGroup.CREATURE) - .build(); + .build(DUMMY); static EntityType OLD_MOB = FabricEntityTypeBuilder.createMob() .disableSaving() .entityFactory(TestMob::new) - .build(); + .build(DUMMY); static EntityType MOB_TEST = FabricEntityTypeBuilder.createMob() .disableSaving() .entityFactory(TestMob::new) - .build(); + .build(DUMMY); private static class TestEntity extends LivingEntity { protected TestEntity(EntityType entityType, World world) { diff --git a/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/FabricBlockSettingsTest.java b/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/FabricBlockSettingsTest.java deleted file mode 100644 index 896133f7c..000000000 --- a/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/FabricBlockSettingsTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.test.object.builder; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -import org.objectweb.asm.Opcodes; - -import net.minecraft.block.AbstractBlock; - -import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; - -public class FabricBlockSettingsTest implements ModInitializer { - @Override - public void onInitialize() { - final List missingMethods = new ArrayList<>(); - - for (Method method : FabricBlockSettings.class.getMethods()) { - if ((method.getModifiers() & Opcodes.ACC_SYNTHETIC) != 0) { - // Ignore synthetic bridge methods - continue; - } - - if ((method.getModifiers() & Opcodes.ACC_STATIC) != 0) { - // Ignore static methods - continue; - } - - if (method.getReturnType() == AbstractBlock.Settings.class) { - missingMethods.add(method.getName()); - } - } - - if (missingMethods.isEmpty()) { - return; - } - - throw new IllegalStateException("Missing method overrides in FabricBlockSettings: " + String.join(", ", missingMethods)); - } -} diff --git a/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/ObjectBuilderTestConstants.java b/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/ObjectBuilderTestConstants.java index 4ab50d8f1..acd0e8837 100644 --- a/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/ObjectBuilderTestConstants.java +++ b/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/ObjectBuilderTestConstants.java @@ -19,6 +19,9 @@ package net.fabricmc.fabric.test.object.builder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import net.minecraft.block.Block; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.util.Identifier; public final class ObjectBuilderTestConstants { @@ -28,4 +31,8 @@ public final class ObjectBuilderTestConstants { public static Identifier id(String name) { return Identifier.of(MOD_ID, name); } + + public static RegistryKey block(String name) { + return RegistryKey.of(RegistryKeys.BLOCK, id(name)); + } } diff --git a/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/TealSignTest.java b/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/TealSignTest.java index 9fd58c691..8992f9f47 100644 --- a/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/TealSignTest.java +++ b/fabric-object-builder-api-v1/src/testmod/java/net/fabricmc/fabric/test/object/builder/TealSignTest.java @@ -17,6 +17,7 @@ package net.fabricmc.fabric.test.object.builder; import net.minecraft.block.AbstractBlock; +import net.minecraft.block.Block; import net.minecraft.block.BlockSetType; import net.minecraft.block.Blocks; import net.minecraft.block.HangingSignBlock; @@ -30,6 +31,7 @@ import net.minecraft.item.Item; import net.minecraft.item.SignItem; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; import net.minecraft.util.Identifier; import net.fabricmc.api.ModInitializer; @@ -40,10 +42,14 @@ public class TealSignTest implements ModInitializer { public static final Identifier TEAL_TYPE_ID = ObjectBuilderTestConstants.id("teal"); public static final BlockSetType TEAL_BLOCK_SET_TYPE = BlockSetTypeBuilder.copyOf(BlockSetType.OAK).build(TEAL_TYPE_ID); public static final WoodType TEAL_WOOD_TYPE = WoodTypeBuilder.copyOf(WoodType.OAK).build(TEAL_TYPE_ID, TEAL_BLOCK_SET_TYPE); - public static final SignBlock TEAL_SIGN = new SignBlock(TEAL_WOOD_TYPE, AbstractBlock.Settings.copy(Blocks.OAK_SIGN)); - public static final WallSignBlock TEAL_WALL_SIGN = new WallSignBlock(TEAL_WOOD_TYPE, AbstractBlock.Settings.copy(Blocks.OAK_SIGN)); - public static final HangingSignBlock TEAL_HANGING_SIGN = new HangingSignBlock(TEAL_WOOD_TYPE, AbstractBlock.Settings.copy(Blocks.OAK_HANGING_SIGN)); - public static final WallHangingSignBlock TEAL_WALL_HANGING_SIGN = new WallHangingSignBlock(TEAL_WOOD_TYPE, AbstractBlock.Settings.copy(Blocks.OAK_HANGING_SIGN)); + public static final RegistryKey TEAL_SIGN_KEY = ObjectBuilderTestConstants.block("teal_sign"); + public static final SignBlock TEAL_SIGN = new SignBlock(TEAL_WOOD_TYPE, AbstractBlock.Settings.copy(Blocks.OAK_SIGN).registryKey(TEAL_SIGN_KEY)); + public static final RegistryKey TEAL_WALL_SIGN_KEY = ObjectBuilderTestConstants.block("teal_wall_sign"); + public static final WallSignBlock TEAL_WALL_SIGN = new WallSignBlock(TEAL_WOOD_TYPE, AbstractBlock.Settings.copy(Blocks.OAK_SIGN).registryKey(TEAL_WALL_SIGN_KEY)); + public static final RegistryKey TEAL_HANGING_SIGN_KEY = ObjectBuilderTestConstants.block("teal_hanging_sign"); + public static final HangingSignBlock TEAL_HANGING_SIGN = new HangingSignBlock(TEAL_WOOD_TYPE, AbstractBlock.Settings.copy(Blocks.OAK_HANGING_SIGN).registryKey(TEAL_HANGING_SIGN_KEY)); + public static final RegistryKey TEAL_WALL_HANGING_SIGN_KEY = ObjectBuilderTestConstants.block("teal_wall_hanging_sign"); + public static final WallHangingSignBlock TEAL_WALL_HANGING_SIGN = new WallHangingSignBlock(TEAL_WOOD_TYPE, AbstractBlock.Settings.copy(Blocks.OAK_HANGING_SIGN).registryKey(TEAL_WALL_HANGING_SIGN_KEY)); public static final SignItem TEAL_SIGN_ITEM = new SignItem(new Item.Settings(), TEAL_SIGN, TEAL_WALL_SIGN); public static final HangingSignItem TEAL_HANGING_SIGN_ITEM = new HangingSignItem(TEAL_HANGING_SIGN, TEAL_WALL_HANGING_SIGN, new Item.Settings()); @@ -51,13 +57,13 @@ public class TealSignTest implements ModInitializer { public void onInitialize() { WoodType.register(TEAL_WOOD_TYPE); - Registry.register(Registries.BLOCK, ObjectBuilderTestConstants.id("teal_sign"), TEAL_SIGN); - Registry.register(Registries.BLOCK, ObjectBuilderTestConstants.id("teal_wall_sign"), TEAL_WALL_SIGN); - Registry.register(Registries.BLOCK, ObjectBuilderTestConstants.id("teal_hanging_sign"), TEAL_HANGING_SIGN); - Registry.register(Registries.BLOCK, ObjectBuilderTestConstants.id("teal_wall_hanging_sign"), TEAL_WALL_HANGING_SIGN); + Registry.register(Registries.BLOCK, TEAL_SIGN_KEY, TEAL_SIGN); + Registry.register(Registries.BLOCK, TEAL_WALL_SIGN_KEY, TEAL_WALL_SIGN); + Registry.register(Registries.BLOCK, TEAL_HANGING_SIGN_KEY, TEAL_HANGING_SIGN); + Registry.register(Registries.BLOCK, TEAL_WALL_HANGING_SIGN_KEY, TEAL_WALL_HANGING_SIGN); - Registry.register(Registries.ITEM, ObjectBuilderTestConstants.id("teal_sign"), TEAL_SIGN_ITEM); - Registry.register(Registries.ITEM, ObjectBuilderTestConstants.id("teal_hanging_sign"), TEAL_HANGING_SIGN_ITEM); + Registry.register(Registries.ITEM, TEAL_SIGN_KEY.getValue(), TEAL_SIGN_ITEM); + Registry.register(Registries.ITEM, TEAL_HANGING_SIGN_KEY.getValue(), TEAL_HANGING_SIGN_ITEM); BlockEntityType.SIGN.addSupportedBlock(TEAL_SIGN); BlockEntityType.HANGING_SIGN.addSupportedBlock(TEAL_HANGING_SIGN); diff --git a/fabric-object-builder-api-v1/src/testmod/resources/fabric.mod.json b/fabric-object-builder-api-v1/src/testmod/resources/fabric.mod.json index 83f2d8d7d..6a083dc8d 100644 --- a/fabric-object-builder-api-v1/src/testmod/resources/fabric.mod.json +++ b/fabric-object-builder-api-v1/src/testmod/resources/fabric.mod.json @@ -23,7 +23,6 @@ "entrypoints": { "main": [ "net.fabricmc.fabric.test.object.builder.BlockEntityTypeBuilderTest", - "net.fabricmc.fabric.test.object.builder.FabricBlockSettingsTest", "net.fabricmc.fabric.test.object.builder.VillagerTypeTest1", "net.fabricmc.fabric.test.object.builder.VillagerTypeTest2", "net.fabricmc.fabric.test.object.builder.TealSignTest", diff --git a/fabric-particles-v1/src/testmod/java/net/fabricmc/fabric/test/particle/ParticleTestSetup.java b/fabric-particles-v1/src/testmod/java/net/fabricmc/fabric/test/particle/ParticleTestSetup.java index 0d658fd65..aff5a71a2 100644 --- a/fabric-particles-v1/src/testmod/java/net/fabricmc/fabric/test/particle/ParticleTestSetup.java +++ b/fabric-particles-v1/src/testmod/java/net/fabricmc/fabric/test/particle/ParticleTestSetup.java @@ -26,6 +26,8 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.server.command.CommandManager; import net.minecraft.util.Identifier; @@ -34,17 +36,20 @@ import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; public final class ParticleTestSetup implements ModInitializer { // The dust particles of this block are always tinted (default). - public static final Block ALWAYS_TINTED = new ParticleTintTestBlock(AbstractBlock.Settings.create().breakInstantly(), 0xFF00FF); + public static final RegistryKey ALWAYS_TINTED_KEY = block("always_tinted"); + public static final Block ALWAYS_TINTED = new ParticleTintTestBlock(AbstractBlock.Settings.create().breakInstantly().registryKey(ALWAYS_TINTED_KEY), 0xFF00FF); // The dust particles of this block are only tinted when the block is broken over water. - public static final Block TINTED_OVER_WATER = new ParticleTintTestBlock(AbstractBlock.Settings.create().breakInstantly(), 0xFFFF00); + public static final RegistryKey TINTED_OVER_WATER_KEY = block("tinted_over_water"); + public static final Block TINTED_OVER_WATER = new ParticleTintTestBlock(AbstractBlock.Settings.create().breakInstantly().registryKey(TINTED_OVER_WATER_KEY), 0xFFFF00); // The dust particles of this block are never tinted. - public static final Block NEVER_TINTED = new ParticleTintTestBlock(AbstractBlock.Settings.create().breakInstantly(), 0x00FFFF); + public static final RegistryKey NEVER_TINTED_KEY = block("never_tinted"); + public static final Block NEVER_TINTED = new ParticleTintTestBlock(AbstractBlock.Settings.create().breakInstantly().registryKey(NEVER_TINTED_KEY), 0x00FFFF); @Override public void onInitialize() { - registerBlock("always_tinted", ALWAYS_TINTED); - registerBlock("tinted_over_water", TINTED_OVER_WATER); - registerBlock("never_tinted", NEVER_TINTED); + registerBlock(ALWAYS_TINTED_KEY, ALWAYS_TINTED); + registerBlock(TINTED_OVER_WATER_KEY, TINTED_OVER_WATER); + registerBlock(NEVER_TINTED_KEY, NEVER_TINTED); CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> { dispatcher.register(CommandManager.literal("addparticletestblocks").executes(context -> { @@ -57,9 +62,12 @@ public final class ParticleTestSetup implements ModInitializer { }); } - private static void registerBlock(String path, Block block) { - Identifier id = Identifier.of("fabric-particles-v1-testmod", path); - Registry.register(Registries.BLOCK, id, block); - Registry.register(Registries.ITEM, id, new BlockItem(block, new Item.Settings())); + private static RegistryKey block(String path) { + return RegistryKey.of(RegistryKeys.BLOCK, Identifier.of("fabric-particles-v1-testmod", path)); + } + + private static void registerBlock(RegistryKey key, Block block) { + Registry.register(Registries.BLOCK, key, block); + Registry.register(Registries.ITEM, key.getValue(), new BlockItem(block, new Item.Settings())); } } diff --git a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/FabricRegistryInit.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/FabricRegistryInit.java index 6d2fe03fa..b8be829a3 100644 --- a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/FabricRegistryInit.java +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/FabricRegistryInit.java @@ -209,7 +209,7 @@ public class FabricRegistryInit implements ModInitializer { .addAttribute(RegistryAttribute.SYNCED); // Synced via PacketCodecs.registry - RegistryAttributeHolder.get(Registries.field_53967) + RegistryAttributeHolder.get(Registries.CONSUME_EFFECT_TYPE) .addAttribute(RegistryAttribute.SYNCED); } } diff --git a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/trackers/vanilla/BlockInitTracker.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/trackers/vanilla/BlockInitTracker.java index ad49d98bf..b54796a10 100644 --- a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/trackers/vanilla/BlockInitTracker.java +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/trackers/vanilla/BlockInitTracker.java @@ -18,36 +18,13 @@ package net.fabricmc.fabric.impl.registry.sync.trackers.vanilla; import java.util.List; -import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; -import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback; import net.fabricmc.fabric.mixin.registry.sync.DebugChunkGeneratorAccessor; -public final class BlockInitTracker implements RegistryEntryAddedCallback { - private final Registry registry; - - private BlockInitTracker(Registry registry) { - this.registry = registry; - } - - public static void register(Registry registry) { - BlockInitTracker tracker = new BlockInitTracker(registry); - RegistryEntryAddedCallback.event(registry).register(tracker); - } - - @Override - public void onEntryAdded(int rawId, Identifier id, Block object) { - // if false, getLootTableKey() will generate an invalid loot table key - assert id.equals(registry.getId(object)); - - object.getLootTableKey(); - } - +public final class BlockInitTracker { public static void postFreeze() { final List blockStateList = Registries.BLOCK.stream() .flatMap((block) -> block.getStateManager().getStates().stream()) diff --git a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/BootstrapMixin.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/BootstrapMixin.java index b7078ff7f..b75502afe 100644 --- a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/BootstrapMixin.java +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/BootstrapMixin.java @@ -32,7 +32,6 @@ import net.minecraft.registry.Registries; import net.fabricmc.fabric.impl.registry.sync.RegistrySyncManager; import net.fabricmc.fabric.impl.registry.sync.trackers.StateIdTracker; -import net.fabricmc.fabric.impl.registry.sync.trackers.vanilla.BlockInitTracker; import net.fabricmc.fabric.impl.registry.sync.trackers.vanilla.BlockItemTracker; @Mixin(Bootstrap.class) @@ -54,9 +53,6 @@ public class BootstrapMixin { // map tracking BlockItemTracker.register(Registries.ITEM); - // block initialization, like Blocks - BlockInitTracker.register(Registries.BLOCK); - RegistrySyncManager.bootstrapRegistries(); } diff --git a/fabric-registry-sync-v0/src/testmod/java/net/fabricmc/fabric/test/registry/sync/CustomDynamicRegistryTest.java b/fabric-registry-sync-v0/src/testmod/java/net/fabricmc/fabric/test/registry/sync/CustomDynamicRegistryTest.java index ae20a4727..7c6edc6cc 100644 --- a/fabric-registry-sync-v0/src/testmod/java/net/fabricmc/fabric/test/registry/sync/CustomDynamicRegistryTest.java +++ b/fabric-registry-sync-v0/src/testmod/java/net/fabricmc/fabric/test/registry/sync/CustomDynamicRegistryTest.java @@ -67,9 +67,8 @@ public final class CustomDynamicRegistryTest implements ModInitializer { CommonLifecycleEvents.TAGS_LOADED.register((registries, client) -> { // Check that the tag has applied - RegistryEntry.Reference entry = registries.get(TEST_SYNCED_1_DYNAMIC_REGISTRY_KEY) - .getEntry(SYNCED_ENTRY_KEY) - .orElseThrow(); + RegistryEntry.Reference entry = registries.getOrThrow(TEST_SYNCED_1_DYNAMIC_REGISTRY_KEY) + .getOrThrow(SYNCED_ENTRY_KEY); if (!entry.isIn(TEST_DYNAMIC_OBJECT_TAG)) { LOGGER.error("Required dynamic registry entry is not in the expected tag! client: " + client); diff --git a/fabric-registry-sync-v0/src/testmod/java/net/fabricmc/fabric/test/registry/sync/RegistrySyncTest.java b/fabric-registry-sync-v0/src/testmod/java/net/fabricmc/fabric/test/registry/sync/RegistrySyncTest.java index 3ac540bcc..71222bb00 100644 --- a/fabric-registry-sync-v0/src/testmod/java/net/fabricmc/fabric/test/registry/sync/RegistrySyncTest.java +++ b/fabric-registry-sync-v0/src/testmod/java/net/fabricmc/fabric/test/registry/sync/RegistrySyncTest.java @@ -154,12 +154,13 @@ public class RegistrySyncTest implements ModInitializer { private static void registerBlocks(String namespace, int amount, int startingId) { for (int i = 0; i < amount; i++) { - Block block = new Block(AbstractBlock.Settings.create()); - Registry.register(Registries.BLOCK, Identifier.of(namespace, "block_" + (i + startingId)), block); + Identifier id = Identifier.of(namespace, "block_" + (i + startingId)); + Block block = new Block(AbstractBlock.Settings.create().registryKey(RegistryKey.of(RegistryKeys.BLOCK, id))); + Registry.register(Registries.BLOCK, id, block); if (REGISTER_ITEMS) { BlockItem blockItem = new BlockItem(block, new Item.Settings()); - Registry.register(Registries.ITEM, Identifier.of(namespace, "block_" + (i + startingId)), blockItem); + Registry.register(Registries.ITEM, id, blockItem); } } } diff --git a/fabric-registry-sync-v0/src/testmodClient/java/net/fabricmc/fabric/test/registry/sync/client/DynamicRegistryClientTest.java b/fabric-registry-sync-v0/src/testmodClient/java/net/fabricmc/fabric/test/registry/sync/client/DynamicRegistryClientTest.java index aaf209dde..d1f4180e7 100644 --- a/fabric-registry-sync-v0/src/testmodClient/java/net/fabricmc/fabric/test/registry/sync/client/DynamicRegistryClientTest.java +++ b/fabric-registry-sync-v0/src/testmodClient/java/net/fabricmc/fabric/test/registry/sync/client/DynamicRegistryClientTest.java @@ -43,13 +43,13 @@ public final class DynamicRegistryClientTest implements ClientModInitializer { LOGGER.info("Starting dynamic registry sync tests..."); TestDynamicObject synced1 = handler.getRegistryManager() - .get(TEST_SYNCED_1_DYNAMIC_REGISTRY_KEY) + .getOrThrow(TEST_SYNCED_1_DYNAMIC_REGISTRY_KEY) .get(SYNCED_ID); TestDynamicObject synced2 = handler.getRegistryManager() - .get(TEST_SYNCED_2_DYNAMIC_REGISTRY_KEY) + .getOrThrow(TEST_SYNCED_2_DYNAMIC_REGISTRY_KEY) .get(SYNCED_ID); TestNestedDynamicObject simpleNested = handler.getRegistryManager() - .get(TEST_NESTED_DYNAMIC_REGISTRY_KEY) + .getOrThrow(TEST_NESTED_DYNAMIC_REGISTRY_KEY) .get(SYNCED_ID); LOGGER.info("Synced - simple: {}", synced1); diff --git a/fabric-renderer-api-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/Registration.java b/fabric-renderer-api-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/Registration.java index dc9546ac9..e1473252e 100644 --- a/fabric-renderer-api-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/Registration.java +++ b/fabric-renderer-api-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/Registration.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.test.renderer; +import java.util.function.Function; + import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; import net.minecraft.block.Blocks; @@ -24,16 +26,19 @@ import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.util.Identifier; import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; public final class Registration { - public static final FrameBlock FRAME_BLOCK = register("frame", new FrameBlock(AbstractBlock.Settings.copy(Blocks.IRON_BLOCK).nonOpaque())); - public static final FrameBlock FRAME_MULTIPART_BLOCK = register("frame_multipart", new FrameBlock(AbstractBlock.Settings.copy(Blocks.IRON_BLOCK).nonOpaque())); - public static final FrameBlock FRAME_VARIANT_BLOCK = register("frame_variant", new FrameBlock(AbstractBlock.Settings.copy(Blocks.IRON_BLOCK).nonOpaque())); - public static final Block PILLAR_BLOCK = register("pillar", new Block(AbstractBlock.Settings.create())); - public static final Block OCTAGONAL_COLUMN_BLOCK = register("octagonal_column", new OctagonalColumnBlock(AbstractBlock.Settings.create().nonOpaque().strength(1.8F))); - public static final Block RIVERSTONE_BLOCK = register("riverstone", new Block(AbstractBlock.Settings.copy(Blocks.STONE))); + public static final FrameBlock FRAME_BLOCK = register("frame", FrameBlock::new, AbstractBlock.Settings.copy(Blocks.IRON_BLOCK).nonOpaque()); + public static final FrameBlock FRAME_MULTIPART_BLOCK = register("frame_multipart", FrameBlock::new, AbstractBlock.Settings.copy(Blocks.IRON_BLOCK).nonOpaque()); + public static final FrameBlock FRAME_VARIANT_BLOCK = register("frame_variant", FrameBlock::new, AbstractBlock.Settings.copy(Blocks.IRON_BLOCK).nonOpaque()); + public static final Block PILLAR_BLOCK = register("pillar", Block::new, AbstractBlock.Settings.create()); + public static final Block OCTAGONAL_COLUMN_BLOCK = register("octagonal_column", OctagonalColumnBlock::new, AbstractBlock.Settings.create().nonOpaque().strength(1.8F)); + public static final Block RIVERSTONE_BLOCK = register("riverstone", Block::new, AbstractBlock.Settings.copy(Blocks.STONE)); public static final FrameBlock[] FRAME_BLOCKS = new FrameBlock[] { FRAME_BLOCK, @@ -50,8 +55,10 @@ public final class Registration { public static final BlockEntityType FRAME_BLOCK_ENTITY_TYPE = register("frame", FabricBlockEntityTypeBuilder.create(FrameBlockEntity::new, FRAME_BLOCKS).build()); - private static T register(String path, T block) { - return Registry.register(Registries.BLOCK, RendererTest.id(path), block); + // see also Blocks#register, which is functionally the same + private static T register(String path, Function constructor, AbstractBlock.Settings settings) { + Identifier id = RendererTest.id(path); + return Registry.register(Registries.BLOCK, id, constructor.apply(settings.registryKey(RegistryKey.of(RegistryKeys.BLOCK, id)))); } private static T register(String path, T item) { diff --git a/fabric-rendering-fluids-v1/src/testmod/java/net/fabricmc/fabric/test/client/rendering/fluid/TestFluids.java b/fabric-rendering-fluids-v1/src/testmod/java/net/fabricmc/fabric/test/client/rendering/fluid/TestFluids.java index c8da4732f..2166b2ba7 100644 --- a/fabric-rendering-fluids-v1/src/testmod/java/net/fabricmc/fabric/test/client/rendering/fluid/TestFluids.java +++ b/fabric-rendering-fluids-v1/src/testmod/java/net/fabricmc/fabric/test/client/rendering/fluid/TestFluids.java @@ -17,33 +17,50 @@ package net.fabricmc.fabric.test.client.rendering.fluid; import net.minecraft.block.AbstractBlock; +import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.block.FluidBlock; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.util.Identifier; public class TestFluids { - public static final NoOverlayFluid NO_OVERLAY = Registry.register(Registries.FLUID, "fabric-rendering-fluids-v1-testmod:no_overlay", new NoOverlayFluid.Still()); - public static final NoOverlayFluid NO_OVERLAY_FLOWING = Registry.register(Registries.FLUID, "fabric-rendering-fluids-v1-testmod:no_overlay_flowing", new NoOverlayFluid.Flowing()); + public static final String MOD_ID = "fabric-rendering-fluids-v1-testmod"; + public static final RegistryKey NO_OVERLAY_KEY = block("no_overlay"); + public static final NoOverlayFluid NO_OVERLAY = Registry.register(Registries.FLUID, NO_OVERLAY_KEY.getValue(), new NoOverlayFluid.Still()); + public static final NoOverlayFluid NO_OVERLAY_FLOWING = Registry.register(Registries.FLUID, id("no_overlay_flowing"), new NoOverlayFluid.Flowing()); - public static final FluidBlock NO_OVERLAY_BLOCK = Registry.register(Registries.BLOCK, "fabric-rendering-fluids-v1-testmod:no_overlay", new FluidBlock(NO_OVERLAY, AbstractBlock.Settings.copy(Blocks.WATER)) { + public static final FluidBlock NO_OVERLAY_BLOCK = Registry.register(Registries.BLOCK, NO_OVERLAY_KEY, new FluidBlock(NO_OVERLAY, AbstractBlock.Settings.copy(Blocks.WATER).registryKey(NO_OVERLAY_KEY)) { }); - public static final OverlayFluid OVERLAY = Registry.register(Registries.FLUID, "fabric-rendering-fluids-v1-testmod:overlay", new OverlayFluid.Still()); - public static final OverlayFluid OVERLAY_FLOWING = Registry.register(Registries.FLUID, "fabric-rendering-fluids-v1-testmod:overlay_flowing", new OverlayFluid.Flowing()); + public static final RegistryKey OVERLAY_KEY = block("overlay"); + public static final OverlayFluid OVERLAY = Registry.register(Registries.FLUID, OVERLAY_KEY.getValue(), new OverlayFluid.Still()); + public static final OverlayFluid OVERLAY_FLOWING = Registry.register(Registries.FLUID, id("overlay_flowing"), new OverlayFluid.Flowing()); - public static final FluidBlock OVERLAY_BLOCK = Registry.register(Registries.BLOCK, "fabric-rendering-fluids-v1-testmod:overlay", new FluidBlock(OVERLAY, AbstractBlock.Settings.copy(Blocks.WATER)) { + public static final FluidBlock OVERLAY_BLOCK = Registry.register(Registries.BLOCK, OVERLAY_KEY, new FluidBlock(OVERLAY, AbstractBlock.Settings.copy(Blocks.WATER).registryKey(OVERLAY_KEY)) { }); - public static final UnregisteredFluid UNREGISTERED = Registry.register(Registries.FLUID, "fabric-rendering-fluids-v1-testmod:unregistered", new UnregisteredFluid.Still()); - public static final UnregisteredFluid UNREGISTERED_FLOWING = Registry.register(Registries.FLUID, "fabric-rendering-fluids-v1-testmod:unregistered_flowing", new UnregisteredFluid.Flowing()); + public static final RegistryKey UNREGISTERED_KEY = block("unregistered"); + public static final UnregisteredFluid UNREGISTERED = Registry.register(Registries.FLUID, UNREGISTERED_KEY.getValue(), new UnregisteredFluid.Still()); + public static final UnregisteredFluid UNREGISTERED_FLOWING = Registry.register(Registries.FLUID, id("unregistered_flowing"), new UnregisteredFluid.Flowing()); - public static final FluidBlock UNREGISTERED_BLOCK = Registry.register(Registries.BLOCK, "fabric-rendering-fluids-v1-testmod:unregistered", new FluidBlock(UNREGISTERED, AbstractBlock.Settings.copy(Blocks.WATER)) { + public static final FluidBlock UNREGISTERED_BLOCK = Registry.register(Registries.BLOCK, UNREGISTERED_KEY, new FluidBlock(UNREGISTERED, AbstractBlock.Settings.copy(Blocks.WATER).registryKey(UNREGISTERED_KEY)) { }); - public static final CustomFluid CUSTOM = Registry.register(Registries.FLUID, "fabric-rendering-fluids-v1-testmod:custom", new CustomFluid.Still()); - public static final CustomFluid CUSTOM_FLOWING = Registry.register(Registries.FLUID, "fabric-rendering-fluids-v1-testmod:custom_flowing", new CustomFluid.Flowing()); + public static final RegistryKey CUSTOM_KEY = block("custom"); + public static final CustomFluid CUSTOM = Registry.register(Registries.FLUID, CUSTOM_KEY.getValue(), new CustomFluid.Still()); + public static final CustomFluid CUSTOM_FLOWING = Registry.register(Registries.FLUID, id("custom_flowing"), new CustomFluid.Flowing()); - public static final FluidBlock CUSTOM_BLOCK = Registry.register(Registries.BLOCK, "fabric-rendering-fluids-v1-testmod:custom", new FluidBlock(CUSTOM, AbstractBlock.Settings.copy(Blocks.WATER)) { + public static final FluidBlock CUSTOM_BLOCK = Registry.register(Registries.BLOCK, CUSTOM_KEY, new FluidBlock(CUSTOM, AbstractBlock.Settings.copy(Blocks.WATER).registryKey(CUSTOM_KEY)) { }); + + private static Identifier id(String path) { + return Identifier.of(MOD_ID, path); + } + + private static RegistryKey block(String path) { + return RegistryKey.of(RegistryKeys.BLOCK, id(path)); + } } diff --git a/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/api/client/rendering/v1/WorldRenderEvents.java b/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/api/client/rendering/v1/WorldRenderEvents.java index 1ddc934f7..f782d895e 100644 --- a/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/api/client/rendering/v1/WorldRenderEvents.java +++ b/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/api/client/rendering/v1/WorldRenderEvents.java @@ -171,7 +171,7 @@ public final class WorldRenderEvents { * outline render for all blocks because all event subscribers will * always render - only the default outline render can be cancelled. That should * be accomplished by mixin to the block outline render routine itself, typically - * by targeting {@link WorldRenderer#drawShapeOutline}. + * by targeting {@link net.minecraft.client.render.VertexRendering#drawOutline}. */ public static final Event BLOCK_OUTLINE = EventFactory.createArrayBacked(BlockOutline.class, (worldRenderContext, blockOutlineContext) -> true, callbacks -> (worldRenderContext, blockOutlineContext) -> { boolean shouldRender = true; diff --git a/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/ArmorFeatureRendererMixin.java b/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/ArmorFeatureRendererMixin.java index 33087a700..a5b48dbd8 100644 --- a/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/ArmorFeatureRendererMixin.java +++ b/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/ArmorFeatureRendererMixin.java @@ -50,7 +50,7 @@ public abstract class ArmorFeatureRendererMixin KEY = RegistryKey.of(RegistryKeys.BLOCK, Identifier.of("fabric-rendering-v1-testmod", "custom_color_block")); + public static final Block CUSTOM_COLOR_BLOCK = new Block(AbstractBlock.Settings.create().registryKey(KEY)); public static final Item CUSTOM_COLOR_BLOCK_ITEM = new BlockItem(CUSTOM_COLOR_BLOCK, new Item.Settings()); @Override public void onInitialize() { - Registry.register(Registries.BLOCK, Identifier.of("fabric-rendering-v1-testmod", "custom_color_block"), CUSTOM_COLOR_BLOCK); - Registry.register(Registries.ITEM, Identifier.of("fabric-rendering-v1-testmod", "custom_color_block"), CUSTOM_COLOR_BLOCK_ITEM); + Registry.register(Registries.BLOCK, KEY, CUSTOM_COLOR_BLOCK); + Registry.register(Registries.ITEM, KEY.getValue(), CUSTOM_COLOR_BLOCK_ITEM); } } diff --git a/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/ArmorRenderingTests.java b/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/ArmorRenderingTests.java index ea7671003..6a2d6228c 100644 --- a/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/ArmorRenderingTests.java +++ b/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/ArmorRenderingTests.java @@ -39,7 +39,7 @@ public class ArmorRenderingTests implements ClientModInitializer { armorModel = new BipedEntityModel<>(MinecraftClient.getInstance().getEntityModelLoader().getModelPart(EntityModelLayers.PLAYER_OUTER_ARMOR)); } - model.copyBipedStateTo(armorModel); + armorModel.setAngles(renderState); armorModel.setVisible(false); armorModel.body.visible = slot == EquipmentSlot.CHEST; armorModel.leftArm.visible = slot == EquipmentSlot.CHEST; diff --git a/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/DimensionalRenderingTest.java b/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/DimensionalRenderingTest.java index e3a0dc387..5c58532df 100644 --- a/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/DimensionalRenderingTest.java +++ b/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/DimensionalRenderingTest.java @@ -19,7 +19,7 @@ package net.fabricmc.fabric.test.rendering.client; import com.mojang.blaze3d.systems.RenderSystem; import org.joml.Matrix4f; -import net.minecraft.class_10142; +import net.minecraft.client.gl.ShaderProgramKeys; import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.BufferRenderer; import net.minecraft.client.render.DimensionEffects; @@ -41,7 +41,7 @@ public class DimensionalRenderingTest implements ClientModInitializer { RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.depthMask(false); - RenderSystem.setShader(class_10142.POSITION_TEX_COLOR); + RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR); RenderSystem.setShaderTexture(0, END_SKY); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); diff --git a/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/WorldRenderEventsTests.java b/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/WorldRenderEventsTests.java index c5f90808a..9e28fa3ac 100644 --- a/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/WorldRenderEventsTests.java +++ b/fabric-rendering-v1/src/testmodClient/java/net/fabricmc/fabric/test/rendering/client/WorldRenderEventsTests.java @@ -19,15 +19,15 @@ package net.fabricmc.fabric.test.rendering.client; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.block.Blocks; -import net.minecraft.class_10142; -import net.minecraft.class_9974; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gl.ShaderProgramKeys; import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.BufferRenderer; import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.Tessellator; import net.minecraft.client.render.VertexFormat; import net.minecraft.client.render.VertexFormats; +import net.minecraft.client.render.VertexRendering; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -70,12 +70,12 @@ public class WorldRenderEventsTests implements ClientModInitializer { matrices.push(); matrices.translate(-camera.x, -camera.y, -camera.z); - RenderSystem.setShader(class_10142.POSITION_COLOR); + RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR); RenderSystem.setShaderColor(1f, 1f, 1f, 1f); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); - class_9974.method_62300(matrices, buffer, 0, 100, 0, 1, 101, 1, 0, 1, 0, 0.5f); + VertexRendering.drawBox(matrices, buffer, 0, 100, 0, 1, 101, 1, 0, 1, 0, 0.5f); BufferRenderer.drawWithGlobalProgram(buffer.end()); matrices.pop(); diff --git a/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/impl/resource/conditions/ResourceConditionsImpl.java b/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/impl/resource/conditions/ResourceConditionsImpl.java index 2e1a090dc..de2219c4a 100644 --- a/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/impl/resource/conditions/ResourceConditionsImpl.java +++ b/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/impl/resource/conditions/ResourceConditionsImpl.java @@ -108,8 +108,7 @@ public final class ResourceConditionsImpl implements ModInitializer { } /** - * Stores the tags deserialized by {@link TagManagerLoader} before they are bound, to use them in the tags_populated conditions. - * The tags are set at the end of the "apply" phase in {@link TagManagerLoader}, and cleared in {@link net.minecraft.server.DataPackContents#refresh}. + * Stores the tags deserialized before they are bound, to use them in the tags_populated conditions. * If the resource reload fails, the thread local is not cleared and: * - the map will remain in memory until the next reload; * - any call to {@link #tagsPopulated} will check the tags from the failed reload instead of failing directly. diff --git a/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/mixin/resource/conditions/RecipeManagerMixin.java b/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/mixin/resource/conditions/RecipeManagerMixin.java index 3ce8bd252..af5807c34 100644 --- a/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/mixin/resource/conditions/RecipeManagerMixin.java +++ b/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/mixin/resource/conditions/RecipeManagerMixin.java @@ -29,10 +29,10 @@ import net.minecraft.registry.RegistryWrapper; public class RecipeManagerMixin extends SinglePreparationResourceReloaderMixin { @Shadow @Final - private RegistryWrapper.WrapperLookup registryLookup; + private RegistryWrapper.WrapperLookup registries; @Override protected @Nullable RegistryOps.RegistryInfoGetter fabric_getRegistryLookup() { - return new RegistryOps.CachedRegistryInfoGetter(registryLookup); + return new RegistryOps.CachedRegistryInfoGetter(registries); } } diff --git a/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/mixin/resource/conditions/ServerAdvancementLoaderMixin.java b/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/mixin/resource/conditions/ServerAdvancementLoaderMixin.java index c0b75f83a..4f8574123 100644 --- a/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/mixin/resource/conditions/ServerAdvancementLoaderMixin.java +++ b/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/mixin/resource/conditions/ServerAdvancementLoaderMixin.java @@ -29,10 +29,10 @@ import net.minecraft.server.ServerAdvancementLoader; public class ServerAdvancementLoaderMixin extends SinglePreparationResourceReloaderMixin { @Shadow @Final - private RegistryWrapper.WrapperLookup registryLookup; + private RegistryWrapper.WrapperLookup registries; @Override protected @Nullable RegistryOps.RegistryInfoGetter fabric_getRegistryLookup() { - return new RegistryOps.CachedRegistryInfoGetter(this.registryLookup); + return new RegistryOps.CachedRegistryInfoGetter(this.registries); } } diff --git a/fabric-resource-conditions-api-v1/src/testmod/java/net/fabricmc/fabric/test/resource/conditions/ConditionalResourcesTest.java b/fabric-resource-conditions-api-v1/src/testmod/java/net/fabricmc/fabric/test/resource/conditions/ConditionalResourcesTest.java index 9ffcbe2cb..5acd63330 100644 --- a/fabric-resource-conditions-api-v1/src/testmod/java/net/fabricmc/fabric/test/resource/conditions/ConditionalResourcesTest.java +++ b/fabric-resource-conditions-api-v1/src/testmod/java/net/fabricmc/fabric/test/resource/conditions/ConditionalResourcesTest.java @@ -82,11 +82,11 @@ public class ConditionalResourcesTest { RegistryEntryLookup.RegistryLookup registries = context.getWorld().getServer().getReloadableRegistries().createRegistryLookup(); - if (registries.getOptionalEntry(RegistryKeys.PREDICATE, RegistryKey.of(RegistryKeys.PREDICATE, id("loaded"))).isEmpty()) { + if (registries.getOptionalEntry(RegistryKey.of(RegistryKeys.PREDICATE, id("loaded"))).isEmpty()) { throw new AssertionError("loaded predicate should have been loaded."); } - if (registries.getOptionalEntry(RegistryKeys.PREDICATE, RegistryKey.of(RegistryKeys.PREDICATE, id("not_loaded"))).isPresent()) { + if (registries.getOptionalEntry(RegistryKey.of(RegistryKeys.PREDICATE, id("not_loaded"))).isPresent()) { throw new AssertionError("not_loaded predicate should not have been loaded."); } @@ -110,7 +110,7 @@ public class ConditionalResourcesTest { @GameTest(templateName = FabricGameTest.EMPTY_STRUCTURE) public void conditionalDynamicRegistry(TestContext context) { - Registry registry = context.getWorld().getRegistryManager().get(RegistryKeys.BANNER_PATTERN); + Registry registry = context.getWorld().getRegistryManager().getOrThrow(RegistryKeys.BANNER_PATTERN); if (registry.get(id("loaded")) == null) { throw new AssertionError("loaded banner pattern should have been loaded."); @@ -127,11 +127,11 @@ public class ConditionalResourcesTest { public void conditionalOverlays(TestContext context) { RegistryEntryLookup.RegistryLookup registries = context.getWorld().getServer().getReloadableRegistries().createRegistryLookup(); - if (registries.getOptionalEntry(RegistryKeys.PREDICATE, RegistryKey.of(RegistryKeys.PREDICATE, id("do_overlay"))).isEmpty()) { + if (registries.getOptionalEntry(RegistryKey.of(RegistryKeys.PREDICATE, id("do_overlay"))).isEmpty()) { throw new AssertionError("do_overlay predicate should have been overlayed."); } - if (registries.getOptionalEntry(RegistryKeys.PREDICATE, RegistryKey.of(RegistryKeys.PREDICATE, id("dont_overlay"))).isPresent()) { + if (registries.getOptionalEntry(RegistryKey.of(RegistryKeys.PREDICATE, id("dont_overlay"))).isPresent()) { throw new AssertionError("dont_overlay predicate should not have been overlayed."); } diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ResourceManagerHelperImpl.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ResourceManagerHelperImpl.java index afd382e1d..b3fdbf043 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ResourceManagerHelperImpl.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ResourceManagerHelperImpl.java @@ -242,7 +242,7 @@ public class ResourceManagerHelperImpl implements ResourceManagerHelper { for (ResourceReloader resourceReloader : listeners) { if (resourceReloader instanceof RecipeManager recipeManager) { - return recipeManager.registryLookup; + return recipeManager.registries; } } diff --git a/fabric-resource-loader-v0/src/main/resources/fabric-resource-loader-v0.accesswidener b/fabric-resource-loader-v0/src/main/resources/fabric-resource-loader-v0.accesswidener index 8c0642a75..6c9686b87 100644 --- a/fabric-resource-loader-v0/src/main/resources/fabric-resource-loader-v0.accesswidener +++ b/fabric-resource-loader-v0/src/main/resources/fabric-resource-loader-v0.accesswidener @@ -4,4 +4,4 @@ accessible method net/minecraft/resource/NamespaceResourceManager getMetadataPat accessible method net/minecraft/resource/NamespaceResourceManager loadMetadata (Lnet/minecraft/resource/InputSupplier;)Lnet/minecraft/resource/metadata/ResourceMetadata; accessible field net/minecraft/resource/FileResourcePackProvider source Lnet/minecraft/resource/ResourcePackSource; accessible field net/minecraft/resource/ResourcePackManager providers Ljava/util/Set; -accessible field net/minecraft/recipe/RecipeManager registryLookup Lnet/minecraft/registry/RegistryWrapper$WrapperLookup; +accessible field net/minecraft/recipe/RecipeManager registries Lnet/minecraft/registry/RegistryWrapper$WrapperLookup; diff --git a/fabric-resource-loader-v0/src/testmod/java/net/fabricmc/fabric/test/resource/loader/ResourceReloadListenerTestMod.java b/fabric-resource-loader-v0/src/testmod/java/net/fabricmc/fabric/test/resource/loader/ResourceReloadListenerTestMod.java index bbbfc8a33..39493f705 100644 --- a/fabric-resource-loader-v0/src/testmod/java/net/fabricmc/fabric/test/resource/loader/ResourceReloadListenerTestMod.java +++ b/fabric-resource-loader-v0/src/testmod/java/net/fabricmc/fabric/test/resource/loader/ResourceReloadListenerTestMod.java @@ -135,7 +135,7 @@ public class ResourceReloadListenerTestMod implements ModInitializer { @Override public void reload(ResourceManager manager) { Objects.requireNonNull(wrapperLookup); - wrapperLookup.getWrapperOrThrow(RegistryKeys.ENCHANTMENT).getOrThrow(Enchantments.FORTUNE); + wrapperLookup.getOrThrow(RegistryKeys.ENCHANTMENT).getOrThrow(Enchantments.FORTUNE); } } } diff --git a/fabric-resource-loader-v0/src/testmod/java/net/fabricmc/fabric/test/resource/loader/VanillaBuiltinResourcePackInjectionTestMod.java b/fabric-resource-loader-v0/src/testmod/java/net/fabricmc/fabric/test/resource/loader/VanillaBuiltinResourcePackInjectionTestMod.java index ac9bb8ce0..1bedddd36 100644 --- a/fabric-resource-loader-v0/src/testmod/java/net/fabricmc/fabric/test/resource/loader/VanillaBuiltinResourcePackInjectionTestMod.java +++ b/fabric-resource-loader-v0/src/testmod/java/net/fabricmc/fabric/test/resource/loader/VanillaBuiltinResourcePackInjectionTestMod.java @@ -23,20 +23,21 @@ import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.util.Identifier; import net.fabricmc.api.ModInitializer; public class VanillaBuiltinResourcePackInjectionTestMod implements ModInitializer { public static final String MODID = "fabric-resource-loader-v0-testmod"; + public static final RegistryKey KEY = RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(MODID, "testblock")); - public static final Block TEST_BLOCK = new Block(AbstractBlock.Settings.copy(Blocks.STONE)); + public static final Block TEST_BLOCK = new Block(AbstractBlock.Settings.copy(Blocks.STONE).registryKey(KEY)); @Override public void onInitialize() { - Identifier id = Identifier.of(MODID, "testblock"); - - Registry.register(Registries.BLOCK, id, TEST_BLOCK); - Registry.register(Registries.ITEM, id, new BlockItem(TEST_BLOCK, new Item.Settings())); + Registry.register(Registries.BLOCK, KEY, TEST_BLOCK); + Registry.register(Registries.ITEM, KEY.getValue(), new BlockItem(TEST_BLOCK, new Item.Settings())); } } diff --git a/fabric-screen-handler-api-v1/src/testmod/java/net/fabricmc/fabric/test/screenhandler/ScreenHandlerTest.java b/fabric-screen-handler-api-v1/src/testmod/java/net/fabricmc/fabric/test/screenhandler/ScreenHandlerTest.java index 955bcbd29..7cfb8ae6b 100644 --- a/fabric-screen-handler-api-v1/src/testmod/java/net/fabricmc/fabric/test/screenhandler/ScreenHandlerTest.java +++ b/fabric-screen-handler-api-v1/src/testmod/java/net/fabricmc/fabric/test/screenhandler/ScreenHandlerTest.java @@ -24,6 +24,8 @@ import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.resource.featuretoggle.FeatureFlags; import net.minecraft.screen.ScreenHandlerType; import net.minecraft.util.Identifier; @@ -45,7 +47,8 @@ public class ScreenHandlerTest implements ModInitializer { public static final Item BAG = new BagItem(new Item.Settings().maxCount(1)); public static final Item POSITIONED_BAG = new PositionedBagItem(new Item.Settings().maxCount(1)); - public static final Block BOX = new BoxBlock(AbstractBlock.Settings.copy(Blocks.OAK_WOOD)); + public static final RegistryKey BOX_KEY = RegistryKey.of(RegistryKeys.BLOCK, id("box")); + public static final Block BOX = new BoxBlock(AbstractBlock.Settings.copy(Blocks.OAK_WOOD).registryKey(BOX_KEY)); public static final Item BOX_ITEM = new BlockItem(BOX, new Item.Settings()); public static final BlockEntityType BOX_ENTITY = FabricBlockEntityTypeBuilder.create(BoxBlockEntity::new, BOX).build(); public static final ScreenHandlerType BAG_SCREEN_HANDLER = new ScreenHandlerType<>(BagScreenHandler::new, FeatureFlags.VANILLA_FEATURES); @@ -60,8 +63,8 @@ public class ScreenHandlerTest implements ModInitializer { public void onInitialize() { Registry.register(Registries.ITEM, id("bag"), BAG); Registry.register(Registries.ITEM, id("positioned_bag"), POSITIONED_BAG); - Registry.register(Registries.BLOCK, id("box"), BOX); - Registry.register(Registries.ITEM, id("box"), BOX_ITEM); + Registry.register(Registries.BLOCK, BOX_KEY, BOX); + Registry.register(Registries.ITEM, BOX_KEY.getValue(), BOX_ITEM); Registry.register(Registries.BLOCK_ENTITY_TYPE, id("box"), BOX_ENTITY); Registry.register(Registries.SCREEN_HANDLER, id("bag"), BAG_SCREEN_HANDLER); Registry.register(Registries.SCREEN_HANDLER, id("positioned_bag"), POSITIONED_BAG_SCREEN_HANDLER); diff --git a/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/ingame/FluidChuteBlock.java b/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/ingame/FluidChuteBlock.java index 7d7bddde6..333e2cb49 100644 --- a/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/ingame/FluidChuteBlock.java +++ b/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/ingame/FluidChuteBlock.java @@ -41,8 +41,8 @@ import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorageUtil; import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariantAttributes; public class FluidChuteBlock extends Block implements BlockEntityProvider { - public FluidChuteBlock() { - super(Settings.create()); + public FluidChuteBlock(Settings settings) { + super(settings); } private static final VoxelShape SHAPE = VoxelShapes.cuboid( diff --git a/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/ingame/TransferTestInitializer.java b/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/ingame/TransferTestInitializer.java index d9a81ffd7..c8bcc2fa1 100644 --- a/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/ingame/TransferTestInitializer.java +++ b/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/ingame/TransferTestInitializer.java @@ -24,6 +24,8 @@ import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.util.Identifier; import net.fabricmc.api.ModInitializer; @@ -34,17 +36,20 @@ import net.fabricmc.fabric.api.transfer.v1.item.ItemStorage; public class TransferTestInitializer implements ModInitializer { public static final String MOD_ID = "fabric-transfer-api-v1-testmod"; - private static final Block INFINITE_WATER_SOURCE = new Block(AbstractBlock.Settings.create()); - private static final Block INFINITE_LAVA_SOURCE = new Block(AbstractBlock.Settings.create()); - private static final Block FLUID_CHUTE = new FluidChuteBlock(); + private static final RegistryKey INFINITE_WATER_SOURCE_KEY = block("infinite_water_source"); + private static final Block INFINITE_WATER_SOURCE = new Block(AbstractBlock.Settings.create().registryKey(INFINITE_WATER_SOURCE_KEY)); + private static final RegistryKey INFINITE_LAVA_SOURCE_KEY = block("infinite_lava_source"); + private static final Block INFINITE_LAVA_SOURCE = new Block(AbstractBlock.Settings.create().registryKey(INFINITE_LAVA_SOURCE_KEY)); + private static final RegistryKey FLUID_CHUTE_KEY = block("fluid_chute"); + private static final Block FLUID_CHUTE = new FluidChuteBlock(AbstractBlock.Settings.create().registryKey(FLUID_CHUTE_KEY)); private static final Item EXTRACT_STICK = new ExtractStickItem(); public static BlockEntityType FLUID_CHUTE_TYPE; @Override public void onInitialize() { - registerBlock(INFINITE_WATER_SOURCE, "infinite_water_source"); - registerBlock(INFINITE_LAVA_SOURCE, "infinite_lava_source"); - registerBlock(FLUID_CHUTE, "fluid_chute"); + registerBlock(INFINITE_WATER_SOURCE_KEY, INFINITE_WATER_SOURCE); + registerBlock(INFINITE_LAVA_SOURCE_KEY, INFINITE_LAVA_SOURCE); + registerBlock(FLUID_CHUTE_KEY, FLUID_CHUTE); Registry.register(Registries.ITEM, Identifier.of(MOD_ID, "extract_stick"), EXTRACT_STICK); FLUID_CHUTE_TYPE = FabricBlockEntityTypeBuilder.create(FluidChuteBlockEntity::new, FLUID_CHUTE).build(); @@ -59,9 +64,12 @@ public class TransferTestInitializer implements ModInitializer { ItemStorage.SIDED.registerForBlocks((world, pos, state, be, direction) -> CreativeStorage.DIAMONDS, Blocks.DIAMOND_ORE); } - private static void registerBlock(Block block, String name) { - Identifier id = Identifier.of(MOD_ID, name); - Registry.register(Registries.BLOCK, id, block); - Registry.register(Registries.ITEM, id, new BlockItem(block, new Item.Settings())); + private static RegistryKey block(String name) { + return RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(MOD_ID, name)); + } + + private static void registerBlock(RegistryKey key, Block block) { + Registry.register(Registries.BLOCK, key, block); + Registry.register(Registries.ITEM, key.getValue(), new BlockItem(block, new Item.Settings())); } } diff --git a/fabric-transfer-api-v1/src/testmodClient/java/net/fabricmc/fabric/test/transfer/ingame/client/FluidVariantRenderTest.java b/fabric-transfer-api-v1/src/testmodClient/java/net/fabricmc/fabric/test/transfer/ingame/client/FluidVariantRenderTest.java index 8358fa63c..986767b33 100644 --- a/fabric-transfer-api-v1/src/testmodClient/java/net/fabricmc/fabric/test/transfer/ingame/client/FluidVariantRenderTest.java +++ b/fabric-transfer-api-v1/src/testmodClient/java/net/fabricmc/fabric/test/transfer/ingame/client/FluidVariantRenderTest.java @@ -21,9 +21,9 @@ import java.util.List; import com.mojang.blaze3d.systems.RenderSystem; import org.joml.Matrix4f; -import net.minecraft.class_10142; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gl.ShaderProgramKeys; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.BufferRenderer; @@ -93,7 +93,7 @@ public class FluidVariantRenderTest implements ClientModInitializer { float b = (color & 255) / 255f; RenderSystem.disableDepthTest(); - RenderSystem.setShader(class_10142.POSITION_TEX_COLOR); + RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX_COLOR); BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); float x0 = (float) i; float y0 = (float) j; diff --git a/fabric-transitive-access-wideners-v1/src/main/resources/fabric-transitive-access-wideners-v1.accesswidener b/fabric-transitive-access-wideners-v1/src/main/resources/fabric-transitive-access-wideners-v1.accesswidener index 476e59dc0..8d5d9e1d2 100644 --- a/fabric-transitive-access-wideners-v1/src/main/resources/fabric-transitive-access-wideners-v1.accesswidener +++ b/fabric-transitive-access-wideners-v1/src/main/resources/fabric-transitive-access-wideners-v1.accesswidener @@ -121,13 +121,11 @@ transitive-accessible method net/minecraft/entity/damage/DamageSources create (L transitive-accessible field net/minecraft/client/MinecraftClient attackCooldown I # Creating certain types of blocks -transitive-accessible method net/minecraft/block/Blocks createFlowerPotBlock (Lnet/minecraft/block/Block;)Lnet/minecraft/block/Block; -transitive-accessible method net/minecraft/block/Blocks createLeavesBlock (Lnet/minecraft/sound/BlockSoundGroup;)Lnet/minecraft/block/Block; -transitive-accessible method net/minecraft/block/Blocks createLogBlock (Lnet/minecraft/block/MapColor;Lnet/minecraft/block/MapColor;)Lnet/minecraft/block/Block; -transitive-accessible method net/minecraft/block/Blocks createLogBlock (Lnet/minecraft/block/MapColor;Lnet/minecraft/block/MapColor;Lnet/minecraft/sound/BlockSoundGroup;)Lnet/minecraft/block/Block; -transitive-accessible method net/minecraft/block/Blocks createNetherStemBlock (Lnet/minecraft/block/MapColor;)Lnet/minecraft/block/Block; -transitive-accessible method net/minecraft/block/Blocks createStoneButtonBlock ()Lnet/minecraft/block/Block; -transitive-accessible method net/minecraft/block/Blocks createWoodenButtonBlock (Lnet/minecraft/block/BlockSetType;)Lnet/minecraft/block/Block; +transitive-accessible method net/minecraft/block/Blocks createLogSettings (Lnet/minecraft/block/MapColor;Lnet/minecraft/block/MapColor;Lnet/minecraft/sound/BlockSoundGroup;)Lnet/minecraft/block/AbstractBlock$Settings; +transitive-accessible method net/minecraft/block/Blocks createNetherStemSettings (Lnet/minecraft/block/MapColor;)Lnet/minecraft/block/AbstractBlock$Settings; +transitive-accessible method net/minecraft/block/Blocks createLeavesSettings (Lnet/minecraft/sound/BlockSoundGroup;)Lnet/minecraft/block/AbstractBlock$Settings; +transitive-accessible method net/minecraft/block/Blocks createButtonSettings ()Lnet/minecraft/block/AbstractBlock$Settings; +transitive-accessible method net/minecraft/block/Blocks createFlowerPotSettings ()Lnet/minecraft/block/AbstractBlock$Settings; # Methods used in block creation transitive-accessible method net/minecraft/block/Blocks always (Lnet/minecraft/block/BlockState;Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;)Z @@ -137,6 +135,10 @@ transitive-accessible method net/minecraft/block/Blocks createLightLevelFromLitB transitive-accessible method net/minecraft/block/Blocks never (Lnet/minecraft/block/BlockState;Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;)Z transitive-accessible method net/minecraft/block/Blocks never (Lnet/minecraft/block/BlockState;Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/EntityType;)Ljava/lang/Boolean; +# Methods used in block registration +transitive-accessible method net/minecraft/block/Blocks register (Lnet/minecraft/registry/RegistryKey;Ljava/util/function/Function;Lnet/minecraft/block/AbstractBlock$Settings;)Lnet/minecraft/block/Block; +transitive-accessible method net/minecraft/block/Blocks register (Lnet/minecraft/registry/RegistryKey;Lnet/minecraft/block/AbstractBlock$Settings;)Lnet/minecraft/block/Block; + ### Generated access wideners below # Constructors of non-abstract block classes transitive-accessible method net/minecraft/block/AttachedStemBlock (Lnet/minecraft/registry/RegistryKey;Lnet/minecraft/registry/RegistryKey;Lnet/minecraft/registry/RegistryKey;Lnet/minecraft/block/AbstractBlock$Settings;)V @@ -151,7 +153,7 @@ transitive-accessible method net/minecraft/block/CakeBlock (Lnet/minecraf transitive-accessible method net/minecraft/block/CandleCakeBlock (Lnet/minecraft/block/Block;Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/CartographyTableBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/CarvedPumpkinBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V -transitive-accessible method net/minecraft/block/ChestBlock (Lnet/minecraft/block/AbstractBlock$Settings;Ljava/util/function/Supplier;)V +transitive-accessible method net/minecraft/block/ChestBlock (Ljava/util/function/Supplier;Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/ChorusFlowerBlock (Lnet/minecraft/block/Block;Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/ChorusPlantBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/CoralBlock (Lnet/minecraft/block/Block;Lnet/minecraft/block/AbstractBlock$Settings;)V diff --git a/fabric-transitive-access-wideners-v1/src/testmod/java/net/fabricmc/fabric/test/access/SignBlockEntityTest.java b/fabric-transitive-access-wideners-v1/src/testmod/java/net/fabricmc/fabric/test/access/SignBlockEntityTest.java index a37585929..3d8415f35 100644 --- a/fabric-transitive-access-wideners-v1/src/testmod/java/net/fabricmc/fabric/test/access/SignBlockEntityTest.java +++ b/fabric-transitive-access-wideners-v1/src/testmod/java/net/fabricmc/fabric/test/access/SignBlockEntityTest.java @@ -17,6 +17,7 @@ package net.fabricmc.fabric.test.access; import net.minecraft.block.AbstractBlock; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.SignBlock; @@ -29,6 +30,8 @@ import net.minecraft.item.Item; import net.minecraft.item.SignItem; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; @@ -37,13 +40,15 @@ import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityT public final class SignBlockEntityTest implements ModInitializer { public static final String MOD_ID = "fabric-transitive-access-wideners-v1-testmod"; - public static final SignBlock TEST_SIGN = new SignBlock(WoodType.OAK, AbstractBlock.Settings.copy(Blocks.OAK_SIGN)) { + public static final RegistryKey TEST_SIGN_KEY = keyOf("test_sign"); + public static final SignBlock TEST_SIGN = new SignBlock(WoodType.OAK, AbstractBlock.Settings.copy(Blocks.OAK_SIGN).registryKey(TEST_SIGN_KEY)) { @Override public BlockEntity createBlockEntity(BlockPos pos, BlockState state) { return new TestSign(pos, state); } }; - public static final WallSignBlock TEST_WALL_SIGN = new WallSignBlock(WoodType.OAK, AbstractBlock.Settings.copy(Blocks.OAK_SIGN)) { + public static final RegistryKey TEST_WALL_SIGN_KEY = keyOf("test_wall_sign"); + public static final WallSignBlock TEST_WALL_SIGN = new WallSignBlock(WoodType.OAK, AbstractBlock.Settings.copy(Blocks.OAK_SIGN).registryKey(TEST_WALL_SIGN_KEY)) { @Override public BlockEntity createBlockEntity(BlockPos pos, BlockState state) { return new TestSign(pos, state); @@ -52,11 +57,15 @@ public final class SignBlockEntityTest implements ModInitializer { public static final SignItem TEST_SIGN_ITEM = new SignItem(new Item.Settings(), TEST_SIGN, TEST_WALL_SIGN); public static final BlockEntityType TEST_SIGN_BLOCK_ENTITY = FabricBlockEntityTypeBuilder.create(TestSign::new, TEST_SIGN, TEST_WALL_SIGN).build(); + private static RegistryKey keyOf(String id) { + return RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(MOD_ID, id)); + } + @Override public void onInitialize() { - Registry.register(Registries.BLOCK, Identifier.of(MOD_ID, "test_sign"), TEST_SIGN); - Registry.register(Registries.BLOCK, Identifier.of(MOD_ID, "test_wall_sign"), TEST_WALL_SIGN); - Registry.register(Registries.ITEM, Identifier.of(MOD_ID, "test_sign"), TEST_SIGN_ITEM); + Registry.register(Registries.BLOCK, TEST_SIGN_KEY, TEST_SIGN); + Registry.register(Registries.BLOCK, TEST_WALL_SIGN_KEY, TEST_WALL_SIGN); + Registry.register(Registries.ITEM, TEST_SIGN_KEY.getValue(), TEST_SIGN_ITEM); Registry.register(Registries.BLOCK_ENTITY_TYPE, Identifier.of(MOD_ID, "test_sign"), TEST_SIGN_BLOCK_ENTITY); } diff --git a/fabric-transitive-access-wideners-v1/template.accesswidener b/fabric-transitive-access-wideners-v1/template.accesswidener index a81a28f52..cdf4976f4 100644 --- a/fabric-transitive-access-wideners-v1/template.accesswidener +++ b/fabric-transitive-access-wideners-v1/template.accesswidener @@ -116,13 +116,11 @@ transitive-accessible method net/minecraft/entity/damage/DamageSources create (L transitive-accessible field net/minecraft/client/MinecraftClient attackCooldown I # Creating certain types of blocks -transitive-accessible method net/minecraft/block/Blocks createFlowerPotBlock (Lnet/minecraft/block/Block;)Lnet/minecraft/block/Block; -transitive-accessible method net/minecraft/block/Blocks createLeavesBlock (Lnet/minecraft/sound/BlockSoundGroup;)Lnet/minecraft/block/Block; -transitive-accessible method net/minecraft/block/Blocks createLogBlock (Lnet/minecraft/block/MapColor;Lnet/minecraft/block/MapColor;)Lnet/minecraft/block/Block; -transitive-accessible method net/minecraft/block/Blocks createLogBlock (Lnet/minecraft/block/MapColor;Lnet/minecraft/block/MapColor;Lnet/minecraft/sound/BlockSoundGroup;)Lnet/minecraft/block/Block; -transitive-accessible method net/minecraft/block/Blocks createNetherStemBlock (Lnet/minecraft/block/MapColor;)Lnet/minecraft/block/Block; -transitive-accessible method net/minecraft/block/Blocks createStoneButtonBlock ()Lnet/minecraft/block/Block; -transitive-accessible method net/minecraft/block/Blocks createWoodenButtonBlock (Lnet/minecraft/block/BlockSetType;)Lnet/minecraft/block/Block; +transitive-accessible method net/minecraft/block/Blocks createLogSettings (Lnet/minecraft/block/MapColor;Lnet/minecraft/block/MapColor;Lnet/minecraft/sound/BlockSoundGroup;)Lnet/minecraft/block/AbstractBlock$Settings; +transitive-accessible method net/minecraft/block/Blocks createNetherStemSettings (Lnet/minecraft/block/MapColor;)Lnet/minecraft/block/AbstractBlock$Settings; +transitive-accessible method net/minecraft/block/Blocks createLeavesSettings (Lnet/minecraft/sound/BlockSoundGroup;)Lnet/minecraft/block/AbstractBlock$Settings; +transitive-accessible method net/minecraft/block/Blocks createButtonSettings ()Lnet/minecraft/block/AbstractBlock$Settings; +transitive-accessible method net/minecraft/block/Blocks createFlowerPotSettings ()Lnet/minecraft/block/AbstractBlock$Settings; # Methods used in block creation transitive-accessible method net/minecraft/block/Blocks always (Lnet/minecraft/block/BlockState;Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;)Z @@ -132,4 +130,8 @@ transitive-accessible method net/minecraft/block/Blocks createLightLevelFromLitB transitive-accessible method net/minecraft/block/Blocks never (Lnet/minecraft/block/BlockState;Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;)Z transitive-accessible method net/minecraft/block/Blocks never (Lnet/minecraft/block/BlockState;Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/EntityType;)Ljava/lang/Boolean; +# Methods used in block registration +transitive-accessible method net/minecraft/block/Blocks register (Lnet/minecraft/registry/RegistryKey;Ljava/util/function/Function;Lnet/minecraft/block/AbstractBlock$Settings;)Lnet/minecraft/block/Block; +transitive-accessible method net/minecraft/block/Blocks register (Lnet/minecraft/registry/RegistryKey;Lnet/minecraft/block/AbstractBlock$Settings;)Lnet/minecraft/block/Block; + ### Generated access wideners below diff --git a/gradle.properties b/gradle.properties index 09ad0a108..4c3627555 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,8 +3,8 @@ org.gradle.parallel=true fabric.loom.multiProjectOptimisation=true version=0.103.0 -minecraft_version=24w34a -yarn_version=+build.1 +minecraft_version=24w35a +yarn_version=+build.4 loader_version=0.16.2 installer_version=1.0.1