Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Lighter(String name, ToolMaterial material){
- super(material);
- setUnlocalizedName(name);
- setRegistryName(name);
- setCreativeTab(CreativeTabs.COMBAT);
- ModItems.ITEMS.add(this);
- }
- public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
- {
- //Grab Vars
- pos = pos.offset(facing);
- ItemStack itemstack = player.getHeldItem(hand);
- //Check for iron nugget and looking at block
- if (!player.canPlayerEdit(pos, facing, itemstack)){
- return EnumActionResult.FAIL;
- }
- else{
- //Check if space for fire is available
- if (worldIn.isAirBlock(pos)){
- //Place fire block
- worldIn.playSound(player, pos, SoundEvents.ENTITY_SLIME_SQUISH, SoundCategory.BLOCKS, 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
- worldIn.setBlockState(pos, Blocks.FIRE.getDefaultState(), 11);
- }
- if (player instanceof EntityPlayerMP){
- CriteriaTriggers.PLACED_BLOCK.trigger((EntityPlayerMP)player, pos, itemstack);
- }
- ItemStack offhand = player.getHeldItemOffhand();
- itemstack.damageItem(100, player);
- return EnumActionResult.SUCCESS;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement