use of org.spongepowered.api.data.DataContainer in project SpongeCommon by SpongePowered.
the class SpongeEntitySnapshot method toContainer.
@Override
public DataContainer toContainer() {
final List<DataView> dataList = DataUtil.getSerializedImmutableManipulatorList(this.manipulators);
final DataContainer container = DataContainer.createNew().set(Queries.CONTENT_VERSION, getContentVersion()).set(Queries.WORLD_ID, this.worldUuid.toString()).set(DataQueries.ENTITY_TYPE, this.entityType.getId()).createView(DataQueries.SNAPSHOT_WORLD_POSITION).set(Queries.POSITION_X, this.position.getX()).set(Queries.POSITION_Y, this.position.getY()).set(Queries.POSITION_Z, this.position.getZ()).getContainer().createView(DataQueries.ENTITY_ROTATION).set(Queries.POSITION_X, this.rotation.getX()).set(Queries.POSITION_Y, this.rotation.getY()).set(Queries.POSITION_Z, this.rotation.getZ()).getContainer().createView(DataQueries.ENTITY_SCALE).set(Queries.POSITION_X, this.scale.getX()).set(Queries.POSITION_Y, this.scale.getY()).set(Queries.POSITION_Z, this.scale.getZ()).getContainer().set(DataQueries.DATA_MANIPULATORS, dataList);
if (this.entityUuid != null) {
container.set(DataQueries.ENTITY_ID, this.entityUuid.toString());
}
if (this.compound != null) {
container.set(DataQueries.UNSAFE_NBT, NbtTranslator.getInstance().translateFrom(this.compound));
}
return container;
}
use of org.spongepowered.api.data.DataContainer in project SpongeCommon by SpongePowered.
the class MixinEntity method toContainer.
@Override
public DataContainer toContainer() {
final Transform<World> transform = getTransform();
final NBTTagCompound compound = new NBTTagCompound();
writeToNBT(compound);
// We must filter the custom data so it isn't stored twice
NbtDataUtil.filterSpongeCustomData(compound);
final DataContainer unsafeNbt = NbtTranslator.getInstance().translateFrom(compound);
final DataContainer container = DataContainer.createNew().set(Queries.CONTENT_VERSION, getContentVersion()).set(DataQueries.ENTITY_CLASS, this.getClass().getName()).set(Queries.WORLD_ID, transform.getExtent().getUniqueId().toString()).createView(DataQueries.SNAPSHOT_WORLD_POSITION).set(Queries.POSITION_X, transform.getPosition().getX()).set(Queries.POSITION_Y, transform.getPosition().getY()).set(Queries.POSITION_Z, transform.getPosition().getZ()).getContainer().createView(DataQueries.ENTITY_ROTATION).set(Queries.POSITION_X, transform.getRotation().getX()).set(Queries.POSITION_Y, transform.getRotation().getY()).set(Queries.POSITION_Z, transform.getRotation().getZ()).getContainer().createView(DataQueries.ENTITY_SCALE).set(Queries.POSITION_X, transform.getScale().getX()).set(Queries.POSITION_Y, transform.getScale().getY()).set(Queries.POSITION_Z, transform.getScale().getZ()).getContainer().set(DataQueries.ENTITY_TYPE, this.entityType.getId()).set(DataQueries.UNSAFE_NBT, unsafeNbt);
final Collection<DataManipulator<?, ?>> manipulators = ((IMixinCustomDataHolder) this).getCustomManipulators();
if (!manipulators.isEmpty()) {
container.set(DataQueries.DATA_MANIPULATORS, DataUtil.getSerializedManipulatorList(manipulators));
}
return container;
}
use of org.spongepowered.api.data.DataContainer in project SpongeCommon by SpongePowered.
the class SpongeFluidStackBuilder method from.
@Override
public FluidStack.Builder from(FluidStack value) {
this.fluidType = value.getFluid();
this.volume = value.getVolume();
final DataContainer container = value.toContainer();
if (container.contains(DataQueries.UNSAFE_NBT)) {
this.extra = container.getView(DataQueries.UNSAFE_NBT).get().copy();
}
return this;
}
use of org.spongepowered.api.data.DataContainer in project SpongeCommon by SpongePowered.
the class MixinTileEntityFurnace method toContainer.
@Override
public DataContainer toContainer() {
DataContainer container = super.toContainer();
container.set(of("BurnTime"), this.getField(0));
container.set(of("BurnTimeTotal"), this.getField(1));
container.set(of("CookTime"), this.getField(3) - this.getField(2));
container.set(of("CookTimeTotal"), this.getField(3));
if (this.furnaceCustomName != null) {
container.set(of("CustomName"), this.furnaceCustomName);
}
return container;
}
use of org.spongepowered.api.data.DataContainer in project SpongeCommon by SpongePowered.
the class MixinWorldServer method updateWorldGenerator.
@Override
public void updateWorldGenerator() {
// Get the default generator for the world type
DataContainer generatorSettings = this.getProperties().getGeneratorSettings();
SpongeWorldGenerator newGenerator = createWorldGenerator(generatorSettings);
// by the base generation populator
if (newGenerator.getBaseGenerationPopulator() instanceof IChunkGenerator) {
// from a mod chunk provider extending a provider that we mixed into
if (WorldGenConstants.isValid((IChunkGenerator) newGenerator.getBaseGenerationPopulator(), IPopulatorProvider.class)) {
((IPopulatorProvider) newGenerator.getBaseGenerationPopulator()).addPopulators(newGenerator);
}
} else if (newGenerator.getBaseGenerationPopulator() instanceof IPopulatorProvider) {
// If its not a chunk provider but is a populator provider then we call it as well
((IPopulatorProvider) newGenerator.getBaseGenerationPopulator()).addPopulators(newGenerator);
}
for (WorldGeneratorModifier modifier : this.getProperties().getGeneratorModifiers()) {
modifier.modifyWorldGenerator(this.getProperties(), generatorSettings, newGenerator);
}
this.spongegen = createChunkGenerator(newGenerator);
this.spongegen.setGenerationPopulators(newGenerator.getGenerationPopulators());
this.spongegen.setPopulators(newGenerator.getPopulators());
this.spongegen.setBiomeOverrides(newGenerator.getBiomeSettings());
ChunkProviderServer chunkProviderServer = this.getChunkProvider();
chunkProviderServer.chunkGenerator = this.spongegen;
}
Aggregations