use of org.spongepowered.api.data.DataContainer in project SpongeCommon by SpongePowered.
the class MixinTileEntity method toContainer.
@Override
public DataContainer toContainer() {
final DataContainer container = DataContainer.createNew().set(Queries.CONTENT_VERSION, getContentVersion()).set(Queries.WORLD_ID, ((World) this.world).getUniqueId().toString()).set(Queries.POSITION_X, this.getPos().getX()).set(Queries.POSITION_Y, this.getPos().getY()).set(Queries.POSITION_Z, this.getPos().getZ()).set(DataQueries.BLOCK_ENTITY_TILE_TYPE, this.tileType.getId());
final NBTTagCompound compound = new NBTTagCompound();
this.writeToNBT(compound);
// We must filter the custom data so it isn't stored twice
NbtDataUtil.filterSpongeCustomData(compound);
container.set(DataQueries.UNSAFE_NBT, NbtTranslator.getInstance().translateFrom(compound));
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 MixinTileEntityBeacon method toContainer.
@Override
public DataContainer toContainer() {
DataContainer container = super.toContainer();
container.set(of("effect1"), getField(1));
container.set(of("effect2"), getField(2));
return container;
}
use of org.spongepowered.api.data.DataContainer in project SpongeCommon by SpongePowered.
the class MixinTileEntityCommandBlock method toContainer.
@Override
@SuppressWarnings("deprecated")
public DataContainer toContainer() {
DataContainer container = super.toContainer();
container.set(of("StoredCommand"), this.getCommandBlockLogic().getCommand());
container.set(of("SuccessCount"), this.getCommandBlockLogic().getSuccessCount());
container.set(of("CustomName"), this.getCommandBlockLogic().getName());
container.set(of("DoesTrackOutput"), this.getCommandBlockLogic().shouldTrackOutput());
if (this.getCommandBlockLogic().shouldTrackOutput()) {
}
return container;
}
use of org.spongepowered.api.data.DataContainer in project SpongeCommon by SpongePowered.
the class MixinTileEntityEnchantmentTable method toContainer.
@Override
public DataContainer toContainer() {
DataContainer container = super.toContainer();
container.set(of("CustomName"), this.customName);
return container;
}
use of org.spongepowered.api.data.DataContainer in project SpongeCommon by SpongePowered.
the class MixinWorldSettings method onSetGeneratorOptions.
@Inject(method = "setGeneratorOptions", at = @At(value = "RETURN"))
public void onSetGeneratorOptions(String generatorOptions, CallbackInfoReturnable<WorldSettings> cir) {
// Minecraft uses a String, we want to return a fancy DataContainer
// Parse the world generator settings as JSON
DataContainer settings = null;
try {
settings = DataFormats.JSON.read(generatorOptions);
} catch (JsonParseException | IOException ignored) {
}
// If null, assume custom
if (settings == null) {
settings = DataContainer.createNew().set(DataQueries.WORLD_CUSTOM_SETTINGS, generatorOptions);
}
this.generatorSettings = settings;
}
Aggregations