3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-02 17:40:09 +01:00

Stop writing corrupt tile entities to schematics

also make some stuff definitely immutable.
Dieser Commit ist enthalten in:
dordsor21 2020-12-13 21:06:36 +00:00
Ursprung 04ba545aa2
Commit 6676d77aaa
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
3 geänderte Dateien mit 16 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -159,15 +159,16 @@ public class FastSchematicWriter implements ClipboardWriter {
if (nbt != null) {
Map<String, Tag> values = nbt.getValue();
values.remove("id"); // Remove 'id' if it exists. We want 'Id'
// Positions are kept in NBT, we don't want that.
values.remove("x");
values.remove("y");
values.remove("z");
if (!values.containsKey("Id")) {
values.put("Id", new StringTag(block.getNbtId()));
}
// Remove 'id' if it exists. We want 'Id'.
// Do this after we get "getNbtId" cos otherwise "getNbtId" doesn't work.
// Dum.
values.remove("id");
values.put("Pos", new IntArrayTag(new int[]{
pos.getX(),
pos.getY(),

Datei anzeigen

@ -49,13 +49,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
private BlockState blockState;
@Nullable private CompoundTag nbtData;
@Deprecated
public BaseBlock() {
this(BlockTypes.AIR.getDefaultState());
}
private final BlockState blockState;
@Nullable private final CompoundTag nbtData;
/**
* Construct a block with the given type and default data.
@ -151,6 +146,9 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
return "";
}
Tag idTag = nbtData.getValue().get("id");
if (idTag == null) {
idTag = nbtData.getValue().get("Id");
}
if (idTag instanceof StringTag) {
return ((StringTag) idTag).getValue();
} else {
@ -164,6 +162,11 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
return this.nbtData;
}
@Override
public void setNbtData(@Nullable CompoundTag nbtData) {
throw new UnsupportedOperationException("This class is immutable.");
}
/**
* Checks whether the type ID and data value are equal.
*/