use of org.spongepowered.api.data.persistence.DataContainer in project SpongeCommon by SpongePowered.
the class SpongeFluidStackBuilder method from.
@Override
public FluidStack.@NonNull Builder from(final FluidStack value) {
this.fluidType = value.fluid();
this.volume = value.volume();
final DataContainer container = value.toContainer();
if (container.contains(Constants.Sponge.UNSAFE_NBT)) {
this.extra = container.getView(Constants.Sponge.UNSAFE_NBT).get().copy();
}
return this;
}
use of org.spongepowered.api.data.persistence.DataContainer in project SpongeCommon by SpongePowered.
the class SpongeFluidStackSnapshotBuilder method from.
@Override
public FluidStackSnapshot.@NonNull Builder from(@NonNull final FluidStack fluidStack) {
this.fluidType = fluidStack.fluid();
this.volume = fluidStack.volume();
final DataContainer datacontainer = fluidStack.toContainer();
this.container = null;
if (datacontainer.contains(Constants.Sponge.UNSAFE_NBT)) {
this.container = datacontainer.getView(Constants.Sponge.UNSAFE_NBT).get();
}
return this;
}
use of org.spongepowered.api.data.persistence.DataContainer in project SpongeCommon by SpongePowered.
the class SpongeTagTemplate method toContainer.
@Override
public DataContainer toContainer() {
final JsonObject jsonObject = this.toJson();
try {
final DataContainer container = DataFormats.JSON.get().read(jsonObject.getAsString());
container.set(DataQuery.of("replace"), this.replace);
return container;
} catch (IOException e) {
SpongeCommon.logger().error("Error reading json serialized by minecraft", e);
return DataContainer.createNew();
}
}
use of org.spongepowered.api.data.persistence.DataContainer in project SpongeCommon by SpongePowered.
the class SignBlockEntityMixin_API method toContainer.
// @formatter:on
@Override
public DataContainer toContainer() {
DataContainer container = super.toContainer();
List<String> lines = Lists.newArrayList();
for (Component line : this.messages) {
lines.add(Component.Serializer.toJson(line));
}
container.set(Constants.TileEntity.SIGN_LINES, lines);
return container;
}
use of org.spongepowered.api.data.persistence.DataContainer in project SpongeCommon by SpongePowered.
the class CommandBlockEntityMixin_API method toContainer.
@Override
public DataContainer toContainer() {
final DataContainer container = super.toContainer();
container.set(Constants.TileEntity.CommandBlock.STORED_COMMAND, this.shadow$getCommandBlock().getCommand());
container.set(Constants.TileEntity.CommandBlock.SUCCESS_COUNT, this.shadow$getCommandBlock().getSuccessCount());
container.set(Constants.TileEntity.CUSTOM_NAME, this.shadow$getCommandBlock().getName());
container.set(Constants.TileEntity.CommandBlock.DOES_TRACK_OUTPUT, this.shadow$getCommandBlock().shouldInformAdmins());
if (this.shadow$getCommandBlock().shouldInformAdmins()) {
container.set(Constants.TileEntity.CommandBlock.TRACKED_OUTPUT, LegacyComponentSerializer.legacySection().serialize(SpongeAdventure.asAdventure(this.shadow$getCommandBlock().getLastOutput())));
}
return container;
}
Aggregations