Java Code Examples for net.minecraft.init.Blocks.BEDROCK

The following are Jave code examples for showing how to use BEDROCK of the net.minecraft.init.Blocks class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: HeroUtils   File: SnowCepter.java   View Source Code Vote up 6 votes
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
	super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected);
	
	if (isSelected) {
		double x = entityIn.posX;
		double y = entityIn.posY;
		double z = entityIn.posZ;
		
		BlockPos pos = new BlockPos(x, --y, z);
		
		if (entityIn instanceof EntityPlayer 
				&& !worldIn.isAirBlock(pos) 
				&& worldIn.getBlockState(pos).getBlock() != Blocks.BEDROCK 
				&& worldIn.getBlockState(pos).getBlock() != Blocks.SNOW
				&& worldIn.getBlockState(pos).getBlock() != Blocks.LAVA
				&& worldIn.getBlockState(pos).getBlock() != Blocks.WATER
				&& worldIn.getBlockState(pos).isFullBlock()
				&& worldIn.getBlockState(pos).isFullCube()) {
			
			worldIn.setBlockState(pos, Blocks.SNOW.getDefaultState());
			
		}
	}
}
 
Example 2
Project: uniquecrops   File: Petramia.java   View Source Code Vote up 6 votes
private void transformBedrock(World world, BlockPos pos) {
	
	Iterable<BlockPos> poslist = BlockPos.getAllInBox(pos.add(-range, -range, -range), pos.add(range, 0, range));
	Iterator posit = poslist.iterator();
	while (posit.hasNext()) {
		BlockPos looppos = (BlockPos)posit.next();
		if (!world.isAirBlock(looppos) && world.getBlockState(looppos).getBlock() == Blocks.BEDROCK) {
			if (looppos.getY() <= 1) continue;
			if (world.rand.nextBoolean()) {
				world.setBlockState(looppos, UCBlocks.darkBlock.getDefaultState(), 2);
				UCPacketHandler.sendToNearbyPlayers(world, looppos, new PacketUCEffect(EnumParticleTypes.CLOUD, looppos.getX(), looppos.getY(), looppos.getZ(), 6));
				return;
			}
		}
	}
}
 
Example 3
Project: ArcaneMagic   File: ItemParchment.java   View Source Code Vote up 5 votes
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing,
		float hitX, float hitY, float hitZ)
{
	if (player.getHeldItem(hand).getItem().equals(ModRegistry.ANCIENT_PARCHMENT))
	{
		if (world.isRemote)
		{
			return EnumActionResult.PASS;
		}
		Block block = world.getBlockState(pos).getBlock();

		if (player.isSneaking() && block == Blocks.BEDROCK)
		{
			player.getCooldownTracker().setCooldown(player.getHeldItem(hand).getItem(), 150);

			player.getHeldItem(hand).shrink(1);
			world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ArcaneMagicSoundHandler.spell,
					SoundCategory.MASTER, 1f, 1f);

			world.spawnEntity(new EntityMagicCircles(world, pos.getX(), pos.getY(), pos.getZ()));

			return EnumActionResult.SUCCESS;
		}

	}
	return EnumActionResult.PASS;
}
 
Example 4
Project: Thermionics   File: BigExplosion.java   View Source Code Vote up 5 votes
public float explodeBlock(World world, BlockPos pos, float power) {
	if (world.isAirBlock(pos)) return power;
	
	IBlockState state = world.getBlockState(pos);
	Block block = state.getBlock();
	
	if (block==Blocks.BEDROCK) return 0;
	
	//Just delete fluids without examination or notification so their neighbors don't try to fill them in.
	if (isFluid(block)) {
		world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2 | 16);
		return power;
	}
	
	float resistance = block.getExplosionResistance(world, pos, null, dummyExplosion);
	if (resistance>power) return 0;
	
	boolean drop = state.getBlock().canDropFromExplosion(dummyExplosion);
	
	if (drop && world.rand.nextInt(1000)==5) {
		block.dropBlockAsItem(world, pos, state, 0);
	}
	//block.onBlockExploded(world, pos, dummyExplosion); //Also calls onBlockDestroyedByExplosion
	
	if (pos.getY()>4) {
		world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2 | 16); //Observers are blinded by explosions or something
	} else {
		world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2 | 16); //Don't know if the chest bug still exists, but if it does we'll be safe with this line.
		world.setBlockState(pos, Blocks.OBSIDIAN.getDefaultState(), 2 | 16); //If we're that strong, glass the crater floor.
	}
	return power - (int)(resistance*RESISTANCE_SCALE);
}
 
