Java Code Examples for net.minecraft.world.World.doesBlockHaveSolidTopSurface()

The following are Jave code examples for showing how to use doesBlockHaveSolidTopSurface() of the net.minecraft.world.World class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: BaseClient   File: BlockFire.java   Source Code and License Vote up 6 votes
/**
 * Get the actual Block state of this Block at the given position. This applies properties not visible in the
 * metadata, such as fence connections.
 */
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
    int i = pos.getX();
    int j = pos.getY();
    int k = pos.getZ();

    if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && !Blocks.fire.canCatchFire(worldIn, pos.down()))
    {
        boolean flag = (i + j + k & 1) == 1;
        boolean flag1 = (i / 2 + j / 2 + k / 2 & 1) == 1;
        int l = 0;

        if (this.canCatchFire(worldIn, pos.up()))
        {
            l = flag ? 1 : 2;
        }

        return state.withProperty(NORTH, Boolean.valueOf(this.canCatchFire(worldIn, pos.north()))).withProperty(EAST, Boolean.valueOf(this.canCatchFire(worldIn, pos.east()))).withProperty(SOUTH, Boolean.valueOf(this.canCatchFire(worldIn, pos.south()))).withProperty(WEST, Boolean.valueOf(this.canCatchFire(worldIn, pos.west()))).withProperty(UPPER, Integer.valueOf(l)).withProperty(FLIP, Boolean.valueOf(flag1)).withProperty(ALT, Boolean.valueOf(flag));
    }
    else
    {
        return this.getDefaultState();
    }
}
 
Example 2
Project: DecompiledMinecraft   File: Village.java   Source Code and License Vote up 5 votes
private boolean func_179861_a(BlockPos p_179861_1_, BlockPos p_179861_2_)
{
    if (!World.doesBlockHaveSolidTopSurface(this.worldObj, p_179861_2_.down()))
    {
        return false;
    }
    else
    {
        int i = p_179861_2_.getX() - p_179861_1_.getX() / 2;
        int j = p_179861_2_.getZ() - p_179861_1_.getZ() / 2;

        for (int k = i; k < i + p_179861_1_.getX(); ++k)
        {
            for (int l = p_179861_2_.getY(); l < p_179861_2_.getY() + p_179861_1_.getY(); ++l)
            {
                for (int i1 = j; i1 < j + p_179861_1_.getZ(); ++i1)
                {
                    if (this.worldObj.getBlockState(new BlockPos(k, l, i1)).getBlock().isNormalCube())
                    {
                        return false;
                    }
                }
            }
        }

        return true;
    }
}
 
Example 3
Project: BaseClient   File: BlockFire.java   Source Code and License Vote up 5 votes
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
    if (worldIn.provider.getDimensionId() > 0 || !Blocks.portal.func_176548_d(worldIn, pos))
    {
        if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && !this.canNeighborCatchFire(worldIn, pos))
        {
            worldIn.setBlockToAir(pos);
        }
        else
        {
            worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn) + worldIn.rand.nextInt(10));
        }
    }
}
 
Example 4
Project: DecompiledMinecraft   File: EntityAIFollowOwner.java   Source Code and License Vote up 5 votes
/**
 * Updates the task
 */
