diff --git a/.github/workflows/1.20.3_pr.yml b/.github/workflows/1.20.6_pr.yml similarity index 92% rename from .github/workflows/1.20.3_pr.yml rename to .github/workflows/1.20.6_pr.yml index da8276b8..ef066170 100644 --- a/.github/workflows/1.20.3_pr.yml +++ b/.github/workflows/1.20.6_pr.yml @@ -1,4 +1,4 @@ -name: Build PR snapshot (1.19) +name: Build PR snapshot (1.20.6) on: pull_request: @@ -7,7 +7,7 @@ on: - '**.properties' - '**/src/**' branches: - - "1.20.4" + - "1.20.6" types: [ opened, synchronize, reopened ] jobs: validate-gradle: @@ -25,10 +25,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: - java-version: 17 + java-version: 21 distribution: 'temurin' - name: Setup Gradle and verify license using Licenser @@ -44,10 +44,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: - java-version: 17 + java-version: 21 distribution: 'temurin' - name: Setup and Build with Gradle diff --git a/.github/workflows/1.20.3_push.yml b/.github/workflows/1.20.6_push.yml similarity index 97% rename from .github/workflows/1.20.3_push.yml rename to .github/workflows/1.20.6_push.yml index 484bb639..a73db539 100644 --- a/.github/workflows/1.20.3_push.yml +++ b/.github/workflows/1.20.6_push.yml @@ -1,4 +1,4 @@ -name: Build and Release (1.19) +name: Build and Release (1.20.6) on: push: @@ -8,7 +8,7 @@ on: - '**/src/**' - '.github/**' branches: - - "1.20.5" + - "1.20.6" workflow_dispatch: inputs: norelease: diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 4e745305..3fd27aec 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -34,9 +34,9 @@ }, "icon": "icon.png", "depends": { - "minecraft": "~1.20.5-", + "minecraft": "~1.20.6-", "fabricloader": ">=0.15.6", - "fabric-api": ">=0.97.6" + "fabric-api": ">=0.98.0" }, "breaks": { "optifabric": "<1.13.0" diff --git a/gradle.properties b/gradle.properties index 75202266..94868a5e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,8 +3,8 @@ org.gradle.daemon=false platforms=fabric,neoforge -minecraft_version=1.20.5 -supported_version=1.20.5 +minecraft_version=1.20.6 +supported_version=1.20.6 artifact_type=release @@ -15,11 +15,11 @@ maven_group=dev.architectury version_suffix= fabric_loader_version=0.15.10 -fabric_api_version=0.97.6+1.20.5 +fabric_api_version=0.98.0+1.20.6 mod_menu_version=10.0.0-beta.1 forge_version=50.0.0 -neoforge_version=20.5.20-beta +neoforge_version=20.6.70-beta # Set to empty if not snapshots neoforge_pr= diff --git a/minecraftforge/build.gradle b/minecraftforge/build.gradle index 1a234bc6..e70a8bcc 100644 --- a/minecraftforge/build.gradle +++ b/minecraftforge/build.gradle @@ -129,7 +129,7 @@ unifiedPublishing { displayName = "[MinecraftForge $rootProject.supported_version] v$project.version" releaseType = "$rootProject.artifact_type" changelog = releaseChangelog() - gameVersions = ["1.20.4"] + gameVersions = ["1.20.6"] gameLoaders = ["forge"] mainPublication renameJarForPublication diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 58a23f87..4e16ac51 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -122,7 +122,7 @@ unifiedPublishing { displayName = "[NeoForge $rootProject.supported_version] v$project.version" releaseType = "$rootProject.artifact_type" changelog = releaseChangelog() - gameVersions = ["1.20.5"] + gameVersions = ["1.20.6"] gameLoaders = ["neoforge"] mainPublication renameJarForPublication diff --git a/neoforge/src/main/java/dev/architectury/core/item/forge/imitator/ArchitecturyBucketItem.java b/neoforge/src/main/java/dev/architectury/core/item/forge/imitator/ArchitecturyBucketItem.java index db8ae5f6..c521fb87 100644 --- a/neoforge/src/main/java/dev/architectury/core/item/forge/imitator/ArchitecturyBucketItem.java +++ b/neoforge/src/main/java/dev/architectury/core/item/forge/imitator/ArchitecturyBucketItem.java @@ -19,6 +19,7 @@ package dev.architectury.core.item.forge.imitator; +import dev.architectury.hooks.fluid.FluidBucketHooks; import dev.architectury.platform.hooks.EventBusesHooks; import dev.architectury.utils.ArchitecturyConstants; import net.minecraft.core.registries.BuiltInRegistries; @@ -49,6 +50,6 @@ public ArchitecturyBucketItem(Supplier fluid, Properties proper } public final Fluid getContainedFluid() { - return getFluid(); + return FluidBucketHooks.getFluid(this); } } diff --git a/neoforge/src/main/java/dev/architectury/event/forge/EventHandlerImplCommon.java b/neoforge/src/main/java/dev/architectury/event/forge/EventHandlerImplCommon.java index 43af0fad..54ab242c 100644 --- a/neoforge/src/main/java/dev/architectury/event/forge/EventHandlerImplCommon.java +++ b/neoforge/src/main/java/dev/architectury/event/forge/EventHandlerImplCommon.java @@ -46,9 +46,9 @@ import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent; import net.neoforged.neoforge.event.entity.item.ItemTossEvent; import net.neoforged.neoforge.event.entity.living.AnimalTameEvent; +import net.neoforged.neoforge.event.entity.living.FinalizeSpawnEvent; import net.neoforged.neoforge.event.entity.living.LivingAttackEvent; import net.neoforged.neoforge.event.entity.living.LivingDeathEvent; -import net.neoforged.neoforge.event.entity.living.MobSpawnEvent; import net.neoforged.neoforge.event.entity.player.*; import net.neoforged.neoforge.event.entity.player.PlayerEvent.*; import net.neoforged.neoforge.event.level.BlockEvent.BreakEvent; @@ -268,8 +268,8 @@ public static void event(FillBucketEvent event) { // } @SubscribeEvent(priority = EventPriority.HIGH) - public static void eventLivingSpawnEvent(MobSpawnEvent.FinalizeSpawn event) { - EventResult result = EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(event.getEntity(), event.getLevel(), event.getX(), event.getY(), event.getZ(), event.getSpawnType(), event.getSpawner()); + public static void eventLivingSpawnEvent(FinalizeSpawnEvent event) { + EventResult result = EntityEvent.LIVING_CHECK_SPAWN.invoker().canSpawn(event.getEntity(), event.getLevel(), event.getX(), event.getY(), event.getZ(), event.getSpawnType(), null);//TODO FIX: , event.getSpawner()); if (result.interruptsFurtherEvaluation()) { if (!result.isEmpty()) { event.setSpawnCancelled(result.value()); diff --git a/neoforge/src/main/java/dev/architectury/hooks/fluid/forge/FluidBucketHooksImpl.java b/neoforge/src/main/java/dev/architectury/hooks/fluid/forge/FluidBucketHooksImpl.java index b4eb4d3f..316b6c99 100644 --- a/neoforge/src/main/java/dev/architectury/hooks/fluid/forge/FluidBucketHooksImpl.java +++ b/neoforge/src/main/java/dev/architectury/hooks/fluid/forge/FluidBucketHooksImpl.java @@ -19,11 +19,12 @@ package dev.architectury.hooks.fluid.forge; +import dev.architectury.mixin.forge.neoforge.BucketItemAccessor; import net.minecraft.world.item.BucketItem; import net.minecraft.world.level.material.Fluid; public class FluidBucketHooksImpl { public static Fluid getFluid(BucketItem item) { - return item.getFluid(); + return ((BucketItemAccessor) item).getContent(); } } diff --git a/neoforge/src/main/java/dev/architectury/mixin/forge/neoforge/BucketItemAccessor.java b/neoforge/src/main/java/dev/architectury/mixin/forge/neoforge/BucketItemAccessor.java new file mode 100644 index 00000000..a075aee1 --- /dev/null +++ b/neoforge/src/main/java/dev/architectury/mixin/forge/neoforge/BucketItemAccessor.java @@ -0,0 +1,31 @@ +/* + * This file is part of architectury. + * Copyright (C) 2020, 2021, 2022 architectury + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package dev.architectury.mixin.forge.neoforge; + +import net.minecraft.world.item.BucketItem; +import net.minecraft.world.level.material.Fluid; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(BucketItem.class) +public interface BucketItemAccessor { + @Accessor("content") + Fluid getContent(); +} diff --git a/neoforge/src/main/java/dev/architectury/registry/forge/CreativeTabRegistryImpl.java b/neoforge/src/main/java/dev/architectury/registry/forge/CreativeTabRegistryImpl.java index 87c8cc1d..ac9e492e 100644 --- a/neoforge/src/main/java/dev/architectury/registry/forge/CreativeTabRegistryImpl.java +++ b/neoforge/src/main/java/dev/architectury/registry/forge/CreativeTabRegistryImpl.java @@ -176,6 +176,12 @@ public void acceptAfter(ItemStack after, ItemStack stack, CreativeModeTab.TabVis if (after.isEmpty()) { entries.put(stack, visibility); } else { + for (Map.Entry entry : entries) { + if (ItemStack.isSameItemSameComponents(entry.getKey(), after)) { + after = entry.getKey(); + break; + } + } entries.putAfter(after, stack, visibility); } } @@ -185,6 +191,12 @@ public void acceptBefore(ItemStack before, ItemStack stack, CreativeModeTab.TabV if (before.isEmpty()) { entries.put(stack, visibility); } else { + for (Map.Entry entry : entries) { + if (ItemStack.isSameItemSameComponents(entry.getKey(), before)) { + before = entry.getKey(); + break; + } + } entries.putBefore(before, stack, visibility); } } diff --git a/neoforge/src/main/java/dev/architectury/registry/menu/forge/MenuRegistryImpl.java b/neoforge/src/main/java/dev/architectury/registry/menu/forge/MenuRegistryImpl.java index abc395d2..b51765a0 100644 --- a/neoforge/src/main/java/dev/architectury/registry/menu/forge/MenuRegistryImpl.java +++ b/neoforge/src/main/java/dev/architectury/registry/menu/forge/MenuRegistryImpl.java @@ -19,10 +19,12 @@ package dev.architectury.registry.menu.forge; +import dev.architectury.platform.hooks.EventBusesHooks; import dev.architectury.registry.menu.ExtendedMenuProvider; import dev.architectury.registry.menu.MenuRegistry.ExtendedMenuTypeFactory; import dev.architectury.registry.menu.MenuRegistry.ScreenFactory; import dev.architectury.registry.menu.MenuRegistry.SimpleMenuTypeFactory; +import dev.architectury.utils.ArchitecturyConstants; import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.MenuAccess; @@ -32,6 +34,8 @@ import net.minecraft.world.inventory.MenuType; import net.neoforged.api.distmarker.Dist; import net.neoforged.api.distmarker.OnlyIn; +import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent; +import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.common.extensions.IMenuTypeExtension; public class MenuRegistryImpl { @@ -48,8 +52,11 @@ public static MenuType ofExtended(ExtendedM return IMenuTypeExtension.create(factory::create); } + @SuppressWarnings("CodeBlock2Expr") // It's neater this way @OnlyIn(Dist.CLIENT) public static > void registerScreenFactory(MenuType type, ScreenFactory factory) { - MenuScreens.register(type, factory::create); + EventBusesHooks.whenAvailable(ArchitecturyConstants.MOD_ID, bus -> { + bus.addListener(RegisterMenuScreensEvent.class, event -> event.register(type, factory::create)); + }); } } diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index c56aadcd..1bbf3dc1 100644 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -17,14 +17,14 @@ license = "LGPL-3" [[dependencies.architectury]] modId = "minecraft" type = "required" -versionRange = "[1.20.5,)" +versionRange = "[1.20.6,)" ordering = "NONE" side = "BOTH" [[dependencies.architectury]] modId = "neoforge" type = "required" -versionRange = "[20.5.0-beta,)" +versionRange = "[20.6.70-beta,)" ordering = "NONE" side = "BOTH" diff --git a/neoforge/src/main/resources/architectury.mixins.json b/neoforge/src/main/resources/architectury.mixins.json index 66e0d7b0..8ec3b2ed 100644 --- a/neoforge/src/main/resources/architectury.mixins.json +++ b/neoforge/src/main/resources/architectury.mixins.json @@ -10,6 +10,7 @@ "MixinMinecraft" ], "mixins": [ + "neoforge.BucketItemAccessor", "neoforge.LiquidBlockAccessor", "neoforge.MixinChunkSerializer", "MixinFallingBlockEntity", diff --git a/testmod-common/src/main/java/dev/architectury/test/TestMod.java b/testmod-common/src/main/java/dev/architectury/test/TestMod.java index 9fac583c..0581cbc4 100644 --- a/testmod-common/src/main/java/dev/architectury/test/TestMod.java +++ b/testmod-common/src/main/java/dev/architectury/test/TestMod.java @@ -22,6 +22,7 @@ import com.mojang.brigadier.arguments.StringArgumentType; import dev.architectury.event.events.client.ClientCommandRegistrationEvent; import dev.architectury.event.events.client.ClientLifecycleEvent; +import dev.architectury.registry.CreativeTabRegistry; import dev.architectury.registry.client.gui.ClientTooltipComponentRegistry; import dev.architectury.registry.client.level.entity.EntityRendererRegistry; import dev.architectury.test.debug.ConsoleMessageSink; @@ -44,6 +45,17 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.renderer.entity.CowRenderer; +import net.minecraft.core.component.DataComponents; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.item.CreativeModeTabs; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.item.enchantment.ItemEnchantments; +import net.minecraft.world.level.block.Blocks; + +import java.util.Collections; +import java.util.List; public class TestMod { public static final MessageSink SINK = EnvExecutor.getEnvSpecific(() -> ClientOverlayMessageSink::new, () -> ConsoleMessageSink::new); @@ -61,6 +73,14 @@ public static void initialize() { TestLoot.init(); TestWorldGeneration.initialize(); EnvExecutor.runInEnv(Env.CLIENT, () -> TestMod.Client::initializeClient); + CreativeTabRegistry.modifyBuiltin(BuiltInRegistries.CREATIVE_MODE_TAB.get(CreativeModeTabs.BUILDING_BLOCKS), (flags, output, canUseGameMasterBlocks) -> { + ItemStack sword = Items.DIAMOND_SWORD.getDefaultInstance(); + ItemEnchantments.Mutable mutable = new ItemEnchantments.Mutable(ItemEnchantments.EMPTY); + mutable.set(Enchantments.SHARPNESS, 10); + sword.set(DataComponents.ENCHANTMENTS, mutable.toImmutable()); + output.acceptBefore(new ItemStack(Items.OAK_WOOD), sword); + output.acceptAfter(Blocks.STRIPPED_OAK_LOG, Items.BEDROCK); + }); } @Environment(EnvType.CLIENT)