Fix more NBT mutability issues

This commit is contained in:
dordsor21
2021-01-06 18:00:40 +00:00
parent 1b870c5d78
commit 7afddcc411
3 changed files with 9 additions and 4 deletions

View File

@ -112,7 +112,7 @@ public class BlockBagChangeSet extends AbstractDelegateChangeSet {
@Override
public void addTileCreate(CompoundTag nbt) {
if (nbt.containsKey("items")) {
Map<String, Tag> map = nbt.getValue();
Map<String, Tag> map = new HashMap<>(nbt.getValue());
map.remove("items");
}
super.addTileCreate(nbt);

View File

@ -13,6 +13,7 @@ import com.sk89q.worldedit.world.NbtValued;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
@ -55,10 +56,11 @@ public class StripNBTExtent extends AbstractDelegateExtent {
return block;
}
CompoundTag nbt = localBlock.getNbtData();
Map<String, Tag> value = nbt.getValue();
Map<String, Tag> value = new HashMap<>(nbt.getValue());
for (String key : strip) {
value.remove(key);
}
localBlock.setNbtData(new CompoundTag(value));
return (B) localBlock;
}
@ -67,10 +69,11 @@ public class StripNBTExtent extends AbstractDelegateExtent {
return entity;
}
CompoundTag nbt = entity.getNbtData();
Map<String, Tag> value = nbt.getValue();
Map<String, Tag> value = new HashMap<>(nbt.getValue());
for (String key : strip) {
value.remove(key);
}
entity.setNbtData(new CompoundTag(value));
return entity;
}
}