From 289ed46f4917bb45695615ad2ec42fcfd70a4a3c Mon Sep 17 00:00:00 2001 From: Jab125 <67534807+Jab125@users.noreply.github.com> Date: Fri, 14 Jun 2024 03:57:55 +1000 Subject: [PATCH] Port to 1.21 (#511) * 1.21-pre1 * progress * fix MixinGameRenderer * update the access widener * pass removal reason in the player respawn event * Update MixinGameRenderer.java * fix more mixins * fix more 1.21 stuff * Update TestRegistries.java * remove enchantments (it's data driven) * rename 1.20.6 files to 1.21 * update to 1.21-pre4 * lol * fix neoforge * Finish port to 1.21 --------- Co-authored-by: shedaniel --- .../workflows/{1.20.6_pr.yml => 1.21_pr.yml} | 2 +- .../{1.20.6_push.yml => 1.21_push.yml} | 2 +- .../core/item/ArchitecturyRecordItem.java | 46 ---------------- .../event/events/client/ClientGuiEvent.java | 7 +-- .../event/events/common/PlayerEvent.java | 4 +- .../networking/NetworkChannel.java | 2 +- .../networking/NetworkManager.java | 3 +- .../networking/SpawnEntityPacket.java | 21 +++++--- .../simple/SimpleNetworkManager.java | 4 +- .../registry/registries/DeferredRegister.java | 2 +- .../main/resources/architectury.accessWidener | 5 -- .../hooks/fabric/DyeColorHooksImpl.java | 3 +- .../mixin/fabric/MixinChunkSerializer.java | 3 +- .../mixin/fabric/MixinLivingEntity.java | 2 +- .../mixin/fabric/MixinPlayerList.java | 5 +- .../fabric/client/MixinEffectInstance.java | 16 +++--- .../fabric/client/MixinGameRenderer.java | 16 +++--- .../fabric/client/MixinKeyboardHandler.java | 2 +- .../networking/fabric/NetworkManagerImpl.java | 5 +- .../fabric/ReloadListenerRegistryImpl.java | 2 +- .../biome/fabric/BiomeModificationsImpl.java | 2 +- fabric/src/main/resources/fabric.mod.json | 4 +- gradle.properties | 12 ++--- neoforge/build.gradle | 2 +- .../event/forge/EventHandlerImplClient.java | 8 +-- .../event/forge/EventHandlerImplCommon.java | 14 +---- .../hooks/forge/DyeColorHooksImpl.java | 3 +- .../mixin/forge/MixinInventory.java | 54 +++++++++++++++++++ .../mixin/forge/MixinItemExtension.java | 7 --- .../forge/neoforge/MixinChunkSerializer.java | 3 +- .../networking/forge/NetworkManagerImpl.java | 5 +- .../biome/forge/BiomeModificationsImpl.java | 2 +- .../resources/META-INF/neoforge.mods.toml | 4 +- .../main/resources/architectury.mixins.json | 1 + .../java/dev/architectury/test/TestMod.java | 5 +- .../client/ClientOverlayMessageSink.java | 7 +-- .../architectury/test/entity/TestEntity.java | 7 +-- .../architectury/test/events/DebugEvents.java | 2 +- .../test/networking/TestModNet.java | 8 +-- .../test/registry/TestRegistries.java | 10 ++-- .../dev/architectury/test/tags/TestTags.java | 4 +- .../test/worldgen/TestWorldGeneration.java | 2 +- 42 files changed, 162 insertions(+), 156 deletions(-) rename .github/workflows/{1.20.6_pr.yml => 1.21_pr.yml} (99%) rename .github/workflows/{1.20.6_push.yml => 1.21_push.yml} (99%) delete mode 100644 common/src/main/java/dev/architectury/core/item/ArchitecturyRecordItem.java create mode 100644 neoforge/src/main/java/dev/architectury/mixin/forge/MixinInventory.java diff --git a/.github/workflows/1.20.6_pr.yml b/.github/workflows/1.21_pr.yml similarity index 99% rename from .github/workflows/1.20.6_pr.yml rename to .github/workflows/1.21_pr.yml index ef0661707..763993ef3 100644 --- a/.github/workflows/1.20.6_pr.yml +++ b/.github/workflows/1.21_pr.yml @@ -7,7 +7,7 @@ on: - '**.properties' - '**/src/**' branches: - - "1.20.6" + - "1.21" types: [ opened, synchronize, reopened ] jobs: validate-gradle: diff --git a/.github/workflows/1.20.6_push.yml b/.github/workflows/1.21_push.yml similarity index 99% rename from .github/workflows/1.20.6_push.yml rename to .github/workflows/1.21_push.yml index a73db539d..cbdb1f78f 100644 --- a/.github/workflows/1.20.6_push.yml +++ b/.github/workflows/1.21_push.yml @@ -8,7 +8,7 @@ on: - '**/src/**' - '.github/**' branches: - - "1.20.6" + - "1.21" workflow_dispatch: inputs: norelease: diff --git a/common/src/main/java/dev/architectury/core/item/ArchitecturyRecordItem.java b/common/src/main/java/dev/architectury/core/item/ArchitecturyRecordItem.java deleted file mode 100644 index cdb7840ac..000000000 --- a/common/src/main/java/dev/architectury/core/item/ArchitecturyRecordItem.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.core.item; - -import dev.architectury.registry.registries.RegistrySupplier; -import net.minecraft.sounds.SoundEvent; -import net.minecraft.world.item.RecordItem; - -public class ArchitecturyRecordItem extends RecordItem { - private final RegistrySupplier sound; - - public ArchitecturyRecordItem(int analogOutput, RegistrySupplier sound, Properties properties, int lengthInSeconds) { - super(analogOutput, sound.orElse(null), properties, lengthInSeconds); - this.sound = sound; - - if (!sound.isPresent()) { - RecordItem.BY_NAME.remove(null); - - sound.listen(soundEvent -> { - RecordItem.BY_NAME.put(soundEvent, this); - }); - } - } - - @Override - public SoundEvent getSound() { - return sound.get(); - } -} diff --git a/common/src/main/java/dev/architectury/event/events/client/ClientGuiEvent.java b/common/src/main/java/dev/architectury/event/events/client/ClientGuiEvent.java index 98a5bdd26..9ed252510 100644 --- a/common/src/main/java/dev/architectury/event/events/client/ClientGuiEvent.java +++ b/common/src/main/java/dev/architectury/event/events/client/ClientGuiEvent.java @@ -26,6 +26,7 @@ import dev.architectury.hooks.client.screen.ScreenAccess; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.client.DeltaTracker; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; @@ -81,7 +82,7 @@ interface RenderHud { * @param graphics The graphics context. * @param tickDelta The tick delta. */ - void renderHud(GuiGraphics graphics, float tickDelta); + void renderHud(GuiGraphics graphics, DeltaTracker deltaTracker); } @Environment(EnvType.CLIENT) @@ -136,7 +137,7 @@ interface ScreenRenderPre { * @return A {@link EventResult} determining the outcome of the event, * the vanilla render may be cancelled by the result. */ - EventResult render(Screen screen, GuiGraphics graphics, int mouseX, int mouseY, float delta); + EventResult render(Screen screen, GuiGraphics graphics, int mouseX, int mouseY, DeltaTracker delta); } @Environment(EnvType.CLIENT) @@ -151,7 +152,7 @@ interface ScreenRenderPost { * @param mouseY The scaled y-coordinate of the mouse cursor. * @param delta The current tick delta. */ - void render(Screen screen, GuiGraphics graphics, int mouseX, int mouseY, float delta); + void render(Screen screen, GuiGraphics graphics, int mouseX, int mouseY, DeltaTracker delta); } @Environment(EnvType.CLIENT) diff --git a/common/src/main/java/dev/architectury/event/events/common/PlayerEvent.java b/common/src/main/java/dev/architectury/event/events/common/PlayerEvent.java index 60e34dd7d..0734d1881 100644 --- a/common/src/main/java/dev/architectury/event/events/common/PlayerEvent.java +++ b/common/src/main/java/dev/architectury/event/events/common/PlayerEvent.java @@ -48,7 +48,7 @@ public interface PlayerEvent { */ Event PLAYER_QUIT = EventFactory.createLoop(); /** - * @see PlayerRespawn#respawn(ServerPlayer, boolean) + * @see PlayerRespawn#respawn(ServerPlayer, boolean, net.minecraft.world.entity.Entity.RemovalReason) */ Event PLAYER_RESPAWN = EventFactory.createLoop(); /** @@ -129,7 +129,7 @@ interface PlayerRespawn { * @param newPlayer The respawned player. * @param conqueredEnd Whether the player has conquered the end. This is true when the player joined the end and now is leaving it. {@link ServerPlayer#wonGame} */ - void respawn(ServerPlayer newPlayer, boolean conqueredEnd); + void respawn(ServerPlayer newPlayer, boolean conqueredEnd, Entity.RemovalReason removalReason); } interface PlayerClone { diff --git a/common/src/main/java/dev/architectury/networking/NetworkChannel.java b/common/src/main/java/dev/architectury/networking/NetworkChannel.java index cb4ead8fd..fb25160b1 100644 --- a/common/src/main/java/dev/architectury/networking/NetworkChannel.java +++ b/common/src/main/java/dev/architectury/networking/NetworkChannel.java @@ -63,7 +63,7 @@ public static NetworkChannel create(ResourceLocation id) { public void register(Class type, BiConsumer encoder, Function decoder, BiConsumer> messageConsumer) { // TODO: this is pretty wasteful; add a way to specify custom or numeric ids var s = UUID.nameUUIDFromBytes(type.getName().getBytes(StandardCharsets.UTF_8)).toString().replace("-", ""); - var info = new MessageInfo(new ResourceLocation(id + "/" + s), encoder, decoder, messageConsumer); + var info = new MessageInfo(ResourceLocation.parse(id + "/" + s), encoder, decoder, messageConsumer); encoders.put(type, info); NetworkManager.NetworkReceiver receiver = (buf, context) -> { info.messageConsumer.accept(info.decoder.apply(buf), () -> context); diff --git a/common/src/main/java/dev/architectury/networking/NetworkManager.java b/common/src/main/java/dev/architectury/networking/NetworkManager.java index db4b7b43a..64ec57c0c 100644 --- a/common/src/main/java/dev/architectury/networking/NetworkManager.java +++ b/common/src/main/java/dev/architectury/networking/NetworkManager.java @@ -37,6 +37,7 @@ import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerEntity; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; @@ -202,7 +203,7 @@ public static boolean canPlayerReceive(ServerPlayer player, CustomPacketPayload. * @see Entity#getAddEntityPacket() */ @ExpectPlatform - public static Packet createAddEntityPacket(Entity entity) { + public static Packet createAddEntityPacket(Entity entity, ServerEntity serverEntity) { throw new AssertionError(); } diff --git a/common/src/main/java/dev/architectury/networking/SpawnEntityPacket.java b/common/src/main/java/dev/architectury/networking/SpawnEntityPacket.java index bc517fe40..f1c2b8f26 100644 --- a/common/src/main/java/dev/architectury/networking/SpawnEntityPacket.java +++ b/common/src/main/java/dev/architectury/networking/SpawnEntityPacket.java @@ -25,6 +25,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; +import net.minecraft.core.BlockPos; import net.minecraft.core.registries.Registries; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; @@ -34,6 +35,7 @@ import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerEntity; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; @@ -43,15 +45,15 @@ * @see net.minecraft.network.protocol.game.ClientboundAddEntityPacket */ public class SpawnEntityPacket { - private static final ResourceLocation PACKET_ID = new ResourceLocation("architectury", "spawn_entity_packet"); + private static final ResourceLocation PACKET_ID = ResourceLocation.fromNamespaceAndPath("architectury", "spawn_entity_packet"); private static final CustomPacketPayload.Type PACKET_TYPE = new CustomPacketPayload.Type<>(PACKET_ID); private static final StreamCodec PACKET_CODEC = CustomPacketPayload.codec(PacketPayload::write, PacketPayload::new); - public static Packet create(Entity entity) { + public static Packet create(Entity entity, ServerEntity serverEntity) { if (entity.level().isClientSide()) { throw new IllegalStateException("SpawnPacketUtil.create called on the logical client!"); } - return (Packet) NetworkManager.toPacket(NetworkManager.s2c(), new PacketPayload(entity), entity.registryAccess()); + return (Packet) NetworkManager.toPacket(NetworkManager.s2c(), new PacketPayload(entity, serverEntity), entity.registryAccess()); } public static void register() { @@ -106,9 +108,16 @@ public PacketPayload(RegistryFriendlyByteBuf buf) { buf.readByteArray()); } - public PacketPayload(Entity entity) { - this(entity.getType(), entity.getUUID(), entity.getId(), entity.getX(), - entity.getY(), entity.getZ(), entity.getXRot(), entity.getYRot(), entity.getYHeadRot(), + public PacketPayload(Entity entity, ServerEntity serverEntity) { + this(entity.getType(), entity.getUUID(), entity.getId(), serverEntity.getPositionBase().x(), + serverEntity.getPositionBase().y(), serverEntity.getPositionBase().z(), serverEntity.getLastSentXRot(), + serverEntity.getLastSentYRot(), serverEntity.getLastSentYHeadRot(), serverEntity.getLastSentMovement().x, + serverEntity.getLastSentMovement().y, serverEntity.getLastSentMovement().z, saveExtra(entity)); + } + + public PacketPayload(Entity entity, BlockPos pos) { + this(entity.getType(), entity.getUUID(), entity.getId(), pos.getX(), + pos.getY(), pos.getZ(), entity.getXRot(), entity.getYRot(), entity.getYHeadRot(), entity.getDeltaMovement().x, entity.getDeltaMovement().y, entity.getDeltaMovement().z, saveExtra(entity)); } diff --git a/common/src/main/java/dev/architectury/networking/simple/SimpleNetworkManager.java b/common/src/main/java/dev/architectury/networking/simple/SimpleNetworkManager.java index de2d9cff1..eb1845324 100644 --- a/common/src/main/java/dev/architectury/networking/simple/SimpleNetworkManager.java +++ b/common/src/main/java/dev/architectury/networking/simple/SimpleNetworkManager.java @@ -75,7 +75,7 @@ public MessageType registerS2C(String id, MessageDecoder decoder */ @ApiStatus.Experimental public MessageType registerS2C(String id, MessageDecoder decoder, List transformers) { - MessageType messageType = new MessageType(this, new ResourceLocation(namespace, id), NetworkManager.s2c()); + MessageType messageType = new MessageType(this, ResourceLocation.fromNamespaceAndPath(namespace, id), NetworkManager.s2c()); if (Platform.getEnvironment() == Env.CLIENT) { NetworkManager.NetworkReceiver receiver = decoder.createReceiver(); @@ -107,7 +107,7 @@ public MessageType registerC2S(String id, MessageDecoder decoder */ @ApiStatus.Experimental public MessageType registerC2S(String id, MessageDecoder decoder, List transformers) { - MessageType messageType = new MessageType(this, new ResourceLocation(namespace, id), NetworkManager.c2s()); + MessageType messageType = new MessageType(this, ResourceLocation.fromNamespaceAndPath(namespace, id), NetworkManager.c2s()); NetworkManager.NetworkReceiver receiver = decoder.createReceiver(); NetworkManager.registerReceiver(NetworkManager.c2s(), messageType.getId(), transformers, receiver); return messageType; diff --git a/common/src/main/java/dev/architectury/registry/registries/DeferredRegister.java b/common/src/main/java/dev/architectury/registry/registries/DeferredRegister.java index e96e1b8ce..8c4f18b3d 100644 --- a/common/src/main/java/dev/architectury/registry/registries/DeferredRegister.java +++ b/common/src/main/java/dev/architectury/registry/registries/DeferredRegister.java @@ -55,7 +55,7 @@ public RegistrySupplier register(String id, Supplier RegistrySupplier register(ResourceLocation id, Supplier supplier) { diff --git a/common/src/main/resources/architectury.accessWidener b/common/src/main/resources/architectury.accessWidener index 7f55f29db..bd20e6a20 100644 --- a/common/src/main/resources/architectury.accessWidener +++ b/common/src/main/resources/architectury.accessWidener @@ -127,7 +127,6 @@ accessible class net/minecraft/client/resources/model/AtlasSet$AtlasEntry accessible field net/minecraft/world/item/SpawnEggItem BY_ID Ljava/util/Map; accessible field net/minecraft/world/item/SpawnEggItem defaultType Lnet/minecraft/world/entity/EntityType; mutable field net/minecraft/world/item/SpawnEggItem defaultType Lnet/minecraft/world/entity/EntityType; -accessible field net/minecraft/world/item/RecordItem BY_NAME Ljava/util/Map; accessible field net/minecraft/client/particle/ParticleEngine textureAtlas Lnet/minecraft/client/renderer/texture/TextureAtlas; accessible class net/minecraft/client/particle/ParticleEngine$MutableSpriteSet accessible field net/minecraft/client/particle/ParticleEngine$MutableSpriteSet sprites Ljava/util/List; @@ -141,7 +140,6 @@ accessible field net/minecraft/client/multiplayer/MultiPlayerGameMode connection # Constructors of non-abstract item classes transitive-accessible method net/minecraft/world/item/DiggerItem (Lnet/minecraft/world/item/Tier;Lnet/minecraft/tags/TagKey;Lnet/minecraft/world/item/Item$Properties;)V -transitive-accessible method net/minecraft/world/item/RecordItem (ILnet/minecraft/sounds/SoundEvent;Lnet/minecraft/world/item/Item$Properties;I)V # Constructors of non-abstract block classes transitive-accessible method net/minecraft/world/level/block/AttachedStemBlock (Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V @@ -253,7 +251,6 @@ transitive-accessible field net/minecraft/client/renderer/RenderStateShard TRANS transitive-accessible field net/minecraft/client/renderer/RenderStateShard NO_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_COLOR_LIGHTMAP_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; -transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_COLOR_TEX_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_TEX_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_COLOR_TEX_LIGHTMAP_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_COLOR_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; @@ -282,11 +279,9 @@ transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDE transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_LEASH_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_WATER_MASK_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_OUTLINE_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; -transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ARMOR_GLINT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ARMOR_ENTITY_GLINT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_GLINT_TRANSLUCENT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_GLINT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; -transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_GLINT_DIRECT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ENTITY_GLINT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_ENTITY_GLINT_DIRECT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_CRUMBLING_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard; diff --git a/fabric/src/main/java/dev/architectury/hooks/fabric/DyeColorHooksImpl.java b/fabric/src/main/java/dev/architectury/hooks/fabric/DyeColorHooksImpl.java index 152a75713..3fe0a0579 100644 --- a/fabric/src/main/java/dev/architectury/hooks/fabric/DyeColorHooksImpl.java +++ b/fabric/src/main/java/dev/architectury/hooks/fabric/DyeColorHooksImpl.java @@ -23,7 +23,6 @@ public class DyeColorHooksImpl { public static int getColorValue(DyeColor color) { - var colors = color.getTextureDiffuseColors(); - return ((int) (colors[0] * 255.0F + 0.5D) & 255) << 16 | ((int) (colors[1] * 255.0F + 0.5D) & 255) << 8 | (int) (colors[2] * 255.0F + 0.5D); + return color.getTextureDiffuseColor(); } } diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinChunkSerializer.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinChunkSerializer.java index 843a939f7..a4a9f17b1 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinChunkSerializer.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinChunkSerializer.java @@ -32,6 +32,7 @@ import net.minecraft.world.level.chunk.*; import net.minecraft.world.level.chunk.status.ChunkType; import net.minecraft.world.level.chunk.storage.ChunkSerializer; +import net.minecraft.world.level.chunk.storage.RegionStorageInfo; import net.minecraft.world.level.levelgen.blending.BlendingData; import net.minecraft.world.level.lighting.LevelLightEngine; import org.spongepowered.asm.mixin.Mixin; @@ -43,7 +44,7 @@ @Mixin(ChunkSerializer.class) public class MixinChunkSerializer { @Inject(method = "read", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILHARD) - private static void load(ServerLevel serverLevel, PoiManager poiManager, ChunkPos chunkPos, CompoundTag compoundTag, + private static void load(ServerLevel serverLevel, PoiManager poiManager, RegionStorageInfo regionStorageInfo, ChunkPos chunkPos, CompoundTag compoundTag, CallbackInfoReturnable cir, ChunkPos chunkPos2, UpgradeData upgradeData, boolean bl, ListTag listTag, int i, LevelChunkSection[] levelChunkSections, boolean bl2, ChunkSource chunkSource, LevelLightEngine levelLightEngine, Registry registry, diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinLivingEntity.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinLivingEntity.java index 7d31bae63..47445f227 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinLivingEntity.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinLivingEntity.java @@ -42,7 +42,7 @@ private void hurt(DamageSource damageSource, float f, CallbackInfoReturnable cir) { + private void getEquipmentSlotForItem(ItemStack stack, CallbackInfoReturnable cir) { var item = stack.getItem(); if (item instanceof ItemExtension extension) { var slot = extension.getCustomEquipmentSlot(stack); diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinPlayerList.java b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinPlayerList.java index 8ded7f764..514560b77 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/MixinPlayerList.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/MixinPlayerList.java @@ -24,6 +24,7 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.network.CommonListenerCookie; import net.minecraft.server.players.PlayerList; +import net.minecraft.world.entity.Entity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -43,7 +44,7 @@ private void remove(ServerPlayer serverPlayer, CallbackInfo ci) { } @Inject(method = "respawn", at = @At("RETURN")) - private void respawn(ServerPlayer serverPlayer, boolean bl, CallbackInfoReturnable cir) { - PlayerEvent.PLAYER_RESPAWN.invoker().respawn(cir.getReturnValue(), bl); + private void respawn(ServerPlayer serverPlayer, boolean bl, Entity.RemovalReason removalReason, CallbackInfoReturnable cir) { + PlayerEvent.PLAYER_RESPAWN.invoker().respawn(cir.getReturnValue(), bl, removalReason); } } diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinEffectInstance.java b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinEffectInstance.java index 83cdb43bd..e518a7718 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinEffectInstance.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinEffectInstance.java @@ -33,25 +33,25 @@ public class MixinEffectInstance { @Redirect( method = "", - at = @At(value = "NEW", - target = "(Ljava/lang/String;)Lnet/minecraft/resources/ResourceLocation;", + at = @At(value = "INVOKE", + target = "Lnet/minecraft/resources/ResourceLocation;withDefaultNamespace(Ljava/lang/String;)Lnet/minecraft/resources/ResourceLocation;", ordinal = 0) ) private ResourceLocation mojangPls(String _0, ResourceProvider rm, String str) { - return mojangPls(new ResourceLocation(str), ".json"); + return mojangPls(ResourceLocation.parse(str), ".json"); } @Redirect( method = "getOrCreate", - at = @At(value = "NEW", - target = "(Ljava/lang/String;)Lnet/minecraft/resources/ResourceLocation;", + at = @At(value = "INVOKE", + target = "Lnet/minecraft/resources/ResourceLocation;withDefaultNamespace(Ljava/lang/String;)Lnet/minecraft/resources/ResourceLocation;", ordinal = 0) ) private static ResourceLocation mojangPls(String _0, ResourceProvider rm, Program.Type type, String str) { - return mojangPls(new ResourceLocation(str), type.getExtension()); + return mojangPls(ResourceLocation.parse(str), type.getExtension()); } - + private static ResourceLocation mojangPls(ResourceLocation rl, String ext) { - return new ResourceLocation(rl.getNamespace(), "shaders/program/" + rl.getPath() + ext); + return ResourceLocation.fromNamespaceAndPath(rl.getNamespace(), "shaders/program/" + rl.getPath() + ext); } } diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinGameRenderer.java b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinGameRenderer.java index df7c61fc6..10c3e1f98 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinGameRenderer.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinGameRenderer.java @@ -24,6 +24,7 @@ import com.mojang.datafixers.util.Pair; import dev.architectury.event.events.client.ClientGuiEvent; import dev.architectury.event.events.client.ClientReloadShadersEvent; +import net.minecraft.client.DeltaTracker; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.GameRenderer; @@ -48,20 +49,23 @@ public abstract class MixinGameRenderer { @Final private Minecraft minecraft; - @Inject(method = "render(FJZ)V", + @Shadow + public abstract void tick(); + + @Inject(method = "render(Lnet/minecraft/client/DeltaTracker;Z)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;renderWithTooltip(Lnet/minecraft/client/gui/GuiGraphics;IIF)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILEXCEPTION, cancellable = true) - public void renderScreenPre(float tickDelta, long startTime, boolean tick, CallbackInfo ci, float speedAppliedTickDelta, boolean isGameLoadFinished, int mouseX, int mouseY, Window window, Matrix4f matrix, Matrix4fStack matrices, GuiGraphics graphics) { - if (ClientGuiEvent.RENDER_PRE.invoker().render(minecraft.screen, graphics, mouseX, mouseY, minecraft.getDeltaFrameTime()).isFalse()) { + public void renderScreenPre(DeltaTracker tickDelta, boolean tick, CallbackInfo ci, boolean isGameLoadFinished, int mouseX, int mouseY, Window window, Matrix4f matrix, Matrix4fStack matrices, GuiGraphics graphics) { + if (ClientGuiEvent.RENDER_PRE.invoker().render(minecraft.screen, graphics, mouseX, mouseY, tickDelta).isFalse()) { ci.cancel(); } } - @Inject(method = "render(FJZ)V", + @Inject(method = "render(Lnet/minecraft/client/DeltaTracker;Z)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;renderWithTooltip(Lnet/minecraft/client/gui/GuiGraphics;IIF)V", shift = At.Shift.AFTER, ordinal = 0), locals = LocalCapture.CAPTURE_FAILEXCEPTION) - public void renderScreenPost(float tickDelta, long startTime, boolean tick, CallbackInfo ci, float speedAppliedTickDelta, boolean isGameLoadFinished, int mouseX, int mouseY, Window window, Matrix4f matrix, Matrix4fStack matrices, GuiGraphics graphics) { - ClientGuiEvent.RENDER_POST.invoker().render(minecraft.screen, graphics, mouseX, mouseY, minecraft.getDeltaFrameTime()); + public void renderScreenPost(DeltaTracker tickDelta, boolean tick, CallbackInfo ci, boolean isGameLoadFinished, int mouseX, int mouseY, Window window, Matrix4f matrix, Matrix4fStack matrices, GuiGraphics graphics) { + ClientGuiEvent.RENDER_POST.invoker().render(minecraft.screen, graphics, mouseX, mouseY, tickDelta); } @Inject(method = "reloadShaders", diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinKeyboardHandler.java b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinKeyboardHandler.java index c9da08f63..c215a3ea4 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinKeyboardHandler.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinKeyboardHandler.java @@ -81,7 +81,7 @@ public void onKey(long long_1, int int_1, int int_2, int int_3, int int_4, Callb target = "Lnet/minecraft/client/gui/screens/Screen;wrapScreenError(Ljava/lang/Runnable;Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0, shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true) - public void onKeyAfter(long long_1, int int_1, int int_2, int int_3, int int_4, CallbackInfo info, boolean f3Pressed, Screen screen, boolean bls[]) { + public void onKeyAfter(long long_1, int int_1, int int_2, int int_3, int int_4, CallbackInfo info, boolean f3Pressed, Screen screen, boolean[] bls) { if (!info.isCancelled() && !bls[0]) { EventResult result; if (int_3 != 1 && int_3 != 2) { diff --git a/fabric/src/main/java/dev/architectury/networking/fabric/NetworkManagerImpl.java b/fabric/src/main/java/dev/architectury/networking/fabric/NetworkManagerImpl.java index 12ec6dbe0..c6d7ed4f0 100644 --- a/fabric/src/main/java/dev/architectury/networking/fabric/NetworkManagerImpl.java +++ b/fabric/src/main/java/dev/architectury/networking/fabric/NetworkManagerImpl.java @@ -37,6 +37,7 @@ import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerEntity; import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.thread.BlockableEventLoop; import net.minecraft.world.entity.Entity; @@ -132,7 +133,7 @@ public static boolean canPlayerReceive(ServerPlayer player, ResourceLocation id) return ServerPlayNetworking.canSend(player, id); } - public static Packet createAddEntityPacket(Entity entity) { - return SpawnEntityPacket.create(entity); + public static Packet createAddEntityPacket(Entity entity, ServerEntity serverEntity) { + return SpawnEntityPacket.create(entity, serverEntity); } } diff --git a/fabric/src/main/java/dev/architectury/registry/fabric/ReloadListenerRegistryImpl.java b/fabric/src/main/java/dev/architectury/registry/fabric/ReloadListenerRegistryImpl.java index 8db200259..e1ded51c0 100644 --- a/fabric/src/main/java/dev/architectury/registry/fabric/ReloadListenerRegistryImpl.java +++ b/fabric/src/main/java/dev/architectury/registry/fabric/ReloadListenerRegistryImpl.java @@ -41,7 +41,7 @@ public class ReloadListenerRegistryImpl { public static void register(PackType type, PreparableReloadListener listener, @Nullable ResourceLocation listenerId, Collection dependencies) { var bytes = new byte[8]; RANDOM.nextBytes(bytes); - var id = listenerId != null ? listenerId : new ResourceLocation("architectury:reload_" + StringUtils.leftPad(Math.abs(Longs.fromByteArray(bytes)) + "", 19, '0')); + var id = listenerId != null ? listenerId : ResourceLocation.parse("architectury:reload_" + StringUtils.leftPad(Math.abs(Longs.fromByteArray(bytes)) + "", 19, '0')); ResourceManagerHelper.get(type).registerReloadListener(new IdentifiableResourceReloadListener() { @Override public ResourceLocation getFabricId() { diff --git a/fabric/src/main/java/dev/architectury/registry/level/biome/fabric/BiomeModificationsImpl.java b/fabric/src/main/java/dev/architectury/registry/level/biome/fabric/BiomeModificationsImpl.java index 5dc144bb1..3065f811d 100644 --- a/fabric/src/main/java/dev/architectury/registry/level/biome/fabric/BiomeModificationsImpl.java +++ b/fabric/src/main/java/dev/architectury/registry/level/biome/fabric/BiomeModificationsImpl.java @@ -54,7 +54,7 @@ import static net.fabricmc.fabric.api.biome.v1.BiomeModificationContext.*; public class BiomeModificationsImpl { - private static final ResourceLocation FABRIC_MODIFICATION = new ResourceLocation("architectury", "fabric_modification"); + private static final ResourceLocation FABRIC_MODIFICATION = ResourceLocation.fromNamespaceAndPath("architectury", "fabric_modification"); private static final List, BiConsumer>> ADDITIONS = Lists.newArrayList(); private static final List, BiConsumer>> POST_PROCESSING = Lists.newArrayList(); private static final List, BiConsumer>> REMOVALS = Lists.newArrayList(); diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 6a935c210..c1cb45219 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.6-", + "minecraft": "~1.21-", "fabricloader": ">=0.15.11", - "fabric-api": ">=0.99.0" + "fabric-api": ">=0.100.0" }, "breaks": { "optifabric": "<1.13.0" diff --git a/gradle.properties b/gradle.properties index 57f89d40d..c598f94a1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,23 +3,23 @@ org.gradle.daemon=false platforms=fabric,neoforge -minecraft_version=1.20.6 -supported_version=1.20.6 +minecraft_version=1.21 +supported_version=1.21 artifact_type=release archives_base_name=architectury archives_base_name_snapshot=architectury-snapshot -base_version=12.1 +base_version=13.0 maven_group=dev.architectury version_suffix= fabric_loader_version=0.15.11 -fabric_api_version=0.99.0+1.20.6 +fabric_api_version=0.100.0+1.21 mod_menu_version=10.0.0-beta.1 -forge_version=50.0.31 -neoforge_version=20.6.98-beta +forge_version=51.0.0 +neoforge_version=21.0.0-beta # Set to empty if not snapshots neoforge_pr= diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 4e16ac51d..1c4223e94 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.6"] + gameVersions = ["1.21"] gameLoaders = ["neoforge"] mainPublication renameJarForPublication diff --git a/neoforge/src/main/java/dev/architectury/event/forge/EventHandlerImplClient.java b/neoforge/src/main/java/dev/architectury/event/forge/EventHandlerImplClient.java index febf20e9c..ccfdbcc0e 100644 --- a/neoforge/src/main/java/dev/architectury/event/forge/EventHandlerImplClient.java +++ b/neoforge/src/main/java/dev/architectury/event/forge/EventHandlerImplClient.java @@ -141,24 +141,24 @@ else if (result.object() != null) @SubscribeEvent(priority = EventPriority.HIGH) public static void eventDrawScreenEvent(ScreenEvent.Render.Pre event) { - if (ClientGuiEvent.RENDER_PRE.invoker().render(event.getScreen(), event.getGuiGraphics(), event.getMouseX(), event.getMouseY(), event.getPartialTick()).isFalse()) { + if (ClientGuiEvent.RENDER_PRE.invoker().render(event.getScreen(), event.getGuiGraphics(), event.getMouseX(), event.getMouseY(), Minecraft.getInstance().getTimer()).isFalse()) { event.setCanceled(true); } } @SubscribeEvent(priority = EventPriority.HIGH) public static void eventDrawScreenEvent(ScreenEvent.Render.Post event) { - ClientGuiEvent.RENDER_POST.invoker().render(event.getScreen(), event.getGuiGraphics(), event.getMouseX(), event.getMouseY(), event.getPartialTick()); + ClientGuiEvent.RENDER_POST.invoker().render(event.getScreen(), event.getGuiGraphics(), event.getMouseX(), event.getMouseY(), Minecraft.getInstance().getTimer()); } @SubscribeEvent(priority = EventPriority.HIGH) public static void eventContainerScreenEvent(ContainerScreenEvent.Render.Background event) { - ClientGuiEvent.RENDER_CONTAINER_BACKGROUND.invoker().render(event.getContainerScreen(), event.getGuiGraphics(), event.getMouseX(), event.getMouseY(), Minecraft.getInstance().getDeltaFrameTime()); + ClientGuiEvent.RENDER_CONTAINER_BACKGROUND.invoker().render(event.getContainerScreen(), event.getGuiGraphics(), event.getMouseX(), event.getMouseY(), Minecraft.getInstance().getTimer().getRealtimeDeltaTicks()); } @SubscribeEvent(priority = EventPriority.HIGH) public static void eventContainerScreenEvent(ContainerScreenEvent.Render.Foreground event) { - ClientGuiEvent.RENDER_CONTAINER_FOREGROUND.invoker().render(event.getContainerScreen(), event.getGuiGraphics(), event.getMouseX(), event.getMouseY(), Minecraft.getInstance().getDeltaFrameTime()); + ClientGuiEvent.RENDER_CONTAINER_FOREGROUND.invoker().render(event.getContainerScreen(), event.getGuiGraphics(), event.getMouseX(), event.getMouseY(), Minecraft.getInstance().getTimer().getRealtimeDeltaTicks()); } @SubscribeEvent(priority = EventPriority.HIGH) 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 524f7f826..c2a4ec49c 100644 --- a/neoforge/src/main/java/dev/architectury/event/forge/EventHandlerImplCommon.java +++ b/neoforge/src/main/java/dev/architectury/event/forge/EventHandlerImplCommon.java @@ -124,7 +124,7 @@ public static void event(PlayerLoggedOutEvent event) { @SubscribeEvent(priority = EventPriority.HIGH) public static void event(PlayerRespawnEvent event) { - PlayerEvent.PLAYER_RESPAWN.invoker().respawn((ServerPlayer) event.getEntity(), event.isEndConquered()); + PlayerEvent.PLAYER_RESPAWN.invoker().respawn((ServerPlayer) event.getEntity(), event.isEndConquered(), event.getEntity().getRemovalReason()); } @SubscribeEvent(priority = EventPriority.HIGH) @@ -355,17 +355,7 @@ public static void eventPlayerInteractEvent(PlayerInteractEvent.LeftClickBlock e @SubscribeEvent(priority = EventPriority.HIGH) public static void event(BreakEvent event) { if (event.getPlayer() instanceof ServerPlayer && event.getLevel() instanceof Level) { - EventResult result = BlockEvent.BREAK.invoker().breakBlock((Level) event.getLevel(), event.getPos(), event.getState(), (ServerPlayer) event.getPlayer(), new IntValue() { - @Override - public int getAsInt() { - return event.getExpToDrop(); - } - - @Override - public void accept(int value) { - event.setExpToDrop(value); - } - }); + EventResult result = BlockEvent.BREAK.invoker().breakBlock((Level) event.getLevel(), event.getPos(), event.getState(), (ServerPlayer) event.getPlayer(), null); if (result.isFalse()) { event.setCanceled(true); } diff --git a/neoforge/src/main/java/dev/architectury/hooks/forge/DyeColorHooksImpl.java b/neoforge/src/main/java/dev/architectury/hooks/forge/DyeColorHooksImpl.java index c94a13be9..4babfd113 100644 --- a/neoforge/src/main/java/dev/architectury/hooks/forge/DyeColorHooksImpl.java +++ b/neoforge/src/main/java/dev/architectury/hooks/forge/DyeColorHooksImpl.java @@ -23,7 +23,6 @@ public class DyeColorHooksImpl { public static int getColorValue(DyeColor dyeColor) { - var colors = dyeColor.getTextureDiffuseColors(); - return ((int) (colors[0] * 255.0F + 0.5D) & 255) << 16 | ((int) (colors[1] * 255.0F + 0.5D) & 255) << 8 | (int) (colors[2] * 255.0F + 0.5D); + return dyeColor.getTextureDiffuseColor(); } } diff --git a/neoforge/src/main/java/dev/architectury/mixin/forge/MixinInventory.java b/neoforge/src/main/java/dev/architectury/mixin/forge/MixinInventory.java new file mode 100644 index 000000000..44bb8046f --- /dev/null +++ b/neoforge/src/main/java/dev/architectury/mixin/forge/MixinInventory.java @@ -0,0 +1,54 @@ +/* + * 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; + +import dev.architectury.extensions.ItemExtension; +import net.minecraft.core.NonNullList; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +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; + +@Mixin(Inventory.class) +public class MixinInventory { + @Shadow + @Final + public NonNullList armor; + + @Shadow + @Final + public Player player; + + @Inject(method = "tick", at = @At("RETURN")) + private void updateItems(CallbackInfo ci) { + for (var stack : armor) { + Item item = stack.getItem(); + if (item instanceof ItemExtension extension) { + extension.tickArmor(stack, player); + } + } + } +} diff --git a/neoforge/src/main/java/dev/architectury/mixin/forge/MixinItemExtension.java b/neoforge/src/main/java/dev/architectury/mixin/forge/MixinItemExtension.java index 687858791..26f4e2b0a 100644 --- a/neoforge/src/main/java/dev/architectury/mixin/forge/MixinItemExtension.java +++ b/neoforge/src/main/java/dev/architectury/mixin/forge/MixinItemExtension.java @@ -21,20 +21,13 @@ import dev.architectury.extensions.ItemExtension; import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; import net.neoforged.neoforge.common.extensions.IItemExtension; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; @Mixin(ItemExtension.class) public interface MixinItemExtension extends IItemExtension { - @Override - default void onArmorTick(ItemStack stack, Level world, Player player) { - ((ItemExtension) this).tickArmor(stack, player); - } - @Nullable @Override default EquipmentSlot getEquipmentSlot(ItemStack stack) { diff --git a/neoforge/src/main/java/dev/architectury/mixin/forge/neoforge/MixinChunkSerializer.java b/neoforge/src/main/java/dev/architectury/mixin/forge/neoforge/MixinChunkSerializer.java index 741ae0fb7..7fca8eef1 100644 --- a/neoforge/src/main/java/dev/architectury/mixin/forge/neoforge/MixinChunkSerializer.java +++ b/neoforge/src/main/java/dev/architectury/mixin/forge/neoforge/MixinChunkSerializer.java @@ -26,6 +26,7 @@ import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.chunk.ProtoChunk; import net.minecraft.world.level.chunk.storage.ChunkSerializer; +import net.minecraft.world.level.chunk.storage.RegionStorageInfo; import net.neoforged.bus.api.Event; import net.neoforged.neoforge.event.level.ChunkDataEvent; import org.spongepowered.asm.mixin.Mixin; @@ -43,7 +44,7 @@ public class MixinChunkSerializer { private static ThreadLocal> level = new ThreadLocal<>(); @Inject(method = "read", at = @At("HEAD")) - private static void read(ServerLevel worldIn, PoiManager arg2, ChunkPos arg3, CompoundTag arg4, CallbackInfoReturnable cir) { + private static void read(ServerLevel worldIn, PoiManager arg2, RegionStorageInfo arg3, ChunkPos arg4, CompoundTag arg5, CallbackInfoReturnable cir) { level.set(new WeakReference<>(worldIn)); } diff --git a/neoforge/src/main/java/dev/architectury/networking/forge/NetworkManagerImpl.java b/neoforge/src/main/java/dev/architectury/networking/forge/NetworkManagerImpl.java index 3871976da..3335481c3 100644 --- a/neoforge/src/main/java/dev/architectury/networking/forge/NetworkManagerImpl.java +++ b/neoforge/src/main/java/dev/architectury/networking/forge/NetworkManagerImpl.java @@ -39,6 +39,7 @@ import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerEntity; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; @@ -130,8 +131,8 @@ public static boolean canPlayerReceive(ServerPlayer player, ResourceLocation id) return player.connection.hasChannel(id); } - public static Packet createAddEntityPacket(Entity entity) { - return SpawnEntityPacket.create(entity); + public static Packet createAddEntityPacket(Entity entity, ServerEntity serverEntity) { + return SpawnEntityPacket.create(entity, serverEntity); } @OnlyIn(Dist.CLIENT) diff --git a/neoforge/src/main/java/dev/architectury/registry/level/biome/forge/BiomeModificationsImpl.java b/neoforge/src/main/java/dev/architectury/registry/level/biome/forge/BiomeModificationsImpl.java index f0444d6f1..79ba63e9d 100644 --- a/neoforge/src/main/java/dev/architectury/registry/level/biome/forge/BiomeModificationsImpl.java +++ b/neoforge/src/main/java/dev/architectury/registry/level/biome/forge/BiomeModificationsImpl.java @@ -67,7 +67,7 @@ public static void init() { EventBusesHooks.whenAvailable(ArchitecturyConstants.MOD_ID, bus -> { bus.addListener(event -> { event.register(NeoForgeRegistries.Keys.BIOME_MODIFIER_SERIALIZERS, registry -> { - registry.register(new ResourceLocation(ArchitecturyConstants.MOD_ID, "none_biome_mod_codec"), + registry.register(ResourceLocation.fromNamespaceAndPath(ArchitecturyConstants.MOD_ID, "none_biome_mod_codec"), noneBiomeModCodec = MapCodec.unit(BiomeModifierImpl.INSTANCE)); }); }); diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index 93221e3d3..44b8712d8 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.6,)" +versionRange = "[1.21,)" ordering = "NONE" side = "BOTH" [[dependencies.architectury]] modId = "neoforge" type = "required" -versionRange = "[20.6.98-beta,)" +versionRange = "[20.1.0-beta,)" ordering = "NONE" side = "BOTH" diff --git a/neoforge/src/main/resources/architectury.mixins.json b/neoforge/src/main/resources/architectury.mixins.json index 022ae408b..bbff1de23 100644 --- a/neoforge/src/main/resources/architectury.mixins.json +++ b/neoforge/src/main/resources/architectury.mixins.json @@ -15,6 +15,7 @@ "neoforge.LiquidBlockAccessor", "neoforge.MixinChunkSerializer", "MixinFallingBlockEntity", + "MixinInventory", "MixinItemExtension", "MixinLevelEvent" ], 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 0581cbc43..157778e51 100644 --- a/testmod-common/src/main/java/dev/architectury/test/TestMod.java +++ b/testmod-common/src/main/java/dev/architectury/test/TestMod.java @@ -47,6 +47,8 @@ import net.minecraft.client.renderer.entity.CowRenderer; import net.minecraft.core.component.DataComponents; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.registries.VanillaRegistries; import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -75,9 +77,6 @@ public static void 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); }); diff --git a/testmod-common/src/main/java/dev/architectury/test/debug/client/ClientOverlayMessageSink.java b/testmod-common/src/main/java/dev/architectury/test/debug/client/ClientOverlayMessageSink.java index fdad66034..c76e60eab 100644 --- a/testmod-common/src/main/java/dev/architectury/test/debug/client/ClientOverlayMessageSink.java +++ b/testmod-common/src/main/java/dev/architectury/test/debug/client/ClientOverlayMessageSink.java @@ -26,6 +26,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.Util; +import net.minecraft.client.DeltaTracker; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; @@ -40,9 +41,9 @@ public class ClientOverlayMessageSink extends ConsoleMessageSink { public ClientOverlayMessageSink() { ClientGuiEvent.RENDER_POST.register((screen, graphics, mouseX, mouseY, delta) -> render(graphics, delta)); - ClientGuiEvent.RENDER_HUD.register((graphics, tickDelta) -> { + ClientGuiEvent.RENDER_HUD.register((graphics, delta) -> { if (Minecraft.getInstance().screen == null && !Minecraft.getInstance().gui.getDebugOverlay().showDebugScreen()) { - render(graphics, tickDelta); + render(graphics, delta); } }); } @@ -53,7 +54,7 @@ public void accept(String message) { messages.add(0, new Message(Component.literal(message), Util.getMillis())); } - public void render(GuiGraphics graphics, float delta) { + public void render(GuiGraphics graphics, DeltaTracker delta) { graphics.pose().pushPose(); graphics.pose().scale(0.5f, 0.5f, 1f); var minecraft = Minecraft.getInstance(); diff --git a/testmod-common/src/main/java/dev/architectury/test/entity/TestEntity.java b/testmod-common/src/main/java/dev/architectury/test/entity/TestEntity.java index 02347b626..a123654ca 100644 --- a/testmod-common/src/main/java/dev/architectury/test/entity/TestEntity.java +++ b/testmod-common/src/main/java/dev/architectury/test/entity/TestEntity.java @@ -29,6 +29,7 @@ import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerEntity; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobCategory; @@ -46,8 +47,8 @@ public TestEntity(EntityType entityType, Level level) { } @Override - public Packet getAddEntityPacket() { - return NetworkManager.createAddEntityPacket(this); + public Packet getAddEntityPacket(ServerEntity entity) { + return NetworkManager.createAddEntityPacket(this, entity); } @Override @@ -59,7 +60,7 @@ protected void tickDeath() { compoundTag.putString("DeathCauser", player.getStringUUID()); RegistryFriendlyByteBuf buf = new RegistryFriendlyByteBuf(Unpooled.buffer(), this.registryAccess()); buf.writeNbt(compoundTag); - NetworkManager.sendToPlayer(player, new ResourceLocation("architectury_test", "sync_data"), buf); + NetworkManager.sendToPlayer(player, ResourceLocation.fromNamespaceAndPath("architectury_test", "sync_data"), buf); } } } diff --git a/testmod-common/src/main/java/dev/architectury/test/events/DebugEvents.java b/testmod-common/src/main/java/dev/architectury/test/events/DebugEvents.java index 5423bf98a..53aedd2c7 100644 --- a/testmod-common/src/main/java/dev/architectury/test/events/DebugEvents.java +++ b/testmod-common/src/main/java/dev/architectury/test/events/DebugEvents.java @@ -189,7 +189,7 @@ public static void debugEvents() { PlayerEvent.PLAYER_QUIT.register(player -> { TestMod.SINK.accept(player.getScoreboardName() + " quit" + logSide(player.level())); }); - PlayerEvent.PLAYER_RESPAWN.register((player, conqueredEnd) -> { + PlayerEvent.PLAYER_RESPAWN.register((player, conqueredEnd, removalReason) -> { if (!conqueredEnd) { TestMod.SINK.accept(player.getScoreboardName() + " respawns " + logSide(player.level())); } diff --git a/testmod-common/src/main/java/dev/architectury/test/networking/TestModNet.java b/testmod-common/src/main/java/dev/architectury/test/networking/TestModNet.java index 58793fadb..1d7dabab9 100644 --- a/testmod-common/src/main/java/dev/architectury/test/networking/TestModNet.java +++ b/testmod-common/src/main/java/dev/architectury/test/networking/TestModNet.java @@ -44,10 +44,10 @@ public interface TestModNet { // An example Server to Client message MessageType SYNC_DATA = NET.registerS2C("sync_data", SyncDataMessage::new); - ResourceLocation BIG_DATA = new ResourceLocation(TestMod.MOD_ID, "big_data"); - ResourceLocation SERVER_TO_CLIENT_TEST = new ResourceLocation(TestMod.MOD_ID, "s2c_test"); - CustomPacketPayload.Type SERVER_TO_CLIENT_TEST_PAYLOAD = new CustomPacketPayload.Type<>(new ResourceLocation(TestMod.MOD_ID, "s2c_test_payload")); - CustomPacketPayload.Type BIG_DATA_PAYLOAD = new CustomPacketPayload.Type<>(new ResourceLocation(TestMod.MOD_ID, "big_data_payload")); + ResourceLocation BIG_DATA = ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "big_data"); + ResourceLocation SERVER_TO_CLIENT_TEST = ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "s2c_test"); + CustomPacketPayload.Type SERVER_TO_CLIENT_TEST_PAYLOAD = new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "s2c_test_payload")); + CustomPacketPayload.Type BIG_DATA_PAYLOAD = new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "big_data_payload")); String BIG_STRING = StringUtils.repeat('a', 100000); static void initialize() { diff --git a/testmod-common/src/main/java/dev/architectury/test/registry/TestRegistries.java b/testmod-common/src/main/java/dev/architectury/test/registry/TestRegistries.java index bc64c5989..8a6cb1120 100644 --- a/testmod-common/src/main/java/dev/architectury/test/registry/TestRegistries.java +++ b/testmod-common/src/main/java/dev/architectury/test/registry/TestRegistries.java @@ -77,7 +77,7 @@ public TestInt(int value) { } } - public static final Registrar INTS = RegistrarManager.get(TestMod.MOD_ID).builder(new ResourceLocation(TestMod.MOD_ID, "ints")) + public static final Registrar INTS = RegistrarManager.get(TestMod.MOD_ID).builder(ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "ints")) .syncToClients() .build(); public static final DeferredRegister TABS = DeferredRegister.create(TestMod.MOD_ID, Registries.CREATIVE_MODE_TAB); @@ -95,14 +95,14 @@ public TestInt(int value) { public static final ArchitecturyFluidAttributes TEST_FLUID_ATTRIBUTES = SimpleArchitecturyFluidAttributes.ofSupplier(() -> TestRegistries.TEST_FLUID_FLOWING, () -> TestRegistries.TEST_FLUID) .convertToSource(true) - .flowingTexture(new ResourceLocation("block/water_flow")) - .sourceTexture(new ResourceLocation("block/water_still")) + .flowingTexture(ResourceLocation.withDefaultNamespace("block/water_flow")) + .sourceTexture(ResourceLocation.withDefaultNamespace("block/water_still")) .blockSupplier(() -> TestRegistries.TEST_FLUID_BLOCK) .bucketItemSupplier(() -> TestRegistries.TEST_FLUID_BUCKET) .color(0xFF0000); - public static final RegistrySupplier TEST_INT = INTS.register(new ResourceLocation(TestMod.MOD_ID, "test_int"), () -> new TestInt(1)); - public static final RegistrySupplier TEST_INT_2 = INTS.register(new ResourceLocation(TestMod.MOD_ID, "test_int_2"), () -> new TestInt(2)); + public static final RegistrySupplier TEST_INT = INTS.register(ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "test_int"), () -> new TestInt(1)); + public static final RegistrySupplier TEST_INT_2 = INTS.register(ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "test_int_2"), () -> new TestInt(2)); public static final RegistrySupplier TEST_EFFECT = MOB_EFFECTS.register("test_effect", () -> new MobEffect(MobEffectCategory.NEUTRAL, 0x123456) { diff --git a/testmod-common/src/main/java/dev/architectury/test/tags/TestTags.java b/testmod-common/src/main/java/dev/architectury/test/tags/TestTags.java index be10f4104..2b9144781 100644 --- a/testmod-common/src/main/java/dev/architectury/test/tags/TestTags.java +++ b/testmod-common/src/main/java/dev/architectury/test/tags/TestTags.java @@ -32,9 +32,9 @@ public class TestTags { public static void initialize() { // This will not be present, but it should return an empty tag - var heartParticles = TagKey.create(Registries.BLOCK, new ResourceLocation(TestMod.MOD_ID, "heart_particles")); + var heartParticles = TagKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "heart_particles")); // This will act like a normal tag, we have emerald block here - var heartParticles2 = TagKey.create(Registries.BLOCK, new ResourceLocation(TestMod.MOD_ID, "heart_particles2")); + var heartParticles2 = TagKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "heart_particles2")); BlockEvent.BREAK.register((world, pos, state, player, xp) -> { if (player != null && !world.isClientSide() && (state.is(heartParticles) || state.is(heartParticles2))) { diff --git a/testmod-common/src/main/java/dev/architectury/test/worldgen/TestWorldGeneration.java b/testmod-common/src/main/java/dev/architectury/test/worldgen/TestWorldGeneration.java index 4f78fe8e3..358af7727 100644 --- a/testmod-common/src/main/java/dev/architectury/test/worldgen/TestWorldGeneration.java +++ b/testmod-common/src/main/java/dev/architectury/test/worldgen/TestWorldGeneration.java @@ -35,7 +35,7 @@ public static void initialize() { if (ctx.hasTag(BiomeTags.IS_FOREST)) { mutable.getGenerationProperties().addFeature(GenerationStep.Decoration.TOP_LAYER_MODIFICATION, ResourceKey.create(Registries.PLACED_FEATURE, - new ResourceLocation(TestMod.MOD_ID + ":diamond_blocks"))); + ResourceLocation.fromNamespaceAndPath(TestMod.MOD_ID, "diamond_blocks"))); } }); });