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


Java Block.getMaterial方法代碼示例

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


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

示例1: scheduleBlockUpdate

import net.minecraft.block.Block; //導入方法依賴的package包/類
public void scheduleBlockUpdate(BlockPos pos, Block blockIn, int delay, int priority)
{
    NextTickListEntry nextticklistentry = new NextTickListEntry(pos, blockIn);
    nextticklistentry.setPriority(priority);

    if (blockIn.getMaterial() != Material.air)
    {
        nextticklistentry.setScheduledTime((long)delay + this.worldInfo.getWorldTotalTime());
    }

    if (!this.pendingTickListEntriesHashSet.contains(nextticklistentry))
    {
        this.pendingTickListEntriesHashSet.add(nextticklistentry);
        this.pendingTickListEntriesTreeSet.add(nextticklistentry);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:17,代碼來源:WorldServer.java

示例2: generate

import net.minecraft.block.Block; //導入方法依賴的package包/類
public boolean generate(World worldIn, Random rand, BlockPos position)
{
    Block block;

    while (((block = worldIn.getBlockState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 0)
    {
        position = position.down();
    }

    for (int i = 0; i < 4; ++i)
    {
        BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));

        if (worldIn.isAirBlock(blockpos) && Blocks.deadbush.canBlockStay(worldIn, blockpos, Blocks.deadbush.getDefaultState()))
        {
            worldIn.setBlockState(blockpos, Blocks.deadbush.getDefaultState(), 2);
        }
    }

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

示例3: generate

import net.minecraft.block.Block; //導入方法依賴的package包/類
public boolean generate(World worldIn, Random rand, BlockPos position)
{
    Block block;

    while (((block = worldIn.getBlockState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 0)
    {
        position = position.down();
    }

    for (int i = 0; i < 128; ++i)
    {
        BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));

        if (worldIn.isAirBlock(blockpos) && Blocks.tallgrass.canBlockStay(worldIn, blockpos, this.tallGrassState))
        {
            worldIn.setBlockState(blockpos, this.tallGrassState, 2);
        }
    }

    return true;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:22,代碼來源:WorldGenTallGrass.java

示例4: fall

import net.minecraft.block.Block; //導入方法依賴的package包/類
public void fall(float distance, float damageMultiplier)
{
    if (distance > 1.0F)
    {
        this.playSound("mob.horse.land", 0.4F, 1.0F);
    }

    int i = MathHelper.ceiling_float_int((distance * 0.5F - 3.0F) * damageMultiplier);

    if (i > 0)
    {
        this.attackEntityFrom(DamageSource.fall, (float)i);

        if (this.riddenByEntity != null)
        {
            this.riddenByEntity.attackEntityFrom(DamageSource.fall, (float)i);
        }

        Block block = this.worldObj.getBlockState(new BlockPos(this.posX, this.posY - 0.2D - (double)this.prevRotationYaw, this.posZ)).getBlock();

        if (block.getMaterial() != Material.air && !this.isSilent())
        {
            Block.SoundType block$soundtype = block.stepSound;
            this.worldObj.playSoundAtEntity(this, block$soundtype.getStepSound(), block$soundtype.getVolume() * 0.5F, block$soundtype.getFrequency() * 0.75F);
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:28,代碼來源:EntityHorse.java

示例5: getFOVModifier

import net.minecraft.block.Block; //導入方法依賴的package包/類
/**
 * Changes the field of view of the player depending on if they are underwater or not
 */
private float getFOVModifier(float partialTicks, boolean p_78481_2_)
{
    if (this.debugView)
    {
        return 90.0F;
    }
    else
    {
        Entity entity = this.mc.getRenderViewEntity();
        float f = 70.0F;

        if (p_78481_2_)
        {
            f = this.mc.gameSettings.fovSetting;
            f = f * (this.fovModifierHandPrev + (this.fovModifierHand - this.fovModifierHandPrev) * partialTicks);
        }

        if (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).getHealth() <= 0.0F)
        {
            float f1 = (float)((EntityLivingBase)entity).deathTime + partialTicks;
            f /= (1.0F - 500.0F / (f1 + 500.0F)) * 2.0F + 1.0F;
        }

        Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(this.mc.theWorld, entity, partialTicks);

        if (block.getMaterial() == Material.water)
        {
            f = f * 60.0F / 70.0F;
        }

        return f;
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:37,代碼來源:EntityRenderer.java

示例6: updateFallState

import net.minecraft.block.Block; //導入方法依賴的package包/類
protected void updateFallState(double y, boolean onGroundIn, Block blockIn, BlockPos pos)
{
    if (!this.isInWater())
    {
        this.handleWaterMovement();
    }

    if (!this.worldObj.isRemote && this.fallDistance > 3.0F && onGroundIn)
    {
        IBlockState iblockstate = this.worldObj.getBlockState(pos);
        Block block = iblockstate.getBlock();
        float f = (float)MathHelper.ceiling_float_int(this.fallDistance - 3.0F);

        if (block.getMaterial() != Material.air)
        {
            double d0 = (double)Math.min(0.2F + f / 15.0F, 10.0F);

            if (d0 > 2.5D)
            {
                d0 = 2.5D;
            }

            int i = (int)(150.0D * d0);
            ((WorldServer)this.worldObj).spawnParticle(EnumParticleTypes.BLOCK_DUST, this.posX, this.posY, this.posZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, new int[] {Block.getStateId(iblockstate)});
        }
    }

    super.updateFallState(y, onGroundIn, blockIn, pos);
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:30,代碼來源:EntityLivingBase.java

示例7: isSafeToStandAt

import net.minecraft.block.Block; //導入方法依賴的package包/類
/**
 * Returns true when an entity could stand at a position, including solid blocks under the entire entity.
 */
private boolean isSafeToStandAt(int x, int y, int z, int sizeX, int sizeY, int sizeZ, Vec3 vec31, double p_179683_8_, double p_179683_10_)
{
    int i = x - sizeX / 2;
    int j = z - sizeZ / 2;

    if (!this.isPositionClear(i, y, j, sizeX, sizeY, sizeZ, vec31, p_179683_8_, p_179683_10_))
    {
        return false;
    }
    else
    {
        for (int k = i; k < i + sizeX; ++k)
        {
            for (int l = j; l < j + sizeZ; ++l)
            {
                double d0 = (double)k + 0.5D - vec31.xCoord;
                double d1 = (double)l + 0.5D - vec31.zCoord;

                if (d0 * p_179683_8_ + d1 * p_179683_10_ >= 0.0D)
                {
                    Block block = this.worldObj.getBlockState(new BlockPos(k, y - 1, l)).getBlock();
                    Material material = block.getMaterial();

                    if (material == Material.air)
                    {
                        return false;
                    }

                    if (material == Material.water && !this.theEntity.isInWater())
                    {
                        return false;
                    }

                    if (material == Material.lava)
                    {
                        return false;
                    }
                }
            }
        }

        return true;
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:48,代碼來源:PathNavigateGround.java

示例8: clickBlock

import net.minecraft.block.Block; //導入方法依賴的package包/類
/**
 * Called when the player is hitting a block with an item.
 */
public boolean clickBlock(BlockPos loc, EnumFacing face)
{
    if (this.currentGameType.isAdventure())
    {
        if (this.currentGameType == WorldSettings.GameType.SPECTATOR)
        {
            return false;
        }

        if (!this.mc.thePlayer.isAllowEdit())
        {
            Block block = this.mc.theWorld.getBlockState(loc).getBlock();
            ItemStack itemstack = this.mc.thePlayer.getCurrentEquippedItem();

            if (itemstack == null)
            {
                return false;
            }

            if (!itemstack.canDestroy(block))
            {
                return false;
            }
        }
    }

    if (!this.mc.theWorld.getWorldBorder().contains(loc))
    {
        return false;
    }
    else
    {
        if (this.currentGameType.isCreative())
        {
            this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, loc, face));
            clickBlockCreative(this.mc, this, loc, face);
            this.blockHitDelay = 5;
        }
        else if (!this.isHittingBlock || !this.isHittingPosition(loc))
        {
            if (this.isHittingBlock)
            {
                this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.ABORT_DESTROY_BLOCK, this.currentBlock, face));
            }

            this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, loc, face));
            Block block1 = this.mc.theWorld.getBlockState(loc).getBlock();
            boolean flag = block1.getMaterial() != Material.air;

            if (flag && this.curBlockDamageMP == 0.0F)
            {
                block1.onBlockClicked(this.mc.theWorld, loc, this.mc.thePlayer);
            }

            if (flag && block1.getPlayerRelativeBlockHardness(this.mc.thePlayer, this.mc.thePlayer.worldObj, loc) >= 1.0F)
            {
                this.onPlayerDestroyBlock(loc, face);
            }
            else
            {
                this.isHittingBlock = true;
                this.currentBlock = loc;
                this.currentItemHittingBlock = this.mc.thePlayer.getHeldItem();
                this.curBlockDamageMP = 0.0F;
                this.stepSoundTickCounter = 0.0F;
                this.mc.theWorld.sendBlockBreakProgress(this.mc.thePlayer.getEntityId(), this.currentBlock, (int)(this.curBlockDamageMP * 10.0F) - 1);
            }
        }

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

示例9: handleMaterialAcceleration

import net.minecraft.block.Block; //導入方法依賴的package包/類
/**
 * handles the acceleration of an object whilst in water. Not sure if it is used elsewhere.
 */
public boolean handleMaterialAcceleration(AxisAlignedBB bb, Material materialIn, Entity entityIn)
{
    int i = MathHelper.floor_double(bb.minX);
    int j = MathHelper.floor_double(bb.maxX + 1.0D);
    int k = MathHelper.floor_double(bb.minY);
    int l = MathHelper.floor_double(bb.maxY + 1.0D);
    int i1 = MathHelper.floor_double(bb.minZ);
    int j1 = MathHelper.floor_double(bb.maxZ + 1.0D);

    if (!this.isAreaLoaded(i, k, i1, j, l, j1, true))
    {
        return false;
    }
    else
    {
        boolean flag = false;
        Vec3 vec3 = new Vec3(0.0D, 0.0D, 0.0D);
        BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

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

                    if (block.getMaterial() == materialIn)
                    {
                        double d0 = (double)((float)(l1 + 1) - BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue()));

                        if ((double)l >= d0)
                        {
                            flag = true;
                            vec3 = block.modifyAcceleration(this, blockpos$mutableblockpos, entityIn, vec3);
                        }
                    }
                }
            }
        }

        if (vec3.lengthVector() > 0.0D && entityIn.isPushedByWater())
        {
            vec3 = vec3.normalize();
            double d1 = 0.014D;
            entityIn.motionX += vec3.xCoord * d1;
            entityIn.motionY += vec3.yCoord * d1;
            entityIn.motionZ += vec3.zCoord * d1;
        }

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

示例10: generate

import net.minecraft.block.Block; //導入方法依賴的package包/類
public boolean generate(World worldIn, Random rand, BlockPos position)
{
    Block block;

    while (((block = worldIn.getBlockState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 0)
    {
        position = position.down();
    }

    Block block1 = worldIn.getBlockState(position).getBlock();

    if (block1 == Blocks.dirt || block1 == Blocks.grass)
    {
        position = position.up();
        this.setBlockAndNotifyAdequately(worldIn, position, this.woodMetadata);

        for (int i = position.getY(); i <= position.getY() + 2; ++i)
        {
            int j = i - position.getY();
            int k = 2 - j;

            for (int l = position.getX() - k; l <= position.getX() + k; ++l)
            {
                int i1 = l - position.getX();

                for (int j1 = position.getZ() - k; j1 <= position.getZ() + k; ++j1)
                {
                    int k1 = j1 - position.getZ();

                    if (Math.abs(i1) != k || Math.abs(k1) != k || rand.nextInt(2) != 0)
                    {
                        BlockPos blockpos = new BlockPos(l, i, j1);

                        if (!worldIn.getBlockState(blockpos).getBlock().isFullBlock())
                        {
                            this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
                        }
                    }
                }
            }
        }
    }

    return true;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:46,代碼來源:WorldGenShrub.java

示例11: canHarvestBlock

import net.minecraft.block.Block; //導入方法依賴的package包/類
/**
 * Check whether this Item can harvest the given Block
 */
public boolean canHarvestBlock(Block blockIn)
{
    return blockIn == Blocks.obsidian ? this.toolMaterial.getHarvestLevel() == 3 : (blockIn != Blocks.diamond_block && blockIn != Blocks.diamond_ore ? (blockIn != Blocks.emerald_ore && blockIn != Blocks.emerald_block ? (blockIn != Blocks.gold_block && blockIn != Blocks.gold_ore ? (blockIn != Blocks.iron_block && blockIn != Blocks.iron_ore ? (blockIn != Blocks.lapis_block && blockIn != Blocks.lapis_ore ? (blockIn != Blocks.redstone_ore && blockIn != Blocks.lit_redstone_ore ? (blockIn.getMaterial() == Material.rock ? true : (blockIn.getMaterial() == Material.iron ? true : blockIn.getMaterial() == Material.anvil)) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2);
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:8,代碼來源:ItemPickaxe.java

示例12: generate

import net.minecraft.block.Block; //導入方法依賴的package包/類
public boolean generate(World worldIn, Random rand, BlockPos position)
{
    int i = this.func_150533_a(rand);

    if (!this.func_175929_a(worldIn, rand, position, i))
    {
        return false;
    }
    else
    {
        this.func_150541_c(worldIn, position.getX(), position.getZ(), position.getY() + i, 0, rand);

        for (int j = 0; j < i; ++j)
        {
            Block block = worldIn.getBlockState(position.up(j)).getBlock();

            if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
            {
                this.setBlockAndNotifyAdequately(worldIn, position.up(j), this.woodMetadata);
            }

            if (j < i - 1)
            {
                block = worldIn.getBlockState(position.add(1, j, 0)).getBlock();

                if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
                {
                    this.setBlockAndNotifyAdequately(worldIn, position.add(1, j, 0), this.woodMetadata);
                }

                block = worldIn.getBlockState(position.add(1, j, 1)).getBlock();

                if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
                {
                    this.setBlockAndNotifyAdequately(worldIn, position.add(1, j, 1), this.woodMetadata);
                }

                block = worldIn.getBlockState(position.add(0, j, 1)).getBlock();

                if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
                {
                    this.setBlockAndNotifyAdequately(worldIn, position.add(0, j, 1), this.woodMetadata);
                }
            }
        }

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

示例13: drawSelectionBox

import net.minecraft.block.Block; //導入方法依賴的package包/類
/**
 * Draws the selection box for the player. Args: entityPlayer, rayTraceHit, i, itemStack, partialTickTime
 */
public void drawSelectionBox(EntityPlayer player, MovingObjectPosition movingObjectPositionIn, int p_72731_3_, float partialTicks)
{
    if (p_72731_3_ == 0 && movingObjectPositionIn.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
    {
        GlStateManager.enableBlend();
        GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
        GlStateManager.color(0.0F, 0.0F, 0.0F, 0.4F);
        GL11.glLineWidth(2.0F);
        GlStateManager.disableTexture2D();

        if (Config.isShaders())
        {
            Shaders.disableTexture2D();
        }

        GlStateManager.depthMask(false);
        float f = 0.002F;
        BlockPos blockpos = movingObjectPositionIn.getBlockPos();
        Block block = this.theWorld.getBlockState(blockpos).getBlock();

        if (block.getMaterial() != Material.air && this.theWorld.getWorldBorder().contains(blockpos))
        {
            block.setBlockBoundsBasedOnState(this.theWorld, blockpos);
            double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)partialTicks;
            double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)partialTicks;
            double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)partialTicks;
            func_181561_a(block.getSelectedBoundingBox(this.theWorld, blockpos).expand(0.0020000000949949026D, 0.0020000000949949026D, 0.0020000000949949026D).offset(-d0, -d1, -d2));
        }

        GlStateManager.depthMask(true);
        GlStateManager.enableTexture2D();

        if (Config.isShaders())
        {
            Shaders.enableTexture2D();
        }

        GlStateManager.disableBlend();
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:44,代碼來源:RenderGlobal.java

示例14: addRainParticles

import net.minecraft.block.Block; //導入方法依賴的package包/類
private void addRainParticles() {
	float f = this.mc.theWorld.getRainStrength(1.0F);

	if (!Config.isRainFancy()) {
		f /= 2.0F;
	}

	if (f != 0.0F && Config.isRainSplash()) {
		this.random.setSeed((long) this.rendererUpdateCount * 312987231L);
		Entity entity = this.mc.getRenderViewEntity();
		WorldClient worldclient = this.mc.theWorld;
		BlockPos blockpos = new BlockPos(entity);
		byte b0 = 10;
		double d0 = 0.0D;
		double d1 = 0.0D;
		double d2 = 0.0D;
		int i = 0;
		int j = (int) (100.0F * f * f);

		if (this.mc.gameSettings.particleSetting == 1) {
			j >>= 1;
		} else if (this.mc.gameSettings.particleSetting == 2) {
			j = 0;
		}

		for (int k = 0; k < j; ++k) {
			BlockPos blockpos1 = worldclient
					.getPrecipitationHeight(blockpos.add(this.random.nextInt(b0) - this.random.nextInt(b0), 0,
							this.random.nextInt(b0) - this.random.nextInt(b0)));
			BiomeGenBase biomegenbase = worldclient.getBiomeGenForCoords(blockpos1);
			BlockPos blockpos2 = blockpos1.down();
			Block block = worldclient.getBlockState(blockpos2).getBlock();

			if (blockpos1.getY() <= blockpos.getY() + b0 && blockpos1.getY() >= blockpos.getY() - b0
					&& biomegenbase.canSpawnLightningBolt()
					&& biomegenbase.getFloatTemperature(blockpos1) >= 0.15F) {
				double d3 = this.random.nextDouble();
				double d4 = this.random.nextDouble();

				if (block.getMaterial() == Material.lava) {
					this.mc.theWorld.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double) blockpos1.getX() + d3,
							(double) ((float) blockpos1.getY() + 0.1F) - block.getBlockBoundsMinY(),
							(double) blockpos1.getZ() + d4, 0.0D, 0.0D, 0.0D, new int[0]);
				} else if (block.getMaterial() != Material.air) {
					block.setBlockBoundsBasedOnState(worldclient, blockpos2);
					++i;

					if (this.random.nextInt(i) == 0) {
						d0 = (double) blockpos2.getX() + d3;
						d1 = (double) ((float) blockpos2.getY() + 0.1F) + block.getBlockBoundsMaxY() - 1.0D;
						d2 = (double) blockpos2.getZ() + d4;
					}

					this.mc.theWorld.spawnParticle(EnumParticleTypes.WATER_DROP, (double) blockpos2.getX() + d3,
							(double) ((float) blockpos2.getY() + 0.1F) + block.getBlockBoundsMaxY(),
							(double) blockpos2.getZ() + d4, 0.0D, 0.0D, 0.0D, new int[0]);
				}
			}
		}

		if (i > 0 && this.random.nextInt(3) < this.rainSoundCounter++) {
			this.rainSoundCounter = 0;

			if (d1 > (double) (blockpos.getY() + 1) && worldclient.getPrecipitationHeight(blockpos)
					.getY() > MathHelper.floor_float((float) blockpos.getY())) {
				this.mc.theWorld.playSound(d0, d1, d2, "ambient.weather.rain", 0.1F, 0.5F, false);
			} else {
				this.mc.theWorld.playSound(d0, d1, d2, "ambient.weather.rain", 0.2F, 1.0F, false);
			}
		}
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:73,代碼來源:EntityRenderer.java

示例15: doExplosionB

import net.minecraft.block.Block; //導入方法依賴的package包/類
/**
 * Does the second part of the explosion (sound, particles, drop spawn)
 */
public void doExplosionB(boolean spawnParticles)
{
    this.worldObj.playSoundEffect(this.explosionX, this.explosionY, this.explosionZ, "random.explode", 4.0F, (1.0F + (this.worldObj.rand.nextFloat() - this.worldObj.rand.nextFloat()) * 0.2F) * 0.7F);

    if (this.explosionSize >= 2.0F && this.isSmoking)
    {
        this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D, new int[0]);
    }
    else
    {
        this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D, new int[0]);
    }

    if (this.isSmoking)
    {
        for (BlockPos blockpos : this.affectedBlockPositions)
        {
            Block block = this.worldObj.getBlockState(blockpos).getBlock();

            if (spawnParticles)
            {
                double d0 = (double)((float)blockpos.getX() + this.worldObj.rand.nextFloat());
                double d1 = (double)((float)blockpos.getY() + this.worldObj.rand.nextFloat());
                double d2 = (double)((float)blockpos.getZ() + this.worldObj.rand.nextFloat());
                double d3 = d0 - this.explosionX;
                double d4 = d1 - this.explosionY;
                double d5 = d2 - this.explosionZ;
                double d6 = (double)MathHelper.sqrt_double(d3 * d3 + d4 * d4 + d5 * d5);
                d3 = d3 / d6;
                d4 = d4 / d6;
                d5 = d5 / d6;
                double d7 = 0.5D / (d6 / (double)this.explosionSize + 0.1D);
                d7 = d7 * (double)(this.worldObj.rand.nextFloat() * this.worldObj.rand.nextFloat() + 0.3F);
                d3 = d3 * d7;
                d4 = d4 * d7;
                d5 = d5 * d7;
                this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, (d0 + this.explosionX * 1.0D) / 2.0D, (d1 + this.explosionY * 1.0D) / 2.0D, (d2 + this.explosionZ * 1.0D) / 2.0D, d3, d4, d5, new int[0]);
                this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, d3, d4, d5, new int[0]);
            }

            if (block.getMaterial() != Material.air)
            {
                if (block.canDropFromExplosion(this))
                {
                    block.dropBlockAsItemWithChance(this.worldObj, blockpos, this.worldObj.getBlockState(blockpos), 1.0F / this.explosionSize, 0);
                }

                this.worldObj.setBlockState(blockpos, Blocks.air.getDefaultState(), 3);
                block.onBlockDestroyedByExplosion(this.worldObj, blockpos, this);
            }
        }
    }

    if (this.isFlaming)
    {
        for (BlockPos blockpos1 : this.affectedBlockPositions)
        {
            if (this.worldObj.getBlockState(blockpos1).getBlock().getMaterial() == Material.air && this.worldObj.getBlockState(blockpos1.down()).getBlock().isFullBlock() && this.explosionRNG.nextInt(3) == 0)
            {
                this.worldObj.setBlockState(blockpos1, Blocks.fire.getDefaultState());
            }
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:68,代碼來源:Explosion.java


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