diff --git a/library/block/block_content_registry/src/testmod/java/org/quiltmc/qsl/block/test/BlockContentRegistryTest.java b/library/block/block_content_registry/src/testmod/java/org/quiltmc/qsl/block/test/BlockContentRegistryTest.java index 97dbc5a134..4df5fe15b7 100644 --- a/library/block/block_content_registry/src/testmod/java/org/quiltmc/qsl/block/test/BlockContentRegistryTest.java +++ b/library/block/block_content_registry/src/testmod/java/org/quiltmc/qsl/block/test/BlockContentRegistryTest.java @@ -66,7 +66,7 @@ public class BlockContentRegistryTest implements ModInitializer, QuiltGameTest { @Override public void onInitialize(ModContainer mod) { RegistryExtensions.register(Registries.BLOCK, new Identifier(MOD_ID, "oxidizable_iron_block"), - new OxidizableBlock(Oxidizable.OxidizationLevel.UNAFFECTED, AbstractBlock.Settings.method_9630(Blocks.IRON_BLOCK)), + new OxidizableBlock(Oxidizable.OxidizationLevel.UNAFFECTED, AbstractBlock.Settings.copy(Blocks.IRON_BLOCK)), BlockContentRegistries.OXIDIZABLE, new ReversibleBlockEntry(Blocks.IRON_BLOCK, false)); BlockContentRegistries.ENCHANTING_BOOSTERS.put(Blocks.IRON_BLOCK, new ConstantBooster(3f)); diff --git a/library/block/block_entity/src/testmod/java/org/quiltmc/qsl/block/entity/test/AngyBlock.java b/library/block/block_entity/src/testmod/java/org/quiltmc/qsl/block/entity/test/AngyBlock.java index 1c2729aa78..dd1a91d407 100644 --- a/library/block/block_entity/src/testmod/java/org/quiltmc/qsl/block/entity/test/AngyBlock.java +++ b/library/block/block_entity/src/testmod/java/org/quiltmc/qsl/block/entity/test/AngyBlock.java @@ -36,7 +36,7 @@ public class AngyBlock extends BlockWithEntity { public AngyBlock(MapColor mapColor) { - super(AbstractBlock.Settings.method_9630(Blocks.STONE).mapColor(mapColor)); + super(AbstractBlock.Settings.copy(Blocks.STONE).mapColor(mapColor)); } @Override diff --git a/library/core/data_callback/DISABLE b/library/core/data_callback/DISABLE deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/library/core/networking/DISABLE b/library/core/networking/DISABLE deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/NetworkingTestMods.java b/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/NetworkingTestMods.java index a44e2e431f..9b576b60ea 100644 --- a/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/NetworkingTestMods.java +++ b/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/NetworkingTestMods.java @@ -16,6 +16,7 @@ package org.quiltmc.qsl.networking.test; +import net.minecraft.network.packet.payload.CustomPayload; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,8 +26,8 @@ public final class NetworkingTestMods { public static final String ID = "quilt_networking_testmod"; public static final Logger LOGGER = LoggerFactory.getLogger(ID); - public static Identifier id(String name) { - return new Identifier(ID, name); + public static CustomPayload.Id id(String name) { + return new CustomPayload.Id<>(new Identifier(ID, name)); } private NetworkingTestMods() { diff --git a/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/channeltest/ChannelScreen.java b/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/channeltest/ChannelScreen.java index 1ca9db7474..b65b278c05 100644 --- a/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/channeltest/ChannelScreen.java +++ b/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/channeltest/ChannelScreen.java @@ -20,6 +20,7 @@ import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.tooltip.Tooltip; import net.minecraft.client.gui.widget.button.ButtonWidget; +import net.minecraft.network.packet.payload.CustomPayload; import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; @@ -53,7 +54,7 @@ protected void init() { @Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - this.renderBackgroundTexture(graphics); + this.renderBackground(graphics, mouseX, mouseY, delta); this.channelList.render(graphics, mouseX, mouseY, delta); super.render(graphics, mouseX, mouseY, delta); @@ -84,8 +85,8 @@ private void toC2S(ButtonWidget button) { button.active = false; this.channelList.clear(); - for (Identifier receiver : ClientPlayNetworking.getSendable()) { - this.channelList.addEntry(this.channelList.new Entry(receiver)); + for (CustomPayload.Id receiver : ClientPlayNetworking.getSendable()) { + this.channelList.addEntry(this.channelList.new Entry(receiver.id())); } } @@ -94,8 +95,8 @@ private void toS2C(ButtonWidget button) { button.active = false; this.channelList.clear(); - for (Identifier receiver : ClientPlayNetworking.getReceived()) { - this.channelList.addEntry(this.channelList.new Entry(receiver)); + for (CustomPayload.Id receiver : ClientPlayNetworking.getReceived()) { + this.channelList.addEntry(this.channelList.new Entry(receiver.id())); } } } diff --git a/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/channeltest/NetworkingChannelTest.java b/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/channeltest/NetworkingChannelTest.java index 89a1b8d359..f024f99af0 100644 --- a/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/channeltest/NetworkingChannelTest.java +++ b/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/channeltest/NetworkingChannelTest.java @@ -38,14 +38,19 @@ import net.minecraft.command.CommandBuildContext; import net.minecraft.command.CommandSource; import net.minecraft.command.EntitySelector; +import net.minecraft.network.packet.payload.CustomPayload; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; +import net.minecraft.server.network.ServerPlayNetworkHandler; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; import net.minecraft.util.Identifier; import org.quiltmc.qsl.command.api.CommandRegistrationCallback; +import org.quiltmc.qsl.networking.api.PacketSender; import org.quiltmc.qsl.networking.api.ServerPlayNetworking; +import org.quiltmc.qsl.networking.impl.payload.PacketByteBufPayload; public final class NetworkingChannelTest implements CommandRegistrationCallback { @Override @@ -92,19 +97,21 @@ public void registerCommands(CommandDispatcher dispatcher, private static CompletableFuture suggestReceivableChannels(CommandContext context, SuggestionsBuilder builder) throws CommandSyntaxException { final ServerPlayerEntity player = context.getSource().getPlayer(); - return CommandSource.suggestIdentifiers(ServerPlayNetworking.getReceived(player), builder); + return CommandSource.suggestIdentifiers(ServerPlayNetworking.getReceived(player).stream().map(CustomPayload.Id::id), builder); } private static int registerChannel(CommandContext context, ServerPlayerEntity executor) throws CommandSyntaxException { - final Identifier channel = getIdentifier(context, "channel"); + final CustomPayload.Id channel = new CustomPayload.Id<>(getIdentifier(context, "channel")); if (ServerPlayNetworking.getReceived(executor).contains(channel)) { throw new SimpleCommandExceptionType(Text.of(String.format("Cannot register channel %s twice for server player", channel))).create(); } - ServerPlayNetworking.registerReceiver(executor.networkHandler, channel, (server, player, handler, buf, sender) -> { - System.out.printf("Received packet on channel %s%n", channel); - }); + // TODO + if (true) throw new UnsupportedOperationException(); +// ServerPlayNetworking.registerReceiver(executor.networkHandler, channel, (server, player, handler, buf, sender) -> { +// System.out.printf("Received packet on channel %s%n", channel); +// }); context.getSource().sendSystemMessage(Text.of(String.format("Registered channel %s for %s", channel, executor.getDisplayName()))); @@ -112,7 +119,7 @@ private static int registerChannel(CommandContext context, } private static int unregisterChannel(CommandContext context, ServerPlayerEntity player) throws CommandSyntaxException { - final Identifier channel = getIdentifier(context, "channel"); + final CustomPayload.Id channel = new CustomPayload.Id<>(getIdentifier(context, "channel")); if (!ServerPlayNetworking.getReceived(player).contains(channel)) { throw new SimpleCommandExceptionType(Text.of("Cannot unregister channel the server player entity cannot receive packets on")).create(); @@ -126,12 +133,12 @@ private static int unregisterChannel(CommandContext context private static int infoCommand(CommandContext context, ServerPlayerEntity player) { ServerCommandSource source = context.getSource(); - Set channels = ServerPlayNetworking.getSendable(player); + Set> channels = ServerPlayNetworking.getSendable(player); source.sendSystemMessage(Text.of(String.format("Available channels for player %s", player.getDisplayName()))); - for (Identifier channel : channels) { - source.sendSystemMessage(Text.of(channel.toString())); + for (CustomPayload.Id channel : channels) { + source.sendSystemMessage(Text.of(channel.id().toString())); } return 1; diff --git a/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/keybindreciever/NetworkingKeyBindPacketTest.java b/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/keybindreciever/NetworkingKeyBindPacketTest.java index f405386f03..dc68596f09 100644 --- a/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/keybindreciever/NetworkingKeyBindPacketTest.java +++ b/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/keybindreciever/NetworkingKeyBindPacketTest.java @@ -35,7 +35,7 @@ // Listens for a packet from the client which is sent to the server when a keybinding is pressed. // In response the server will send a message containing the keybind text letting the client know it pressed that key. public final class NetworkingKeyBindPacketTest implements ModInitializer { - public static final Identifier KEYBINDING_PACKET_ID = NetworkingTestMods.id("keybind_press_test"); + public static final CustomPayload.Id KEYBINDING_PACKET_ID = NetworkingTestMods.id("keybind_press_test"); private static void receive(MinecraftServer server, ServerPlayerEntity player, ServerPlayNetworkHandler handler, PacketByteBuf buf, PacketSender responseSender) { // TODO: Can we send chat off the server thread? diff --git a/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/login/NetworkingLoginQueryTest.java b/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/login/NetworkingLoginQueryTest.java index 6553e58e27..8a8bb78b43 100644 --- a/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/login/NetworkingLoginQueryTest.java +++ b/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/login/NetworkingLoginQueryTest.java @@ -19,6 +19,7 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.FutureTask; +import net.minecraft.network.packet.payload.CustomPayload; import net.minecraft.network.packet.s2c.login.payload.CustomQueryPayload; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerLoginNetworkHandler; @@ -34,8 +35,8 @@ import org.quiltmc.qsl.networking.test.NetworkingTestMods; public final class NetworkingLoginQueryTest implements ModInitializer { - public static final Identifier TEST_CHANNEL_GLOBAL = NetworkingTestMods.id("test_channel_global"); - public static final Identifier TEST_CHANNEL = NetworkingTestMods.id("test_channel"); + public static final CustomPayload.Id TEST_CHANNEL_GLOBAL = NetworkingTestMods.id("test_channel_global"); + public static final CustomPayload.Id TEST_CHANNEL = NetworkingTestMods.id("test_channel"); private static final boolean useLoginDelayTest = System.getProperty("quilt_networking.login_delay_test") != null; @Override diff --git a/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/payload/C2SPayloadTest.java b/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/payload/C2SPayloadTest.java index 7f88df9e85..d067170434 100644 --- a/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/payload/C2SPayloadTest.java +++ b/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/payload/C2SPayloadTest.java @@ -19,6 +19,7 @@ import java.util.List; import net.minecraft.network.PacketByteBuf; +import net.minecraft.network.codec.PacketCodec; import net.minecraft.network.packet.payload.CustomPayload; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayNetworkHandler; @@ -40,7 +41,7 @@ public class C2SPayloadTest implements ClientModInitializer { private static boolean received = false; @Override public void onInitializeClient(ModContainer mod) { - CustomPayloads.registerC2SPayload(TestC2SPayload.ID, TestC2SPayload::new); + CustomPayloads.registerC2SPayload(TestC2SPayload.ID, TestC2SPayload.CODEC); ServerPlayNetworking.registerGlobalReceiver(TestC2SPayload.ID, this::handleTestPayload); ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> { @@ -74,21 +75,21 @@ public void handleTestPayload(MinecraftServer server, ServerPlayerEntity player, } public record TestC2SPayload(List strings, int a, double b) implements CustomPayload { - public static final Identifier ID = new Identifier("quilt_networking_testmod", "test_c2s_payload"); + public static final Id ID = new Id<>(new Identifier("quilt_networking_testmod", "test_c2s_payload")); + public static final PacketCodec CODEC = CustomPayload.create(TestC2SPayload::write, TestC2SPayload::new); TestC2SPayload(PacketByteBuf buf) { this(buf.readList(PacketByteBuf::readString), buf.readInt(), buf.readDouble()); } - @Override - public void write(PacketByteBuf buf) { + private void write(PacketByteBuf buf) { buf.writeCollection(this.strings, PacketByteBuf::writeString); buf.writeInt(this.a); buf.writeDouble(this.b); } @Override - public Identifier id() { + public Id getId() { return ID; } } diff --git a/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/payload/S2CPayloadTest.java b/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/payload/S2CPayloadTest.java index 4813ec8b7a..a3613bbb33 100644 --- a/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/payload/S2CPayloadTest.java +++ b/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/payload/S2CPayloadTest.java @@ -21,6 +21,7 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.network.PacketByteBuf; +import net.minecraft.network.codec.PacketCodec; import net.minecraft.network.packet.payload.CustomPayload; import net.minecraft.util.Identifier; @@ -32,6 +33,7 @@ import org.quiltmc.qsl.networking.api.ServerPlayConnectionEvents; import org.quiltmc.qsl.networking.api.client.ClientPlayNetworking; import org.quiltmc.qsl.networking.impl.NetworkingImpl; +import org.quiltmc.qsl.networking.impl.common.CommonRegisterPayload; import org.quiltmc.qsl.networking.test.NetworkingTestMods; // Test cannot run on a server, so only run with a client @@ -40,7 +42,7 @@ public class S2CPayloadTest implements ClientModInitializer { @Override public void onInitializeClient(ModContainer mod) { - CustomPayloads.registerS2CPayload(TestS2CPayload.ID, TestS2CPayload::new); + CustomPayloads.registerS2CPayload(TestS2CPayload.ID, TestS2CPayload.CODEC); ClientPlayNetworking.registerGlobalReceiver(TestS2CPayload.ID, this::handleTestPayload); ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> { @@ -74,22 +76,24 @@ public void handleTestPayload(MinecraftClient client, ClientPlayNetworkHandler h } public record TestS2CPayload(List strings, int a, double b) implements CustomPayload { - public static final Identifier ID = new Identifier("quilt_networking_testmod", "test_s2c_payload"); + public static final Id ID = new Id<>(new Identifier("quilt_networking_testmod", "test_s2c_payload")); + public static final PacketCodec CODEC = CustomPayload.create(TestS2CPayload::write, TestS2CPayload::new); TestS2CPayload(PacketByteBuf buf) { this(buf.readList(PacketByteBuf::readString), buf.readInt(), buf.readDouble()); } - @Override - public void write(PacketByteBuf buf) { + + private void write(PacketByteBuf buf) { buf.writeCollection(this.strings, PacketByteBuf::writeString); buf.writeInt(this.a); buf.writeDouble(this.b); } + @Override - public Identifier id() { - return ID; + public Id getId() { + return null; } } } diff --git a/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/play/NetworkingPlayPacketClientTest.java b/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/play/NetworkingPlayPacketClientTest.java index a715180bfa..9d43e4655b 100644 --- a/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/play/NetworkingPlayPacketClientTest.java +++ b/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/play/NetworkingPlayPacketClientTest.java @@ -44,10 +44,10 @@ public void onInitializeClient(ModContainer mod) { } private void receive(ClientPlayNetworkHandler handler, PacketSender sender, MinecraftClient client, PacketByteBuf buf) { - Text text = buf.readText(); + String text = buf.readString(); client.execute(() -> { LOGGER.info("Received text from {} which says {}.", NetworkingPlayPacketTest.TEST_CHANNEL, text); - client.inGameHud.setOverlayMessage(text, true); + client.inGameHud.setOverlayMessage(Text.literal(text), true); }); } } diff --git a/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/play/NetworkingPlayPacketTest.java b/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/play/NetworkingPlayPacketTest.java index 86d3f80cb2..64d873bbc6 100644 --- a/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/play/NetworkingPlayPacketTest.java +++ b/library/core/networking/src/testmod/java/org/quiltmc/qsl/networking/test/play/NetworkingPlayPacketTest.java @@ -29,6 +29,7 @@ import net.minecraft.network.PacketByteBuf; import net.minecraft.network.listener.ClientPlayPacketListener; import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.payload.CustomPayload; import net.minecraft.network.packet.s2c.PacketBundleS2CPacket; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; @@ -43,11 +44,11 @@ import org.quiltmc.qsl.networking.test.NetworkingTestMods; public final class NetworkingPlayPacketTest implements ModInitializer { - public static final Identifier TEST_CHANNEL = NetworkingTestMods.id("test_channel"); + public static final CustomPayload.Id TEST_CHANNEL = NetworkingTestMods.id("test_channel"); public static void sendToTestChannel(ServerPlayerEntity player, String stuff) { PacketByteBuf buf = PacketByteBufs.create(); - buf.writeText(Text.of(stuff)); + buf.writeString(stuff); ServerPlayNetworking.send(player, TEST_CHANNEL, buf); NetworkingTestMods.LOGGER.info("Sent custom payload packet in {}", TEST_CHANNEL); } @@ -63,9 +64,9 @@ public static void registerCommand(CommandDispatcher dispat })) .then(literal("bundled").executes(ctx -> { PacketByteBuf bufA = PacketByteBufs.create(); - bufA.writeText(Text.literal("Bundled #1")); + bufA.writeString("Bundled #1"); PacketByteBuf bufB = PacketByteBufs.create(); - bufB.writeText(Text.literal("Bundled #2")); + bufB.writeString("Bundled #2"); var packet = new PacketBundleS2CPacket(List.of( (Packet) (Object) ServerPlayNetworking.createS2CPacket(TEST_CHANNEL, bufA), diff --git a/library/core/registry/DISABLE b/library/core/registry/DISABLE deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/library/core/registry/src/main/java/org/quiltmc/qsl/registry/impl/dynamic/DynamicMetaRegistryImpl.java b/library/core/registry/src/main/java/org/quiltmc/qsl/registry/impl/dynamic/DynamicMetaRegistryImpl.java index ff09f1dffd..2f8a165a4e 100644 --- a/library/core/registry/src/main/java/org/quiltmc/qsl/registry/impl/dynamic/DynamicMetaRegistryImpl.java +++ b/library/core/registry/src/main/java/org/quiltmc/qsl/registry/impl/dynamic/DynamicMetaRegistryImpl.java @@ -16,12 +16,14 @@ package org.quiltmc.qsl.registry.impl.dynamic; +import java.util.ArrayList; import java.util.HashSet; import java.util.Set; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.mojang.serialization.Codec; +import net.minecraft.registry.DynamicRegistrySync; import org.jetbrains.annotations.ApiStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,7 +34,6 @@ import net.minecraft.util.Identifier; import org.quiltmc.qsl.registry.api.dynamic.DynamicRegistryFlag; -import org.quiltmc.qsl.registry.mixin.DynamicRegistrySyncAccessor; @ApiStatus.Internal public class DynamicMetaRegistryImpl { @@ -62,12 +63,17 @@ public static void register(RegistryKey> ref, Codec public static void registerSynced(RegistryKey> ref, Codec entryCodec, Codec syncCodec, DynamicRegistryFlag... flags) { register(ref, entryCodec, flags); - RegistryLoader.SYNCED_REGISTRIES.add(new RegistryLoader.DecodingData<>(ref, entryCodec)); - DynamicRegistrySyncAccessor.quilt$getSyncedCodecs().add(ref); - // TODO figure out whether the above works at all and whether the syncCodec arg is still needed - /*var builder = ImmutableSet.>>builder().addAll(DynamicRegistrySyncAccessor.quilt$getSyncedCodecs()); - DynamicRegistrySyncAccessor.quilt$invokeAddSyncedRegistry(builder, ref, syncCodec); - DynamicRegistrySyncAccessor.quilt$setSyncedCodecs(builder.build());*/ + if (!(RegistryLoader.SYNCED_REGISTRIES instanceof ArrayList>)) { + RegistryLoader.SYNCED_REGISTRIES = new ArrayList<>(RegistryLoader.SYNCED_REGISTRIES); + } + + RegistryLoader.SYNCED_REGISTRIES.add(new RegistryLoader.DecodingData<>(ref, syncCodec)); + + if (!(DynamicRegistrySync.SYNCED_CODECS instanceof HashSet>>)) { + DynamicRegistrySync.SYNCED_CODECS = new HashSet<>(DynamicRegistrySync.SYNCED_CODECS); + } + + DynamicRegistrySync.SYNCED_CODECS.add(ref); } public static void freeze() { diff --git a/library/core/registry/src/main/java/org/quiltmc/qsl/registry/mixin/DynamicRegistrySyncAccessor.java b/library/core/registry/src/main/java/org/quiltmc/qsl/registry/mixin/DynamicRegistrySyncAccessor.java deleted file mode 100644 index 7ec8c90581..0000000000 --- a/library/core/registry/src/main/java/org/quiltmc/qsl/registry/mixin/DynamicRegistrySyncAccessor.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2023 The Quilt Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.quiltmc.qsl.registry.mixin; - -import java.util.Set; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import net.minecraft.registry.DynamicRegistrySync; -import net.minecraft.registry.Registry; -import net.minecraft.registry.RegistryKey; - -@Mixin(DynamicRegistrySync.class) -public interface DynamicRegistrySyncAccessor { - @Accessor("SYNCED_CODECS") - static Set>> quilt$getSyncedCodecs() { - throw new IllegalStateException("Mixin injection failed."); - } - - @Accessor("SYNCED_CODECS") - static void quilt$setSyncedCodecs(Set>> syncedCodecs) { - throw new IllegalStateException("Mixin injection failed."); - } -} diff --git a/library/core/registry/src/main/resources/quilt_registry.accesswidener b/library/core/registry/src/main/resources/quilt_registry.accesswidener index 0c40fc8bc5..8db09ca66a 100644 --- a/library/core/registry/src/main/resources/quilt_registry.accesswidener +++ b/library/core/registry/src/main/resources/quilt_registry.accesswidener @@ -2,6 +2,7 @@ accessWidener v2 named accessible method net/minecraft/registry/Holder$Reference setValue (Ljava/lang/Object;)V -# Registry Loader - added for 1.20.5/6 accessible class net/minecraft/registry/RegistryLoader$ContentLoader accessible class net/minecraft/registry/RegistryLoader$LoadingFunction +mutable field net/minecraft/registry/RegistryLoader SYNCED_REGISTRIES Ljava/util/List; +mutable field net/minecraft/registry/DynamicRegistrySync SYNCED_CODECS Ljava/util/Set; diff --git a/library/core/registry/src/main/resources/quilt_registry.mixins.json b/library/core/registry/src/main/resources/quilt_registry.mixins.json index 61b736a46e..797e0863a7 100644 --- a/library/core/registry/src/main/resources/quilt_registry.mixins.json +++ b/library/core/registry/src/main/resources/quilt_registry.mixins.json @@ -8,7 +8,6 @@ "ClientConnectionMixin", "compat.StatusEffectFixMixin", "DebugChunkGeneratorAccessor", - "DynamicRegistrySyncAccessor", "DynamicRegistrySyncMixin", "FluidsMixin", "IdListMixin", diff --git a/library/core/registry/src/testmod/java/org/quiltmc/qsl/registry/test/RegistryLibEventsTest.java b/library/core/registry/src/testmod/java/org/quiltmc/qsl/registry/test/RegistryLibEventsTest.java index a22bd8c754..f6e7201d89 100644 --- a/library/core/registry/src/testmod/java/org/quiltmc/qsl/registry/test/RegistryLibEventsTest.java +++ b/library/core/registry/src/testmod/java/org/quiltmc/qsl/registry/test/RegistryLibEventsTest.java @@ -49,7 +49,7 @@ public void onInitialize(ModContainer mod) { } }); - register(TEST_BLOCK_ID, new Block(AbstractBlock.Settings.method_9630(Blocks.STONE).mapColor(MapColor.BLACK))); + register(TEST_BLOCK_ID, new Block(AbstractBlock.Settings.copy(Blocks.STONE).mapColor(MapColor.BLACK))); if (!entryAddEventFoundBlock) { throw new AssertionError("Registry entry add event was not invoked on the registration of block with id " + TEST_BLOCK_ID); diff --git a/library/core/registry/src/testmod/java/org/quiltmc/qsl/registry/test/RegistryLibMonitorRegistrationTest.java b/library/core/registry/src/testmod/java/org/quiltmc/qsl/registry/test/RegistryLibMonitorRegistrationTest.java index 03c9c06bad..63bc274a30 100644 --- a/library/core/registry/src/testmod/java/org/quiltmc/qsl/registry/test/RegistryLibMonitorRegistrationTest.java +++ b/library/core/registry/src/testmod/java/org/quiltmc/qsl/registry/test/RegistryLibMonitorRegistrationTest.java @@ -45,7 +45,7 @@ public class RegistryLibMonitorRegistrationTest implements ModInitializer { @Override public void onInitialize(ModContainer mod) { - register(TEST_BLOCK_A_ID, new Block(AbstractBlock.Settings.method_9630(Blocks.STONE).mapColor(MapColor.BLACK))); + register(TEST_BLOCK_A_ID, new Block(AbstractBlock.Settings.copy(Blocks.STONE).mapColor(MapColor.BLACK))); var monitor = RegistryMonitor.create(Registries.BLOCK) .filter(context -> context.id().getNamespace().equals("quilt_registry_test_monitors_registration")); @@ -55,7 +55,7 @@ public void onInitialize(ModContainer mod) { context.value(), context.id(), context.rawId(), context.registry()); if (context.id() == TEST_BLOCK_A_ID) { - context.register(TEST_BLOCK_B_ID, new Block(AbstractBlock.Settings.method_9630(Blocks.STONE).mapColor(MapColor.BLACK))); + context.register(TEST_BLOCK_B_ID, new Block(AbstractBlock.Settings.copy(Blocks.STONE).mapColor(MapColor.BLACK))); } }); } diff --git a/library/core/registry/src/testmod/java/org/quiltmc/qsl/registry/test/RegistryLibMonitorTest.java b/library/core/registry/src/testmod/java/org/quiltmc/qsl/registry/test/RegistryLibMonitorTest.java index eecd0dc978..0b5aab8593 100644 --- a/library/core/registry/src/testmod/java/org/quiltmc/qsl/registry/test/RegistryLibMonitorTest.java +++ b/library/core/registry/src/testmod/java/org/quiltmc/qsl/registry/test/RegistryLibMonitorTest.java @@ -42,7 +42,7 @@ public class RegistryLibMonitorTest implements ModInitializer { @Override public void onInitialize(ModContainer mod) { - Block blockA = register(TEST_BLOCK_A_ID, new Block(AbstractBlock.Settings.method_9630(Blocks.STONE).mapColor(MapColor.BLACK))); + Block blockA = register(TEST_BLOCK_A_ID, new Block(AbstractBlock.Settings.copy(Blocks.STONE).mapColor(MapColor.BLACK))); var monitor = RegistryMonitor.create(Registries.BLOCK) .filter(context -> context.id().getNamespace().equals("quilt_registry_test_monitors")); @@ -61,7 +61,7 @@ public void onInitialize(ModContainer mod) { upcomingSet.add(context.value()); }); - Block blockB = register(TEST_BLOCK_B_ID, new Block(AbstractBlock.Settings.method_9630(Blocks.STONE).mapColor(MapColor.BLACK))); + Block blockB = register(TEST_BLOCK_B_ID, new Block(AbstractBlock.Settings.copy(Blocks.STONE).mapColor(MapColor.BLACK))); if (!allSet.contains(blockA) || !allSet.contains(blockB)) { throw new AssertionError("Entries " + allSet + " found by RegistryMonitor via forAll were not as expected"); diff --git a/library/core/registry/src/testmod/java/org/quiltmc/qsl/registry/test/RegistryLibSyncOrderTest.java b/library/core/registry/src/testmod/java/org/quiltmc/qsl/registry/test/RegistryLibSyncOrderTest.java index fd882c4e7d..ea33be830a 100644 --- a/library/core/registry/src/testmod/java/org/quiltmc/qsl/registry/test/RegistryLibSyncOrderTest.java +++ b/library/core/registry/src/testmod/java/org/quiltmc/qsl/registry/test/RegistryLibSyncOrderTest.java @@ -18,10 +18,12 @@ import java.util.function.Consumer; +import com.mojang.serialization.Codec; import net.fabricmc.api.EnvType; import net.minecraft.item.Item; import net.minecraft.network.PacketByteBuf; +import net.minecraft.network.codec.PacketCodec; import net.minecraft.server.network.ServerConfigurationNetworkHandler; import net.minecraft.network.configuration.ConfigurationTask; import net.minecraft.network.packet.Packet; @@ -46,7 +48,8 @@ * Makes sure that the registry sync is done soon enough in the configuration system. */ public class RegistryLibSyncOrderTest implements ModInitializer, DedicatedServerModInitializer, ClientModInitializer { - private static final Identifier PACKET_ID = new Identifier("quilt", "reg_sync_order_packet"); + private static final CustomPayload.Id PACKET_ID = new CustomPayload.Id<>(new Identifier("quilt", "reg_sync_order_packet")); + private static final PacketCodec PACKET_CODEC = CustomPayload.create(TestPayload::write, TestPayload::new); public static Item ITEM_A = new Item(new Item.Settings()); public static Item ITEM_B = new Item(new Item.Settings()); private static final Identifier EARLY_PHASE = new Identifier("quilt", "reg_sync_order_early"); @@ -56,15 +59,14 @@ record TestPayload(boolean early, int a, int b) implements CustomPayload { this(buf.readBoolean(), buf.readInt(), buf.readInt()); } - @Override - public void write(PacketByteBuf buf) { + private void write(PacketByteBuf buf) { buf.writeBoolean(this.early); buf.writeInt(this.a); buf.writeInt(this.b); } @Override - public Identifier id() { + public CustomPayload.Id getId() { return PACKET_ID; } } @@ -79,7 +81,7 @@ public void onInitialize(ModContainer mod) { Registry.register(Registries.ITEM, new Identifier("quilt", "reg_sync_order_a"), ITEM_A); } - CustomPayloads.registerS2CPayload(PACKET_ID, TestPayload::new); + CustomPayloads.registerS2CPayload(PACKET_ID, PACKET_CODEC); } @Override diff --git a/library/core/registry/src/testmod/java/org/quiltmc/qsl/registry/test/RegistryLibSyncTest.java b/library/core/registry/src/testmod/java/org/quiltmc/qsl/registry/test/RegistryLibSyncTest.java index d175772c1b..8820304710 100644 --- a/library/core/registry/src/testmod/java/org/quiltmc/qsl/registry/test/RegistryLibSyncTest.java +++ b/library/core/registry/src/testmod/java/org/quiltmc/qsl/registry/test/RegistryLibSyncTest.java @@ -72,7 +72,7 @@ public void onInitialize(ModContainer mod) { ServerLifecycleEvents.READY.register((x) -> this.printReg()); } - var customRequiredRegistry = Registry.register((Registry>) Registries.REGISTRY, + var customRequiredRegistry = Registry.register((Registry>) Registries.ROOT, new Identifier(NAMESPACE, "synced_registry"), new SimpleRegistry<>(RegistryKey.ofRegistry(new Identifier(NAMESPACE, "synced_registry")), Lifecycle.stable())); @@ -88,8 +88,8 @@ private void printReg() { StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE ); - for (var reg : Registries.REGISTRY) { - writer.write("\n=== Registry: " + ((Registry>) Registries.REGISTRY).getId(reg) + "\n"); + for (var reg : Registries.ROOT) { + writer.write("\n=== Registry: " + ((Registry>) Registries.ROOT).getId(reg) + "\n"); if (reg instanceof SynchronizedRegistry sync) { writer.write("== Requires Sync: " + sync.quilt$requiresSyncing() + "\n"); writer.write("== Status: " + sync.quilt$getContentStatus() + "\n"); @@ -119,7 +119,7 @@ private void printReg() { @SuppressWarnings("unchecked") static Identifier register(int i) { var id = new Identifier(NAMESPACE, "entry_" + i); - var block = new Block(AbstractBlock.Settings.method_9630(Blocks.STONE).mapColor(MapColor.BLACK)); + var block = new Block(AbstractBlock.Settings.copy(Blocks.STONE).mapColor(MapColor.BLACK)); Registry.register(Registries.BLOCK, id, block); Registry.register(Registries.ITEM, id, new BlockItem(block, new Item.Settings())); diff --git a/library/core/resource_loader/DISABLE b/library/core/resource_loader/DISABLE deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/library/core/testing/DISABLE b/library/core/testing/DISABLE deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/library/data/DISABLE b/library/data/DISABLE deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/library/entity/entity_extensions/DISABLE b/library/entity/entity_extensions/DISABLE deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/library/gui/tooltip/DISABLE b/library/gui/tooltip/DISABLE deleted file mode 100644 index bec92e9e35..0000000000 --- a/library/gui/tooltip/DISABLE +++ /dev/null @@ -1 +0,0 @@ -Resource loader testmod diff --git a/library/management/command/DISABLE b/library/management/command/DISABLE deleted file mode 100644 index e69de29bb2..0000000000