use of org.spongepowered.common.data.holder.SimpleNBTDataHolder in project SpongeCommon by SpongePowered.
the class SpongeEntitySnapshotBuilder method build.
@Override
public EntitySnapshot build() {
Objects.requireNonNull(this.worldKey);
Objects.requireNonNull(this.position);
Objects.requireNonNull(this.rotation);
Objects.requireNonNull(this.scale);
Objects.requireNonNull(this.entityType);
final EntitySnapshot snapshot = new SpongeEntitySnapshot(this);
// Write the the manipulator values to NBT
if (this.manipulator != null && !this.manipulator.getKeys().isEmpty()) {
if (this.compound == null) {
this.compound = new CompoundTag();
}
final SimpleNBTDataHolder dataHolder = new SimpleNBTDataHolder(this.compound, NBTDataTypes.ENTITY);
dataHolder.copyFrom(this.manipulator);
this.compound = dataHolder.data$getCompound();
// If there was no data remove the compound again
if (this.compound.isEmpty()) {
this.compound = null;
}
}
return snapshot;
}
Aggregations