use of net.minecraft.nbt.NBTUtil in project BuildCraft by BuildCraft.
the class SchematicBlockDefault method serializeNBT.
@Override
public NBTTagCompound serializeNBT() {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setTag("requiredBlockOffsets", NBTUtilBC.writeCompoundList(requiredBlockOffsets.stream().map(NBTUtil::createPosTag)));
nbt.setTag("blockState", NBTUtil.writeBlockState(new NBTTagCompound(), blockState));
nbt.setTag("ignoredProperties", NBTUtilBC.writeStringList(ignoredProperties.stream().map(IProperty::getName)));
if (tileNbt != null) {
nbt.setTag("tileNbt", tileNbt);
}
nbt.setTag("tileRotation", NBTUtilBC.writeEnum(tileRotation));
nbt.setString("placeBlock", Block.REGISTRY.getNameForObject(placeBlock).toString());
nbt.setTag("updateBlockOffsets", NBTUtilBC.writeCompoundList(updateBlockOffsets.stream().map(NBTUtil::createPosTag)));
nbt.setTag("canBeReplacedWithBlocks", NBTUtilBC.writeStringList(canBeReplacedWithBlocks.stream().map(Block.REGISTRY::getNameForObject).map(Object::toString)));
return nbt;
}
use of net.minecraft.nbt.NBTUtil in project minecolonies by Minecolonies.
the class CompatabilityManager method readFromNBT.
@Override
public void readFromNBT(@NotNull final NBTTagCompound compound) {
leavesToSaplingMap.putAll(NBTUtils.streamCompound(compound.getTagList(TAG_SAP_LEAVE, Constants.NBT.TAG_COMPOUND)).map(CompatabilityManager::readLeaveSaplingEntryFromNBT).collect(Collectors.toMap(Tuple::getFirst, Tuple::getSecond)));
final List<ItemStorage> storages = NBTUtils.streamCompound(compound.getTagList(TAG_SAPLINGS, Constants.NBT.TAG_COMPOUND)).map(tempCompound -> new ItemStorage(new ItemStack(tempCompound))).collect(Collectors.toList());
// Filter duplicated values.
for (final ItemStorage storage : storages) {
if (!saplings.contains(storage)) {
saplings.add(storage);
}
}
final List<IBlockState> states = NBTUtils.streamCompound(compound.getTagList(TAG_ORES, Constants.NBT.TAG_COMPOUND)).map(NBTUtil::readBlockState).collect(Collectors.toList());
for (final IBlockState state : states) {
if (!ores.contains(state.getBlock())) {
ores.add(state.getBlock());
}
}
}
Aggregations