Example 5
Project: Backmemed   File: DragonFightManager.java   View Source Code Vote up 5 votes
private void generatePortal(boolean active)
{
    WorldGenEndPodium worldgenendpodium = new WorldGenEndPodium(active);

    if (this.exitPortalLocation == null)
    {
        for (this.exitPortalLocation = this.world.getTopSolidOrLiquidBlock(WorldGenEndPodium.END_PODIUM_LOCATION).down(); this.world.getBlockState(this.exitPortalLocation).getBlock() == Blocks.BEDROCK && this.exitPortalLocation.getY() > this.world.getSeaLevel(); this.exitPortalLocation = this.exitPortalLocation.down())
        {
            ;
        }
    }

    worldgenendpodium.generate(this.world, new Random(), this.exitPortalLocation);
}
 
Example 6
Project: Backmemed   File: DragonFightManager.java   View Source Code Vote up 5 votes
private void respawnDragon(List<EntityEnderCrystal> crystalsIn)
{
    if (this.dragonKilled && this.respawnState == null)
    {
        for (BlockPattern.PatternHelper blockpattern$patternhelper = this.findExitPortal(); blockpattern$patternhelper != null; blockpattern$patternhelper = this.findExitPortal())
        {
            for (int i = 0; i < this.portalPattern.getPalmLength(); ++i)
            {
                for (int j = 0; j < this.portalPattern.getThumbLength(); ++j)
                {
                    for (int k = 0; k < this.portalPattern.getFingerLength(); ++k)
                    {
                        BlockWorldState blockworldstate = blockpattern$patternhelper.translateOffset(i, j, k);

                        if (blockworldstate.getBlockState().getBlock() == Blocks.BEDROCK || blockworldstate.getBlockState().getBlock() == Blocks.END_PORTAL)
                        {
                            this.world.setBlockState(blockworldstate.getPos(), Blocks.END_STONE.getDefaultState());
                        }
                    }
                }
            }
        }

        this.respawnState = DragonSpawnManager.START;
        this.respawnStateTicks = 0;
        this.generatePortal(false);
        this.crystals = crystalsIn;
    }
}
 
Example 7
Project: Backmemed   File: WorldEntitySpawner.java   View Source Code Vote up 5 votes
public static boolean canCreatureTypeSpawnAtLocation(EntityLiving.SpawnPlacementType spawnPlacementTypeIn, World worldIn, BlockPos pos)
{
    if (!worldIn.getWorldBorder().contains(pos))
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (spawnPlacementTypeIn == EntityLiving.SpawnPlacementType.IN_WATER)
        {
            return iblockstate.getMaterial() == Material.WATER && worldIn.getBlockState(pos.down()).getMaterial() == Material.WATER && !worldIn.getBlockState(pos.up()).isNormalCube();
        }
        else
        {
            BlockPos blockpos = pos.down();

            if (!worldIn.getBlockState(blockpos).isFullyOpaque())
            {
                return false;
            }
            else
            {
                Block block = worldIn.getBlockState(blockpos).getBlock();
                boolean flag = block != Blocks.BEDROCK && block != Blocks.BARRIER;
                return flag && isValidEmptySpawnBlock(iblockstate) && isValidEmptySpawnBlock(worldIn.getBlockState(pos.up()));
            }
        }
    }
}
 
Example 8
Project: Backmemed   File: TileEntityEndGateway.java   View Source Code Vote up 5 votes
private static BlockPos findHighestBlock(World p_184308_0_, BlockPos p_184308_1_, int p_184308_2_, boolean p_184308_3_)
{
    BlockPos blockpos = null;

    for (int i = -p_184308_2_; i <= p_184308_2_; ++i)
    {
        for (int j = -p_184308_2_; j <= p_184308_2_; ++j)
        {
            if (i != 0 || j != 0 || p_184308_3_)
            {
                for (int k = 255; k > (blockpos == null ? 0 : blockpos.getY()); --k)
                {
                    BlockPos blockpos1 = new BlockPos(p_184308_1_.getX() + i, k, p_184308_1_.getZ() + j);
                    IBlockState iblockstate = p_184308_0_.getBlockState(blockpos1);

                    if (iblockstate.isBlockNormalCube() && (p_184308_3_ || iblockstate.getBlock() != Blocks.BEDROCK))
                    {
                        blockpos = blockpos1;
                        break;
                    }
                }
            }
        }
    }

    return blockpos == null ? p_184308_1_ : blockpos;
}
 
