mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
Part 1 of upstream merge and format
This commit is contained in:
@ -35,21 +35,21 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import com.sk89q.worldedit.world.storage.InvalidFormatException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class AnvilChunk implements Chunk {
|
||||
|
||||
private CompoundTag rootTag;
|
||||
private byte[][] blocks;
|
||||
private byte[][] blocksAdd;
|
||||
private byte[][] data;
|
||||
private int rootX;
|
||||
private int rootZ;
|
||||
private final CompoundTag rootTag;
|
||||
private final byte[][] blocks;
|
||||
private final byte[][] blocksAdd;
|
||||
private final byte[][] data;
|
||||
private final int rootX;
|
||||
private final int rootZ;
|
||||
|
||||
private Map<BlockVector3, Map<String,Tag>> tileEntities;
|
||||
private Map<BlockVector3, Map<String, Tag>> tileEntities;
|
||||
|
||||
/**
|
||||
* Construct the chunk with a compound tag.
|
||||
@ -85,14 +85,14 @@ public class AnvilChunk implements Chunk {
|
||||
}
|
||||
|
||||
blocks[y] = NBTUtils.getChildTag(sectionTag.getValue(),
|
||||
"Blocks", ByteArrayTag.class).getValue();
|
||||
"Blocks", ByteArrayTag.class).getValue();
|
||||
data[y] = NBTUtils.getChildTag(sectionTag.getValue(), "Data",
|
||||
ByteArrayTag.class).getValue();
|
||||
ByteArrayTag.class).getValue();
|
||||
|
||||
// 4096 ID block support
|
||||
if (sectionTag.getValue().containsKey("Add")) {
|
||||
blocksAdd[y] = NBTUtils.getChildTag(sectionTag.getValue(),
|
||||
"Add", ByteArrayTag.class).getValue();
|
||||
"Add", ByteArrayTag.class).getValue();
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,17 +100,16 @@ public class AnvilChunk implements Chunk {
|
||||
for (byte[] block : blocks) {
|
||||
if (block.length != sectionsize) {
|
||||
throw new InvalidFormatException(
|
||||
"Chunk blocks byte array expected " + "to be "
|
||||
+ sectionsize + " bytes; found "
|
||||
+ block.length);
|
||||
"Chunk blocks byte array expected " + "to be " + sectionsize + " bytes; found "
|
||||
+ block.length);
|
||||
}
|
||||
}
|
||||
|
||||
for (byte[] aData : data) {
|
||||
if (aData.length != (sectionsize / 2)) {
|
||||
throw new InvalidFormatException("Chunk block data byte array "
|
||||
+ "expected to be " + sectionsize + " bytes; found "
|
||||
+ aData.length);
|
||||
throw new InvalidFormatException(
|
||||
"Chunk block data byte array " + "expected to be " + sectionsize
|
||||
+ " bytes; found " + aData.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -177,12 +176,9 @@ public class AnvilChunk implements Chunk {
|
||||
|
||||
/**
|
||||
* Used to load the tile entities.
|
||||
*
|
||||
* @throws DataException
|
||||
*/
|
||||
private void populateTileEntities() throws DataException {
|
||||
List<Tag> tags = NBTUtils.getChildTag(rootTag.getValue(),
|
||||
"TileEntities", ListTag.class).getValue();
|
||||
List<Tag> tags = NBTUtils.getChildTag(rootTag.getValue(), "TileEntities", ListTag.class).getValue();
|
||||
|
||||
tileEntities = new HashMap<>();
|
||||
|
||||
@ -216,6 +212,8 @@ public class AnvilChunk implements Chunk {
|
||||
z = ((IntTag) entry.getValue()).getValue();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
@ -256,7 +254,8 @@ public class AnvilChunk implements Chunk {
|
||||
|
||||
BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(id, data);
|
||||
if (state == null) {
|
||||
WorldEdit.logger.warn("Unknown legacy block " + id + ":" + data + " found when loading legacy anvil chunk.");
|
||||
WorldEdit.logger.warn("Unknown legacy block " + id + ":" + data
|
||||
+ " found when loading legacy anvil chunk.");
|
||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||
}
|
||||
CompoundTag tileEntity = getBlockTileEntity(position);
|
||||
|
@ -35,10 +35,10 @@ import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.storage.InvalidFormatException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* The chunk format for Minecraft 1.13 and newer
|
||||
|
Reference in New Issue
Block a user