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 8b105104f..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 @@ -137,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) @@ -152,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 f222fccd0..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(); /** 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 b9d928dd5..07820b9e5 100644 --- a/common/src/main/java/dev/architectury/networking/SpawnEntityPacket.java +++ b/common/src/main/java/dev/architectury/networking/SpawnEntityPacket.java @@ -34,6 +34,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; @@ -47,7 +48,7 @@ public class SpawnEntityPacket { 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) { // TODO FIX if (entity.level().isClientSide()) { throw new IllegalStateException("SpawnPacketUtil.create called on the logical client!"); } 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/client/MixinGameRenderer.java b/fabric/src/main/java/dev/architectury/mixin/fabric/client/MixinGameRenderer.java index 71a222146..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 @@ -49,11 +49,14 @@ public abstract class MixinGameRenderer { @Final private Minecraft minecraft; + @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(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.getGameTimeDeltaTicks()).isFalse()) { + if (ClientGuiEvent.RENDER_PRE.invoker().render(minecraft.screen, graphics, mouseX, mouseY, tickDelta).isFalse()) { ci.cancel(); } } @@ -62,7 +65,7 @@ public void renderScreenPre(DeltaTracker tickDelta, boolean tick, CallbackInfo c 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(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.getGameTimeDeltaTicks()); + ClientGuiEvent.RENDER_POST.invoker().render(minecraft.screen, graphics, mouseX, mouseY, tickDelta); } @Inject(method = "reloadShaders", 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/testmod-common/src/main/java/dev/architectury/test/TestMod.java b/testmod-common/src/main/java/dev/architectury/test/TestMod.java index 0581cbc43..486080146 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; @@ -76,7 +78,7 @@ public static void initialize() { 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); + mutable.set(VanillaRegistries.createLookup().lookup(Registries.ENCHANTMENT).orElseThrow().getOrThrow(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..8d85875c8 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.fromNamespaceAndPath("block/water_flow")) + .sourceTexture(ResourceLocation.fromNamespaceAndPath("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"))); } }); });