package minestrapteam.mods.minestrappolation.block; import minestrapteam.mods.minestrappolation.lib.MBlocks; import net.minecraft.block.Block; import net.minecraft.block.BlockGrass; import net.minecraft.block.state.IBlockState; import net.minecraft.item.Item; import net.minecraft.util.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import java.util.Random; public class BlockPermaFrost extends BlockGrass { public BlockPermaFrost() { this.setDefaultState(this.blockState.getBaseState().withProperty(SNOWY, Boolean.valueOf(false))); this.setTickRandomly(true); } @Override @SideOnly(Side.CLIENT) public int getRenderColor(IBlockState state) { return this.getBlockColor(); } @Override @SideOnly(Side.CLIENT) public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) { return 11052399; } @Override public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { if (!worldIn.isRemote) { if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getBlockState(pos.up()).getBlock().getLightOpacity(worldIn, pos.up()) > 2) { worldIn.setBlockState(pos, MBlocks.dirt_permafrost.getDefaultState()); } else { if (worldIn.getLightFromNeighbors(pos.up()) >= 9) { for (int i = 0; i < 4; ++i) { BlockPos blockpos1 = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1); Block block = worldIn.getBlockState(blockpos1.up()).getBlock(); IBlockState iblockstate1 = worldIn.getBlockState(blockpos1); if (iblockstate1.getBlock() == MBlocks.dirt_permafrost && worldIn.getLightFromNeighbors(blockpos1.up()) >= 4 && block.getLightOpacity(worldIn, blockpos1.up()) <= 2) { worldIn.setBlockState(blockpos1, MBlocks.lichen_permafrost.getDefaultState()); } } } } } } @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return MBlocks.dirt_permafrost.getItemDropped(MBlocks.dirt_permafrost.getDefaultState(), rand, fortune); } }