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

ShapedRecipe error on join #10748

Closed
NickCloudAT opened this issue May 19, 2024 · 16 comments
Closed

ShapedRecipe error on join #10748

NickCloudAT opened this issue May 19, 2024 · 16 comments
Labels
type: bug Something doesn't work as it was intended to. version: 1.20.6 Game version 1.20.6

Comments

@NickCloudAT
Copy link

NickCloudAT commented May 19, 2024

Expected behavior

Joining the Server normaly, not getting an error

Observed/Actual behavior

When joining the server, getting an error and getting kicked.

Steps/models to reproduce

Create a Plugin with the following code for a custom ShapedRecipe:

        final ShapedRecipe bundleRecipe = new ShapedRecipe(new NamespacedKey(Main.getInstance(), "WinterCraftCoreBundle"), new ItemStack(Material.BUNDLE, 1));
        bundleRecipe.shape("SLS", "LAL", "LLL");
        bundleRecipe.setIngredient('S', Material.STRING);
        bundleRecipe.setIngredient('L', Material.LEATHER);
        bundleRecipe.setIngredient('A', Material.AIR);

        Main.getInstance().getServer().addRecipe(bundleRecipe);

This Code worked prior to Paper 1.20.6.

Plugin and Datapack List

No datapacks, only my own plugin which adds the recipe above

Paper version

This server is running Paper version 1.20.6-82-master@0ad09de (2024-05-18T20:25:01Z) (Implementing API version 1.20.6-R0.1-SNAPSHOT)

Other

Error I get when joining:

[14:41:54 INFO]: UUID of player NickCloud is aa162c9f-0772-446c-9acb-31c8a4ac0adb [14:41:55 INFO]: [+] NickCloud [14:41:55 ERROR]: Error sending packet clientbound/minecraft:update_recipes (skippable? false) io.netty.handler.codec.EncoderException: Failed to encode packet 'clientbound/minecraft:update_recipes' at net.minecraft.network.codec.IdDispatchCodec.encode(IdDispatchCodec.java:53) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at net.minecraft.network.codec.IdDispatchCodec.encode(IdDispatchCodec.java:20) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at net.minecraft.network.PacketEncoder.encode(PacketEncoder.java:26) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at net.minecraft.network.PacketEncoder.encode(PacketEncoder.java:12) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:107) ~[netty-codec-4.1.97.Final.jar:4.1.97.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:881) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:863) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:968) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:856) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final] at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:113) ~[netty-codec-4.1.97.Final.jar:4.1.97.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:881) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:863) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:968) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:856) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final] at io.netty.channel.ChannelOutboundHandlerAdapter.write(ChannelOutboundHandlerAdapter.java:113) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final] at net.minecraft.network.Connection$2.write(Connection.java:749) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:881) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:940) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:966) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final] at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:934) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final] at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:984) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final] at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1025) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final] at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:306) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final] at net.minecraft.network.Connection.doSendPacket(Connection.java:504) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at net.minecraft.network.Connection.lambda$sendPacket$13(Connection.java:489) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) ~[netty-common-4.1.97.Final.jar:4.1.97.Final] at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167) ~[netty-common-4.1.97.Final.jar:4.1.97.Final] at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) ~[netty-common-4.1.97.Final.jar:4.1.97.Final] at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:413) ~[netty-transport-classes-epoll-4.1.97.Final.jar:4.1.97.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[netty-common-4.1.97.Final.jar:4.1.97.Final] at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.97.Final.jar:4.1.97.Final] at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?] Caused by: io.netty.handler.codec.EncoderException: Empty ItemStack not allowed at net.minecraft.world.item.ItemStack$2.encode(ItemStack.java:214) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at net.minecraft.world.item.ItemStack$2.encode(ItemStack.java:201) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at net.minecraft.network.codec.ByteBufCodecs$19.encode(ByteBufCodecs.java:413) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at net.minecraft.network.codec.ByteBufCodecs$19.encode(ByteBufCodecs.java:395) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at net.minecraft.network.codec.StreamCodec$4.encode(StreamCodec.java:72) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at net.minecraft.world.item.crafting.ShapedRecipePattern.toNetwork(ShapedRecipePattern.java:167) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at net.minecraft.network.codec.StreamCodec$2.encode(StreamCodec.java:38) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at net.minecraft.world.item.crafting.ShapedRecipe$Serializer.toNetwork(ShapedRecipe.java:208) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at net.minecraft.network.codec.StreamCodec$1.encode(StreamCodec.java:24) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at net.minecraft.network.codec.StreamCodec$6.encode(StreamCodec.java:107) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at net.minecraft.network.codec.StreamCodec$8.encode(StreamCodec.java:141) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at net.minecraft.network.codec.ByteBufCodecs$19.encode(ByteBufCodecs.java:413) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at net.minecraft.network.codec.ByteBufCodecs$19.encode(ByteBufCodecs.java:395) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at net.minecraft.network.codec.StreamCodec$7.encode(StreamCodec.java:122) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at net.minecraft.network.codec.StreamCodec$5.encode(StreamCodec.java:88) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] at net.minecraft.network.codec.StreamCodec$5.encode(StreamCodec.java:78) ~[paper-1.20.6.jar:1.20.6-82-0ad09de] ... 32 more [14:41:55 INFO]: NickCloud[/46.57.89.116:59729] logged in with entity id 60 at ([world]-112.45268948341727, 75.0, -59.66880202521697) [14:41:56 INFO]: NickCloud lost connection: Internal Exception: io.netty.handler.codec.EncoderException: Failed to encode packet 'clientbound/minecraft:update_recipes' [14:41:57 INFO]: [-] NickCloud

@NickCloudAT NickCloudAT added status: needs triage type: bug Something doesn't work as it was intended to. labels May 19, 2024
@papermc-sniffer papermc-sniffer bot added the version: 1.20.6 Game version 1.20.6 label May 19, 2024
@papermc-projects papermc-projects bot moved this to 🕑 Needs Triage in Issues: Bugs May 19, 2024
@electronicboy
Copy link
Member

#10710 - I'd guess this is basically the fix here

@NickCloudAT
Copy link
Author

#10710 - I'd guess this is basically the fix here

Ah, I see.
If that's already a PR I guess I will have to wait then.

@Machine-Maker
Copy link
Member

Machine-Maker commented May 19, 2024

I think you mis-understood what that PR does. It will continue to throw an error when you create a recipe, it will just do it earlier. air is no longer a valid ingredient. If we didn't add early error checking, you would instead get an error when a player joined and the server tried to send the recipe packet to the player.

That PR adds an "empty" recipe choice for very specific recipes that allow empty ingredients.

@NickCloudAT
Copy link
Author

I think you mis-understood what that PR does. It will continue to throw an error when you create a recipe, it will just do it earlier. air is no longer a valid ingredient. If we didn't add early error checking, you would instead get an error when a player joined and the server tried to send the recipe packet to the player.

That PR adds an "empty" recipe choice for very specific recipes that allow empty ingredients.

Ah ok.
And in the current API, can I even (and how?) create a recipe with empty slots?

@electronicboy
Copy link
Member

oh, but then that confuses me, what is the answer for an ingredient with an empty hole? I've not touched that API in a short while

@masmc05
Copy link
Contributor

masmc05 commented May 19, 2024

Try to use space as a char and don't try to define it

@NickCloudAT
Copy link
Author

Try to use space as a char and don't try to define it

Damn, yes you are right that works.. Thanks.

Was/is this change documented somewhere? I never would have thought about trying that... Also not sure if I should close this issue with that now...

@Machine-Maker
Copy link
Member

Using a space to signify emptiness isn't a new thing. If it's not in the javadocs, it probably should be.

@NickCloudAT
Copy link
Author

NickCloudAT commented May 19, 2024

Using a space to signify emptiness isn't a new thing. If it's not in the javadocs, it probably should be.

Yeah a space should be quite obvious I guess.. But I was so used to it needing to be a material I guess.

@masmc05
Copy link
Contributor

masmc05 commented May 19, 2024

I looked at the code and seems like this was always the supported method, which copied the vanilla, while adding air was just not prevented, which now adds restrictions

Also bukkit doesn't limit you to use only space as emptiness, unlike vanilla. Just as long as you don't define the char, it will mean emptiness, but space will ensure no future incompatibility, since it's the same as vanilla

@electronicboy
Copy link
Member

Yea, I don't recall seeing this doc'd on the wiki (as in, the entire recipe system? or in the JDs; I thought it would scream if you didn't define a char, but, I guess that's only in some recipe types? This is, fun

@NickCloudAT
Copy link
Author

Ok if this has always worked then I guess I just never tried it nor questioned it "needing" a material and all chars defined..

I guess I can close this issue with that though as it's not a bug in paper I would say.

@github-project-automation github-project-automation bot moved this from 🕑 Needs Triage to Done in Issues: Bugs May 19, 2024
@papermc-projects papermc-projects bot moved this from Done to Invalid in Issues: Bugs May 19, 2024
@electronicboy
Copy link
Member

There is a documentation issue here, however

@NickCloudAT
Copy link
Author

There is a documentation issue here, however

Yeah, but would this not fall und paper/docs?

@electronicboy
Copy link
Member

Yes, I've raised a seperate issue for a docs page; though, I have no idea if somebody wants to look at the javadocs

@NickCloudAT
Copy link
Author

Yes, I've raised a seperate issue for a docs page; though, I have no idea if somebody wants to look at the javadocs

Ah, thanks for opening that.. I guess we will see if anyone takes a look.
Maybe you want to reference this issue here for them to at least have a discussion point?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something doesn't work as it was intended to. version: 1.20.6 Game version 1.20.6
Projects
Status: Invalid
Development

No branches or pull requests

5 participants