Advertisement
Equite

[JAVA] Lighter

Jun 4th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None | 0 0
  1. public Lighter(String name, ToolMaterial material){
  2.         super(material);
  3.         setUnlocalizedName(name);
  4.         setRegistryName(name);
  5.         setCreativeTab(CreativeTabs.COMBAT);
  6.            
  7.         ModItems.ITEMS.add(this);
  8.     }
  9.  
  10.     public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
  11.     {
  12.                 //Grab Vars
  13.                 pos = pos.offset(facing);
  14.                 ItemStack itemstack = player.getHeldItem(hand);
  15.                
  16.                 //Check for iron nugget and looking at block
  17.                 if (!player.canPlayerEdit(pos, facing, itemstack)){
  18.                     return EnumActionResult.FAIL;
  19.                 }
  20.                 else{
  21.                     //Check if space for fire is available
  22.                     if (worldIn.isAirBlock(pos)){
  23.                         //Place fire block
  24.                         worldIn.playSound(player, pos, SoundEvents.ENTITY_SLIME_SQUISH, SoundCategory.BLOCKS, 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
  25.                         worldIn.setBlockState(pos, Blocks.FIRE.getDefaultState(), 11);
  26.                     }
  27.  
  28.                     if (player instanceof EntityPlayerMP){
  29.                         CriteriaTriggers.PLACED_BLOCK.trigger((EntityPlayerMP)player, pos, itemstack);
  30.                     }
  31.                     ItemStack offhand = player.getHeldItemOffhand();
  32.  
  33.                     itemstack.damageItem(100, player);
  34.                     return EnumActionResult.SUCCESS;
  35.                 }
  36.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement