mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-26 15:06:42 +01:00
fix blocks having unsafe nbt values
This commit is contained in:
parent
11787d845f
commit
ac61d249cc
1 changed files with 14 additions and 6 deletions
|
@ -86,14 +86,22 @@ public final class NBTProcessors {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack withUnsafeNBTDiscarded(ItemStack stack) {
|
public static ItemStack withUnsafeNBTDiscarded(ItemStack stack) {
|
||||||
if (stack.getTag() == null)
|
CompoundTag tag = stack.getTag();
|
||||||
|
if (tag == null)
|
||||||
return stack;
|
return stack;
|
||||||
ItemStack copy = stack.copy();
|
ItemStack copy = stack.copy();
|
||||||
stack.getTag()
|
copy.setTag(withUnsafeNBTDiscarded(tag));
|
||||||
.getAllKeys()
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CompoundTag withUnsafeNBTDiscarded(CompoundTag tag) {
|
||||||
|
if (tag == null)
|
||||||
|
return null;
|
||||||
|
CompoundTag copy = tag.copy();
|
||||||
|
tag.getAllKeys()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(NBTProcessors::isUnsafeItemNBTKey)
|
.filter(NBTProcessors::isUnsafeItemNBTKey)
|
||||||
.forEach(copy::removeTagKey);
|
.forEach(copy::remove);
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +144,7 @@ public final class NBTProcessors {
|
||||||
return signProcessor.apply(compound);
|
return signProcessor.apply(compound);
|
||||||
if (blockEntity.onlyOpCanSetNbt())
|
if (blockEntity.onlyOpCanSetNbt())
|
||||||
return null;
|
return null;
|
||||||
return compound;
|
return withUnsafeNBTDiscarded(compound);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue