mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-06 15:52:03 +00:00
添加容器包拦截
This commit is contained in:
@@ -13,6 +13,7 @@ import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import net.momirealms.craftengine.core.world.BlockPos;
|
||||
import net.momirealms.sparrow.nbt.CompoundTag;
|
||||
import net.momirealms.sparrow.nbt.NBT;
|
||||
import net.momirealms.sparrow.nbt.Tag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -316,12 +317,12 @@ public class FriendlyByteBuf extends ByteBuf {
|
||||
return this;
|
||||
}
|
||||
|
||||
public FriendlyByteBuf writeNbt(@Nullable CompoundTag compound) {
|
||||
public FriendlyByteBuf writeNbt(@Nullable Tag compound, boolean named) {
|
||||
if (compound == null) {
|
||||
this.writeByte(0);
|
||||
} else {
|
||||
try {
|
||||
NBT.writeCompound(compound, new ByteBufOutputStream(this));
|
||||
NBT.writeUnnamedTag(compound, new ByteBufOutputStream(this), named);
|
||||
} catch (IOException e) {
|
||||
throw new EncoderException("Failed to write NBT compound: " + e.getMessage(), e);
|
||||
}
|
||||
@@ -330,7 +331,7 @@ public class FriendlyByteBuf extends ByteBuf {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CompoundTag readNbt() {
|
||||
public Tag readNbt(boolean named) {
|
||||
int initialIndex = this.readerIndex();
|
||||
byte marker = this.readByte();
|
||||
if (marker == 0) {
|
||||
@@ -338,7 +339,7 @@ public class FriendlyByteBuf extends ByteBuf {
|
||||
} else {
|
||||
this.readerIndex(initialIndex);
|
||||
try {
|
||||
return NBT.readCompound(new ByteBufInputStream(this));
|
||||
return NBT.readUnnamedTag(new ByteBufInputStream(this), named);
|
||||
} catch (IOException e) {
|
||||
throw new EncoderException("Failed to read NBT compound: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class DefaultRegionFileStorage implements WorldDataStorage {
|
||||
|
||||
private static final int FORMAT_VERSION = 1;
|
||||
private final Path folder;
|
||||
|
||||
public static final String REGION_FILE_SUFFIX = ".mca";
|
||||
@@ -127,7 +127,7 @@ public class DefaultRegionFileStorage implements WorldDataStorage {
|
||||
if (dataInputStream == null) {
|
||||
return null;
|
||||
}
|
||||
tag = NBT.readCompound(dataInputStream);
|
||||
tag = NBT.readCompound(dataInputStream, true);
|
||||
} catch (Throwable t1) {
|
||||
try {
|
||||
dataInputStream.close();
|
||||
@@ -152,7 +152,7 @@ public class DefaultRegionFileStorage implements WorldDataStorage {
|
||||
} else {
|
||||
DataOutputStream dataOutputStream = regionFile.getChunkDataOutputStream(pos);
|
||||
try {
|
||||
NBT.writeCompound(nbt, dataOutputStream);
|
||||
NBT.writeCompound(nbt, dataOutputStream, true);
|
||||
} catch (Throwable t1) {
|
||||
if (dataOutputStream != null) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user