Esempio n. 1
0
  public boolean interactWith(
      ItemStack itemstack,
      EntityHuman entityhuman,
      World world,
      BlockPosition blockposition,
      EnumDirection enumdirection,
      float f,
      float f1,
      float f2) {
    if (!entityhuman.a(blockposition.shift(enumdirection), enumdirection, itemstack)) {
      return false;
    } else {
      IBlockData iblockdata = world.getType(blockposition);
      Block block = iblockdata.getBlock();

      if (enumdirection != EnumDirection.DOWN
          && world.getType(blockposition.up()).getBlock().getMaterial() == Material.AIR) {
        if (block == Blocks.GRASS) {
          return this.a(
              itemstack, entityhuman, world, blockposition, Blocks.FARMLAND.getBlockData());
        }

        if (block == Blocks.DIRT) {
          switch (ItemHoe.SyntheticClass_1.a[
              ((BlockDirt.EnumDirtVariant) iblockdata.get(BlockDirt.VARIANT)).ordinal()]) {
            case 1:
              return this.a(
                  itemstack, entityhuman, world, blockposition, Blocks.FARMLAND.getBlockData());

            case 2:
              return this.a(
                  itemstack,
                  entityhuman,
                  world,
                  blockposition,
                  Blocks.DIRT
                      .getBlockData()
                      .set(BlockDirt.VARIANT, BlockDirt.EnumDirtVariant.DIRT));
          }
        }
      }

      return false;
    }
  }
Esempio n. 2
0
  public UseResult registerItemKey(
      ItemStack var1,
      EntityHuman var2,
      World var3,
      BlockPosition var4,
      EnumUsedHand var5,
      EnumDirection var6,
      float var7,
      float var8,
      float var9) {
    if (!var2.a(var4.shift(var6), var6, var1)) {
      return UseResult.CANT_USE;
    } else {
      IBlockData var10 = var3.getType(var4);
      Block var11 = var10.getBlock();
      if (var6 != EnumDirection.DOWN
          && var3.getType(var4.up()).getBlock().getMaterial() == Material.AIR) {
        if (var11 == Blocks.GRASS || var11 == Blocks.GRASS_PATH) {
          return this.a(var1, var2, var3, var4, Blocks.FARMLAND.getBlockData());
        }

        if (var11 == Blocks.DIRT) {
          switch (ItemHoe.SyntheticClass_1.a[
              ((BlockDirt.EnumDirtVariant) var10.get(BlockDirt.VARIANT)).ordinal()]) {
            case 1:
              return this.a(var1, var2, var3, var4, Blocks.FARMLAND.getBlockData());
            case 2:
              return this.a(
                  var1,
                  var2,
                  var3,
                  var4,
                  Blocks.DIRT
                      .getBlockData()
                      .set(BlockDirt.VARIANT, BlockDirt.EnumDirtVariant.DIRT));
          }
        }
      }

      return UseResult.CANT_USE;
    }
  }
