當前位置: 首頁>>代碼示例>>Java>>正文


Java Material.isSolid方法代碼示例

本文整理匯總了Java中net.minecraft.block.material.Material.isSolid方法的典型用法代碼示例。如果您正苦於以下問題:Java Material.isSolid方法的具體用法?Java Material.isSolid怎麽用?Java Material.isSolid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.block.material.Material的用法示例。


在下文中一共展示了Material.isSolid方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: canBlockStay

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
public boolean canBlockStay(World worldIn, BlockPos pos)
{
    for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
    {
        Material material = worldIn.getBlockState(pos.offset(enumfacing)).getMaterial();

        if (material.isSolid() || material == Material.LAVA)
        {
            return false;
        }
    }

    Block block = worldIn.getBlockState(pos.down()).getBlock();
    return block == Blocks.CACTUS || block == Blocks.SAND && !worldIn.getBlockState(pos.up()).getMaterial().isLiquid();
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:16,代碼來源:BlockCactus.java

示例2: canBlockStay

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
public boolean canBlockStay(World worldIn, BlockPos pos)
{
    for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
    {
        Material material = worldIn.getBlockState(pos.offset(enumfacing)).getMaterial();

        if (material.isSolid() || material == Material.LAVA)
        {
            return false;
        }
    }

    IBlockState state = worldIn.getBlockState(pos.down());
    return state.getBlock().canSustainPlant(state, worldIn, pos.down(), EnumFacing.UP, this) && !worldIn.getBlockState(pos.up()).getMaterial().isLiquid();
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:16,代碼來源:BlockCactus.java

示例3: tryPlaceContainedLiquid

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
public boolean tryPlaceContainedLiquid(World worldIn, BlockPos pos)
{
    if (this.isFull == Blocks.air)
    {
        return false;
    }
    else
    {
        Material material = worldIn.getBlockState(pos).getBlock().getMaterial();
        boolean flag = !material.isSolid();

        if (!worldIn.isAirBlock(pos) && !flag)
        {
            return false;
        }
        else
        {
            if (worldIn.provider.doesWaterVaporize() && this.isFull == Blocks.flowing_water)
            {
                int i = pos.getX();
                int j = pos.getY();
                int k = pos.getZ();
                worldIn.playSoundEffect((double)((float)i + 0.5F), (double)((float)j + 0.5F), (double)((float)k + 0.5F), "random.fizz", 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);

                for (int l = 0; l < 8; ++l)
                {
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, (double)i + Math.random(), (double)j + Math.random(), (double)k + Math.random(), 0.0D, 0.0D, 0.0D, new int[0]);
                }
            }
            else
            {
                if (!worldIn.isRemote && flag && !material.isLiquid())
                {
                    worldIn.destroyBlock(pos, true);
                }

                worldIn.setBlockState(pos, this.isFull.getDefaultState(), 3);
            }

            return true;
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:44,代碼來源:ItemBucket.java

示例4: onUpdate

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
/**
 * Called to update the entity's position/logic.
 */
public void onUpdate()
{
    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    this.motionY -= (double)this.particleGravity;
    this.moveEntity(this.motionX, this.motionY, this.motionZ);
    this.motionX *= 0.9800000190734863D;
    this.motionY *= 0.9800000190734863D;
    this.motionZ *= 0.9800000190734863D;

    if (this.particleMaxAge-- <= 0)
    {
        this.setDead();
    }

    if (this.onGround)
    {
        if (Math.random() < 0.5D)
        {
            this.setDead();
        }

        this.motionX *= 0.699999988079071D;
        this.motionZ *= 0.699999988079071D;
    }

    BlockPos blockpos = new BlockPos(this);
    IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
    Block block = iblockstate.getBlock();
    block.setBlockBoundsBasedOnState(this.worldObj, blockpos);
    Material material = iblockstate.getBlock().getMaterial();

    if (material.isLiquid() || material.isSolid())
    {
        double d0 = 0.0D;

        if (iblockstate.getBlock() instanceof BlockLiquid)
        {
            d0 = (double)(1.0F - BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue()));
        }
        else
        {
            d0 = block.getBlockBoundsMaxY();
        }

        double d1 = (double)MathHelper.floor_double(this.posY) + d0;

        if (this.posY < d1)
        {
            this.setDead();
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:58,代碼來源:EntityRainFX.java

示例5: getFluidHeight

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
private float getFluidHeight(IBlockAccess blockAccess, BlockPos blockPosIn, Material blockMaterial)
{
    int i = 0;
    float f = 0.0F;

    for (int j = 0; j < 4; ++j)
    {
        BlockPos blockpos = blockPosIn.add(-(j & 1), 0, -(j >> 1 & 1));

        if (blockAccess.getBlockState(blockpos.up()).getBlock().getMaterial() == blockMaterial)
        {
            return 1.0F;
        }

        IBlockState iblockstate = blockAccess.getBlockState(blockpos);
        Material material = iblockstate.getBlock().getMaterial();

        if (material != blockMaterial)
        {
            if (!material.isSolid())
            {
                ++f;
                ++i;
            }
        }
        else
        {
            int k = ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue();

            if (k >= 8 || k == 0)
            {
                f += BlockLiquid.getLiquidHeightPercent(k) * 10.0F;
                i += 10;
            }

            f += BlockLiquid.getLiquidHeightPercent(k);
            ++i;
        }
    }

    return 1.0F - f / (float)i;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:43,代碼來源:BlockFluidRenderer.java

示例6: onUpdate

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
public void onUpdate()
{
    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    this.motionY -= (double)this.particleGravity;
    this.moveEntity(this.motionX, this.motionY, this.motionZ);
    this.motionX *= 0.9800000190734863D;
    this.motionY *= 0.9800000190734863D;
    this.motionZ *= 0.9800000190734863D;

    if (this.particleMaxAge-- <= 0)
    {
        this.setExpired();
    }

    if (this.isCollided)
    {
        if (Math.random() < 0.5D)
        {
            this.setExpired();
        }

        this.motionX *= 0.699999988079071D;
        this.motionZ *= 0.699999988079071D;
    }

    BlockPos blockpos = new BlockPos(this.posX, this.posY, this.posZ);
    IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
    Material material = iblockstate.getMaterial();

    if (material.isLiquid() || material.isSolid())
    {
        double d0;

        if (iblockstate.getBlock() instanceof BlockLiquid)
        {
            d0 = (double)(1.0F - BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue()));
        }
        else
        {
            d0 = iblockstate.getBoundingBox(this.worldObj, blockpos).maxY;
        }

        double d1 = (double)MathHelper.floor_double(this.posY) + d0;

        if (this.posY < d1)
        {
            this.setExpired();
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:53,代碼來源:ParticleRain.java

示例7: getIsSolid

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
public static boolean getIsSolid(Material mat) {
    return mat.isSolid();
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:4,代碼來源:ZWrapper.java

示例8: tryPlaceContainedLiquid

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
public boolean tryPlaceContainedLiquid(@Nullable EntityPlayer player, World worldIn, BlockPos posIn)
{
    if (this.containedBlock == Blocks.AIR)
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(posIn);
        Material material = iblockstate.getMaterial();
        boolean flag = !material.isSolid();
        boolean flag1 = iblockstate.getBlock().isReplaceable(worldIn, posIn);

        if (!worldIn.isAirBlock(posIn) && !flag && !flag1)
        {
            return false;
        }
        else
        {
            if (worldIn.provider.doesWaterVaporize() && this.containedBlock == Blocks.FLOWING_WATER)
            {
                int l = posIn.getX();
                int i = posIn.getY();
                int j = posIn.getZ();
                worldIn.playSound(player, posIn, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);

                for (int k = 0; k < 8; ++k)
                {
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, (double)l + Math.random(), (double)i + Math.random(), (double)j + Math.random(), 0.0D, 0.0D, 0.0D, new int[0]);
                }
            }
            else
            {
                if (!worldIn.isRemote && (flag || flag1) && !material.isLiquid())
                {
                    worldIn.destroyBlock(posIn, true);
                }

                SoundEvent soundevent = this.containedBlock == Blocks.FLOWING_LAVA ? SoundEvents.ITEM_BUCKET_EMPTY_LAVA : SoundEvents.ITEM_BUCKET_EMPTY;
                worldIn.playSound(player, posIn, soundevent, SoundCategory.BLOCKS, 1.0F, 1.0F);
                worldIn.setBlockState(posIn, this.containedBlock.getDefaultState(), 11);
            }

            return true;
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:48,代碼來源:ItemBucket.java

示例9: onUpdate

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
public void onUpdate()
{
    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;

    if (this.materialType == Material.WATER)
    {
        this.particleRed = 0.2F;
        this.particleGreen = 0.3F;
        this.particleBlue = 1.0F;
    }
    else
    {
        this.particleRed = 1.0F;
        this.particleGreen = 16.0F / (float)(40 - this.bobTimer + 16);
        this.particleBlue = 4.0F / (float)(40 - this.bobTimer + 8);
    }

    this.motionY -= (double)this.particleGravity;

    if (this.bobTimer-- > 0)
    {
        this.motionX *= 0.02D;
        this.motionY *= 0.02D;
        this.motionZ *= 0.02D;
        this.setParticleTextureIndex(113);
    }
    else
    {
        this.setParticleTextureIndex(112);
    }

    this.moveEntity(this.motionX, this.motionY, this.motionZ);
    this.motionX *= 0.9800000190734863D;
    this.motionY *= 0.9800000190734863D;
    this.motionZ *= 0.9800000190734863D;

    if (this.particleMaxAge-- <= 0)
    {
        this.setExpired();
    }

    if (this.isCollided)
    {
        if (this.materialType == Material.WATER)
        {
            this.setExpired();
            this.worldObj.spawnParticle(EnumParticleTypes.WATER_SPLASH, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
        }
        else
        {
            this.setParticleTextureIndex(114);
        }

        this.motionX *= 0.699999988079071D;
        this.motionZ *= 0.699999988079071D;
    }

    BlockPos blockpos = new BlockPos(this.posX, this.posY, this.posZ);
    IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
    Material material = iblockstate.getMaterial();

    if (material.isLiquid() || material.isSolid())
    {
        double d0 = 0.0D;

        if (iblockstate.getBlock() instanceof BlockLiquid)
        {
            d0 = (double)BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue());
        }

        double d1 = (double)(MathHelper.floor(this.posY) + 1) - d0;

        if (this.posY < d1)
        {
            this.setExpired();
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:81,代碼來源:ParticleDrip.java

示例10: onUpdate

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
public void onUpdate()
{
    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    this.motionY -= (double)this.particleGravity;
    this.moveEntity(this.motionX, this.motionY, this.motionZ);
    this.motionX *= 0.9800000190734863D;
    this.motionY *= 0.9800000190734863D;
    this.motionZ *= 0.9800000190734863D;

    if (this.particleMaxAge-- <= 0)
    {
        this.setExpired();
    }

    if (this.isCollided)
    {
        if (Math.random() < 0.5D)
        {
            this.setExpired();
        }

        this.motionX *= 0.699999988079071D;
        this.motionZ *= 0.699999988079071D;
    }

    BlockPos blockpos = new BlockPos(this.posX, this.posY, this.posZ);
    IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
    Material material = iblockstate.getMaterial();

    if (material.isLiquid() || material.isSolid())
    {
        double d0;

        if (iblockstate.getBlock() instanceof BlockLiquid)
        {
            d0 = (double)(1.0F - BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue()));
        }
        else
        {
            d0 = iblockstate.getBoundingBox(this.worldObj, blockpos).maxY;
        }

        double d1 = (double)MathHelper.floor(this.posY) + d0;

        if (this.posY < d1)
        {
            this.setExpired();
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:53,代碼來源:ParticleRain.java

示例11: getFluidHeight

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
private float getFluidHeight(IBlockAccess blockAccess, BlockPos blockPosIn, Material blockMaterial)
{
    int i = 0;
    float f = 0.0F;

    for (int j = 0; j < 4; ++j)
    {
        BlockPos blockpos = blockPosIn.add(-(j & 1), 0, -(j >> 1 & 1));

        if (blockAccess.getBlockState(blockpos.up()).getMaterial() == blockMaterial)
        {
            return 1.0F;
        }

        IBlockState iblockstate = blockAccess.getBlockState(blockpos);
        Material material = iblockstate.getMaterial();

        if (material != blockMaterial)
        {
            if (!material.isSolid())
            {
                ++f;
                ++i;
            }
        }
        else
        {
            int k = ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue();

            if (k >= 8 || k == 0)
            {
                f += BlockLiquid.getLiquidHeightPercent(k) * 10.0F;
                i += 10;
            }

            f += BlockLiquid.getLiquidHeightPercent(k);
            ++i;
        }
    }

    return 1.0F - f / (float)i;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:43,代碼來源:BlockFluidRenderer.java

示例12: tryPlaceFluid

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
/**
 * Tries to place a fluid in the world in block form.
 * Makes a fluid emptying sound when successful.
 * Checks if water-like fluids should vaporize like in the nether.
 *
 * Modeled after {@link net.minecraft.item.ItemBucket#tryPlaceContainedLiquid(EntityPlayer, World, BlockPos)}
 *
 * @param player     Player who places the fluid. May be null for blocks like dispensers.
 * @param worldIn    World to place the fluid in
 * @param fluidStack The fluidStack to place.
 * @param pos        The position in the world to place the fluid block
 * @return true if successful
 */
public static boolean tryPlaceFluid(@Nullable EntityPlayer player, World worldIn, FluidStack fluidStack, BlockPos pos)
{
    if (worldIn == null || fluidStack == null || pos == null)
    {
        return false;
    }

    Fluid fluid = fluidStack.getFluid();
    if (fluid == null || !fluid.canBePlacedInWorld())
    {
        return false;
    }

    // check that we can place the fluid at the destination
    IBlockState destBlockState = worldIn.getBlockState(pos);
    Material destMaterial = destBlockState.getMaterial();
    boolean isDestNonSolid = !destMaterial.isSolid();
    boolean isDestReplaceable = destBlockState.getBlock().isReplaceable(worldIn, pos);
    if (!worldIn.isAirBlock(pos) && !isDestNonSolid && !isDestReplaceable)
    {
        return false; // Non-air, solid, unreplacable block. We can't put fluid here.
    }

    if (worldIn.provider.doesWaterVaporize() && fluid.doesVaporize(fluidStack))
    {
        fluid.vaporize(player, worldIn, pos, fluidStack);
    }
    else
    {
        if (!worldIn.isRemote && (isDestNonSolid || isDestReplaceable) && !destMaterial.isLiquid())
        {
            worldIn.destroyBlock(pos, true);
        }

        SoundEvent soundevent = fluid.getEmptySound(fluidStack);
        worldIn.playSound(player, pos, soundevent, SoundCategory.BLOCKS, 1.0F, 1.0F);

        IBlockState fluidBlockState = fluid.getBlock().getDefaultState();
        worldIn.setBlockState(pos, fluidBlockState, 11);
    }
    return true;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:56,代碼來源:FluidUtil.java

示例13: onUpdate

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
public void onUpdate()
{
    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;

    if (this.materialType == Material.WATER)
    {
        this.particleRed = 0.2F;
        this.particleGreen = 0.3F;
        this.particleBlue = 1.0F;
    }
    else
    {
        this.particleRed = 1.0F;
        this.particleGreen = 16.0F / (float)(40 - this.bobTimer + 16);
        this.particleBlue = 4.0F / (float)(40 - this.bobTimer + 8);
    }

    this.motionY -= (double)this.particleGravity;

    if (this.bobTimer-- > 0)
    {
        this.motionX *= 0.02D;
        this.motionY *= 0.02D;
        this.motionZ *= 0.02D;
        this.setParticleTextureIndex(113);
    }
    else
    {
        this.setParticleTextureIndex(112);
    }

    this.moveEntity(this.motionX, this.motionY, this.motionZ);
    this.motionX *= 0.9800000190734863D;
    this.motionY *= 0.9800000190734863D;
    this.motionZ *= 0.9800000190734863D;

    if (this.particleMaxAge-- <= 0)
    {
        this.setExpired();
    }

    if (this.isCollided)
    {
        if (this.materialType == Material.WATER)
        {
            this.setExpired();
            this.worldObj.spawnParticle(EnumParticleTypes.WATER_SPLASH, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
        }
        else
        {
            this.setParticleTextureIndex(114);
        }

        this.motionX *= 0.699999988079071D;
        this.motionZ *= 0.699999988079071D;
    }

    BlockPos blockpos = new BlockPos(this.posX, this.posY, this.posZ);
    IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
    Material material = iblockstate.getMaterial();

    if (material.isLiquid() || material.isSolid())
    {
        double d0 = 0.0D;

        if (iblockstate.getBlock() instanceof BlockLiquid)
        {
            d0 = (double)BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue());
        }

        double d1 = (double)(MathHelper.floor_double(this.posY) + 1) - d0;

        if (this.posY < d1)
        {
            this.setExpired();
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:81,代碼來源:ParticleDrip.java


注:本文中的net.minecraft.block.material.Material.isSolid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。