use of net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper in project MinecraftForge by MinecraftForge.
the class UniversalBucket method getSubItems.
@SideOnly(Side.CLIENT)
@Override
public void getSubItems(@Nonnull Item itemIn, @Nullable CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems) {
for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) {
if (fluid != FluidRegistry.WATER && fluid != FluidRegistry.LAVA && !fluid.getName().equals("milk")) {
// add all fluids that the bucket can be filled with
FluidStack fs = new FluidStack(fluid, getCapacity());
ItemStack stack = new ItemStack(this);
IFluidHandlerItem fluidHandler = new FluidBucketWrapper(stack);
if (fluidHandler.fill(fs, true) == fs.amount) {
ItemStack filled = fluidHandler.getContainer();
subItems.add(filled);
}
}
}
}
use of net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper in project RFTools by McJty.
the class SensorTileEntity method checkFluid.
private boolean checkFluid(BlockPos newpos) {
IBlockState state = getWorld().getBlockState(newpos);
ItemStack matcher = inventoryHelper.getStackInSlot(0);
Block block = state.getBlock();
if (matcher.isEmpty()) {
if (block instanceof BlockLiquid || block instanceof IFluidBlock) {
return !block.isAir(state, getWorld(), newpos);
}
return false;
}
ItemStack stack = block.getItem(getWorld(), newpos, state);
Item matcherItem = matcher.getItem();
FluidStack matcherFluidStack = null;
// }
if (matcherItem instanceof ItemBucket || matcherItem instanceof UniversalBucket) {
matcherFluidStack = new FluidBucketWrapper(matcher).getFluid();
return checkFluid(block, matcherFluidStack, state, newpos);
}
return false;
}
Aggregations