From 75e98211bdee25aaf189f8a6b42fa8cdd18c7e69 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sat, 22 Oct 2022 20:38:33 +0100 Subject: [PATCH] =?UTF-8?q?22w42a=20=F0=9F=90=AB=20(#2599)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: shartte Co-authored-by: Juuz <6596629+Juuxel@users.noreply.github.com> --- build.gradle | 11 +- checkstyle.xml | 2 +- .../test/lookup/FabricApiLookupTest.java | 7 +- .../test/lookup/item/InspectableItem.java | 3 +- fabric-biome-api-v1/.gitignore | 1 + fabric-biome-api-v1/build.gradle | 33 +- .../BiomeModificationContextImpl.java | 44 +- .../modification/BiomeModificationImpl.java | 8 +- .../BiomeSelectionContextImpl.java | 9 +- .../mixin/biome/MinecraftServerMixin.java | 16 +- .../modification/MinecraftServerMixin.java | 2 +- .../worldgen/biome/custom_plains.json | 200 ++++++++ .../worldgen/biome/test_crimson_forest.json | 106 ++++ .../worldgen/biome/test_end_barrens.json | 130 +++++ .../worldgen/biome/test_end_highlands.json | 138 ++++++ .../worldgen/biome/test_end_midlands.json | 130 +++++ .../configured_feature/fab_desert_well.json | 4 + .../placed_feature/fab_desert_well.json | 15 + .../test/biome/DataGeneratorEntrypoint.java | 14 +- .../fabric/test/biome/FabricBiomeTest.java | 14 +- .../src/testmod/resources/fabric.mod.json | 3 + .../client/ClientPlayNetworkHandlerMixin.java | 26 +- .../client/ClientPlayerEntityMixin.java | 45 -- .../fabric-command-api-v2.client.mixins.json | 1 - .../SculkSensorFrequencyRegistry.java | 4 +- ...Mixin.java => VibrationListenerMixin.java} | 5 +- .../fabric-content-registries-v0.mixins.json | 2 +- fabric-data-generation-api-v1/build.gradle | 6 +- .../api/datagen/v1/FabricDataGenerator.java | 12 +- .../provider/FabricAdvancementProvider.java | 8 +- .../FabricBlockLootTableProvider.java | 12 +- .../FabricBuiltinRegistriesProvider.java | 115 +++++ .../v1/provider/FabricLanguageProvider.java | 37 +- .../v1/provider/FabricLootTableProvider.java | 3 +- .../v1/provider/FabricModelProvider.java | 2 +- .../v1/provider/FabricRecipeProvider.java | 16 +- .../v1/provider/FabricTagProvider.java | 20 +- .../impl/datagen/FabricDataGenHelper.java | 4 +- .../fabric/impl/datagen/FabricDataOutput.java | 32 +- .../datagen/AbstractTagProviderMixin.java | 4 +- .../mixin/datagen/ModelProviderMixin.java | 21 +- ...abric-data-generation-api-v1.accesswidener | 250 +++++----- .../fabric-data-generation-api-v1.mixins.json | 1 - .../datagen/DataGeneratorTestContent.java | 34 +- .../datagen/DataGeneratorTestEntrypoint.java | 11 +- .../template.accesswidener | 27 +- .../fabric/mixin/dimension/MainMixin.java | 93 ---- .../fabric-dimensions-v1.mixins.json | 3 +- .../event/elytra/ClientPlayerEntityMixin.java | 5 +- .../test/entity/event/DiamondElytraItem.java | 3 +- .../test/entity/event/EntityEventTests.java | 3 +- .../mixin/gametest/server/MainMixin.java | 2 +- .../api/item/v1/FabricItemSettings.java | 8 +- .../test/item/FabricItemSettingsTests.java | 3 +- .../fabric/test/item/UpdatingItem.java | 5 +- fabric-item-group-api-v1/build.gradle | 11 + .../itemgroup}/CreativeGuiExtensions.java | 2 +- .../FabricCreativeGuiComponents.java | 24 +- .../client/CreativeInventoryScreenMixin.java | 36 +- .../itemgroup}/client/ItemGroupMixin.java | 4 +- ...abric-item-group-api-v1.client.mixins.json | 4 +- .../api/itemgroup/v1/FabricItemGroup.java | 65 +++ .../itemgroup/v1/FabricItemGroupEntries.java | 464 ++++++++++++++++++ .../itemgroup/v1/IdentifiableItemGroup.java | 17 +- .../api/itemgroup/v1/ItemGroupEvents.java | 67 +++ .../impl/itemgroup/ItemGroupEventsImpl.java | 51 ++ .../impl/itemgroup/ItemGroupHelper.java | 47 ++ .../impl/itemgroup/MinecraftItemGroups.java | 60 +++ .../mixin/itemgroup/ItemGroupAccessor.java | 15 +- .../mixin/itemgroup/ItemGroupMixin.java | 95 ++++ .../mixin/itemgroup/ItemGroupsAccessor.java | 27 +- .../mixin/itemgroup/ItemGroupsMixin.java | 38 ++ .../assets/fabric-item-group-api-v1}/icon.png | Bin .../resources/assets/fabric/lang/bg_bg.json | 0 .../resources/assets/fabric/lang/de_de.json | 0 .../resources/assets/fabric/lang/el_gr.json | 0 .../resources/assets/fabric/lang/en_us.json | 0 .../resources/assets/fabric/lang/es_es.json | 0 .../resources/assets/fabric/lang/es_mx.json | 0 .../resources/assets/fabric/lang/et_ee.json | 0 .../resources/assets/fabric/lang/fa_ir.json | 0 .../resources/assets/fabric/lang/fi_fi.json | 0 .../resources/assets/fabric/lang/fr_fr.json | 0 .../resources/assets/fabric/lang/it_it.json | 0 .../resources/assets/fabric/lang/ja_jp.json | 0 .../resources/assets/fabric/lang/ko_kr.json | 0 .../resources/assets/fabric/lang/pl_pl.json | 0 .../resources/assets/fabric/lang/pt_br.json | 0 .../resources/assets/fabric/lang/sv_se.json | 0 .../resources/assets/fabric/lang/tr_tr.json | 0 .../resources/assets/fabric/lang/zh_cn.json | 0 .../resources/assets/fabric/lang/zh_tw.json | 0 .../fabric/textures/gui/creative_buttons.png | Bin .../fabric-item-group-api-v1.accesswidener | 6 + .../fabric-item-group-api-v1.mixins.json | 14 + .../src/main/resources/fabric.mod.json | 19 +- .../fabric/test/item/group/ItemGroupTest.java | 94 ++++ .../src/testmod/resources/fabric.mod.json | 6 +- fabric-item-groups-v0/build.gradle | 7 - .../itemgroup/FabricItemGroupBuilder.java | 185 ------- .../impl/item/group/ItemGroupExtensions.java | 21 - .../fabric-item-groups-v0.mixins.json | 11 - .../fabric/test/item/group/ItemGroupTest.java | 61 --- .../client/ClientPlayNetworkHandlerMixin.java | 7 +- .../fabricmc/fabric/impl/loot/LootUtil.java | 2 +- .../mixin/message/PlayerManagerMixin.java | 12 - .../fabric/test/message/ChatTest.java | 4 +- .../test/mininglevel/MiningLevelTest.java | 5 +- .../mixin/client/model/ModelLoaderMixin.java | 17 +- .../src/testmod/resources/fabric.mod.json | 1 - .../v1/entity/FabricEntityTypeBuilder.java | 9 +- .../impl/object/builder/FabricEntityType.java | 5 +- .../builder/BlockEntityTypeBuilderTest.java | 3 +- fabric-registry-sync-v0/build.gradle | 4 + .../event/registry/FabricRegistryBuilder.java | 4 +- .../packet/DirectRegistryPacketHandler.java | 10 +- .../registry/sync/BuiltinRegistriesMixin.java | 21 +- .../sync/CombinedDynamicRegistriesMixin.java | 43 ++ .../sync/DynamicRegistryManagerMixin.java | 22 +- .../registry/sync/MinecraftServerMixin.java | 8 + .../registry/sync/SimpleRegistryMixin.java | 19 +- .../fabric-registry-sync-v0.accesswidener | 4 + .../fabric-registry-sync-v0.mixins.json | 1 + .../src/main/resources/fabric.mod.json | 1 + .../test/registry/sync/RegistrySyncTest.java | 12 +- .../registry/sync/RegistrySyncTestClient.java | 12 +- .../impl/renderer/SpriteFinderImpl.java | 2 +- .../client/SpriteAtlasTextureMixin.java | 5 +- .../test/renderer/simple/RendererTest.java | 5 +- .../simple/client/FrameUnbakedModel.java | 9 +- .../fluid/v1/SimpleFluidRenderHandler.java | 6 +- .../fluid/CustomizedFluidRenderer.java | 2 +- .../FabricFluidRenderingTestModClient.java | 9 +- .../rendering/TooltipComponentTestInit.java | 8 +- ...lientBuiltinResourcePackProviderMixin.java | 68 --- .../loader/client/CreateWorldScreenMixin.java | 89 +--- .../ServerResourcePackProviderMixin.java | 38 ++ ...bric-resource-loader-v0.client.mixins.json | 2 +- .../loader/BuiltinModResourcePackSource.java | 5 + .../loader/FabricModResourcePack.java | 55 +-- .../impl/resource/loader/FabricResource.java | 4 +- .../resource/loader/GroupResourcePack.java | 69 +-- .../resource/loader/ModNioResourcePack.java | 84 ++-- .../loader/ModResourcePackCreator.java | 29 +- .../resource/loader/ModResourcePackUtil.java | 9 +- .../loader/ResourceManagerHelperImpl.java | 22 +- .../loader/ResourcePackSourceTracker.java | 4 +- .../pack/ProgrammerArtResourcePack.java | 111 ----- .../loader/DefaultResourcePackMixin.java | 127 ----- .../NamespaceResourceManagerAccessor.java | 36 -- .../NamespaceResourceManagerEntryMixin.java | 48 -- .../loader/NamespaceResourceManagerMixin.java | 66 +-- .../mixin/resource/loader/ResourceMixin.java | 17 +- .../loader/ResourcePackManagerAccessor.java | 36 -- .../loader/ResourcePackManagerMixin.java | 6 +- ...java => ServerPropertiesHandlerMixin.java} | 12 +- .../resource/loader/TestServerMixin.java | 25 +- .../fabric-resource-loader-v0.accesswidener | 10 +- .../fabric-resource-loader-v0.mixins.json | 7 +- .../assets/minecraft/textures/block/dirt.png | Bin 114 -> 1887 bytes .../minecraft/textures/block/dirt.png.mcmeta | 15 + .../resources/resourcepacks/test/pack.mcmeta | 6 +- .../resources/resourcepacks/test2/pack.mcmeta | 6 +- .../test/screenhandler/ScreenHandlerTest.java | 9 +- fabric-sound-api-v1/build.gradle | 6 - .../client/ClientSpriteRegistryCallback.java | 56 +-- .../texture/SpriteRegistryCallbackHolder.java | 7 - .../texture/SpriteAtlasManagerMixin.java | 61 +++ .../texture/SpriteAtlasTextureMixin.java | 141 ------ .../resources/fabric-textures-v0.mixins.json | 2 +- .../impl/transfer/item/ComposterWrapper.java | 2 +- .../transfer/ingame/ExtractStickItem.java | 5 +- .../ingame/TransferTestInitializer.java | 3 +- ...ransitive-access-wideners-v1.accesswidener | 11 +- gradle.properties | 108 ++-- settings.gradle | 2 +- src/main/resources/fabric.mod.json | 4 +- 177 files changed, 2904 insertions(+), 1955 deletions(-) create mode 100644 fabric-biome-api-v1/.gitignore create mode 100644 fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome/custom_plains.json create mode 100644 fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome/test_crimson_forest.json create mode 100644 fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome/test_end_barrens.json create mode 100644 fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome/test_end_highlands.json create mode 100644 fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome/test_end_midlands.json create mode 100644 fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/configured_feature/fab_desert_well.json create mode 100644 fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/placed_feature/fab_desert_well.json rename fabric-textures-v0/src/client/java/net/fabricmc/fabric/impl/client/texture/FabricSprite.java => fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/DataGeneratorEntrypoint.java (57%) delete mode 100644 fabric-command-api-v2/src/client/java/net/fabricmc/fabric/mixin/command/client/ClientPlayerEntityMixin.java rename fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/mixin/content/registry/{SculkSensorBlockMixin.java => VibrationListenerMixin.java} (91%) create mode 100644 fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricBuiltinRegistriesProvider.java rename fabric-textures-v0/src/client/java/net/fabricmc/fabric/api/client/texture/DependentSprite.java => fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/FabricDataOutput.java (50%) delete mode 100644 fabric-dimensions-v1/src/main/java/net/fabricmc/fabric/mixin/dimension/MainMixin.java create mode 100644 fabric-item-group-api-v1/build.gradle rename {fabric-item-groups-v0/src/client/java/net/fabricmc/fabric/impl/item/group => fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/impl/itemgroup}/CreativeGuiExtensions.java (95%) rename {fabric-item-groups-v0/src/client/java/net/fabricmc/fabric/impl/item/group => fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/impl/itemgroup}/FabricCreativeGuiComponents.java (83%) rename {fabric-item-groups-v0/src/client/java/net/fabricmc/fabric/mixin/item/group => fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/mixin/itemgroup}/client/CreativeInventoryScreenMixin.java (83%) rename {fabric-item-groups-v0/src/client/java/net/fabricmc/fabric/mixin/item/group => fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/mixin/itemgroup}/client/ItemGroupMixin.java (93%) rename fabric-item-groups-v0/src/client/resources/fabric-item-groups-v0.client.mixins.json => fabric-item-group-api-v1/src/client/resources/fabric-item-group-api-v1.client.mixins.json (60%) create mode 100644 fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/api/itemgroup/v1/FabricItemGroup.java create mode 100644 fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/api/itemgroup/v1/FabricItemGroupEntries.java rename fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/FabricNamespaceResourceManagerEntry.java => fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/api/itemgroup/v1/IdentifiableItemGroup.java (61%) create mode 100644 fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/api/itemgroup/v1/ItemGroupEvents.java create mode 100644 fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/impl/itemgroup/ItemGroupEventsImpl.java create mode 100644 fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/impl/itemgroup/ItemGroupHelper.java create mode 100644 fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/impl/itemgroup/MinecraftItemGroups.java rename fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/FileResourcePackProviderAccessor.java => fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/mixin/itemgroup/ItemGroupAccessor.java (69%) create mode 100644 fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/mixin/itemgroup/ItemGroupMixin.java rename fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/mixin/item/group/ItemGroupMixin.java => fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/mixin/itemgroup/ItemGroupsAccessor.java (62%) create mode 100644 fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/mixin/itemgroup/ItemGroupsMixin.java rename {fabric-item-groups-v0/src/main/resources/assets/fabric-item-groups-v0 => fabric-item-group-api-v1/src/main/resources/assets/fabric-item-group-api-v1}/icon.png (100%) rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/assets/fabric/lang/bg_bg.json (100%) rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/assets/fabric/lang/de_de.json (100%) rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/assets/fabric/lang/el_gr.json (100%) rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/assets/fabric/lang/en_us.json (100%) rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/assets/fabric/lang/es_es.json (100%) rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/assets/fabric/lang/es_mx.json (100%) rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/assets/fabric/lang/et_ee.json (100%) rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/assets/fabric/lang/fa_ir.json (100%) rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/assets/fabric/lang/fi_fi.json (100%) rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/assets/fabric/lang/fr_fr.json (100%) rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/assets/fabric/lang/it_it.json (100%) rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/assets/fabric/lang/ja_jp.json (100%) rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/assets/fabric/lang/ko_kr.json (100%) rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/assets/fabric/lang/pl_pl.json (100%) rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/assets/fabric/lang/pt_br.json (100%) rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/assets/fabric/lang/sv_se.json (100%) rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/assets/fabric/lang/tr_tr.json (100%) rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/assets/fabric/lang/zh_cn.json (100%) rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/assets/fabric/lang/zh_tw.json (100%) rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/assets/fabric/textures/gui/creative_buttons.png (100%) create mode 100644 fabric-item-group-api-v1/src/main/resources/fabric-item-group-api-v1.accesswidener create mode 100644 fabric-item-group-api-v1/src/main/resources/fabric-item-group-api-v1.mixins.json rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/main/resources/fabric.mod.json (52%) create mode 100644 fabric-item-group-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/group/ItemGroupTest.java rename {fabric-item-groups-v0 => fabric-item-group-api-v1}/src/testmod/resources/fabric.mod.json (62%) delete mode 100644 fabric-item-groups-v0/build.gradle delete mode 100644 fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/api/client/itemgroup/FabricItemGroupBuilder.java delete mode 100644 fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/impl/item/group/ItemGroupExtensions.java delete mode 100644 fabric-item-groups-v0/src/main/resources/fabric-item-groups-v0.mixins.json delete mode 100644 fabric-item-groups-v0/src/testmod/java/net/fabricmc/fabric/test/item/group/ItemGroupTest.java rename fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/DynamicRegistryManagerAccessor.java => fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/BuiltinRegistriesMixin.java (56%) create mode 100644 fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/CombinedDynamicRegistriesMixin.java create mode 100644 fabric-registry-sync-v0/src/main/resources/fabric-registry-sync-v0.accesswidener delete mode 100644 fabric-resource-loader-v0/src/client/java/net/fabricmc/fabric/mixin/resource/loader/client/ClientBuiltinResourcePackProviderMixin.java create mode 100644 fabric-resource-loader-v0/src/client/java/net/fabricmc/fabric/mixin/resource/loader/client/ServerResourcePackProviderMixin.java delete mode 100644 fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/client/pack/ProgrammerArtResourcePack.java delete mode 100644 fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/DefaultResourcePackMixin.java delete mode 100644 fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/NamespaceResourceManagerAccessor.java delete mode 100644 fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/NamespaceResourceManagerEntryMixin.java delete mode 100644 fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourcePackManagerAccessor.java rename fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/{MainMixin.java => ServerPropertiesHandlerMixin.java} (72%) create mode 100644 fabric-resource-loader-v0/src/testmod/resources/resourcepacks/test/assets/minecraft/textures/block/dirt.png.mcmeta create mode 100644 fabric-textures-v0/src/client/java/net/fabricmc/fabric/mixin/client/texture/SpriteAtlasManagerMixin.java delete mode 100644 fabric-textures-v0/src/client/java/net/fabricmc/fabric/mixin/client/texture/SpriteAtlasTextureMixin.java diff --git a/build.gradle b/build.gradle index 8a11cc1c1..b4b001e2b 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ plugins { id "eclipse" id "idea" id "maven-publish" - id "fabric-loom" version "1.0.7" apply false + id "fabric-loom" version "1.0.11" apply false id "com.diffplug.spotless" version "6.11.0" id "org.ajoberstar.grgit" version "3.1.0" id "com.matthewprenger.cursegradle" version "1.4.0" @@ -286,6 +286,11 @@ remapTestmodJar { apply from: "gradle/module-validation.gradle" apply from: "gradle/module-versioning.gradle" +loom { + // Required as the item-group API uses access widened classes in its API, without this the javadoc generation fails. + accessWidenerPath = file("fabric-item-group-api-v1/src/main/resources/fabric-item-group-api-v1.accesswidener") +} + javadoc { options { source = "17" @@ -318,7 +323,7 @@ javadoc { classpath = files(sourceSets.main.compileClasspath, sourceSets.client.compileClasspath) include("**/api/**") - failOnError false + failOnError true } task javadocJar(type: Jar) { @@ -511,7 +516,7 @@ curseforge { id = "306612" changelog = ENV.CHANGELOG ?: "No changelog provided" releaseType = project.prerelease == "true" ? "beta" : "release" - addGameVersion "1.19.2" + addGameVersion "1.19.3" addGameVersion "Fabric" mainArtifact(signingEnabled ? signRemapJar.output : remapJar) { diff --git a/checkstyle.xml b/checkstyle.xml index 2ec284761..6d1359a2e 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -194,7 +194,7 @@ - largely unconstained trailing subpackages --> + value="^net\.fabricmc\.fabric\.(api(?!\.common\.)(\.client|\.server|)(\.(?!client\.|server\.)[a-z]+([a-rt-z]|ss))+\.v[1-9][0-9]*|(impl|mixin|test)(?!\.common\.)(\.client|\.server|)(\.(?!client\.|server\.)[a-z]+([a-rt-z]|ss))+(\.v[1-9][0-9]*)?|api\.(event|util|biomes\.v1|registry|client\.screen|container|block|entity|client\.keybinding|tag|tools|client\.model|network|server|client\.render|resource|client\.texture))(|\.[a-z]+(\.[a-z0-9]+)*)$"/> 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 b7f27e5b5..3b763abc6 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 @@ -22,7 +22,6 @@ import net.minecraft.block.Material; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; import net.minecraft.util.Identifier; import net.minecraft.util.math.Direction; import net.minecraft.util.registry.Registry; @@ -43,17 +42,17 @@ public class FabricApiLookupTest implements ModInitializer { // 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(FabricBlockSettings.of(Material.METAL)); - public static final BlockItem CHUTE_ITEM = new BlockItem(CHUTE_BLOCK, new Item.Settings().group(ItemGroup.MISC)); + 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(FabricBlockSettings.of(Material.METAL)); - public static final BlockItem COBBLE_GEN_ITEM = new BlockItem(COBBLE_GEN_BLOCK, new Item.Settings().group(ItemGroup.MISC)); + 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(FabricBlockSettings.of(Material.METAL)); - public static final BlockItem INSPECTOR_ITEM = new BlockItem(INSPECTOR_BLOCK, new Item.Settings().group(ItemGroup.MISC)); + public static final BlockItem INSPECTOR_ITEM = new BlockItem(INSPECTOR_BLOCK, new Item.Settings()); @Override public void onInitialize() { diff --git a/fabric-api-lookup-api-v1/src/testmod/java/net/fabricmc/fabric/test/lookup/item/InspectableItem.java b/fabric-api-lookup-api-v1/src/testmod/java/net/fabricmc/fabric/test/lookup/item/InspectableItem.java index 3f93a04b9..9cf89887a 100644 --- a/fabric-api-lookup-api-v1/src/testmod/java/net/fabricmc/fabric/test/lookup/item/InspectableItem.java +++ b/fabric-api-lookup-api-v1/src/testmod/java/net/fabricmc/fabric/test/lookup/item/InspectableItem.java @@ -17,7 +17,6 @@ package net.fabricmc.fabric.test.lookup.item; import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; import net.minecraft.text.Text; import net.fabricmc.fabric.test.lookup.api.Inspectable; @@ -26,7 +25,7 @@ public class InspectableItem extends Item implements Inspectable { private final String inspectionResult; public InspectableItem(String inspectionResult) { - super(new Settings().group(ItemGroup.MISC)); + super(new Settings()); this.inspectionResult = inspectionResult; } diff --git a/fabric-biome-api-v1/.gitignore b/fabric-biome-api-v1/.gitignore new file mode 100644 index 000000000..cb2228995 --- /dev/null +++ b/fabric-biome-api-v1/.gitignore @@ -0,0 +1 @@ +/src/testmod/generated/.cache diff --git a/fabric-biome-api-v1/build.gradle b/fabric-biome-api-v1/build.gradle index 543bd160b..c2261c7d8 100644 --- a/fabric-biome-api-v1/build.gradle +++ b/fabric-biome-api-v1/build.gradle @@ -7,5 +7,36 @@ loom { testDependencies(project, [ ':fabric-api-base', - ':fabric-resource-loader-v0' + ':fabric-resource-loader-v0', + ':fabric-registry-sync-v0', + ':fabric-data-generation-api-v1' ]) + +sourceSets { + testmod { + resources { + srcDirs += [ + 'src/testmod/generated' + ] + } + } +} + +loom { + runs { + datagen { + inherit testmodServer + name "Data Generation" + vmArg "-Dfabric-api.datagen" + vmArg "-Dfabric-api.datagen.output-dir=${file("src/testmod/generated")}" + vmArg "-Dfabric-api.datagen.strict-validation" + + ideConfigGenerated = true + runDir "build/datagen" + } + } +} + +// Ensure the worldgen JSONs are re-created to ensure the data-gen still works +test.dependsOn runDatagen +runTestmodClient.dependsOn runDatagen 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 7de4c4f69..8adb6c7d2 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 @@ -40,6 +40,7 @@ import net.minecraft.sound.BiomeMoodSound; import net.minecraft.sound.MusicSound; import net.minecraft.sound.SoundEvent; import net.minecraft.util.collection.Pool; +import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.RegistryEntry; @@ -60,16 +61,14 @@ import net.fabricmc.fabric.api.biome.v1.BiomeModificationContext; @ApiStatus.Internal public class BiomeModificationContextImpl implements BiomeModificationContext { private final DynamicRegistryManager registries; - private final RegistryKey biomeKey; private final Biome biome; private final WeatherContext weather; private final EffectsContext effects; private final GenerationSettingsContextImpl generationSettings; private final SpawnSettingsContextImpl spawnSettings; - public BiomeModificationContextImpl(DynamicRegistryManager registries, RegistryKey biomeKey, Biome biome) { + public BiomeModificationContextImpl(DynamicRegistryManager registries, Biome biome) { this.registries = registries; - this.biomeKey = biomeKey; this.biome = biome; this.weather = new WeatherContextImpl(); this.effects = new EffectsContextImpl(); @@ -257,7 +256,7 @@ public class BiomeModificationContextImpl implements BiomeModificationContext { @Override public boolean removeFeature(GenerationStep.Feature step, RegistryKey placedFeatureKey) { - PlacedFeature configuredFeature = features.getOrThrow(placedFeatureKey); + PlacedFeature placedFeature = getEntry(features, placedFeatureKey).value(); int stepIndex = step.ordinal(); List> featureSteps = generationSettings.features; @@ -269,7 +268,7 @@ public class BiomeModificationContextImpl implements BiomeModificationContext { RegistryEntryList featuresInStep = featureSteps.get(stepIndex); List> features = new ArrayList<>(featuresInStep.stream().toList()); - if (features.removeIf(feature -> feature.value() == configuredFeature)) { + if (features.removeIf(feature -> feature.value() == placedFeature)) { featureSteps.set(stepIndex, RegistryEntryList.of(features)); rebuildFlowerFeatures = true; @@ -289,21 +288,21 @@ public class BiomeModificationContextImpl implements BiomeModificationContext { featureSteps.add(RegistryEntryList.of(Collections.emptyList())); } - featureSteps.set(index, plus(featureSteps.get(index), features.getEntry(entry).orElseThrow())); + featureSteps.set(index, plus(featureSteps.get(index), getEntry(features, entry))); - // Ensure the list of flower features is up to date + // Ensure the list of flower features is up-to-date rebuildFlowerFeatures = true; } @Override public void addCarver(GenerationStep.Carver step, RegistryKey> entry) { // We do not need to delay evaluation of this since the registries are already fully built - generationSettings.carvers.put(step, plus(generationSettings.carvers.get(step), carvers.getEntry(entry).orElseThrow())); + generationSettings.carvers.put(step, plus(generationSettings.carvers.get(step), getEntry(carvers, entry))); } @Override public boolean removeCarver(GenerationStep.Carver step, RegistryKey> configuredCarverKey) { - ConfiguredCarver carver = carvers.getOrThrow(configuredCarverKey); + ConfiguredCarver carver = getEntry(carvers, configuredCarverKey).value(); List>> genCarvers = new ArrayList<>(generationSettings.carvers.get(step).stream().toList()); if (genCarvers.removeIf(entry -> entry.value() == carver)) { @@ -321,6 +320,33 @@ public class BiomeModificationContextImpl implements BiomeModificationContext { } } + /** + * Gets an entry from the given registry, assuming it's a registry loaded from data packs. + * Gives more helpful error messages if an entry is missing by checking if the modder + * 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); + + if (entry == null) { + // Entry is missing. Check if it exists in the built-in registries and warn modders + // about the worldgen changing to JSON-only. + DynamicRegistryManager.Immutable builtInAccess = BuiltinRegistries.createBuiltinRegistryManager(); + Registry builtInRegistry = builtInAccess.get(registry.getKey()); + + if (builtInRegistry.contains(key)) { + throw new IllegalArgumentException("Entry " + key + " only exists in the built-in registry " + + "but a corresponding JSON file couldn't be found in the loaded data packs. " + + "Since 1.19.3+, the built-in registry for world generation objects is only used for data generation purposes."); + } + + // The key doesn't exist in either built-in registries or data packs + throw new IllegalArgumentException("Couldn't find registry entry for " + key); + } + + return entry; + } + private class SpawnSettingsContextImpl implements SpawnSettingsContext { private final SpawnSettings spawnSettings = biome.getSpawnSettings(); private final EnumMap> fabricSpawners = new EnumMap<>(SpawnGroup.class); 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 08e12bc8c..093f65a58 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 @@ -36,7 +36,6 @@ import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.biome.Biome; -import net.minecraft.world.level.LevelProperties; import net.fabricmc.fabric.api.biome.v1.BiomeModificationContext; import net.fabricmc.fabric.api.biome.v1.BiomeSelectionContext; @@ -102,8 +101,7 @@ public class BiomeModificationImpl { return modifiers; } - @SuppressWarnings("ConstantConditions") - public void finalizeWorldGen(DynamicRegistryManager impl, LevelProperties levelProperties) { + public void finalizeWorldGen(DynamicRegistryManager impl) { Stopwatch sw = Stopwatch.createStarted(); // Now that we apply biome modifications inside the MinecraftServer constructor, we should only ever do @@ -134,7 +132,7 @@ public class BiomeModificationImpl { // Make a copy of the biome to allow selection contexts to see it unmodified, // But do so only once it's known anything wants to modify the biome at all - BiomeSelectionContext context = new BiomeSelectionContextImpl(impl, levelProperties, key, biome); + BiomeSelectionContext context = new BiomeSelectionContextImpl(impl, key, biome); BiomeModificationContextImpl modificationContext = null; for (ModifierRecord modifier : sortedModifiers) { @@ -144,7 +142,7 @@ public class BiomeModificationImpl { // Create the copy only if at least one modifier applies, since it's pretty costly if (modificationContext == null) { biomesChanged++; - modificationContext = new BiomeModificationContextImpl(impl, key, biome); + modificationContext = new BiomeModificationContextImpl(impl, biome); } modifier.apply(context, modificationContext); 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 77ee51a1a..2581f30e7 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 @@ -30,21 +30,18 @@ import net.minecraft.world.dimension.DimensionOptions; import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.PlacedFeature; import net.minecraft.world.gen.structure.Structure; -import net.minecraft.world.level.LevelProperties; import net.fabricmc.fabric.api.biome.v1.BiomeSelectionContext; @ApiStatus.Internal public class BiomeSelectionContextImpl implements BiomeSelectionContext { private final DynamicRegistryManager dynamicRegistries; - private final LevelProperties levelProperties; private final RegistryKey key; private final Biome biome; private final RegistryEntry entry; - public BiomeSelectionContextImpl(DynamicRegistryManager dynamicRegistries, LevelProperties levelProperties, RegistryKey key, Biome biome) { + public BiomeSelectionContextImpl(DynamicRegistryManager dynamicRegistries, RegistryKey key, Biome biome) { this.dynamicRegistries = dynamicRegistries; - this.levelProperties = levelProperties; this.key = key; this.biome = biome; this.entry = dynamicRegistries.get(Registry.BIOME_KEY).getEntry(this.key).orElseThrow(); @@ -96,13 +93,13 @@ public class BiomeSelectionContextImpl implements BiomeSelectionContext { @Override public boolean canGenerateIn(RegistryKey dimensionKey) { - DimensionOptions dimension = levelProperties.getGeneratorOptions().getDimensions().get(dimensionKey); + DimensionOptions dimension = dynamicRegistries.get(Registry.DIMENSION_KEY).get(dimensionKey); if (dimension == null) { return false; } - return dimension.getChunkGenerator().getBiomeSource().getBiomes().stream().anyMatch(entry -> entry.value() == biome); + return dimension.chunkGenerator().getBiomeSource().getBiomes().stream().anyMatch(entry -> entry.value() == biome); } @Override diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/MinecraftServerMixin.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/MinecraftServerMixin.java index 06411dda2..299afecff 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/MinecraftServerMixin.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/MinecraftServerMixin.java @@ -16,7 +16,6 @@ package net.fabricmc.fabric.mixin.biome; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -27,25 +26,24 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.WorldGenerationProgressListener; import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.util.registry.Registry; -import net.minecraft.world.SaveProperties; +import net.minecraft.world.dimension.DimensionOptions; import net.fabricmc.fabric.impl.biome.NetherBiomeData; @Mixin(MinecraftServer.class) public class MinecraftServerMixin { @Shadow - @Final - protected SaveProperties saveProperties; - - @Shadow - @Final - private DynamicRegistryManager.Immutable registryManager; + private DynamicRegistryManager.Immutable getRegistryManager() { + throw new AssertionError(); + } @Inject(method = "createWorlds", at = @At("HEAD")) private void addNetherBiomes(WorldGenerationProgressListener worldGenerationProgressListener, CallbackInfo ci) { // This is the last point where we can safely modify worldgen related things // plus, this is server-side only, and DRM is easily accessible // please blame Mojang for using dynamic registry - this.saveProperties.getGeneratorOptions().getDimensions().stream().forEach(dimensionOptions -> NetherBiomeData.modifyBiomeSource(this.registryManager.get(Registry.BIOME_KEY), dimensionOptions.getChunkGenerator().getBiomeSource())); + Registry registry = getRegistryManager().get(Registry.DIMENSION_KEY); + + registry.stream().forEach(dimensionOptions -> NetherBiomeData.modifyBiomeSource(getRegistryManager().get(Registry.BIOME_KEY), dimensionOptions.chunkGenerator().getBiomeSource())); } } diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/modification/MinecraftServerMixin.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/modification/MinecraftServerMixin.java index 326e6e525..8acfc053a 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/modification/MinecraftServerMixin.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/modification/MinecraftServerMixin.java @@ -45,6 +45,6 @@ public abstract class MinecraftServerMixin { throw new RuntimeException("Incompatible SaveProperties passed to MinecraftServer: " + saveProperties); } - BiomeModificationImpl.INSTANCE.finalizeWorldGen(getRegistryManager(), levelProperties); + BiomeModificationImpl.INSTANCE.finalizeWorldGen(getRegistryManager()); } } diff --git a/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome/custom_plains.json b/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome/custom_plains.json new file mode 100644 index 000000000..fa8806803 --- /dev/null +++ b/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome/custom_plains.json @@ -0,0 +1,200 @@ +{ + "carvers": { + "air": [ + "minecraft:cave", + "minecraft:cave_extra_underground", + "minecraft:canyon" + ] + }, + "downfall": 0.4, + "effects": { + "fog_color": 12638463, + "mood_sound": { + "block_search_extent": 8, + "offset": 2.0, + "sound": "minecraft:ambient.cave", + "tick_delay": 6000 + }, + "sky_color": 7907327, + "water_color": 4159204, + "water_fog_color": 329011 + }, + "features": [ + [], + [ + "minecraft:lake_lava_underground", + "minecraft:lake_lava_surface" + ], + [ + "minecraft:amethyst_geode" + ], + [ + "minecraft:monster_room", + "minecraft:monster_room_deep" + ], + [], + [], + [ + "minecraft:ore_dirt", + "minecraft:ore_gravel", + "minecraft:ore_granite_upper", + "minecraft:ore_granite_lower", + "minecraft:ore_diorite_upper", + "minecraft:ore_diorite_lower", + "minecraft:ore_andesite_upper", + "minecraft:ore_andesite_lower", + "minecraft:ore_tuff", + "minecraft:ore_coal_upper", + "minecraft:ore_coal_lower", + "minecraft:ore_iron_upper", + "minecraft:ore_iron_middle", + "minecraft:ore_iron_small", + "minecraft:ore_gold", + "minecraft:ore_gold_lower", + "minecraft:ore_redstone", + "minecraft:ore_redstone_lower", + "minecraft:ore_diamond", + "minecraft:ore_diamond_large", + "minecraft:ore_diamond_buried", + "minecraft:ore_lapis", + "minecraft:ore_lapis_buried", + "minecraft:ore_copper", + "minecraft:underwater_magma", + "minecraft:disk_sand", + "minecraft:disk_clay", + "minecraft:disk_gravel" + ], + [], + [ + "minecraft:spring_water", + "minecraft:spring_lava" + ], + [ + "minecraft:glow_lichen", + "minecraft:patch_tall_grass_2", + "minecraft:trees_plains", + "minecraft:flower_plains", + "minecraft:patch_grass_plain", + "minecraft:brown_mushroom_normal", + "minecraft:red_mushroom_normal", + "minecraft:patch_sugar_cane", + "minecraft:patch_pumpkin" + ], + [ + "minecraft:freeze_top_layer" + ] + ], + "precipitation": "rain", + "spawn_costs": {}, + "spawners": { + "ambient": [ + { + "type": "minecraft:bat", + "maxCount": 8, + "minCount": 8, + "weight": 10 + } + ], + "axolotls": [], + "creature": [ + { + "type": "minecraft:sheep", + "maxCount": 4, + "minCount": 4, + "weight": 12 + }, + { + "type": "minecraft:pig", + "maxCount": 4, + "minCount": 4, + "weight": 10 + }, + { + "type": "minecraft:chicken", + "maxCount": 4, + "minCount": 4, + "weight": 10 + }, + { + "type": "minecraft:cow", + "maxCount": 4, + "minCount": 4, + "weight": 8 + }, + { + "type": "minecraft:horse", + "maxCount": 6, + "minCount": 2, + "weight": 5 + }, + { + "type": "minecraft:donkey", + "maxCount": 3, + "minCount": 1, + "weight": 1 + } + ], + "misc": [], + "monster": [ + { + "type": "minecraft:spider", + "maxCount": 4, + "minCount": 4, + "weight": 100 + }, + { + "type": "minecraft:zombie", + "maxCount": 4, + "minCount": 4, + "weight": 95 + }, + { + "type": "minecraft:zombie_villager", + "maxCount": 1, + "minCount": 1, + "weight": 5 + }, + { + "type": "minecraft:skeleton", + "maxCount": 4, + "minCount": 4, + "weight": 100 + }, + { + "type": "minecraft:creeper", + "maxCount": 4, + "minCount": 4, + "weight": 100 + }, + { + "type": "minecraft:slime", + "maxCount": 4, + "minCount": 4, + "weight": 100 + }, + { + "type": "minecraft:enderman", + "maxCount": 4, + "minCount": 1, + "weight": 10 + }, + { + "type": "minecraft:witch", + "maxCount": 1, + "minCount": 1, + "weight": 5 + } + ], + "underground_water_creature": [ + { + "type": "minecraft:glow_squid", + "maxCount": 6, + "minCount": 4, + "weight": 10 + } + ], + "water_ambient": [], + "water_creature": [] + }, + "temperature": 0.8 +} \ No newline at end of file diff --git a/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome/test_crimson_forest.json b/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome/test_crimson_forest.json new file mode 100644 index 000000000..6b89203c7 --- /dev/null +++ b/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome/test_crimson_forest.json @@ -0,0 +1,106 @@ +{ + "carvers": { + "air": "minecraft:nether_cave" + }, + "downfall": 0.0, + "effects": { + "additions_sound": { + "sound": "minecraft:ambient.crimson_forest.additions", + "tick_chance": 0.0111 + }, + "ambient_sound": "minecraft:ambient.crimson_forest.loop", + "fog_color": 3343107, + "mood_sound": { + "block_search_extent": 8, + "offset": 2.0, + "sound": "minecraft:ambient.crimson_forest.mood", + "tick_delay": 6000 + }, + "music": { + "max_delay": 24000, + "min_delay": 12000, + "replace_current_music": false, + "sound": "minecraft:music.nether.crimson_forest" + }, + "particle": { + "options": { + "type": "minecraft:crimson_spore" + }, + "probability": 0.025 + }, + "sky_color": 7254527, + "water_color": 4159204, + "water_fog_color": 329011 + }, + "features": [ + [], + [], + [], + [], + [], + [], + [], + [ + "minecraft:spring_open", + "minecraft:patch_fire", + "minecraft:glowstone_extra", + "minecraft:glowstone", + "minecraft:ore_magma", + "minecraft:spring_closed", + "minecraft:ore_gravel_nether", + "minecraft:ore_blackstone", + "minecraft:ore_gold_nether", + "minecraft:ore_quartz_nether", + "minecraft:ore_ancient_debris_large", + "minecraft:ore_debris_small" + ], + [], + [ + "minecraft:spring_lava", + "minecraft:brown_mushroom_normal", + "minecraft:red_mushroom_normal", + "minecraft:weeping_vines", + "minecraft:crimson_fungi", + "minecraft:crimson_forest_vegetation" + ] + ], + "precipitation": "none", + "spawn_costs": {}, + "spawners": { + "ambient": [], + "axolotls": [], + "creature": [ + { + "type": "minecraft:strider", + "maxCount": 2, + "minCount": 1, + "weight": 60 + } + ], + "misc": [], + "monster": [ + { + "type": "minecraft:zombified_piglin", + "maxCount": 4, + "minCount": 2, + "weight": 1 + }, + { + "type": "minecraft:hoglin", + "maxCount": 4, + "minCount": 3, + "weight": 9 + }, + { + "type": "minecraft:piglin", + "maxCount": 4, + "minCount": 3, + "weight": 5 + } + ], + "underground_water_creature": [], + "water_ambient": [], + "water_creature": [] + }, + "temperature": 2.0 +} \ No newline at end of file diff --git a/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome/test_end_barrens.json b/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome/test_end_barrens.json new file mode 100644 index 000000000..f2a4e2e51 --- /dev/null +++ b/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome/test_end_barrens.json @@ -0,0 +1,130 @@ +{ + "carvers": {}, + "downfall": 0.5, + "effects": { + "fog_color": 10518688, + "mood_sound": { + "block_search_extent": 8, + "offset": 2.0, + "sound": "minecraft:ambient.cave", + "tick_delay": 6000 + }, + "sky_color": 0, + "water_color": 4159204, + "water_fog_color": 329011 + }, + "features": [], + "precipitation": "none", + "spawn_costs": {}, + "spawners": { + "ambient": [ + { + "type": "minecraft:bat", + "maxCount": 8, + "minCount": 8, + "weight": 10 + } + ], + "axolotls": [], + "creature": [ + { + "type": "minecraft:sheep", + "maxCount": 4, + "minCount": 4, + "weight": 12 + }, + { + "type": "minecraft:pig", + "maxCount": 4, + "minCount": 4, + "weight": 10 + }, + { + "type": "minecraft:chicken", + "maxCount": 4, + "minCount": 4, + "weight": 10 + }, + { + "type": "minecraft:cow", + "maxCount": 4, + "minCount": 4, + "weight": 8 + }, + { + "type": "minecraft:horse", + "maxCount": 6, + "minCount": 2, + "weight": 5 + }, + { + "type": "minecraft:donkey", + "maxCount": 3, + "minCount": 1, + "weight": 1 + } + ], + "misc": [], + "monster": [ + { + "type": "minecraft:spider", + "maxCount": 4, + "minCount": 4, + "weight": 100 + }, + { + "type": "minecraft:zombie", + "maxCount": 4, + "minCount": 4, + "weight": 95 + }, + { + "type": "minecraft:zombie_villager", + "maxCount": 1, + "minCount": 1, + "weight": 5 + }, + { + "type": "minecraft:skeleton", + "maxCount": 4, + "minCount": 4, + "weight": 100 + }, + { + "type": "minecraft:creeper", + "maxCount": 4, + "minCount": 4, + "weight": 100 + }, + { + "type": "minecraft:slime", + "maxCount": 4, + "minCount": 4, + "weight": 100 + }, + { + "type": "minecraft:enderman", + "maxCount": 4, + "minCount": 1, + "weight": 10 + }, + { + "type": "minecraft:witch", + "maxCount": 1, + "minCount": 1, + "weight": 5 + } + ], + "underground_water_creature": [ + { + "type": "minecraft:glow_squid", + "maxCount": 6, + "minCount": 4, + "weight": 10 + } + ], + "water_ambient": [], + "water_creature": [] + }, + "temperature": 0.5 +} \ No newline at end of file diff --git a/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome/test_end_highlands.json b/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome/test_end_highlands.json new file mode 100644 index 000000000..b0955e233 --- /dev/null +++ b/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome/test_end_highlands.json @@ -0,0 +1,138 @@ +{ + "carvers": {}, + "downfall": 0.5, + "effects": { + "fog_color": 10518688, + "mood_sound": { + "block_search_extent": 8, + "offset": 2.0, + "sound": "minecraft:ambient.cave", + "tick_delay": 6000 + }, + "sky_color": 0, + "water_color": 4159204, + "water_fog_color": 329011 + }, + "features": [ + [], + [], + [], + [], + [ + "minecraft:end_gateway_return" + ] + ], + "precipitation": "none", + "spawn_costs": {}, + "spawners": { + "ambient": [ + { + "type": "minecraft:bat", + "maxCount": 8, + "minCount": 8, + "weight": 10 + } + ], + "axolotls": [], + "creature": [ + { + "type": "minecraft:sheep", + "maxCount": 4, + "minCount": 4, + "weight": 12 + }, + { + "type": "minecraft:pig", + "maxCount": 4, + "minCount": 4, + "weight": 10 + }, + { + "type": "minecraft:chicken", + "maxCount": 4, + "minCount": 4, + "weight": 10 + }, + { + "type": "minecraft:cow", + "maxCount": 4, + "minCount": 4, + "weight": 8 + }, + { + "type": "minecraft:horse", + "maxCount": 6, + "minCount": 2, + "weight": 5 + }, + { + "type": "minecraft:donkey", + "maxCount": 3, + "minCount": 1, + "weight": 1 + } + ], + "misc": [], + "monster": [ + { + "type": "minecraft:spider", + "maxCount": 4, + "minCount": 4, + "weight": 100 + }, + { + "type": "minecraft:zombie", + "maxCount": 4, + "minCount": 4, + "weight": 95 + }, + { + "type": "minecraft:zombie_villager", + "maxCount": 1, + "minCount": 1, + "weight": 5 + }, + { + "type": "minecraft:skeleton", + "maxCount": 4, + "minCount": 4, + "weight": 100 + }, + { + "type": "minecraft:creeper", + "maxCount": 4, + "minCount": 4, + "weight": 100 + }, + { + "type": "minecraft:slime", + "maxCount": 4, + "minCount": 4, + "weight": 100 + }, + { + "type": "minecraft:enderman", + "maxCount": 4, + "minCount": 1, + "weight": 10 + }, + { + "type": "minecraft:witch", + "maxCount": 1, + "minCount": 1, + "weight": 5 + } + ], + "underground_water_creature": [ + { + "type": "minecraft:glow_squid", + "maxCount": 6, + "minCount": 4, + "weight": 10 + } + ], + "water_ambient": [], + "water_creature": [] + }, + "temperature": 0.5 +} \ No newline at end of file diff --git a/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome/test_end_midlands.json b/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome/test_end_midlands.json new file mode 100644 index 000000000..f2a4e2e51 --- /dev/null +++ b/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/biome/test_end_midlands.json @@ -0,0 +1,130 @@ +{ + "carvers": {}, + "downfall": 0.5, + "effects": { + "fog_color": 10518688, + "mood_sound": { + "block_search_extent": 8, + "offset": 2.0, + "sound": "minecraft:ambient.cave", + "tick_delay": 6000 + }, + "sky_color": 0, + "water_color": 4159204, + "water_fog_color": 329011 + }, + "features": [], + "precipitation": "none", + "spawn_costs": {}, + "spawners": { + "ambient": [ + { + "type": "minecraft:bat", + "maxCount": 8, + "minCount": 8, + "weight": 10 + } + ], + "axolotls": [], + "creature": [ + { + "type": "minecraft:sheep", + "maxCount": 4, + "minCount": 4, + "weight": 12 + }, + { + "type": "minecraft:pig", + "maxCount": 4, + "minCount": 4, + "weight": 10 + }, + { + "type": "minecraft:chicken", + "maxCount": 4, + "minCount": 4, + "weight": 10 + }, + { + "type": "minecraft:cow", + "maxCount": 4, + "minCount": 4, + "weight": 8 + }, + { + "type": "minecraft:horse", + "maxCount": 6, + "minCount": 2, + "weight": 5 + }, + { + "type": "minecraft:donkey", + "maxCount": 3, + "minCount": 1, + "weight": 1 + } + ], + "misc": [], + "monster": [ + { + "type": "minecraft:spider", + "maxCount": 4, + "minCount": 4, + "weight": 100 + }, + { + "type": "minecraft:zombie", + "maxCount": 4, + "minCount": 4, + "weight": 95 + }, + { + "type": "minecraft:zombie_villager", + "maxCount": 1, + "minCount": 1, + "weight": 5 + }, + { + "type": "minecraft:skeleton", + "maxCount": 4, + "minCount": 4, + "weight": 100 + }, + { + "type": "minecraft:creeper", + "maxCount": 4, + "minCount": 4, + "weight": 100 + }, + { + "type": "minecraft:slime", + "maxCount": 4, + "minCount": 4, + "weight": 100 + }, + { + "type": "minecraft:enderman", + "maxCount": 4, + "minCount": 1, + "weight": 10 + }, + { + "type": "minecraft:witch", + "maxCount": 1, + "minCount": 1, + "weight": 5 + } + ], + "underground_water_creature": [ + { + "type": "minecraft:glow_squid", + "maxCount": 6, + "minCount": 4, + "weight": 10 + } + ], + "water_ambient": [], + "water_creature": [] + }, + "temperature": 0.5 +} \ No newline at end of file diff --git a/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/configured_feature/fab_desert_well.json b/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/configured_feature/fab_desert_well.json new file mode 100644 index 000000000..f0f1ba227 --- /dev/null +++ b/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/configured_feature/fab_desert_well.json @@ -0,0 +1,4 @@ +{ + "type": "minecraft:desert_well", + "config": {} +} \ No newline at end of file diff --git a/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/placed_feature/fab_desert_well.json b/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/placed_feature/fab_desert_well.json new file mode 100644 index 000000000..ac34b18f0 --- /dev/null +++ b/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/placed_feature/fab_desert_well.json @@ -0,0 +1,15 @@ +{ + "feature": "fabric-biome-api-v1-testmod:fab_desert_well", + "placement": [ + { + "type": "minecraft:in_square" + }, + { + "type": "minecraft:heightmap", + "heightmap": "MOTION_BLOCKING" + }, + { + "type": "minecraft:biome" + } + ] +} \ No newline at end of file diff --git a/fabric-textures-v0/src/client/java/net/fabricmc/fabric/impl/client/texture/FabricSprite.java b/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/DataGeneratorEntrypoint.java similarity index 57% rename from fabric-textures-v0/src/client/java/net/fabricmc/fabric/impl/client/texture/FabricSprite.java rename to fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/DataGeneratorEntrypoint.java index 33aba5414..10a82ff1d 100644 --- a/fabric-textures-v0/src/client/java/net/fabricmc/fabric/impl/client/texture/FabricSprite.java +++ b/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/DataGeneratorEntrypoint.java @@ -14,14 +14,14 @@ * limitations under the License. */ -package net.fabricmc.fabric.impl.client.texture; +package net.fabricmc.fabric.test.biome; -import net.minecraft.client.texture.NativeImage; -import net.minecraft.client.texture.Sprite; -import net.minecraft.client.texture.SpriteAtlasTexture; +import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricBuiltinRegistriesProvider; -public class FabricSprite extends Sprite { - public FabricSprite(SpriteAtlasTexture spriteAtlasTexture, Sprite.Info info, int mipmap, int u, int v, int x, int y, NativeImage nativeImage) { - super(spriteAtlasTexture, info, mipmap, u, v, x, y, nativeImage); +public class DataGeneratorEntrypoint implements net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint { + @Override + public void onInitializeDataGenerator(FabricDataGenerator dataGenerator) { + dataGenerator.addProvider(FabricBuiltinRegistriesProvider.forCurrentMod()); } } diff --git a/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/FabricBiomeTest.java b/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/FabricBiomeTest.java index d69e19724..49d541ddd 100644 --- a/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/FabricBiomeTest.java +++ b/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/FabricBiomeTest.java @@ -71,16 +71,16 @@ public class FabricBiomeTest implements ModInitializer { private static final RegistryKey TEST_END_BARRRENS = RegistryKey.of(Registry.BIOME_KEY, new Identifier(MOD_ID, "test_end_barrens")); @Override public void onInitialize() { - Registry.register(BuiltinRegistries.BIOME, TEST_CRIMSON_FOREST.getValue(), TheNetherBiomeCreator.createCrimsonForest()); + BuiltinRegistries.add(BuiltinRegistries.BIOME, TEST_CRIMSON_FOREST.getValue(), TheNetherBiomeCreator.createCrimsonForest()); NetherBiomes.addNetherBiome(BiomeKeys.PLAINS, MultiNoiseUtil.createNoiseHypercube(0.0F, 0.5F, 0.0F, 0.0F, 0.0f, 0, 0.1F)); NetherBiomes.addNetherBiome(TEST_CRIMSON_FOREST, MultiNoiseUtil.createNoiseHypercube(0.0F, -0.15F, 0.0f, 0.0F, 0.0f, 0.0F, 0.2F)); - Registry.register(BuiltinRegistries.BIOME, CUSTOM_PLAINS.getValue(), OverworldBiomeCreator.createPlains(false, false, false)); + BuiltinRegistries.add(BuiltinRegistries.BIOME, CUSTOM_PLAINS.getValue(), OverworldBiomeCreator.createPlains(false, false, false)); - Registry.register(BuiltinRegistries.BIOME, TEST_END_HIGHLANDS.getValue(), createEndHighlands()); - Registry.register(BuiltinRegistries.BIOME, TEST_END_MIDLANDS.getValue(), createEndMidlands()); - Registry.register(BuiltinRegistries.BIOME, TEST_END_BARRRENS.getValue(), createEndBarrens()); + BuiltinRegistries.add(BuiltinRegistries.BIOME, TEST_END_HIGHLANDS.getValue(), createEndHighlands()); + BuiltinRegistries.add(BuiltinRegistries.BIOME, TEST_END_MIDLANDS.getValue(), createEndMidlands()); + BuiltinRegistries.add(BuiltinRegistries.BIOME, TEST_END_BARRRENS.getValue(), createEndBarrens()); // TESTING HINT: to get to the end: // /execute in minecraft:the_end run tp @s 0 90 0 @@ -90,12 +90,12 @@ public class FabricBiomeTest implements ModInitializer { TheEndBiomes.addBarrensBiome(TEST_END_HIGHLANDS, TEST_END_BARRRENS, 10.0); ConfiguredFeature COMMON_DESERT_WELL = new ConfiguredFeature<>(Feature.DESERT_WELL, DefaultFeatureConfig.INSTANCE); - Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier(MOD_ID, "fab_desert_well"), COMMON_DESERT_WELL); + BuiltinRegistries.add(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier(MOD_ID, "fab_desert_well"), COMMON_DESERT_WELL); RegistryEntry> featureEntry = BuiltinRegistries.CONFIGURED_FEATURE.getOrCreateEntry(BuiltinRegistries.CONFIGURED_FEATURE.getKey(COMMON_DESERT_WELL).orElseThrow()); // The placement config is taken from the vanilla desert well, but no randomness PlacedFeature PLACED_COMMON_DESERT_WELL = new PlacedFeature(featureEntry, List.of(SquarePlacementModifier.of(), PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, BiomePlacementModifier.of())); - Registry.register(BuiltinRegistries.PLACED_FEATURE, new Identifier(MOD_ID, "fab_desert_well"), PLACED_COMMON_DESERT_WELL); + BuiltinRegistries.add(BuiltinRegistries.PLACED_FEATURE, new Identifier(MOD_ID, "fab_desert_well"), PLACED_COMMON_DESERT_WELL); BiomeModifications.create(new Identifier("fabric:test_mod")) .add(ModificationPhase.ADDITIONS, diff --git a/fabric-biome-api-v1/src/testmod/resources/fabric.mod.json b/fabric-biome-api-v1/src/testmod/resources/fabric.mod.json index b3fbb654b..bfae85359 100644 --- a/fabric-biome-api-v1/src/testmod/resources/fabric.mod.json +++ b/fabric-biome-api-v1/src/testmod/resources/fabric.mod.json @@ -11,6 +11,9 @@ "entrypoints": { "main": [ "net.fabricmc.fabric.test.biome.FabricBiomeTest" + ], + "fabric-datagen": [ + "net.fabricmc.fabric.test.biome.DataGeneratorEntrypoint" ] } } diff --git a/fabric-command-api-v2/src/client/java/net/fabricmc/fabric/mixin/command/client/ClientPlayNetworkHandlerMixin.java b/fabric-command-api-v2/src/client/java/net/fabricmc/fabric/mixin/command/client/ClientPlayNetworkHandlerMixin.java index c6fc1045f..83eb5604f 100644 --- a/fabric-command-api-v2/src/client/java/net/fabricmc/fabric/mixin/command/client/ClientPlayNetworkHandlerMixin.java +++ b/fabric-command-api-v2/src/client/java/net/fabricmc/fabric/mixin/command/client/ClientPlayNetworkHandlerMixin.java @@ -23,13 +23,17 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import net.minecraft.client.network.ClientCommandSource; +import net.minecraft.client.network.ClientDynamicRegistryType; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.command.CommandRegistryAccess; import net.minecraft.command.CommandSource; import net.minecraft.network.packet.s2c.play.CommandTreeS2CPacket; import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket; +import net.minecraft.resource.featuretoggle.FeatureSet; +import net.minecraft.util.registry.CombinedDynamicRegistries; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; @@ -44,11 +48,17 @@ abstract class ClientPlayNetworkHandlerMixin { @Final private ClientCommandSource commandSource; + @Shadow + private FeatureSet field_40482; + + @Shadow + private CombinedDynamicRegistries registryManager; + @Inject(method = "onGameJoin", at = @At("RETURN")) private void onGameJoin(GameJoinS2CPacket packet, CallbackInfo info) { final CommandDispatcher dispatcher = new CommandDispatcher<>(); ClientCommandInternals.setActiveDispatcher(dispatcher); - ClientCommandRegistrationCallback.EVENT.invoker().register(dispatcher, new CommandRegistryAccess(packet.registryManager())); + ClientCommandRegistrationCallback.EVENT.invoker().register(dispatcher, new CommandRegistryAccess(this.registryManager.getCombinedRegistryManager(), this.field_40482)); ClientCommandInternals.finalizeInit(); } @@ -60,4 +70,18 @@ abstract class ClientPlayNetworkHandlerMixin { // to be in the same dispatcher and completion results. ClientCommandInternals.addCommands((CommandDispatcher) commandDispatcher, (FabricClientCommandSource) commandSource); } + + @Inject(method = "method_45731", at = @At("HEAD"), cancellable = true) + private void onSendCommand(String command, CallbackInfoReturnable cir) { + if (ClientCommandInternals.executeCommand(command)) { + cir.setReturnValue(true); + } + } + + @Inject(method = "method_45730", at = @At("HEAD"), cancellable = true) + private void onSendCommand(String command, CallbackInfo info) { + if (ClientCommandInternals.executeCommand(command)) { + info.cancel(); + } + } } diff --git a/fabric-command-api-v2/src/client/java/net/fabricmc/fabric/mixin/command/client/ClientPlayerEntityMixin.java b/fabric-command-api-v2/src/client/java/net/fabricmc/fabric/mixin/command/client/ClientPlayerEntityMixin.java deleted file mode 100644 index b21a8ca4c..000000000 --- a/fabric-command-api-v2/src/client/java/net/fabricmc/fabric/mixin/command/client/ClientPlayerEntityMixin.java +++ /dev/null @@ -1,45 +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.command.client; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.text.Text; - -import net.fabricmc.fabric.impl.command.client.ClientCommandInternals; - -@Mixin(ClientPlayerEntity.class) -abstract class ClientPlayerEntityMixin { - @Inject(method = "sendCommand(Ljava/lang/String;)Z", at = @At("HEAD"), cancellable = true) - private void onSendCommand(String command, CallbackInfoReturnable cir) { - if (ClientCommandInternals.executeCommand(command)) { - cir.setReturnValue(true); - } - } - - @Inject(method = "sendCommand(Ljava/lang/String;Lnet/minecraft/text/Text;)V", at = @At("HEAD"), cancellable = true) - private void onSendCommand(String command, Text preview, CallbackInfo info) { - if (ClientCommandInternals.executeCommand(command)) { - info.cancel(); - } - } -} diff --git a/fabric-command-api-v2/src/client/resources/fabric-command-api-v2.client.mixins.json b/fabric-command-api-v2/src/client/resources/fabric-command-api-v2.client.mixins.json index 2a119e8a0..2eef11336 100644 --- a/fabric-command-api-v2/src/client/resources/fabric-command-api-v2.client.mixins.json +++ b/fabric-command-api-v2/src/client/resources/fabric-command-api-v2.client.mixins.json @@ -4,7 +4,6 @@ "compatibilityLevel": "JAVA_16", "client": [ "ClientCommandSourceMixin", - "ClientPlayerEntityMixin", "ClientPlayNetworkHandlerMixin" ], "injectors": { diff --git a/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/api/registry/SculkSensorFrequencyRegistry.java b/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/api/registry/SculkSensorFrequencyRegistry.java index 87b251d89..53c169768 100644 --- a/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/api/registry/SculkSensorFrequencyRegistry.java +++ b/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/api/registry/SculkSensorFrequencyRegistry.java @@ -19,9 +19,9 @@ package net.fabricmc.fabric.api.registry; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.minecraft.block.SculkSensorBlock; import net.minecraft.tag.GameEventTags; import net.minecraft.world.event.GameEvent; +import net.minecraft.world.event.listener.VibrationListener; /** * Provides a method for registering sculk sensor frequencies. @@ -51,7 +51,7 @@ public final class SculkSensorFrequencyRegistry { throw new IllegalArgumentException("Attempted to register Sculk Sensor frequency for event "+event.getId()+" with frequency "+frequency+". Sculk Sensor frequencies must be between 1 and 15 inclusive."); } - int replaced = SculkSensorBlock.FREQUENCIES.put(event, frequency); + int replaced = VibrationListener.field_40356.put(event, frequency); if (replaced != 0) { LOGGER.debug("Replaced old frequency mapping for {} - was {}, now {}", event.getId(), replaced, frequency); diff --git a/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/mixin/content/registry/SculkSensorBlockMixin.java b/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/mixin/content/registry/VibrationListenerMixin.java similarity index 91% rename from fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/mixin/content/registry/SculkSensorBlockMixin.java rename to fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/mixin/content/registry/VibrationListenerMixin.java index fbb807b83..6fcb80210 100644 --- a/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/mixin/content/registry/SculkSensorBlockMixin.java +++ b/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/mixin/content/registry/VibrationListenerMixin.java @@ -23,9 +23,10 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; import net.minecraft.block.SculkSensorBlock; +import net.minecraft.world.event.listener.VibrationListener; -@Mixin(SculkSensorBlock.class) -public class SculkSensorBlockMixin { +@Mixin(VibrationListener.class) +public class VibrationListenerMixin { /** * Redirects the call to {@linkplain Object2IntMaps#unmodifiable(Object2IntMap)} in initialization of {@linkplain SculkSensorBlock#FREQUENCIES}. */ diff --git a/fabric-content-registries-v0/src/main/resources/fabric-content-registries-v0.mixins.json b/fabric-content-registries-v0/src/main/resources/fabric-content-registries-v0.mixins.json index ed71d45e9..f9eaf7dd0 100644 --- a/fabric-content-registries-v0/src/main/resources/fabric-content-registries-v0.mixins.json +++ b/fabric-content-registries-v0/src/main/resources/fabric-content-registries-v0.mixins.json @@ -13,7 +13,7 @@ "AbstractFurnaceBlockEntityMixin", "FireBlockMixin", "OxidizableMixin", - "SculkSensorBlockMixin", + "VibrationListenerMixin", "ShovelItemAccessor", "VillagerEntityAccessor", "VillagerEntityMixin" diff --git a/fabric-data-generation-api-v1/build.gradle b/fabric-data-generation-api-v1/build.gradle index 8b335766b..7506fe753 100644 --- a/fabric-data-generation-api-v1/build.gradle +++ b/fabric-data-generation-api-v1/build.gradle @@ -6,7 +6,7 @@ moduleDependencies(project, [ 'fabric-registry-sync-v0', 'fabric-networking-api-v1', 'fabric-resource-conditions-api-v1', - 'fabric-item-groups-v0' + 'fabric-item-group-api-v1' ]) dependencies { @@ -63,7 +63,7 @@ task generateAccessWidener() { File inputJar = loom.namedMinecraftProvider.parentMinecraftProvider.commonJar.toFile() String accessWidener = file("template.accesswidener").text + "\n" - visitMethods(inputJar, "net/minecraft/data/server/RecipeProvider.class") { name, desc, owner -> + visitMethods(inputJar, "net/minecraft/data/server/recipe/RecipeProvider.class") { name, desc, owner -> if (it.name == "generate") return @@ -78,7 +78,7 @@ task generateAccessWidener() { accessWidener += "transitive-accessible\tmethod\t${owner}\t${name}\t${desc}\n" } - visitMethods(inputJar, "net/minecraft/data/server/BlockLootTableGenerator.class") { name, desc, owner -> + visitMethods(inputJar, "net/minecraft/data/server/loottable/BlockLootTableGenerator.class") { name, desc, owner -> accessWidener += "transitive-accessible\tmethod\t${owner}\t${name}\t${desc}\n" } diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/FabricDataGenerator.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/FabricDataGenerator.java index 526292325..b68b705b7 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/FabricDataGenerator.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/FabricDataGenerator.java @@ -17,7 +17,6 @@ package net.fabricmc.fabric.api.datagen.v1; import java.nio.file.Path; -import java.util.Collections; import java.util.Objects; import java.util.function.Function; @@ -25,8 +24,10 @@ import org.jetbrains.annotations.ApiStatus; import net.minecraft.SharedConstants; import net.minecraft.data.DataGenerator; +import net.minecraft.data.DataOutput; import net.minecraft.data.DataProvider; +import net.fabricmc.fabric.impl.datagen.FabricDataOutput; import net.fabricmc.loader.api.ModContainer; /** @@ -38,9 +39,16 @@ public final class FabricDataGenerator extends DataGenerator { @ApiStatus.Internal public FabricDataGenerator(Path output, ModContainer mod, boolean strictValidation) { - super(output, Collections.emptyList(), SharedConstants.getGameVersion(), true); + super(output, SharedConstants.getGameVersion(), true); this.modContainer = Objects.requireNonNull(mod); this.strictValidation = strictValidation; + + this.output = new FabricDataOutput(this, output); + } + + @Override + public DataOutput getOutputFor(String packName) { + return new FabricDataOutput(this, super.getOutputFor(packName).getPath()); } /** diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricAdvancementProvider.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricAdvancementProvider.java index 50605a4c1..b1b20e760 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricAdvancementProvider.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricAdvancementProvider.java @@ -26,7 +26,7 @@ import com.google.common.collect.Sets; import com.google.gson.JsonObject; import net.minecraft.advancement.Advancement; -import net.minecraft.data.DataGenerator; +import net.minecraft.data.DataOutput; import net.minecraft.data.DataProvider; import net.minecraft.data.DataWriter; import net.minecraft.util.Identifier; @@ -42,11 +42,11 @@ import net.fabricmc.fabric.impl.datagen.FabricDataGenHelper; */ public abstract class FabricAdvancementProvider implements DataProvider { protected final FabricDataGenerator dataGenerator; - private final DataGenerator.PathResolver pathResolver; + private final DataOutput.PathResolver pathResolver; protected FabricAdvancementProvider(FabricDataGenerator dataGenerator) { this.dataGenerator = dataGenerator; - this.pathResolver = dataGenerator.createPathResolver(DataGenerator.OutputType.DATA_PACK, "advancements"); + this.pathResolver = dataGenerator.getOutput().getResolver(DataOutput.OutputType.DATA_PACK, "advancements"); } /** @@ -87,7 +87,7 @@ public abstract class FabricAdvancementProvider implements DataProvider { } private Path getOutputPath(Advancement advancement) { - return dataGenerator.getOutput().resolve("data/%s/advancements/%s.json".formatted(advancement.getId().getNamespace(), advancement.getId().getPath())); + return pathResolver.resolveJson(advancement.getId()); } @Override 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 df763ebed..565797dd5 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 @@ -16,6 +16,7 @@ package net.fabricmc.fabric.api.datagen.v1.provider; +import java.util.Collections; import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -24,18 +25,19 @@ import java.util.function.BiConsumer; import com.google.common.collect.Sets; import net.minecraft.block.Block; -import net.minecraft.data.server.BlockLootTableGenerator; +import net.minecraft.data.server.loottable.BlockLootTableGenerator; import net.minecraft.loot.LootTable; import net.minecraft.loot.LootTables; import net.minecraft.loot.context.LootContextType; import net.minecraft.loot.context.LootContextTypes; +import net.minecraft.resource.featuretoggle.FeatureFlags; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; /** - * Extend this class and implement {@link FabricBlockLootTableProvider#generateBlockLootTables}. + * Extend this class and implement {@link FabricBlockLootTableProvider#generate}. * *

Register an instance of the class with {@link FabricDataGenerator#addProvider} in a {@link net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint} */ @@ -44,6 +46,7 @@ public abstract class FabricBlockLootTableProvider extends BlockLootTableGenerat private final Set excludedFromStrictValidation = new HashSet<>(); protected FabricBlockLootTableProvider(FabricDataGenerator dataGenerator) { + super(Collections.emptySet(), FeatureFlags.FEATURE_MANAGER.getFeatureSet()); this.dataGenerator = dataGenerator; } @@ -52,7 +55,8 @@ public abstract class FabricBlockLootTableProvider extends BlockLootTableGenerat * *

Use the range of {@link BlockLootTableGenerator#addDrop} methods to generate block drops. */ - protected abstract void generateBlockLootTables(); + @Override + public abstract void generate(); /** * Disable strict validation for the passed block. @@ -73,7 +77,7 @@ public abstract class FabricBlockLootTableProvider extends BlockLootTableGenerat @Override public void accept(BiConsumer biConsumer) { - generateBlockLootTables(); + generate(); for (Map.Entry entry : lootTables.entrySet()) { Identifier identifier = entry.getKey(); diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricBuiltinRegistriesProvider.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricBuiltinRegistriesProvider.java new file mode 100644 index 000000000..65262a690 --- /dev/null +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricBuiltinRegistriesProvider.java @@ -0,0 +1,115 @@ +/* + * 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.datagen.v1.provider; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.Map; +import java.util.Optional; +import java.util.function.Function; +import java.util.function.Predicate; + +import com.google.gson.JsonElement; +import com.mojang.serialization.DynamicOps; +import com.mojang.serialization.Encoder; +import com.mojang.serialization.JsonOps; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.minecraft.data.DataOutput; +import net.minecraft.data.DataProvider; +import net.minecraft.data.DataWriter; +import net.minecraft.data.report.WorldgenProvider; +import net.minecraft.util.dynamic.RegistryOps; +import net.minecraft.util.registry.BuiltinRegistries; +import net.minecraft.util.registry.DynamicRegistryManager; +import net.minecraft.util.registry.Registry; +import net.minecraft.util.registry.RegistryKey; +import net.minecraft.util.registry.RegistryLoader; + +import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; + +/** + * Data-generates all entries from {@link BuiltinRegistries} that matches a given filter (i.e. mod id). + * + * @see WorldgenProvider For Vanilla's data provider that does the same for the entire registry. + */ +public class FabricBuiltinRegistriesProvider implements DataProvider { + private static final Logger LOGGER = LoggerFactory.getLogger(FabricBuiltinRegistriesProvider.class); + + private final Predicate> entryFilter; + private final DataOutput output; + + private FabricBuiltinRegistriesProvider(DataOutput output, Predicate> entryFilter) { + this.output = output; + this.entryFilter = entryFilter; + } + + /** + * @return A provider that will export all entries from {@link BuiltinRegistries} for the mod running the + * data generation. + */ + public static Function forCurrentMod() { + return fabricDataGenerator -> new FabricBuiltinRegistriesProvider( + fabricDataGenerator.getOutput(), + e -> e.getValue().getNamespace().equals(fabricDataGenerator.getModId()) + ); + } + + @Override + public void run(DataWriter writer) { + DynamicRegistryManager dynamicRegistryManager = BuiltinRegistries.createBuiltinRegistryManager(); + DynamicOps dynamicOps = RegistryOps.of(JsonOps.INSTANCE, dynamicRegistryManager); + RegistryLoader.DYNAMIC_REGISTRIES.forEach((info) -> this.writeRegistryEntries(writer, dynamicRegistryManager, dynamicOps, info)); + } + + private void writeRegistryEntries(DataWriter writer, DynamicRegistryManager registryManager, DynamicOps ops, RegistryLoader.Entry registry) { + RegistryKey> registryKey = registry.key(); + Registry registry2 = registryManager.get(registryKey); + DataOutput.PathResolver pathResolver = this.output.getResolver(DataOutput.OutputType.DATA_PACK, registryKey.getValue().getPath()); + + for (Map.Entry, T> regEntry : registry2.getEntrySet()) { + RegistryKey key = regEntry.getKey(); + + if (!entryFilter.test(key)) { + continue; + } + + Path path = pathResolver.resolveJson(key.getValue()); + writeToPath(path, writer, ops, registry.elementCodec(), regEntry.getValue()); + } + } + + private static void writeToPath(Path path, DataWriter cache, DynamicOps json, Encoder encoder, E value) { + try { + Optional optional = encoder.encodeStart(json, value).resultOrPartial((error) -> { + LOGGER.error("Couldn't serialize element {}: {}", path, error); + }); + + if (optional.isPresent()) { + DataProvider.writeToPath(cache, optional.get(), path); + } + } catch (IOException var6) { + LOGGER.error("Couldn't save element {}", path, var6); + } + } + + @Override + public String getName() { + return "Built-In Registry Content"; + } +} 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 473563276..33867a639 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 @@ -29,6 +29,7 @@ import com.google.gson.JsonParser; import org.jetbrains.annotations.ApiStatus; import net.minecraft.block.Block; +import net.minecraft.data.DataOutput; import net.minecraft.data.DataProvider; import net.minecraft.data.DataWriter; import net.minecraft.enchantment.Enchantment; @@ -93,7 +94,9 @@ public abstract class FabricLanguageProvider implements DataProvider { } private Path getLangFilePath(String code) { - return dataGenerator.getOutput().resolve("assets/%s/lang/%s.json".formatted(dataGenerator.getModId(), code)); + return dataGenerator.getOutput() + .getResolver(DataOutput.OutputType.RESOURCE_PACK, "lang") + .resolveJson(new Identifier(dataGenerator.getModId(), code)); } @Override @@ -110,22 +113,24 @@ public abstract class FabricLanguageProvider implements DataProvider { /** * Adds a translation. * - * @param translationKey The key of the translation. - * @param value The value of the entry. + * @param translationKey The key of the translation. + * @param value The value of the entry. */ void add(String translationKey, String value); /** * Adds a translation for an {@link Item}. - * @param item The {@link Item} to get the translation key from. + * + * @param item The {@link Item} to get the translation key from. * @param value The value of the entry. */ default void add(Item item, String value) { add(item.getTranslationKey(), value); - }; + } /** * Adds a translation for a {@link Block}. + * * @param block The {@link Block} to get the translation key from. * @param value The value of the entry. */ @@ -135,17 +140,19 @@ public abstract class FabricLanguageProvider implements DataProvider { /** * Adds a translation for an {@link ItemGroup}. + * * @param group The {@link ItemGroup} to get the translation key from. * @param value The value of the entry. */ default void add(ItemGroup group, String value) { - add("itemGroup." + group.getName(), value); + add(group.getDisplayName().toString(), value); } /** * Adds a translation for an {@link EntityType}. + * * @param entityType The {@link EntityType} to get the translation key from. - * @param value The value of the entry. + * @param value The value of the entry. */ default void add(EntityType entityType, String value) { add(entityType.getTranslationKey(), value); @@ -153,8 +160,9 @@ public abstract class FabricLanguageProvider implements DataProvider { /** * Adds a translation for an {@link Enchantment}. + * * @param enchantment The {@link Enchantment} to get the translation key from. - * @param value The value of the entry. + * @param value The value of the entry. */ default void add(Enchantment enchantment, String value) { add(enchantment.getTranslationKey(), value); @@ -162,8 +170,9 @@ public abstract class FabricLanguageProvider implements DataProvider { /** * Adds a translation for an {@link EntityAttribute}. + * * @param entityAttribute The {@link EntityAttribute} to get the translation key from. - * @param value The value of the entry. + * @param value The value of the entry. */ default void add(EntityAttribute entityAttribute, String value) { add(entityAttribute.getTranslationKey(), value); @@ -171,8 +180,9 @@ public abstract class FabricLanguageProvider implements DataProvider { /** * Adds a translation for a {@link StatType}. + * * @param statType The {@link StatType} to get the translation key from. - * @param value The value of the entry. + * @param value The value of the entry. */ default void add(StatType statType, String value) { add(statType.getTranslationKey(), value); @@ -180,8 +190,9 @@ public abstract class FabricLanguageProvider implements DataProvider { /** * Adds a translation for a {@link StatusEffect}. + * * @param statusEffect The {@link StatusEffect} to get the translation key from. - * @param value The value of the entry. + * @param value The value of the entry. */ default void add(StatusEffect statusEffect, String value) { add(statusEffect.getTranslationKey(), value); @@ -189,8 +200,9 @@ public abstract class FabricLanguageProvider implements DataProvider { /** * Adds a translation for an {@link Identifier}. + * * @param identifier The {@link Identifier} to get the translation key from. - * @param value The value of the entry. + * @param value The value of the entry. */ default void add(Identifier identifier, String value) { add(identifier.toTranslationKey(), value); @@ -198,6 +210,7 @@ public abstract class FabricLanguageProvider implements DataProvider { /** * Merges an existing language file into the generated language file. + * * @param existingLanguageFile The path to the existing language file. * @throws IOException If loading the language file failed. */ diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricLootTableProvider.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricLootTableProvider.java index 55e414c25..2c37688aa 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricLootTableProvider.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricLootTableProvider.java @@ -28,6 +28,7 @@ import com.google.common.collect.Maps; import com.google.gson.JsonObject; import org.jetbrains.annotations.ApiStatus; +import net.minecraft.data.DataOutput; import net.minecraft.data.DataProvider; import net.minecraft.data.DataWriter; import net.minecraft.loot.LootManager; @@ -87,6 +88,6 @@ public interface FabricLootTableProvider extends ConsumerRegister an instance of the class with {@link FabricDataGenerator#addProvider} in a {@link net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint} */ @@ -43,14 +43,15 @@ public abstract class FabricRecipeProvider extends RecipeProvider { protected final FabricDataGenerator dataGenerator; public FabricRecipeProvider(FabricDataGenerator dataGenerator) { - super(dataGenerator); + super(dataGenerator.getOutput()); this.dataGenerator = dataGenerator; } /** * Implement this method and then use the range of methods in {@link RecipeProvider} or from one of the recipe json factories such as {@link ShapedRecipeJsonBuilder} or {@link ShapelessRecipeJsonBuilder}. */ - protected abstract void generateRecipes(Consumer exporter); + @Override + public abstract void generate(Consumer exporter); /** * Return a new exporter that applies the specified conditions to any recipe json provider it receives. @@ -66,7 +67,7 @@ public abstract class FabricRecipeProvider extends RecipeProvider { @Override public void run(DataWriter writer) { Set generatedRecipes = Sets.newHashSet(); - generateRecipes(provider -> { + generate(provider -> { Identifier identifier = getRecipeIdentifier(provider.getRecipeId()); if (!generatedRecipes.add(identifier)) { @@ -87,6 +88,11 @@ public abstract class FabricRecipeProvider extends RecipeProvider { }); } + @Override + public String getName() { + return "Recipes"; + } + /** * Override this method to change the recipe identifier. The default implementation normalizes the namespace to the mod ID. */ diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricTagProvider.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricTagProvider.java index a6e6aebd0..70ec94e32 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricTagProvider.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricTagProvider.java @@ -19,32 +19,31 @@ package net.fabricmc.fabric.api.datagen.v1.provider; import java.util.Objects; import java.util.function.Function; -import com.google.common.base.Preconditions; import org.jetbrains.annotations.Nullable; import net.minecraft.block.Block; -import net.minecraft.data.server.AbstractTagProvider; +import net.minecraft.data.server.tag.AbstractTagProvider; import net.minecraft.entity.EntityType; import net.minecraft.fluid.Fluid; import net.minecraft.item.Item; import net.minecraft.tag.BlockTags; -import net.minecraft.tag.TagBuilder; import net.minecraft.tag.EntityTypeTags; import net.minecraft.tag.FluidTags; import net.minecraft.tag.GameEventTags; import net.minecraft.tag.ItemTags; +import net.minecraft.tag.TagBuilder; import net.minecraft.tag.TagEntry; import net.minecraft.tag.TagKey; import net.minecraft.util.Identifier; import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.RegistryKey; +import net.minecraft.util.registry.RegistryLoader; import net.minecraft.world.event.GameEvent; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; import net.fabricmc.fabric.impl.datagen.FabricDataGenHelper; import net.fabricmc.fabric.impl.datagen.ForcedTagEntry; -import net.fabricmc.fabric.mixin.datagen.DynamicRegistryManagerAccessor; /** * Implement this class (or one of the inner classes) to generate a tag list. @@ -69,10 +68,10 @@ public abstract class FabricTagProvider extends AbstractTagProvider { *

Common implementations of this class are provided. For example @see BlockTagProvider * * @param dataGenerator The data generator instance - * @param registry The backing registry for the Tag type. + * @param registry The backing registry for the Tag type. */ public FabricTagProvider(FabricDataGenerator dataGenerator, Registry registry) { - super(dataGenerator, registry); + super(dataGenerator.getOutput(), registry); this.fabricDataGenerator = dataGenerator; if (!(this instanceof DynamicRegistryTagProvider) && BuiltinRegistries.REGISTRIES.contains((RegistryKey) registry.getKey())) { @@ -145,7 +144,7 @@ public abstract class FabricTagProvider extends AbstractTagProvider { *

Any block ids that do not exist in the item registry will be filtered out automatically. * * @param blockTag The block tag to copy from. - * @param itemTag The item tag to copy to. + * @param itemTag The item tag to copy to. */ public void copy(TagKey blockTag, TagKey itemTag) { TagBuilder blockTagBuilder = Objects.requireNonNull(this.blockTagBuilderProvider, "Pass Block tag provider via constructor to use copy").apply(blockTag); @@ -189,12 +188,15 @@ public abstract class FabricTagProvider extends AbstractTagProvider { * Construct a new {@link DynamicRegistryTagProvider}. * * @param dataGenerator The data generator instance - * @param registryKey The registry key of the dynamic registry + * @param registryKey The registry key of the dynamic registry * @throws IllegalArgumentException if the registry is static registry */ protected DynamicRegistryTagProvider(FabricDataGenerator dataGenerator, RegistryKey> registryKey) { super(dataGenerator, FabricDataGenHelper.getFakeDynamicRegistry(registryKey)); - Preconditions.checkArgument(DynamicRegistryManagerAccessor.getInfos().containsKey(registryKey), "Only dynamic registries are supported in this tag provider."); + if (RegistryLoader.DYNAMIC_REGISTRIES.stream().noneMatch(o -> o.key() == registryKey) + && RegistryLoader.DIMENSION_REGISTRIES.stream().noneMatch(o -> o.key() == registryKey)) { + throw new IllegalArgumentException("Only dynamic registries are supported in this tag provider."); + } } } diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/FabricDataGenHelper.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/FabricDataGenHelper.java index e5a8d6a5c..c443df228 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/FabricDataGenHelper.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/FabricDataGenHelper.java @@ -31,7 +31,7 @@ import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.minecraft.data.server.AbstractTagProvider; +import net.minecraft.data.server.tag.AbstractTagProvider; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.RegistryKey; @@ -138,7 +138,7 @@ public final class FabricDataGenHelper { */ @SuppressWarnings("rawtypes") public static Registry getFakeDynamicRegistry(RegistryKey> registryKey) { - return new SimpleRegistry<>(registryKey, Lifecycle.experimental(), null) { + return new SimpleRegistry<>(registryKey, Lifecycle.experimental(), false) { @Override public boolean containsId(Identifier id) { return true; diff --git a/fabric-textures-v0/src/client/java/net/fabricmc/fabric/api/client/texture/DependentSprite.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/FabricDataOutput.java similarity index 50% rename from fabric-textures-v0/src/client/java/net/fabricmc/fabric/api/client/texture/DependentSprite.java rename to fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/FabricDataOutput.java index 6ad130c4e..94b221c4b 100644 --- a/fabric-textures-v0/src/client/java/net/fabricmc/fabric/api/client/texture/DependentSprite.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/FabricDataOutput.java @@ -14,21 +14,29 @@ * limitations under the License. */ -package net.fabricmc.fabric.api.client.texture; +package net.fabricmc.fabric.impl.datagen; -import java.util.Set; +import java.nio.file.Path; -import net.minecraft.util.Identifier; +import org.jetbrains.annotations.ApiStatus; + +import net.minecraft.data.DataOutput; + +import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; /** - * Implement this interface on a Sprite to declare additional dependencies - * that should be processed prior to this sprite. - * - *

Best used in conjunction with {@link net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback}. + * Extends {@link DataOutput} to keep track of the {@link FabricDataGenerator} that it originated from. */ -public interface DependentSprite { - /** - * @return A set of all sprites that should be loaded before this sprite. - */ - Set getDependencies(); +@ApiStatus.Internal +public class FabricDataOutput extends DataOutput { + private final FabricDataGenerator generator; + + public FabricDataOutput(FabricDataGenerator generator, Path path) { + super(path); + this.generator = generator; + } + + public FabricDataGenerator getGenerator() { + return generator; + } } diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/AbstractTagProviderMixin.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/AbstractTagProviderMixin.java index 4f878a21a..f93eb4e11 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/AbstractTagProviderMixin.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/AbstractTagProviderMixin.java @@ -26,7 +26,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import net.minecraft.data.DataWriter; -import net.minecraft.data.server.AbstractTagProvider; +import net.minecraft.data.server.tag.AbstractTagProvider; import net.minecraft.tag.TagBuilder; import net.minecraft.util.Identifier; @@ -34,7 +34,7 @@ import net.fabricmc.fabric.impl.datagen.FabricTagBuilder; @Mixin(AbstractTagProvider.class) public class AbstractTagProviderMixin { - @Inject(method = "method_27046", at = @At(value = "INVOKE", target = "Lnet/minecraft/data/DataGenerator$PathResolver;resolveJson(Lnet/minecraft/util/Identifier;)Ljava/nio/file/Path;"), locals = LocalCapture.CAPTURE_FAILHARD) + @Inject(method = "method_27046", at = @At(value = "INVOKE", target = "Lnet/minecraft/data/DataOutput$PathResolver;resolveJson(Lnet/minecraft/util/Identifier;)Ljava/nio/file/Path;"), locals = LocalCapture.CAPTURE_FAILHARD) public void addReplaced(DataWriter dataWriter, Identifier id, TagBuilder builder, CallbackInfo ci, List list, List list2, JsonElement jsonElement) { if (builder instanceof FabricTagBuilder fabricTagBuilder) { jsonElement.getAsJsonObject().addProperty("replace", fabricTagBuilder.fabric_isReplaced()); diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/ModelProviderMixin.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/ModelProviderMixin.java index a8da15e1d..171f5e012 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/ModelProviderMixin.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/ModelProviderMixin.java @@ -31,7 +31,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import net.minecraft.block.Block; -import net.minecraft.data.DataGenerator; +import net.minecraft.data.DataOutput; import net.minecraft.data.DataWriter; import net.minecraft.data.client.BlockStateModelGenerator; import net.minecraft.data.client.BlockStateSupplier; @@ -43,18 +43,21 @@ import net.minecraft.util.registry.Registry; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider; +import net.fabricmc.fabric.impl.datagen.FabricDataOutput; @Mixin(ModelProvider.class) public class ModelProviderMixin { @Unique - private DataGenerator generator; + private FabricDataGenerator generator; @Unique - private static final ThreadLocal dataGeneratorThreadLocal = new ThreadLocal<>(); + private static final ThreadLocal dataGeneratorThreadLocal = new ThreadLocal<>(); @Inject(method = "", at = @At("RETURN")) - public void init(DataGenerator generator, CallbackInfo ci) { - this.generator = generator; + public void init(DataOutput generator, CallbackInfo ci) { + if (generator instanceof FabricDataOutput fabricDataOutput) { + this.generator = fabricDataOutput.getGenerator(); + } } @Unique @@ -94,7 +97,9 @@ public class ModelProviderMixin { @Inject(method = "method_25738", at = @At("HEAD"), cancellable = true) private static void filterBlocksForProcessingMod(Map map, Block block, CallbackInfoReturnable cir) { - if (dataGeneratorThreadLocal.get() instanceof FabricDataGenerator dataGenerator) { + FabricDataGenerator dataGenerator = dataGeneratorThreadLocal.get(); + + if (dataGenerator != null) { if (!dataGenerator.isStrictValidationEnabled()) { cir.setReturnValue(false); return; @@ -109,7 +114,9 @@ public class ModelProviderMixin { @Inject(method = "method_25741", at = @At(value = "INVOKE", target = "Lnet/minecraft/data/client/ModelIds;getItemModelId(Lnet/minecraft/item/Item;)Lnet/minecraft/util/Identifier;"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD) private static void filterItemsForProcessingMod(Set set, Map> map, Block block, CallbackInfo ci, Item item) { - if (dataGeneratorThreadLocal.get() instanceof FabricDataGenerator dataGenerator) { + FabricDataGenerator dataGenerator = dataGeneratorThreadLocal.get(); + + if (dataGenerator != null) { // Only generate the item model if the block state json was registered if (!blockStateMapThreadLocal.get().containsKey(block)) { ci.cancel(); diff --git a/fabric-data-generation-api-v1/src/main/resources/fabric-data-generation-api-v1.accesswidener b/fabric-data-generation-api-v1/src/main/resources/fabric-data-generation-api-v1.accesswidener index 93f6ceb93..975e66e21 100644 --- a/fabric-data-generation-api-v1/src/main/resources/fabric-data-generation-api-v1.accesswidener +++ b/fabric-data-generation-api-v1/src/main/resources/fabric-data-generation-api-v1.accesswidener @@ -1,25 +1,29 @@ accessWidener v2 named -accessible field net/minecraft/data/server/RecipeProvider recipesPathResolver Lnet/minecraft/data/DataGenerator$PathResolver; -accessible field net/minecraft/data/server/RecipeProvider advancementsPathResolver Lnet/minecraft/data/DataGenerator$PathResolver; +accessible field net/minecraft/data/DataGenerator output Lnet/minecraft/data/DataOutput; +mutable field net/minecraft/data/DataGenerator output Lnet/minecraft/data/DataOutput; +accessible field net/minecraft/data/DataGenerator outputPath Ljava/nio/file/Path; -accessible method net/minecraft/data/server/AbstractTagProvider$ObjectBuilder (Lnet/minecraft/tag/TagBuilder;Lnet/minecraft/util/registry/Registry;)V -extendable method net/minecraft/data/server/AbstractTagProvider$ObjectBuilder add ([Ljava/lang/Object;)Lnet/minecraft/data/server/AbstractTagProvider$ObjectBuilder; -accessible field net/minecraft/data/server/AbstractTagProvider$ObjectBuilder builder Lnet/minecraft/tag/TagBuilder; -accessible field net/minecraft/data/server/AbstractTagProvider$ObjectBuilder registry Lnet/minecraft/util/registry/Registry; +accessible field net/minecraft/data/server/recipe/RecipeProvider recipesPathResolver Lnet/minecraft/data/DataOutput$PathResolver; +accessible field net/minecraft/data/server/recipe/RecipeProvider advancementsPathResolver Lnet/minecraft/data/DataOutput$PathResolver; -accessible field net/minecraft/data/server/AbstractTagProvider tagBuilders Ljava/util/Map; +accessible method net/minecraft/data/server/tag/AbstractTagProvider$ObjectBuilder (Lnet/minecraft/tag/TagBuilder;Lnet/minecraft/util/registry/Registry;)V +extendable method net/minecraft/data/server/tag/AbstractTagProvider$ObjectBuilder add ([Ljava/lang/Object;)Lnet/minecraft/data/server/tag/AbstractTagProvider$ObjectBuilder; +accessible field net/minecraft/data/server/tag/AbstractTagProvider$ObjectBuilder builder Lnet/minecraft/tag/TagBuilder; +accessible field net/minecraft/data/server/tag/AbstractTagProvider$ObjectBuilder registry Lnet/minecraft/util/registry/Registry; -accessible field net/minecraft/data/server/BlockLootTableGenerator lootTables Ljava/util/Map; +accessible field net/minecraft/data/server/tag/AbstractTagProvider tagBuilders Ljava/util/Map; + +accessible field net/minecraft/data/server/loottable/BlockLootTableGenerator lootTables Ljava/util/Map; extendable method net/minecraft/tag/TagEntry (Lnet/minecraft/util/Identifier;ZZ)V accessible field net/minecraft/tag/TagEntry id Lnet/minecraft/util/Identifier; accessible field net/minecraft/tag/TagEntry tag Z accessible field net/minecraft/tag/TagEntry required Z -extendable method net/minecraft/data/DataGenerator$PathResolver (Lnet/minecraft/data/DataGenerator;Lnet/minecraft/data/DataGenerator$OutputType;Ljava/lang/String;)V -accessible field net/minecraft/data/DataGenerator$PathResolver rootPath Ljava/nio/file/Path; -accessible field net/minecraft/data/DataGenerator$PathResolver directoryName Ljava/lang/String; +extendable method net/minecraft/data/DataOutput$PathResolver (Lnet/minecraft/data/DataOutput;Lnet/minecraft/data/DataOutput$OutputType;Ljava/lang/String;)V +accessible field net/minecraft/data/DataOutput$PathResolver rootPath Ljava/nio/file/Path; +accessible field net/minecraft/data/DataOutput$PathResolver directoryName Ljava/lang/String; transitive-accessible method net/minecraft/data/family/BlockFamilies register (Lnet/minecraft/block/Block;)Lnet/minecraft/data/family/BlockFamily$Builder; @@ -29,7 +33,7 @@ transitive-accessible field net/minecraft/data/client/BlockStateModelGenerat transitive-accessible method net/minecraft/data/client/TextureKey of (Ljava/lang/String;)Lnet/minecraft/data/client/TextureKey; transitive-accessible method net/minecraft/data/client/TextureKey of (Ljava/lang/String;Lnet/minecraft/data/client/TextureKey;)Lnet/minecraft/data/client/TextureKey; -transitive-extendable method net/minecraft/data/server/AbstractTagProvider$ObjectBuilder add ([Lnet/minecraft/util/registry/RegistryKey;)Lnet/minecraft/data/server/AbstractTagProvider$ObjectBuilder; +transitive-extendable method net/minecraft/data/server/tag/AbstractTagProvider$ObjectBuilder add ([Lnet/minecraft/util/registry/RegistryKey;)Lnet/minecraft/data/server/tag/AbstractTagProvider$ObjectBuilder; transitive-accessible method net/minecraft/data/client/TexturedModel makeFactory (Ljava/util/function/Function;Lnet/minecraft/data/client/Model;)Lnet/minecraft/data/client/TexturedModel$Factory; @@ -38,65 +42,80 @@ transitive-accessible class net/minecraft/data/client/BlockStateModelGenerator transitive-accessible class net/minecraft/data/client/BlockStateModelGenerator$LogTexturePool transitive-accessible class net/minecraft/data/client/BlockStateModelGenerator$BuiltinModelPool -transitive-accessible method net/minecraft/data/server/RecipeProvider saveRecipe (Lnet/minecraft/data/DataWriter;Lcom/google/gson/JsonObject;Ljava/nio/file/Path;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider saveRecipeAdvancement (Lnet/minecraft/data/DataWriter;Lcom/google/gson/JsonObject;Ljava/nio/file/Path;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider generate (Ljava/util/function/Consumer;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerSingleOutputShapelessRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerShapelessRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;I)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerSmelting (Ljava/util/function/Consumer;Ljava/util/List;Lnet/minecraft/item/ItemConvertible;FILjava/lang/String;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerBlasting (Ljava/util/function/Consumer;Ljava/util/List;Lnet/minecraft/item/ItemConvertible;FILjava/lang/String;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerMultipleOptions (Ljava/util/function/Consumer;Lnet/minecraft/recipe/CookingRecipeSerializer;Ljava/util/List;Lnet/minecraft/item/ItemConvertible;FILjava/lang/String;Ljava/lang/String;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerNetheriteUpgradeRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/Item;Lnet/minecraft/item/Item;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerPlanksRecipe2 (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/tag/TagKey;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerPlanksRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/tag/TagKey;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerBarkBlockRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerBoatRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerChestBoatRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider createTransmutationRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; -transitive-accessible method net/minecraft/data/server/RecipeProvider createDoorRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; -transitive-accessible method net/minecraft/data/server/RecipeProvider createFenceRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; -transitive-accessible method net/minecraft/data/server/RecipeProvider createFenceGateRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; -transitive-accessible method net/minecraft/data/server/RecipeProvider offerPressurePlateRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider createPressurePlateRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; -transitive-accessible method net/minecraft/data/server/RecipeProvider offerSlabRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider createSlabRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; -transitive-accessible method net/minecraft/data/server/RecipeProvider createStairsRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; -transitive-accessible method net/minecraft/data/server/RecipeProvider createTrapdoorRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; -transitive-accessible method net/minecraft/data/server/RecipeProvider createSignRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; -transitive-accessible method net/minecraft/data/server/RecipeProvider offerWoolDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerCarpetRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerCarpetDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerBedRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerBedDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerBannerRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerStainedGlassDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerStainedGlassPaneRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerStainedGlassPaneDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerTerracottaDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerConcretePowderDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerStonecuttingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerStonecuttingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;I)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerCrackingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerReversibleCompactingRecipes (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerReversibleCompactingRecipesWithCompactingRecipeGroup (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;Ljava/lang/String;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerReversibleCompactingRecipesWithReverseRecipeGroup (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;Ljava/lang/String;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerReversibleCompactingRecipes (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider generateCookingRecipes (Ljava/util/function/Consumer;Ljava/lang/String;Lnet/minecraft/recipe/CookingRecipeSerializer;I)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerCookingRecipe (Ljava/util/function/Consumer;Ljava/lang/String;Lnet/minecraft/recipe/CookingRecipeSerializer;ILnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;F)V -transitive-accessible method net/minecraft/data/server/RecipeProvider offerWaxingRecipes (Ljava/util/function/Consumer;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider generateFamily (Ljava/util/function/Consumer;Lnet/minecraft/data/family/BlockFamily;)V -transitive-accessible method net/minecraft/data/server/RecipeProvider getVariantRecipeInput (Lnet/minecraft/data/family/BlockFamily;Lnet/minecraft/data/family/BlockFamily$Variant;)Lnet/minecraft/block/Block; -transitive-accessible method net/minecraft/data/server/RecipeProvider requireEnteringFluid (Lnet/minecraft/block/Block;)Lnet/minecraft/advancement/criterion/EnterBlockCriterion$Conditions; -transitive-accessible method net/minecraft/data/server/RecipeProvider conditionsFromItem (Lnet/minecraft/predicate/NumberRange$IntRange;Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/advancement/criterion/InventoryChangedCriterion$Conditions; -transitive-accessible method net/minecraft/data/server/RecipeProvider conditionsFromItem (Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/advancement/criterion/InventoryChangedCriterion$Conditions; -transitive-accessible method net/minecraft/data/server/RecipeProvider conditionsFromTag (Lnet/minecraft/tag/TagKey;)Lnet/minecraft/advancement/criterion/InventoryChangedCriterion$Conditions; -transitive-accessible method net/minecraft/data/server/RecipeProvider conditionsFromItemPredicates ([Lnet/minecraft/predicate/item/ItemPredicate;)Lnet/minecraft/advancement/criterion/InventoryChangedCriterion$Conditions; -transitive-accessible method net/minecraft/data/server/RecipeProvider hasItem (Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; -transitive-accessible method net/minecraft/data/server/RecipeProvider getItemPath (Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; -transitive-accessible method net/minecraft/data/server/RecipeProvider getRecipeName (Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; -transitive-accessible method net/minecraft/data/server/RecipeProvider convertBetween (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; -transitive-accessible method net/minecraft/data/server/RecipeProvider getSmeltingItemPath (Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; -transitive-accessible method net/minecraft/data/server/RecipeProvider getBlastingItemPath (Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider saveRecipeAdvancement (Lnet/minecraft/data/DataWriter;Lnet/minecraft/util/Identifier;Lnet/minecraft/advancement/Advancement$Builder;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider saveRecipe (Lnet/minecraft/data/DataWriter;Lcom/google/gson/JsonObject;Ljava/nio/file/Path;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider saveRecipeAdvancement (Lnet/minecraft/data/DataWriter;Lcom/google/gson/JsonObject;Ljava/nio/file/Path;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider generate (Ljava/util/function/Consumer;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider generateFamilies (Ljava/util/function/Consumer;Lnet/minecraft/resource/featuretoggle/FeatureSet;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerSingleOutputShapelessRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerShapelessRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;I)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerSmelting (Ljava/util/function/Consumer;Ljava/util/List;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;FILjava/lang/String;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerBlasting (Ljava/util/function/Consumer;Ljava/util/List;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;FILjava/lang/String;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerMultipleOptions (Ljava/util/function/Consumer;Lnet/minecraft/recipe/RecipeSerializer;Ljava/util/List;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;FILjava/lang/String;Ljava/lang/String;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerNetheriteUpgradeRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/Item;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/Item;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offer2x2CompactingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerPlanksRecipe2 (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/tag/TagKey;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerPlanksRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/tag/TagKey;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerBarkBlockRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerBoatRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerChestBoatRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider createTransmutationRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider createDoorRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider createFenceRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider createFenceGateRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerPressurePlateRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider createPressurePlateRecipe (Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerSlabRecipe (Ljava/util/function/Consumer;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider createSlabRecipe (Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider createStairsRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider createTrapdoorRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider createSignRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerHangingSignRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerHangingSignRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;I)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerWoolDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerCarpetRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerCarpetDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerBedRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerBedDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerBannerRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerStainedGlassDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerStainedGlassPaneRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerStainedGlassPaneDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerTerracottaDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerConcretePowderDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerCandleDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerWallRecipe (Ljava/util/function/Consumer;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider getWallRecipe (Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerPolishedStoneRecipe (Ljava/util/function/Consumer;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider createCondensingRecipe (Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerCutCopperRecipe (Ljava/util/function/Consumer;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider createCutCopperRecipe (Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/ShapedRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerChiseledBlockRecipe (Ljava/util/function/Consumer;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerMosaicRecipe (Ljava/util/function/Consumer;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider createChiseledBlockRecipe (Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/ShapedRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerStonecuttingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerStonecuttingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;I)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerCrackingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerReversibleCompactingRecipes (Ljava/util/function/Consumer;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerReversibleCompactingRecipesWithCompactingRecipeGroup (Ljava/util/function/Consumer;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;Ljava/lang/String;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerReversibleCompactingRecipesWithReverseRecipeGroup (Ljava/util/function/Consumer;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;Ljava/lang/String;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerReversibleCompactingRecipes (Ljava/util/function/Consumer;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider generateCookingRecipes (Ljava/util/function/Consumer;Ljava/lang/String;Lnet/minecraft/recipe/RecipeSerializer;I)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerFoodCookingRecipe (Ljava/util/function/Consumer;Ljava/lang/String;Lnet/minecraft/recipe/RecipeSerializer;ILnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;F)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerWaxingRecipes (Ljava/util/function/Consumer;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider generateFamily (Ljava/util/function/Consumer;Lnet/minecraft/data/family/BlockFamily;)V +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider getVariantRecipeInput (Lnet/minecraft/data/family/BlockFamily;Lnet/minecraft/data/family/BlockFamily$Variant;)Lnet/minecraft/block/Block; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider requireEnteringFluid (Lnet/minecraft/block/Block;)Lnet/minecraft/advancement/criterion/EnterBlockCriterion$Conditions; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider conditionsFromItem (Lnet/minecraft/predicate/NumberRange$IntRange;Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/advancement/criterion/InventoryChangedCriterion$Conditions; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider conditionsFromItem (Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/advancement/criterion/InventoryChangedCriterion$Conditions; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider conditionsFromTag (Lnet/minecraft/tag/TagKey;)Lnet/minecraft/advancement/criterion/InventoryChangedCriterion$Conditions; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider conditionsFromItemPredicates ([Lnet/minecraft/predicate/item/ItemPredicate;)Lnet/minecraft/advancement/criterion/InventoryChangedCriterion$Conditions; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider hasItem (Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider getItemPath (Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider getRecipeName (Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider convertBetween (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider getSmeltingItemPath (Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; +transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider getBlastingItemPath (Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createStoneState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/data/client/TextureMap;Ljava/util/function/BiConsumer;)Lnet/minecraft/data/client/BlockStateSupplier; transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createMudBrickState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/data/client/TextureMap;Ljava/util/function/BiConsumer;)Lnet/minecraft/data/client/BlockStateSupplier; transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createDeepslateState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/data/client/TextureMap;Ljava/util/function/BiConsumer;)Lnet/minecraft/data/client/BlockStateSupplier; @@ -119,9 +138,10 @@ transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createButtonBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator fillDoorVariantMap (Lnet/minecraft/data/client/BlockStateVariantMap$QuadrupleProperty;Lnet/minecraft/block/enums/DoubleBlockHalf;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateVariantMap$QuadrupleProperty; transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createDoorBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createCustomFenceBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createFenceBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createWallBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; -transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createFenceGateBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createFenceGateBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Z)Lnet/minecraft/data/client/BlockStateSupplier; transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createStairsBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createOrientableTrapdoorBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createTrapdoorBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; @@ -205,47 +225,51 @@ transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerRoots (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator addJigsawOrientationToVariant (Lnet/minecraft/block/enums/JigsawOrientation;Lnet/minecraft/data/client/BlockStateVariant;)Lnet/minecraft/data/client/BlockStateVariant; transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerCandle (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator applyExplosionDecay (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/loot/function/LootFunctionConsumingBuilder;)Lnet/minecraft/loot/function/LootFunctionConsumingBuilder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator addSurvivesExplosionCondition (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/loot/condition/LootConditionConsumingBuilder;)Lnet/minecraft/loot/condition/LootConditionConsumingBuilder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator drops (Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator drops (Lnet/minecraft/block/Block;Lnet/minecraft/loot/condition/LootCondition$Builder;Lnet/minecraft/loot/entry/LootPoolEntry$Builder;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator dropsWithSilkTouch (Lnet/minecraft/block/Block;Lnet/minecraft/loot/entry/LootPoolEntry$Builder;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator dropsWithShears (Lnet/minecraft/block/Block;Lnet/minecraft/loot/entry/LootPoolEntry$Builder;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator dropsWithSilkTouchOrShears (Lnet/minecraft/block/Block;Lnet/minecraft/loot/entry/LootPoolEntry$Builder;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator drops (Lnet/minecraft/block/Block;Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator drops (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/loot/provider/number/LootNumberProvider;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator drops (Lnet/minecraft/block/Block;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/loot/provider/number/LootNumberProvider;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator dropsWithSilkTouch (Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator pottedPlantDrops (Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator slabDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator dropsWithProperty (Lnet/minecraft/block/Block;Lnet/minecraft/state/property/Property;Ljava/lang/Comparable;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator nameableContainerDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator shulkerBoxDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator copperOreDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator lapisOreDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator redstoneOreDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator bannerDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator beeNestDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator beehiveDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator glowBerryDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator oreDrops (Lnet/minecraft/block/Block;Lnet/minecraft/item/Item;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator mushroomBlockDrops (Lnet/minecraft/block/Block;Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator grassDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator cropStemDrops (Lnet/minecraft/block/Block;Lnet/minecraft/item/Item;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator attachedCropStemDrops (Lnet/minecraft/block/Block;Lnet/minecraft/item/Item;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator dropsWithShears (Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator multifaceGrowthDrops (Lnet/minecraft/block/Block;Lnet/minecraft/loot/condition/LootCondition$Builder;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator leavesDrop (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;[F)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator oakLeavesDrop (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;[F)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator mangroveLeavesDrop (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator cropDrops (Lnet/minecraft/block/Block;Lnet/minecraft/item/Item;Lnet/minecraft/item/Item;Lnet/minecraft/loot/condition/LootCondition$Builder;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator seagrassDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator tallGrassDrops (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator candleDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator candleCakeDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator addVinePlantDrop (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator addDrop (Lnet/minecraft/block/Block;Ljava/util/function/Function;)V -transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator addDrop (Lnet/minecraft/block/Block;Lnet/minecraft/loot/LootTable$Builder;)V +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator applyExplosionDecay (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/loot/function/LootFunctionConsumingBuilder;)Lnet/minecraft/loot/function/LootFunctionConsumingBuilder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator addSurvivesExplosionCondition (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/loot/condition/LootConditionConsumingBuilder;)Lnet/minecraft/loot/condition/LootConditionConsumingBuilder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator drops (Lnet/minecraft/block/Block;Lnet/minecraft/loot/condition/LootCondition$Builder;Lnet/minecraft/loot/entry/LootPoolEntry$Builder;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator dropsWithSilkTouch (Lnet/minecraft/block/Block;Lnet/minecraft/loot/entry/LootPoolEntry$Builder;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator dropsWithShears (Lnet/minecraft/block/Block;Lnet/minecraft/loot/entry/LootPoolEntry$Builder;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator dropsWithSilkTouchOrShears (Lnet/minecraft/block/Block;Lnet/minecraft/loot/entry/LootPoolEntry$Builder;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator drops (Lnet/minecraft/block/Block;Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator drops (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/loot/provider/number/LootNumberProvider;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator drops (Lnet/minecraft/block/Block;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/loot/provider/number/LootNumberProvider;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator dropsWithSilkTouch (Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator pottedPlantDrops (Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator slabDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator dropsWithProperty (Lnet/minecraft/block/Block;Lnet/minecraft/state/property/Property;Ljava/lang/Comparable;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator nameableContainerDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator shulkerBoxDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator copperOreDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator lapisOreDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator redstoneOreDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator bannerDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator beeNestDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator beehiveDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator glowBerryDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator oreDrops (Lnet/minecraft/block/Block;Lnet/minecraft/item/Item;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator mushroomBlockDrops (Lnet/minecraft/block/Block;Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator grassDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator dropsWithShears (Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator multifaceGrowthDrops (Lnet/minecraft/block/Block;Lnet/minecraft/loot/condition/LootCondition$Builder;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator leavesDrops (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;[F)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator oakLeavesDrops (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;[F)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator mangroveLeavesDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator cropDrops (Lnet/minecraft/block/Block;Lnet/minecraft/item/Item;Lnet/minecraft/item/Item;Lnet/minecraft/loot/condition/LootCondition$Builder;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator seagrassDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator tallGrassDrops (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator candleDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator candleCakeDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator generate ()V +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator addVinePlantDrop (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator doorDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder; +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator addPottedPlantDrops (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator addDropWithSilkTouch (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator addDrop (Lnet/minecraft/block/Block;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator addDropWithSilkTouch (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator addDrop (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator addDrop (Lnet/minecraft/block/Block;Ljava/util/function/Function;)V +transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator addDrop (Lnet/minecraft/block/Block;Lnet/minecraft/loot/LootTable$Builder;)V transitive-accessible method net/minecraft/data/client/ItemModelGenerator register (Lnet/minecraft/item/Item;Lnet/minecraft/data/client/Model;)V transitive-accessible method net/minecraft/data/client/ItemModelGenerator register (Lnet/minecraft/item/Item;Ljava/lang/String;Lnet/minecraft/data/client/Model;)V transitive-accessible method net/minecraft/data/client/ItemModelGenerator register (Lnet/minecraft/item/Item;Lnet/minecraft/item/Item;Lnet/minecraft/data/client/Model;)V diff --git a/fabric-data-generation-api-v1/src/main/resources/fabric-data-generation-api-v1.mixins.json b/fabric-data-generation-api-v1/src/main/resources/fabric-data-generation-api-v1.mixins.json index aeae6bfd1..5784bfad1 100644 --- a/fabric-data-generation-api-v1/src/main/resources/fabric-data-generation-api-v1.mixins.json +++ b/fabric-data-generation-api-v1/src/main/resources/fabric-data-generation-api-v1.mixins.json @@ -5,7 +5,6 @@ "mixins": [ "AbstractTagProviderMixin", "ModelProviderMixin", - "DynamicRegistryManagerAccessor", "TagBuilderMixin" ], "server": [ 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 f397f2b82..9ca566ae4 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 @@ -16,21 +16,22 @@ package net.fabricmc.fabric.test.datagen; -import java.util.Objects; +import java.util.ArrayList; +import java.util.List; import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; import net.minecraft.block.Material; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.resource.featuretoggle.FeatureSet; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder; +import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; public class DataGeneratorTestContent implements ModInitializer { public static final String MOD_ID = "fabric-data-gen-api-v1-testmod"; @@ -38,11 +39,11 @@ public class DataGeneratorTestContent implements ModInitializer { public static Block SIMPLE_BLOCK; public static Block BLOCK_WITHOUT_ITEM; public static Block BLOCK_WITHOUT_LOOT_TABLE; - public static ItemGroup SIMPLE_ITEM_GROUP; + + public static final SimpleItemGroup SIMPLE_ITEM_GROUP = new SimpleItemGroup(); @Override public void onInitialize() { - SIMPLE_ITEM_GROUP = FabricItemGroupBuilder.build(new Identifier(MOD_ID, "default"), () -> new ItemStack(Items.BONE)); SIMPLE_BLOCK = createBlock("simple_block", true); BLOCK_WITHOUT_ITEM = createBlock("block_without_item", false); BLOCK_WITHOUT_LOOT_TABLE = createBlock("block_without_loot_table", false); @@ -53,11 +54,28 @@ public class DataGeneratorTestContent implements ModInitializer { Block block = Registry.register(Registry.BLOCK, identifier, new Block(AbstractBlock.Settings.of(Material.STONE))); if (hasItem) { - Registry.register(Registry.ITEM, identifier, new BlockItem(block, new Item.Settings().group(ItemGroup.MISC))); - - Objects.requireNonNull(block.asItem().getGroup()); + Item item = Registry.register(Registry.ITEM, identifier, new BlockItem(block, new Item.Settings())); + SIMPLE_ITEM_GROUP.items.add(new ItemStack(item)); } return block; } + + private static class SimpleItemGroup extends FabricItemGroup { + public List items = new ArrayList<>(); + + SimpleItemGroup() { + super(new Identifier(MOD_ID, "simple")); + } + + @Override + public ItemStack createIcon() { + return new ItemStack(Items.BONE); + } + + @Override + protected void addItems(FeatureSet featureSet, Entries entries) { + entries.addAll(items); + } + } } 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 f64217639..a60a3d97f 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 @@ -47,6 +47,7 @@ import net.minecraft.loot.LootTables; import net.minecraft.loot.context.LootContextTypes; import net.minecraft.loot.entry.ItemEntry; import net.minecraft.loot.provider.number.ConstantLootNumberProvider; +import net.minecraft.recipe.book.RecipeCategory; import net.minecraft.tag.BlockTags; import net.minecraft.tag.ItemTags; import net.minecraft.tag.TagKey; @@ -118,7 +119,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint { } @Override - protected void generateRecipes(Consumer exporter) { + public void generate(Consumer exporter) { offerPlanksRecipe2(exporter, SIMPLE_BLOCK, ItemTags.ACACIA_LOGS); } } @@ -174,9 +175,9 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint { } @Override - protected void generateRecipes(Consumer exporter) { - ShapelessRecipeJsonBuilder.create(Items.GOLD_INGOT).input(Items.DIRT).criterion("has_dirt", conditionsFromItem(Items.DIRT)).offerTo(withConditions(exporter, NEVER_LOADED)); - ShapelessRecipeJsonBuilder.create(Items.DIAMOND).input(Items.STICK).criterion("has_stick", conditionsFromItem(Items.STICK)).offerTo(withConditions(exporter, ALWAYS_LOADED)); + public void generate(Consumer exporter) { + ShapelessRecipeJsonBuilder.create(RecipeCategory.MISC, Items.GOLD_INGOT).input(Items.DIRT).criterion("has_dirt", conditionsFromItem(Items.DIRT)).offerTo(withConditions(exporter, NEVER_LOADED)); + ShapelessRecipeJsonBuilder.create(RecipeCategory.MISC, Items.DIAMOND).input(Items.STICK).criterion("has_stick", conditionsFromItem(Items.STICK)).offerTo(withConditions(exporter, ALWAYS_LOADED)); } } @@ -278,7 +279,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint { } @Override - protected void generateBlockLootTables() { + public void generate() { addDrop(SIMPLE_BLOCK); addDrop(BLOCK_WITHOUT_ITEM, drops(SIMPLE_BLOCK)); diff --git a/fabric-data-generation-api-v1/template.accesswidener b/fabric-data-generation-api-v1/template.accesswidener index 07dbfdd17..f42173abf 100644 --- a/fabric-data-generation-api-v1/template.accesswidener +++ b/fabric-data-generation-api-v1/template.accesswidener @@ -1,25 +1,28 @@ accessWidener v2 named -accessible field net/minecraft/data/server/RecipeProvider recipesPathResolver Lnet/minecraft/data/DataGenerator$PathResolver; -accessible field net/minecraft/data/server/RecipeProvider advancementsPathResolver Lnet/minecraft/data/DataGenerator$PathResolver; +accessible field net/minecraft/data/DataGenerator output Lnet/minecraft/data/DataOutput; +mutable field net/minecraft/data/DataGenerator output Lnet/minecraft/data/DataOutput; -accessible method net/minecraft/data/server/AbstractTagProvider$ObjectBuilder (Lnet/minecraft/tag/TagBuilder;Lnet/minecraft/util/registry/Registry;)V -extendable method net/minecraft/data/server/AbstractTagProvider$ObjectBuilder add ([Ljava/lang/Object;)Lnet/minecraft/data/server/AbstractTagProvider$ObjectBuilder; -accessible field net/minecraft/data/server/AbstractTagProvider$ObjectBuilder builder Lnet/minecraft/tag/TagBuilder; -accessible field net/minecraft/data/server/AbstractTagProvider$ObjectBuilder registry Lnet/minecraft/util/registry/Registry; +accessible field net/minecraft/data/server/recipe/RecipeProvider recipesPathResolver Lnet/minecraft/data/DataOutput$PathResolver; +accessible field net/minecraft/data/server/recipe/RecipeProvider advancementsPathResolver Lnet/minecraft/data/DataOutput$PathResolver; -accessible field net/minecraft/data/server/AbstractTagProvider tagBuilders Ljava/util/Map; +accessible method net/minecraft/data/server/tag/AbstractTagProvider$ObjectBuilder (Lnet/minecraft/tag/TagBuilder;Lnet/minecraft/util/registry/Registry;)V +extendable method net/minecraft/data/server/tag/AbstractTagProvider$ObjectBuilder add ([Ljava/lang/Object;)Lnet/minecraft/data/server/tag/AbstractTagProvider$ObjectBuilder; +accessible field net/minecraft/data/server/tag/AbstractTagProvider$ObjectBuilder builder Lnet/minecraft/tag/TagBuilder; +accessible field net/minecraft/data/server/tag/AbstractTagProvider$ObjectBuilder registry Lnet/minecraft/util/registry/Registry; -accessible field net/minecraft/data/server/BlockLootTableGenerator lootTables Ljava/util/Map; +accessible field net/minecraft/data/server/tag/AbstractTagProvider tagBuilders Ljava/util/Map; + +accessible field net/minecraft/data/server/loottable/BlockLootTableGenerator lootTables Ljava/util/Map; extendable method net/minecraft/tag/TagEntry (Lnet/minecraft/util/Identifier;ZZ)V accessible field net/minecraft/tag/TagEntry id Lnet/minecraft/util/Identifier; accessible field net/minecraft/tag/TagEntry tag Z accessible field net/minecraft/tag/TagEntry required Z -extendable method net/minecraft/data/DataGenerator$PathResolver (Lnet/minecraft/data/DataGenerator;Lnet/minecraft/data/DataGenerator$OutputType;Ljava/lang/String;)V -accessible field net/minecraft/data/DataGenerator$PathResolver rootPath Ljava/nio/file/Path; -accessible field net/minecraft/data/DataGenerator$PathResolver directoryName Ljava/lang/String; +extendable method net/minecraft/data/DataOutput$PathResolver (Lnet/minecraft/data/DataOutput;Lnet/minecraft/data/DataOutput$OutputType;Ljava/lang/String;)V +accessible field net/minecraft/data/DataOutput$PathResolver rootPath Ljava/nio/file/Path; +accessible field net/minecraft/data/DataOutput$PathResolver directoryName Ljava/lang/String; transitive-accessible method net/minecraft/data/family/BlockFamilies register (Lnet/minecraft/block/Block;)Lnet/minecraft/data/family/BlockFamily$Builder; @@ -29,7 +32,7 @@ transitive-accessible field net/minecraft/data/client/BlockStateModelGenerat transitive-accessible method net/minecraft/data/client/TextureKey of (Ljava/lang/String;)Lnet/minecraft/data/client/TextureKey; transitive-accessible method net/minecraft/data/client/TextureKey of (Ljava/lang/String;Lnet/minecraft/data/client/TextureKey;)Lnet/minecraft/data/client/TextureKey; -transitive-extendable method net/minecraft/data/server/AbstractTagProvider$ObjectBuilder add ([Lnet/minecraft/util/registry/RegistryKey;)Lnet/minecraft/data/server/AbstractTagProvider$ObjectBuilder; +transitive-extendable method net/minecraft/data/server/tag/AbstractTagProvider$ObjectBuilder add ([Lnet/minecraft/util/registry/RegistryKey;)Lnet/minecraft/data/server/tag/AbstractTagProvider$ObjectBuilder; transitive-accessible method net/minecraft/data/client/TexturedModel makeFactory (Ljava/util/function/Function;Lnet/minecraft/data/client/Model;)Lnet/minecraft/data/client/TexturedModel$Factory; diff --git a/fabric-dimensions-v1/src/main/java/net/fabricmc/fabric/mixin/dimension/MainMixin.java b/fabric-dimensions-v1/src/main/java/net/fabricmc/fabric/mixin/dimension/MainMixin.java deleted file mode 100644 index 845d2b651..000000000 --- a/fabric-dimensions-v1/src/main/java/net/fabricmc/fabric/mixin/dimension/MainMixin.java +++ /dev/null @@ -1,93 +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.dimension; - -import com.mojang.serialization.DynamicOps; -import com.mojang.serialization.Lifecycle; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; -import org.spongepowered.asm.mixin.injection.Redirect; - -import net.minecraft.nbt.NbtElement; -import net.minecraft.resource.DataPackSettings; -import net.minecraft.server.Main; -import net.minecraft.util.registry.DynamicRegistryManager; -import net.minecraft.world.gen.GeneratorOptions; -import net.minecraft.world.level.LevelInfo; -import net.minecraft.world.level.LevelProperties; -import net.minecraft.world.level.storage.LevelStorage; - -/** - * This Mixin aims to solve a Minecraft Vanilla bug where datapacks are ignored during creation of the - * initial LevelProperties when a dedicated server creates a completely new level. - * - *

This also includes the datapacks of loaded Fabric mods, and results in modded dimensions only - * being available after restarting the server, once the world has been created. - * - *

This Mixin aims to solve this problem by saving and loading the level.dat file once, after - * a new set of level properties is created. This will apply the same logic as reloading the - * level.dat after a restart, now including all datapack dimensions. - * - *

See https://bugs.mojang.com/browse/MC-195468 for a related bug report. - * - *

TODO: Retest if this bug still occurs without this Mixin by launching a dedicated server with the - * dimension testmod, and no world directory. If the dimension is available (i.e. in /execute in, or via - * the testmod's commands), then the bug is fixed and this Mixin can be removed. - */ -@Mixin(value = Main.class) -public class MainMixin { - @Unique - private static LevelStorage.Session session; - - @Unique - private static DynamicRegistryManager.Mutable drm; - - @Unique - private static DynamicOps ops; - - @ModifyVariable(method = "main", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/level/storage/LevelStorage;createSession(Ljava/lang/String;)Lnet/minecraft/world/level/storage/LevelStorage$Session;")) - private static LevelStorage.Session captureSession(LevelStorage.Session value) { - session = value; - return value; - } - - @ModifyVariable(method = "method_43613", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/util/registry/DynamicRegistryManager;createAndLoad()Lnet/minecraft/util/registry/DynamicRegistryManager$Mutable;")) - private static DynamicRegistryManager.Mutable captureDrm(DynamicRegistryManager.Mutable value) { - drm = value; - return value; - } - - // The value is stored as DynamicOps instead of RegistryOps in the bytecode - @ModifyVariable(method = "method_43613", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/util/dynamic/RegistryOps;ofLoaded(Lcom/mojang/serialization/DynamicOps;Lnet/minecraft/util/registry/DynamicRegistryManager$Mutable;Lnet/minecraft/resource/ResourceManager;)Lnet/minecraft/util/dynamic/RegistryOps;")) - private static DynamicOps captureOps(DynamicOps value) { - ops = value; - return value; - } - - @Redirect(method = "method_43613", at = @At(value = "NEW", target = "net/minecraft/world/level/LevelProperties")) - private static LevelProperties onCreateNewLevelProperties(LevelInfo levelInfo, GeneratorOptions generatorOptions, Lifecycle lifecycle) { - DataPackSettings dataPackSettings = levelInfo.getDataPackSettings(); - - // Save the level.dat file - session.backupLevelDataFile(drm, new LevelProperties(levelInfo, generatorOptions, lifecycle)); - - // And reload it again, and replace the actual level properties with it - return (LevelProperties) session.readLevelProperties(ops, dataPackSettings, drm.getRegistryLifecycle()); - } -} diff --git a/fabric-dimensions-v1/src/main/resources/fabric-dimensions-v1.mixins.json b/fabric-dimensions-v1/src/main/resources/fabric-dimensions-v1.mixins.json index 04fd4f95f..4e991ea62 100644 --- a/fabric-dimensions-v1/src/main/resources/fabric-dimensions-v1.mixins.json +++ b/fabric-dimensions-v1/src/main/resources/fabric-dimensions-v1.mixins.json @@ -4,8 +4,7 @@ "compatibilityLevel": "JAVA_16", "mixins": [ "EntityMixin", - "LevelStorageMixin", - "MainMixin" + "LevelStorageMixin" ], "injectors": { "defaultRequire": 1 diff --git a/fabric-entity-events-v1/src/client/java/net/fabricmc/fabric/mixin/entity/event/elytra/ClientPlayerEntityMixin.java b/fabric-entity-events-v1/src/client/java/net/fabricmc/fabric/mixin/entity/event/elytra/ClientPlayerEntityMixin.java index a9bb3197a..8a6cb7f87 100644 --- a/fabric-entity-events-v1/src/client/java/net/fabricmc/fabric/mixin/entity/event/elytra/ClientPlayerEntityMixin.java +++ b/fabric-entity-events-v1/src/client/java/net/fabricmc/fabric/mixin/entity/event/elytra/ClientPlayerEntityMixin.java @@ -30,14 +30,13 @@ import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.world.ClientWorld; import net.minecraft.item.Items; -import net.minecraft.network.encryption.PlayerPublicKey; import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; @SuppressWarnings("unused") @Mixin(ClientPlayerEntity.class) abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity { - ClientPlayerEntityMixin(ClientWorld world, GameProfile profile, PlayerPublicKey playerPublicKey) { - super(world, profile, playerPublicKey); + ClientPlayerEntityMixin(ClientWorld world, GameProfile profile) { + super(world, profile); throw new AssertionError(); } diff --git a/fabric-entity-events-v1/src/testmod/java/net/fabricmc/fabric/test/entity/event/DiamondElytraItem.java b/fabric-entity-events-v1/src/testmod/java/net/fabricmc/fabric/test/entity/event/DiamondElytraItem.java index 6ccb5d323..c568b5e54 100644 --- a/fabric-entity-events-v1/src/testmod/java/net/fabricmc/fabric/test/entity/event/DiamondElytraItem.java +++ b/fabric-entity-events-v1/src/testmod/java/net/fabricmc/fabric/test/entity/event/DiamondElytraItem.java @@ -19,12 +19,11 @@ package net.fabricmc.fabric.test.entity.event; import net.minecraft.entity.EquipmentSlot; import net.minecraft.item.ArmorItem; import net.minecraft.item.ArmorMaterials; -import net.minecraft.item.ItemGroup; import net.fabricmc.fabric.api.entity.event.v1.FabricElytraItem; public class DiamondElytraItem extends ArmorItem implements FabricElytraItem { public DiamondElytraItem() { - super(ArmorMaterials.DIAMOND, EquipmentSlot.CHEST, new Settings().maxCount(1).group(ItemGroup.COMBAT)); + super(ArmorMaterials.DIAMOND, EquipmentSlot.CHEST, new Settings().maxCount(1)); } } 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 60de1df3d..02eeaa962 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 @@ -27,7 +27,6 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.server.command.CommandManager; @@ -55,7 +54,7 @@ public final class EntityEventTests implements ModInitializer { @Override public void onInitialize() { Registry.register(Registry.BLOCK, new Identifier("fabric-entity-events-v1-testmod", "test_bed"), TEST_BED); - Registry.register(Registry.ITEM, new Identifier("fabric-entity-events-v1-testmod", "test_bed"), new BlockItem(TEST_BED, new Item.Settings().group(ItemGroup.DECORATIONS))); + Registry.register(Registry.ITEM, new Identifier("fabric-entity-events-v1-testmod", "test_bed"), new BlockItem(TEST_BED, new Item.Settings())); Registry.register(Registry.ITEM, new Identifier("fabric-entity-events-v1-testmod", "diamond_elytra"), DIAMOND_ELYTRA); ServerEntityCombatEvents.AFTER_KILLED_OTHER_ENTITY.register((world, entity, killed) -> { diff --git a/fabric-gametest-api-v1/src/main/java/net/fabricmc/fabric/mixin/gametest/server/MainMixin.java b/fabric-gametest-api-v1/src/main/java/net/fabricmc/fabric/mixin/gametest/server/MainMixin.java index 7be3cf465..218e9855e 100644 --- a/fabric-gametest-api-v1/src/main/java/net/fabricmc/fabric/mixin/gametest/server/MainMixin.java +++ b/fabric-gametest-api-v1/src/main/java/net/fabricmc/fabric/mixin/gametest/server/MainMixin.java @@ -47,7 +47,7 @@ public class MainMixin { } // Inject after resourcePackManager is stored - @Inject(method = "main", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", shift = At.Shift.BY, by = 2, target = "Lnet/minecraft/resource/ResourcePackManager;(Lnet/minecraft/resource/ResourceType;[Lnet/minecraft/resource/ResourcePackProvider;)V")) + @Inject(method = "main", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", shift = At.Shift.BY, by = 2, target = "Lnet/minecraft/resource/VanillaDataPackProvider;createManager(Ljava/nio/file/Path;)Lnet/minecraft/resource/ResourcePackManager;")) private static void main(String[] args, CallbackInfo info, OptionParser optionParser, OptionSpec optionSpec, OptionSpec optionSpec2, OptionSpec optionSpec3, OptionSpec optionSpec4, OptionSpec optionSpec5, OptionSpec optionSpec6, OptionSpec optionSpec7, OptionSpec optionSpec8, OptionSpec optionSpec9, OptionSpec optionSpec10, OptionSpec optionSpec11, OptionSpec optionSpec12, OptionSpec optionSpec13, OptionSpec optionSpec14, OptionSpec optionSpec15, OptionSet optionSet, Path path, ServerPropertiesLoader serverPropertiesLoader, Path path2, EulaReader eulaReader, File file, ApiServices lv, String string, LevelStorage levelStorage, LevelStorage.Session session, LevelSummary levelSummary, boolean bl, ResourcePackManager resourcePackManager) { if (FabricGameTestHelper.ENABLED) { FabricGameTestHelper.runHeadlessServer(session, resourcePackManager); diff --git a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/FabricItemSettings.java b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/FabricItemSettings.java index ff77de99b..d9121a443 100644 --- a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/FabricItemSettings.java +++ b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/api/item/v1/FabricItemSettings.java @@ -18,7 +18,6 @@ package net.fabricmc.fabric.api.item.v1; import net.minecraft.item.FoodComponent; import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.util.Rarity; @@ -46,6 +45,7 @@ public class FabricItemSettings extends Item.Settings { /** * Sets the custom damage handler of the item. * Note that this is only called on an ItemStack if {@link ItemStack#isDamageable()} returns true. + * * @see CustomDamageHandler */ public FabricItemSettings customDamage(CustomDamageHandler handler) { @@ -85,12 +85,6 @@ public class FabricItemSettings extends Item.Settings { return this; } - @Override - public FabricItemSettings group(ItemGroup group) { - super.group(group); - return this; - } - @Override public FabricItemSettings rarity(Rarity rarity) { super.rarity(rarity); diff --git a/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/FabricItemSettingsTests.java b/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/FabricItemSettingsTests.java index aa5c0fb43..d54c1d988 100644 --- a/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/FabricItemSettingsTests.java +++ b/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/FabricItemSettingsTests.java @@ -18,7 +18,6 @@ package net.fabricmc.fabric.test.item; import net.minecraft.entity.EquipmentSlot; import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; @@ -29,7 +28,7 @@ public class FabricItemSettingsTests implements ModInitializer { @Override public void onInitialize() { // Registers an item with a custom equipment slot. - Item testItem = new Item(new FabricItemSettings().group(ItemGroup.MISC).equipmentSlot(stack -> EquipmentSlot.CHEST)); + Item testItem = new Item(new FabricItemSettings().equipmentSlot(stack -> EquipmentSlot.CHEST)); Registry.register(Registry.ITEM, new Identifier("fabric-item-api-v1-testmod", "test_item"), testItem); } } diff --git a/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/UpdatingItem.java b/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/UpdatingItem.java index 44c295c02..9c9a0d982 100644 --- a/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/UpdatingItem.java +++ b/fabric-item-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/UpdatingItem.java @@ -27,7 +27,6 @@ import net.minecraft.entity.attribute.EntityAttributeModifier; import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; import net.minecraft.util.Hand; @@ -40,7 +39,7 @@ public class UpdatingItem extends Item { private final boolean allowUpdateAnimation; public UpdatingItem(boolean allowUpdateAnimation) { - super(new Settings().group(ItemGroup.MISC)); + super(new Settings()); this.allowUpdateAnimation = allowUpdateAnimation; } @@ -48,7 +47,7 @@ public class UpdatingItem extends Item { public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) { if (!world.isClient) { NbtCompound tag = stack.getOrCreateNbt(); - tag.putLong("ticks", tag.getLong("ticks")+1); + tag.putLong("ticks", tag.getLong("ticks") + 1); } } diff --git a/fabric-item-group-api-v1/build.gradle b/fabric-item-group-api-v1/build.gradle new file mode 100644 index 000000000..1c8135fb5 --- /dev/null +++ b/fabric-item-group-api-v1/build.gradle @@ -0,0 +1,11 @@ +archivesBaseName = "fabric-item-group-api-v1" +version = getSubprojectVersion(project) + +moduleDependencies(project, [ + 'fabric-api-base', + 'fabric-resource-loader-v0' +]) + +loom { + accessWidenerPath = file('src/main/resources/fabric-item-group-api-v1.accesswidener') +} diff --git a/fabric-item-groups-v0/src/client/java/net/fabricmc/fabric/impl/item/group/CreativeGuiExtensions.java b/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/impl/itemgroup/CreativeGuiExtensions.java similarity index 95% rename from fabric-item-groups-v0/src/client/java/net/fabricmc/fabric/impl/item/group/CreativeGuiExtensions.java rename to fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/impl/itemgroup/CreativeGuiExtensions.java index 4784157db..efd9c6e9f 100644 --- a/fabric-item-groups-v0/src/client/java/net/fabricmc/fabric/impl/item/group/CreativeGuiExtensions.java +++ b/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/impl/itemgroup/CreativeGuiExtensions.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package net.fabricmc.fabric.impl.item.group; +package net.fabricmc.fabric.impl.itemgroup; public interface CreativeGuiExtensions { void fabric_nextPage(); diff --git a/fabric-item-groups-v0/src/client/java/net/fabricmc/fabric/impl/item/group/FabricCreativeGuiComponents.java b/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/impl/itemgroup/FabricCreativeGuiComponents.java similarity index 83% rename from fabric-item-groups-v0/src/client/java/net/fabricmc/fabric/impl/item/group/FabricCreativeGuiComponents.java rename to fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/impl/itemgroup/FabricCreativeGuiComponents.java index db2e3c2a5..5a8253028 100644 --- a/fabric-item-groups-v0/src/client/java/net/fabricmc/fabric/impl/item/group/FabricCreativeGuiComponents.java +++ b/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/impl/itemgroup/FabricCreativeGuiComponents.java @@ -14,9 +14,8 @@ * limitations under the License. */ -package net.fabricmc.fabric.impl.item.group; +package net.fabricmc.fabric.impl.itemgroup; -import java.util.HashSet; import java.util.Set; import java.util.function.Consumer; @@ -26,23 +25,18 @@ import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemGroups; import net.minecraft.text.Text; import net.minecraft.util.Identifier; public class FabricCreativeGuiComponents { private static final Identifier BUTTON_TEX = new Identifier("fabric", "textures/gui/creative_buttons.png"); - public static final Set COMMON_GROUPS = new HashSet<>(); - - static { - COMMON_GROUPS.add(ItemGroup.SEARCH); - COMMON_GROUPS.add(ItemGroup.INVENTORY); - COMMON_GROUPS.add(ItemGroup.HOTBAR); - } + public static final Set COMMON_GROUPS = Set.of(ItemGroups.SEARCH, ItemGroups.INVENTORY, ItemGroups.HOTBAR); public static class ItemGroupButtonWidget extends ButtonWidget { - CreativeGuiExtensions extensions; - CreativeInventoryScreen gui; - Type type; + final CreativeGuiExtensions extensions; + final CreativeInventoryScreen gui; + final Type type; public ItemGroupButtonWidget(int x, int y, Type type, CreativeGuiExtensions extensions) { super(x, y, 11, 10, type.text, (bw) -> type.clickConsumer.accept(extensions)); @@ -66,7 +60,7 @@ public class FabricCreativeGuiComponents { this.drawTexture(matrixStack, this.x, this.y, u + (type == Type.NEXT ? 11 : 0), v, 11, 10); if (this.hovered) { - int pageCount = (int) Math.ceil((ItemGroup.GROUPS.length - COMMON_GROUPS.size()) / 9D); + int pageCount = (int) Math.ceil((ItemGroups.GROUPS.length - COMMON_GROUPS.size()) / 9D); gui.renderTooltip(matrixStack, Text.translatable("fabric.gui.creativeTabPage", extensions.fabric_currentPage() + 1, pageCount), mouseX, mouseY); } } @@ -77,8 +71,8 @@ public class FabricCreativeGuiComponents { NEXT(Text.literal(">"), CreativeGuiExtensions::fabric_nextPage), PREVIOUS(Text.literal("<"), CreativeGuiExtensions::fabric_previousPage); - Text text; - Consumer clickConsumer; + final Text text; + final Consumer clickConsumer; Type(Text text, Consumer clickConsumer) { this.text = text; diff --git a/fabric-item-groups-v0/src/client/java/net/fabricmc/fabric/mixin/item/group/client/CreativeInventoryScreenMixin.java b/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/mixin/itemgroup/client/CreativeInventoryScreenMixin.java similarity index 83% rename from fabric-item-groups-v0/src/client/java/net/fabricmc/fabric/mixin/item/group/client/CreativeInventoryScreenMixin.java rename to fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/mixin/itemgroup/client/CreativeInventoryScreenMixin.java index 6a12b8f44..fc21c7c68 100644 --- a/fabric-item-groups-v0/src/client/java/net/fabricmc/fabric/mixin/item/group/client/CreativeInventoryScreenMixin.java +++ b/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/mixin/itemgroup/client/CreativeInventoryScreenMixin.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package net.fabricmc.fabric.mixin.item.group.client; +package net.fabricmc.fabric.mixin.itemgroup.client; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -26,18 +26,19 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen; import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.screen.ScreenHandler; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemGroups; +import net.minecraft.screen.ScreenHandler; import net.minecraft.text.Text; -import net.fabricmc.fabric.impl.item.group.CreativeGuiExtensions; -import net.fabricmc.fabric.impl.item.group.FabricCreativeGuiComponents; +import net.fabricmc.fabric.impl.itemgroup.CreativeGuiExtensions; +import net.fabricmc.fabric.impl.itemgroup.FabricCreativeGuiComponents; @Mixin(CreativeInventoryScreen.class) -public abstract class CreativeInventoryScreenMixin extends AbstractInventoryScreen implements CreativeGuiExtensions { - public CreativeInventoryScreenMixin(ScreenHandler container_1, PlayerInventory playerInventory_1, Text textComponent_1) { - super(container_1, playerInventory_1, textComponent_1); +public abstract class CreativeInventoryScreenMixin extends AbstractInventoryScreen implements CreativeGuiExtensions { + public CreativeInventoryScreenMixin(T screenHandler, PlayerInventory playerInventory, Text text) { + super(screenHandler, playerInventory, text); } @Shadow @@ -50,14 +51,11 @@ public abstract class CreativeInventoryScreenMixin extends AbstractInventoryScre private static int fabric_currentPage = 0; private int fabric_getPageOffset(int page) { - switch (page) { - case 0: - return 0; - case 1: - return 12; - default: - return 12 + ((12 - FabricCreativeGuiComponents.COMMON_GROUPS.size()) * (page - 1)); - } + return switch (page) { + case 0 -> 0; + case 1 -> 12; + default -> 12 + ((12 - FabricCreativeGuiComponents.COMMON_GROUPS.size()) * (page - 1)); + }; } private int fabric_getOffsetPage(int offset) { @@ -70,7 +68,7 @@ public abstract class CreativeInventoryScreenMixin extends AbstractInventoryScre @Override public void fabric_nextPage() { - if (fabric_getPageOffset(fabric_currentPage + 1) >= ItemGroup.GROUPS.length) { + if (fabric_getPageOffset(fabric_currentPage + 1) >= ItemGroups.GROUPS.length) { return; } @@ -90,13 +88,13 @@ public abstract class CreativeInventoryScreenMixin extends AbstractInventoryScre @Override public boolean fabric_isButtonVisible(FabricCreativeGuiComponents.Type type) { - return ItemGroup.GROUPS.length > 12; + return ItemGroups.GROUPS.length > 12; } @Override public boolean fabric_isButtonEnabled(FabricCreativeGuiComponents.Type type) { if (type == FabricCreativeGuiComponents.Type.NEXT) { - return !(fabric_getPageOffset(fabric_currentPage + 1) >= ItemGroup.GROUPS.length); + return !(fabric_getPageOffset(fabric_currentPage + 1) >= ItemGroups.GROUPS.length); } if (type == FabricCreativeGuiComponents.Type.PREVIOUS) { @@ -112,7 +110,7 @@ public abstract class CreativeInventoryScreenMixin extends AbstractInventoryScre int curPos = getSelectedTab(); if (curPos < minPos || curPos > maxPos) { - setSelectedTab(ItemGroup.GROUPS[fabric_getPageOffset(fabric_currentPage)]); + setSelectedTab(ItemGroups.GROUPS[fabric_getPageOffset(fabric_currentPage)]); } } diff --git a/fabric-item-groups-v0/src/client/java/net/fabricmc/fabric/mixin/item/group/client/ItemGroupMixin.java b/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/mixin/itemgroup/client/ItemGroupMixin.java similarity index 93% rename from fabric-item-groups-v0/src/client/java/net/fabricmc/fabric/mixin/item/group/client/ItemGroupMixin.java rename to fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/mixin/itemgroup/client/ItemGroupMixin.java index b1920fbb3..7d33173d4 100644 --- a/fabric-item-groups-v0/src/client/java/net/fabricmc/fabric/mixin/item/group/client/ItemGroupMixin.java +++ b/fabric-item-group-api-v1/src/client/java/net/fabricmc/fabric/mixin/itemgroup/client/ItemGroupMixin.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package net.fabricmc.fabric.mixin.item.group.client; +package net.fabricmc.fabric.mixin.itemgroup.client; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -24,7 +24,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import net.minecraft.item.ItemGroup; -import net.fabricmc.fabric.impl.item.group.FabricCreativeGuiComponents; +import net.fabricmc.fabric.impl.itemgroup.FabricCreativeGuiComponents; @Mixin(ItemGroup.class) public abstract class ItemGroupMixin { diff --git a/fabric-item-groups-v0/src/client/resources/fabric-item-groups-v0.client.mixins.json b/fabric-item-group-api-v1/src/client/resources/fabric-item-group-api-v1.client.mixins.json similarity index 60% rename from fabric-item-groups-v0/src/client/resources/fabric-item-groups-v0.client.mixins.json rename to fabric-item-group-api-v1/src/client/resources/fabric-item-group-api-v1.client.mixins.json index a6555a8b2..7e0df6f45 100644 --- a/fabric-item-groups-v0/src/client/resources/fabric-item-groups-v0.client.mixins.json +++ b/fabric-item-group-api-v1/src/client/resources/fabric-item-group-api-v1.client.mixins.json @@ -1,7 +1,7 @@ { "required": true, - "package": "net.fabricmc.fabric.mixin.item.group.client", - "compatibilityLevel": "JAVA_16", + "package": "net.fabricmc.fabric.mixin.itemgroup.client", + "compatibilityLevel": "JAVA_17", "client": [ "ItemGroupMixin", "CreativeInventoryScreenMixin" diff --git a/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/api/itemgroup/v1/FabricItemGroup.java b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/api/itemgroup/v1/FabricItemGroup.java new file mode 100644 index 000000000..f0907497c --- /dev/null +++ b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/api/itemgroup/v1/FabricItemGroup.java @@ -0,0 +1,65 @@ +/* + * 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.itemgroup.v1; + +import java.util.Objects; + +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemGroups; +import net.minecraft.text.Text; +import net.minecraft.util.Identifier; + +import net.fabricmc.fabric.impl.itemgroup.ItemGroupHelper; + +/** + * Extend this abstract class to create a new {@link ItemGroup} for a mod. + * + *

Each new instance of this class is automatically appended to {@link ItemGroups#GROUPS}. + * + *

Example: + *

{@code
+ * public static final ItemGroup ITEM_GROUP = new FabricItemGroup(new Identifier("modid", "test_group")) {
+ *    @Override
+ *    public ItemStack createIcon() {
+ *       return new ItemStack(Items.DIAMOND);
+ *    }
+ *
+ *    @Override
+ *    protected void addItems(FeatureSet enabledFeatures, Entries entries) {
+ *       entries.add(TEST_ITEM);
+ *     }
+ * };
+ * }
+ */ +public abstract class FabricItemGroup extends ItemGroup implements IdentifiableItemGroup { + private final Identifier identifier; + + public FabricItemGroup(Identifier identifier) { + super(-1, getText(Objects.requireNonNull(identifier, "identifier"))); + this.identifier = identifier; + ItemGroupHelper.appendItemGroup(this); + } + + private static Text getText(Identifier identifier) { + return Text.translatable("itemGroup.%s.%s".formatted(identifier.getNamespace(), identifier.getPath())); + } + + @Override + public final Identifier getId() { + return identifier; + } +} diff --git a/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/api/itemgroup/v1/FabricItemGroupEntries.java b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/api/itemgroup/v1/FabricItemGroupEntries.java new file mode 100644 index 000000000..42046f642 --- /dev/null +++ b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/api/itemgroup/v1/FabricItemGroupEntries.java @@ -0,0 +1,464 @@ +/* + * 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.itemgroup.v1; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.function.Predicate; + +import org.jetbrains.annotations.ApiStatus; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemConvertible; +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemStack; +import net.minecraft.resource.featuretoggle.FeatureSet; + +/** + * This class allows the entries of {@linkplain ItemGroup item groups} to be modified by the events in {@link ItemGroupEvents}. + */ +@ApiStatus.Experimental +public class FabricItemGroupEntries implements ItemGroup.Entries { + private final FeatureSet enabledFeatures; + private final List displayStacks; + private final List searchTabStacks; + + @ApiStatus.Internal + public FabricItemGroupEntries(FeatureSet enabledFeatures, List displayStacks, List searchTabStacks) { + this.enabledFeatures = enabledFeatures; + this.displayStacks = displayStacks; + this.searchTabStacks = searchTabStacks; + } + + /** + * @return The currently enabled feature set. + */ + public FeatureSet getEnabledFeatures() { + return enabledFeatures; + } + + /** + * @return The stacks that will be shown in the tab in the creative mode inventory. This list can be modified. + */ + public List getDisplayStacks() { + return displayStacks; + } + + /** + * @return The stacks that will be searched by the creative mode inventory search. This list can be + * modified. + */ + public List getSearchTabStacks() { + return searchTabStacks; + } + + /** + * Adds a stack to the end of the item group. Duplicate stacks will be removed. + * + * @param visibility Determines whether the stack will be shown in the tab itself, returned + * for searches, or both. + */ + @Override + public void add(ItemStack stack, ItemGroup.StackVisibility visibility) { + if (isEnabled(stack)) { + switch (visibility) { + case PARENT_AND_SEARCH_TABS -> { + this.displayStacks.add(stack); + this.searchTabStacks.add(stack); + } + case PARENT_TAB_ONLY -> this.displayStacks.add(stack); + case SEARCH_TAB_ONLY -> this.searchTabStacks.add(stack); + } + } + } + + /** + * See {@link #prepend(ItemStack, ItemGroup.StackVisibility)}. Will use {@link ItemGroup.StackVisibility#PARENT_AND_SEARCH_TABS} + * for visibility. + */ + public void prepend(ItemStack stack) { + prepend(stack, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS); + } + + /** + * Adds a stack to the beginning of the item group. Duplicate stacks will be removed. + * + * @param visibility Determines whether the stack will be shown in the tab itself, returned + * for searches, or both. + */ + public void prepend(ItemStack stack, ItemGroup.StackVisibility visibility) { + if (isEnabled(stack)) { + switch (visibility) { + case PARENT_AND_SEARCH_TABS -> { + this.displayStacks.add(0, stack); + this.searchTabStacks.add(0, stack); + } + case PARENT_TAB_ONLY -> this.displayStacks.add(0, stack); + case SEARCH_TAB_ONLY -> this.searchTabStacks.add(0, stack); + } + } + } + + /** + * See {@link #prepend(ItemStack)}. Automatically creates an {@link ItemStack} from the given item. + */ + public void prepend(ItemConvertible item) { + prepend(item, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS); + } + + /** + * See {@link #prepend(ItemStack, net.minecraft.item.ItemGroup.StackVisibility)}. + * Automatically creates an {@link ItemStack} from the given item. + */ + public void prepend(ItemConvertible item, ItemGroup.StackVisibility visibility) { + prepend(new ItemStack(item), visibility); + } + + /** + * See {@link #addAfter(ItemConvertible, Collection)}. + */ + public void addAfter(ItemConvertible afterLast, ItemStack... newStack) { + addAfter(afterLast, Arrays.asList(newStack)); + } + + /** + * See {@link #addAfter(ItemStack, Collection)}. + */ + public void addAfter(ItemStack afterLast, ItemStack... newStack) { + addAfter(afterLast, Arrays.asList(newStack)); + } + + /** + * See {@link #addAfter(ItemConvertible, Collection)}. + */ + public void addAfter(ItemConvertible afterLast, ItemConvertible... newItem) { + addAfter(afterLast, Arrays.stream(newItem).map(ItemStack::new).toList()); + } + + /** + * See {@link #addAfter(ItemStack, Collection)}. + */ + public void addAfter(ItemStack afterLast, ItemConvertible... newItem) { + addAfter(afterLast, Arrays.stream(newItem).map(ItemStack::new).toList()); + } + + /** + * See {@link #addAfter(ItemConvertible, Collection, net.minecraft.item.ItemGroup.StackVisibility)}. + */ + public void addAfter(ItemConvertible afterLast, Collection newStacks) { + addAfter(afterLast, newStacks, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS); + } + + /** + * See {@link #addAfter(ItemStack, Collection, net.minecraft.item.ItemGroup.StackVisibility)}. + */ + public void addAfter(ItemStack afterLast, Collection newStacks) { + addAfter(afterLast, newStacks, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS); + } + + /** + * Adds stacks after an existing item in the group, or at the end, if the item isn't in the group. + * + * @param afterLast Add {@code newStacks} after the last entry of this item in the group. + * @param newStacks The stacks to add. Only {@linkplain #isEnabled(ItemStack) enabled} stacks will be added. + * @param visibility Determines whether the stack will be shown in the tab itself, returned + * for searches, or both. + */ + public void addAfter(ItemConvertible afterLast, Collection newStacks, ItemGroup.StackVisibility visibility) { + newStacks = getEnabledStacks(newStacks); + + if (newStacks.isEmpty()) { + return; + } + + switch (visibility) { + case PARENT_AND_SEARCH_TABS -> { + addAfter(afterLast, newStacks, displayStacks); + addAfter(afterLast, newStacks, searchTabStacks); + } + case PARENT_TAB_ONLY -> addAfter(afterLast, newStacks, displayStacks); + case SEARCH_TAB_ONLY -> addAfter(afterLast, newStacks, searchTabStacks); + } + } + + /** + * Adds stacks after an existing stack in the group, or at the end, if the stack isn't in the group. + * + * @param afterLast Add {@code newStacks} after the last group entry matching this stack (compared using {@link ItemStack#canCombine}). + * @param newStacks The stacks to add. Only {@linkplain #isEnabled(ItemStack) enabled} stacks will be added. + * @param visibility Determines whether the stack will be shown in the tab itself, returned + * for searches, or both. + */ + public void addAfter(ItemStack afterLast, Collection newStacks, ItemGroup.StackVisibility visibility) { + newStacks = getEnabledStacks(newStacks); + + if (newStacks.isEmpty()) { + return; + } + + switch (visibility) { + case PARENT_AND_SEARCH_TABS -> { + addAfter(afterLast, newStacks, displayStacks); + addAfter(afterLast, newStacks, searchTabStacks); + } + case PARENT_TAB_ONLY -> addAfter(afterLast, newStacks, displayStacks); + case SEARCH_TAB_ONLY -> addAfter(afterLast, newStacks, searchTabStacks); + } + } + + /** + * Adds stacks after the last group entry matching a predicate, or at the end, if no entries match. + * + * @param afterLast Add {@code newStacks} after the last group entry matching this predicate. + * @param newStacks The stacks to add. Only {@linkplain #isEnabled(ItemStack) enabled} stacks will be added. + * @param visibility Determines whether the stack will be shown in the tab itself, returned + * for searches, or both. + */ + public void addAfter(Predicate afterLast, Collection newStacks, ItemGroup.StackVisibility visibility) { + newStacks = getEnabledStacks(newStacks); + + if (newStacks.isEmpty()) { + return; + } + + switch (visibility) { + case PARENT_AND_SEARCH_TABS -> { + addAfter(afterLast, newStacks, displayStacks); + addAfter(afterLast, newStacks, searchTabStacks); + } + case PARENT_TAB_ONLY -> addAfter(afterLast, newStacks, displayStacks); + case SEARCH_TAB_ONLY -> addAfter(afterLast, newStacks, searchTabStacks); + } + } + + /** + * See {@link #addBefore(ItemConvertible, Collection)}. + */ + public void addBefore(ItemConvertible beforeFirst, ItemStack... newStack) { + addBefore(beforeFirst, Arrays.asList(newStack)); + } + + /** + * See {@link #addBefore(ItemStack, Collection)}. + */ + public void addBefore(ItemStack beforeFirst, ItemStack... newStack) { + addBefore(beforeFirst, Arrays.asList(newStack)); + } + + /** + * See {@link #addBefore(ItemConvertible, Collection)}. + */ + public void addBefore(ItemConvertible beforeFirst, ItemConvertible... newItem) { + addBefore(beforeFirst, Arrays.stream(newItem).map(ItemStack::new).toList()); + } + + /** + * See {@link #addBefore(ItemStack, Collection)}. + */ + public void addBefore(ItemStack beforeFirst, ItemConvertible... newItem) { + addBefore(beforeFirst, Arrays.stream(newItem).map(ItemStack::new).toList()); + } + + /** + * See {@link #addBefore(ItemConvertible, Collection, net.minecraft.item.ItemGroup.StackVisibility)}. + */ + public void addBefore(ItemConvertible beforeFirst, Collection newStacks) { + addBefore(beforeFirst, newStacks, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS); + } + + /** + * See {@link #addBefore(ItemStack, Collection, net.minecraft.item.ItemGroup.StackVisibility)}. + */ + public void addBefore(ItemStack beforeFirst, Collection newStacks) { + addBefore(beforeFirst, newStacks, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS); + } + + /** + * Adds stacks before an existing item in the group, or at the end, if the item isn't in the group. + * + * @param beforeFirst Add {@code newStacks} before the first entry of this item in the group. + * @param newStacks The stacks to add. Only {@linkplain #isEnabled(ItemStack) enabled} stacks will be added. + * @param visibility Determines whether the stack will be shown in the tab itself, returned + * for searches, or both. + */ + public void addBefore(ItemConvertible beforeFirst, Collection newStacks, ItemGroup.StackVisibility visibility) { + newStacks = getEnabledStacks(newStacks); + + if (newStacks.isEmpty()) { + return; + } + + switch (visibility) { + case PARENT_AND_SEARCH_TABS -> { + addBefore(beforeFirst, newStacks, displayStacks); + addBefore(beforeFirst, newStacks, searchTabStacks); + } + case PARENT_TAB_ONLY -> addBefore(beforeFirst, newStacks, displayStacks); + case SEARCH_TAB_ONLY -> addBefore(beforeFirst, newStacks, searchTabStacks); + } + } + + /** + * Adds stacks before an existing stack to the group, or at the end, if the stack isn't in the group. + * + * @param beforeFirst Add {@code newStacks} before the first group entry matching this stack (compared using {@link ItemStack#canCombine}). + * @param newStacks The stacks to add. Only {@linkplain #isEnabled(ItemStack) enabled} stacks will be added. + * @param visibility Determines whether the stack will be shown in the tab itself, returned + * for searches, or both. + */ + public void addBefore(ItemStack beforeFirst, Collection newStacks, ItemGroup.StackVisibility visibility) { + newStacks = getEnabledStacks(newStacks); + + if (newStacks.isEmpty()) { + return; + } + + switch (visibility) { + case PARENT_AND_SEARCH_TABS -> { + addBefore(beforeFirst, newStacks, displayStacks); + addBefore(beforeFirst, newStacks, searchTabStacks); + } + case PARENT_TAB_ONLY -> addBefore(beforeFirst, newStacks, displayStacks); + case SEARCH_TAB_ONLY -> addBefore(beforeFirst, newStacks, searchTabStacks); + } + } + + /** + * Adds stacks before the first group entry matching a predicate, or at the end, if no entries match. + * + * @param beforeFirst Add {@code newStacks} before the first group entry matching this predicate. + * @param newStacks The stacks to add. Only {@linkplain #isEnabled(ItemStack) enabled} stacks will be added. + * @param visibility Determines whether the stack will be shown in the tab itself, returned + * for searches, or both. + */ + public void addBefore(Predicate beforeFirst, Collection newStacks, ItemGroup.StackVisibility visibility) { + newStacks = getEnabledStacks(newStacks); + + if (newStacks.isEmpty()) { + return; + } + + switch (visibility) { + case PARENT_AND_SEARCH_TABS -> { + addBefore(beforeFirst, newStacks, displayStacks); + addBefore(beforeFirst, newStacks, searchTabStacks); + } + case PARENT_TAB_ONLY -> addBefore(beforeFirst, newStacks, displayStacks); + case SEARCH_TAB_ONLY -> addBefore(beforeFirst, newStacks, searchTabStacks); + } + } + + /** + * @return True if the item of a given stack is enabled in the current {@link FeatureSet}. + * @see Item#method_45382 + */ + private boolean isEnabled(ItemStack stack) { + return stack.getItem().method_45382(enabledFeatures); + } + + private Collection getEnabledStacks(Collection newStacks) { + // If not all stacks are enabled, filter the list, otherwise use it as-is + if (newStacks.stream().allMatch(this::isEnabled)) { + return newStacks; + } + + return newStacks.stream().filter(this::isEnabled).toList(); + } + + /** + * Adds the {@link ItemStack} before the first match, if no matches the {@link ItemStack} is appended to the end of the {@link ItemGroup}. + */ + private static void addBefore(Predicate predicate, Collection newStacks, List addTo) { + for (int i = 0; i < addTo.size(); i++) { + if (predicate.test(addTo.get(i))) { + addTo.subList(i, i).addAll(newStacks); + return; + } + } + + // Anchor not found, add to end + addTo.addAll(newStacks); + } + + private static void addAfter(Predicate predicate, Collection newStacks, List addTo) { + // Iterate in reverse to add after the last match + for (int i = addTo.size() - 1; i >= 0; i--) { + if (predicate.test(addTo.get(i))) { + addTo.subList(i + 1, i + 1).addAll(newStacks); + return; + } + } + + // Anchor not found, add to end + addTo.addAll(newStacks); + } + + private static void addBefore(ItemStack anchor, Collection newStacks, List addTo) { + for (int i = 0; i < addTo.size(); i++) { + if (ItemStack.canCombine(anchor, addTo.get(i))) { + addTo.subList(i, i).addAll(newStacks); + return; + } + } + + // Anchor not found, add to end + addTo.addAll(newStacks); + } + + private static void addAfter(ItemStack anchor, Collection newStacks, List addTo) { + // Iterate in reverse to add after the last match + for (int i = addTo.size() - 1; i >= 0; i--) { + if (ItemStack.canCombine(anchor, addTo.get(i))) { + addTo.subList(i + 1, i + 1).addAll(newStacks); + return; + } + } + + // Anchor not found, add to end + addTo.addAll(newStacks); + } + + private static void addBefore(ItemConvertible anchor, Collection newStacks, List addTo) { + Item anchorItem = anchor.asItem(); + + for (int i = 0; i < addTo.size(); i++) { + if (addTo.get(i).isOf(anchorItem)) { + addTo.subList(i, i).addAll(newStacks); + return; + } + } + + // Anchor not found, add to end + addTo.addAll(newStacks); + } + + private static void addAfter(ItemConvertible anchor, Collection newStacks, List addTo) { + Item anchorItem = anchor.asItem(); + + // Iterate in reverse to add after the last match + for (int i = addTo.size() - 1; i >= 0; i--) { + if (addTo.get(i).isOf(anchorItem)) { + addTo.subList(i + 1, i + 1).addAll(newStacks); + return; + } + } + + // Anchor not found, add to end + addTo.addAll(newStacks); + } +} diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/FabricNamespaceResourceManagerEntry.java b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/api/itemgroup/v1/IdentifiableItemGroup.java similarity index 61% rename from fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/FabricNamespaceResourceManagerEntry.java rename to fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/api/itemgroup/v1/IdentifiableItemGroup.java index 0fec2e908..13aabe23b 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/FabricNamespaceResourceManagerEntry.java +++ b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/api/itemgroup/v1/IdentifiableItemGroup.java @@ -14,10 +14,19 @@ * limitations under the License. */ -package net.fabricmc.fabric.impl.resource.loader; +package net.fabricmc.fabric.api.itemgroup.v1; -import net.minecraft.resource.ResourcePackSource; +import net.minecraft.item.ItemGroup; +import net.minecraft.util.Identifier; -public interface FabricNamespaceResourceManagerEntry { - void setFabricPackSource(ResourcePackSource packSource); +/** + * This interface is automatically injected to {@link ItemGroup}. + */ +public interface IdentifiableItemGroup { + /** + * {@return the unique identifier of this {@link ItemGroup}}. + */ + default Identifier getId() { + throw new AssertionError("Not implemented"); + } } diff --git a/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/api/itemgroup/v1/ItemGroupEvents.java b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/api/itemgroup/v1/ItemGroupEvents.java new file mode 100644 index 000000000..18d9bb793 --- /dev/null +++ b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/api/itemgroup/v1/ItemGroupEvents.java @@ -0,0 +1,67 @@ +/* + * 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.itemgroup.v1; + +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemGroups; +import net.minecraft.util.Identifier; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; +import net.fabricmc.fabric.impl.itemgroup.ItemGroupEventsImpl; + +/** + * Holds events related to {@link ItemGroups}. + * + * @see FabricItemGroup + */ +public final class ItemGroupEvents { + private ItemGroupEvents() { + } + + /** + * This event allows the entries of any item group to be modified. + *

+ * If you know beforehand which item group you'd like to modify, use {@link #modifyEntriesEvent(ItemGroup)} + * or {@link #modifyEntriesEvent(Identifier)} instead. + *

+ * This event is invoked after those two more specific events. + */ + public static final Event MODIFY_ENTRIES_ALL = EventFactory.createArrayBacked(ModifyEntriesAll.class, callbacks -> (group, entries) -> { + for (ModifyEntriesAll callback : callbacks) { + callback.modifyEntries(group, entries); + } + }); + + public static Event modifyEntriesEvent(ItemGroup itemGroup) { + return modifyEntriesEvent(itemGroup.getId()); + } + + public static Event modifyEntriesEvent(Identifier groupId) { + return ItemGroupEventsImpl.getOrCreateModifyEntriesEvent(groupId); + } + + @FunctionalInterface + public interface ModifyEntries { + void modifyEntries(FabricItemGroupEntries entries); + } + + @FunctionalInterface + public interface ModifyEntriesAll { + void modifyEntries(ItemGroup group, FabricItemGroupEntries entries); + } +} diff --git a/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/impl/itemgroup/ItemGroupEventsImpl.java b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/impl/itemgroup/ItemGroupEventsImpl.java new file mode 100644 index 000000000..c516791f1 --- /dev/null +++ b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/impl/itemgroup/ItemGroupEventsImpl.java @@ -0,0 +1,51 @@ +/* + * 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.impl.itemgroup; + +import java.util.HashMap; +import java.util.Map; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +import net.minecraft.util.Identifier; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; + +@ApiStatus.Internal +public class ItemGroupEventsImpl { + private static final Map> IDENTIFIER_EVENT_MAP = new HashMap<>(); + + public static Event getOrCreateModifyEntriesEvent(Identifier identifier) { + return IDENTIFIER_EVENT_MAP.computeIfAbsent(identifier, (g -> createModifyEvent())); + } + + @Nullable + public static Event getModifyEntriesEvent(Identifier identifier) { + return IDENTIFIER_EVENT_MAP.get(identifier); + } + + private static Event createModifyEvent() { + return EventFactory.createArrayBacked(ItemGroupEvents.ModifyEntries.class, callbacks -> (entries) -> { + for (ItemGroupEvents.ModifyEntries callback : callbacks) { + callback.modifyEntries(entries); + } + }); + } +} diff --git a/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/impl/itemgroup/ItemGroupHelper.java b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/impl/itemgroup/ItemGroupHelper.java new file mode 100644 index 000000000..dce2cf6e7 --- /dev/null +++ b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/impl/itemgroup/ItemGroupHelper.java @@ -0,0 +1,47 @@ +/* + * 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.impl.itemgroup; + +import org.apache.commons.lang3.ArrayUtils; +import org.jetbrains.annotations.ApiStatus; + +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemGroups; + +import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; +import net.fabricmc.fabric.mixin.itemgroup.ItemGroupAccessor; +import net.fabricmc.fabric.mixin.itemgroup.ItemGroupsAccessor; + +@ApiStatus.Internal +public final class ItemGroupHelper { + private ItemGroupHelper() { + } + + public static void appendItemGroup(FabricItemGroup itemGroup) { + for (ItemGroup existingGroup : ItemGroups.GROUPS) { + if (existingGroup.getId().equals(itemGroup.getId())) { + throw new IllegalStateException("Duplicate item group: " + itemGroup.getId()); + } + } + + final int index = ItemGroups.GROUPS.length; + final ItemGroup[] itemGroups = ArrayUtils.add(ItemGroups.GROUPS, itemGroup); + + ((ItemGroupAccessor) itemGroup).setIndex(index); + ItemGroupsAccessor.setGroups(ItemGroupsAccessor.invokeAsArray(itemGroups)); + } +} diff --git a/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/impl/itemgroup/MinecraftItemGroups.java b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/impl/itemgroup/MinecraftItemGroups.java new file mode 100644 index 000000000..dc4c0f710 --- /dev/null +++ b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/impl/itemgroup/MinecraftItemGroups.java @@ -0,0 +1,60 @@ +/* + * 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.impl.itemgroup; + +import java.util.Map; + +import com.google.common.collect.ImmutableMap; +import org.jetbrains.annotations.ApiStatus; + +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemGroups; +import net.minecraft.util.Identifier; + +@ApiStatus.Internal +public final class MinecraftItemGroups { + public static final Identifier BUILDING_BLOCKS_ID = new Identifier("minecraft:building_blocks"); + public static final Identifier NATURE_ID = new Identifier("minecraft:nature"); + public static final Identifier FUNCTIONAL_ID = new Identifier("minecraft:functional"); + public static final Identifier REDSTONE_ID = new Identifier("minecraft:redstone"); + public static final Identifier HOTBAR_ID = new Identifier("minecraft:hotbar"); + public static final Identifier SEARCH_ID = new Identifier("minecraft:search"); + public static final Identifier TOOLS_ID = new Identifier("minecraft:tools"); + public static final Identifier COMBAT_ID = new Identifier("minecraft:combat"); + public static final Identifier CONSUMABLES_ID = new Identifier("minecraft:consumables"); + public static final Identifier CRAFTING_ID = new Identifier("minecraft:crafting"); + public static final Identifier SPAWN_EGGS_ID = new Identifier("minecraft:spawn_eggs"); + public static final Identifier INVENTORY_ID = new Identifier("minecraft:inventory"); + + public static final Map GROUP_ID_MAP = new ImmutableMap.Builder() + .put(ItemGroups.BUILDING_BLOCKS, MinecraftItemGroups.BUILDING_BLOCKS_ID) + .put(ItemGroups.NATURE, MinecraftItemGroups.NATURE_ID) + .put(ItemGroups.FUNCTIONAL, MinecraftItemGroups.FUNCTIONAL_ID) + .put(ItemGroups.REDSTONE, MinecraftItemGroups.REDSTONE_ID) + .put(ItemGroups.HOTBAR, MinecraftItemGroups.HOTBAR_ID) + .put(ItemGroups.SEARCH, MinecraftItemGroups.SEARCH_ID) + .put(ItemGroups.TOOLS, MinecraftItemGroups.TOOLS_ID) + .put(ItemGroups.COMBAT, MinecraftItemGroups.COMBAT_ID) + .put(ItemGroups.CONSUMABLES, MinecraftItemGroups.CONSUMABLES_ID) + .put(ItemGroups.CRAFTING, MinecraftItemGroups.CRAFTING_ID) + .put(ItemGroups.SPAWN_EGGS, MinecraftItemGroups.SPAWN_EGGS_ID) + .put(ItemGroups.INVENTORY, MinecraftItemGroups.INVENTORY_ID) + .build(); + + private MinecraftItemGroups() { + } +} diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/FileResourcePackProviderAccessor.java b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/mixin/itemgroup/ItemGroupAccessor.java similarity index 69% rename from fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/FileResourcePackProviderAccessor.java rename to fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/mixin/itemgroup/ItemGroupAccessor.java index b09feee8c..b518f606c 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/FileResourcePackProviderAccessor.java +++ b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/mixin/itemgroup/ItemGroupAccessor.java @@ -14,16 +14,17 @@ * limitations under the License. */ -package net.fabricmc.fabric.mixin.resource.loader; +package net.fabricmc.fabric.mixin.itemgroup; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.gen.Accessor; -import net.minecraft.resource.FileResourcePackProvider; -import net.minecraft.resource.ResourcePackSource; +import net.minecraft.item.ItemGroup; -@Mixin(FileResourcePackProvider.class) -public interface FileResourcePackProviderAccessor { - @Accessor("source") - ResourcePackSource getResourcePackSource(); +@Mixin(ItemGroup.class) +public interface ItemGroupAccessor { + @Accessor + @Mutable + void setIndex(int index); } diff --git a/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/mixin/itemgroup/ItemGroupMixin.java b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/mixin/itemgroup/ItemGroupMixin.java new file mode 100644 index 000000000..e7970529e --- /dev/null +++ b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/mixin/itemgroup/ItemGroupMixin.java @@ -0,0 +1,95 @@ +/* + * 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.itemgroup; + +import java.util.LinkedList; +import java.util.Objects; + +import org.objectweb.asm.Opcodes; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemStackSet; +import net.minecraft.resource.featuretoggle.FeatureSet; +import net.minecraft.util.Identifier; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.itemgroup.v1.IdentifiableItemGroup; +import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroupEntries; +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; +import net.fabricmc.fabric.impl.itemgroup.ItemGroupEventsImpl; +import net.fabricmc.fabric.impl.itemgroup.MinecraftItemGroups; + +@Mixin(ItemGroup.class) +abstract class ItemGroupMixin implements IdentifiableItemGroup { + @Shadow + @Final + private int index; + + @Shadow + private ItemStackSet displayStacks; + + @Shadow + private ItemStackSet searchTabStacks; + + @SuppressWarnings("ConstantConditions") + @Inject(method = "getStacks", at = @At(value = "FIELD", target = "Lnet/minecraft/item/ItemGroup;searchTabStacks:Lnet/minecraft/item/ItemStackSet;", opcode = Opcodes.PUTFIELD, shift = At.Shift.AFTER)) + public void getStacks(FeatureSet enabledFeatures, boolean search, CallbackInfoReturnable cir) { + // Sanity check for the injection point. It should be after these fields are set. + Objects.requireNonNull(displayStacks, "displayStacks"); + Objects.requireNonNull(searchTabStacks, "searchTabStacks"); + + // Convert the entries to lists + var mutableDisplayStacks = new LinkedList<>(displayStacks); + var mutableSearchTabStacks = new LinkedList<>(searchTabStacks); + var entries = new FabricItemGroupEntries(enabledFeatures, mutableDisplayStacks, mutableSearchTabStacks); + + final Event modifyEntriesEvent = ItemGroupEventsImpl.getModifyEntriesEvent(getId()); + + if (modifyEntriesEvent != null) { + modifyEntriesEvent.invoker().modifyEntries(entries); + } + + // Now trigger the global event + ItemGroup self = (ItemGroup) (Object) this; + ItemGroupEvents.MODIFY_ENTRIES_ALL.invoker().modifyEntries(self, entries); + + // Convert the stacks back to sets after the events had a chance to modify them + displayStacks.clear(); + displayStacks.addAll(mutableDisplayStacks); + + searchTabStacks.clear(); + searchTabStacks.addAll(mutableSearchTabStacks); + } + + @Override + public Identifier getId() { + final Identifier identifier = MinecraftItemGroups.GROUP_ID_MAP.get((ItemGroup) (Object) this); + + if (identifier == null) { + // Fallback when no ID is found for this ItemGroup. + return new Identifier("minecraft", "unidentified_" + index); + } + + return identifier; + } +} diff --git a/fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/mixin/item/group/ItemGroupMixin.java b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/mixin/itemgroup/ItemGroupsAccessor.java similarity index 62% rename from fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/mixin/item/group/ItemGroupMixin.java rename to fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/mixin/itemgroup/ItemGroupsAccessor.java index 5e6194050..9c525f2e3 100644 --- a/fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/mixin/item/group/ItemGroupMixin.java +++ b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/mixin/itemgroup/ItemGroupsAccessor.java @@ -14,29 +14,28 @@ * limitations under the License. */ -package net.fabricmc.fabric.mixin.item.group; +package net.fabricmc.fabric.mixin.itemgroup; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.gen.Invoker; import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemGroups; -import net.fabricmc.fabric.impl.item.group.ItemGroupExtensions; - -@Mixin(ItemGroup.class) -public abstract class ItemGroupMixin implements ItemGroupExtensions { - @Shadow +@Mixin(ItemGroups.class) +public interface ItemGroupsAccessor { + @Accessor("GROUPS") @Final @Mutable - public static ItemGroup[] GROUPS; + static void setGroups(ItemGroup[] groups) { + throw new AssertionError(); + } - @Override - public void fabric_expandArray() { - ItemGroup[] tempGroups = GROUPS; - GROUPS = new ItemGroup[GROUPS.length + 1]; - - System.arraycopy(tempGroups, 0, GROUPS, 0, tempGroups.length); + @Invoker + static ItemGroup[] invokeAsArray(ItemGroup[] groups) { + throw new AssertionError(); } } 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 new file mode 100644 index 000000000..060eecb89 --- /dev/null +++ b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/mixin/itemgroup/ItemGroupsMixin.java @@ -0,0 +1,38 @@ +/* + * 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.itemgroup; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemGroups; + +@Mixin(ItemGroups.class) +abstract class ItemGroupsMixin { + @Inject(method = "asArray", at = @At("HEAD")) + private static void asArray(ItemGroup[] groups, CallbackInfoReturnable cir) { + // Ensure that all item groups have a nonnull id. + for (ItemGroup group : groups) { + if (group.getId() == null) { + throw new NullPointerException("Item group %s has a null id".formatted(group.getClass().getName())); + } + } + } +} diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric-item-groups-v0/icon.png b/fabric-item-group-api-v1/src/main/resources/assets/fabric-item-group-api-v1/icon.png similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric-item-groups-v0/icon.png rename to fabric-item-group-api-v1/src/main/resources/assets/fabric-item-group-api-v1/icon.png diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/lang/bg_bg.json b/fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/bg_bg.json similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric/lang/bg_bg.json rename to fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/bg_bg.json diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/lang/de_de.json b/fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/de_de.json similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric/lang/de_de.json rename to fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/de_de.json diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/lang/el_gr.json b/fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/el_gr.json similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric/lang/el_gr.json rename to fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/el_gr.json diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/lang/en_us.json b/fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/en_us.json similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric/lang/en_us.json rename to fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/en_us.json diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/lang/es_es.json b/fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/es_es.json similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric/lang/es_es.json rename to fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/es_es.json diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/lang/es_mx.json b/fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/es_mx.json similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric/lang/es_mx.json rename to fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/es_mx.json diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/lang/et_ee.json b/fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/et_ee.json similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric/lang/et_ee.json rename to fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/et_ee.json diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/lang/fa_ir.json b/fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/fa_ir.json similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric/lang/fa_ir.json rename to fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/fa_ir.json diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/lang/fi_fi.json b/fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/fi_fi.json similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric/lang/fi_fi.json rename to fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/fi_fi.json diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/lang/fr_fr.json b/fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/fr_fr.json similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric/lang/fr_fr.json rename to fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/fr_fr.json diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/lang/it_it.json b/fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/it_it.json similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric/lang/it_it.json rename to fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/it_it.json diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/lang/ja_jp.json b/fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/ja_jp.json similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric/lang/ja_jp.json rename to fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/ja_jp.json diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/lang/ko_kr.json b/fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/ko_kr.json similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric/lang/ko_kr.json rename to fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/ko_kr.json diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/lang/pl_pl.json b/fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/pl_pl.json similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric/lang/pl_pl.json rename to fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/pl_pl.json diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/lang/pt_br.json b/fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/pt_br.json similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric/lang/pt_br.json rename to fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/pt_br.json diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/lang/sv_se.json b/fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/sv_se.json similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric/lang/sv_se.json rename to fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/sv_se.json diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/lang/tr_tr.json b/fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/tr_tr.json similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric/lang/tr_tr.json rename to fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/tr_tr.json diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/lang/zh_cn.json b/fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/zh_cn.json similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric/lang/zh_cn.json rename to fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/zh_cn.json diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/lang/zh_tw.json b/fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/zh_tw.json similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric/lang/zh_tw.json rename to fabric-item-group-api-v1/src/main/resources/assets/fabric/lang/zh_tw.json diff --git a/fabric-item-groups-v0/src/main/resources/assets/fabric/textures/gui/creative_buttons.png b/fabric-item-group-api-v1/src/main/resources/assets/fabric/textures/gui/creative_buttons.png similarity index 100% rename from fabric-item-groups-v0/src/main/resources/assets/fabric/textures/gui/creative_buttons.png rename to fabric-item-group-api-v1/src/main/resources/assets/fabric/textures/gui/creative_buttons.png diff --git a/fabric-item-group-api-v1/src/main/resources/fabric-item-group-api-v1.accesswidener b/fabric-item-group-api-v1/src/main/resources/fabric-item-group-api-v1.accesswidener new file mode 100644 index 000000000..e49b76929 --- /dev/null +++ b/fabric-item-group-api-v1/src/main/resources/fabric-item-group-api-v1.accesswidener @@ -0,0 +1,6 @@ +accessWidener v2 named + +transitive-accessible class net/minecraft/item/ItemGroup$StackVisibility + +accessible class net/minecraft/item/ItemGroup$Entries +accessible class net/minecraft/item/ItemGroup$EntriesImpl diff --git a/fabric-item-group-api-v1/src/main/resources/fabric-item-group-api-v1.mixins.json b/fabric-item-group-api-v1/src/main/resources/fabric-item-group-api-v1.mixins.json new file mode 100644 index 000000000..cb3bcdf82 --- /dev/null +++ b/fabric-item-group-api-v1/src/main/resources/fabric-item-group-api-v1.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "package": "net.fabricmc.fabric.mixin.itemgroup", + "compatibilityLevel": "JAVA_17", + "mixins": [ + "ItemGroupsAccessor", + "ItemGroupMixin", + "ItemGroupAccessor", + "ItemGroupsMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/fabric-item-groups-v0/src/main/resources/fabric.mod.json b/fabric-item-group-api-v1/src/main/resources/fabric.mod.json similarity index 52% rename from fabric-item-groups-v0/src/main/resources/fabric.mod.json rename to fabric-item-group-api-v1/src/main/resources/fabric.mod.json index dfd9ac8f1..dbcba828d 100644 --- a/fabric-item-groups-v0/src/main/resources/fabric.mod.json +++ b/fabric-item-group-api-v1/src/main/resources/fabric.mod.json @@ -1,11 +1,11 @@ { "schemaVersion": 1, - "id": "fabric-item-groups-v0", - "name": "Fabric Item Groups (v0)", + "id": "fabric-item-group-api-v1", + "name": "Fabric Item Group API (v1)", "version": "${version}", "environment": "*", "license": "Apache-2.0", - "icon": "assets/fabric-item-groups-v0/icon.png", + "icon": "assets/fabric-item-group-api-v1/icon.png", "contact": { "homepage": "https://fabricmc.net", "irc": "irc://irc.esper.net:6667/fabric", @@ -16,20 +16,23 @@ "FabricMC" ], "depends": { - "fabricloader": ">=0.6.0", - "minecraft": ">=1.15-", + "fabricloader": ">=0.14.9", "fabric-api-base": "*", "fabric-resource-loader-v0": "*" }, "description": "An API for adding custom item groups.", "mixins": [ - "fabric-item-groups-v0.mixins.json", + "fabric-item-group-api-v1.mixins.json", { - "config": "fabric-item-groups-v0.client.mixins.json", + "config": "fabric-item-group-api-v1.client.mixins.json", "environment": "client" } ], + "accessWidener": "fabric-item-group-api-v1.accesswidener", "custom": { - "fabric-api:module-lifecycle": "stable" + "fabric-api:module-lifecycle": "stable", + "loom:injected_interfaces": { + "net/minecraft/class_1761": ["net/fabricmc/fabric/api/itemgroup/v1/IdentifiableItemGroup"] + } } } diff --git a/fabric-item-group-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/group/ItemGroupTest.java b/fabric-item-group-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/group/ItemGroupTest.java new file mode 100644 index 000000000..068751eb3 --- /dev/null +++ b/fabric-item-group-api-v1/src/testmod/java/net/fabricmc/fabric/test/item/group/ItemGroupTest.java @@ -0,0 +1,94 @@ +/* + * 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.item.group; + +import com.google.common.base.Preconditions; + +import net.minecraft.block.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemGroups; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.resource.featuretoggle.FeatureSet; +import net.minecraft.util.Identifier; +import net.minecraft.util.registry.Registry; + +import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; +import net.fabricmc.fabric.impl.itemgroup.MinecraftItemGroups; + +public class ItemGroupTest implements ModInitializer { + private static final String MOD_ID = "fabric-item-group-api-v1-testmod"; + private static Item TEST_ITEM; + + //Adds an item group with all items in it + private static final ItemGroup ITEM_GROUP = new FabricItemGroup(new Identifier(MOD_ID, "test_group")) { + @Override + public ItemStack createIcon() { + return new ItemStack(Items.DIAMOND); + } + + @Override + protected void addItems(FeatureSet featureSet, Entries entries) { + entries.addAll(Registry.ITEM.stream() + .map(ItemStack::new) + .toList()); + } + }; + + @Override + public void onInitialize() { + TEST_ITEM = Registry.register(Registry.ITEM, new Identifier("fabric-item-groups-v0-testmod", "item_test_group"), new Item(new Item.Settings())); + + checkAllVanillaGroupsHaveAssignedIds(); + + ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register((content) -> { + content.add(TEST_ITEM); + + content.addBefore(Blocks.OAK_FENCE, Items.DIAMOND, Items.DIAMOND_BLOCK); + content.addAfter(Blocks.OAK_DOOR, Items.EMERALD, Items.EMERALD_BLOCK); + + // Test adding when the existing entry does not exist. + content.addBefore(Blocks.BEDROCK, Items.GOLD_INGOT, Items.GOLD_BLOCK); + content.addAfter(Blocks.BEDROCK, Items.IRON_INGOT, Items.IRON_BLOCK); + }); + + // Add a differently damaged pickaxe to all groups + ItemGroupEvents.MODIFY_ENTRIES_ALL.register((group, content) -> { + ItemStack minDmgPickaxe = new ItemStack(Items.DIAMOND_PICKAXE); + minDmgPickaxe.setDamage(1); + content.prepend(minDmgPickaxe); + + ItemStack maxDmgPickaxe = new ItemStack(Items.DIAMOND_PICKAXE); + maxDmgPickaxe.setDamage(maxDmgPickaxe.getMaxDamage() - 1); + content.add(maxDmgPickaxe); + }); + } + + private static void checkAllVanillaGroupsHaveAssignedIds() { + for (ItemGroup group : ItemGroups.GROUPS) { + if (group instanceof FabricItemGroup) { + continue; // Skip groups added by test mods + } + + Preconditions.checkArgument(MinecraftItemGroups.GROUP_ID_MAP.containsKey(group), + "Missing ID for Vanilla ItemGroup %s. Assign one in MinecraftItemGroups.", group); + } + } +} diff --git a/fabric-item-groups-v0/src/testmod/resources/fabric.mod.json b/fabric-item-group-api-v1/src/testmod/resources/fabric.mod.json similarity index 62% rename from fabric-item-groups-v0/src/testmod/resources/fabric.mod.json rename to fabric-item-group-api-v1/src/testmod/resources/fabric.mod.json index 8485d086e..88ee994d5 100644 --- a/fabric-item-groups-v0/src/testmod/resources/fabric.mod.json +++ b/fabric-item-group-api-v1/src/testmod/resources/fabric.mod.json @@ -1,12 +1,12 @@ { "schemaVersion": 1, - "id": "fabric-item-groups-v0-testmod", - "name": "Fabric Item Groups (v0) Test Mod", + "id": "fabric-item-group-api-v1-testmod", + "name": "Fabric Item Group API (v1) Test Mod", "version": "1.0.0", "environment": "*", "license": "Apache-2.0", "depends": { - "fabric-item-groups-v0": "*" + "fabric-item-group-api-v1": "*" }, "entrypoints": { "main": [ diff --git a/fabric-item-groups-v0/build.gradle b/fabric-item-groups-v0/build.gradle deleted file mode 100644 index c83073e88..000000000 --- a/fabric-item-groups-v0/build.gradle +++ /dev/null @@ -1,7 +0,0 @@ -archivesBaseName = "fabric-item-groups-v0" -version = getSubprojectVersion(project) - -moduleDependencies(project, [ - 'fabric-api-base', - 'fabric-resource-loader-v0' -]) diff --git a/fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/api/client/itemgroup/FabricItemGroupBuilder.java b/fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/api/client/itemgroup/FabricItemGroupBuilder.java deleted file mode 100644 index 134ff5786..000000000 --- a/fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/api/client/itemgroup/FabricItemGroupBuilder.java +++ /dev/null @@ -1,185 +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.client.itemgroup; - -import java.util.List; -import java.util.Objects; -import java.util.function.BiConsumer; -import java.util.function.Consumer; -import java.util.function.Supplier; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Identifier; -import net.minecraft.util.collection.DefaultedList; - -import net.fabricmc.fabric.impl.item.group.ItemGroupExtensions; - -/** - * A builder for {@link ItemGroup}. Item groups are used to group items in the creative - * inventory. - * - *

Example of creating an empty group (recommended for modded item-only group):

- *
{@code
- * MY_GROUP = FabricItemGroupBuilder.build(
- * 	new Identifier("my_mod", "example_group"),
- * 	() -> new ItemStack(MY_ITEM);
- * );
- * // Use item settings to assign a group. Otherwise, it won't appear on creative inventory
- * // search result.
- * MY_ITEM = new Item(new Item.Settings().group(MY_GROUP));
- * }
- * - *

Example of creating a group with vanilla item stacks:

- *
{@code
- * ItemGroup myGroup = FabricItemGroupBuilder.create(new Identifier("my_mod", "group_2"))
- * 	.icon(Items.STONE::getDefaultStack)
- * 	.appendItems((stacks) -> {
- * 	   stacks.add(new ItemStack(Items.STONE));
- * 	   stacks.add(new ItemStack(Items.COBBLESTONE));
- * 	})
- * 	.build();
- * }
- * - * - *

Creative inventory search is implemented as a special item group. Adding items with - * the builder by default does not add them to the search result; to make the item searchable, - * set the item group via {@link Item.Settings#group(ItemGroup)} as well. If there are - * multiple searchable item stacks of the item (such as colored variants or ones with - * different NBT), override {@link Item#appendStacks(ItemGroup, DefaultedList)} on your - * item as well. This should be called by {@link #appendItems(BiConsumer)} to actually add - * items to your item group.

- */ -public final class FabricItemGroupBuilder { - private final Identifier identifier; - private Supplier stackSupplier = () -> ItemStack.EMPTY; - private BiConsumer, ItemGroup> stacksForDisplay; - - private FabricItemGroupBuilder(Identifier identifier) { - Objects.requireNonNull(identifier, "identifier cannot be null"); - this.identifier = identifier; - } - - /** - * Creates a new item group builder. - * - * @param identifier the id of the ItemGroup, to be used as the translation key - * @return a new builder - */ - public static FabricItemGroupBuilder create(Identifier identifier) { - return new FabricItemGroupBuilder(identifier); - } - - /** - * Sets an icon for the group. This is displayed on the creative inventory tab. - * - * @param stackSupplier the supplier that returns the item stack to be used as an icon - * @return this builder - */ - public FabricItemGroupBuilder icon(Supplier stackSupplier) { - Objects.requireNonNull(stackSupplier, "icon cannot be null"); - this.stackSupplier = stackSupplier; - return this; - } - - /** - * This allows for a custom list of items to be displayed in a tab, this enabled tabs to be created with a custom set of items. - * - * @param appender Add ItemStack's to this list to show in the ItemGroup - * @return a reference to the FabricItemGroupBuilder - * @deprecated use {@link FabricItemGroupBuilder#appendItems(Consumer)} - */ - @Deprecated - public FabricItemGroupBuilder stacksForDisplay(Consumer> appender) { - return appendItems(appender); - } - - /** - * Sets the item stacks of this item group, by having the consumer add them to the passed list. - * This bypasses {@link Item#appendStacks}, and by default, does not append the stack to the search result. - * To add modded items, consider setting the group via {@linkplain Item.Settings#group(ItemGroup) - * item groups} in addition to this, as that adds the item stack to the search result. - * See the creative inventory searching section for details. - * - *

Calling this multiple times overwrites the previously set stacks.

- * - * @param stacksForDisplay a callback that adds item stacks to the passed list - * @return this builder - */ - public FabricItemGroupBuilder appendItems(Consumer> stacksForDisplay) { - return appendItems((itemStacks, itemGroup) -> stacksForDisplay.accept(itemStacks)); - } - - /** - * Sets the item stacks of this item group, by having the consumer add them to the passed list. - * This bypasses {@link Item#appendStacks}, and by default, does not append the stack to the search result. - * To add modded items, consider setting the group via {@linkplain Item.Settings#group(ItemGroup) - * item groups} in addition to this, as that adds the item stack to the search result. - * See the creative inventory searching section for details. - * - *

Compared to the other overload, this one also passes the new ItemGroup. - * This allows you to call {@link Item#appendStacks} yourself if you want.

- * - *

Calling this multiple times overwrites the previously set stacks.

- * - * @param stacksForDisplay a callback that adds item stacks to the passed list - * @return this builder - */ - public FabricItemGroupBuilder appendItems(BiConsumer, ItemGroup> stacksForDisplay) { - this.stacksForDisplay = stacksForDisplay; - return this; - } - - /** - * This is a single method that makes creating an empty ItemGroup with an icon one call. - * Items should be added using {@linkplain Item.Settings#group(ItemGroup) item settings}. - * Useful for modded item-only group. - * - * @param identifier the id of the ItemGroup, to be used as the translation key - * @param stackSupplier the supplier that returns the item stack to be used as an icon - * @return an instance of the built ItemGroup - */ - public static ItemGroup build(Identifier identifier, Supplier stackSupplier) { - return new FabricItemGroupBuilder(identifier).icon(stackSupplier).build(); - } - - /** - * Creates an instance of the ItemGroup. - * - * @return an instance of the built ItemGroup - */ - public ItemGroup build() { - ((ItemGroupExtensions) ItemGroup.BUILDING_BLOCKS).fabric_expandArray(); - return new ItemGroup(ItemGroup.GROUPS.length - 1, String.format("%s.%s", identifier.getNamespace(), identifier.getPath())) { - @Override - public ItemStack createIcon() { - return stackSupplier.get(); - } - - @Override - public void appendStacks(DefaultedList stacks) { - if (stacksForDisplay != null) { - stacksForDisplay.accept(stacks, this); - return; - } - - super.appendStacks(stacks); - } - }; - } -} diff --git a/fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/impl/item/group/ItemGroupExtensions.java b/fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/impl/item/group/ItemGroupExtensions.java deleted file mode 100644 index fbfb3ae3e..000000000 --- a/fabric-item-groups-v0/src/main/java/net/fabricmc/fabric/impl/item/group/ItemGroupExtensions.java +++ /dev/null @@ -1,21 +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.impl.item.group; - -public interface ItemGroupExtensions { - void fabric_expandArray(); -} diff --git a/fabric-item-groups-v0/src/main/resources/fabric-item-groups-v0.mixins.json b/fabric-item-groups-v0/src/main/resources/fabric-item-groups-v0.mixins.json deleted file mode 100644 index 1c704f60b..000000000 --- a/fabric-item-groups-v0/src/main/resources/fabric-item-groups-v0.mixins.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "required": true, - "package": "net.fabricmc.fabric.mixin.item.group", - "compatibilityLevel": "JAVA_16", - "mixins": [ - "ItemGroupMixin" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/fabric-item-groups-v0/src/testmod/java/net/fabricmc/fabric/test/item/group/ItemGroupTest.java b/fabric-item-groups-v0/src/testmod/java/net/fabricmc/fabric/test/item/group/ItemGroupTest.java deleted file mode 100644 index 9fd22c9a7..000000000 --- a/fabric-item-groups-v0/src/testmod/java/net/fabricmc/fabric/test/item/group/ItemGroupTest.java +++ /dev/null @@ -1,61 +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.item.group; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; - -import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder; - -public class ItemGroupTest implements ModInitializer { - private static Item TEST_ITEM; - - //Adds an item group with all items in it - private static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.create(new Identifier("fabric-item-groups-v0-testmod", "test_group")) - .icon(() -> new ItemStack(Items.DIAMOND)) - .appendItems(stacks -> - Registry.ITEM.stream() - .map(ItemStack::new) - .forEach(stacks::add) - ).build(); - - private static final ItemGroup ITEM_GROUP_2 = FabricItemGroupBuilder.create(new Identifier("fabric-item-groups-v0-testmod", "test_group_two")) - .icon(() -> new ItemStack(Items.REDSTONE)) - .appendItems((stacks, itemGroup) -> { - for (Item item : Registry.ITEM) { - if (item.getGroup() == ItemGroup.FOOD || item.getGroup() == itemGroup) { - stacks.add(new ItemStack(item)); - } - } - }).build(); - - @Override - public void onInitialize() { - TEST_ITEM = Registry.register(Registry.ITEM, new Identifier("fabric-item-groups-v0-testmod", "item_test_group"), new Item(new Item.Settings().group(ITEM_GROUP_2))); - - // Exactly two pages of item groups - for (int i = 3; i < 10; i++) { - Item iconItem = Registry.ITEM.get(i); - FabricItemGroupBuilder.build(new Identifier("fabric-item-groups-v0-testmod", "test_group_" + i), () -> new ItemStack(iconItem)); - } - } -} diff --git a/fabric-lifecycle-events-v1/src/client/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientPlayNetworkHandlerMixin.java b/fabric-lifecycle-events-v1/src/client/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientPlayNetworkHandlerMixin.java index 6da122f45..15ee67a71 100644 --- a/fabric-lifecycle-events-v1/src/client/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientPlayNetworkHandlerMixin.java +++ b/fabric-lifecycle-events-v1/src/client/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientPlayNetworkHandlerMixin.java @@ -29,7 +29,6 @@ import net.minecraft.entity.Entity; import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket; import net.minecraft.network.packet.s2c.play.PlayerRespawnS2CPacket; import net.minecraft.network.packet.s2c.play.SynchronizeTagsS2CPacket; -import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.world.chunk.WorldChunk; import net.fabricmc.api.EnvType; @@ -44,8 +43,6 @@ import net.fabricmc.fabric.impl.event.lifecycle.LoadedChunksCache; abstract class ClientPlayNetworkHandlerMixin { @Shadow private ClientWorld world; - @Shadow - private DynamicRegistryManager.Immutable registryManager; @Inject(method = "onPlayerRespawn", at = @At(value = "NEW", target = "net/minecraft/client/world/ClientWorld")) private void onPlayerRespawn(PlayerRespawnS2CPacket packet, CallbackInfo ci) { @@ -102,6 +99,7 @@ abstract class ClientPlayNetworkHandlerMixin { } } + @SuppressWarnings("ConstantConditions") @Inject( method = "onSynchronizeTags", at = @At( @@ -111,6 +109,7 @@ abstract class ClientPlayNetworkHandlerMixin { ) ) private void hookOnSynchronizeTags(SynchronizeTagsS2CPacket packet, CallbackInfo ci) { - CommonLifecycleEvents.TAGS_LOADED.invoker().onTagsLoaded(registryManager, true); + ClientPlayNetworkHandler self = (ClientPlayNetworkHandler) (Object) this; + CommonLifecycleEvents.TAGS_LOADED.invoker().onTagsLoaded(self.getRegistryManager(), true); } } diff --git a/fabric-loot-api-v2/src/main/java/net/fabricmc/fabric/impl/loot/LootUtil.java b/fabric-loot-api-v2/src/main/java/net/fabricmc/fabric/impl/loot/LootUtil.java index 9fd3ff024..82f02a2a3 100644 --- a/fabric-loot-api-v2/src/main/java/net/fabricmc/fabric/impl/loot/LootUtil.java +++ b/fabric-loot-api-v2/src/main/java/net/fabricmc/fabric/impl/loot/LootUtil.java @@ -35,7 +35,7 @@ public final class LootUtil { if (resource != null) { ResourcePackSource packSource = ((FabricResource) resource).getFabricPackSource(); - if (packSource == ResourcePackSource.PACK_SOURCE_BUILTIN) { + if (packSource == ResourcePackSource.BUILTIN) { return LootTableSource.VANILLA; } else if (packSource == ModResourcePackCreator.RESOURCE_PACK_SOURCE || packSource instanceof BuiltinModResourcePackSource) { return LootTableSource.MOD; diff --git a/fabric-message-api-v1/src/main/java/net/fabricmc/fabric/mixin/message/PlayerManagerMixin.java b/fabric-message-api-v1/src/main/java/net/fabricmc/fabric/mixin/message/PlayerManagerMixin.java index 60ae903d5..3ecf8e6c1 100644 --- a/fabric-message-api-v1/src/main/java/net/fabricmc/fabric/mixin/message/PlayerManagerMixin.java +++ b/fabric-message-api-v1/src/main/java/net/fabricmc/fabric/mixin/message/PlayerManagerMixin.java @@ -16,7 +16,6 @@ package net.fabricmc.fabric.mixin.message; -import java.util.Set; import java.util.function.Function; import org.spongepowered.asm.mixin.Final; @@ -42,16 +41,9 @@ public abstract class PlayerManagerMixin { @Final private MinecraftServer server; - @Shadow - public abstract void sendMessageHeader(SignedMessage message, Set except); - @Inject(method = "broadcast(Lnet/minecraft/network/message/SignedMessage;Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/network/message/MessageType$Parameters;)V", at = @At("HEAD"), cancellable = true) private void onSendChatMessage(SignedMessage message, ServerPlayerEntity sender, MessageType.Parameters params, CallbackInfo ci) { if (!ServerMessageEvents.ALLOW_CHAT_MESSAGE.invoker().allowChatMessage(message, sender, params)) { - if (!message.headerSignature().isEmpty()) { - sendMessageHeader(message, Set.of()); - } - ci.cancel(); return; } @@ -72,10 +64,6 @@ public abstract class PlayerManagerMixin { @Inject(method = "broadcast(Lnet/minecraft/network/message/SignedMessage;Lnet/minecraft/server/command/ServerCommandSource;Lnet/minecraft/network/message/MessageType$Parameters;)V", at = @At("HEAD"), cancellable = true) private void onSendCommandMessage(SignedMessage message, ServerCommandSource source, MessageType.Parameters params, CallbackInfo ci) { if (!ServerMessageEvents.ALLOW_COMMAND_MESSAGE.invoker().allowCommandMessage(message, source, params)) { - if (!message.headerSignature().isEmpty()) { - sendMessageHeader(message, Set.of()); - } - ci.cancel(); return; } diff --git a/fabric-message-api-v1/src/testmod/java/net/fabricmc/fabric/test/message/ChatTest.java b/fabric-message-api-v1/src/testmod/java/net/fabricmc/fabric/test/message/ChatTest.java index a782f4c79..993028dd4 100644 --- a/fabric-message-api-v1/src/testmod/java/net/fabricmc/fabric/test/message/ChatTest.java +++ b/fabric-message-api-v1/src/testmod/java/net/fabricmc/fabric/test/message/ChatTest.java @@ -95,7 +95,7 @@ public class ChatTest implements ModInitializer { // ServerMessageEvents blocking ServerMessageEvents.ALLOW_CHAT_MESSAGE.register( - (message, sender, params) -> !message.getContent().getString().contains("sadtater") + (message, sender, params) -> !message.getSignedContent().contains("sadtater") ); ServerMessageEvents.ALLOW_GAME_MESSAGE.register((server, message, overlay) -> { if (message.getContent() instanceof TranslatableTextContent translatable) { @@ -105,7 +105,7 @@ public class ChatTest implements ModInitializer { return true; }); ServerMessageEvents.ALLOW_COMMAND_MESSAGE.register( - (message, source, params) -> !message.getContent().getString().contains("sadtater") + (message, source, params) -> !message.getSignedContent().contains("sadtater") ); } } diff --git a/fabric-mining-level-api-v1/src/testmod/java/net/fabricmc/fabric/test/mininglevel/MiningLevelTest.java b/fabric-mining-level-api-v1/src/testmod/java/net/fabricmc/fabric/test/mininglevel/MiningLevelTest.java index 8157d36a3..1821228b6 100644 --- a/fabric-mining-level-api-v1/src/testmod/java/net/fabricmc/fabric/test/mininglevel/MiningLevelTest.java +++ b/fabric-mining-level-api-v1/src/testmod/java/net/fabricmc/fabric/test/mininglevel/MiningLevelTest.java @@ -19,8 +19,8 @@ package net.fabricmc.fabric.test.mininglevel; import java.util.ArrayList; import java.util.List; -import org.slf4j.LoggerFactory; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; @@ -29,7 +29,6 @@ import net.minecraft.block.Blocks; import net.minecraft.block.Material; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.util.Identifier; @@ -80,7 +79,7 @@ public final class MiningLevelTest implements ModInitializer { private static void register(String id, Block block) { Identifier identifier = new Identifier(ID, id); Registry.register(Registry.BLOCK, identifier, block); - Registry.register(Registry.ITEM, identifier, new BlockItem(block, new Item.Settings().group(ItemGroup.MISC))); + Registry.register(Registry.ITEM, identifier, new BlockItem(block, new Item.Settings())); } private static void test() { diff --git a/fabric-models-v0/src/client/java/net/fabricmc/fabric/mixin/client/model/ModelLoaderMixin.java b/fabric-models-v0/src/client/java/net/fabricmc/fabric/mixin/client/model/ModelLoaderMixin.java index f67f1d4d7..b16480a41 100644 --- a/fabric-models-v0/src/client/java/net/fabricmc/fabric/mixin/client/model/ModelLoaderMixin.java +++ b/fabric-models-v0/src/client/java/net/fabricmc/fabric/mixin/client/model/ModelLoaderMixin.java @@ -26,6 +26,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.model.ModelLoader; import net.minecraft.client.render.model.UnbakedModel; import net.minecraft.client.util.ModelIdentifier; @@ -43,9 +44,6 @@ public abstract class ModelLoaderMixin implements ModelLoaderHooks { public static ModelIdentifier MISSING_ID; @Final @Shadow - private ResourceManager resourceManager; - @Final - @Shadow private Set modelsToLoad; @Final @Shadow @@ -57,15 +55,19 @@ public abstract class ModelLoaderMixin implements ModelLoaderHooks { private ModelLoadingRegistryImpl.LoaderInstance fabric_mlrLoaderInstance; @Shadow - private void addModel(ModelIdentifier id) { } + private void addModel(ModelIdentifier id) { + } @Shadow - private void putModel(Identifier id, UnbakedModel unbakedModel) { } + private void putModel(Identifier id, UnbakedModel unbakedModel) { + } @Shadow - private void loadModel(Identifier id) { } + private void loadModel(Identifier id) { + } - @Shadow public abstract UnbakedModel getOrLoadModel(Identifier id); + @Shadow + public abstract UnbakedModel getOrLoadModel(Identifier id); @Inject(at = @At("HEAD"), method = "loadModel", cancellable = true) private void loadModelHook(Identifier id, CallbackInfo ci) { @@ -83,6 +85,7 @@ public abstract class ModelLoaderMixin implements ModelLoaderHooks { //noinspection RedundantCast ModelLoaderHooks hooks = this; + ResourceManager resourceManager = MinecraftClient.getInstance().getResourceManager(); fabric_mlrLoaderInstance = ModelLoadingRegistryImpl.begin((ModelLoader) (Object) this, resourceManager); fabric_mlrLoaderInstance.onModelPopulation(hooks::fabric_addModel); } diff --git a/fabric-models-v0/src/testmod/resources/fabric.mod.json b/fabric-models-v0/src/testmod/resources/fabric.mod.json index 655f6b811..83599a1f7 100644 --- a/fabric-models-v0/src/testmod/resources/fabric.mod.json +++ b/fabric-models-v0/src/testmod/resources/fabric.mod.json @@ -7,7 +7,6 @@ "license": "Apache-2.0", "depends": { "fabric-models-v0": "*", - "fabric-renderer-registries-v1": "*", "fabric-resource-loader-v0": "*" }, "entrypoints": { 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 5129a178f..1f511a2e9 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 @@ -21,15 +21,16 @@ import java.util.function.Supplier; import com.google.common.collect.ImmutableSet; +import net.minecraft.block.Block; import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.SpawnGroup; import net.minecraft.entity.EntityDimensions; import net.minecraft.entity.EntityType; -import net.minecraft.block.Block; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.SpawnGroup; import net.minecraft.entity.SpawnRestriction; import net.minecraft.entity.attribute.DefaultAttributeContainer; import net.minecraft.entity.mob.MobEntity; +import net.minecraft.resource.featuretoggle.FeatureFlags; import net.minecraft.world.Heightmap; import net.minecraft.world.World; @@ -260,7 +261,7 @@ public class FabricEntityTypeBuilder { // TODO: Flesh out once modded datafixers exist. } - EntityType type = new FabricEntityType<>(this.factory, this.spawnGroup, this.saveable, this.summonable, this.fireImmune, this.spawnableFarFromPlayer, this.specificSpawnBlocks, dimensions, trackRange, trackedUpdateRate, forceTrackedVelocityUpdates); + EntityType type = new FabricEntityType<>(this.factory, this.spawnGroup, this.saveable, this.summonable, this.fireImmune, this.spawnableFarFromPlayer, this.specificSpawnBlocks, dimensions, trackRange, trackedUpdateRate, forceTrackedVelocityUpdates, FeatureFlags.DEFAULT_ENABLED_FEATURES); return type; } diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/impl/object/builder/FabricEntityType.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/impl/object/builder/FabricEntityType.java index 0d74fce13..7b68ef0f4 100644 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/impl/object/builder/FabricEntityType.java +++ b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/impl/object/builder/FabricEntityType.java @@ -23,12 +23,13 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.SpawnGroup; import net.minecraft.entity.EntityDimensions; import net.minecraft.entity.EntityType; +import net.minecraft.resource.featuretoggle.FeatureSet; public class FabricEntityType extends EntityType { private final Boolean alwaysUpdateVelocity; - public FabricEntityType(EntityType.EntityFactory factory, SpawnGroup spawnGroup, boolean bl, boolean summonable, boolean fireImmune, boolean spawnableFarFromPlayer, ImmutableSet spawnBlocks, EntityDimensions entityDimensions, int maxTrackDistance, int trackTickInterval, Boolean alwaysUpdateVelocity) { - super(factory, spawnGroup, bl, summonable, fireImmune, spawnableFarFromPlayer, spawnBlocks, entityDimensions, maxTrackDistance, trackTickInterval); + public FabricEntityType(EntityType.EntityFactory factory, SpawnGroup spawnGroup, boolean bl, boolean summonable, boolean fireImmune, boolean spawnableFarFromPlayer, ImmutableSet spawnBlocks, EntityDimensions entityDimensions, int maxTrackDistance, int trackTickInterval, Boolean alwaysUpdateVelocity, FeatureSet featureSet) { + super(factory, spawnGroup, bl, summonable, fireImmune, spawnableFarFromPlayer, spawnBlocks, entityDimensions, maxTrackDistance, trackTickInterval, featureSet); this.alwaysUpdateVelocity = alwaysUpdateVelocity; } 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 ae7246fe2..f5f6da268 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 @@ -27,7 +27,6 @@ import net.minecraft.block.entity.BlockEntityType; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; @@ -72,7 +71,7 @@ public class BlockEntityTypeBuilderTest implements ModInitializer { private static void register(Identifier id, Block block) { Registry.register(Registry.BLOCK, id, block); - Item item = new BlockItem(block, new Item.Settings().group(ItemGroup.MISC)); + Item item = new BlockItem(block, new Item.Settings()); Registry.register(Registry.ITEM, id, item); } diff --git a/fabric-registry-sync-v0/build.gradle b/fabric-registry-sync-v0/build.gradle index 8f2bdc1fe..0b8474ae9 100644 --- a/fabric-registry-sync-v0/build.gradle +++ b/fabric-registry-sync-v0/build.gradle @@ -1,6 +1,10 @@ archivesBaseName = "fabric-registry-sync-v0" version = getSubprojectVersion(project) +loom { + accessWidenerPath = file("src/main/resources/fabric-registry-sync-v0.accesswidener") +} + moduleDependencies(project, [ 'fabric-api-base', 'fabric-networking-api-v1' diff --git a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/api/event/registry/FabricRegistryBuilder.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/api/event/registry/FabricRegistryBuilder.java index 5eb503767..88e21093c 100644 --- a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/api/event/registry/FabricRegistryBuilder.java +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/api/event/registry/FabricRegistryBuilder.java @@ -64,7 +64,7 @@ public final class FabricRegistryBuilder> { * @return An instance of FabricRegistryBuilder */ public static FabricRegistryBuilder> createSimple(Class type, Identifier registryId) { - return from(new SimpleRegistry(RegistryKey.ofRegistry(registryId), Lifecycle.stable(), null)); + return from(new SimpleRegistry(RegistryKey.ofRegistry(registryId), Lifecycle.stable(), false)); } /** @@ -76,7 +76,7 @@ public final class FabricRegistryBuilder> { * @return An instance of FabricRegistryBuilder */ public static FabricRegistryBuilder> createDefaulted(Class type, Identifier registryId, Identifier defaultId) { - return from(new DefaultedRegistry(defaultId.toString(), RegistryKey.ofRegistry(registryId), Lifecycle.stable(), null)); + return from(new DefaultedRegistry(defaultId.toString(), RegistryKey.ofRegistry(registryId), Lifecycle.stable(), false)); } private final R registry; diff --git a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/packet/DirectRegistryPacketHandler.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/packet/DirectRegistryPacketHandler.java index 55ebcdca1..3386da0ed 100644 --- a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/packet/DirectRegistryPacketHandler.java +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/packet/DirectRegistryPacketHandler.java @@ -181,7 +181,7 @@ public class DirectRegistryPacketHandler extends RegistryPacketHandler { int regNamespaceGroupAmount = combinedBuf.readVarInt(); for (int i = 0; i < regNamespaceGroupAmount; i++) { - String regNamespace = combinedBuf.readString(); + String regNamespace = unoptimizeNamespace(combinedBuf.readString()); int regNamespaceGroupLength = combinedBuf.readVarInt(); for (int j = 0; j < regNamespaceGroupLength; j++) { @@ -192,7 +192,7 @@ public class DirectRegistryPacketHandler extends RegistryPacketHandler { int lastBulkLastRawId = 0; for (int k = 0; k < idNamespaceGroupAmount; k++) { - String idNamespace = combinedBuf.readString(); + String idNamespace = unoptimizeNamespace(combinedBuf.readString()); int rawIdBulkAmount = combinedBuf.readVarInt(); for (int l = 0; l < rawIdBulkAmount; l++) { @@ -241,7 +241,11 @@ public class DirectRegistryPacketHandler extends RegistryPacketHandler { return map; } - private String optimizeNamespace(String namespace) { + private static String optimizeNamespace(String namespace) { return namespace.equals(Identifier.DEFAULT_NAMESPACE) ? "" : namespace; } + + private static String unoptimizeNamespace(String namespace) { + return namespace.isEmpty() ? Identifier.DEFAULT_NAMESPACE : namespace; + } } diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/DynamicRegistryManagerAccessor.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/BuiltinRegistriesMixin.java similarity index 56% rename from fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/DynamicRegistryManagerAccessor.java rename to fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/BuiltinRegistriesMixin.java index 51acabb41..943e265ce 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/DynamicRegistryManagerAccessor.java +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/BuiltinRegistriesMixin.java @@ -14,21 +14,20 @@ * limitations under the License. */ -package net.fabricmc.fabric.mixin.datagen; - -import java.util.Map; +package net.fabricmc.fabric.mixin.registry.sync; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; -import net.minecraft.util.registry.DynamicRegistryManager; +import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; -@Mixin(DynamicRegistryManager.class) -public interface DynamicRegistryManagerAccessor { - @Accessor("INFOS") - static Map>, ?> getInfos() { - throw new AssertionError(); +@Mixin(BuiltinRegistries.class) +public class BuiltinRegistriesMixin { + @Redirect(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/registry/Registry;freeze()Lnet/minecraft/util/registry/Registry;")) + private static Registry unfreezeBultinRegistries(Registry reg) { + // Don't freeze + return reg; } } diff --git a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/CombinedDynamicRegistriesMixin.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/CombinedDynamicRegistriesMixin.java new file mode 100644 index 000000000..e692f7b2d --- /dev/null +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/CombinedDynamicRegistriesMixin.java @@ -0,0 +1,43 @@ +/* + * 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.registry.sync; + +import java.util.List; + +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import net.minecraft.util.registry.CombinedDynamicRegistries; +import net.minecraft.util.registry.DynamicRegistryManager; + +import net.fabricmc.fabric.api.event.registry.DynamicRegistrySetupCallback; + +@Mixin(CombinedDynamicRegistries.class) +public class CombinedDynamicRegistriesMixin { + @Shadow + @Final + private DynamicRegistryManager.Immutable combinedRegistryManager; + + @Inject(method = "(Ljava/util/List;Ljava/util/List;)V", at = @At("RETURN")) + private void init(List list, List list2, CallbackInfo ci) { + DynamicRegistrySetupCallback.EVENT.invoker().onRegistrySetup(this.combinedRegistryManager); + } +} diff --git a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/DynamicRegistryManagerMixin.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/DynamicRegistryManagerMixin.java index 44574481b..b9bfd18ac 100644 --- a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/DynamicRegistryManagerMixin.java +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/DynamicRegistryManagerMixin.java @@ -17,29 +17,19 @@ package net.fabricmc.fabric.mixin.registry.sync; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import net.minecraft.util.registry.DynamicRegistryManager; -import net.fabricmc.fabric.api.event.registry.DynamicRegistrySetupCallback; -import net.fabricmc.fabric.impl.registry.sync.DynamicRegistrySync; - @Mixin(DynamicRegistryManager.class) public interface DynamicRegistryManagerMixin { - @Inject(method = "createAndLoad", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/dynamic/EntryLoader$Impl;()V"), locals = LocalCapture.CAPTURE_FAILHARD) - private static void onCreateImpl(CallbackInfoReturnable cir, DynamicRegistryManager.Mutable registryManager) { - DynamicRegistrySetupCallback.EVENT.invoker().onRegistrySetup(registryManager); - } - /** * Ensures that any registrations made into {@link net.minecraft.util.registry.BuiltinRegistries} after * {@link DynamicRegistryManager} has been class-loaded are still propagated. */ - @Inject(method = "method_40327", at = @At(value = "RETURN")) - private static void setupBuiltInSync(CallbackInfoReturnable cir) { - DynamicRegistrySync.setupSync(cir.getReturnValue()); - } + /* TODO 22w42a not needed? + @Inject(method = "method_40327", at = @At(value = "RETURN")) + private static void setupBuiltInSync(CallbackInfoReturnable cir) { + DynamicRegistrySync.setupSync(cir.getReturnValue()); + } + */ } diff --git a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/MinecraftServerMixin.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/MinecraftServerMixin.java index 28e13cefd..c631a87c0 100644 --- a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/MinecraftServerMixin.java +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/MinecraftServerMixin.java @@ -25,7 +25,9 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import net.minecraft.server.MinecraftServer; +import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.Registry; +import net.minecraft.util.registry.SimpleRegistry; import net.fabricmc.api.EnvType; import net.fabricmc.fabric.impl.registry.sync.trackers.vanilla.BlockInitTracker; @@ -41,6 +43,12 @@ public class MinecraftServerMixin { if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER) { // Freeze the registries on the server FABRIC_LOGGER.debug("Freezing registries"); + BuiltinRegistries.REGISTRIES.freeze(); + + for (Registry registry : BuiltinRegistries.REGISTRIES) { + ((SimpleRegistry) registry).freeze(); + } + Registry.freezeRegistries(); BlockInitTracker.postFreeze(); } diff --git a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/SimpleRegistryMixin.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/SimpleRegistryMixin.java index a5ba557f4..7d906b16a 100644 --- a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/SimpleRegistryMixin.java +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/SimpleRegistryMixin.java @@ -155,7 +155,14 @@ public abstract class SimpleRegistryMixin extends Registry implements Rema } @Inject(method = "set", at = @At("RETURN")) - private void set(int rawId, RegistryKey> registryKey, V entry, Lifecycle lifecycle, CallbackInfoReturnable info) { + private void set(int rawId, RegistryKey> registryKey, V entry, Lifecycle lifecycle, CallbackInfoReturnable> info) { + // We need to restore the 1.19 behavior of binding the value to references immediately. + // Unfrozen registries cannot be interacted with otherwise, because the references would throw when + // trying to access their values. + if (info.getReturnValue() instanceof RegistryEntry.Reference reference) { + reference.setValue(entry); + } + onChange(registryKey); } @@ -172,8 +179,8 @@ public abstract class SimpleRegistryMixin extends Registry implements Rema } } - @Inject(method = "set(ILnet/minecraft/util/registry/RegistryKey;Ljava/lang/Object;Lcom/mojang/serialization/Lifecycle;Z)Lnet/minecraft/util/registry/RegistryEntry;", at = @At("HEAD")) - public void setPre(int id, RegistryKey registryId, T object, Lifecycle lifecycle, boolean checkDuplicateKeys, CallbackInfoReturnable info) { + @Inject(method = "set", at = @At("HEAD")) + public void setPre(int id, RegistryKey registryId, T object, Lifecycle lifecycle, CallbackInfoReturnable> info) { int indexedEntriesId = entryToRawId.getInt(object); if (indexedEntriesId >= 0) { @@ -188,7 +195,7 @@ public abstract class SimpleRegistryMixin extends Registry implements Rema if (oldObject != null && oldObject.value() != null && oldObject.value() != object) { int oldId = entryToRawId.getInt(oldObject.value()); - if (oldId != id && checkDuplicateKeys) { + if (oldId != id) { throw new RuntimeException("Attempted to register ID " + registryId + " at different raw IDs (" + oldId + ", " + id + ")! If you're trying to override an item, use .set(), not .register()!"); } @@ -200,8 +207,8 @@ public abstract class SimpleRegistryMixin extends Registry implements Rema } } - @Inject(method = "set(ILnet/minecraft/util/registry/RegistryKey;Ljava/lang/Object;Lcom/mojang/serialization/Lifecycle;Z)Lnet/minecraft/util/registry/RegistryEntry;", at = @At("RETURN")) - public void setPost(int id, RegistryKey registryId, T object, Lifecycle lifecycle, boolean checkDuplicateKeys, CallbackInfoReturnable info) { + @Inject(method = "set", at = @At("RETURN")) + public void setPost(int id, RegistryKey registryId, T object, Lifecycle lifecycle, CallbackInfoReturnable> info) { if (fabric_isObjectNew) { fabric_addObjectEvent.invoker().onEntryAdded(id, registryId.getValue(), object); } diff --git a/fabric-registry-sync-v0/src/main/resources/fabric-registry-sync-v0.accesswidener b/fabric-registry-sync-v0/src/main/resources/fabric-registry-sync-v0.accesswidener new file mode 100644 index 000000000..ba3e368fa --- /dev/null +++ b/fabric-registry-sync-v0/src/main/resources/fabric-registry-sync-v0.accesswidener @@ -0,0 +1,4 @@ +accessWidener v2 named + +accessible field net/minecraft/util/registry/SimpleRegistry frozen Z +accessible method net/minecraft/util/registry/RegistryEntry$Reference setValue (Ljava/lang/Object;)V diff --git a/fabric-registry-sync-v0/src/main/resources/fabric-registry-sync-v0.mixins.json b/fabric-registry-sync-v0/src/main/resources/fabric-registry-sync-v0.mixins.json index aa23ba48f..cb4fc621e 100644 --- a/fabric-registry-sync-v0/src/main/resources/fabric-registry-sync-v0.mixins.json +++ b/fabric-registry-sync-v0/src/main/resources/fabric-registry-sync-v0.mixins.json @@ -6,6 +6,7 @@ "DebugChunkGeneratorAccessor", "RegistryAccessor", "BootstrapMixin", + "BuiltinRegistriesMixin", "ChunkSerializerMixin", "DynamicRegistryManagerMixin", "IdListMixin", diff --git a/fabric-registry-sync-v0/src/main/resources/fabric.mod.json b/fabric-registry-sync-v0/src/main/resources/fabric.mod.json index fe36dd055..be43f19de 100644 --- a/fabric-registry-sync-v0/src/main/resources/fabric.mod.json +++ b/fabric-registry-sync-v0/src/main/resources/fabric.mod.json @@ -36,6 +36,7 @@ "net.fabricmc.fabric.impl.registry.sync.FabricRegistryClientInit" ] }, + "accessWidener": "fabric-registry-sync-v0.accesswidener", "custom": { "fabric-api:module-lifecycle": "stable" } 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 386bb2974..3ab5792e6 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 @@ -145,13 +145,13 @@ public class RegistrySyncTest implements ModInitializer { // Force-Initialize the dynamic registry manager, doing this in a Mod initializer would cause // further registrations into BuiltInRegistries to _NOT_ propagate into DynamicRegistryManager.BUILTIN - checkFeature(DynamicRegistryManager.createAndLoad(), f1Id); + checkFeature(DynamicRegistryManager.of(BuiltinRegistries.REGISTRIES), f1Id); ConfiguredFeature cf2 = new ConfiguredFeature<>(Feature.DESERT_WELL, DefaultFeatureConfig.INSTANCE); Identifier f2Id = new Identifier("registry_sync", "f2"); Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, f2Id, cf2); - DynamicRegistryManager impl2 = DynamicRegistryManager.createAndLoad(); + DynamicRegistryManager impl2 = DynamicRegistryManager.of(BuiltinRegistries.REGISTRIES); checkFeature(impl2, f1Id); checkFeature(impl2, f2Id); } @@ -170,13 +170,5 @@ public class RegistrySyncTest implements ModInitializer { if (entry == null) { throw new IllegalStateException("Expected dynamic registry to contain entry " + id); } - - if (builtInEntry == entry) { - throw new IllegalStateException("Expected that the built-in entry and dynamic entry don't have object identity because the dynamic entry is created by serializing the built-in entry to JSON and back."); - } - - if (builtInEntry.feature() != entry.feature()) { - throw new IllegalStateException("Expected both entries to reference the same feature since it's only in Registry and is never copied"); - } } } diff --git a/fabric-registry-sync-v0/src/testmod/java/net/fabricmc/fabric/test/registry/sync/RegistrySyncTestClient.java b/fabric-registry-sync-v0/src/testmod/java/net/fabricmc/fabric/test/registry/sync/RegistrySyncTestClient.java index 145e65e90..6af00c723 100644 --- a/fabric-registry-sync-v0/src/testmod/java/net/fabricmc/fabric/test/registry/sync/RegistrySyncTestClient.java +++ b/fabric-registry-sync-v0/src/testmod/java/net/fabricmc/fabric/test/registry/sync/RegistrySyncTestClient.java @@ -20,9 +20,10 @@ import java.util.Map; import java.util.Objects; import com.google.common.base.Preconditions; +import com.google.common.collect.Sets; import it.unimi.dsi.fastutil.objects.Object2IntMap; -import org.slf4j.LoggerFactory; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import net.minecraft.util.Identifier; @@ -51,6 +52,15 @@ public class RegistrySyncTestClient implements ClientModInitializer { Map> directPacketMap = RegistrySyncTest.DIRECT_PACKET_HANDLER.getSyncedRegistryMap(); Map> nbtPacketMap = RegistrySyncTest.NBT_PACKET_HANDLER.getSyncedRegistryMap(); + Objects.requireNonNull(nbtPacketMap, "nbtPacketMap"); + Objects.requireNonNull(directPacketMap, "directPacketMap"); + + Sets.SetView registryDiffs = Sets.symmetricDifference(directPacketMap.keySet(), nbtPacketMap.keySet()); + + if (!registryDiffs.isEmpty()) { + throw new IllegalStateException("Non-Equal set of synched registries between NBT/Direct: " + nbtPacketMap.keySet() + " != " + directPacketMap.keySet()); + } + Preconditions.checkArgument(Objects.requireNonNull(nbtPacketMap).equals(directPacketMap), "nbt packet and direct packet are not equal!"); }); } diff --git a/fabric-renderer-api-v1/src/client/java/net/fabricmc/fabric/impl/renderer/SpriteFinderImpl.java b/fabric-renderer-api-v1/src/client/java/net/fabricmc/fabric/impl/renderer/SpriteFinderImpl.java index 9661f4bbc..b2b3a2d10 100644 --- a/fabric-renderer-api-v1/src/client/java/net/fabricmc/fabric/impl/renderer/SpriteFinderImpl.java +++ b/fabric-renderer-api-v1/src/client/java/net/fabricmc/fabric/impl/renderer/SpriteFinderImpl.java @@ -93,7 +93,7 @@ public class SpriteFinderImpl implements SpriteFinder { // Prefer failing with a log warning rather than risking a stack overflow. if (badSpriteCount++ < 5) { String errorMessage = "SpriteFinderImpl: Skipping sprite {} with broken bounds [{}, {}]x[{}, {}]. Sprite bounds should be between 0 and 1."; - LOGGER.error(errorMessage, sprite.getId(), sprite.getMinU(), sprite.getMaxU(), sprite.getMinV(), sprite.getMaxV()); + LOGGER.error(errorMessage, sprite.method_45852(), sprite.getMinU(), sprite.getMaxU(), sprite.getMinV(), sprite.getMaxV()); } return; diff --git a/fabric-renderer-api-v1/src/client/java/net/fabricmc/fabric/mixin/renderer/client/SpriteAtlasTextureMixin.java b/fabric-renderer-api-v1/src/client/java/net/fabricmc/fabric/mixin/renderer/client/SpriteAtlasTextureMixin.java index 2cc5ee0df..09a24fabe 100644 --- a/fabric-renderer-api-v1/src/client/java/net/fabricmc/fabric/mixin/renderer/client/SpriteAtlasTextureMixin.java +++ b/fabric-renderer-api-v1/src/client/java/net/fabricmc/fabric/mixin/renderer/client/SpriteAtlasTextureMixin.java @@ -25,6 +25,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import net.minecraft.class_7766; import net.minecraft.client.texture.Sprite; import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.util.Identifier; @@ -39,8 +40,8 @@ public class SpriteAtlasTextureMixin implements SpriteFinderImpl.SpriteFinderAcc private SpriteFinderImpl fabric_spriteFinder = null; - @Inject(at = @At("RETURN"), method = "upload") - private void uploadHook(SpriteAtlasTexture.Data input, CallbackInfo info) { + @Inject(at = @At("RETURN"), method = "method_45848") + private void uploadHook(class_7766.class_7767 arg, CallbackInfo ci) { fabric_spriteFinder = null; } diff --git a/fabric-renderer-api-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/simple/RendererTest.java b/fabric-renderer-api-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/simple/RendererTest.java index 97f2d9c93..c77fe91cd 100644 --- a/fabric-renderer-api-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/simple/RendererTest.java +++ b/fabric-renderer-api-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/simple/RendererTest.java @@ -19,7 +19,6 @@ package net.fabricmc.fabric.test.renderer.simple; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; @@ -34,7 +33,7 @@ import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityT *

There are no fancy shaders or glow that is provided by this renderer test. */ public final class RendererTest implements ModInitializer { - public static final FrameBlock[] FRAMES = new FrameBlock[] { + public static final FrameBlock[] FRAMES = new FrameBlock[]{ new FrameBlock(id("frame")), new FrameBlock(id("frame_multipart")), new FrameBlock(id("frame_weighted")), @@ -45,7 +44,7 @@ public final class RendererTest implements ModInitializer { public void onInitialize() { for (FrameBlock frameBlock : FRAMES) { Registry.register(Registry.BLOCK, frameBlock.id, frameBlock); - Registry.register(Registry.ITEM, frameBlock.id, new BlockItem(frameBlock, new Item.Settings().group(ItemGroup.MISC))); + Registry.register(Registry.ITEM, frameBlock.id, new BlockItem(frameBlock, new Item.Settings())); } Registry.register(Registry.BLOCK_ENTITY_TYPE, id("frame"), FRAME_BLOCK_ENTITY); diff --git a/fabric-renderer-api-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/simple/client/FrameUnbakedModel.java b/fabric-renderer-api-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/simple/client/FrameUnbakedModel.java index 8656bbf64..b94c3a1f1 100644 --- a/fabric-renderer-api-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/simple/client/FrameUnbakedModel.java +++ b/fabric-renderer-api-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/simple/client/FrameUnbakedModel.java @@ -18,15 +18,13 @@ package net.fabricmc.fabric.test.renderer.simple.client; import java.util.Collection; import java.util.Collections; -import java.util.Set; import java.util.function.Function; -import com.mojang.datafixers.util.Pair; import org.jetbrains.annotations.Nullable; +import net.minecraft.class_7775; import net.minecraft.client.render.model.BakedModel; import net.minecraft.client.render.model.ModelBakeSettings; -import net.minecraft.client.render.model.ModelLoader; import net.minecraft.client.render.model.UnbakedModel; import net.minecraft.client.texture.Sprite; import net.minecraft.client.texture.SpriteAtlasTexture; @@ -50,8 +48,7 @@ final class FrameUnbakedModel implements UnbakedModel { } @Override - public Collection getTextureDependencies(Function unbakedModelGetter, Set> unresolvedTextureReferences) { - return Collections.emptySet(); // TODO: Also set the return value when we set a proper texture. + public void method_45785(Function function) { } /* @@ -60,7 +57,7 @@ final class FrameUnbakedModel implements UnbakedModel { */ @Nullable @Override - public BakedModel bake(ModelLoader loader, Function textureGetter, ModelBakeSettings rotationContainer, Identifier modelId) { + public BakedModel bake(class_7775 arg, Function textureGetter, ModelBakeSettings rotationContainer, Identifier modelId) { // The renderer api may not have an implementation. // For this reason we will just null check the renderer impl if (RendererAccess.INSTANCE.hasRenderer()) { diff --git a/fabric-rendering-fluids-v1/src/client/java/net/fabricmc/fabric/api/client/render/fluid/v1/SimpleFluidRenderHandler.java b/fabric-rendering-fluids-v1/src/client/java/net/fabricmc/fabric/api/client/render/fluid/v1/SimpleFluidRenderHandler.java index 1f2343138..47d55e085 100644 --- a/fabric-rendering-fluids-v1/src/client/java/net/fabricmc/fabric/api/client/render/fluid/v1/SimpleFluidRenderHandler.java +++ b/fabric-rendering-fluids-v1/src/client/java/net/fabricmc/fabric/api/client/render/fluid/v1/SimpleFluidRenderHandler.java @@ -16,6 +16,8 @@ package net.fabricmc.fabric.api.client.render.fluid.v1; +import java.util.Objects; + import org.jetbrains.annotations.Nullable; import net.minecraft.client.texture.Sprite; @@ -82,8 +84,8 @@ public class SimpleFluidRenderHandler implements FluidRenderHandler { * @param tint The fluid color RGB. Alpha is ignored. */ public SimpleFluidRenderHandler(Identifier stillTexture, Identifier flowingTexture, @Nullable Identifier overlayTexture, int tint) { - this.stillTexture = stillTexture; - this.flowingTexture = flowingTexture; + this.stillTexture = Objects.requireNonNull(stillTexture, "stillTexture"); + this.flowingTexture = Objects.requireNonNull(flowingTexture, "flowingTexture");; this.overlayTexture = overlayTexture; this.sprites = new Sprite[overlayTexture == null ? 2 : 3]; this.tint = tint; diff --git a/fabric-rendering-fluids-v1/src/testmod/java/net/fabricmc/fabric/test/client/rendering/fluid/CustomizedFluidRenderer.java b/fabric-rendering-fluids-v1/src/testmod/java/net/fabricmc/fabric/test/client/rendering/fluid/CustomizedFluidRenderer.java index 41543accb..fea521b6a 100644 --- a/fabric-rendering-fluids-v1/src/testmod/java/net/fabricmc/fabric/test/client/rendering/fluid/CustomizedFluidRenderer.java +++ b/fabric-rendering-fluids-v1/src/testmod/java/net/fabricmc/fabric/test/client/rendering/fluid/CustomizedFluidRenderer.java @@ -28,7 +28,7 @@ import net.fabricmc.fabric.api.client.render.fluid.v1.SimpleFluidRenderHandler; public class CustomizedFluidRenderer extends SimpleFluidRenderHandler { public CustomizedFluidRenderer(Identifier overlayTexture) { - super(null, null, overlayTexture); + super(overlayTexture, overlayTexture, overlayTexture); } @Override diff --git a/fabric-rendering-fluids-v1/src/testmod/java/net/fabricmc/fabric/test/client/rendering/fluid/FabricFluidRenderingTestModClient.java b/fabric-rendering-fluids-v1/src/testmod/java/net/fabricmc/fabric/test/client/rendering/fluid/FabricFluidRenderingTestModClient.java index d022a713c..a4457a2e3 100644 --- a/fabric-rendering-fluids-v1/src/testmod/java/net/fabricmc/fabric/test/client/rendering/fluid/FabricFluidRenderingTestModClient.java +++ b/fabric-rendering-fluids-v1/src/testmod/java/net/fabricmc/fabric/test/client/rendering/fluid/FabricFluidRenderingTestModClient.java @@ -17,6 +17,7 @@ package net.fabricmc.fabric.test.client.rendering.fluid; import net.minecraft.block.Blocks; +import net.minecraft.class_7766; import net.minecraft.screen.PlayerScreenHandler; import net.minecraft.util.Identifier; @@ -59,10 +60,10 @@ public class FabricFluidRenderingTestModClient implements ClientModInitializer { new Identifier("fabric-rendering-fluids-v1-testmod:block/test_fluid_overlay") )); - ClientSpriteRegistryCallback.event(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE).register((atlasTexture, registry) -> { - registry.register(new Identifier("fabric-rendering-fluids-v1-testmod:block/test_fluid_still")); - registry.register(new Identifier("fabric-rendering-fluids-v1-testmod:block/test_fluid_flowing")); - registry.register(new Identifier("fabric-rendering-fluids-v1-testmod:block/test_fluid_overlay")); + ClientSpriteRegistryCallback.event(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE).register((resourceManager, sprites) -> { + class_7766.method_45830(resourceManager, new Identifier("fabric-rendering-fluids-v1-testmod:block/test_fluid_still"), sprites::put); + class_7766.method_45830(resourceManager, new Identifier("fabric-rendering-fluids-v1-testmod:block/test_fluid_flowing"), sprites::put); + class_7766.method_45830(resourceManager, new Identifier("fabric-rendering-fluids-v1-testmod:block/test_fluid_overlay"), sprites::put); }); } } diff --git a/fabric-rendering-v1/src/testmod/java/net/fabricmc/fabric/test/rendering/TooltipComponentTestInit.java b/fabric-rendering-v1/src/testmod/java/net/fabricmc/fabric/test/rendering/TooltipComponentTestInit.java index 8f5fc409e..49035e8fb 100644 --- a/fabric-rendering-v1/src/testmod/java/net/fabricmc/fabric/test/rendering/TooltipComponentTestInit.java +++ b/fabric-rendering-v1/src/testmod/java/net/fabricmc/fabric/test/rendering/TooltipComponentTestInit.java @@ -23,7 +23,6 @@ import net.minecraft.entity.EquipmentSlot; import net.minecraft.item.ArmorItem; import net.minecraft.item.ArmorMaterial; import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.recipe.Ingredient; @@ -36,7 +35,7 @@ import net.fabricmc.api.ModInitializer; public class TooltipComponentTestInit implements ModInitializer { public static Item CUSTOM_TOOLTIP_ITEM = new CustomTooltipItem(); - public static Item CUSTOM_ARMOR_ITEM = new ArmorItem(TestArmorMaterial.INSTANCE, EquipmentSlot.CHEST, new Item.Settings().group(ItemGroup.MISC)); + public static Item CUSTOM_ARMOR_ITEM = new ArmorItem(TestArmorMaterial.INSTANCE, EquipmentSlot.CHEST, new Item.Settings()); @Override public void onInitialize() { @@ -46,7 +45,7 @@ public class TooltipComponentTestInit implements ModInitializer { private static class CustomTooltipItem extends Item { CustomTooltipItem() { - super(new Settings().group(ItemGroup.MISC)); + super(new Settings()); } @Override @@ -55,7 +54,8 @@ public class TooltipComponentTestInit implements ModInitializer { } } - public record Data(String string) implements TooltipData { } + public record Data(String string) implements TooltipData { + } public static final class TestArmorMaterial implements ArmorMaterial { public static final TestArmorMaterial INSTANCE = new TestArmorMaterial(); diff --git a/fabric-resource-loader-v0/src/client/java/net/fabricmc/fabric/mixin/resource/loader/client/ClientBuiltinResourcePackProviderMixin.java b/fabric-resource-loader-v0/src/client/java/net/fabricmc/fabric/mixin/resource/loader/client/ClientBuiltinResourcePackProviderMixin.java deleted file mode 100644 index 53bb53f39..000000000 --- a/fabric-resource-loader-v0/src/client/java/net/fabricmc/fabric/mixin/resource/loader/client/ClientBuiltinResourcePackProviderMixin.java +++ /dev/null @@ -1,68 +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.resource.loader.client; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Consumer; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import net.minecraft.resource.AbstractFileResourcePack; -import net.minecraft.resource.ResourcePack; -import net.minecraft.resource.ResourcePackProfile; -import net.minecraft.client.resource.ClientBuiltinResourcePackProvider; -import net.minecraft.resource.ResourceType; - -import net.fabricmc.fabric.api.resource.ModResourcePack; -import net.fabricmc.fabric.impl.resource.loader.ModResourcePackCreator; -import net.fabricmc.fabric.impl.resource.loader.ModResourcePackUtil; -import net.fabricmc.fabric.impl.resource.loader.client.pack.ProgrammerArtResourcePack; - -@Mixin(ClientBuiltinResourcePackProvider.class) -public class ClientBuiltinResourcePackProviderMixin { - @Inject(method = "register", at = @At("RETURN")) - private void addBuiltinResourcePacks(Consumer consumer, ResourcePackProfile.Factory factory, CallbackInfo ci) { - // Register mod and built-in resource packs after the vanilla built-in resource packs are registered. - ModResourcePackCreator.CLIENT_RESOURCE_PACK_PROVIDER.register(consumer, factory); - } - - // ClientBuiltinResourcePackProvider#method_25454 first lambda. - @Inject(method = "method_25457", at = @At("RETURN"), cancellable = true) - private static void onSupplyZipProgrammerArtPack(File file, CallbackInfoReturnable cir) { - AbstractFileResourcePack originalPack = (AbstractFileResourcePack) cir.getReturnValue(); - cir.setReturnValue(new ProgrammerArtResourcePack(originalPack, getProgrammerArtModResourcePacks())); - } - - // ClientBuiltinResourcePackProvider#method_25454 second lambda. - @Inject(method = "method_25456", at = @At("RETURN"), cancellable = true) - private static void onSupplyDirProgrammerArtPack(File file, CallbackInfoReturnable cir) { - AbstractFileResourcePack originalPack = (AbstractFileResourcePack) cir.getReturnValue(); - cir.setReturnValue(new ProgrammerArtResourcePack(originalPack, getProgrammerArtModResourcePacks())); - } - - private static List getProgrammerArtModResourcePacks() { - List packs = new ArrayList<>(); - ModResourcePackUtil.appendModResourcePacks(packs, ResourceType.CLIENT_RESOURCES, "programmer_art"); - return packs; - } -} diff --git a/fabric-resource-loader-v0/src/client/java/net/fabricmc/fabric/mixin/resource/loader/client/CreateWorldScreenMixin.java b/fabric-resource-loader-v0/src/client/java/net/fabricmc/fabric/mixin/resource/loader/client/CreateWorldScreenMixin.java index a84d34d9f..55b5ec42b 100644 --- a/fabric-resource-loader-v0/src/client/java/net/fabricmc/fabric/mixin/resource/loader/client/CreateWorldScreenMixin.java +++ b/fabric-resource-loader-v0/src/client/java/net/fabricmc/fabric/mixin/resource/loader/client/CreateWorldScreenMixin.java @@ -17,16 +17,8 @@ package net.fabricmc.fabric.mixin.resource.loader.client; import java.io.File; -import java.util.concurrent.CompletableFuture; -import com.google.gson.JsonElement; import com.mojang.datafixers.util.Pair; -import com.mojang.serialization.DataResult; -import com.mojang.serialization.DynamicOps; -import com.mojang.serialization.JsonOps; -import org.jetbrains.annotations.Nullable; -import org.slf4j.Logger; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -35,114 +27,51 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import net.minecraft.class_7712; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.world.CreateWorldScreen; -import net.minecraft.client.gui.screen.world.MoreOptionsDialog; -import net.minecraft.client.world.GeneratorOptionsHolder; -import net.minecraft.resource.DataPackSettings; -import net.minecraft.resource.ResourceManager; import net.minecraft.resource.ResourcePackManager; import net.minecraft.resource.ResourceType; -import net.minecraft.server.SaveLoading; -import net.minecraft.util.Util; -import net.minecraft.util.dynamic.RegistryOps; -import net.minecraft.util.registry.DynamicRegistryManager; -import net.minecraft.world.gen.GeneratorOptions; import net.fabricmc.fabric.impl.resource.loader.ModResourcePackCreator; import net.fabricmc.fabric.impl.resource.loader.ModResourcePackUtil; -import net.fabricmc.fabric.mixin.resource.loader.ResourcePackManagerAccessor; @Mixin(CreateWorldScreen.class) public abstract class CreateWorldScreenMixin extends Screen { @Unique - private static DataPackSettings defaultDataPackSettings; + private static class_7712 defaultDataPackSettings; @Shadow private ResourcePackManager packManager; - @Shadow - @Final - private static Logger LOGGER; - - @Shadow - @Final - public MoreOptionsDialog moreOptionsDialog; - - @Shadow - protected DataPackSettings dataPackSettings; - - @Shadow - private static SaveLoading.ServerConfig createServerConfig(ResourcePackManager resourcePackManager, DataPackSettings dataPackSettings) { - return null; - } - - @Shadow - @Nullable - protected abstract Pair getScannedPack(); - private CreateWorldScreenMixin() { super(null); } @ModifyVariable(method = "create(Lnet/minecraft/client/MinecraftClient;Lnet/minecraft/client/gui/screen/Screen;)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/world/CreateWorldScreen;createServerConfig(Lnet/minecraft/resource/ResourcePackManager;Lnet/minecraft/resource/DataPackSettings;)Lnet/minecraft/server/SaveLoading$ServerConfig;")) + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/world/CreateWorldScreen;createServerConfig(Lnet/minecraft/resource/ResourcePackManager;Lnet/minecraft/class_7712;)Lnet/minecraft/server/SaveLoading$ServerConfig;")) private static ResourcePackManager onCreateResManagerInit(ResourcePackManager manager) { // Add mod data packs to the initial res pack manager so they are active even if the user doesn't use custom data packs - ((ResourcePackManagerAccessor) manager).getProviders().add(new ModResourcePackCreator(ResourceType.SERVER_DATA)); + manager.providers.add(new ModResourcePackCreator(ResourceType.SERVER_DATA)); return manager; } - @Redirect(method = "create(Lnet/minecraft/client/MinecraftClient;Lnet/minecraft/client/gui/screen/Screen;)V", at = @At(value = "FIELD", target = "Lnet/minecraft/resource/DataPackSettings;SAFE_MODE:Lnet/minecraft/resource/DataPackSettings;", ordinal = 0)) - private static DataPackSettings replaceDefaultSettings() { + @Redirect(method = "create(Lnet/minecraft/client/MinecraftClient;Lnet/minecraft/client/gui/screen/Screen;)V", at = @At(value = "FIELD", target = "Lnet/minecraft/class_7712;field_40260:Lnet/minecraft/class_7712;", ordinal = 0)) + private static class_7712 replaceDefaultSettings() { return (defaultDataPackSettings = ModResourcePackUtil.createDefaultDataPackSettings()); } - @ModifyArg(method = "create(Lnet/minecraft/client/MinecraftClient;Lnet/minecraft/client/gui/screen/Screen;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/world/CreateWorldScreen;(Lnet/minecraft/client/gui/screen/Screen;Lnet/minecraft/resource/DataPackSettings;Lnet/minecraft/client/gui/screen/world/MoreOptionsDialog;)V"), index = 1) - private static DataPackSettings useReplacedDefaultSettings(DataPackSettings dataPackSettings) { + @ModifyArg(method = "create(Lnet/minecraft/client/MinecraftClient;Lnet/minecraft/client/gui/screen/Screen;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/world/CreateWorldScreen;(Lnet/minecraft/client/gui/screen/Screen;Lnet/minecraft/class_7712;Lnet/minecraft/client/gui/screen/world/MoreOptionsDialog;)V"), index = 1) + private static class_7712 useReplacedDefaultSettings(class_7712 dataPackSettings) { return defaultDataPackSettings; } - @Redirect(method = "method_41854", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/registry/DynamicRegistryManager$Mutable;toImmutable()Lnet/minecraft/util/registry/DynamicRegistryManager$Immutable;")) - private static DynamicRegistryManager.Immutable loadDynamicRegistry(DynamicRegistryManager.Mutable mutableRegistryManager, ResourceManager dataPackManager) { - // This loads the dynamic registry from the data pack - RegistryOps.ofLoaded(JsonOps.INSTANCE, mutableRegistryManager, dataPackManager); - return mutableRegistryManager.toImmutable(); - } - - /** - * Load the DynamicRegistryManager again to fix GeneratorOptions not having custom dimensions. - * Taken from {@link CreateWorldScreen#applyDataPacks(ResourcePackManager)}. - */ - @SuppressWarnings("JavadocReference") - @Inject(method = "startServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/world/CreateWorldScreen;clearDataPackTempDir()V")) - private void loadDatapackDimensions(CallbackInfo ci) { - CompletableFuture future = SaveLoading.load(createServerConfig(getScannedPack().getSecond(), dataPackSettings), (resourceManager, dataPackSettings1) -> { - GeneratorOptionsHolder holder = moreOptionsDialog.getGeneratorOptionsHolder(); - DynamicRegistryManager.Mutable newDrm = DynamicRegistryManager.createAndLoad(); - DynamicOps heldOps = RegistryOps.of(JsonOps.INSTANCE, holder.dynamicRegistryManager()); - DynamicOps newOps = RegistryOps.ofLoaded(JsonOps.INSTANCE, newDrm, resourceManager); - DataResult result = GeneratorOptions.CODEC.encodeStart(heldOps, holder.generatorOptions()) - .flatMap(json -> GeneratorOptions.CODEC.parse(newOps, json)); - return Pair.of(result, newDrm.toImmutable()); - }, (resourceManager, dataPackContents, drm, result) -> { - resourceManager.close(); - GeneratorOptions options = result.getOrThrow(false, Util.addPrefix("Error parsing worldgen settings after loading data packs: ", LOGGER::error)); - GeneratorOptionsHolder holder = new GeneratorOptionsHolder(options, result.lifecycle().add(drm.getRegistryLifecycle()), drm, dataPackContents); - ((MoreOptionsDialogAccessor) moreOptionsDialog).callSetGeneratorOptionsHolder(holder); - return null; - }, Util.getMainWorkerExecutor(), client); - - client.runTasks(future::isDone); - } - @Inject(method = "getScannedPack", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/ResourcePackManager;scanPacks()V", shift = At.Shift.BEFORE)) private void onScanPacks(CallbackInfoReturnable> cir) { // Allow to display built-in data packs in the data pack selection screen at world creation. - ((ResourcePackManagerAccessor) this.packManager).getProviders().add(new ModResourcePackCreator(ResourceType.SERVER_DATA)); + this.packManager.providers.add(new ModResourcePackCreator(ResourceType.SERVER_DATA)); } } diff --git a/fabric-resource-loader-v0/src/client/java/net/fabricmc/fabric/mixin/resource/loader/client/ServerResourcePackProviderMixin.java b/fabric-resource-loader-v0/src/client/java/net/fabricmc/fabric/mixin/resource/loader/client/ServerResourcePackProviderMixin.java new file mode 100644 index 000000000..a6cf3f8e9 --- /dev/null +++ b/fabric-resource-loader-v0/src/client/java/net/fabricmc/fabric/mixin/resource/loader/client/ServerResourcePackProviderMixin.java @@ -0,0 +1,38 @@ +/* + * 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.resource.loader.client; + +import java.util.function.Consumer; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import net.minecraft.client.resource.ServerResourcePackProvider; +import net.minecraft.resource.ResourcePackProfile; + +import net.fabricmc.fabric.impl.resource.loader.ModResourcePackCreator; + +@Mixin(ServerResourcePackProvider.class) +public class ServerResourcePackProviderMixin { + @Inject(method = "register", at = @At("RETURN")) + private void addBuiltinResourcePacks(Consumer consumer, CallbackInfo ci) { + // Register mod and built-in resource packs after the vanilla built-in resource packs are registered. + ModResourcePackCreator.CLIENT_RESOURCE_PACK_PROVIDER.register(consumer); + } +} diff --git a/fabric-resource-loader-v0/src/client/resources/fabric-resource-loader-v0.client.mixins.json b/fabric-resource-loader-v0/src/client/resources/fabric-resource-loader-v0.client.mixins.json index 4585321b7..f797fcaed 100644 --- a/fabric-resource-loader-v0/src/client/resources/fabric-resource-loader-v0.client.mixins.json +++ b/fabric-resource-loader-v0/src/client/resources/fabric-resource-loader-v0.client.mixins.json @@ -3,7 +3,7 @@ "package": "net.fabricmc.fabric.mixin.resource.loader.client", "compatibilityLevel": "JAVA_16", "client": [ - "ClientBuiltinResourcePackProviderMixin", + "ServerResourcePackProviderMixin", "CreateWorldScreenMixin", "FontManagerMixin", "GameOptionsMixin", diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/BuiltinModResourcePackSource.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/BuiltinModResourcePackSource.java index 9be1b6af1..43a455cce 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/BuiltinModResourcePackSource.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/BuiltinModResourcePackSource.java @@ -27,6 +27,11 @@ public class BuiltinModResourcePackSource implements ResourcePackSource { this.modId = modId; } + @Override + public boolean canBeEnabledLater() { + return true; + } + @Override public Text decorate(Text packName) { return Text.translatable("pack.nameAndSource", packName, Text.translatable("pack.source.builtinMod", modId)).formatted(Formatting.GRAY); diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/FabricModResourcePack.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/FabricModResourcePack.java index df0965a53..8a093dd6c 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/FabricModResourcePack.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/FabricModResourcePack.java @@ -16,7 +16,6 @@ package net.fabricmc.fabric.impl.resource.loader; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; @@ -28,6 +27,7 @@ import org.jetbrains.annotations.Nullable; import net.minecraft.SharedConstants; import net.minecraft.resource.AbstractFileResourcePack; +import net.minecraft.resource.InputSupplier; import net.minecraft.resource.ResourceType; import net.minecraft.resource.metadata.ResourceMetadataReader; @@ -43,60 +43,33 @@ public class FabricModResourcePack extends GroupResourcePack { } @Override - public InputStream openRoot(String fileName) throws IOException { + public InputSupplier openRoot(String... pathSegments) { + String fileName = String.join("/", pathSegments); + if ("pack.mcmeta".equals(fileName)) { String description = "Mod resources."; String pack = String.format("{\"pack\":{\"pack_format\":" + type.getPackVersion(SharedConstants.getGameVersion()) + ",\"description\":\"%s\"}}", description); - return IOUtils.toInputStream(pack, Charsets.UTF_8); + return () -> IOUtils.toInputStream(pack, Charsets.UTF_8); } else if ("pack.png".equals(fileName)) { - InputStream stream = FabricLoader.getInstance().getModContainer("fabric-resource-loader-v0") + return FabricLoader.getInstance().getModContainer("fabric-resource-loader-v0") .flatMap(container -> container.getMetadata().getIconPath(512).map(container::getPath)) .filter(Files::exists) - .map(iconPath -> { - try { - return Files.newInputStream(iconPath); - } catch (IOException e) { - return null; - } - }).orElse(null); - - if (stream != null) { - return stream; - } + .map(path -> (InputSupplier) (() -> Files.newInputStream(path))) + .orElse(null); } - // ReloadableResourceManagerImpl gets away with FileNotFoundException. - throw new FileNotFoundException("\"" + fileName + "\" in Fabric mod resource pack"); + return null; } @Override public @Nullable T parseMetadata(ResourceMetadataReader metaReader) throws IOException { - try { - InputStream inputStream = this.openRoot("pack.mcmeta"); - Throwable error = null; - T metadata; + InputSupplier inputSupplier = this.openRoot("pack.mcmeta"); - try { - metadata = AbstractFileResourcePack.parseMetadata(metaReader, inputStream); - } catch (Throwable e) { - error = e; - throw e; - } finally { - if (inputStream != null) { - if (error != null) { - try { - inputStream.close(); - } catch (Throwable e) { - error.addSuppressed(e); - } - } else { - inputStream.close(); - } - } + if (inputSupplier != null) { + try (InputStream input = inputSupplier.get()) { + return AbstractFileResourcePack.parseMetadata(metaReader, input); } - - return metadata; - } catch (FileNotFoundException | RuntimeException e) { + } else { return null; } } diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/FabricResource.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/FabricResource.java index d4bbf754b..2da9c6b1f 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/FabricResource.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/FabricResource.java @@ -36,8 +36,6 @@ public interface FabricResource { */ default ResourcePackSource getFabricPackSource() { LoggerFactory.getLogger(FabricResource.class).error("Unknown Resource implementation {}, returning PACK_SOURCE_NONE as the source", getClass().getName()); - return ResourcePackSource.PACK_SOURCE_NONE; + return ResourcePackSource.NONE; } - - void setFabricPackSource(ResourcePackSource packSource); } diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/GroupResourcePack.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/GroupResourcePack.java index 951be350b..6ee2708f3 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/GroupResourcePack.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/GroupResourcePack.java @@ -16,28 +16,24 @@ package net.fabricmc.fabric.impl.resource.loader; -import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.function.Predicate; import java.util.stream.Collectors; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import net.minecraft.resource.InputSupplier; import net.minecraft.resource.NamespaceResourceManager; -import net.minecraft.resource.ResourceNotFoundException; +import net.minecraft.resource.Resource; import net.minecraft.resource.ResourcePack; import net.minecraft.resource.ResourceType; +import net.minecraft.resource.metadata.ResourceMetadata; import net.minecraft.util.Identifier; import net.fabricmc.fabric.api.resource.ModResourcePack; -import net.fabricmc.fabric.mixin.resource.loader.NamespaceResourceManagerAccessor; /** * Represents a group resource pack, holds multiple resource packs as one. @@ -56,60 +52,32 @@ public abstract class GroupResourcePack implements ResourcePack { } @Override - public InputStream open(ResourceType type, Identifier id) throws IOException { + public InputSupplier open(ResourceType type, Identifier id) { List packs = this.namespacedPacks.get(id.getNamespace()); if (packs != null) { for (int i = packs.size() - 1; i >= 0; i--) { ResourcePack pack = packs.get(i); + InputSupplier supplier = pack.open(type, id); - if (pack.contains(type, id)) { - return pack.open(type, id); + if (supplier != null) { + return supplier; } } } - throw new ResourceNotFoundException(null, - String.format("%s/%s/%s", type.getDirectory(), id.getNamespace(), id.getPath())); + return null; } @Override - public Collection findResources(ResourceType type, String namespace, String prefix, Predicate predicate) { + public void findResources(ResourceType type, String namespace, String prefix, ResultConsumer arg) { List packs = this.namespacedPacks.get(namespace); - if (packs == null) { - return Collections.emptyList(); - } - - Set resources = new HashSet<>(); - - for (int i = packs.size() - 1; i >= 0; i--) { - ResourcePack pack = packs.get(i); - Collection modResources = pack.findResources(type, namespace, prefix, predicate); - - resources.addAll(modResources); - } - - return resources; - } - - @Override - public boolean contains(ResourceType type, Identifier id) { - List packs = this.namespacedPacks.get(id.getNamespace()); - - if (packs == null) { - return false; - } - for (int i = packs.size() - 1; i >= 0; i--) { ResourcePack pack = packs.get(i); - if (pack.contains(type, id)) { - return true; - } + pack.findResources(type, namespace, prefix, arg); } - - return false; } @Override @@ -117,20 +85,25 @@ public abstract class GroupResourcePack implements ResourcePack { return this.namespacedPacks.keySet(); } - public void appendResources(NamespaceResourceManagerAccessor manager, Identifier id, List resources) { + public void appendResources(ResourceType type, Identifier id, List resources) { List packs = this.namespacedPacks.get(id.getNamespace()); if (packs == null) { return; } - Identifier metadataId = NamespaceResourceManagerAccessor.fabric$accessor_getMetadataPath(id); + Identifier metadataId = NamespaceResourceManager.getMetadataPath(id); for (ModResourcePack pack : packs) { - if (pack.contains(manager.getType(), id)) { - final NamespaceResourceManager.Entry entry = ((NamespaceResourceManager) manager).new Entry(id, metadataId, pack); - ((FabricNamespaceResourceManagerEntry) entry).setFabricPackSource(ModResourcePackCreator.RESOURCE_PACK_SOURCE); - resources.add(entry); + InputSupplier supplier = pack.open(type, id); + + if (supplier != null) { + InputSupplier metadataSupplier = () -> { + InputSupplier rawMetadataSupplier = pack.open(this.type, metadataId); + return rawMetadataSupplier != null ? NamespaceResourceManager.loadMetadata(rawMetadataSupplier) : ResourceMetadata.NONE; + }; + + resources.add(new Resource(pack, supplier, metadataSupplier)); } } } diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModNioResourcePack.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModNioResourcePack.java index 7779a848b..ede57ea26 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModNioResourcePack.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModNioResourcePack.java @@ -16,7 +16,6 @@ package net.fabricmc.fabric.impl.resource.loader; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.nio.file.DirectoryStream; @@ -28,7 +27,6 @@ import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.EnumMap; import java.util.HashSet; @@ -36,19 +34,20 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.function.Predicate; import java.util.regex.Pattern; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import net.minecraft.resource.AbstractFileResourcePack; +import net.minecraft.resource.InputSupplier; import net.minecraft.resource.ResourcePack; import net.minecraft.resource.ResourceType; import net.minecraft.resource.metadata.ResourceMetadataReader; +import net.minecraft.util.PathUtil; import net.minecraft.util.Identifier; -import net.minecraft.util.InvalidIdentifierException; import net.fabricmc.fabric.api.resource.ModResourcePack; import net.fabricmc.fabric.api.resource.ResourcePackActivationType; @@ -186,47 +185,41 @@ public class ModNioResourcePack implements ResourcePack, ModResourcePack { return !namespaces.get(type).contains(filename.substring(prefixLen, nsEnd)); } - private InputStream openFile(String filename) throws IOException { - InputStream stream; - + private InputSupplier openFile(String filename) { Path path = getPath(filename); if (path != null && Files.isRegularFile(path)) { - return Files.newInputStream(path); + return () -> Files.newInputStream(path); } - stream = ModResourcePackUtil.openDefault(this.modInfo, this.type, filename); - - if (stream != null) { - return stream; + if (ModResourcePackUtil.containsDefault(this.modInfo, filename)) { + return () -> ModResourcePackUtil.openDefault(this.modInfo, this.type, filename); } - // ReloadableResourceManagerImpl gets away with FileNotFoundException. - throw new FileNotFoundException("\"" + filename + "\" in Fabric mod \"" + modInfo.getId() + "\""); + return null; + } + + @Nullable + @Override + public InputSupplier openRoot(String... pathSegments) { + PathUtil.validatePath(pathSegments); + + return this.openFile(String.join("/", pathSegments)); } @Override - public InputStream openRoot(String fileName) throws IOException { - if (fileName.contains("/") || fileName.contains("\\")) { - throw new IllegalArgumentException("Root resources can only be filenames, not paths (no / allowed!)"); - } - - return this.openFile(fileName); + @Nullable + public InputSupplier open(ResourceType type, Identifier id) { + final Path path = getPath(getFilename(type, id)); + return path == null ? null : InputSupplier.create(path); } @Override - public InputStream open(ResourceType type, Identifier id) throws IOException { - return openFile(getFilename(type, id)); - } - - @Override - public Collection findResources(ResourceType type, String namespace, String path, Predicate predicate) { + public void findResources(ResourceType type, String namespace, String path, ResultConsumer visitor) { if (!namespaces.getOrDefault(type, Collections.emptySet()).contains(namespace)) { - return Collections.emptyList(); + return; } - List ids = new ArrayList<>(); - for (Path basePath : basePaths) { String separator = basePath.getFileSystem().getSeparator(); Path nsPath = basePath.resolve(type.getDirectory()).resolve(namespace); @@ -234,17 +227,16 @@ public class ModNioResourcePack implements ResourcePack, ModResourcePack { if (!exists(searchPath)) continue; try { - Files.walkFileTree(searchPath, new SimpleFileVisitor() { + Files.walkFileTree(searchPath, new SimpleFileVisitor<>() { @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - String fileName = file.getFileName().toString(); - if (fileName.endsWith(".mcmeta")) return FileVisitResult.CONTINUE; + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { + String filename = nsPath.relativize(file).toString().replace(separator, "/"); + Identifier identifier = Identifier.of(namespace, filename); - try { - Identifier id = new Identifier(namespace, nsPath.relativize(file).toString().replace(separator, "/")); - if (predicate.test(id)) ids.add(id); - } catch (InvalidIdentifierException e) { - LOGGER.error(e.getMessage()); + if (identifier == null) { + LOGGER.error("Invalid path in mod resource-pack {}: {}:{}, ignoring", id, namespace, filename); + } else { + visitor.accept(identifier, InputSupplier.create(file)); } return FileVisitResult.CONTINUE; @@ -254,20 +246,6 @@ public class ModNioResourcePack implements ResourcePack, ModResourcePack { LOGGER.warn("findResources at " + path + " in namespace " + namespace + ", mod " + modInfo.getId() + " failed!", e); } } - - return ids; - } - - @Override - public boolean contains(ResourceType type, Identifier id) { - String filename = getFilename(type, id); - - if (ModResourcePackUtil.containsDefault(modInfo, filename)) { - return true; - } - - Path path = getPath(filename); - return path != null && Files.isRegularFile(path); } @Override @@ -277,7 +255,7 @@ public class ModNioResourcePack implements ResourcePack, ModResourcePack { @Override public T parseMetadata(ResourceMetadataReader metaReader) throws IOException { - try (InputStream is = openFile("pack.mcmeta")) { + try (InputStream is = openFile("pack.mcmeta").get()) { return AbstractFileResourcePack.parseMetadata(metaReader, is); } } diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackCreator.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackCreator.java index fb25bf4b5..efd2a4b8c 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackCreator.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackCreator.java @@ -24,6 +24,7 @@ import net.minecraft.resource.ResourcePackProfile; import net.minecraft.resource.ResourcePackProvider; import net.minecraft.resource.ResourcePackSource; import net.minecraft.resource.ResourceType; +import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.fabricmc.fabric.api.resource.ModResourcePack; @@ -32,15 +33,22 @@ import net.fabricmc.fabric.api.resource.ModResourcePack; * Represents a resource pack provider for mods and built-in mods resource packs. */ public class ModResourcePackCreator implements ResourcePackProvider { - public static final ResourcePackSource RESOURCE_PACK_SOURCE = text -> Text.translatable("pack.nameAndSource", text, Text.translatable("pack.source.fabricmod")); + public static final ResourcePackSource RESOURCE_PACK_SOURCE = new ResourcePackSource() { + @Override + public Text decorate(Text packName) { + return Text.translatable("pack.nameAndSource", packName, Text.translatable("pack.source.fabricmod")); + } + + @Override + public boolean canBeEnabledLater() { + return true; + } + }; public static final ModResourcePackCreator CLIENT_RESOURCE_PACK_PROVIDER = new ModResourcePackCreator(ResourceType.CLIENT_RESOURCES); - private final ResourcePackProfile.Factory factory; private final ResourceType type; public ModResourcePackCreator(ResourceType type) { this.type = type; - this.factory = (name, text, bl, supplier, metadata, initialPosition, source) -> - new ResourcePackProfile(name, text, bl, supplier, metadata, type, initialPosition, source); } /** @@ -48,12 +56,8 @@ public class ModResourcePackCreator implements ResourcePackProvider { * * @param consumer The resource pack profile consumer. */ - public void register(Consumer consumer) { - this.register(consumer, this.factory); - } - @Override - public void register(Consumer consumer, ResourcePackProfile.Factory factory) { + public void register(Consumer consumer) { /* Register order rule in this provider: 1. Mod resource packs @@ -75,8 +79,9 @@ public class ModResourcePackCreator implements ResourcePackProvider { // Mod resource packs must always be enabled to avoid issues // and inserted on top to ensure that they are applied before user resource packs and after default/programmer art resource pack. // @TODO: "inserted on top" comment is deprecated, it does not guarantee the condition "applied before user resource packs". - ResourcePackProfile resourcePackProfile = ResourcePackProfile.of("Fabric Mods", - true, () -> new FabricModResourcePack(this.type, packs), factory, ResourcePackProfile.InsertionPosition.TOP, + MutableText title = Text.literal("Fabric Mods"); + ResourcePackProfile resourcePackProfile = ResourcePackProfile.create("fabric", title, + true, factory -> new FabricModResourcePack(this.type, packs), type, ResourcePackProfile.InsertionPosition.TOP, RESOURCE_PACK_SOURCE); if (resourcePackProfile != null) { @@ -85,6 +90,6 @@ public class ModResourcePackCreator implements ResourcePackProvider { } // Register all built-in resource packs provided by mods. - ResourceManagerHelperImpl.registerBuiltinResourcePacks(this.type, consumer, factory); + ResourceManagerHelperImpl.registerBuiltinResourcePacks(this.type, consumer); } } diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackUtil.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackUtil.java index b27f0c598..abd470fa7 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackUtil.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackUtil.java @@ -28,10 +28,12 @@ import org.apache.commons.io.IOUtils; import org.jetbrains.annotations.Nullable; import net.minecraft.SharedConstants; +import net.minecraft.class_7712; import net.minecraft.resource.DataPackSettings; import net.minecraft.resource.ResourcePack; import net.minecraft.resource.ResourcePackProfile; import net.minecraft.resource.ResourceType; +import net.minecraft.resource.featuretoggle.FeatureFlags; import net.minecraft.util.Identifier; import net.fabricmc.fabric.api.resource.ModResourcePack; @@ -107,7 +109,7 @@ public final class ModResourcePackUtil { * {@code DataPackSettings.SAFE_MODE} used in vanilla. * @return the default data pack settings */ - public static DataPackSettings createDefaultDataPackSettings() { + public static class_7712 createDefaultDataPackSettings() { ModResourcePackCreator modResourcePackCreator = new ModResourcePackCreator(ResourceType.SERVER_DATA); List moddedResourcePacks = new ArrayList<>(); modResourcePackCreator.register(moddedResourcePacks::add); @@ -127,6 +129,9 @@ public final class ModResourcePackUtil { } } - return new DataPackSettings(enabled, disabled); + return new class_7712( + new DataPackSettings(enabled, disabled), + FeatureFlags.DEFAULT_ENABLED_FEATURES + ); } } 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 dc892e1ab..ba8766d18 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 @@ -16,6 +16,7 @@ package net.fabricmc.fabric.impl.resource.loader; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -34,6 +35,7 @@ import org.slf4j.LoggerFactory; import net.minecraft.resource.ResourcePackProfile; import net.minecraft.resource.ResourceReloader; import net.minecraft.resource.ResourceType; +import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.minecraft.util.Pair; @@ -68,7 +70,9 @@ public class ResourceManagerHelperImpl implements ResourceManagerHelper { * @see ResourceManagerHelper#registerBuiltinResourcePack(Identifier, String, ModContainer, boolean) */ public static boolean registerBuiltinResourcePack(Identifier id, String subPath, ModContainer container, String displayName, ResourcePackActivationType activationType) { - String separator = container.getRootPath().getFileSystem().getSeparator(); + // Assuming the mod has multiple paths, we simply "hope" that the file separator is *not* different across them + List paths = container.getRootPaths(); + String separator = paths.get(0).getFileSystem().getSeparator(); subPath = subPath.replace("/", separator); String name = displayName; ModNioResourcePack resourcePack = ModNioResourcePack.create(id, name, container, subPath, ResourceType.CLIENT_RESOURCES, activationType); @@ -102,7 +106,7 @@ public class ResourceManagerHelperImpl implements ResourceManagerHelper { return registerBuiltinResourcePack(id, subPath, container, id.getNamespace() + "/" + id.getPath(), activationType); } - public static void registerBuiltinResourcePacks(ResourceType resourceType, Consumer consumer, ResourcePackProfile.Factory factory) { + public static void registerBuiltinResourcePacks(ResourceType resourceType, Consumer consumer) { // Loop through each registered built-in resource packs and add them if valid. for (Pair entry : builtinResourcePacks) { ModNioResourcePack pack = entry.getRight(); @@ -110,12 +114,16 @@ public class ResourceManagerHelperImpl implements ResourceManagerHelper { // Add the built-in pack only if namespaces for the specified resource type are present. if (!pack.getNamespaces(resourceType).isEmpty()) { // Make the resource pack profile for built-in pack, should never be always enabled. - ResourcePackProfile profile = ResourcePackProfile.of(entry.getLeft(), + ResourcePackProfile profile = ResourcePackProfile.create( + entry.getRight().getId().toString(), + Text.literal(entry.getLeft()), pack.getActivationType() == ResourcePackActivationType.ALWAYS_ENABLED, - entry::getRight, factory, ResourcePackProfile.InsertionPosition.TOP, new BuiltinModResourcePackSource(pack.getFabricModMetadata().getId())); - if (profile != null) { - consumer.accept(profile); - } + ignored -> entry.getRight(), + resourceType, + ResourcePackProfile.InsertionPosition.TOP, + new BuiltinModResourcePackSource(pack.getFabricModMetadata().getName()) + ); + consumer.accept(profile); } } } diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ResourcePackSourceTracker.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ResourcePackSourceTracker.java index 87132ac74..aecdd4945 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ResourcePackSourceTracker.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ResourcePackSourceTracker.java @@ -38,10 +38,10 @@ public final class ResourcePackSourceTracker { * Gets the source of a pack. * * @param pack the resource pack - * @return the source, or {@link ResourcePackSource#PACK_SOURCE_NONE} if not tracked + * @return the source, or {@link ResourcePackSource#NONE} if not tracked */ public static ResourcePackSource getSource(ResourcePack pack) { - return SOURCES.getOrDefault(pack, ResourcePackSource.PACK_SOURCE_NONE); + return SOURCES.getOrDefault(pack, ResourcePackSource.NONE); } /** diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/client/pack/ProgrammerArtResourcePack.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/client/pack/ProgrammerArtResourcePack.java deleted file mode 100644 index e28da3a00..000000000 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/client/pack/ProgrammerArtResourcePack.java +++ /dev/null @@ -1,111 +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.impl.resource.loader.client.pack; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.function.Predicate; - -import org.jetbrains.annotations.Nullable; - -import net.minecraft.resource.AbstractFileResourcePack; -import net.minecraft.resource.ResourceType; -import net.minecraft.resource.metadata.ResourceMetadataReader; -import net.minecraft.util.Identifier; - -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.resource.ModResourcePack; -import net.fabricmc.fabric.impl.resource.loader.GroupResourcePack; - -/** - * Represents the Programmer Art resource pack with support for modded content. - * - *

Any vanilla resources are provided like in Vanilla through the original programmer art, any missing resources - * will be searched in the provided modded resource packs. - */ -@Environment(EnvType.CLIENT) -public class ProgrammerArtResourcePack extends GroupResourcePack { - private final AbstractFileResourcePack originalResourcePack; - - public ProgrammerArtResourcePack(AbstractFileResourcePack originalResourcePack, List modResourcePacks) { - super(ResourceType.CLIENT_RESOURCES, modResourcePacks); - this.originalResourcePack = originalResourcePack; - } - - @Override - public InputStream openRoot(String fileName) throws IOException { - if (!fileName.contains("/") && !fileName.contains("\\")) { - // There should be nothing to read at the root of mod's Programmer Art extensions. - return this.originalResourcePack.openRoot(fileName); - } else { - throw new IllegalArgumentException("Root resources can only be filenames, not paths (no / allowed!)"); - } - } - - @Override - public InputStream open(ResourceType type, Identifier id) throws IOException { - if (this.originalResourcePack.contains(type, id)) { - return this.originalResourcePack.open(type, id); - } - - return super.open(type, id); - } - - @Override - public Collection findResources(ResourceType type, String namespace, String prefix, Predicate predicate) { - Set resources = new HashSet<>(this.originalResourcePack.findResources(type, namespace, prefix, predicate)); - - resources.addAll(super.findResources(type, namespace, prefix, predicate)); - - return resources; - } - - @Override - public boolean contains(ResourceType type, Identifier id) { - return this.originalResourcePack.contains(type, id) || super.contains(type, id); - } - - @Override - public Set getNamespaces(ResourceType type) { - Set namespaces = this.originalResourcePack.getNamespaces(type); - - namespaces.addAll(super.getNamespaces(type)); - - return namespaces; - } - - @Override - public @Nullable T parseMetadata(ResourceMetadataReader metaReader) throws IOException { - return this.originalResourcePack.parseMetadata(metaReader); - } - - @Override - public String getName() { - return "Programmer Art"; - } - - @Override - public void close() { - this.originalResourcePack.close(); - super.close(); - } -} diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/DefaultResourcePackMixin.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/DefaultResourcePackMixin.java deleted file mode 100644 index 59d12cad6..000000000 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/DefaultResourcePackMixin.java +++ /dev/null @@ -1,127 +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.resource.loader; - -import java.io.IOException; -import java.io.InputStream; -import java.net.JarURLConnection; -import java.net.URL; -import java.net.URLConnection; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Collection; -import java.util.function.Predicate; - -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Unique; - -import net.minecraft.resource.DefaultResourcePack; -import net.minecraft.resource.DirectoryResourcePack; -import net.minecraft.resource.ResourcePack; -import net.minecraft.resource.ResourceType; -import net.minecraft.resource.ZipResourcePack; -import net.minecraft.util.Identifier; - -/** - * Make the default resource pack use the MC jar directly instead of the full classpath. - * This is a major speed improvement, as well as a bugfix (it prevents other mod jars from overriding MC's resources). - */ -@Mixin(DefaultResourcePack.class) -public abstract class DefaultResourcePackMixin { - /** - * Redirect all resource access to the MC jar zip pack. - */ - final ResourcePack fabric_mcJarPack = createJarZipPack(); - - @Unique - private ResourcePack createJarZipPack() { - ResourceType type; - - if (getClass().equals(DefaultResourcePack.class)) { - // Server pack - type = ResourceType.SERVER_DATA; - } else { - // Client pack - type = ResourceType.CLIENT_RESOURCES; - } - - // Locate MC jar by finding the URL that contains the assets root. - try { - URL assetsRootUrl = DefaultResourcePack.class.getResource("/" + type.getDirectory() + "/.mcassetsroot"); - URLConnection connection = assetsRootUrl.openConnection(); - - if (connection instanceof JarURLConnection jarURLConnection) { - return new ZipResourcePack(Paths.get(jarURLConnection.getJarFileURL().toURI()).toFile()); - } else { - // Not a jar, assume it's a regular directory. - Path rootPath = Paths.get(assetsRootUrl.toURI()).resolve("../..").toAbsolutePath(); - return new DirectoryResourcePack(rootPath.toFile()); - } - } catch (Exception exception) { - throw new RuntimeException("Fabric: Failed to locate Minecraft assets root!", exception); - } - } - - /** - * @author FabricMC - * @reason Gets rid of classpath scanning. - */ - @Overwrite - public Collection findResources(ResourceType type, String namespace, String prefix, Predicate predicate) { - return fabric_mcJarPack.findResources(type, namespace, prefix, predicate); - } - - /** - * @author FabricMC - * @reason Gets rid of classpath scanning. - */ - @Overwrite - public boolean contains(ResourceType type, Identifier id) { - return fabric_mcJarPack.contains(type, id); - } - - /** - * @author FabricMC - * @reason Close the resource pack we redirect resource access to. - */ - @Overwrite - public void close() { - fabric_mcJarPack.close(); - } - - /** - * @author FabricMC - * @reason Gets rid of classpath scanning. - */ - @Nullable - @Overwrite - public InputStream getInputStream(String path) throws IOException { - return fabric_mcJarPack.openRoot(path); - } - - /** - * @author FabricMC - * @reason Gets rid of classpath scanning. - */ - @Nullable - @Overwrite - public InputStream findInputStream(ResourceType type, Identifier id) throws IOException { - return fabric_mcJarPack.open(type, id); - } -} diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/NamespaceResourceManagerAccessor.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/NamespaceResourceManagerAccessor.java deleted file mode 100644 index 6d28c33a9..000000000 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/NamespaceResourceManagerAccessor.java +++ /dev/null @@ -1,36 +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.resource.loader; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; -import org.spongepowered.asm.mixin.gen.Invoker; - -import net.minecraft.resource.NamespaceResourceManager; -import net.minecraft.resource.ResourceType; -import net.minecraft.util.Identifier; - -@Mixin(NamespaceResourceManager.class) -public interface NamespaceResourceManagerAccessor { - @Accessor("type") - ResourceType getType(); - - @Invoker("getMetadataPath") - static Identifier fabric$accessor_getMetadataPath(Identifier id) { - throw new UnsupportedOperationException("Invoker injection failed."); - } -} diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/NamespaceResourceManagerEntryMixin.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/NamespaceResourceManagerEntryMixin.java deleted file mode 100644 index da15c702c..000000000 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/NamespaceResourceManagerEntryMixin.java +++ /dev/null @@ -1,48 +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.resource.loader; - -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import net.minecraft.resource.NamespaceResourceManager; -import net.minecraft.resource.Resource; -import net.minecraft.resource.ResourcePackSource; - -import net.fabricmc.fabric.impl.resource.loader.FabricNamespaceResourceManagerEntry; -import net.fabricmc.fabric.impl.resource.loader.FabricResource; - -@Mixin(NamespaceResourceManager.Entry.class) -public class NamespaceResourceManagerEntryMixin implements FabricNamespaceResourceManagerEntry { - @Unique - private @Nullable ResourcePackSource fabric_packSource; - - @Override - public void setFabricPackSource(ResourcePackSource packSource) { - this.fabric_packSource = packSource; - } - - @Inject(method = "toReference", at = @At("RETURN")) - public void toReference(CallbackInfoReturnable cir) { - Resource resource = cir.getReturnValue(); - ((FabricResource) resource).setFabricPackSource(fabric_packSource); - } -} diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/NamespaceResourceManagerMixin.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/NamespaceResourceManagerMixin.java index d12dc42f1..74f3972a5 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/NamespaceResourceManagerMixin.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/NamespaceResourceManagerMixin.java @@ -16,9 +16,8 @@ package net.fabricmc.fabric.mixin.resource.loader; -import java.util.Iterator; +import java.io.InputStream; import java.util.List; -import java.util.Optional; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -27,83 +26,38 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import net.minecraft.resource.InputSupplier; import net.minecraft.resource.NamespaceResourceManager; import net.minecraft.resource.Resource; import net.minecraft.resource.ResourcePack; import net.minecraft.resource.ResourceType; import net.minecraft.util.Identifier; -import net.fabricmc.fabric.impl.resource.loader.FabricNamespaceResourceManagerEntry; -import net.fabricmc.fabric.impl.resource.loader.FabricResource; import net.fabricmc.fabric.impl.resource.loader.GroupResourcePack; -import net.fabricmc.fabric.impl.resource.loader.ResourcePackSourceTracker; /** * Patches getAllResources and method_41265 to work with GroupResourcePack. */ @Mixin(NamespaceResourceManager.class) public class NamespaceResourceManagerMixin { - private final ThreadLocal> fabric$getAllResources$resources = new ThreadLocal<>(); + private final ThreadLocal> fabric$getAllResources$resources = new ThreadLocal<>(); @Inject(method = "getAllResources", - at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/NamespaceResourceManager;getMetadataPath(Lnet/minecraft/util/Identifier;)Lnet/minecraft/util/Identifier;"), + at = @At(value = "INVOKE", target = "Ljava/util/List;size()I"), locals = LocalCapture.CAPTURE_FAILHARD) - private void onGetAllResources(Identifier id, CallbackInfoReturnable> cir, List resources) { + private void onGetAllResources(Identifier id, CallbackInfoReturnable> cir, Identifier metadataId, List resources) { this.fabric$getAllResources$resources.set(resources); } @Redirect(method = "getAllResources", - at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/ResourcePack;contains(Lnet/minecraft/resource/ResourceType;Lnet/minecraft/util/Identifier;)Z")) - private boolean onResourceAdd(ResourcePack pack, ResourceType type, Identifier id) { + at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/ResourcePack;open(Lnet/minecraft/resource/ResourceType;Lnet/minecraft/util/Identifier;)Lnet/minecraft/resource/InputSupplier;")) + private InputSupplier onResourceAdd(ResourcePack pack, ResourceType type, Identifier id) { if (pack instanceof GroupResourcePack) { - ((GroupResourcePack) pack).appendResources((NamespaceResourceManagerAccessor) this, id, this.fabric$getAllResources$resources.get()); + ((GroupResourcePack) pack).appendResources(type, id, this.fabric$getAllResources$resources.get()); - return false; + return null; } - return pack.contains(type, id); - } - - @Redirect(method = "findAndAdd", - at = @At(value = "INVOKE", target = "Ljava/util/List;add(Ljava/lang/Object;)Z"), - allow = 1) - private boolean onResourceAdd(List entries, Object entryObject) { - // Required due to type erasure of List.add - NamespaceResourceManager.Entry entry = (NamespaceResourceManager.Entry) entryObject; - ResourcePack pack = entry.pack; - - if (pack instanceof GroupResourcePack grp) { - grp.appendResources((NamespaceResourceManagerAccessor) this, entry.id, entries); - return true; - } - - return entries.add(entry); - } - - /* The two injectors below set the resource pack sources (see FabricResourceImpl) - * for resources created in NamespaceResourceManager.getAllResources and NamespaceResourceManager.getResource. - * - * Since (in 1.18.2) ResourceImpl doesn't hold a reference to its resource pack, - * we have to get the source from the resource pack when the resource is created. - * These are the main creation sites for resources in 1.18.2 - * along with DefaultResourcePack.getResource and Fabric API's GroupResourcePack, - * which also either track the source similarly or provide other types of Resource instances - * that have a different FabricResource implementation. - */ - @Inject(method = "getAllResources", at = @At(value = "INVOKE", target = "Ljava/util/List;add(Ljava/lang/Object;)Z", remap = false, shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD) - private void trackSourceOnGetAllResources(Identifier id, CallbackInfoReturnable> cir, List entries, Identifier identifier, String string, Iterator var5, NamespaceResourceManager.FilterablePack filterablePack, ResourcePack resourcePack) { - // After the created resource has been added, read it from the list and set its source - // to match the tracked source of its resource pack. - if (entries.get(entries.size() - 1) instanceof FabricNamespaceResourceManagerEntry entry) { - entry.setFabricPackSource(ResourcePackSourceTracker.getSource(resourcePack)); - } - } - - @Inject(method = "getResource", at = @At(value = "RETURN", ordinal = 1), locals = LocalCapture.CAPTURE_FAILHARD) - private void trackSourceOnGetResource(Identifier identifier, CallbackInfoReturnable> cir, int i, NamespaceResourceManager.FilterablePack filterablePack, ResourcePack resourcePack) { - // Set the resource's source to match the tracked source of its resource pack. - if (cir.getReturnValue().orElseThrow() instanceof FabricResource resource) { - resource.setFabricPackSource(ResourcePackSourceTracker.getSource(resourcePack)); - } + return pack.open(type, id); } } diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourceMixin.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourceMixin.java index 7b11eba0b..bd510500c 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourceMixin.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourceMixin.java @@ -16,16 +16,13 @@ package net.fabricmc.fabric.mixin.resource.loader; -import java.util.Objects; - -import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; import net.minecraft.resource.Resource; import net.minecraft.resource.ResourcePackSource; import net.fabricmc.fabric.impl.resource.loader.FabricResource; +import net.fabricmc.fabric.impl.resource.loader.ResourcePackSourceTracker; /** * Implements {@link FabricResource} (resource source getter/setter) @@ -35,16 +32,10 @@ import net.fabricmc.fabric.impl.resource.loader.FabricResource; */ @Mixin(Resource.class) class ResourceMixin implements FabricResource { - @Unique - private @Nullable ResourcePackSource fabric_packSource; - + @SuppressWarnings("ConstantConditions") @Override public ResourcePackSource getFabricPackSource() { - return Objects.requireNonNullElse(fabric_packSource, ResourcePackSource.PACK_SOURCE_NONE); - } - - @Override - public void setFabricPackSource(ResourcePackSource packSource) { - this.fabric_packSource = packSource; + Resource self = (Resource) (Object) this; + return ResourcePackSourceTracker.getSource(self.getPack()); } } diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourcePackManagerAccessor.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourcePackManagerAccessor.java deleted file mode 100644 index 7bc4d09d5..000000000 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourcePackManagerAccessor.java +++ /dev/null @@ -1,36 +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.resource.loader; - -import java.util.Set; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import net.minecraft.resource.ResourcePackManager; -import net.minecraft.resource.ResourcePackProvider; - -@Mixin(ResourcePackManager.class) -public interface ResourcePackManagerAccessor { - /** - * Returns the resource pack providers of this resource pack manager. - * - * @return The resource pack providers. - */ - @Accessor("providers") - Set getProviders(); -} diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourcePackManagerMixin.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourcePackManagerMixin.java index 11813de92..181dc05f3 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourcePackManagerMixin.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourcePackManagerMixin.java @@ -44,7 +44,7 @@ public abstract class ResourcePackManagerMixin { private Set providers; @Inject(method = "", at = @At("RETURN")) - public void construct(ResourcePackProfile.Factory arg, ResourcePackProvider[] resourcePackProviders, CallbackInfo info) { + public void construct(ResourcePackProvider[] resourcePackProviders, CallbackInfo info) { providers = new HashSet<>(providers); // Search resource pack providers to find any server-related pack provider. @@ -52,8 +52,8 @@ public abstract class ResourcePackManagerMixin { for (ResourcePackProvider provider : this.providers) { if (provider instanceof FileResourcePackProvider - && (((FileResourcePackProviderAccessor) provider).getResourcePackSource() == ResourcePackSource.PACK_SOURCE_WORLD - || ((FileResourcePackProviderAccessor) provider).getResourcePackSource() == ResourcePackSource.PACK_SOURCE_SERVER)) { + && (((FileResourcePackProvider) provider).source == ResourcePackSource.WORLD + || ((FileResourcePackProvider) provider).source == ResourcePackSource.SERVER)) { shouldAddServerProvider = true; break; } diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/MainMixin.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ServerPropertiesHandlerMixin.java similarity index 72% rename from fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/MainMixin.java rename to fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ServerPropertiesHandlerMixin.java index 64d2db878..4e67b5346 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/MainMixin.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ServerPropertiesHandlerMixin.java @@ -20,15 +20,15 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import net.minecraft.resource.DataPackSettings; -import net.minecraft.server.Main; +import net.minecraft.class_7712; +import net.minecraft.server.dedicated.ServerPropertiesHandler; import net.fabricmc.fabric.impl.resource.loader.ModResourcePackUtil; -@Mixin(Main.class) -public class MainMixin { - @Redirect(method = "main", at = @At(value = "FIELD", target = "Lnet/minecraft/resource/DataPackSettings;SAFE_MODE:Lnet/minecraft/resource/DataPackSettings;")) - private static DataPackSettings replaceDefaultDataPackSettings() { +@Mixin(ServerPropertiesHandler.class) +public class ServerPropertiesHandlerMixin { + @Redirect(method = "", at = @At(value = "FIELD", target = "Lnet/minecraft/class_7712;field_40260:Lnet/minecraft/class_7712;")) + private class_7712 replaceDefaultDataPackSettings() { return ModResourcePackUtil.createDefaultDataPackSettings(); } } diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/TestServerMixin.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/TestServerMixin.java index ee6373f49..21a12a8be 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/TestServerMixin.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/TestServerMixin.java @@ -16,34 +16,25 @@ package net.fabricmc.fabric.mixin.resource.loader; -import java.util.function.Supplier; +import java.util.List; -import com.mojang.serialization.JsonOps; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; import net.minecraft.resource.DataPackSettings; -import net.minecraft.resource.ResourceManager; import net.minecraft.test.TestServer; -import net.minecraft.util.dynamic.RegistryOps; -import net.minecraft.util.registry.DynamicRegistryManager; import net.fabricmc.fabric.impl.resource.loader.ModResourcePackUtil; +/** + * Vanilla enables all available datapacks automatically in TestServer#create, but it does so in alphabetical order, + * which means the Vanilla pack has higher precedence than modded, breaking our tests. + */ @Mixin(TestServer.class) public class TestServerMixin { - @Redirect(method = "create", at = @At(value = "FIELD", target = "Lnet/minecraft/resource/DataPackSettings;SAFE_MODE:Lnet/minecraft/resource/DataPackSettings;")) - private static DataPackSettings replaceDefaultDataPackSettings() { - return ModResourcePackUtil.createDefaultDataPackSettings(); - } - - @SuppressWarnings("unchecked") - @Redirect(method = "method_40377", at = @At(value = "INVOKE", target = "Ljava/util/function/Supplier;get()Ljava/lang/Object;")) - private static T loadRegistry(Supplier unused, ResourceManager resourceManager) { - DynamicRegistryManager.Mutable mutableRegistryManager = DynamicRegistryManager.createAndLoad(); - // This loads the dynamic registry manager - RegistryOps.ofLoaded(JsonOps.INSTANCE, mutableRegistryManager, resourceManager); - return (T) mutableRegistryManager.toImmutable(); + @Redirect(method = "create", at = @At(value = "NEW", target = "(Ljava/util/List;Ljava/util/List;)Lnet/minecraft/resource/DataPackSettings;")) + private static DataPackSettings replaceDefaultDataPackSettings(List enabled, List disabled) { + return ModResourcePackUtil.createDefaultDataPackSettings().dataPacks(); } } 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 165fffadb..a60e57afe 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 @@ -1,6 +1,6 @@ accessWidener v2 named - -accessible method net/minecraft/resource/NamespaceResourceManager$Entry (Lnet/minecraft/resource/NamespaceResourceManager;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/resource/ResourcePack;)V -accessible field net/minecraft/resource/NamespaceResourceManager$Entry id Lnet/minecraft/util/Identifier; -accessible field net/minecraft/resource/NamespaceResourceManager$Entry pack Lnet/minecraft/resource/ResourcePack; -accessible class net/minecraft/resource/NamespaceResourceManager$FilterablePack +accessible field net/minecraft/resource/NamespaceResourceManager type Lnet/minecraft/resource/ResourceType; +accessible method net/minecraft/resource/NamespaceResourceManager getMetadataPath (Lnet/minecraft/util/Identifier;)Lnet/minecraft/util/Identifier; +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; diff --git a/fabric-resource-loader-v0/src/main/resources/fabric-resource-loader-v0.mixins.json b/fabric-resource-loader-v0/src/main/resources/fabric-resource-loader-v0.mixins.json index 443845724..22337eead 100644 --- a/fabric-resource-loader-v0/src/main/resources/fabric-resource-loader-v0.mixins.json +++ b/fabric-resource-loader-v0/src/main/resources/fabric-resource-loader-v0.mixins.json @@ -3,20 +3,15 @@ "package": "net.fabricmc.fabric.mixin.resource.loader", "compatibilityLevel": "JAVA_16", "mixins": [ - "DefaultResourcePackMixin", - "FileResourcePackProviderAccessor", "KeyedResourceReloadListenerMixin", "LifecycledResourceManagerImplMixin", - "MainMixin", "MinecraftServerMixin", - "NamespaceResourceManagerAccessor", - "NamespaceResourceManagerEntryMixin", "NamespaceResourceManagerMixin", "ReloadableResourceManagerImplMixin", "ResourceMixin", "ResourcePackManagerMixin", - "ResourcePackManagerAccessor", "ResourcePackProfileMixin", + "ServerPropertiesHandlerMixin", "SimpleResourceReloadMixin", "TestServerMixin" ], diff --git a/fabric-resource-loader-v0/src/testmod/resources/resourcepacks/test/assets/minecraft/textures/block/dirt.png b/fabric-resource-loader-v0/src/testmod/resources/resourcepacks/test/assets/minecraft/textures/block/dirt.png index 7d6941764eb8bf6d9e6208682d4045846a685243..9c96618a01b29a35ba1b6849baa2e9e57196ddbc 100644 GIT binary patch literal 1887 zcmah~eM}Q)7(WCjP^;q5xXvw?QzlW{Ym4pR(!#K5keSW{^_q@-? z``#LZel9;&5DP&NUz?%M0srH`14oYlzqNO%?GP0818FodCS4Y0rko<&LKPDt*69W~ z1S!&3H*Q`=FmN$pBV9`5!SQAUCM`-NPo@*=+$zFOW|Vt~+;Y9qT)xblVnNbUV-+k0 z1e^qe!>rTcqA^y91avX*&Y4jJ4p5k7O2niyz$(f^z%r3cBt}wWVTH$H#d6ehLe5~N zMC=UX#!$4ZtV~pvB%(YvRFaaCf{LZ6R4N1vA?+4Dccj zCKzCYvtYp){QvmeM8gW;q0?a*B+XDBZ@?5B^IT$ia1~rS$iRHVaG=W=Zsw}4MBEwP{axnv}IU3ASiKD z$)?sB>g@QlY1Zl&)kwZ6OCYa$k%;4x;>4NOdg-MT-W$JvyX|551MR^DM{{d0^&j~Q zUE<%j1<5&BD{Dw^^;(xsrCm4cTL-RH==9r>0jP2@)uMu64V-_$C6bfZ$r%deV3|Q7M8n((-U`ZcD*GsrNI#>)Lj^ z`t-zy)|sbPMPE1Xh^xB2dwayT=eKsQ*5_wWZN59LvL@kNyG3p~W7!m?b&T+dGM_Z6 z3ws;a#`|3_Up{SbtElj_`&SyC-by~O-_R6Olz;Z`WcQ8(s-D!7-fuQGA09hE`E0zp z%CSp3I(vOP&m8S^MAqHsw;L;`9%!7~(b+v|sn1Y3atr-qeRp5Vu}DJKbZ2~N=`P** zj`Nj~jpcUU{ z37K}Xcb@DQVf+liy^j)`N+W$ecL&-!cXpWvB7Aec*6hAK5= BOX_ENTITY = FabricBlockEntityTypeBuilder.create(BoxBlockEntity::new, BOX).build(); public static final ScreenHandlerType BAG_SCREEN_HANDLER = new ScreenHandlerType<>(BagScreenHandler::new); public static final ScreenHandlerType POSITIONED_BAG_SCREEN_HANDLER = new ExtendedScreenHandlerType<>(PositionedBagScreenHandler::new); diff --git a/fabric-sound-api-v1/build.gradle b/fabric-sound-api-v1/build.gradle index 60afee363..2fe939c6e 100644 --- a/fabric-sound-api-v1/build.gradle +++ b/fabric-sound-api-v1/build.gradle @@ -1,12 +1,6 @@ archivesBaseName = "fabric-sound-api-v1" version = getSubprojectVersion(project) -loom { - interfaceInjection { - interfaceInjectionSourceSets.add sourceSets.client - } -} - testDependencies(project, [ ':fabric-api-base', ':fabric-resource-loader-v0', diff --git a/fabric-textures-v0/src/client/java/net/fabricmc/fabric/api/event/client/ClientSpriteRegistryCallback.java b/fabric-textures-v0/src/client/java/net/fabricmc/fabric/api/event/client/ClientSpriteRegistryCallback.java index d635bf43f..df44e2f1b 100644 --- a/fabric-textures-v0/src/client/java/net/fabricmc/fabric/api/event/client/ClientSpriteRegistryCallback.java +++ b/fabric-textures-v0/src/client/java/net/fabricmc/fabric/api/event/client/ClientSpriteRegistryCallback.java @@ -17,10 +17,10 @@ package net.fabricmc.fabric.api.event.client; import java.util.Map; -import java.util.function.Consumer; -import net.minecraft.client.texture.Sprite; -import net.minecraft.client.texture.SpriteAtlasTexture; +import net.minecraft.class_7766; +import net.minecraft.resource.Resource; +import net.minecraft.resource.ResourceManager; import net.minecraft.util.Identifier; import net.fabricmc.fabric.api.event.Event; @@ -28,59 +28,23 @@ import net.fabricmc.fabric.impl.client.texture.SpriteRegistryCallbackHolder; public interface ClientSpriteRegistryCallback { /** - * @deprecated Use the {@link ClientSpriteRegistryCallback#event(Identifier)} registration method. Since 1.14 - * started making use of multiple sprite atlases, it is unwise to register sprites to *all* of them. + * Add sprites to the map of sprites that will be baked into the sprite atlas. + * + * @see class_7766#method_45834 For adding textures from a folder recursively. + * @see class_7766#method_45830 For adding a single texture. */ - @Deprecated - Event EVENT = SpriteRegistryCallbackHolder.EVENT_GLOBAL; - - void registerSprites(SpriteAtlasTexture atlasTexture, Registry registry); + void registerSprites(ResourceManager resourceManager, Map sprites); /** * Get an event instance for a given atlas path. * * @param atlasId The atlas texture ID you want to register to. * @return The event for a given atlas path. - * * @since 0.1.1 + * + * @see net.minecraft.client.texture.SpriteAtlasTexture#BLOCK_ATLAS_TEXTURE */ static Event event(Identifier atlasId) { return SpriteRegistryCallbackHolder.eventLocal(atlasId); } - - /** - * @deprecated Use the {@link ClientSpriteRegistryCallback#event(Identifier)} registration method. - */ - @Deprecated - static void registerBlockAtlas(ClientSpriteRegistryCallback callback) { - event(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE).register(callback); - } - - class Registry { - private final Map spriteMap; - private final Consumer defaultSpriteRegister; - - public Registry(Map spriteMap, Consumer defaultSpriteRegister) { - this.spriteMap = spriteMap; - this.defaultSpriteRegister = defaultSpriteRegister; - } - - /** - * Register a sprite to be loaded using the default implementation. - * - * @param id The sprite identifier. - */ - public void register(Identifier id) { - this.defaultSpriteRegister.accept(id); - } - - /** - * Register a custom sprite to be added and loaded. - * - * @param sprite The sprite to be added. - */ - public void register(Sprite sprite) { - spriteMap.put(sprite.getId(), sprite); - } - } } diff --git a/fabric-textures-v0/src/client/java/net/fabricmc/fabric/impl/client/texture/SpriteRegistryCallbackHolder.java b/fabric-textures-v0/src/client/java/net/fabricmc/fabric/impl/client/texture/SpriteRegistryCallbackHolder.java index 734b9013f..0040e7900 100644 --- a/fabric-textures-v0/src/client/java/net/fabricmc/fabric/impl/client/texture/SpriteRegistryCallbackHolder.java +++ b/fabric-textures-v0/src/client/java/net/fabricmc/fabric/impl/client/texture/SpriteRegistryCallbackHolder.java @@ -18,9 +18,6 @@ package net.fabricmc.fabric.impl.client.texture; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock; import net.minecraft.util.Identifier; @@ -29,11 +26,7 @@ import net.fabricmc.fabric.api.event.EventFactory; import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; public final class SpriteRegistryCallbackHolder { - public static final Event EVENT_GLOBAL = createEvent(); private static final Map> eventMap = new ConcurrentHashMap<>(); - private static final ReadWriteLock eventMapLock = new ReentrantReadWriteLock(); - private static final Lock eventMapReadLock = eventMapLock.readLock(); - private static final Lock eventMapWriteLock = eventMapLock.writeLock(); private SpriteRegistryCallbackHolder() { } diff --git a/fabric-textures-v0/src/client/java/net/fabricmc/fabric/mixin/client/texture/SpriteAtlasManagerMixin.java b/fabric-textures-v0/src/client/java/net/fabricmc/fabric/mixin/client/texture/SpriteAtlasManagerMixin.java new file mode 100644 index 000000000..44edd2fbe --- /dev/null +++ b/fabric-textures-v0/src/client/java/net/fabricmc/fabric/mixin/client/texture/SpriteAtlasManagerMixin.java @@ -0,0 +1,61 @@ +/* + * 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.client.texture; + +import java.util.HashMap; +import java.util.Map; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + +import net.minecraft.client.render.model.SpriteAtlasManager; +import net.minecraft.resource.Resource; +import net.minecraft.util.Identifier; + +import net.fabricmc.fabric.impl.client.texture.SpriteRegistryCallbackHolder; + +/** + * Mix in to where texture atlases discover the files they should bake. + */ +@Mixin(SpriteAtlasManager.class) +public class SpriteAtlasManagerMixin { + @ModifyVariable(method = "", at = @At("HEAD")) + private static Map initAtlases(Map atlases) { + // Make modifiable + atlases = new HashMap<>(atlases); + + for (Map.Entry entry : atlases.entrySet()) { + SpriteAtlasManager.class_7773 resourceFinder = entry.getValue(); + + entry.setValue(resourceManager -> { + // First run vanilla logic + Map resources = resourceFinder.apply(resourceManager); + + // Then invoke event + SpriteRegistryCallbackHolder + .eventLocal(entry.getKey()) + .invoker() + .registerSprites(resourceManager, resources); + + return resources; + }); + } + + return atlases; + } +} diff --git a/fabric-textures-v0/src/client/java/net/fabricmc/fabric/mixin/client/texture/SpriteAtlasTextureMixin.java b/fabric-textures-v0/src/client/java/net/fabricmc/fabric/mixin/client/texture/SpriteAtlasTextureMixin.java deleted file mode 100644 index 879fd04fd..000000000 --- a/fabric-textures-v0/src/client/java/net/fabricmc/fabric/mixin/client/texture/SpriteAtlasTextureMixin.java +++ /dev/null @@ -1,141 +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.client.texture; - -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import com.google.common.base.Joiner; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyVariable; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import net.minecraft.client.texture.Sprite; -import net.minecraft.client.texture.SpriteAtlasTexture; -import net.minecraft.resource.ResourceManager; -import net.minecraft.util.Identifier; -import net.minecraft.util.crash.CrashException; -import net.minecraft.util.crash.CrashReport; -import net.minecraft.util.crash.CrashReportSection; - -import net.fabricmc.fabric.api.client.texture.DependentSprite; -import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; -import net.fabricmc.fabric.impl.client.texture.SpriteRegistryCallbackHolder; - -@Mixin(SpriteAtlasTexture.class) -public abstract class SpriteAtlasTextureMixin { - @Shadow - public abstract Identifier getId(); - - private Map fabric_injectedSprites; - - // Loads in custom sprite object injections. - @Inject(at = @At("RETURN"), method = "loadSprites(Lnet/minecraft/resource/ResourceManager;Ljava/util/Set;)Ljava/util/Collection;") - private void afterLoadSprites(ResourceManager resourceManager_1, Set set_1, CallbackInfoReturnable> info) { - if (fabric_injectedSprites != null) { - info.getReturnValue().addAll(fabric_injectedSprites.values()); - fabric_injectedSprites = null; - } - } - - // Handles DependentSprite + custom sprite object injections. - @ModifyVariable(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/SpriteAtlasTexture;loadSprites(Lnet/minecraft/resource/ResourceManager;Ljava/util/Set;)Ljava/util/Collection;"), method = "stitch") - public Set beforeSpriteLoad(Set set) { - fabric_injectedSprites = new HashMap<>(); - ClientSpriteRegistryCallback.Registry registry = new ClientSpriteRegistryCallback.Registry(fabric_injectedSprites, set::add); - - SpriteRegistryCallbackHolder.eventLocal(getId()).invoker().registerSprites((SpriteAtlasTexture) (Object) this, registry); - SpriteRegistryCallbackHolder.EVENT_GLOBAL.invoker().registerSprites((SpriteAtlasTexture) (Object) this, registry); - - // TODO: Unoptimized. - Set dependentSprites = new HashSet<>(); - Set dependentSpriteIds = new HashSet<>(); - - for (Identifier id : set) { - Sprite sprite; - - if ((sprite = fabric_injectedSprites.get(id)) instanceof DependentSprite) { - dependentSprites.add((DependentSprite) sprite); - dependentSpriteIds.add(id); - } - } - - Set result = set; - boolean isResultNew = false; - - if (!dependentSprites.isEmpty()) { - if (!isResultNew) { - result = new LinkedHashSet<>(); - isResultNew = true; - } - - for (Identifier id : set) { - if (!dependentSpriteIds.contains(id)) { - result.add(id); - } - } - - int lastSpriteSize = 0; - - while (lastSpriteSize != result.size() && result.size() < set.size()) { - lastSpriteSize = result.size(); - - for (DependentSprite sprite : dependentSprites) { - Identifier id = ((Sprite) sprite).getId(); - - if (!result.contains(id) && result.containsAll(sprite.getDependencies())) { - result.add(id); - } - } - } - - if (result.size() < set.size()) { - CrashReport report = CrashReport.create(new Throwable(), "Resolving sprite dependencies"); - - for (DependentSprite sprite : dependentSprites) { - Identifier id = ((Sprite) sprite).getId(); - - if (!result.contains(id)) { - CrashReportSection element = report.addElement("Unresolved sprite"); - element.add("Sprite", id); - element.add("Dependencies", Joiner.on(',').join(sprite.getDependencies())); - } - } - - throw new CrashException(report); - } - } - - if (!fabric_injectedSprites.isEmpty()) { - if (!isResultNew) { - result = new LinkedHashSet<>(set); - isResultNew = true; - } - - result.removeAll(fabric_injectedSprites.keySet()); - } - - return result; - } -} diff --git a/fabric-textures-v0/src/client/resources/fabric-textures-v0.mixins.json b/fabric-textures-v0/src/client/resources/fabric-textures-v0.mixins.json index ca383ac1b..a77cf0915 100644 --- a/fabric-textures-v0/src/client/resources/fabric-textures-v0.mixins.json +++ b/fabric-textures-v0/src/client/resources/fabric-textures-v0.mixins.json @@ -3,7 +3,7 @@ "package": "net.fabricmc.fabric.mixin.client.texture", "compatibilityLevel": "JAVA_16", "client": [ - "SpriteAtlasTextureMixin" + "SpriteAtlasManagerMixin" ], "injectors": { "defaultRequire": 1 diff --git a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/ComposterWrapper.java b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/ComposterWrapper.java index 19b5b1fd4..6fe8fa0fa 100644 --- a/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/ComposterWrapper.java +++ b/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/ComposterWrapper.java @@ -118,7 +118,7 @@ public class ComposterWrapper extends SnapshotParticipant { location.setBlockState(newState); if (newLevel == 7) { - location.world.createAndScheduleBlockTick(location.pos, state.getBlock(), 20); + location.world.scheduleBlockTick(location.pos, state.getBlock(), 20); } } diff --git a/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/ingame/ExtractStickItem.java b/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/ingame/ExtractStickItem.java index 140d7baef..c641ea80b 100644 --- a/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/ingame/ExtractStickItem.java +++ b/fabric-transfer-api-v1/src/testmod/java/net/fabricmc/fabric/test/transfer/ingame/ExtractStickItem.java @@ -17,20 +17,19 @@ package net.fabricmc.fabric.test.transfer.ingame; import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemUsageContext; import net.minecraft.util.ActionResult; import net.fabricmc.fabric.api.transfer.v1.fluid.FluidConstants; -import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant; import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage; +import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant; import net.fabricmc.fabric.api.transfer.v1.storage.Storage; import net.fabricmc.fabric.api.transfer.v1.storage.StorageUtil; import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction; public class ExtractStickItem extends Item { public ExtractStickItem() { - super(new Settings().group(ItemGroup.MISC)); + super(new Settings()); } @Override 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 f608e11ab..ac5011c57 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 @@ -23,7 +23,6 @@ import net.minecraft.block.Material; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; @@ -63,6 +62,6 @@ public class TransferTestInitializer implements ModInitializer { private static void registerBlock(Block block, String name) { Identifier id = new Identifier(MOD_ID, name); Registry.register(Registry.BLOCK, id, block); - Registry.register(Registry.ITEM, id, new BlockItem(block, new Item.Settings().group(ItemGroup.MISC))); + Registry.register(Registry.ITEM, id, new BlockItem(block, new Item.Settings())); } } 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 8536b5f15..570b2941c 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 @@ -114,6 +114,7 @@ transitive-accessible field net/minecraft/inventory/SimpleInventory stacks Lnet/ ### Generated access wideners below # Constructors of non-abstract block classes +transitive-accessible method net/minecraft/block/AbstractButtonBlock (Lnet/minecraft/block/AbstractBlock$Settings;IZLnet/minecraft/sound/SoundEvent;Lnet/minecraft/sound/SoundEvent;)V transitive-accessible method net/minecraft/block/AirBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/AttachedStemBlock (Lnet/minecraft/block/GourdBlock;Ljava/util/function/Supplier;Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/AzaleaBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V @@ -142,7 +143,7 @@ transitive-accessible method net/minecraft/block/DeadCoralFanBlock (Lnet/ transitive-accessible method net/minecraft/block/DeadCoralWallFanBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/DirtPathBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/DispenserBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V -transitive-accessible method net/minecraft/block/DoorBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V +transitive-accessible method net/minecraft/block/DoorBlock (Lnet/minecraft/block/AbstractBlock$Settings;Lnet/minecraft/sound/SoundEvent;Lnet/minecraft/sound/SoundEvent;)V transitive-accessible method net/minecraft/block/DyedCarpetBlock (Lnet/minecraft/util/DyeColor;Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/EnchantingTableBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/EndGatewayBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V @@ -175,7 +176,7 @@ transitive-accessible method net/minecraft/block/PaneBlock (Lnet/minecraf transitive-accessible method net/minecraft/block/PlantBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/PlayerSkullBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/PoweredRailBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V -transitive-accessible method net/minecraft/block/PressurePlateBlock (Lnet/minecraft/block/PressurePlateBlock$ActivationRule;Lnet/minecraft/block/AbstractBlock$Settings;)V +transitive-accessible method net/minecraft/block/PressurePlateBlock (Lnet/minecraft/block/PressurePlateBlock$ActivationRule;Lnet/minecraft/block/AbstractBlock$Settings;Lnet/minecraft/sound/SoundEvent;Lnet/minecraft/sound/SoundEvent;)V transitive-accessible method net/minecraft/block/PumpkinBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/RailBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/RedstoneTorchBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V @@ -195,20 +196,18 @@ transitive-accessible method net/minecraft/block/SpawnerBlock (Lnet/minec transitive-accessible method net/minecraft/block/SpongeBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/StairsBlock (Lnet/minecraft/block/BlockState;Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/StemBlock (Lnet/minecraft/block/GourdBlock;Ljava/util/function/Supplier;Lnet/minecraft/block/AbstractBlock$Settings;)V -transitive-accessible method net/minecraft/block/StoneButtonBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/StructureBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/StructureVoidBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/SugarCaneBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/TorchBlock (Lnet/minecraft/block/AbstractBlock$Settings;Lnet/minecraft/particle/ParticleEffect;)V transitive-accessible method net/minecraft/block/TransparentBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V -transitive-accessible method net/minecraft/block/TrapdoorBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V +transitive-accessible method net/minecraft/block/TrapdoorBlock (Lnet/minecraft/block/AbstractBlock$Settings;Lnet/minecraft/sound/SoundEvent;Lnet/minecraft/sound/SoundEvent;)V transitive-accessible method net/minecraft/block/WallMountedBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/WallPlayerSkullBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/WallRedstoneTorchBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/WallSkullBlock (Lnet/minecraft/block/SkullBlock$SkullType;Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/WallTorchBlock (Lnet/minecraft/block/AbstractBlock$Settings;Lnet/minecraft/particle/ParticleEffect;)V transitive-accessible method net/minecraft/block/WallWitherSkullBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V -transitive-accessible method net/minecraft/block/WeightedPressurePlateBlock (ILnet/minecraft/block/AbstractBlock$Settings;)V +transitive-accessible method net/minecraft/block/WeightedPressurePlateBlock (ILnet/minecraft/block/AbstractBlock$Settings;Lnet/minecraft/sound/SoundEvent;Lnet/minecraft/sound/SoundEvent;)V transitive-accessible method net/minecraft/block/WetSpongeBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V transitive-accessible method net/minecraft/block/WitherSkullBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V -transitive-accessible method net/minecraft/block/WoodenButtonBlock (Lnet/minecraft/block/AbstractBlock$Settings;)V diff --git a/gradle.properties b/gradle.properties index dd7fcdcd4..bd24b98d3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,60 +1,60 @@ org.gradle.jvmargs=-Xmx2560M org.gradle.parallel=true -version=0.64.0 -minecraft_version=1.19.2 -yarn_version=+build.17 -loader_version=0.14.9 +version=0.65.0 +minecraft_version=22w42a +yarn_version=+build.19 +loader_version=0.14.10 -prerelease=false +prerelease=true # Do not manually update, use the bumpversions task: -fabric-api-base-version=0.4.12 -fabric-api-lookup-api-v1-version=1.6.10 -fabric-biome-api-v1-version=9.0.18 -fabric-blockrenderlayer-v1-version=1.1.21 -fabric-command-api-v1-version=1.2.12 -fabric-command-api-v2-version=2.1.8 -fabric-commands-v0-version=0.2.29 -fabric-containers-v0-version=0.1.35 -fabric-content-registries-v0-version=3.4.0 -fabric-crash-report-info-v1-version=0.2.6 -fabric-data-generation-api-v1-version=5.2.2 -fabric-dimensions-v1-version=2.1.32 -fabric-entity-events-v1-version=1.4.19 -fabric-events-interaction-v0-version=0.4.29 -fabric-events-lifecycle-v0-version=0.2.29 -fabric-game-rule-api-v1-version=1.0.22 -fabric-gametest-api-v1-version=1.1.1 -fabric-item-api-v1-version=1.5.8 -fabric-item-groups-v0-version=0.3.32 -fabric-key-binding-api-v1-version=1.0.22 -fabric-keybindings-v0-version=0.2.20 -fabric-lifecycle-events-v1-version=2.2.0 -fabric-loot-api-v2-version=1.1.6 -fabric-loot-tables-v1-version=1.1.9 -fabric-message-api-v1-version=5.0.4 -fabric-mining-level-api-v1-version=2.1.17 -fabric-models-v0-version=0.3.18 -fabric-networking-api-v1-version=1.2.5 -fabric-networking-v0-version=0.3.22 -fabric-object-builder-api-v1-version=4.0.14 -fabric-particles-v1-version=1.0.11 -fabric-registry-sync-v0-version=0.9.26 -fabric-renderer-api-v1-version=1.0.12 -fabric-renderer-indigo-version=0.6.14 -fabric-renderer-registries-v1-version=3.2.21 -fabric-rendering-data-attachment-v1-version=0.3.15 -fabric-rendering-fluids-v1-version=3.0.8 -fabric-rendering-v0-version=1.1.23 -fabric-rendering-v1-version=1.11.0 -fabric-resource-conditions-api-v1-version=2.1.0 -fabric-resource-loader-v0-version=0.7.2 -fabric-screen-api-v1-version=1.0.27 -fabric-screen-handler-api-v1-version=1.3.1 -fabric-sound-api-v1-version=1.0.0 -fabric-textures-v0-version=1.0.21 -fabric-transfer-api-v1-version=2.1.1 -fabric-transitive-access-wideners-v1-version=1.3.1 -fabric-convention-tags-v1-version=1.1.2 -fabric-client-tags-api-v1-version=1.0.2 +fabric-api-base-version=0.4.13 +fabric-api-lookup-api-v1-version=1.6.11 +fabric-biome-api-v1-version=10.0.0 +fabric-blockrenderlayer-v1-version=1.1.22 +fabric-command-api-v1-version=1.2.13 +fabric-command-api-v2-version=2.1.9 +fabric-commands-v0-version=0.2.30 +fabric-containers-v0-version=0.1.36 +fabric-content-registries-v0-version=3.4.1 +fabric-crash-report-info-v1-version=0.2.7 +fabric-data-generation-api-v1-version=6.0.0 +fabric-dimensions-v1-version=2.1.33 +fabric-entity-events-v1-version=1.4.20 +fabric-events-interaction-v0-version=0.4.30 +fabric-events-lifecycle-v0-version=0.2.30 +fabric-game-rule-api-v1-version=1.0.23 +fabric-gametest-api-v1-version=1.1.2 +fabric-item-api-v1-version=2.0.0 +fabric-item-group-api-v1-version=1.0.0 +fabric-key-binding-api-v1-version=1.0.23 +fabric-keybindings-v0-version=0.2.21 +fabric-lifecycle-events-v1-version=2.2.1 +fabric-loot-api-v2-version=1.1.7 +fabric-loot-tables-v1-version=1.1.10 +fabric-message-api-v1-version=5.0.5 +fabric-mining-level-api-v1-version=2.1.18 +fabric-models-v0-version=0.3.19 +fabric-networking-api-v1-version=1.2.6 +fabric-networking-v0-version=0.3.23 +fabric-object-builder-api-v1-version=4.0.15 +fabric-particles-v1-version=1.0.12 +fabric-registry-sync-v0-version=0.9.27 +fabric-renderer-api-v1-version=1.0.13 +fabric-renderer-indigo-version=0.6.15 +fabric-renderer-registries-v1-version=3.2.22 +fabric-rendering-data-attachment-v1-version=0.3.16 +fabric-rendering-fluids-v1-version=3.0.9 +fabric-rendering-v0-version=1.1.24 +fabric-rendering-v1-version=1.11.1 +fabric-resource-conditions-api-v1-version=2.1.1 +fabric-resource-loader-v0-version=0.8.0 +fabric-screen-api-v1-version=1.0.28 +fabric-screen-handler-api-v1-version=1.3.2 +fabric-sound-api-v1-version=1.0.1 +fabric-textures-v0-version=2.0.0 +fabric-transfer-api-v1-version=2.1.2 +fabric-transitive-access-wideners-v1-version=1.3.2 +fabric-convention-tags-v1-version=1.1.3 +fabric-client-tags-api-v1-version=1.0.3 diff --git a/settings.gradle b/settings.gradle index c12df6ea8..dba95e309 100644 --- a/settings.gradle +++ b/settings.gradle @@ -26,7 +26,7 @@ include 'fabric-events-interaction-v0' include 'fabric-game-rule-api-v1' include 'fabric-gametest-api-v1' include 'fabric-item-api-v1' -include 'fabric-item-groups-v0' +include 'fabric-item-group-api-v1' include 'fabric-key-binding-api-v1' include 'fabric-lifecycle-events-v1' include 'fabric-loot-api-v2' diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 3265ab51a..4dbeec178 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -19,9 +19,9 @@ "FabricMC" ], "depends": { - "fabricloader": ">=0.14.9", + "fabricloader": ">=0.14.10", "java": ">=17", - "minecraft": "~1.19.1-beta.2" + "minecraft": ">=1.19.3- <1.19.4-" }, "description": "Core API module providing key hooks and intercompatibility features." }