use of org.spongepowered.api.data.persistence.DataContainer in project SpongeCommon by SpongePowered.
the class SpongeBlockEntityArchetypeBuilder method blockEntityData.
@Override
public BlockEntityArchetype.Builder blockEntityData(final DataView dataView) {
final DataContainer copy = Objects.requireNonNull(dataView, "DataView cannot be null!").copy();
this.data = copy;
return this;
}
use of org.spongepowered.api.data.persistence.DataContainer in project SpongeCommon by SpongePowered.
the class SchematicTranslator method translate.
@Override
public DataContainer translate(final Schematic schematic) throws InvalidDataException {
final DataContainer data = DataContainer.createNew(DataView.SafetyMode.NO_DATA_CLONED);
final DataView view = data.createView(Constants.Sponge.Schematic.SCHEMATIC);
this.addTo(schematic, view);
return data;
}
use of org.spongepowered.api.data.persistence.DataContainer in project SpongeCommon by SpongePowered.
the class SpongeEntitySnapshot method toContainer.
@Override
public DataContainer toContainer() {
final DataContainer unsafeNbt = NBTTranslator.INSTANCE.translateFrom(this.compound == null ? new CompoundTag() : this.compound);
final DataContainer container = DataContainer.createNew(DataView.SafetyMode.NO_DATA_CLONED).set(Queries.CONTENT_VERSION, this.contentVersion()).set(Queries.WORLD_KEY, this.worldKey.formatted()).createView(Constants.Sponge.SNAPSHOT_WORLD_POSITION).set(Queries.POSITION_X, this.position.x()).set(Queries.POSITION_Y, this.position.y()).set(Queries.POSITION_Z, this.position.z()).container().createView(Constants.Entity.ROTATION).set(Queries.POSITION_X, this.rotation.x()).set(Queries.POSITION_Y, this.rotation.y()).set(Queries.POSITION_Z, this.rotation.z()).container().createView(Constants.Entity.SCALE).set(Queries.POSITION_X, this.scale.x()).set(Queries.POSITION_Y, this.scale.y()).set(Queries.POSITION_Z, this.scale.z()).container().set(Constants.Entity.TYPE, net.minecraft.world.entity.EntityType.getKey((net.minecraft.world.entity.EntityType<?>) this.entityType)).set(Constants.Sponge.UNSAFE_NBT, unsafeNbt);
if (this.uniqueId != null) {
container.set(Constants.Entity.UUID, this.uniqueId.toString());
}
return container;
}
use of org.spongepowered.api.data.persistence.DataContainer in project SpongeCommon by SpongePowered.
the class SpongeEntityArchetypeBuilder method entityData.
@Override
public EntityArchetype.Builder entityData(final DataView view) {
final DataContainer container = Objects.requireNonNull(view, "Provided DataView cannot be null!").copy();
new DelegateDataValidator(SpongeEntityArchetype.VALIDATORS, ValidationTypes.ENTITY.get()).validate(container);
this.compound = NBTTranslator.INSTANCE.translate(container);
SpongeEntityArchetypeBuilder.stripCompound(this.compound);
return this;
}
use of org.spongepowered.api.data.persistence.DataContainer in project SpongeCommon by SpongePowered.
the class SpongeGameProfile method toContainer.
@Override
@NonNull
public DataContainer toContainer() {
final DataContainer container = DataContainer.createNew().set(Queries.CONTENT_VERSION, this.contentVersion()).set(Constants.Profile.UUID, this.uniqueId().toString());
if (this.name != null) {
container.set(Constants.Profile.NAME, this.name);
}
if (!this.properties.isEmpty()) {
final List<DataContainer> entries = new ArrayList<>(this.properties.size());
for (final ProfileProperty property : this.properties) {
entries.add(property.toContainer());
}
container.set(Constants.Profile.PROPERTIES, entries);
}
return container;
}
Aggregations