FastAsyncWorldEdit

FastAsyncWorldEdit

245k Downloads

Optimize/Replace the "onPlayerInteract()"

Closed this issue ยท 1 comments

commented

What feature do you want to see added?

WorldEdit implementation of the "onPlayerInteract()" that check if your hand's tool is a worldedit stick or not isn't optimized well.
I already reported it to them and they said "remove worldedit if you want to save 0.2% of your tick".
It's "only" 0.2-0.3% of the tick, but for only one plugin, and with 50-60 plugins like that it's some % that can be saved to allows more players on the server.

By changing this method it would allow the plugin to run on the background without taking any % for "nothing".

Here is the spark with the latest dev build on 1.21.4 : https://spark.lucko.me/oFOQ3RATqs

  • I just used a vanilla pickaxe and added a lore to it using essentials (the lore check seems heavier than just vanilla item with only enchants)
Image - I mined in the nether with haste 2 - On prod with tons of players it's still at 0.2-0.3% of the tick for the same event

Are there any alternatives?

Tested worldedit and FAWE, they use the same event
Make a PR into worldedit plugin, but :

  • They maybe won't accept the PR

Could also just fork worldedit, but every new version I'll need to fork it again

Anything else?

No response

commented

I guess we could put the whole piping through the codec into the supplier for the LazyReference, as the NBT is not regularly accessed. Should save a bit of resources and is generally the more sensible thing to do ig.
We just have to make sure to keep it memory safe.

final ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
final net.minecraft.nbt.Tag tag = COMPONENTS_CODEC.encodeStart(
registryAccess.createSerializationContext(NbtOps.INSTANCE),
nmsStack.getComponentsPatch()
).getOrThrow();
return new BaseItemStack(
BukkitAdapter.asItemType(itemStack.getType()),
LazyReference.from(() -> (LinCompoundTag) toNativeLin(tag)),
itemStack.getAmount()
);