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

[FEAT] The PDC Filter #79

Open
iceBear67 opened this issue Mar 26, 2022 · 4 comments
Open

[FEAT] The PDC Filter #79

iceBear67 opened this issue Mar 26, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request priority: low
Milestone

Comments

@iceBear67
Copy link
Member

iceBear67 commented Mar 26, 2022

To reduce meaningless bandwidth overheads caused by #42 (with PDC), PDC Filter is set.

Patch

By redefine.

At FriendlyByteBuf (Paper, called PacketDataSerializer in spigot)

    public FriendlyByteBuf writeItem(ItemStack stack) {
        if (stack.isEmpty() || stack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem()
            this.writeBoolean(false);
        } else {
            this.writeBoolean(true);
            Item item = stack.getItem();

            this.writeVarInt(Item.getId(item));
            this.writeByte(stack.getCount());
            CompoundTag nbttagcompound = null;

            if (item.canBeDepleted() || item.shouldOverrideMultiplayerNbt()) {
                // Spigot start - filter
                stack = stack.copy();
                // CraftItemStack.setItemMeta(stack, CraftItemStack.getItemMeta(stack)); // Paper - This is no longer needed due to NBT being supported
                // Spigot end
                nbttagcompound = stack.getTag();
                // Paper start
                if (nbttagcompound != null && nbttagcompound.contains("SkullOwner", 10)) {
                    CompoundTag owner = nbttagcompound.getCompound("SkullOwner");
                    if (owner.hasUUID("Id")) {
                        nbttagcompound.putUUID("SkullOwnerOrig", owner.getUUID("Id"));
                        net.minecraft.world.level.block.entity.SkullBlockEntity.sanitizeUUID(owner);
                    }
                }
                // Paper end
            }

            this.writeNbt(nbttagcompound);
        }

        return this;
    }

Inserting hooks before this.writeNbt(nbttagcompound) would work, however it is leading to full of asm codes.

Tasks

So here're our tasks:

  1. Find CompoundTag in obfuscated environments. (including 1.18+, treat them as obfuscated)
  2. Find FriendlyByteBuf / PacketDataSerializer in obfuscated environments.
  3. Determine injector solution. Predefine or redefine or server patching? I prefer redefine with mixin but there're no projects has implemented mixin injection for bukkit ( or poor API )

Other

This feature is an option and disabled by default.

@iceBear67 iceBear67 added enhancement New feature or request priority: low labels Mar 26, 2022
@iceBear67 iceBear67 added this to the Backlog milestone Mar 26, 2022
@iceBear67 iceBear67 self-assigned this Mar 26, 2022
@iceBear67 iceBear67 modified the milestones: Backlog, 0.1.0-M3 Apr 2, 2022
@iceBear67
Copy link
Member Author

We will need to handle creative item actions due to minecraft feature. Players in creative mode sends itemstack data from their client, which overrides server-side item even though it has pdc or sth else.

@iceBear67
Copy link
Member Author

I ve heard something from paper-dev. They said the limitation isnt too small

I will try it later

@iceBear67
Copy link
Member Author

Internal Exception: net.minecraft.network.PacketEncoder$PacketTooLargeException: PacketTooLarge - PacketPlayOutSetSlot is 5000438. Max is 2097152

And that means we can store ~2M data in one pdc, that's fully enough for many situations.

@iceBear67 iceBear67 modified the milestones: 0.1.0-M3, Backlog Apr 3, 2022
@iceBear67
Copy link
Member Author

We will not work on this for this moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority: low
Projects
None yet
Development

No branches or pull requests

1 participant