use of org.spongepowered.api.fluid.FluidStack in project SpongeCommon by SpongePowered.
the class SpongeFluidStackSnapshot method withRawData.
@Override
@NonNull
public FluidStackSnapshot withRawData(@NonNull final DataView container) throws InvalidDataException {
final FluidStack stack = this.createStack();
stack.setRawData(container);
return stack.createSnapshot();
}
use of org.spongepowered.api.fluid.FluidStack in project SpongeCommon by SpongePowered.
the class SpongeFluidStackSnapshotBuilder method build.
@Override
@SuppressWarnings(value = { "unchecked", "rawtypes" })
public FluidStackSnapshot build() {
if (this.fluidType == null) {
throw new IllegalStateException("FluidType cannot be null!");
}
if (this.volume < 0) {
throw new IllegalStateException("The fluid volume must be at least 0!");
}
final SpongeFluidStackSnapshot snapshot = new SpongeFluidStackSnapshot(this);
if (this.keyValues != null) {
final FluidStack stack = snapshot.createStack();
this.keyValues.forEach((k, v) -> stack.offer((Key) k, v));
return stack.createSnapshot();
}
return snapshot;
}
Aggregations