public void remove(World world, int i, int j, int k, int l, int i1) {
    super.remove(world, i, j, k, l, i1);
    if (!world.isStatic) {
      world.applyPhysics(i, j + 1, k, this.id);
      world.applyPhysics(i, j - 1, k, this.id);
      world.applyPhysics(i + 1, j, k, this.id);
      world.applyPhysics(i - 1, j, k, this.id);
      world.applyPhysics(i, j, k + 1, this.id);
      world.applyPhysics(i, j, k - 1, this.id);
      this.l(world, i, j, k);
      this.n(world, i - 1, j, k);
      this.n(world, i + 1, j, k);
      this.n(world, i, j, k - 1);
      this.n(world, i, j, k + 1);
      if (world.t(i - 1, j, k)) {
        this.n(world, i - 1, j + 1, k);
      } else {
        this.n(world, i - 1, j - 1, k);
      }

      if (world.t(i + 1, j, k)) {
        this.n(world, i + 1, j + 1, k);
      } else {
        this.n(world, i + 1, j - 1, k);
      }

      if (world.t(i, j, k - 1)) {
        this.n(world, i, j + 1, k - 1);
      } else {
        this.n(world, i, j - 1, k - 1);
      }

      if (world.t(i, j, k + 1)) {
        this.n(world, i, j + 1, k + 1);
      } else {
        this.n(world, i, j - 1, k + 1);
      }
    }
  }
  public void onPlace(World world, int i, int j, int k) {
    if (world.suppressPhysics) return; // CraftBukkit
    super.onPlace(world, i, j, k);
    if (!world.isStatic) {
      this.l(world, i, j, k);
      world.applyPhysics(i, j + 1, k, this.id);
      world.applyPhysics(i, j - 1, k, this.id);
      this.n(world, i - 1, j, k);
      this.n(world, i + 1, j, k);
      this.n(world, i, j, k - 1);
      this.n(world, i, j, k + 1);
      if (world.t(i - 1, j, k)) {
        this.n(world, i - 1, j + 1, k);
      } else {
        this.n(world, i - 1, j - 1, k);
      }

      if (world.t(i + 1, j, k)) {
        this.n(world, i + 1, j + 1, k);
      } else {
        this.n(world, i + 1, j - 1, k);
      }

      if (world.t(i, j, k - 1)) {
        this.n(world, i, j + 1, k - 1);
      } else {
        this.n(world, i, j - 1, k - 1);
      }

      if (world.t(i, j, k + 1)) {
        this.n(world, i, j + 1, k + 1);
      } else {
        this.n(world, i, j - 1, k + 1);
      }
    }
  }
示例#3
0
 public boolean canPlace(World world, int i, int j, int k) {
   return (world.t(i, j - 1, k)) || (world.getTypeId(i, j - 1, k) == Block.GLOWSTONE.id);
 }
  private void a(World world, int i, int j, int k, int l, int i1, int j1) {
    int k1 = world.getData(i, j, k);
    int l1 = 0;

    this.a = false;
    boolean flag = world.isBlockIndirectlyPowered(i, j, k);

    this.a = true;
    int i2;
    int j2;
    int k2;

    if (flag) {
      l1 = 15;
    } else {
      for (i2 = 0; i2 < 4; ++i2) {
        j2 = i;
        k2 = k;
        if (i2 == 0) {
          j2 = i - 1;
        }

        if (i2 == 1) {
          ++j2;
        }

        if (i2 == 2) {
          k2 = k - 1;
        }

        if (i2 == 3) {
          ++k2;
        }

        if (j2 != l || j != i1 || k2 != j1) {
          l1 = this.getPower(world, j2, j, k2, l1);
        }

        if (world.t(j2, j, k2) && !world.t(i, j + 1, k)) {
          if (j2 != l || j + 1 != i1 || k2 != j1) {
            l1 = this.getPower(world, j2, j + 1, k2, l1);
          }
        } else if (!world.t(j2, j, k2) && (j2 != l || j - 1 != i1 || k2 != j1)) {
          l1 = this.getPower(world, j2, j - 1, k2, l1);
        }
      }

      if (l1 > 0) {
        --l1;
      } else {
        l1 = 0;
      }
    }

    // CraftBukkit start
    if (k1 != l1) {
      BlockRedstoneEvent event =
          new BlockRedstoneEvent(world.getWorld().getBlockAt(i, j, k), k1, l1);
      world.getServer().getPluginManager().callEvent(event);

      l1 = event.getNewCurrent();
    }
    // CraftBukkit end

    if (k1 != l1) {
      world.suppressPhysics = true;
      world.setData(i, j, k, l1);
      world.e(i, j, k, i, j, k);
      world.suppressPhysics = false;

      for (i2 = 0; i2 < 4; ++i2) {
        j2 = i;
        k2 = k;
        int l2 = j - 1;

        if (i2 == 0) {
          j2 = i - 1;
        }

        if (i2 == 1) {
          ++j2;
        }

        if (i2 == 2) {
          k2 = k - 1;
        }

        if (i2 == 3) {
          ++k2;
        }

        if (world.t(j2, j, k2)) {
          l2 += 2;
        }

        boolean flag1 = false;
        int i3 = this.getPower(world, j2, j, k2, -1);

        l1 = world.getData(i, j, k);
        if (l1 > 0) {
          --l1;
        }

        if (i3 >= 0 && i3 != l1) {
          this.a(world, j2, j, k2, i, j, k);
        }

        i3 = this.getPower(world, j2, l2, k2, -1);
        l1 = world.getData(i, j, k);
        if (l1 > 0) {
          --l1;
        }

        if (i3 >= 0 && i3 != l1) {
          this.a(world, j2, l2, k2, i, j, k);
        }
      }

      if (k1 < l1 || l1 == 0) {
        this.b.add(new ChunkPosition(i, j, k));
        this.b.add(new ChunkPosition(i - 1, j, k));
        this.b.add(new ChunkPosition(i + 1, j, k));
        this.b.add(new ChunkPosition(i, j - 1, k));
        this.b.add(new ChunkPosition(i, j + 1, k));
        this.b.add(new ChunkPosition(i, j, k - 1));
        this.b.add(new ChunkPosition(i, j, k + 1));
      }
    }
  }
