emilyploszaj / emi

A featureful and accessible item and recipe viewer
MIT License
220 stars 46 forks source link

Flatten ItemEmiStack and store item/NBT directly #519

Closed embeddedt closed 2 months ago

embeddedt commented 2 months ago

Reduces total retained size of ItemEmiStack objects in a test modpack from roughly 145MB -> 70MB. This change shouldn't be visible to mods unless they rely on consistent identity of the returned ItemStack.

emilyploszaj commented 2 months ago

Er, sorry I just remembered there are EmiStack.of methods for items in EmiStack that wastefully construct an itemstack now that this new constructor exists, can you adjust those as well?

embeddedt commented 2 months ago

I am not sure that adjustment would be safe as the default stack might contain NBT (which we cannot retrieve without constructing it, as far as I know).

emilyploszaj commented 2 months ago

Hm. Yeah I guess that's fine then.

emilyploszaj commented 2 months ago

I guess that means the new constructor should be private if we're assuming it can't be safely called

embeddedt commented 2 months ago

I mean, it's fine to call if you have both the item and its NBT already, through some other means. It's no less safe than constructing a stack manually just to pass it to the constructor.

emilyploszaj commented 2 months ago

...I just realized I'm talking about an EmiStack.of method that takes an item, nbt, and amount that I haven't committed yet. I'll handle it myself.