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


Java Block.onBlockClicked方法代碼示例

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


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

示例1: onLeftClickEvent

import net.minecraft.block.Block; //導入方法依賴的package包/類
@SubscribeEvent
public void onLeftClickEvent(PlayerInteractEvent.EntityInteract.LeftClickBlock event) {
	if (event.getEntityPlayer().isCreative()) {
		extinguishFire(null, event.getPos(), event.getFace(), event.getWorld());
	} else {
		IBlockState iblockstate = event.getWorld().getBlockState(event.getPos());
		Block block = iblockstate.getBlock();
		if (!iblockstate.getBlock().isAir(iblockstate, event.getWorld(), event.getPos())) {
			block.onBlockClicked(event.getWorld(), event.getPos(), event.getEntityPlayer());
			extinguishFire(null, event.getPos(), event.getFace(), event.getWorld());

		}
	}
}
 
開發者ID:MinecraftModDevelopmentMods,項目名稱:Got-Wood,代碼行數:15,代碼來源:FireHandler.java

示例2: onRightClickEvent

import net.minecraft.block.Block; //導入方法依賴的package包/類
@SubscribeEvent
public void onRightClickEvent(PlayerInteractEvent.EntityInteract.RightClickBlock event) {
	if (event.getEntityPlayer().isCreative()) {
		extinguishFire(null, event.getPos(), event.getFace(), event.getWorld());
	} else {
		IBlockState iblockstate = event.getWorld().getBlockState(event.getPos());
		Block block = iblockstate.getBlock();
		if (!iblockstate.getBlock().isAir(iblockstate, event.getWorld(), event.getPos())) {
			block.onBlockClicked(event.getWorld(), event.getPos(), event.getEntityPlayer());
			extinguishFire(null, event.getPos(), event.getFace(), event.getWorld());
		}
	}
}
 
開發者ID:MinecraftModDevelopmentMods,項目名稱:Got-Wood,代碼行數:14,代碼來源:FireHandler.java

示例3: onBlockClicked

import net.minecraft.block.Block; //導入方法依賴的package包/類
/**
 * If not creative, it calls sendBlockBreakProgress until the block is broken first. tryHarvestBlock can also be the
 * result of this call.
 */
public void onBlockClicked(BlockPos pos, EnumFacing side)
{
    if (this.isCreative())
    {
        if (!this.theWorld.extinguishFire((EntityPlayer)null, pos, side))
        {
            this.tryHarvestBlock(pos);
        }
    }
    else
    {
        Block block = this.theWorld.getBlockState(pos).getBlock();

        if (this.gameType.isAdventure())
        {
            if (this.gameType == WorldSettings.GameType.SPECTATOR)
            {
                return;
            }

            if (!this.thisPlayerMP.isAllowEdit())
            {
                ItemStack itemstack = this.thisPlayerMP.getCurrentEquippedItem();

                if (itemstack == null)
                {
                    return;
                }

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

        this.theWorld.extinguishFire((EntityPlayer)null, pos, side);
        this.initialDamage = this.curblockDamage;
        float f = 1.0F;

        if (block.getMaterial() != Material.air)
        {
            block.onBlockClicked(this.theWorld, pos, this.thisPlayerMP);
            f = block.getPlayerRelativeBlockHardness(this.thisPlayerMP, this.thisPlayerMP.worldObj, pos);
        }

        if (block.getMaterial() != Material.air && f >= 1.0F)
        {
            this.tryHarvestBlock(pos);
        }
        else
        {
            this.isDestroyingBlock = true;
            this.field_180240_f = pos;
            int i = (int)(f * 10.0F);
            this.theWorld.sendBlockBreakProgress(this.thisPlayerMP.getEntityId(), pos, i);
            this.durabilityRemainingOnBlock = i;
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:65,代碼來源:ItemInWorldManager.java

示例4: 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

示例5: onBlockClicked

import net.minecraft.block.Block; //導入方法依賴的package包/類
/**
 * If not creative, it calls sendBlockBreakProgress until the block is broken first. tryHarvestBlock can also be the
 * result of this call.
 */
public void onBlockClicked(BlockPos pos, EnumFacing side)
{
    if (this.isCreative())
    {
        if (!this.theWorld.extinguishFire((EntityPlayer)null, pos, side))
        {
            this.tryHarvestBlock(pos);
        }
    }
    else
    {
        IBlockState iblockstate = this.theWorld.getBlockState(pos);
        Block block = iblockstate.getBlock();

        if (this.gameType.isAdventure())
        {
            if (this.gameType == GameType.SPECTATOR)
            {
                return;
            }

            if (!this.thisPlayerMP.isAllowEdit())
            {
                ItemStack itemstack = this.thisPlayerMP.getHeldItemMainhand();

                if (itemstack.func_190926_b())
                {
                    return;
                }

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

        this.theWorld.extinguishFire((EntityPlayer)null, pos, side);
        this.initialDamage = this.curblockDamage;
        float f = 1.0F;

        if (iblockstate.getMaterial() != Material.AIR)
        {
            block.onBlockClicked(this.theWorld, pos, this.thisPlayerMP);
            f = iblockstate.getPlayerRelativeBlockHardness(this.thisPlayerMP, this.thisPlayerMP.world, pos);
        }

        if (iblockstate.getMaterial() != Material.AIR && f >= 1.0F)
        {
            this.tryHarvestBlock(pos);
        }
        else
        {
            this.isDestroyingBlock = true;
            this.destroyPos = pos;
            int i = (int)(f * 10.0F);
            this.theWorld.sendBlockBreakProgress(this.thisPlayerMP.getEntityId(), pos, i);
            this.durabilityRemainingOnBlock = i;
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:66,代碼來源:PlayerInteractionManager.java


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