net.minecraftforge.fluids.UniversalBucket Java Examples
The following examples show how to use
net.minecraftforge.fluids.UniversalBucket.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RecipeShapelessFluid.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@Override public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) { NonNullList<ItemStack> remains = super.getRemainingItems(inv); for (int i = 0; i < remains.size(); i++) { ItemStack stack = inv.getStackInSlot(i); ItemStack remain = remains.get(i); if (!stack.isEmpty() && remain.isEmpty() && stack.getItem() instanceof UniversalBucket) { ItemStack empty = ((UniversalBucket) stack.getItem()).getEmpty(); if (!empty.isEmpty()) remains.set(i, empty.copy()); } } return remains; }
Example #2
Source File: Hydroponic.java From EmergingTechnology with MIT License | 4 votes |
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { return true; } HydroponicTileEntity tileEntity = (HydroponicTileEntity) worldIn.getTileEntity(pos); ItemStack itemStackHeld = playerIn.getHeldItemMainhand(); Item itemHeld = itemStackHeld.getItem(); if (itemHeld == Items.WATER_BUCKET || itemHeld == Items.LAVA_BUCKET) { Fluid fluid = itemHeld == Items.WATER_BUCKET ? FluidRegistry.WATER : FluidRegistry.LAVA; int waterFilled = tileEntity.fluidHandler.fill(new FluidStack(fluid, 1000), true); if (waterFilled > 0 && !playerIn.isCreative()) { playerIn.setHeldItem(EnumHand.MAIN_HAND, new ItemStack(Items.BUCKET)); } } else if (itemHeld instanceof UniversalBucket) { UniversalBucket bucket = (UniversalBucket) itemHeld; FluidStack fluidStack = bucket.getFluid(itemStackHeld); if (tileEntity.fluidHandler.canFillFluidType(fluidStack)) { tileEntity.fluidHandler.fill(fluidStack, true); playerIn.setHeldItem(EnumHand.MAIN_HAND, bucket.getEmpty()); } } else if (HydroponicHelper.isItemStackValid(itemStackHeld) && tileEntity.itemHandler.getStackInSlot(0).isEmpty()) { ItemStack remainder = tileEntity.itemHandler.insertItem(0, itemStackHeld.copy(), false); if (!playerIn.isCreative()) { playerIn.setHeldItem(EnumHand.MAIN_HAND, remainder); } return true; } else if (PlantHelper.isPlantItem(itemHeld) && facing == EnumFacing.UP) { return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ); // Otherwise open the gui } else { playerIn.openGui(EmergingTechnology.instance, Reference.GUI_HYDROPONIC, worldIn, pos.getX(), pos.getY(), pos.getZ()); return true; } return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ); }
Example #3
Source File: Util.java From ExNihiloAdscensio with MIT License | 4 votes |
public static ItemStack getBucketStack(Fluid fluid) { return UniversalBucket.getFilledBucket(ForgeModContainer.getInstance().universalBucket, fluid); }