public void updateTask()
{
    this.thePet.getLookHelper().setLookPositionWithEntity(this.theOwner, 10.0F, (float)this.thePet.getVerticalFaceSpeed());

    if (!this.thePet.isSitting())
    {
        if (--this.field_75343_h <= 0)
        {
            this.field_75343_h = 10;

            if (!this.petPathfinder.tryMoveToEntityLiving(this.theOwner, this.followSpeed))
            {
                if (!this.thePet.getLeashed())
                {
                    if (this.thePet.getDistanceSqToEntity(this.theOwner) >= 144.0D)
                    {
                        int i = MathHelper.floor_double(this.theOwner.posX) - 2;
                        int j = MathHelper.floor_double(this.theOwner.posZ) - 2;
                        int k = MathHelper.floor_double(this.theOwner.getEntityBoundingBox().minY);

                        for (int l = 0; l <= 4; ++l)
                        {
                            for (int i1 = 0; i1 <= 4; ++i1)
                            {
                                if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && World.doesBlockHaveSolidTopSurface(this.theWorld, new BlockPos(i + l, k - 1, j + i1)) && this.func_181065_a(new BlockPos(i + l, k, j + i1)) && this.func_181065_a(new BlockPos(i + l, k + 1, j + i1)))
                                {
                                    this.thePet.setLocationAndAngles((double)((float)(i + l) + 0.5F), (double)k, (double)((float)(j + i1) + 0.5F), this.thePet.rotationYaw, this.thePet.rotationPitch);
                                    this.petPathfinder.clearPathEntity();
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
 
Example 5
Project: BaseClient   File: BlockTripWire.java   Source Code and License Vote up 5 votes
/**
 * Called when a neighboring block changes.
 */
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
    boolean flag = ((Boolean)state.getValue(SUSPENDED)).booleanValue();
    boolean flag1 = !World.doesBlockHaveSolidTopSurface(worldIn, pos.down());

    if (flag != flag1)
    {
        this.dropBlockAsItem(worldIn, pos, state, 0);
        worldIn.setBlockToAir(pos);
    }
}
 
Example 6
Project: BaseClient   File: EntityAIFollowOwner.java   Source Code and License Vote up 5 votes
/**
 * Updates the task
 */
public void updateTask()
{
    this.thePet.getLookHelper().setLookPositionWithEntity(this.theOwner, 10.0F, (float)this.thePet.getVerticalFaceSpeed());

    if (!this.thePet.isSitting())
    {
        if (--this.field_75343_h <= 0)
        {
            this.field_75343_h = 10;

            if (!this.petPathfinder.tryMoveToEntityLiving(this.theOwner, this.followSpeed))
            {
                if (!this.thePet.getLeashed())
                {
                    if (this.thePet.getDistanceSqToEntity(this.theOwner) >= 144.0D)
                    {
                        int i = MathHelper.floor_double(this.theOwner.posX) - 2;
                        int j = MathHelper.floor_double(this.theOwner.posZ) - 2;
                        int k = MathHelper.floor_double(this.theOwner.getEntityBoundingBox().minY);

                        for (int l = 0; l <= 4; ++l)
                        {
                            for (int i1 = 0; i1 <= 4; ++i1)
                            {
                                if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && World.doesBlockHaveSolidTopSurface(this.theWorld, new BlockPos(i + l, k - 1, j + i1)) && this.func_181065_a(new BlockPos(i + l, k, j + i1)) && this.func_181065_a(new BlockPos(i + l, k + 1, j + i1)))
                                {
                                    this.thePet.setLocationAndAngles((double)((float)(i + l) + 0.5F), (double)k, (double)((float)(j + i1) + 0.5F), this.thePet.rotationYaw, this.thePet.rotationPitch);
                                    this.petPathfinder.clearPathEntity();
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
 
Example 7
Project: BaseClient   File: Village.java   Source Code and License Vote up 5 votes
private boolean func_179861_a(BlockPos p_179861_1_, BlockPos p_179861_2_)
{
    if (!World.doesBlockHaveSolidTopSurface(this.worldObj, p_179861_2_.down()))
    {
        return false;
    }
    else
    {
        int i = p_179861_2_.getX() - p_179861_1_.getX() / 2;
        int j = p_179861_2_.getZ() - p_179861_1_.getZ() / 2;

        for (int k = i; k < i + p_179861_1_.getX(); ++k)
        {
            for (int l = p_179861_2_.getY(); l < p_179861_2_.getY() + p_179861_1_.getY(); ++l)
            {
                for (int i1 = j; i1 < j + p_179861_1_.getZ(); ++i1)
                {
                    if (this.worldObj.getBlockState(new BlockPos(k, l, i1)).getBlock().isNormalCube())
                    {
                        return false;
                    }
                }
            }
        }

        return true;
    }
}
 
Example 8
Project: BaseClient   File: BlockPumpkin.java   Source Code and License Vote up 4 votes
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
    return worldIn.getBlockState(pos).getBlock().blockMaterial.isReplaceable() && World.doesBlockHaveSolidTopSurface(worldIn, pos.down());
}
 
Example 9
Project: BaseClient   File: BlockBasePressurePlate.java   Source Code and License Vote up 4 votes
private boolean canBePlacedOn(World worldIn, BlockPos pos)
{
    return World.doesBlockHaveSolidTopSurface(worldIn, pos) || worldIn.getBlockState(pos).getBlock() instanceof BlockFence;
}
 
Example 10
Project: DecompiledMinecraft   File: BlockRailBase.java   Source Code and License Vote up 4 votes
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
    return World.doesBlockHaveSolidTopSurface(worldIn, pos.down());
}
 
Example 11
Project: BaseClient   File: BlockSponge.java   Source Code and License Vote up 4 votes
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (((Boolean)state.getValue(WET)).booleanValue())
    {
        EnumFacing enumfacing = EnumFacing.random(rand);

        if (enumfacing != EnumFacing.UP && !World.doesBlockHaveSolidTopSurface(worldIn, pos.offset(enumfacing)))
        {
            double d0 = (double)pos.getX();
            double d1 = (double)pos.getY();
            double d2 = (double)pos.getZ();

            if (enumfacing == EnumFacing.DOWN)
            {
                d1 = d1 - 0.05D;
                d0 += rand.nextDouble();
                d2 += rand.nextDouble();
            }
            else
            {
                d1 = d1 + rand.nextDouble() * 0.8D;

                if (enumfacing.getAxis() == EnumFacing.Axis.X)
                {
                    d2 += rand.nextDouble();

                    if (enumfacing == EnumFacing.EAST)
                    {
                        ++d0;
                    }
                    else
                    {
                        d0 += 0.05D;
                    }
                }
                else
                {
                    d0 += rand.nextDouble();

                    if (enumfacing == EnumFacing.SOUTH)
                    {
                        ++d2;
                    }
                    else
                    {
                        d2 += 0.05D;
                    }
                }
            }

            worldIn.spawnParticle(EnumParticleTypes.DRIP_WATER, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
        }
    }
}
 
Example 12
Project: DecompiledMinecraft   File: BlockFlowerPot.java   Source Code and License Vote up 4 votes
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
    return super.canPlaceBlockAt(worldIn, pos) && World.doesBlockHaveSolidTopSurface(worldIn, pos.down());
}
 
Example 13
Project: BaseClient   File: BlockRailBase.java   Source Code and License Vote up 4 votes
/**
 * Called when a neighboring block changes.
 */
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
    if (!worldIn.isRemote)
    {
        BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)state.getValue(this.getShapeProperty());
        boolean flag = false;

        if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()))
        {
            flag = true;
        }

        if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_EAST && !World.doesBlockHaveSolidTopSurface(worldIn, pos.east()))
        {
            flag = true;
        }
        else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_WEST && !World.doesBlockHaveSolidTopSurface(worldIn, pos.west()))
        {
            flag = true;
        }
        else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_NORTH && !World.doesBlockHaveSolidTopSurface(worldIn, pos.north()))
        {
            flag = true;
        }
        else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_SOUTH && !World.doesBlockHaveSolidTopSurface(worldIn, pos.south()))
        {
            flag = true;
        }

        if (flag)
        {
            this.dropBlockAsItem(worldIn, pos, state, 0);
            worldIn.setBlockToAir(pos);
        }
        else
        {
            this.onNeighborChangedInternal(worldIn, pos, state, neighborBlock);
        }
    }
}
 
Example 14
Project: BaseClient   File: BlockDoor.java   Source Code and License Vote up 4 votes
/**
 * Called when a neighboring block changes.
 */
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
    if (state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER)
    {
        BlockPos blockpos = pos.down();
        IBlockState iblockstate = worldIn.getBlockState(blockpos);

        if (iblockstate.getBlock() != this)
        {
            worldIn.setBlockToAir(pos);
        }
        else if (neighborBlock != this)
        {
            this.onNeighborBlockChange(worldIn, blockpos, iblockstate, neighborBlock);
        }
    }
    else
    {
        boolean flag1 = false;
        BlockPos blockpos1 = pos.up();
        IBlockState iblockstate1 = worldIn.getBlockState(blockpos1);

        if (iblockstate1.getBlock() != this)
        {
            worldIn.setBlockToAir(pos);
            flag1 = true;
        }

        if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()))
        {
            worldIn.setBlockToAir(pos);
            flag1 = true;

            if (iblockstate1.getBlock() == this)
            {
                worldIn.setBlockToAir(blockpos1);
            }
        }

        if (flag1)
        {
            if (!worldIn.isRemote)
            {
                this.dropBlockAsItem(worldIn, pos, state, 0);
            }
        }
        else
        {
            boolean flag = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(blockpos1);

            if ((flag || neighborBlock.canProvidePower()) && neighborBlock != this && flag != ((Boolean)iblockstate1.getValue(POWERED)).booleanValue())
            {
                worldIn.setBlockState(blockpos1, iblockstate1.withProperty(POWERED, Boolean.valueOf(flag)), 2);

                if (flag != ((Boolean)state.getValue(OPEN)).booleanValue())
                {
                    worldIn.setBlockState(pos, state.withProperty(OPEN, Boolean.valueOf(flag)), 2);
                    worldIn.markBlockRangeForRenderUpdate(pos, pos);
                    worldIn.playAuxSFXAtEntity((EntityPlayer)null, flag ? 1003 : 1006, pos, 0);
                }
            }
        }
    }
}
 
Example 15
Project: BaseClient   File: BlockFire.java   Source Code and License Vote up 4 votes
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
    return World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) || this.canNeighborCatchFire(worldIn, pos);
}
 