Example 9
Project: CustomWorldGen   File: DragonFightManager.java   View Source Code Vote up 5 votes
private void generatePortal(boolean active)
{
    WorldGenEndPodium worldgenendpodium = new WorldGenEndPodium(active);

    if (this.exitPortalLocation == null)
    {
        for (this.exitPortalLocation = this.world.getTopSolidOrLiquidBlock(WorldGenEndPodium.END_PODIUM_LOCATION).down(); this.world.getBlockState(this.exitPortalLocation).getBlock() == Blocks.BEDROCK && this.exitPortalLocation.getY() > this.world.getSeaLevel(); this.exitPortalLocation = this.exitPortalLocation.down())
        {
            ;
        }
    }

    worldgenendpodium.generate(this.world, new Random(), this.exitPortalLocation);
}
 
Example 10
Project: CustomWorldGen   File: DragonFightManager.java   View Source Code Vote up 5 votes
private void respawnDragon(List<EntityEnderCrystal> crystalsIn)
{
    if (this.dragonKilled && this.respawnState == null)
    {
        for (BlockPattern.PatternHelper blockpattern$patternhelper = this.findExitPortal(); blockpattern$patternhelper != null; blockpattern$patternhelper = this.findExitPortal())
        {
            for (int i = 0; i < this.portalPattern.getPalmLength(); ++i)
            {
                for (int j = 0; j < this.portalPattern.getThumbLength(); ++j)
                {
                    for (int k = 0; k < this.portalPattern.getFingerLength(); ++k)
                    {
                        BlockWorldState blockworldstate = blockpattern$patternhelper.translateOffset(i, j, k);

                        if (blockworldstate.getBlockState().getBlock() == Blocks.BEDROCK || blockworldstate.getBlockState().getBlock() == Blocks.END_PORTAL)
                        {
                            this.world.setBlockState(blockworldstate.getPos(), Blocks.END_STONE.getDefaultState());
                        }
                    }
                }
            }
        }

        this.respawnState = DragonSpawnManager.START;
        this.respawnStateTicks = 0;
        this.generatePortal(false);
        this.crystals = crystalsIn;
    }
}
 
Example 11
Project: CustomWorldGen   File: WorldEntitySpawner.java   View Source Code Vote up 5 votes
public static boolean canCreatureTypeSpawnAtLocation(EntityLiving.SpawnPlacementType spawnPlacementTypeIn, World worldIn, BlockPos pos)
{
    if (!worldIn.getWorldBorder().contains(pos))
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (spawnPlacementTypeIn == EntityLiving.SpawnPlacementType.IN_WATER)
        {
            return iblockstate.getMaterial().isLiquid() && worldIn.getBlockState(pos.down()).getMaterial().isLiquid() && !worldIn.getBlockState(pos.up()).isNormalCube();
        }
        else
        {
            BlockPos blockpos = pos.down();
            IBlockState state = worldIn.getBlockState(blockpos);

            if (!state.getBlock().canCreatureSpawn(state, worldIn, blockpos, spawnPlacementTypeIn))
            {
                return false;
            }
            else
            {
                Block block = worldIn.getBlockState(blockpos).getBlock();
                boolean flag = block != Blocks.BEDROCK && block != Blocks.BARRIER;
                return flag && isValidEmptySpawnBlock(iblockstate) && isValidEmptySpawnBlock(worldIn.getBlockState(pos.up()));
            }
        }
    }
}
 
Example 12
Project: CustomWorldGen   File: TileEntityEndGateway.java   View Source Code Vote up 5 votes
private static BlockPos findHighestBlock(World p_184308_0_, BlockPos p_184308_1_, int p_184308_2_, boolean p_184308_3_)
{
    BlockPos blockpos = null;

    for (int i = -p_184308_2_; i <= p_184308_2_; ++i)
    {
        for (int j = -p_184308_2_; j <= p_184308_2_; ++j)
        {
            if (i != 0 || j != 0 || p_184308_3_)
            {
                for (int k = 255; k > (blockpos == null ? 0 : blockpos.getY()); --k)
                {
                    BlockPos blockpos1 = new BlockPos(p_184308_1_.getX() + i, k, p_184308_1_.getZ() + j);
                    IBlockState iblockstate = p_184308_0_.getBlockState(blockpos1);

                    if (iblockstate.isBlockNormalCube() && (p_184308_3_ || iblockstate.getBlock() != Blocks.BEDROCK))
                    {
                        blockpos = blockpos1;
                        break;
                    }
                }
            }
        }
    }

    return blockpos == null ? p_184308_1_ : blockpos;
}
 
