Java Code Examples for com.sk89q.jnbt.ListTag#getValue()
The following examples show how to use
com.sk89q.jnbt.ListTag#getValue() .
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: MCAFile2LevelDB.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
private CompoundTag transformItem(CompoundTag item) { String itemId = item.getString("id"); short damage = item.getShort("Damage"); BaseItem remapped = remapper.remapItem(itemId, damage); Map<String, com.sk89q.jnbt.Tag> map = ReflectionUtils.getMap(item.getValue()); map.put("id", new ShortTag((short) remapped.getType())); map.put("Damage", new ShortTag((short) remapped.getData())); if (!map.containsKey("Count")) map.put("Count", new ByteTag((byte) 0)); CompoundTag tag = (CompoundTag) item.getValue().get("tag"); if (tag != null) { Map<String, com.sk89q.jnbt.Tag> tagMap = ReflectionUtils.getMap(tag.getValue()); ListTag<CompoundTag> enchants = (ListTag<CompoundTag>) tagMap.get("ench"); if (enchants != null) { for (CompoundTag ench : enchants.getValue()) { Map<String, com.sk89q.jnbt.Tag> value = ReflectionUtils.getMap(ench.getValue()); String id = ench.getString("id"); String lvl = ench.getString("lvl"); if (id != null && !id.isEmpty()) value.put("id", new ShortTag(Short.parseShort(id))); if (lvl != null && !lvl.isEmpty()) value.put("lvl", new ShortTag(Short.parseShort(lvl))); } } CompoundTag tile = (CompoundTag) tagMap.get("BlockEntityTag"); if (tile != null) { tagMap.putAll(tile.getValue()); } } return item; }
Example 2
Source File: Polygonal2DRegionSchematicCodec.java From HeavySpleef with GNU General Public License v3.0 | 5 votes |
@Override public Polygonal2DRegion asRegion(Map<String, Tag> tags) { ListTag pointsListTag = (ListTag) tags.get("points"); List<Tag> pointList = pointsListTag.getValue(); List<BlockVector2D> points = Lists.newArrayList(); for (Tag vectorTag : pointList) { if (!(vectorTag instanceof ListTag)) { continue; } ListTag vectorListTag = (ListTag) vectorTag; int x = vectorListTag.getInt(0); int z = vectorListTag.getInt(1); BlockVector2D vector = new BlockVector2D(x, z); points.add(vector); } int minY = (int) tags.get("minY").getValue(); int maxY = (int) tags.get("maxY").getValue(); Polygonal2DRegion region = new Polygonal2DRegion(); for (BlockVector2D point : points) { region.addPoint(point); } region.setMaximumY(maxY); region.setMinimumY(minY); return region; }