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

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

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

Block.getCollisionBoundingBox介绍

暂无

代码示例

代码示例来源:origin: DimensionalDevelopment/VanillaFix

@Override
@Nullable
public AxisAlignedBB getCollisionBoundingBox(IBlockAccess world, BlockPos pos) {
  return block.getCollisionBoundingBox(this, world, pos);
}

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

@Nullable
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
  return super.getCollisionBoundingBox(blockState, worldIn, pos);
}

代码示例来源:origin: DimensionalDevelopment/VanillaFix

@Override
@Nullable
public AxisAlignedBB getCollisionBoundingBox(IBlockAccess worldIn, BlockPos pos) {
  return normalState.getBlock().getCollisionBoundingBox(this, worldIn, pos);
}

代码示例来源:origin: ForestryMC/ForestryMC

@Nullable
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
  TreeDefinition treeDefinition = blockState.getValue(getVariant());
  if (TreeDefinition.Willow.equals(treeDefinition)) {
    return null;
  }
  return super.getCollisionBoundingBox(blockState, worldIn, pos);
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

private boolean canSupport(Block block, BlockPos pos) {
  IBlockState state = world.getBlockState(pos);
  if (block == Blocks.TRAPDOOR) {
    return !state.getValue(BlockTrapDoor.OPEN) && state.getValue(BlockTrapDoor.HALF) == BlockTrapDoor.DoorHalf.BOTTOM;
  }
  AxisAlignedBB bb = block.getCollisionBoundingBox(state, world, pos);
  return bb != null && bb.maxY <= 0.5d && bb.minX < 0.35 && bb.maxX > 0.65 && bb.minZ < 0.35 && bb.maxZ > 0.65;
}

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

public static boolean canBeAbove(World world, BlockPos pos) {
  BlockPos upPos = pos.up();
  IBlockState state = world.getBlockState(upPos);
  Block block = state.getBlock();
  return block.getCollisionBoundingBox(state, world, upPos) == null;
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

/**
 * checks the collision bounds of the block at x,y,z to make sure it is <= 0.5 tall (pathable)
 *
 * @return true if it is a pathable block, false if it fails bounds checks
 */
public boolean checkBlockBounds(int x, int y, int z) {
  BlockPos pos = new BlockPos(x, y, z);
  IBlockState state = world.getBlockState(pos);
  Block block = state.getBlock();
  if (block == Blocks.WATER || block == Blocks.FLOWING_WATER) {
    return true;
  } else if (block == Blocks.TRAPDOOR) {
    return state.getValue(BlockTrapDoor.OPEN);
  }
  if (block != Blocks.AIR) {
    AxisAlignedBB bb = block.getCollisionBoundingBox(state, world, pos);
    if (bb == null) {
      return true;
    }
    if (bb.maxY >= 0.5d) {
      return false;
    }
  }
  return true;
}

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

private void teleportPlayer(EntityEnderman entity, EntityLivingBase target, BlockPos pos) {
  IBlockState state = entity.getEntityWorld().getBlockState(pos);
  Block block = state.getBlock();
  if(block.getCollisionBoundingBox(state, entity.getEntityWorld(), pos) != null) {
    for(int i = 0; i < 16; i++)
      if(target.attemptTeleport(entity.posX + (Math.random() - 0.5) * 2, entity.posY + 0.5, entity.posZ + (Math.random() - 0.5) * 2))
        break;
    target.addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, 30, 0));
    target.getEntityWorld().playSound(null, entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_ENDERMEN_SCREAM, SoundCategory.HOSTILE, 1F, 1F);
    target.getEntityWorld().playSound(null, entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.HOSTILE, 1F, 1F);
  }
}

代码示例来源:origin: RS485/LogisticsPipes

DoubleCoordinates coords = CoordinateUtils.add(new DoubleCoordinates((TileEntity) pipeTile), dir);
Block block = coords.getBlock(pipeTile.getWorld());
AxisAlignedBB bb = block.getCollisionBoundingBox(coords.getBlockState(pipeTile.getWorld()), pipeTile.getWorld(), coords.getBlockPos());
if(bb == null) bb = Block.FULL_BLOCK_AABB;
double[] bounds = { bb.minY, bb.minZ, bb.minX, bb.maxY, bb.maxZ, bb.maxX };

代码示例来源: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: Vazkii/Quark

@SubscribeEvent
public void onUpdate(LivingUpdateEvent event) {
  if(event.getEntityLiving() instanceof EntityEnderman && event.getEntityLiving().getEntityWorld().getDifficulty().getDifficultyId() >= minimumDifficulty) {
    EntityEnderman entity = (EntityEnderman) event.getEntityLiving();
    
    if(entity.getHealth() < lowerBound)
      return;
    BlockPos ourPos = entity.getPosition().up(2);
    IBlockState ourState = entity.getEntityWorld().getBlockState(ourPos);
    Block ourBlock = ourState.getBlock();
    if(ourBlock.getCollisionBoundingBox(ourState, entity.getEntityWorld(), ourPos) != null)
      return;
    EntityLivingBase target = entity.getAttackTarget();
    if(target != null && target instanceof EntityPlayer && target.onGround) {
      BlockPos pos = target.getPosition().up(2);
      if(pos.getDistance(ourPos.getX(), ourPos.getY(), ourPos.getZ()) > 5)
        return;
      if(oldBehaviour)
        teleportPlayer(entity, target, pos);
      else pickupDefense(entity, target, ourPos);
    }
  }
}

相关文章

Block类方法