Example 16
Project: BaseClient   File: BlockRedstoneWire.java   Source Code and License Vote up 4 votes
public boolean canPlaceBlockAt(World worldIn, BlockPos pos) {
	return World.doesBlockHaveSolidTopSurface(worldIn, pos.down())
			|| worldIn.getBlockState(pos.down()).getBlock() == Blocks.glowstone;
}
 
Example 17
Project: BaseClient   File: BlockPumpkin.java   Source Code and License Vote up 4 votes
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
    return worldIn.getBlockState(pos).getBlock().blockMaterial.isReplaceable() && World.doesBlockHaveSolidTopSurface(worldIn, pos.down());
}
 
Example 18
Project: DecompiledMinecraft   File: BlockBed.java   Source Code and License Vote up 4 votes
protected static boolean hasRoomForPlayer(World worldIn, BlockPos pos)
{
    return World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && !worldIn.getBlockState(pos).getBlock().getMaterial().isSolid() && !worldIn.getBlockState(pos.up()).getBlock().getMaterial().isSolid();
}
 
Example 19
Project: BaseClient   File: BlockBed.java   Source Code and License Vote up 4 votes
protected static boolean hasRoomForPlayer(World worldIn, BlockPos pos)
{
    return World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && !worldIn.getBlockState(pos).getBlock().getMaterial().isSolid() && !worldIn.getBlockState(pos.up()).getBlock().getMaterial().isSolid();
}
 
Example 20
Project: DecompiledMinecraft   File: BlockPumpkin.java   Source Code and License Vote up 4 votes
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
    return worldIn.getBlockState(pos).getBlock().blockMaterial.isReplaceable() && World.doesBlockHaveSolidTopSurface(worldIn, pos.down());
}