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


Java Material.blocksMovement方法代碼示例

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


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

示例1: getTopSolidOrLiquidBlock

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
/**
 * Finds the highest block on the x and z coordinate that is solid or liquid, and returns its y coord.
 */
public BlockPos getTopSolidOrLiquidBlock(BlockPos pos)
{
    Chunk chunk = this.getChunkFromBlockCoords(pos);
    BlockPos blockpos;
    BlockPos blockpos1;

    for (blockpos = new BlockPos(pos.getX(), chunk.getTopFilledSegment() + 16, pos.getZ()); blockpos.getY() >= 0; blockpos = blockpos1)
    {
        blockpos1 = blockpos.down();
        Material material = chunk.getBlock(blockpos1).getMaterial();

        if (material.blocksMovement() && material != Material.leaves)
        {
            break;
        }
    }

    return blockpos;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:23,代碼來源:World.java

示例2: canGoThrough

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
private boolean canGoThrough(BlockPos pos)
{
	// check if loaded
	if(!WMinecraft.getWorld().isBlockLoaded(pos, false))
		return false;
	
	// check if solid
	Material material = WBlock.getMaterial(pos);
	Block block = WBlock.getBlock(pos);
	if(material.blocksMovement() && !(block instanceof BlockSign))
		return false;
	
	// check if trapped
	if(block instanceof BlockTripWire
		|| block instanceof BlockPressurePlate)
		return false;
	
	// check if safe
	if(!invulnerable
		&& (material == Material.LAVA || material == Material.FIRE))
		return false;
	
	return true;
}
 
開發者ID:Wurst-Imperium,項目名稱:Wurst-MC-1.12,代碼行數:25,代碼來源:PathFinder.java

示例3: getTopSolidOrLiquidBlock

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
/**
 * Finds the highest block on the x and z coordinate that is solid or liquid, and returns its y coord.
 */
public BlockPos getTopSolidOrLiquidBlock(BlockPos pos)
{
    Chunk chunk = this.getChunkFromBlockCoords(pos);
    BlockPos blockpos;
    BlockPos blockpos1;

    for (blockpos = new BlockPos(pos.getX(), chunk.getTopFilledSegment() + 16, pos.getZ()); blockpos.getY() >= 0; blockpos = blockpos1)
    {
        blockpos1 = blockpos.down();
        Material material = chunk.getBlockState(blockpos1).getMaterial();

        if (material.blocksMovement() && material != Material.LEAVES)
        {
            break;
        }
    }

    return blockpos;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:23,代碼來源:World.java

示例4: harvestBlock

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
    player.addExhaustion(0.025F);

    if (this.canSilkHarvest() && EnchantmentHelper.getSilkTouchModifier(player))
    {
        ItemStack itemstack = this.createStackedBlock(state);

        if (itemstack != null)
        {
            spawnAsEntity(worldIn, pos, itemstack);
        }
    }
    else
    {
        if (worldIn.provider.doesWaterVaporize())
        {
            worldIn.setBlockToAir(pos);
            return;
        }

        int i = EnchantmentHelper.getFortuneModifier(player);
        this.dropBlockAsItem(worldIn, pos, state, i);
        Material material = worldIn.getBlockState(pos.down()).getBlock().getMaterial();

        if (material.blocksMovement() || material.isLiquid())
        {
            worldIn.setBlockState(pos, Blocks.flowing_water.getDefaultState());
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:33,代碼來源:BlockIce.java

示例5: canBeSolid

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
protected boolean canBeSolid(BlockPos pos)
{
	Material material = WBlock.getMaterial(pos);
	Block block = WBlock.getBlock(pos);
	return material.blocksMovement() && !(block instanceof BlockSign)
		|| block instanceof BlockLadder || jesus
			&& (material == Material.WATER || material == Material.LAVA);
}
 
開發者ID:Wurst-Imperium,項目名稱:Wurst-MC-1.12,代碼行數:9,代碼來源:PathFinder.java

示例6: harvestBlock

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack)
{
    player.addStat(StatList.getBlockStats(this));
    player.addExhaustion(0.005F);

    if (this.canSilkHarvest() && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0)
    {
        spawnAsEntity(worldIn, pos, this.getSilkTouchDrop(state));
    }
    else
    {
        if (worldIn.provider.doesWaterVaporize())
        {
            worldIn.setBlockToAir(pos);
            return;
        }

        int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack);
        this.dropBlockAsItem(worldIn, pos, state, i);
        Material material = worldIn.getBlockState(pos.down()).getMaterial();

        if (material.blocksMovement() || material.isLiquid())
        {
            worldIn.setBlockState(pos, Blocks.FLOWING_WATER.getDefaultState());
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:28,代碼來源:BlockIce.java

示例7: canDisplace

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
/**
 * Returns true if the block at (pos) is displaceable. Does not displace the block.
 */
public boolean canDisplace(IBlockAccess world, BlockPos pos)
{
    if (world.isAirBlock(pos)) return true;

    IBlockState state = world.getBlockState(pos);

    if (state.getBlock() == this)
    {
        return false;
    }

    if (displacements.containsKey(state.getBlock()))
    {
        return displacements.get(state.getBlock());
    }

    Material material = state.getMaterial();
    if (material.blocksMovement() || material == Material.PORTAL)
    {
        return false;
    }

    int density = getDensity(world, pos);
    if (density == Integer.MAX_VALUE)
    {
        return true;
    }

    if (this.density > density)
    {
        return true;
    }
    else
    {
        return false;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:41,代碼來源:BlockFluidBase.java

示例8: canFlowInto

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
protected boolean canFlowInto(IBlockAccess world, BlockPos pos)
{
    if (world.isAirBlock(pos)) return true;

    IBlockState state = world.getBlockState(pos);
    if (state.getBlock() == this)
    {
        return true;
    }

    if (displacements.containsKey(state.getBlock()))
    {
        return displacements.get(state.getBlock());
    }

    Material material = state.getMaterial();
    if (material.blocksMovement()  ||
        material == Material.WATER ||
        material == Material.LAVA  ||
        material == Material.PORTAL)
    {
        return false;
    }

    int density = getDensity(world, pos);
    if (density == Integer.MAX_VALUE)
    {
         return true;
    }

    if (this.density > density)
    {
        return true;
    }
    else
    {
        return false;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:40,代碼來源:BlockFluidClassic.java

示例9: harvestBlock

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, @Nullable ItemStack stack)
{
    player.addStat(StatList.getBlockStats(this));
    player.addExhaustion(0.025F);

    if (this.canSilkHarvest(worldIn, pos, state, player) && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0)
    {
        java.util.List<ItemStack> items = new java.util.ArrayList<ItemStack>();
        ItemStack itemstack = this.createStackedBlock(state);

        if (itemstack != null)
        {
            items.add(itemstack);
        }

        net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(items, worldIn, pos, state, 0, 1.0f, true, player);
        for (ItemStack is : items)
            spawnAsEntity(worldIn, pos, is);
    }
    else
    {
        if (worldIn.provider.doesWaterVaporize())
        {
            worldIn.setBlockToAir(pos);
            return;
        }

        int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack);
        harvesters.set(player);
        this.dropBlockAsItem(worldIn, pos, state, i);
        harvesters.set(null);
        Material material = worldIn.getBlockState(pos.down()).getMaterial();

        if (material.blocksMovement() || material.isLiquid())
        {
            worldIn.setBlockState(pos, Blocks.FLOWING_WATER.getDefaultState());
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:40,代碼來源:BlockIce.java

示例10: randomDisplayTick

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    double d0 = (double)pos.getX();
    double d1 = (double)pos.getY();
    double d2 = (double)pos.getZ();

    if (this.blockMaterial == Material.water)
    {
        int i = ((Integer)state.getValue(LEVEL)).intValue();

        if (i > 0 && i < 8)
        {
            if (rand.nextInt(64) == 0)
            {
                worldIn.playSound(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, "liquid.water", rand.nextFloat() * 0.25F + 0.75F, rand.nextFloat() * 1.0F + 0.5F, false);
            }
        }
        else if (rand.nextInt(10) == 0)
        {
            worldIn.spawnParticle(EnumParticleTypes.SUSPENDED, d0 + (double)rand.nextFloat(), d1 + (double)rand.nextFloat(), d2 + (double)rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]);
        }
    }

    if (this.blockMaterial == Material.lava && worldIn.getBlockState(pos.up()).getBlock().getMaterial() == Material.air && !worldIn.getBlockState(pos.up()).getBlock().isOpaqueCube())
    {
        if (rand.nextInt(100) == 0)
        {
            double d8 = d0 + (double)rand.nextFloat();
            double d4 = d1 + this.maxY;
            double d6 = d2 + (double)rand.nextFloat();
            worldIn.spawnParticle(EnumParticleTypes.LAVA, d8, d4, d6, 0.0D, 0.0D, 0.0D, new int[0]);
            worldIn.playSound(d8, d4, d6, "liquid.lavapop", 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
        }

        if (rand.nextInt(200) == 0)
        {
            worldIn.playSound(d0, d1, d2, "liquid.lava", 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
        }
    }

    if (rand.nextInt(10) == 0 && World.doesBlockHaveSolidTopSurface(worldIn, pos.down()))
    {
        Material material = worldIn.getBlockState(pos.down(2)).getBlock().getMaterial();

        if (!material.blocksMovement() && !material.isLiquid())
        {
            double d3 = d0 + (double)rand.nextFloat();
            double d5 = d1 - 1.05D;
            double d7 = d2 + (double)rand.nextFloat();

            if (this.blockMaterial == Material.water)
            {
                worldIn.spawnParticle(EnumParticleTypes.DRIP_WATER, d3, d5, d7, 0.0D, 0.0D, 0.0D, new int[0]);
            }
            else
            {
                worldIn.spawnParticle(EnumParticleTypes.DRIP_LAVA, d3, d5, d7, 0.0D, 0.0D, 0.0D, new int[0]);
            }
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:62,代碼來源:BlockLiquid.java

示例11: randomDisplayTick

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand)
{
    double d0 = (double)pos.getX();
    double d1 = (double)pos.getY();
    double d2 = (double)pos.getZ();

    if (this.blockMaterial == Material.WATER)
    {
        int i = ((Integer)stateIn.getValue(LEVEL)).intValue();

        if (i > 0 && i < 8)
        {
            if (rand.nextInt(64) == 0)
            {
                worldIn.playSound(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, SoundEvents.BLOCK_WATER_AMBIENT, SoundCategory.BLOCKS, rand.nextFloat() * 0.25F + 0.75F, rand.nextFloat() + 0.5F, false);
            }
        }
        else if (rand.nextInt(10) == 0)
        {
            worldIn.spawnParticle(EnumParticleTypes.SUSPENDED, d0 + (double)rand.nextFloat(), d1 + (double)rand.nextFloat(), d2 + (double)rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]);
        }
    }

    if (this.blockMaterial == Material.LAVA && worldIn.getBlockState(pos.up()).getMaterial() == Material.AIR && !worldIn.getBlockState(pos.up()).isOpaqueCube())
    {
        if (rand.nextInt(100) == 0)
        {
            double d8 = d0 + (double)rand.nextFloat();
            double d4 = d1 + stateIn.getBoundingBox(worldIn, pos).maxY;
            double d6 = d2 + (double)rand.nextFloat();
            worldIn.spawnParticle(EnumParticleTypes.LAVA, d8, d4, d6, 0.0D, 0.0D, 0.0D, new int[0]);
            worldIn.playSound(d8, d4, d6, SoundEvents.BLOCK_LAVA_POP, SoundCategory.BLOCKS, 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
        }

        if (rand.nextInt(200) == 0)
        {
            worldIn.playSound(d0, d1, d2, SoundEvents.BLOCK_LAVA_AMBIENT, SoundCategory.BLOCKS, 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
        }
    }

    if (rand.nextInt(10) == 0 && worldIn.getBlockState(pos.down()).isFullyOpaque())
    {
        Material material = worldIn.getBlockState(pos.down(2)).getMaterial();

        if (!material.blocksMovement() && !material.isLiquid())
        {
            double d3 = d0 + (double)rand.nextFloat();
            double d5 = d1 - 1.05D;
            double d7 = d2 + (double)rand.nextFloat();

            if (this.blockMaterial == Material.WATER)
            {
                worldIn.spawnParticle(EnumParticleTypes.DRIP_WATER, d3, d5, d7, 0.0D, 0.0D, 0.0D, new int[0]);
            }
            else
            {
                worldIn.spawnParticle(EnumParticleTypes.DRIP_LAVA, d3, d5, d7, 0.0D, 0.0D, 0.0D, new int[0]);
            }
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:63,代碼來源:BlockLiquid.java

示例12: randomDisplayTick

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
	double d0 = (double) pos.getX();
	double d1 = (double) pos.getY();
	double d2 = (double) pos.getZ();

	if (this.blockMaterial == Material.water) {
		int i = ((Integer) state.getValue(LEVEL)).intValue();

		if (i > 0 && i < 8) {
			if (rand.nextInt(64) == 0) {
				worldIn.playSound(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, "liquid.water", rand.nextFloat() * 0.25F + 0.75F,
						rand.nextFloat() * 1.0F + 0.5F, false);
			}
		} else if (rand.nextInt(10) == 0) {
			worldIn.spawnParticle(EnumParticleTypes.SUSPENDED, d0 + (double) rand.nextFloat(),
					d1 + (double) rand.nextFloat(), d2 + (double) rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]);
		}
	}

	if (this.blockMaterial == Material.lava
			&& worldIn.getBlockState(pos.up()).getBlock().getMaterial() == Material.air
			&& !worldIn.getBlockState(pos.up()).getBlock().isOpaqueCube()) {
		if (rand.nextInt(100) == 0) {
			double d8 = d0 + (double) rand.nextFloat();
			double d4 = d1 + this.maxY;
			double d6 = d2 + (double) rand.nextFloat();
			worldIn.spawnParticle(EnumParticleTypes.LAVA, d8, d4, d6, 0.0D, 0.0D, 0.0D, new int[0]);
			worldIn.playSound(d8, d4, d6, "liquid.lavapop", 0.2F + rand.nextFloat() * 0.2F,
					0.9F + rand.nextFloat() * 0.15F, false);
		}

		if (rand.nextInt(200) == 0) {
			worldIn.playSound(d0, d1, d2, "liquid.lava", 0.2F + rand.nextFloat() * 0.2F,
					0.9F + rand.nextFloat() * 0.15F, false);
		}
	}

	if (rand.nextInt(10) == 0 && World.doesBlockHaveSolidTopSurface(worldIn, pos.down())) {
		Material material = worldIn.getBlockState(pos.down(2)).getBlock().getMaterial();

		if (!material.blocksMovement() && !material.isLiquid()) {
			double d3 = d0 + (double) rand.nextFloat();
			double d5 = d1 - 1.05D;
			double d7 = d2 + (double) rand.nextFloat();

			if (this.blockMaterial == Material.water) {
				worldIn.spawnParticle(EnumParticleTypes.DRIP_WATER, d3, d5, d7, 0.0D, 0.0D, 0.0D, new int[0]);
			} else {
				worldIn.spawnParticle(EnumParticleTypes.DRIP_LAVA, d3, d5, d7, 0.0D, 0.0D, 0.0D, new int[0]);
			}
		}
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:54,代碼來源:BlockLiquid.java

示例13: randomDisplayTick

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand)
{
    double d0 = (double)pos.getX();
    double d1 = (double)pos.getY();
    double d2 = (double)pos.getZ();

    if (this.blockMaterial == Material.WATER)
    {
        int i = ((Integer)stateIn.getValue(LEVEL)).intValue();

        if (i > 0 && i < 8)
        {
            if (rand.nextInt(64) == 0)
            {
                worldIn.playSound(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, SoundEvents.BLOCK_WATER_AMBIENT, SoundCategory.BLOCKS, rand.nextFloat() * 0.25F + 0.75F, rand.nextFloat() + 0.5F, false);
            }
        }
        else if (rand.nextInt(10) == 0)
        {
            worldIn.spawnParticle(EnumParticleTypes.SUSPENDED, d0 + (double)rand.nextFloat(), d1 + (double)rand.nextFloat(), d2 + (double)rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]);
        }
    }

    if (this.blockMaterial == Material.LAVA && worldIn.getBlockState(pos.up()).getMaterial() == Material.AIR && !worldIn.getBlockState(pos.up()).isOpaqueCube())
    {
        if (rand.nextInt(100) == 0)
        {
            double d8 = d0 + (double)rand.nextFloat();
            double d4 = d1 + stateIn.getBoundingBox(worldIn, pos).maxY;
            double d6 = d2 + (double)rand.nextFloat();
            worldIn.spawnParticle(EnumParticleTypes.LAVA, d8, d4, d6, 0.0D, 0.0D, 0.0D, new int[0]);
            worldIn.playSound(d8, d4, d6, SoundEvents.BLOCK_LAVA_POP, SoundCategory.BLOCKS, 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
        }

        if (rand.nextInt(200) == 0)
        {
            worldIn.playSound(d0, d1, d2, SoundEvents.BLOCK_LAVA_AMBIENT, SoundCategory.BLOCKS, 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
        }
    }

    if (rand.nextInt(10) == 0 && worldIn.getBlockState(pos.down()).isFullyOpaque())
    {
        Material material = worldIn.getBlockState(pos.down(2)).getMaterial();

        if (!material.blocksMovement() && !material.isLiquid())
        {
            double d3 = d0 + (double)rand.nextFloat();
            double d5 = d1 - 1.05D;
            double d7 = d2 + (double)rand.nextFloat();

            if (this.blockMaterial == Material.WATER)
            {
                worldIn.spawnParticle(EnumParticleTypes.DRIP_WATER, d3, d5, d7, 0.0D, 0.0D, 0.0D, new int[0]);
            }
            else
            {
                worldIn.spawnParticle(EnumParticleTypes.DRIP_LAVA, d3, d5, d7, 0.0D, 0.0D, 0.0D, new int[0]);
            }
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:62,代碼來源:BlockLiquid.java

示例14: displaceIfPossible

import net.minecraft.block.material.Material; //導入方法依賴的package包/類
/**
 * Attempt to displace the block at (pos), return true if it was displaced.
 */
public boolean displaceIfPossible(World world, BlockPos pos)
{
    if (world.isAirBlock(pos))
    {
        return true;
    }

    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();
    if (block == this)
    {
        return false;
    }

    if (displacements.containsKey(block))
    {
        if (displacements.get(block))
        {
            if (state.getBlock() != Blocks.SNOW_LAYER) //Forge: Vanilla has a 'bug' where snowballs don't drop like every other block. So special case because ewww...
                block.dropBlockAsItem(world, pos, state, 0);
            return true;
        }
        return false;
    }

    Material material = state.getMaterial();
    if (material.blocksMovement() || material == Material.PORTAL)
    {
        return false;
    }

    int density = getDensity(world, pos);
    if (density == Integer.MAX_VALUE)
    {
        block.dropBlockAsItem(world, pos, state, 0);
        return true;
    }

    if (this.density > density)
    {
        return true;
    }
    else
    {
        return false;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:51,代碼來源:BlockFluidBase.java


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