Java Code Examples for net.minecraft.init.Items#LAVA_BUCKET
The following examples show how to use
net.minecraft.init.Items#LAVA_BUCKET .
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: RecipeSteroidSyringe.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@Override public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) { boolean foundSyringe = false; boolean foundMana = false; boolean foundNacre = false; boolean foundLava = false; boolean foundDevilDust = false; ItemStack mana = FluidUtil.getFilledBucket(new FluidStack(ModFluids.MANA.getActual(), 1)); ItemStack nacre = FluidUtil.getFilledBucket(new FluidStack(ModFluids.NACRE.getActual(), 1)); for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); if (stack.getItem() == ModItems.SYRINGE && stack.getItemDamage() == 0) foundSyringe = true; if (ItemStack.areItemStacksEqual(mana, stack)) foundMana = true; if (ItemStack.areItemStacksEqual(nacre, stack)) foundNacre = true; if (stack.getItem() == Items.LAVA_BUCKET) foundLava = true; if (stack.getItem() == ModItems.DEVIL_DUST) foundDevilDust = true; } return foundSyringe && foundMana && foundDevilDust && foundLava && foundNacre; }
Example 2
Source File: ItemUtils.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
public static ItemStack getStateToItemOverride(IBlockState state) { if (state.getBlock() == Blocks.LAVA || state.getBlock() == Blocks.FLOWING_LAVA) { return new ItemStack(Items.LAVA_BUCKET); } else if (state.getBlock() == Blocks.WATER || state.getBlock() == Blocks.FLOWING_WATER) { return new ItemStack(Items.WATER_BUCKET); } return ItemStack.EMPTY; }
Example 3
Source File: CraftingHelper.java From malmo with MIT License | 5 votes |
/** * Consume fuel from the player's inventory.<br> * Take it first from their cache, if present, and then from their inventory, starting * at the first slot and working upwards. * * @param player * @param burnAmount amount of fuel to burn, in ticks. */ public static void burnInventory(EntityPlayerMP player, int burnAmount, ItemStack input) { if (!fuelCaches.containsKey(player)) fuelCaches.put(player, -burnAmount); else fuelCaches.put(player, fuelCaches.get(player) - burnAmount); int index = 0; while (fuelCaches.get(player) < 0 && index < player.inventory.mainInventory.size()) { ItemStack is = player.inventory.mainInventory.get(index); if (is != null) { int burnTime = TileEntityFurnace.getItemBurnTime(is); if (burnTime != 0) { // Consume item: if (is.getCount() > 1) is.setCount(is.getCount() - 1); else { // If this is a bucket of lava, we need to consume the lava but leave the bucket. if (is.getItem() == Items.LAVA_BUCKET) { // And if we're cooking wet sponge, we need to leave the bucket filled with water. if (input.getItem() == Item.getItemFromBlock(Blocks.SPONGE) && input.getMetadata() == 1) player.inventory.mainInventory.set(index, new ItemStack(Items.WATER_BUCKET)); else player.inventory.mainInventory.set(index, new ItemStack(Items.BUCKET)); } else player.inventory.mainInventory.get(index).setCount(0); index++; } fuelCaches.put(player, fuelCaches.get(player) + burnTime); } else index++; } else index++; } }
Example 4
Source File: PlanetEventHandler.java From AdvancedRocketry with MIT License | 5 votes |
@SubscribeEvent public void blockPlaceEvent(RightClickBlock event) { EnumFacing direction = event.getFace(); if(!event.getWorld().isRemote && direction != null && event.getEntityPlayer() != null && AtmosphereHandler.getOxygenHandler(event.getWorld().provider.getDimension()) != null && !AtmosphereHandler.getOxygenHandler(event.getWorld().provider.getDimension()).getAtmosphereType(event.getPos().offset(direction)).allowsCombustion()) { if(event.getEntityPlayer().getHeldItem(event.getHand()) != null) { if(event.getEntityPlayer().getHeldItem(event.getHand()).getItem() == Item.getItemFromBlock(Blocks.TORCH) && event.getWorld().getBlockState(event.getPos()).isSideSolid(event.getWorld(), event.getPos(), direction)) { event.setCanceled(true); event.getWorld().setBlockState(event.getPos().offset(direction), AdvancedRocketryBlocks.blockUnlitTorch.getDefaultState().withProperty(BlockTorch.FACING, direction)); } else if(zmaster587.advancedRocketry.api.Configuration.torchBlocks.contains(Block.getBlockFromItem(event.getEntityPlayer().getHeldItem(event.getHand()).getItem())) ) event.setCanceled(true); else if(event.getEntityPlayer().getHeldItem(event.getHand()).getItem() == Items.FLINT_AND_STEEL || event.getEntityPlayer().getHeldItem(event.getHand()).getItem() == Items.FIRE_CHARGE|| event.getEntityPlayer().getHeldItem(event.getHand()).getItem() == Items.BLAZE_POWDER || event.getEntityPlayer().getHeldItem(event.getHand()).getItem() == Items.BLAZE_ROD || event.getEntityPlayer().getHeldItem(event.getHand()).getItem() == Items.LAVA_BUCKET) event.setCanceled(true); } } if(!event.getWorld().isRemote && event.getItemStack() != null && event instanceof PlayerInteractEvent.RightClickBlock && event.getItemStack().getItem() == Items.BED && event.getWorld().provider instanceof WorldProviderPlanet) { AdvancedRocketryItems.itemAstroBed.onItemUse( event.getEntityPlayer(), event.getEntityPlayer().world, event.getPos(), event.getHand(), event.getFace(), 0, 0, 0); event.setCanceled(true); } if(!event.getWorld().isRemote && event.getItemStack() != null && event.getItemStack().getItem() == Item.getItemFromBlock(AdvancedRocketryBlocks.blockGenericSeat) && event.getWorld().getBlockState(event.getPos()).getBlock() == Blocks.TNT) { ARAchivements.BEER.trigger((EntityPlayerMP) event.getEntityPlayer()); } }
Example 5
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 6
Source File: MaterialCache.java From litematica with GNU Lesser General Public License v3.0 | 4 votes |
@Nullable protected ItemStack getStateToItemOverride(IBlockState state) { Block block = state.getBlock(); if (block == Blocks.PISTON_HEAD || block == Blocks.PISTON_EXTENSION || block == Blocks.PORTAL || block == Blocks.END_PORTAL || block == Blocks.END_GATEWAY) { return ItemStack.EMPTY; } else if (block == Blocks.FARMLAND) { return new ItemStack(Blocks.DIRT); } else if (block == Blocks.GRASS_PATH) { return new ItemStack(Blocks.GRASS); } else if (block == Blocks.BROWN_MUSHROOM_BLOCK) { return new ItemStack(Blocks.BROWN_MUSHROOM_BLOCK); } else if (block == Blocks.RED_MUSHROOM_BLOCK) { return new ItemStack(Blocks.RED_MUSHROOM_BLOCK); } else if (block == Blocks.LAVA) { if (state.getValue(BlockLiquid.LEVEL) == 0) { return new ItemStack(Items.LAVA_BUCKET); } else { return ItemStack.EMPTY; } } else if (block == Blocks.WATER) { if (state.getValue(BlockLiquid.LEVEL) == 0) { return new ItemStack(Items.WATER_BUCKET); } else { return ItemStack.EMPTY; } } else if (block instanceof BlockDoor && state.getValue(BlockDoor.HALF) == BlockDoor.EnumDoorHalf.UPPER) { return ItemStack.EMPTY; } else if (block instanceof BlockBed && state.getValue(BlockBed.PART) == BlockBed.EnumPartType.HEAD) { return ItemStack.EMPTY; } else if (block instanceof BlockDoublePlant && state.getValue(BlockDoublePlant.HALF) == BlockDoublePlant.EnumBlockHalf.UPPER) { return ItemStack.EMPTY; } return null; }
Example 7
Source File: TileEntityEnderFurnace.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
/** * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't fuel * @param stack * @return */ private static int getItemBurnTime(ItemStack stack) { if (stack.isEmpty()) { return 0; } int burnTime = ForgeEventFactory.getItemBurnTime(stack) * COOKTIME_DEFAULT * 3 / 400; if (burnTime >= 0) { return burnTime; } Item item = stack.getItem(); if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR) { Block block = Block.getBlockFromItem(item); if (block.getDefaultState().getMaterial() == Material.WOOD) { return COOKTIME_DEFAULT * 225 / 100; } if (block == Blocks.COAL_BLOCK) { return COOKTIME_DEFAULT * 120; } if (block == Blocks.WOODEN_SLAB) { return COOKTIME_DEFAULT * 45 / 40; } if (block == Blocks.SAPLING) return COOKTIME_DEFAULT * 3 / 4; } else { if (item == Items.COAL) return COOKTIME_DEFAULT * 12; if (item == Items.BLAZE_ROD) return COOKTIME_DEFAULT * 18; if (item == Items.LAVA_BUCKET) return COOKTIME_DEFAULT * 150; if (item == Items.STICK) return COOKTIME_DEFAULT * 3 / 4; if (item instanceof ItemTool && ((ItemTool)item).getToolMaterialName().equals("WOOD")) return COOKTIME_DEFAULT * 15 / 10; if (item instanceof ItemSword && ((ItemSword)item).getToolMaterialName().equals("WOOD")) return COOKTIME_DEFAULT * 15 / 10; if (item instanceof ItemHoe && ((ItemHoe)item).getMaterialName().equals("WOOD")) return COOKTIME_DEFAULT * 15 / 10; // Ender Furnace custom fuels if (item == Items.BLAZE_POWDER) return COOKTIME_DEFAULT * 9; if (item == Items.ENDER_PEARL) { return COOKTIME_DEFAULT * 8; } if (item == Items.ENDER_EYE) { return COOKTIME_DEFAULT * 17; } } return 0; }