<commit_before>package betterwithaddons.block;

import betterwithaddons.item.rbdtools.ItemMatchPick;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockFaceShape;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemFlintAndSteel;
import net.minecraft.item.ItemStack;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

import java.util.Random;

public class BlockLantern extends BlockBase {
    public static PropertyBool LIT = PropertyBool.create("lit");
    public static PropertyDirection FACING = PropertyDirection.create("facing");

    public BlockLantern(String name, Material materialIn) {
        super(name, materialIn);
        setDefaultState(getDefaultState().withProperty(FACING,EnumFacing.UP).withProperty(LIT,false));
    }

    @Override
    public int getLightValue(IBlockState state) {
        return state.getValue(LIT) ? 15 : 0;
    }

    public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
    {
        boolean canStay = false;

        for(EnumFacing facing : EnumFacing.VALUES)
        {
            if(canBlockStay(worldIn,pos,facing))
                canStay = true;
        }

        return super.canPlaceBlockAt(worldIn, pos) && canStay;
    }

    @Override
    public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
        checkAndDrop(worldIn,state,pos);
    }

    @Override
    public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos frompos) {
        super.neighborChanged(state, worldIn, pos, blockIn,frompos);
        checkAndDrop(worldIn,state,pos);
    }

    @Override
    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
        boolean isLit = state.getValue(LIT);

        ItemStack heldItem = playerIn.getHeldItem(hand);

        if(!isLit && !heldItem.isEmpty() && (heldItem.getItem() instanceof ItemFlintAndSteel || heldItem.getItem() instanceof ItemMatchPick))
        {
            worldIn.setBlockState(pos,state.withProperty(LIT,true));
            heldItem.damageItem(1,playerIn);
            return true;
        }
        else if(isLit && heldItem.isEmpty())
        {
            worldIn.setBlockState(pos,state.withProperty(LIT,false));
            return true;
        }

        return false;<commit_msg>- Adds sound to lighting Lanterns. Closes #123.<commit_after>package betterwithaddons.block;

import betterwithaddons.item.rbdtools.ItemMatchPick;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockFaceShape;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemFlintAndSteel;
import net.minecraft.item.ItemStack;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

import java.util.Random;

public class BlockLantern extends BlockBase {
    public static PropertyBool LIT = PropertyBool.create("lit");
    public static PropertyDirection FACING = PropertyDirection.create("facing");

    public BlockLantern(String name, Material materialIn) {
        super(name, materialIn);
        setDefaultState(getDefaultState().withProperty(FACING,EnumFacing.UP).withProperty(LIT,false));
    }

    @Override
    public int getLightValue(IBlockState state) {
        return state.getValue(LIT) ? 15 : 0;
    }

    public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
    {
        boolean canStay = false;

        for(EnumFacing facing : EnumFacing.VALUES)
        {
            if(canBlockStay(worldIn,pos,facing))
                canStay = true;
        }

        return super.canPlaceBlockAt(worldIn, pos) && canStay;
    }

    @Override
    public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
        checkAndDrop(worldIn,state,pos);
    }

    @Override
    public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos frompos) {
        super.neighborChanged(state, worldIn, pos, blockIn,frompos);
        checkAndDrop(worldIn,state,pos);
    }

    @Override
    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
        boolean isLit = state.getValue(LIT);

        ItemStack heldItem = playerIn.getHeldItem(hand);

        if(!isLit && !heldItem.isEmpty() && (heldItem.getItem() instanceof ItemFlintAndSteel || heldItem.getItem() instanceof ItemMatchPick)) {
            worldIn.setBlockState(pos,state.withProperty(LIT,true));
            worldIn.playSound(null, pos, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0f, 0.2f);
            heldItem.damageItem(1,playerIn);
            return true;
        }
        else if(isLit && heldItem.isEmpty())
        {
            worldIn.setBlockState(pos,state.withProperty(LIT,false));
            worldIn.playSound(null, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 1.0f, 1.5f);
            return true;
        }

        return false;
{'fraction_non_alphanumeric': 0.09800608313619466, 'fraction_numerical': 0.003210544102737411, 'mean_word_length': 3.6606299212598423, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1688607', 'n_tokens_mistral': 1750, 'n_tokens_neox': 1723, 'n_words': 348}