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

1.21.4 discovey recipe invalid packet #303

Open
ewof opened this issue Dec 5, 2024 · 2 comments
Open

1.21.4 discovey recipe invalid packet #303

ewof opened this issue Dec 5, 2024 · 2 comments

Comments

@ewof
Copy link

ewof commented Dec 5, 2024

Stack trace

[04:57:02 ERROR]: Error sending packet clientbound/minecraft:recipe_book_add (skippable? false)
io.netty.handler.codec.EncoderException: Failed to encode packet 'clientbound/minecraft:recipe_book_add'
        at net.minecraft.network.codec.IdDispatchCodec.encode(IdDispatchCodec.java:53) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.IdDispatchCodec.encode(IdDispatchCodec.java:20) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.PacketEncoder.encode(PacketEncoder.java:26) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.PacketEncoder.encode(PacketEncoder.java:12) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:107) ~[netty-codec-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:893) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:875) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:984) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:868) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:113) ~[netty-codec-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:893) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:875) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:984) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:868) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.channel.ChannelOutboundHandlerAdapter.write(ChannelOutboundHandlerAdapter.java:113) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at net.minecraft.network.Connection$2.write(Connection.java:819) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:893) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:875) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:984) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:868) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.channel.ChannelDuplexHandler.write(ChannelDuplexHandler.java:115) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at ItemJoin.jar/me.RockinChaos.itemjoin.core.utils.protocol.TinyProtocol$PacketInterceptor.write(TinyProtocol.java:480) ~[ItemJoin.jar:?]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:891) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:956) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:982) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:950) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:1000) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:974) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:305) ~[netty-transport-4.1.115.Final.jar:4.1.115.Final]
        at net.minecraft.network.Connection.doSendPacket(Connection.java:540) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.Connection.lambda$sendPacket$13(Connection.java:525) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173) ~[netty-common-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166) ~[netty-common-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) ~[netty-common-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:405) ~[netty-transport-classes-epoll-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[netty-common-4.1.115.Final.jar:4.1.115.Final]
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.115.Final.jar:4.1.115.Final]
        at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?]
Caused by: java.lang.RuntimeException: Error encoding component minecraft:equippable
        at net.minecraft.core.component.DataComponentPatch$1.encodeComponent(DataComponentPatch.java:151) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.core.component.DataComponentPatch$1.encode(DataComponentPatch.java:128) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.core.component.DataComponentPatch$1.encode(DataComponentPatch.java:66) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.world.item.ItemStack$1.encode(ItemStack.java:191) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.world.item.ItemStack$1.encode(ItemStack.java:155) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.world.item.ItemStack$2.encode(ItemStack.java:214) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.world.item.ItemStack$2.encode(ItemStack.java:199) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.StreamCodec$7.encode(StreamCodec.java:124) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.StreamCodec$6.encode(StreamCodec.java:109) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.StreamCodec$11.encode(StreamCodec.java:235) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.StreamCodec$6.encode(StreamCodec.java:109) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.StreamCodec$11.encode(StreamCodec.java:233) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.StreamCodec$8.encode(StreamCodec.java:142) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.ByteBufCodecs$21.encode(ByteBufCodecs.java:441) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.ByteBufCodecs$21.encode(ByteBufCodecs.java:423) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.StreamCodec$8.encode(StreamCodec.java:142) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.StreamCodec$5.encode(StreamCodec.java:90) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.StreamCodec$5.encode(StreamCodec.java:80) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        ... 38 more
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.Optional.isPresent()" because "optional" is null
        at net.minecraft.network.codec.ByteBufCodecs$20.encode(ByteBufCodecs.java:389) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.ByteBufCodecs$20.encode(ByteBufCodecs.java:381) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.StreamCodec$14.encode(StreamCodec.java:360) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.core.component.DataComponentPatch$1.encodeComponent(DataComponentPatch.java:149) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.core.component.DataComponentPatch$1.encode(DataComponentPatch.java:128) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.core.component.DataComponentPatch$1.encode(DataComponentPatch.java:66) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.world.item.ItemStack$1.encode(ItemStack.java:191) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.world.item.ItemStack$1.encode(ItemStack.java:155) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.world.item.ItemStack$2.encode(ItemStack.java:214) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.world.item.ItemStack$2.encode(ItemStack.java:199) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.StreamCodec$7.encode(StreamCodec.java:124) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.StreamCodec$6.encode(StreamCodec.java:109) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.StreamCodec$11.encode(StreamCodec.java:235) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.StreamCodec$6.encode(StreamCodec.java:109) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.StreamCodec$11.encode(StreamCodec.java:233) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.StreamCodec$8.encode(StreamCodec.java:142) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.ByteBufCodecs$21.encode(ByteBufCodecs.java:441) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.ByteBufCodecs$21.encode(ByteBufCodecs.java:423) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.StreamCodec$8.encode(StreamCodec.java:142) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.StreamCodec$5.encode(StreamCodec.java:90) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        at net.minecraft.network.codec.StreamCodec$5.encode(StreamCodec.java:80) ~[folia-1.21.4.jar:1.21.4-DEV-d4bc338]
        ... 38 more

Plugin and Datapack List

[04:59:39 INFO]: Server Plugins (70):
[04:59:39 INFO]: Paper Plugins:
[04:59:39 INFO]:  - help, MvndiAchievements, MvndiBattle, MvndiCombat, MvndiCore, MvndiCrafting, MvndiEquipment, MvndiHolders, MvndiHunters, MvndiMisc
[04:59:39 INFO]:  MvndiMMO, MvndiMounts, MvndiPlayers, MvndiRPG, MvndiStats, MvndiTowny, MvndiUI, TownyWaypoints
[04:59:39 INFO]: Bukkit Plugins:
[04:59:39 INFO]:  - Backuper, BetterGUI, BetterHud, BetterRTP, BigDoors, BreweryX, BukkitGreentext, ChatFilter, ChestShop, ChestShop-towny
[04:59:39 INFO]:  Chunky, ChunkyBorder, CommandBlocker, DarkerNights, FarmControl, FlagsH, FreedomChat, HeadDrop, HexNicks, iConomyUnlocked
[04:59:39 INFO]:  InventoryRollbackPlus, InvSeePlusPlus, ItemJoin, LiteBans, LuckPerms, MapTowny, MinecraftSSH, MvndiBanHooks, MvndiChisel, MvndiGUI
[04:59:39 INFO]:  MvndiMenus, MvndiMobs, MvndiSiege, OPItemsRemover, packetevents, PlaceholderAPI, PotionEffectsRemover, SiegeWar, SmoothTimber, spark
[04:59:39 INFO]:  squaremap, SuperVanish, TAB, Towny, TownyBlockGlitch, TownyChat, TownyMenus, TownyResources, UltimateAdvancementAPI, Vault
[04:59:39 INFO]:  VoidWorldGenerator, ZAutoBroadcast

player gets kicked and cant join server

no datapacks

Actions to reproduce (if known)

this is the method in our plugin that causes out (if the discover recipes line is commented out then players can join)

    @org.bukkit.event.EventHandler(priority = EventPriority.LOW)
    public void onPlayerJoin(PlayerJoinEvent e) {
        RecipeManager.setCraftMenuView(e.getPlayer(), CraftMenuView.NONE);
        e.getPlayer().discoverRecipes(recipe_manager.getVanillaRecipes());
    }

Folia version

This server is running Folia version 1.21.4-DEV-dev/1.21.4@d4bc338 (2024-12-05T04:54:20Z) (Implementing API version 1.21.4-R0.1-SNAPSHOT)

Other

it doesnt happen on bb4fb5334e7f7231c86c6ef9951d3eb24db9e6ea

@Spottedleaf
Copy link
Member

I really don't know what that code is doing. You are using some library and haven't said what it is.

I've run /recipe give searchndstroy * on 94d65c3 locally and it works.

I am going to need code that I can run to look at this further.

@ewof
Copy link
Author

ewof commented Dec 8, 2024

sorry the guy who wrote this disappeared awhile ago, when i first looked at it after seeing the crash stack trace i guess i skimmed it and just assumed it was mostly bukkit api my bad
get vanilla recipes is just a getter

    public ArrayList<NamespacedKey> getVanillaRecipes() { return this.vanilla_recipes; }

this is the only function that adds to vanilla_recipes

    private void loadVanillaRecipe(String recipe_name, ItemStack result, HashMap<Character, RecipeItem> dictionary) {
        NamespacedKey recipe_key = new NamespacedKey(plugin, recipe_name);

        // TODO really sloppy, only works with one ingredient shapeless
        if (config.contains(recipe_name + ".shapeless")) {
            ShapelessRecipe recipe = new ShapelessRecipe(recipe_key, result);
            ArrayList<RecipeItem> dict_items = new ArrayList<>(dictionary.values());
            ItemStack itemStack = dict_items.get(0).getItemStack(1);
            recipe.addIngredient(config.getInt(recipe_name + ".shapeless"), itemStack);

            addRecipe(recipe, recipe_key);
            return;
        }
        if (result.getType() == Material.AIR)
            return;
        ShapedRecipe recipe = new ShapedRecipe(recipe_key, result);
        // Add 1, 2 or 3 lines.
        try {
            if (config.getString(recipe_name + ".recipe.shape.bottom") != null) {
                recipe.shape(config.getString(recipe_name + ".recipe.shape.top"), config.getString(recipe_name + ".recipe.shape.middle"),
                        config.getString(recipe_name + ".recipe.shape.bottom"));
            } else if (config.getString(recipe_name + ".recipe.shape.middle") != null) {
                recipe.shape(config.getString(recipe_name + ".recipe.shape.top"), config.getString(recipe_name + ".recipe.shape.middle"));
            } else {
                recipe.shape(config.getString(recipe_name + ".recipe.shape.top"));
            }
    
        } catch (Exception e) {
            MvndiCrafting.getInstance().getLogger().info("Error loading vanilla recipe " + recipe_name);
        }
        for (Character c : dictionary.keySet()) {
            try {
                recipe.setIngredient(c, dictionary.get(c).getRecipeChoice());
            } catch (Exception e) {
                MvndiCrafting.getInstance().getLogger().info("Error loading vanilla recipe ingrediant " + dictionary.get(c).getID() + " in " + recipe_name);
            }
        }

        this.vanilla_recipes.add(recipe_key);
        addRecipe(recipe, recipe_key);
    }

addRecipe on the last line is

    private void addRecipe(Recipe recipe, NamespacedKey key) {
        if (Bukkit.getServer().getRecipe(key) != null)
            Bukkit.getServer().removeRecipe(key);
        Bukkit.getServer().addRecipe(recipe);
    }

it reads from a config that looks like

gunpowder:
  category: Parts
  item:
    type: minecraft
    id: gunpowder
  quantity: 1
  recipe:
    shape:
      top: " R "
      middle: "RDR"
      bottom: " R "
    R:
      type: minecraft
      id: redstone
    D:
      type: minecraft
      id: charcoal

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

No branches or pull requests

2 participants