Example 13
Project: Backmemed   File: EntityWither.java   View Source Code Vote up 4 votes
public static boolean canDestroyBlock(Block blockIn)
{
    return blockIn != Blocks.BEDROCK && blockIn != Blocks.END_PORTAL && blockIn != Blocks.END_PORTAL_FRAME && blockIn != Blocks.COMMAND_BLOCK && blockIn != Blocks.REPEATING_COMMAND_BLOCK && blockIn != Blocks.CHAIN_COMMAND_BLOCK && blockIn != Blocks.BARRIER && blockIn != Blocks.STRUCTURE_BLOCK && blockIn != Blocks.STRUCTURE_VOID;
}
 
Example 14
Project: Backmemed   File: EntityDragon.java   View Source Code Vote up 4 votes
/**
 * Destroys all blocks that aren't associated with 'The End' inside the given bounding box.
 */
private boolean destroyBlocksInAABB(AxisAlignedBB p_70972_1_)
{
    int i = MathHelper.floor(p_70972_1_.minX);
    int j = MathHelper.floor(p_70972_1_.minY);
    int k = MathHelper.floor(p_70972_1_.minZ);
    int l = MathHelper.floor(p_70972_1_.maxX);
    int i1 = MathHelper.floor(p_70972_1_.maxY);
    int j1 = MathHelper.floor(p_70972_1_.maxZ);
    boolean flag = false;
    boolean flag1 = false;

    for (int k1 = i; k1 <= l; ++k1)
    {
        for (int l1 = j; l1 <= i1; ++l1)
        {
            for (int i2 = k; i2 <= j1; ++i2)
            {
                BlockPos blockpos = new BlockPos(k1, l1, i2);
                IBlockState iblockstate = this.world.getBlockState(blockpos);
                Block block = iblockstate.getBlock();

                if (iblockstate.getMaterial() != Material.AIR && iblockstate.getMaterial() != Material.FIRE)
                {
                    if (!this.world.getGameRules().getBoolean("mobGriefing"))
                    {
                        flag = true;
                    }
                    else if (block != Blocks.BARRIER && block != Blocks.OBSIDIAN && block != Blocks.END_STONE && block != Blocks.BEDROCK && block != Blocks.END_PORTAL && block != Blocks.END_PORTAL_FRAME)
                    {
                        if (block != Blocks.COMMAND_BLOCK && block != Blocks.REPEATING_COMMAND_BLOCK && block != Blocks.CHAIN_COMMAND_BLOCK && block != Blocks.IRON_BARS && block != Blocks.END_GATEWAY)
                        {
                            flag1 = this.world.setBlockToAir(blockpos) || flag1;
                        }
                        else
                        {
                            flag = true;
                        }
                    }
                    else
                    {
                        flag = true;
                    }
                }
            }
        }
    }

    if (flag1)
    {
        double d0 = p_70972_1_.minX + (p_70972_1_.maxX - p_70972_1_.minX) * (double)this.rand.nextFloat();
        double d1 = p_70972_1_.minY + (p_70972_1_.maxY - p_70972_1_.minY) * (double)this.rand.nextFloat();
        double d2 = p_70972_1_.minZ + (p_70972_1_.maxZ - p_70972_1_.minZ) * (double)this.rand.nextFloat();
        this.world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
    }

    return flag;
}
 
