本文整理汇总了Java中net.minecraft.block.Block.getPlayerRelativeBlockHardness方法的典型用法代码示例。如果您正苦于以下问题:Java Block.getPlayerRelativeBlockHardness方法的具体用法?Java Block.getPlayerRelativeBlockHardness怎么用?Java Block.getPlayerRelativeBlockHardness使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.block.Block
的用法示例。
在下文中一共展示了Block.getPlayerRelativeBlockHardness方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: blockRemoving
import net.minecraft.block.Block; //导入方法依赖的package包/类
public void blockRemoving(BlockPos pos)
{
if (pos.equals(this.field_180240_f))
{
int i = this.curblockDamage - this.initialDamage;
Block block = this.theWorld.getBlockState(pos).getBlock();
if (block.getMaterial() != Material.air)
{
float f = block.getPlayerRelativeBlockHardness(this.thisPlayerMP, this.thisPlayerMP.worldObj, pos) * (float)(i + 1);
if (f >= 0.7F)
{
this.isDestroyingBlock = false;
this.theWorld.sendBlockBreakProgress(this.thisPlayerMP.getEntityId(), pos, -1);
this.tryHarvestBlock(pos);
}
else if (!this.receivedFinishDiggingPacket)
{
this.isDestroyingBlock = false;
this.receivedFinishDiggingPacket = true;
this.field_180241_i = pos;
this.initialBlockDamage = this.initialDamage;
}
}
}
}
示例2: updateBlockRemoving
import net.minecraft.block.Block; //导入方法依赖的package包/类
public void updateBlockRemoving()
{
++this.curblockDamage;
if (this.receivedFinishDiggingPacket)
{
int i = this.curblockDamage - this.initialBlockDamage;
Block block = this.theWorld.getBlockState(this.field_180241_i).getBlock();
if (block.getMaterial() == Material.air)
{
this.receivedFinishDiggingPacket = false;
}
else
{
float f = block.getPlayerRelativeBlockHardness(this.thisPlayerMP, this.thisPlayerMP.worldObj, this.field_180241_i) * (float)(i + 1);
int j = (int)(f * 10.0F);
if (j != this.durabilityRemainingOnBlock)
{
this.theWorld.sendBlockBreakProgress(this.thisPlayerMP.getEntityId(), this.field_180241_i, j);
this.durabilityRemainingOnBlock = j;
}
if (f >= 1.0F)
{
this.receivedFinishDiggingPacket = false;
this.tryHarvestBlock(this.field_180241_i);
}
}
}
else if (this.isDestroyingBlock)
{
Block block1 = this.theWorld.getBlockState(this.field_180240_f).getBlock();
if (block1.getMaterial() == Material.air)
{
this.theWorld.sendBlockBreakProgress(this.thisPlayerMP.getEntityId(), this.field_180240_f, -1);
this.durabilityRemainingOnBlock = -1;
this.isDestroyingBlock = false;
}
else
{
int k = this.curblockDamage - this.initialDamage;
float f1 = block1.getPlayerRelativeBlockHardness(this.thisPlayerMP, this.thisPlayerMP.worldObj, this.field_180241_i) * (float)(k + 1);
int l = (int)(f1 * 10.0F);
if (l != this.durabilityRemainingOnBlock)
{
this.theWorld.sendBlockBreakProgress(this.thisPlayerMP.getEntityId(), this.field_180240_f, l);
this.durabilityRemainingOnBlock = l;
}
}
}
}
示例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;
}
}
}
示例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;
}
}
示例5: onPlayerDamageBlock
import net.minecraft.block.Block; //导入方法依赖的package包/类
public boolean onPlayerDamageBlock(BlockPos posBlock, EnumFacing directionFacing)
{
this.syncCurrentPlayItem();
if (this.blockHitDelay > 0)
{
--this.blockHitDelay;
return true;
}
else if (this.currentGameType.isCreative() && this.mc.theWorld.getWorldBorder().contains(posBlock))
{
this.blockHitDelay = 5;
this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, posBlock, directionFacing));
clickBlockCreative(this.mc, this, posBlock, directionFacing);
return true;
}
else if (this.isHittingPosition(posBlock))
{
Block block = this.mc.theWorld.getBlockState(posBlock).getBlock();
if (block.getMaterial() == Material.air)
{
this.isHittingBlock = false;
return false;
}
else
{
this.curBlockDamageMP += block.getPlayerRelativeBlockHardness(this.mc.thePlayer, this.mc.thePlayer.worldObj, posBlock);
if (this.stepSoundTickCounter % 4.0F == 0.0F)
{
this.mc.getSoundHandler().playSound(new PositionedSoundRecord(new ResourceLocation(block.stepSound.getStepSound()), (block.stepSound.getVolume() + 1.0F) / 8.0F, block.stepSound.getFrequency() * 0.5F, (float)posBlock.getX() + 0.5F, (float)posBlock.getY() + 0.5F, (float)posBlock.getZ() + 0.5F));
}
++this.stepSoundTickCounter;
if (this.curBlockDamageMP >= 1.0F)
{
this.isHittingBlock = false;
this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.STOP_DESTROY_BLOCK, posBlock, directionFacing));
this.onPlayerDestroyBlock(posBlock, directionFacing);
this.curBlockDamageMP = 0.0F;
this.stepSoundTickCounter = 0.0F;
this.blockHitDelay = 5;
}
this.mc.theWorld.sendBlockBreakProgress(this.mc.thePlayer.getEntityId(), this.currentBlock, (int)(this.curBlockDamageMP * 10.0F) - 1);
return true;
}
}
else
{
return this.clickBlock(posBlock, directionFacing);
}
}