net.minecraft.block.BlockDirt Java Examples
The following examples show how to use
net.minecraft.block.BlockDirt.
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: BlockTorikkiGrass.java From Wizardry with GNU Lesser General Public License v3.0 | 7 votes |
@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()).getLightOpacity(worldIn, pos.up()) > 2) { worldIn.setBlockState(pos, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, DirtType.DIRT)); } else { if (worldIn.getLightFromNeighbors(pos.up()) >= 9) { for (int i = 0; i < 4; ++i) { BlockPos posAt = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1); IBlockState stateAt = worldIn.getBlockState(posAt); IBlockState stateAbove = worldIn.getBlockState(posAt.up()); if (Blocks.DIRT.equals(stateAt.getBlock()) && DirtType.DIRT.equals(stateAt.getValue(BlockDirt.VARIANT)) && worldIn.getLightFromNeighbors(posAt.up()) >= 4 && stateAbove.getLightOpacity(worldIn, posAt.up()) <= 2) { worldIn.setBlockState(posAt, this.getDefaultState()); } } } } } }
Example #2
Source File: BiomeThicket.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) { if (noiseVal > 1.5D) { this.topBlock = Blocks.GRASS.getDefaultState(); this.fillerBlock = Blocks.DIRT.getDefaultState(); } else { this.topBlock = Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT); this.fillerBlock = Blocks.DIRT.getDefaultState(); } this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal); }
Example #3
Source File: HoeBehaviour.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public ActionResult<ItemStack> onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); if (player.canPlayerEdit(blockPos, facing, stack) && !world.isAirBlock(blockPos)) { IBlockState blockState = world.getBlockState(blockPos); if (blockState.getBlock() == Blocks.GRASS || blockState.getBlock() == Blocks.DIRT) { if (blockState.getBlock() == Blocks.GRASS && player.isSneaking()) { if (GTUtility.doDamageItem(stack, this.cost, false)) { if (world.rand.nextInt(3) == 0) { ItemStack grassSeed = ForgeHooks.getGrassSeed(world.rand, 0); Block.spawnAsEntity(world, blockPos.up(), grassSeed); } world.playSound(null, blockPos, SoundEvents.ITEM_HOE_TILL, SoundCategory.PLAYERS, 1.0F, 1.0F); world.setBlockState(blockPos, Blocks.DIRT.getDefaultState() .withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT)); return ActionResult.newResult(EnumActionResult.SUCCESS, stack); } } else if (blockState.getBlock() == Blocks.GRASS || blockState.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT || blockState.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.COARSE_DIRT) { if (GTUtility.doDamageItem(stack, this.cost, false)) { world.playSound(null, blockPos, SoundEvents.ITEM_HOE_TILL, SoundCategory.PLAYERS, 1.0F, 1.0F); world.setBlockState(blockPos, Blocks.FARMLAND.getDefaultState()); return ActionResult.newResult(EnumActionResult.SUCCESS, stack); } } } } return ActionResult.newResult(EnumActionResult.FAIL, stack); }
Example #4
Source File: BiomeThicket.java From Traverse-Legacy-1-12-2 with MIT License | 5 votes |
@Override public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) { if (noiseVal > 1.5D) { this.topBlock = Blocks.GRASS.getDefaultState(); this.fillerBlock = Blocks.DIRT.getDefaultState(); } else { this.topBlock = Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT); this.fillerBlock = Blocks.DIRT.getDefaultState(); } this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal); }
Example #5
Source File: MobSpawnEventHandler.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
@SubscribeEvent public void onBlockHarvest(HarvestDropsEvent event) { if (!Config.direSlimeEnabled || event.isCanceled() || event.getWorld() == null || event.getWorld().isRemote) { return; } if (event.getHarvester() == null || event.getHarvester().capabilities.isCreativeMode) { return; } if (!(event.getState().getBlock() instanceof BlockDirt || event.getState().getBlock() instanceof BlockGrass)) { return; } if (!isToolEffective(event.getState(), event.getHarvester().getHeldItemMainhand())) { if (Config.direSlimeChance < event.getWorld().rand.nextFloat()) { return; } EntityDireSlime direSlime = new EntityDireSlime(event.getWorld()); direSlime.setPosition(event.getPos().getX() + 0.5, event.getPos().getY() + 0.0, event.getPos().getZ() + 0.5); event.getWorld().spawnEntity(direSlime); direSlime.playLivingSound(); for (ItemStack drop : event.getDrops()) { if (drop != null && drop.getItem() != null && drop.getItem() == Item.getItemFromBlock(Blocks.DIRT)) { if (drop.getCount() > 1) { drop.shrink(1); } else if (event.getDrops().size() == 1) { event.getDrops().clear(); } else { event.getDrops().remove(drop); } return; } } } }
Example #6
Source File: BlockTorikkiGrass.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
@Nonnull @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Blocks.DIRT.getItemDropped(Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, DirtType.DIRT), rand, fortune); }
Example #7
Source File: ItemEnderTool.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
public boolean useHoe(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side) { if (player.canPlayerEdit(pos, side, stack) == false) { return false; } int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(stack, player, world, pos); if (hook != 0) { return hook > 0; } IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); if (side != EnumFacing.DOWN && world.isAirBlock(pos.up())) { IBlockState newBlockState = null; if (block == Blocks.GRASS) { newBlockState = Blocks.FARMLAND.getDefaultState(); } else if (block == Blocks.DIRT) { if (state.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT || state.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.COARSE_DIRT) { newBlockState = Blocks.FARMLAND.getDefaultState(); } else { return false; } } else { return false; } if (newBlockState != null) { world.setBlockState(pos, newBlockState, 3); this.addToolDamage(stack, 1, player, player); world.playSound(null, pos.getX() + 0.5d, pos.getY() + 0.5d, pos.getZ() + 0.5d, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0f, 1.0f); return true; } } return false; }