cn.nukkit.nbt.tag.IntArrayTag Java Examples
The following examples show how to use
cn.nukkit.nbt.tag.IntArrayTag.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Chunk.java From Jupiter with GNU General Public License v3.0 | 4 votes |
public Chunk(LevelProvider level, CompoundTag nbt) { this.provider = level; if (level != null) { this.providerClass = level.getClass(); } if (nbt == null) { this.nbt = new CompoundTag("Level"); return; } this.nbt = nbt; if (!(this.nbt.contains("Entities") && (this.nbt.get("Entities") instanceof ListTag))) { this.nbt.putList(new ListTag<CompoundTag>("Entities")); } if (!(this.nbt.contains("TileEntities") && (this.nbt.get("TileEntities") instanceof ListTag))) { this.nbt.putList(new ListTag<CompoundTag>("TileEntities")); } if (!(this.nbt.contains("TileTicks") && (this.nbt.get("TileTicks") instanceof ListTag))) { this.nbt.putList(new ListTag<CompoundTag>("TileTicks")); } if (!(this.nbt.contains("BiomeColors") && (this.nbt.get("BiomeColors") instanceof IntArrayTag))) { this.nbt.putIntArray("BiomeColors", new int[256]); } if (!(this.nbt.contains("HeightMap") && (this.nbt.get("HeightMap") instanceof IntArrayTag))) { this.nbt.putIntArray("HeightMap", new int[256]); } if (!(this.nbt.contains("Blocks"))) { this.nbt.putByteArray("Blocks", new byte[32768]); } if (!(this.nbt.contains("Data"))) { this.nbt.putByteArray("Data", new byte[16384]); this.nbt.putByteArray("SkyLight", new byte[16384]); this.nbt.putByteArray("BlockLight", new byte[16384]); } Map<Integer, Integer> extraData = new HashMap<>(); if (!this.nbt.contains("ExtraData") || !(this.nbt.get("ExtraData") instanceof ByteArrayTag)) { this.nbt.putByteArray("ExtraData", Binary.writeInt(0)); } else { BinaryStream stream = new BinaryStream(this.nbt.getByteArray("ExtraData")); for (int i = 0; i < stream.getInt(); i++) { int key = stream.getInt(); extraData.put(key, stream.getShort()); } } this.x = this.nbt.getInt("xPos"); this.z = this.nbt.getInt("zPos"); this.blocks = this.nbt.getByteArray("Blocks"); this.data = this.nbt.getByteArray("Data"); this.skyLight = this.nbt.getByteArray("SkyLight"); this.blockLight = this.nbt.getByteArray("BlockLight"); int[] biomeColors = this.nbt.getIntArray("BiomeColors"); if (biomeColors.length != 256) { biomeColors = new int[256]; Arrays.fill(biomeColors, Binary.readInt(new byte[]{(byte) 0xff, (byte) 0x00, (byte) 0x00, (byte) 0x00})); } this.biomeColors = biomeColors; int[] heightMap = this.nbt.getIntArray("HeightMap"); if (heightMap.length != 256) { heightMap = new int[256]; Arrays.fill(heightMap, 127); } this.heightMap = heightMap; this.extraData = extraData; this.NBTentities = ((ListTag<CompoundTag>) this.nbt.getList("Entities")).getAll(); this.NBTtiles = ((ListTag<CompoundTag>) this.nbt.getList("TileEntities")).getAll(); if (this.nbt.contains("Biomes")) { this.checkOldBiomes(this.nbt.getByteArray("Biomes")); this.nbt.remove("Biomes"); } this.nbt.remove("Blocks"); this.nbt.remove("Data"); this.nbt.remove("SkyLight"); this.nbt.remove("BlockLight"); this.nbt.remove("BiomeColors"); this.nbt.remove("HeightMap"); this.nbt.remove("Biomes"); }
Example #2
Source File: Chunk.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public Chunk(LevelProvider level, CompoundTag nbt) { this.provider = level; if (level != null) { this.providerClass = level.getClass(); } if (nbt == null) { return; } this.nbt = nbt; if (!(this.nbt.contains("Entities") && (this.nbt.get("Entities") instanceof ListTag))) { this.nbt.putList(new ListTag<CompoundTag>("Entities")); } if (!(this.nbt.contains("TileEntities") && (this.nbt.get("TileEntities") instanceof ListTag))) { this.nbt.putList(new ListTag<CompoundTag>("TileEntities")); } if (!(this.nbt.contains("TileTicks") && (this.nbt.get("TileTicks") instanceof ListTag))) { this.nbt.putList(new ListTag<CompoundTag>("TileTicks")); } if (!(this.nbt.contains("Biomes") && (this.nbt.get("Biomes") instanceof ByteArrayTag))) { this.nbt.putByteArray("Biomes", new byte[256]); } if (!(this.nbt.contains("HeightMap") && (this.nbt.get("HeightMap") instanceof IntArrayTag))) { this.nbt.putIntArray("HeightMap", new int[256]); } if (!(this.nbt.contains("Blocks"))) { this.nbt.putByteArray("Blocks", new byte[32768]); } if (!(this.nbt.contains("Data"))) { this.nbt.putByteArray("Data", new byte[16384]); this.nbt.putByteArray("SkyLight", new byte[16384]); this.nbt.putByteArray("BlockLight", new byte[16384]); } Map<Integer, Integer> extraData = new HashMap<>(); if (!this.nbt.contains("ExtraData") || !(this.nbt.get("ExtraData") instanceof ByteArrayTag)) { this.nbt.putByteArray("ExtraData", Binary.writeInt(0)); } else { BinaryStream stream = new BinaryStream(this.nbt.getByteArray("ExtraData")); for (int i = 0; i < stream.getInt(); i++) { int key = stream.getInt(); extraData.put(key, stream.getShort()); } } this.setPosition(this.nbt.getInt("xPos"), this.nbt.getInt("zPos")); this.blocks = this.nbt.getByteArray("Blocks"); this.data = this.nbt.getByteArray("Data"); this.skyLight = this.nbt.getByteArray("SkyLight"); this.blockLight = this.nbt.getByteArray("BlockLight"); if (this.nbt.contains("BiomeColors")) { this.biomes = new byte[16 * 16]; int[] biomeColors = this.nbt.getIntArray("BiomeColors"); if (biomeColors.length == 256) { BiomePalette palette = new BiomePalette(biomeColors); for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { this.biomes[(x << 4) | z] = (byte) (palette.get(x, z) >> 24); } } } } else { this.biomes = this.nbt.getByteArray("Biomes"); } int[] heightMap = this.nbt.getIntArray("HeightMap"); this.heightMap = new byte[256]; if (heightMap.length != 256) { Arrays.fill(this.heightMap, (byte) 255); } else { for (int i = 0; i < heightMap.length; i++) { this.heightMap[i] = (byte) heightMap[i]; } } if (!extraData.isEmpty()) this.extraData = extraData; this.NBTentities = ((ListTag<CompoundTag>) this.nbt.getList("Entities")).getAll(); this.NBTtiles = ((ListTag<CompoundTag>) this.nbt.getList("TileEntities")).getAll(); this.nbt.remove("Blocks"); this.nbt.remove("Data"); this.nbt.remove("SkyLight"); this.nbt.remove("BlockLight"); this.nbt.remove("BiomeColors"); this.nbt.remove("HeightMap"); this.nbt.remove("Biomes"); }
Example #3
Source File: Chunk.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public Chunk(LevelProvider level, CompoundTag nbt) { this.provider = level; if (level != null) { this.providerClass = level.getClass(); } if (nbt == null) { this.nbt = new CompoundTag("Level"); return; } this.nbt = nbt; if (!(this.nbt.contains("Entities") && (this.nbt.get("Entities") instanceof ListTag))) { this.nbt.putList(new ListTag<CompoundTag>("Entities")); } if (!(this.nbt.contains("TileEntities") && (this.nbt.get("TileEntities") instanceof ListTag))) { this.nbt.putList(new ListTag<CompoundTag>("TileEntities")); } if (!(this.nbt.contains("TileTicks") && (this.nbt.get("TileTicks") instanceof ListTag))) { this.nbt.putList(new ListTag<CompoundTag>("TileTicks")); } if (!(this.nbt.contains("BiomeColors") && (this.nbt.get("BiomeColors") instanceof IntArrayTag))) { this.nbt.putIntArray("BiomeColors", new int[256]); } if (!(this.nbt.contains("HeightMap") && (this.nbt.get("HeightMap") instanceof IntArrayTag))) { this.nbt.putIntArray("HeightMap", new int[256]); } if (!(this.nbt.contains("Blocks"))) { this.nbt.putByteArray("Blocks", new byte[32768]); } if (!(this.nbt.contains("Data"))) { this.nbt.putByteArray("Data", new byte[16384]); this.nbt.putByteArray("SkyLight", new byte[16384]); this.nbt.putByteArray("BlockLight", new byte[16384]); } Map<Integer, Integer> extraData = new HashMap<>(); if (!this.nbt.contains("ExtraData") || !(this.nbt.get("ExtraData") instanceof ByteArrayTag)) { this.nbt.putByteArray("ExtraData", Binary.writeInt(0)); } else { BinaryStream stream = new BinaryStream(this.nbt.getByteArray("ExtraData")); for (int i = 0; i < stream.getInt(); i++) { int key = stream.getInt(); extraData.put(key, stream.getShort()); } } this.setPosition(this.nbt.getInt("xPos"), this.nbt.getInt("zPos")); this.blocks = this.nbt.getByteArray("Blocks"); this.data = this.nbt.getByteArray("Data"); this.skyLight = this.nbt.getByteArray("SkyLight"); this.blockLight = this.nbt.getByteArray("BlockLight"); int[] biomeColors = this.nbt.getIntArray("BiomeColors"); if (biomeColors.length != 256) { biomeColors = new int[256]; Arrays.fill(biomeColors, Binary.readInt(new byte[]{(byte) 0xff, (byte) 0x00, (byte) 0x00, (byte) 0x00})); } this.biomeColors = biomeColors; int[] heightMap = this.nbt.getIntArray("HeightMap"); this.heightMap = new byte[256]; if (heightMap.length != 256) { Arrays.fill(this.heightMap, (byte) 255); } else { for (int i = 0; i < heightMap.length; i++) { this.heightMap[i] = (byte) heightMap[i]; } } this.extraData = extraData; this.NBTentities = ((ListTag<CompoundTag>) this.nbt.getList("Entities")).getAll(); this.NBTtiles = ((ListTag<CompoundTag>) this.nbt.getList("TileEntities")).getAll(); if (this.nbt.contains("Biomes")) { this.checkOldBiomes(this.nbt.getByteArray("Biomes")); this.nbt.remove("Biomes"); } this.nbt.remove("Blocks"); this.nbt.remove("Data"); this.nbt.remove("SkyLight"); this.nbt.remove("BlockLight"); this.nbt.remove("BiomeColors"); this.nbt.remove("HeightMap"); this.nbt.remove("Biomes"); }