示例#5
0
  public boolean interactWith(
      ItemStack itemstack,
      EntityHuman entityhuman,
      World world,
      int i,
      int j,
      int k,
      int l,
      float f,
      float f1,
      float f2) {
    if (!entityhuman.a(i, j, k, l, itemstack)) {
      return false;
    } else {
      int i1;
      int j1;
      int k1;

      if (itemstack.getData() == 15) {
        i1 = world.getTypeId(i, j, k);
        if (i1 == Block.SAPLING.id) {
          if (!world.isStatic) {
            // CraftBukkit start
            Player player =
                (entityhuman instanceof EntityPlayer)
                    ? (Player) entityhuman.getBukkitEntity()
                    : null;
            ((BlockSapling) Block.SAPLING)
                .grow(world, i, j, k, world.random, true, player, itemstack);
            // --itemstack.count; - called later if the bonemeal attempt was succesful
            // CraftBukkit end
          }

          return true;
        }

        if (i1 == Block.BROWN_MUSHROOM.id || i1 == Block.RED_MUSHROOM.id) {
          // CraftBukkit start
          if (!world.isStatic) {
            Player player =
                (entityhuman instanceof EntityPlayer)
                    ? (Player) entityhuman.getBukkitEntity()
                    : null;
            ((BlockMushroom) Block.byId[i1])
                .grow(world, i, j, k, world.random, true, player, itemstack);
            // --itemstack.count; - called later if the bonemeal attempt was succesful
            // CraftBukkit end
          }

          return true;
        }

        if (i1 == Block.MELON_STEM.id || i1 == Block.PUMPKIN_STEM.id) {
          if (world.getData(i, j, k) == 7) {
            return false;
          }

          if (!world.isStatic) {
            ((BlockStem) Block.byId[i1]).l(world, i, j, k);
            --itemstack.count;
          }

          return true;
        }

        if (i1 > 0 && Block.byId[i1] instanceof BlockCrops) {
          if (world.getData(i, j, k) == 7) {
            return false;
          }

          if (!world.isStatic) {
            ((BlockCrops) Block.byId[i1]).c_(world, i, j, k);
            --itemstack.count;
          }

          return true;
        }

        if (i1 == Block.COCOA.id) {
          if (!world.isStatic) {
            world.setData(i, j, k, 8 | BlockDirectional.e(world.getData(i, j, k)));
            --itemstack.count;
          }

          return true;
        }

        if (i1 == Block.GRASS.id) {
          if (!world.isStatic) {
            --itemstack.count;

            label133:
            for (j1 = 0; j1 < 128; ++j1) {
              k1 = i;
              int l1 = j + 1;
              int i2 = k;

              for (int j2 = 0; j2 < j1 / 16; ++j2) {
                k1 += d.nextInt(3) - 1;
                l1 += (d.nextInt(3) - 1) * d.nextInt(3) / 2;
                i2 += d.nextInt(3) - 1;
                if (world.getTypeId(k1, l1 - 1, i2) != Block.GRASS.id || world.t(k1, l1, i2)) {
                  continue label133;
                }
              }

              if (world.getTypeId(k1, l1, i2) == 0) {
                if (d.nextInt(10) != 0) {
                  if (Block.LONG_GRASS.d(world, k1, l1, i2)) {
                    world.setTypeIdAndData(k1, l1, i2, Block.LONG_GRASS.id, 1);
                  }
                } else if (d.nextInt(3) != 0) {
                  if (Block.YELLOW_FLOWER.d(world, k1, l1, i2)) {
                    world.setTypeId(k1, l1, i2, Block.YELLOW_FLOWER.id);
                  }
                } else if (Block.RED_ROSE.d(world, k1, l1, i2)) {
                  world.setTypeId(k1, l1, i2, Block.RED_ROSE.id);
                }
              }
            }
          }

          return true;
        }
      } else if (itemstack.getData() == 3) {
        i1 = world.getTypeId(i, j, k);
        j1 = world.getData(i, j, k);
        if (i1 == Block.LOG.id && BlockLog.e(j1) == 3) {
          if (l == 0) {
            return false;
          }

          if (l == 1) {
            return false;
          }

          if (l == 2) {
            --k;
          }

          if (l == 3) {
            ++k;
          }

          if (l == 4) {
            --i;
          }

          if (l == 5) {
            ++i;
          }

          if (world.isEmpty(i, j, k)) {
            k1 = Block.byId[Block.COCOA.id].getPlacedData(world, i, j, k, l, f, f1, f2, 0);
            world.setTypeIdAndData(i, j, k, Block.COCOA.id, k1);
            if (!entityhuman.abilities.canInstantlyBuild) {
              --itemstack.count;
            }
          }

          return true;
        }
      }

      return false;
    }
  }