Beispiel #1
0
  @Override
  public void breakBlock(World world, int x, int y, int z, int par5, int par6) {
    // Remove the ghost block.
    world.setBlockToAir(x, y + 1, z);

    // Spawn the required number of extra sudes.
    TileEntitySudis tileEntitySudis = (TileEntitySudis) world.getBlockTileEntity(x, y, z);
    if (tileEntitySudis != null && tileEntitySudis.getHasMultipleSudes()) {
      for (int i = 0; i < tileEntitySudis.getNumberOfSudes() - 1; i++) {
        float spawnX = x + world.rand.nextFloat();
        float spawnY = y + world.rand.nextFloat();
        float spawnZ = z + world.rand.nextFloat();

        EntityItem droppedItem =
            new EntityItem(
                world, spawnX, spawnY, spawnZ, new ItemStack(BlockManager.blockSudis, 1));

        float mult = 0.05F;

        droppedItem.motionX = (-0.5F + world.rand.nextFloat()) * mult;
        droppedItem.motionY = (4 + world.rand.nextFloat()) * mult;
        droppedItem.motionZ = (-0.5F + world.rand.nextFloat()) * mult;

        world.spawnEntityInWorld(droppedItem);
      }
    }

    super.breakBlock(world, x, y, z, par5, par6);
  }
Beispiel #2
0
  /**
   * Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they
   * intersect the mask.) Parameters: World, X, Y, Z, mask, list, colliding entity
   */
  public void addCollisionBoxesToList(
      World world,
      int x,
      int y,
      int z,
      AxisAlignedBB par5AxisAlignedBB,
      List par6List,
      Entity par7Entity) {
    TileEntitySudis tileEntitySudis = (TileEntitySudis) world.getBlockTileEntity(x, y, z);
    boolean flag = false, flag1 = false, flag2 = false, flag3 = false;
    if (tileEntitySudis != null && tileEntitySudis.getHasMultipleSudes()) {
      flag = canConnectSudisTo(world, x, y, z - 1);
      flag1 = canConnectSudisTo(world, x, y, z + 1);
      flag2 = canConnectSudisTo(world, x - 1, y, z);
      flag3 = canConnectSudisTo(world, x + 1, y, z);
    }

    int connectCount = 0;
    if (flag) {
      connectCount++;
    }
    if (flag1) {
      connectCount++;
    }
    if (flag2) {
      connectCount++;
    }
    if (flag3) {
      connectCount++;
    }

    float f = 0.375F;
    float f1 = 0.625F;
    float f2 = 0.375F;
    float f3 = 0.625F;

    if (flag || (flag1 && connectCount <= 1)) {
      f2 = 0.0F;
    }
    if (flag1 || (flag && connectCount <= 1)) {
      f3 = 1.0F;
    }
    if (flag || flag1) {
      setBlockBounds(f, 0, f2, f1, MODEL_SUDIS_HEIGHT, f3);
      super.addCollisionBoxesToList(world, x, y, z, par5AxisAlignedBB, par6List, par7Entity);
    }

    f2 = 0.375F;
    f3 = 0.625F;

    if (flag2 || (flag3 && connectCount <= 1)) {
      f = 0.0F;
    }
    if (flag3 || (flag2 && connectCount <= 1)) {
      f1 = 1.0F;
    }
    if (flag2 || flag3 || !flag && !flag1) {
      setBlockBounds(f, 0, f2, f1, MODEL_SUDIS_HEIGHT, f3);
      super.addCollisionBoxesToList(world, x, y, z, par5AxisAlignedBB, par6List, par7Entity);
    }
    if (flag || (flag1 && connectCount <= 1)) {
      f2 = 0.0F;
    }
    if (flag1 || (flag && connectCount <= 1)) {
      f3 = 1.0F;
    }

    setBlockBounds(f, 0, f2, f1, MODEL_SUDIS_HEIGHT, f3);
  }