Example 15
Project: Backmemed   File: ItemEndCrystal.java   View Source Code Vote up 4 votes
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
    IBlockState iblockstate = playerIn.getBlockState(worldIn);

    if (iblockstate.getBlock() != Blocks.OBSIDIAN && iblockstate.getBlock() != Blocks.BEDROCK)
    {
        return EnumActionResult.FAIL;
    }
    else
    {
        BlockPos blockpos = worldIn.up();
        ItemStack itemstack = stack.getHeldItem(pos);

        if (!stack.canPlayerEdit(blockpos, hand, itemstack))
        {
            return EnumActionResult.FAIL;
        }
        else
        {
            BlockPos blockpos1 = blockpos.up();
            boolean flag = !playerIn.isAirBlock(blockpos) && !playerIn.getBlockState(blockpos).getBlock().isReplaceable(playerIn, blockpos);
            flag = flag | (!playerIn.isAirBlock(blockpos1) && !playerIn.getBlockState(blockpos1).getBlock().isReplaceable(playerIn, blockpos1));

            if (flag)
            {
                return EnumActionResult.FAIL;
            }
            else
            {
                double d0 = (double)blockpos.getX();
                double d1 = (double)blockpos.getY();
                double d2 = (double)blockpos.getZ();
                List<Entity> list = playerIn.getEntitiesWithinAABBExcludingEntity((Entity)null, new AxisAlignedBB(d0, d1, d2, d0 + 1.0D, d1 + 2.0D, d2 + 1.0D));

                if (!list.isEmpty())
                {
                    return EnumActionResult.FAIL;
                }
                else
                {
                    if (!playerIn.isRemote)
                    {
                        EntityEnderCrystal entityendercrystal = new EntityEnderCrystal(playerIn, (double)((float)worldIn.getX() + 0.5F), (double)(worldIn.getY() + 1), (double)((float)worldIn.getZ() + 0.5F));
                        entityendercrystal.setShowBottom(false);
                        playerIn.spawnEntityInWorld(entityendercrystal);

                        if (playerIn.provider instanceof WorldProviderEnd)
                        {
                            DragonFightManager dragonfightmanager = ((WorldProviderEnd)playerIn.provider).getDragonFightManager();
                            dragonfightmanager.respawnDragon();
                        }
                    }

                    itemstack.func_190918_g(1);
                    return EnumActionResult.SUCCESS;
                }
            }
        }
    }
}
 
Example 16
Project: CustomWorldGen   File: EntityWither.java   View Source Code Vote up 4 votes
public static boolean canDestroyBlock(Block blockIn)
{
    return blockIn != Blocks.BEDROCK && blockIn != Blocks.END_PORTAL && blockIn != Blocks.END_PORTAL_FRAME && blockIn != Blocks.COMMAND_BLOCK && blockIn != Blocks.REPEATING_COMMAND_BLOCK && blockIn != Blocks.CHAIN_COMMAND_BLOCK && blockIn != Blocks.BARRIER;
}
 
Example 17
Project: CustomWorldGen   File: ItemEndCrystal.java   View Source Code Vote up 4 votes
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (iblockstate.getBlock() != Blocks.OBSIDIAN && iblockstate.getBlock() != Blocks.BEDROCK)
    {
        return EnumActionResult.FAIL;
    }
    else
    {
        BlockPos blockpos = pos.up();

        if (!playerIn.canPlayerEdit(blockpos, facing, stack))
        {
            return EnumActionResult.FAIL;
        }
        else
        {
            BlockPos blockpos1 = blockpos.up();
            boolean flag = !worldIn.isAirBlock(blockpos) && !worldIn.getBlockState(blockpos).getBlock().isReplaceable(worldIn, blockpos);
            flag = flag | (!worldIn.isAirBlock(blockpos1) && !worldIn.getBlockState(blockpos1).getBlock().isReplaceable(worldIn, blockpos1));

            if (flag)
            {
                return EnumActionResult.FAIL;
            }
            else
            {
                double d0 = (double)blockpos.getX();
                double d1 = (double)blockpos.getY();
                double d2 = (double)blockpos.getZ();
                List<Entity> list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity)null, new AxisAlignedBB(d0, d1, d2, d0 + 1.0D, d1 + 2.0D, d2 + 1.0D));

                if (!list.isEmpty())
                {
                    return EnumActionResult.FAIL;
                }
                else
                {
                    if (!worldIn.isRemote)
                    {
                        EntityEnderCrystal entityendercrystal = new EntityEnderCrystal(worldIn, (double)((float)pos.getX() + 0.5F), (double)(pos.getY() + 1), (double)((float)pos.getZ() + 0.5F));
                        entityendercrystal.setShowBottom(false);
                        worldIn.spawnEntityInWorld(entityendercrystal);

                        if (worldIn.provider instanceof WorldProviderEnd)
                        {
                            DragonFightManager dragonfightmanager = ((WorldProviderEnd)worldIn.provider).getDragonFightManager();
                            dragonfightmanager.respawnDragon();
                        }
                    }

                    --stack.stackSize;
                    return EnumActionResult.SUCCESS;
                }
            }
        }
    }
}