Java Code Examples for net.querz.nbt.tag.CompoundTag#putInt()
The following examples show how to use
net.querz.nbt.tag.CompoundTag#putInt() .
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: MCAChunkData.java From mcaselector with MIT License | 5 votes |
static MCAChunkData newEmptyLevelMCAChunkData(Point2i absoluteLocation, int dataVersion) { MCAChunkData mcaChunkData = new MCAChunkData(absoluteLocation, 0, 0, (byte) 1); CompoundTag root = new CompoundTag(); CompoundTag level = new CompoundTag(); level.putInt("xPos", absoluteLocation.getX()); level.putInt("zPos", absoluteLocation.getY()); level.putString("Status", "full"); root.put("Level", level); root.putInt("DataVersion", dataVersion); mcaChunkData.data = root; mcaChunkData.compressionType = CompressionType.ZLIB; return mcaChunkData; }
Example 2
Source File: Chunk.java From NBT with MIT License | 5 votes |
public CompoundTag updateHandle(int xPos, int zPos) { data.putInt("DataVersion", dataVersion); CompoundTag level = data.getCompoundTag("Level"); level.putInt("xPos", xPos); level.putInt("zPos", zPos); level.putLong("LastUpdate", lastUpdate); level.putLong("InhabitedTime", inhabitedTime); if (dataVersion < 2202) { if (biomes != null && biomes.length == 256) level.putIntArray("Biomes", biomes); } else { if (biomes != null && biomes.length == 1024) level.putIntArray("Biomes", biomes); } if (heightMaps != null) level.put("Heightmaps", heightMaps); if (carvingMasks != null) level.put("CarvingMasks", carvingMasks); if (entities != null) level.put("Entities", entities); if (tileEntities != null) level.put("TileEntities", tileEntities); if (tileTicks != null) level.put("TileTicks", tileTicks); if (liquidTicks != null) level.put("LiquidTicks", liquidTicks); if (lights != null) level.put("Lights", lights); if (liquidsToBeTicked != null) level.put("LiquidsToBeTicked", liquidsToBeTicked); if (toBeTicked != null) level.put("ToBeTicked", toBeTicked); if (postProcessing != null) level.put("PostProcessing", postProcessing); level.putString("Status", status); if (structures != null) level.put("Structures", structures); ListTag<CompoundTag> sections = new ListTag<>(CompoundTag.class); for (int i = 0; i < this.sections.length; i++) { if (this.sections[i] != null) { sections.add(this.sections[i].updateHandle(i)); } } level.put("Sections", sections); return data; }
Example 3
Source File: DataVersionField.java From mcaselector with MIT License | 4 votes |
@Override public void force(CompoundTag root) { root.putInt("DataVersion", getNewValue()); }
Example 4
Source File: MCAChunkData.java From mcaselector with MIT License | 4 votes |
public boolean relocate(Point2i offset) { if (data == null || !data.containsKey("Level")) { return false; } CompoundTag level = catchClassCastException(() -> data.getCompoundTag("Level")); if (level == null) { return true; } // adjust or set chunk position level.putInt("xPos", level.getInt("xPos") + offset.blockToChunk().getX()); level.putInt("zPos", level.getInt("zPos") + offset.blockToChunk().getY()); // adjust entity positions if (level.containsKey("Entities")) { ListTag<CompoundTag> entities = catchClassCastException(() -> level.getListTag("Entities").asCompoundTagList()); if (entities != null) { entities.forEach(v -> applyOffsetToEntity(v, offset)); } } // adjust tile entity positions if (level.containsKey("TileEntities")) { ListTag<CompoundTag> tileEntities = catchClassCastException(() -> level.getListTag("TileEntities").asCompoundTagList()); if (tileEntities != null) { tileEntities.forEach(v -> applyOffsetToTileEntity(v, offset)); } } // adjust tile ticks if (level.containsKey("TileTicks")) { ListTag<CompoundTag> tileTicks = catchClassCastException(() -> level.getListTag("TileTicks").asCompoundTagList()); if (tileTicks != null) { tileTicks.forEach(v -> applyOffsetToTick(v, offset)); } } // adjust liquid ticks if (level.containsKey("LiquidTicks")) { ListTag<CompoundTag> liquidTicks = catchClassCastException(() -> level.getListTag("LiquidTicks").asCompoundTagList()); if (liquidTicks != null) { liquidTicks.forEach(v -> applyOffsetToTick(v, offset)); } } // adjust structures if (level.containsKey("Structures")) { CompoundTag structures = catchClassCastException(() -> level.getCompoundTag("Structures")); if (structures != null) { applyOffsetToStructures(structures, offset); } } return true; }
Example 5
Source File: MCAChunkData.java From mcaselector with MIT License | 4 votes |
private void applyIntIfPresent(CompoundTag root, String key, int offset) { Integer value; if (root.containsKey(key) && (value = catchClassCastException(() -> root.getInt(key))) != null) { root.putInt(key, value + offset); } }