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] Better Storage for ITEMs #42

Closed
iceBear67 opened this issue Mar 6, 2022 · 6 comments · Fixed by #96
Closed

[FEAT] Better Storage for ITEMs #42

iceBear67 opened this issue Mar 6, 2022 · 6 comments · Fixed by #96
Assignees
Labels
enhancement New feature or request question Further information is requested
Milestone

Comments

@iceBear67
Copy link
Member

a reliable and compat storage for items.

And there are my ideas

  1. Write data into items directly
  2. Pushing extra data into item uuids

The first way seems easiest and most benefit. By this way we can dispose unused items and reduce our work to design such a structure.

The second way might be effective by pushing file index into uuid. However it is not compat because it will produce tons of unused spaces by the time.

We should combine their advantage to solve these following problems.

  1. Lifecycle. Plugins cant monitor that some item jist disposed. And if we dont deal with that we will ran out the disk at last
  2. Compat. We need to minimalize the usage
  3. Effective Cant be too slow
  4. Reliable. Security is also important
@iceBear67 iceBear67 added the enhancement New feature or request label Mar 6, 2022
@iceBear67 iceBear67 self-assigned this Mar 6, 2022
@iceBear67 iceBear67 added the question Further information is requested label Mar 6, 2022
@iceBear67 iceBear67 added this to the Backlog milestone Mar 6, 2022
@iceBear67
Copy link
Member Author

It is ineffectient about filtering the pdc from itemstack.

I will add an option about filter,and AF will get its first magics.

  1. Filtering over packets.
  2. JDK Redefine Magics.
  3. Server patching

@iceBear67
Copy link
Member Author

I found where we should patch.

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 above this.writeNbt(nbttagcompound) would work, however it is leading to full of asm codes.

@iceBear67
Copy link
Member Author

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 )

@iceBear67
Copy link
Member Author

This Optimization (nbt filter) will be separated into another module and introduce as an option.

@iceBear67
Copy link
Member Author

This Optimization (nbt filter) will be separated into another module.

#79

@iceBear67 iceBear67 modified the milestones: Backlog, 0.1.0-M2 Mar 27, 2022
@iceBear67
Copy link
Member Author

This depends on #79

@iceBear67 iceBear67 modified the milestones: 0.1.0-M2, 0.1.0-M3 Apr 2, 2022
@iceBear67 iceBear67 added this to the 0.1.0-M3 milestone Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant