Clone instead of caching

This commit is contained in:
TheMode 2021-04-10 00:25:50 +02:00
parent 5e8e7cbaf4
commit f5b8f267d6
1 changed files with 1 additions and 9 deletions

View File

@ -7,7 +7,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
import java.lang.ref.SoftReference;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -29,8 +28,6 @@ public class ItemMeta {
private final NBTCompound nbt;
private final ItemMetaBuilder emptyBuilder;
private SoftReference<NBTCompound> nbtCache;
protected ItemMeta(@NotNull ItemMetaBuilder metaBuilder) {
this.damage = metaBuilder.damage;
this.unbreakable = metaBuilder.unbreakable;
@ -106,12 +103,7 @@ public class ItemMeta {
}
public @NotNull NBTCompound toNBT() {
NBTCompound cache = nbtCache.get();
if (cache == null) {
cache = nbt.deepClone();
nbtCache = new SoftReference<>(cache);
}
return cache;
return nbt.deepClone();
}
@Override