use of org.spongepowered.api.extra.fluid.FluidStack in project SpongeForge by SpongePowered.
the class MixinSpongeFluidStackBuilder method build.
@Overwrite
public FluidStack build() {
checkNotNull(this.fluidType, "Fluidtype cannot be null!");
checkState(this.volume >= 0, "Volume must be at least zero!");
@Nullable NBTTagCompound compound = this.extra == null ? null : NbtTranslator.getInstance().translateData(this.extra);
net.minecraftforge.fluids.FluidStack fluidStack = new net.minecraftforge.fluids.FluidStack((Fluid) this.fluidType, this.volume, compound);
return (FluidStack) fluidStack;
}
use of org.spongepowered.api.extra.fluid.FluidStack in project SpongeForge by SpongePowered.
the class ForgeFluidTankDataProcessor method getVal.
@Override
protected Optional<Map<Direction, List<FluidStackSnapshot>>> getVal(TileEntity dataHolder) {
Map<Direction, List<FluidStackSnapshot>> map = new HashMap<>();
for (EnumFacing facing : EnumFacing.values()) {
final Direction direction = DirectionFacingProvider.getInstance().getKey(facing).get();
if (dataHolder.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing)) {
final IFluidHandler handler = dataHolder.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing);
final IFluidTankProperties[] tankProperties = handler.getTankProperties();
if (tankProperties != null) {
ImmutableList.Builder<FluidStackSnapshot> snapshotBuilder = ImmutableList.builder();
for (IFluidTankProperties info : tankProperties) {
if (info != null && info.getContents() != null) {
final FluidStack drained = (FluidStack) handler.drain(info.getContents(), false);
if (drained != null) {
snapshotBuilder.add(drained.createSnapshot());
}
}
}
map.put(direction, snapshotBuilder.build());
}
}
}
return Optional.of(map);
}
Aggregations