Esempio n. 3
0
  public void a(World world, Entity entity, WorldMap worldmap) {
    // CraftBukkit - world.worldProvider -> ((WorldServer) world)
    if (((WorldServer) world).dimension == worldmap.map && entity instanceof EntityHuman) {
      int i = 1 << worldmap.scale;
      int j = worldmap.centerX;
      int k = worldmap.centerZ;
      int l = MathHelper.floor(entity.locX - j) / i + 64;
      int i1 = MathHelper.floor(entity.locZ - k) / i + 64;
      int j1 = 128 / i;

      if (world.worldProvider.g) {
        j1 /= 2;
      }

      WorldMapHumanTracker worldmaphumantracker = worldmap.a((EntityHuman) entity);

      ++worldmaphumantracker.d;

      for (int k1 = l - j1 + 1; k1 < l + j1; ++k1) {
        if ((k1 & 15) == (worldmaphumantracker.d & 15)) {
          int l1 = 255;
          int i2 = 0;
          double d0 = 0.0D;

          for (int j2 = i1 - j1 - 1; j2 < i1 + j1; ++j2) {
            if (k1 >= 0 && j2 >= -1 && k1 < 128 && j2 < 128) {
              int k2 = k1 - l;
              int l2 = j2 - i1;
              boolean flag = k2 * k2 + l2 * l2 > (j1 - 2) * (j1 - 2);
              int i3 = (j / i + k1 - 64) * i;
              int j3 = (k / i + j2 - 64) * i;
              HashMultiset hashmultiset = HashMultiset.create();
              Chunk chunk = world.getChunkAtWorldCoords(i3, j3);

              if (!chunk.isEmpty()) {
                int k3 = i3 & 15;
                int l3 = j3 & 15;
                int i4 = 0;
                double d1 = 0.0D;
                int j4;

                if (world.worldProvider.g) {
                  j4 = i3 + j3 * 231871;
                  j4 = j4 * j4 * 31287121 + j4 * 11;
                  if ((j4 >> 20 & 1) == 0) {
                    hashmultiset.add(Blocks.DIRT.f(0), 10);
                  } else {
                    hashmultiset.add(Blocks.STONE.f(0), 100);
                  }

                  d1 = 100.0D;
                } else {
                  for (j4 = 0; j4 < i; ++j4) {
                    for (int k4 = 0; k4 < i; ++k4) {
                      int l4 = chunk.b(j4 + k3, k4 + l3) + 1;
                      Block block = Blocks.AIR;
                      int i5 = 0;

                      if (l4 > 1) {
                        do {
                          --l4;
                          block = chunk.getType(j4 + k3, l4, k4 + l3);
                          i5 = chunk.getData(j4 + k3, l4, k4 + l3);
                        } while (block.f(i5) == MaterialMapColor.b && l4 > 0);

                        if (l4 > 0 && block.getMaterial().isLiquid()) {
                          int j5 = l4 - 1;

                          Block block1;

                          do {
                            block1 = chunk.getType(j4 + k3, j5--, k4 + l3);
                            ++i4;
                          } while (j5 > 0 && block1.getMaterial().isLiquid());
                        }
                      }

                      d1 += (double) l4 / (double) (i * i);
                      hashmultiset.add(block.f(i5));
                    }
                  }
                }

                i4 /= i * i;
                double d2 = (d1 - d0) * 4.0D / (i + 4) + ((k1 + j2 & 1) - 0.5D) * 0.4D;
                byte b0 = 1;

                if (d2 > 0.6D) {
                  b0 = 2;
                }

                if (d2 < -0.6D) {
                  b0 = 0;
                }

                MaterialMapColor materialmapcolor =
                    Iterables.getFirst(
                        Multisets.copyHighestCountFirst(hashmultiset), MaterialMapColor.b);

                if (materialmapcolor == MaterialMapColor.n) {
                  d2 = i4 * 0.1D + (k1 + j2 & 1) * 0.2D;
                  b0 = 1;
                  if (d2 < 0.5D) {
                    b0 = 2;
                  }

                  if (d2 > 0.9D) {
                    b0 = 0;
                  }
                }

                d0 = d1;
                if (j2 >= 0 && k2 * k2 + l2 * l2 < j1 * j1 && (!flag || (k1 + j2 & 1) != 0)) {
                  byte b1 = worldmap.colors[k1 + j2 * 128];
                  byte b2 = (byte) (materialmapcolor.M * 4 + b0);

                  if (b1 != b2) {
                    if (l1 > j2) {
                      l1 = j2;
                    }

                    if (i2 < j2) {
                      i2 = j2;
                    }

                    worldmap.colors[k1 + j2 * 128] = b2;
                  }
                }
              }
            }
          }

          if (l1 <= i2) {
            worldmap.flagDirty(k1, l1, i2);
          }
        }
      }
    }
  }