Silent's Gems

Silent's Gems

9M Downloads

Lag in ToolPartPosition

LemADEC opened this issue ยท 0 comments

commented

Versions

Minecraft Version: 1.12.2
Silent's Gems Version: 2.8.2-293
Silent Lib Version: 3.0.1-145
Modpack and Version (if applicable): N/A

Expected behavior

  • No lag

Actual behaviour

  • Lag observed in profiler related to string formatting in ToolPartPosition.getKey()

Steps to reproduce the problem

  1. Fill inventory with pickaxes
  2. Profile!

Here's a single player having a single pickaxe in their inventory:
image

Relevant code is https://github.com/SilentChaos512/SilentGems/blob/1.12/src/main/java/net/silentchaos512/gems/api/lib/ToolPartPosition.java#L43
We can see a systematic formatting of integer into string for every tool, every tick to check if it's blank and need to be randomized. The result is then split with another string operation.
Since a blank item has no NBT, consider doing a simple hasTagCompoung() test here: https://github.com/SilentChaos512/SilentGems/blob/1.12/src/main/java/net/silentchaos512/gems/util/ToolHelper.java#L738 ?