net.minecraft.block.Block.canEntityDestroy()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(3.9k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中net.minecraft.block.Block.canEntityDestroy()方法的一些代码示例,展示了Block.canEntityDestroy()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.canEntityDestroy()方法的具体详情如下:
包路径:net.minecraft.block.Block
类名称:Block
方法名:canEntityDestroy

Block.canEntityDestroy介绍

暂无

代码示例

代码示例来源:origin: Alex-the-666/Ice_and_Fire

public boolean canDestroyBlock(BlockPos pos){
  float hardness = world.getBlockState(pos).getBlock().getBlockHardness(world.getBlockState(pos), world, pos);
  return world.getBlockState(pos).getBlock().canEntityDestroy(world.getBlockState(pos), world, pos, this) && hardness >= 0;
}

代码示例来源:origin: Silentine/GrimoireOfGaia

/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute() {
  if (!super.shouldExecute()) {
    return false;
  } else if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.entity.world, this.entity) || !this.entity.world.getBlockState(this.doorPosition).getBlock().canEntityDestroy(this.entity.world.getBlockState(this.doorPosition), this.entity.world, this.doorPosition, this.entity) || !net.minecraftforge.event.ForgeEventFactory.onEntityDestroyBlock(this.entity, this.doorPosition, this.entity.world.getBlockState(this.doorPosition))) {
    return false;
  } else {
    BlockDoor blockdoor = this.doorBlock;
    return !BlockDoor.isOpen(this.entity.world, this.doorPosition);
  }
}

代码示例来源:origin: Alex-the-666/Ice_and_Fire

if (f > 0.0F && (this.exploder == null || this.exploder.canExplosionDestroyBlock(this, this.worldObj, blockpos, iblockstate, f)) && iblockstate.getBlock().canEntityDestroy(iblockstate, this.worldObj, blockpos, this.exploder)) {
  set.add(blockpos);

代码示例来源:origin: Alex-the-666/Ice_and_Fire

if (f > 0.0F && (this.exploder == null || this.exploder.canExplosionDestroyBlock(this, this.worldObj, blockpos, iblockstate, f)) && iblockstate.getBlock().canEntityDestroy(iblockstate, this.worldObj, blockpos, this.exploder)) {
  set.add(blockpos);

代码示例来源:origin: Alex-the-666/Ice_and_Fire

if (f > 0.0F && (this.exploder == null || this.exploder.canExplosionDestroyBlock(this, this.worldObj, blockpos, iblockstate, f)) && iblockstate.getBlock().canEntityDestroy(iblockstate, this.worldObj, blockpos, this.exploder)) {
  set.add(blockpos);

代码示例来源:origin: Alex-the-666/Ice_and_Fire

if (f > 0.0F && (this.exploder == null || this.exploder.canExplosionDestroyBlock(this, this.worldObj, blockpos, iblockstate, f)) && iblockstate.getBlock().canEntityDestroy(iblockstate, this.worldObj, blockpos, this.exploder)) {
  set.add(blockpos);

代码示例来源:origin: Alex-the-666/Ice_and_Fire

if (f > 0.0F && (this.exploder == null || this.exploder.canExplosionDestroyBlock(this, this.worldObj, blockpos, iblockstate, f)) && iblockstate.getBlock().canEntityDestroy(iblockstate, this.worldObj, blockpos, this.exploder)) {
  set.add(blockpos);

代码示例来源:origin: Vazkii/Quark

private void pickupDefense(EntityEnderman entity, EntityLivingBase target, BlockPos pos) {
  if(entity.ticksExisted % delay != 0 && (ignoreMobGriefing || !entity.world.getGameRules().getBoolean("mobGriefing")))
    return;
  Vec3d look = entity.getLookVec();
  pos = pos.add((int) (look.x * 1.2), 0, (int) (look.z * 1.2));
  entity.swingArm(EnumHand.MAIN_HAND);
  
  IBlockState state = entity.world.getBlockState(pos);
  Block block = state.getBlock();
  boolean unbreakable = block.getBlockHardness(state, entity.world, pos) == -1 || !block.canEntityDestroy(state, entity.world, pos, entity);
  if(!unbreakable && block.getCollisionBoundingBox(state, entity.getEntityWorld(), pos) != null) {
    List<ItemStack> drops = block.getDrops(entity.world, pos, state, 0);
    entity.world.setBlockToAir(pos);
    entity.world.playEvent(2001, pos, Block.getStateId(state));
    
    if(!target.world.isRemote)
      for(ItemStack drop : drops)
        entity.world.spawnEntity(new EntityItem(entity.world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, drop));
  }
}

代码示例来源:origin: PrinceOfAmber/Cyclic

|| bsCurrent.getBlock().canEntityDestroy(bsCurrent, world, posCurrent, player) == false
 || bsCurrent.getBlock().getBlockHardness(bsCurrent, world, posCurrent) < 0) {
continue;

相关文章

Block类方法