Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fabric] [1.19] SyncedProperty<T> on a ScreenHandler doesn't work at all #352

Open
Jankoy opened this issue Feb 7, 2025 · 4 comments
Open

Comments

@Jankoy
Copy link

Jankoy commented Feb 7, 2025

I'm trying to write a handled screen for a block entity, and using regular owo-lib networking works fine, but if I try to use synced properties like in the example mod, it just doesn't work. It doesn't sync at all. I don't know if I'm missing something or if it just doesn't work. If I'm missing something it would be really helpful to add exact steps to the documentation.

@Jankoy
Copy link
Author

Jankoy commented Feb 7, 2025

Turns out I do get a weird error with the ScreenHander packet sending. Sometimes I get an error for accessing index zero of an array with size zero in the mixin.

[22:46:39] [Netty Local Client IO #0/ERROR] (ClientPlayNetworkAddon for Player418) Encountered exception while handling in channel with name "owo:local_packet"
 java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
	at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[?:?]
	at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) ~[?:?]
	at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) ~[?:?]
	at java.util.Objects.checkIndex(Objects.java:361) ~[?:?]
	at java.util.ArrayList.get(ArrayList.java:427) ~[?:?]
	at net.minecraft.screen.ScreenHandler.owo$handlePacket(ScreenHandler.java:1747) ~[minecraft-merged-f2f8a096fc-1.19.2-net.fabricmc.yarn.1_19_2.1.19.2+build.28-v2.jar:?]
	at io.wispforest.owo.client.screens.ScreenInternals$Client.lambda$init$1(ScreenInternals.java:50) ~[owo-lib-0.9.3+1.19.jar:?]
	at net.fabricmc.fabric.impl.networking.client.ClientPlayNetworkAddon.receive(ClientPlayNetworkAddon.java:106) ~[fabric-networking-api-v1-1.2.12+def3f86d90.jar:?]
	at net.fabricmc.fabric.impl.networking.client.ClientPlayNetworkAddon.receive(ClientPlayNetworkAddon.java:42) ~[fabric-networking-api-v1-1.2.12+def3f86d90.jar:?]
	at net.fabricmc.fabric.impl.networking.AbstractChanneledNetworkAddon.handle(AbstractChanneledNetworkAddon.java:101) [fabric-networking-api-v1-1.2.12+def3f86d90.jar:?]
	at net.fabricmc.fabric.impl.networking.client.ClientPlayNetworkAddon.handle(ClientPlayNetworkAddon.java:98) [fabric-networking-api-v1-1.2.12+def3f86d90.jar:?]
	at net.minecraft.client.network.ClientPlayNetworkHandler.handler$zjd000$fabric-networking-api-v1$handleCustomPayload(ClientPlayNetworkHandler.java:2533) [minecraft-merged-f2f8a096fc-1.19.2-net.fabricmc.yarn.1_19_2.1.19.2+build.28-v2.jar:?]
	at net.minecraft.client.network.ClientPlayNetworkHandler.onCustomPayload(ClientPlayNetworkHandler.java) [minecraft-merged-f2f8a096fc-1.19.2-net.fabricmc.yarn.1_19_2.1.19.2+build.28-v2.jar:?]
	at net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket.apply(CustomPayloadS2CPacket.java:56) [minecraft-merged-f2f8a096fc-1.19.2-net.fabricmc.yarn.1_19_2.1.19.2+build.28-v2.jar:?]
	at net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket.apply(CustomPayloadS2CPacket.java:32) [minecraft-merged-f2f8a096fc-1.19.2-net.fabricmc.yarn.1_19_2.1.19.2+build.28-v2.jar:?]
	at net.minecraft.network.ClientConnection.handlePacket(ClientConnection.java:173) [minecraft-merged-f2f8a096fc-1.19.2-net.fabricmc.yarn.1_19_2.1.19.2+build.28-v2.jar:?]
	at net.minecraft.network.ClientConnection.channelRead0(ClientConnection.java:159) [minecraft-merged-f2f8a096fc-1.19.2-net.fabricmc.yarn.1_19_2.1.19.2+build.28-v2.jar:?]
	at net.minecraft.network.ClientConnection.channelRead0(ClientConnection.java:65) [minecraft-merged-f2f8a096fc-1.19.2-net.fabricmc.yarn.1_19_2.1.19.2+build.28-v2.jar:?]
	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99) [netty-transport-4.1.77.Final.jar:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.77.Final.jar:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.77.Final.jar:?]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.77.Final.jar:?]
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) [netty-transport-4.1.77.Final.jar:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.77.Final.jar:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.77.Final.jar:?]
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) [netty-transport-4.1.77.Final.jar:?]
	at io.netty.channel.local.LocalChannel.readInbound(LocalChannel.java:299) [netty-transport-4.1.77.Final.jar:?]
	at io.netty.channel.local.LocalChannel.finishPeerRead0(LocalChannel.java:445) [netty-transport-4.1.77.Final.jar:?]
	at io.netty.channel.local.LocalChannel.access$400(LocalChannel.java:50) [netty-transport-4.1.77.Final.jar:?]
	at io.netty.channel.local.LocalChannel$5.run(LocalChannel.java:403) [netty-transport-4.1.77.Final.jar:?]
	at io.netty.util.concurrent.AbstractEventExecutor.runTask$$$capture(AbstractEventExecutor.java:174) [netty-common-4.1.77.Final.jar:?]
	at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java) [netty-common-4.1.77.Final.jar:?]
	at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54) [netty-transport-4.1.77.Final.jar:?]
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:995) [netty-common-4.1.77.Final.jar:?]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-common-4.1.77.Final.jar:?]
	at java.lang.Thread.run(Thread.java:840) [?:?]

@gliscowo
Copy link
Member

gliscowo commented Mar 1, 2025

While I won't be able to really provide you with much support in way of fixes to the library (1.19 has long reached end-of-support), I might be able to help you use it.

Could you maybe provide some more context on the surrounding code and your usage of properties? I should point out again (although I do believe this is stated in the docs and thus I assume you know it) that they only sync from server to client, not vice-versa.

Cheers

@Jankoy
Copy link
Author

Jankoy commented Mar 7, 2025

Which docs are you referencing? The only docs I know of don't mention synced properties at all.

@Dragon-Seeker
Copy link
Member

I assume they are referring to java docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants