diff --git a/build.gradle b/build.gradle index 6a264db7..3cb849fc 100644 --- a/build.gradle +++ b/build.gradle @@ -119,7 +119,8 @@ loom { } dependencies { -// modLocalRuntime("me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}") + modLocalRuntime("me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}") + modCompileOnly("me.shedaniel:RoughlyEnoughItems-default-plugin:${project.rei_version}") modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:${project.rei_version}") modCompileOnly("dev.emi:emi-fabric:${project.emi_version}") diff --git a/gradle.properties b/gradle.properties index 914a8e1c..71d212a3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,23 +7,23 @@ minecraft_version=1.20.3 yarn_mappings=1.20.3+build.1 loader_version=0.15.0 # Mod Properties -mod_version=0.12.0-pre.5 +mod_version=0.12.0 maven_group=io.wispforest archives_base_name=owo-lib # Dependencies fabric_version=0.91.1+1.20.3 # https://maven.shedaniel.me/me/shedaniel/RoughlyEnoughItems-fabric/ -rei_version=13.0.661 +rei_version=14.0.688 # https://maven.terraformersmc.com/releases/dev/emi/emi-fabric/ -emi_version=1.0.19+1.20.1 +emi_version=1.0.29+1.20.4 # https://search.maven.org/artifact/blue.endless/jankson jankson_version=1.2.2 # https://maven.terraformersmc.com/releases/com/terraformersmc/modmenu -modmenu_version=9.0.0-pre.1 +modmenu_version=9.0.0 # https://maven.nucleoid.xyz/xyz/nucleoid/server-translations-api/ stapi_version=2.2.0+1.20.3-rc1 diff --git a/src/main/java/io/wispforest/owo/compat/rei/OwoReiPlugin.java b/src/main/java/io/wispforest/owo/compat/rei/OwoReiPlugin.java index fb5d1b13..6f3702ea 100644 --- a/src/main/java/io/wispforest/owo/compat/rei/OwoReiPlugin.java +++ b/src/main/java/io/wispforest/owo/compat/rei/OwoReiPlugin.java @@ -20,10 +20,8 @@ import me.shedaniel.rei.api.client.registry.screen.OverlayRendererProvider; import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry; import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents; -import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.RotationAxis; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/io/wispforest/owo/network/OwoHandshake.java b/src/main/java/io/wispforest/owo/network/OwoHandshake.java index 2dff6d43..8ce03f2b 100644 --- a/src/main/java/io/wispforest/owo/network/OwoHandshake.java +++ b/src/main/java/io/wispforest/owo/network/OwoHandshake.java @@ -36,7 +36,6 @@ import java.util.Set; import java.util.function.ToIntFunction; -@SuppressWarnings("UnstableApiUsage") @ApiStatus.Internal public final class OwoHandshake { diff --git a/src/main/java/io/wispforest/owo/network/OwoNetChannel.java b/src/main/java/io/wispforest/owo/network/OwoNetChannel.java index 9f26f559..0eb9ca2e 100644 --- a/src/main/java/io/wispforest/owo/network/OwoNetChannel.java +++ b/src/main/java/io/wispforest/owo/network/OwoNetChannel.java @@ -1,6 +1,7 @@ package io.wispforest.owo.network; import io.wispforest.owo.mixin.ServerCommonNetworkHandlerAccessor; +import io.wispforest.owo.serialization.Endec; import io.wispforest.owo.serialization.endec.RecordEndec; import io.wispforest.owo.serialization.StructEndec; import io.wispforest.owo.serialization.format.bytebuf.ByteBufDeserializer; @@ -37,9 +38,10 @@ /** * An efficient networking abstraction that uses {@code record}s to store * and define packet data. Serialization for most types is fully automatic - * and no custom handling needs to be done, should one of your record - * components be of an unsupported type use {@link PacketBufSerializer#register(Class, PacketByteBuf.PacketWriter, PacketByteBuf.PacketReader)} - * to register a custom serializer. + * and no custom handling needs to be done. + * + *

Should one of your record components be of an unsupported type, either use {@link io.wispforest.owo.serialization.endec.ReflectiveEndecBuilder#register(Endec, Class)} + * to register an appropriate endec, or supply it directly using {@link #registerClientbound(Class, StructEndec, ChannelHandler)} and {@link #registerServerbound(Class, StructEndec, ChannelHandler)} * *

To define a packet class suited for use with this wrapper, simply create a * standard Java {@code record} class and put the desired data into the record header. @@ -56,9 +58,6 @@ * *

The registered packet handlers are executed synchronously on the target environment's * game thread instead of Netty's event loops - there is no need to call {@code .execute(...)} - * - * @see PacketBufSerializer#register(Class, PacketByteBuf.PacketWriter, PacketByteBuf.PacketReader) - * @see PacketBufSerializer#registerCollectionProvider(Class, Supplier) */ public class OwoNetChannel { @@ -129,14 +128,14 @@ private OwoNetChannel(Identifier id, String ownerClassName, boolean required) { ServerPlayNetworking.registerGlobalReceiver(packetId, (server, player, handler, buf, responseSender) -> { int handlerIndex = buf.readVarInt(); - final Record message = serializersByIndex.get(handlerIndex).serializer.decodeFully(ByteBufDeserializer::new, buf); + final Record message = serializersByIndex.get(handlerIndex).endec.decodeFully(ByteBufDeserializer::new, buf); server.execute(() -> serverHandlers.get(handlerIndex).handle(message, new ServerAccess(player))); }); if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { ClientPlayNetworking.registerGlobalReceiver(packetId, (client, handler, buf, responseSender) -> { int handlerIndex = buf.readVarInt(); - final Record message = serializersByIndex.get(-handlerIndex).serializer.decodeFully(ByteBufDeserializer::new, buf); + final Record message = serializersByIndex.get(-handlerIndex).endec.decodeFully(ByteBufDeserializer::new, buf); client.execute(() -> clientHandlers.get(handlerIndex).handle(message, new ClientAccess(handler))); }); } @@ -162,9 +161,7 @@ private OwoNetChannel(Identifier id, String ownerClassName, boolean required) { * @see #serverHandle(PlayerEntity) * @see #serverHandle(MinecraftServer) * @see #serverHandle(ServerWorld, BlockPos) - * @see PacketBufSerializer#register(Class, PacketByteBuf.PacketWriter, PacketByteBuf.PacketReader) */ - @SuppressWarnings("unchecked") public void registerClientbound(Class messageClass, ChannelHandler handler) { registerClientbound(messageClass, handler, () -> RecordEndec.create(messageClass)); } @@ -178,7 +175,6 @@ public void registerClientbound(Class messageClass, Channe * @see #serverHandle(PlayerEntity) * @see #serverHandle(MinecraftServer) * @see #serverHandle(ServerWorld, BlockPos) - * @see PacketBufSerializer#register(Class, PacketByteBuf.PacketWriter, PacketByteBuf.PacketReader) */ public void registerClientboundDeferred(Class messageClass) { registerClientboundDeferred(messageClass, () -> RecordEndec.create(messageClass)); @@ -192,9 +188,7 @@ public void registerClientboundDeferred(Class messageClass * @param messageClass The type of packet data to send and serialize * @param handler The handler that will receive the deserialized * @see #clientHandle() - * @see PacketBufSerializer#register(Class, PacketByteBuf.PacketWriter, PacketByteBuf.PacketReader) */ - @SuppressWarnings("unchecked") public void registerServerbound(Class messageClass, ChannelHandler handler) { registerServerbound(messageClass, handler, () -> RecordEndec.create(messageClass)); } @@ -212,9 +206,7 @@ public void registerServerbound(Class messageClass, Channe * @see #serverHandle(PlayerEntity) * @see #serverHandle(MinecraftServer) * @see #serverHandle(ServerWorld, BlockPos) - * @see PacketBufSerializer#register(Class, PacketByteBuf.PacketWriter, PacketByteBuf.PacketReader) */ - @SuppressWarnings("unchecked") public void registerClientbound(Class messageClass, StructEndec endec, ChannelHandler handler) { registerClientbound(messageClass, handler, () -> endec); } @@ -229,7 +221,6 @@ public void registerClientbound(Class messageClass, Struct * @see #serverHandle(PlayerEntity) * @see #serverHandle(MinecraftServer) * @see #serverHandle(ServerWorld, BlockPos) - * @see PacketBufSerializer#register(Class, PacketByteBuf.PacketWriter, PacketByteBuf.PacketReader) */ public void registerClientboundDeferred(Class messageClass, StructEndec endec) { registerClientboundDeferred(messageClass, () -> endec); @@ -244,9 +235,7 @@ public void registerClientboundDeferred(Class messageClass * @param endec The alternative Endec to Serialize the given Record * @param handler The handler that will receive the deserialized * @see #clientHandle() - * @see PacketBufSerializer#register(Class, PacketByteBuf.PacketWriter, PacketByteBuf.PacketReader) */ - @SuppressWarnings("unchecked") public void registerServerbound(Class messageClass, StructEndec endec, ChannelHandler handler) { registerServerbound(messageClass, handler, () -> endec); } @@ -443,7 +432,7 @@ private PacketByteBuf encode(R message, EnvType target) { } buffer.writeVarInt(serializer.handlerIndex(target)); - return serializer.serializer.encodeFully(() -> new ByteBufSerializer<>(buffer), message); + return serializer.endec.encodeFully(() -> new ByteBufSerializer<>(buffer), message); } public class ClientHandle { @@ -548,7 +537,7 @@ public interface EnvironmentAccess

{ private void verify() { if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { - if (deferredClientSerializers.size() > 0) { + if (!this.deferredClientSerializers.isEmpty()) { throw new NetworkException("Some deferred client handlers for channel " + packetId + " haven't been registered: " + deferredClientSerializers.keySet().stream().map(Class::getName).collect(Collectors.joining(", "))); } } @@ -566,16 +555,16 @@ static final class IndexedSerializer { private int clientHandlerIndex = -1; private int serverHandlerIndex = -1; - final Class rClass; - final StructEndec serializer; + private final Class recordClass; + private final StructEndec endec; - private IndexedSerializer(Class rClass, StructEndec serializer) { - this.serializer = serializer; - this.rClass = rClass; + private IndexedSerializer(Class recordClass, StructEndec endec) { + this.endec = endec; + this.recordClass = recordClass; } - public static IndexedSerializer create(Class rClass, StructEndec serializer, int index, EnvType target) { - return new IndexedSerializer<>(rClass, serializer).setHandlerIndex(index, target); + public static IndexedSerializer create(Class rClass, StructEndec endec, int index, EnvType target) { + return new IndexedSerializer<>(rClass, endec).setHandlerIndex(index, target); } public IndexedSerializer setHandlerIndex(int index, EnvType target) { @@ -594,7 +583,7 @@ public int handlerIndex(EnvType target) { } public Class getRecordClass(){ - return this.rClass; + return this.recordClass; } } }