Esempio n. 1
0
  public void a(
      World world, BlockPosition blockposition, IBlockData iblockdata, EntityLiving entityliving) {
    if (!world.isClientSide) {
      if (((Boolean) iblockdata.get(BlockTNT.EXPLODE)).booleanValue()) {
        EntityTNTPrimed entitytntprimed =
            new EntityTNTPrimed(
                world,
                (double) ((float) blockposition.getX() + 0.5F),
                (double) blockposition.getY(),
                (double) ((float) blockposition.getZ() + 0.5F),
                entityliving);

        world.addEntity(entitytntprimed);
        world.a(
            (EntityHuman) null,
            entitytntprimed.locX,
            entitytntprimed.locY,
            entitytntprimed.locZ,
            SoundEffects.gV,
            SoundCategory.BLOCKS,
            1.0F,
            1.0F);
      }
    }
  }
Esempio n. 2
0
  public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) {
    super.dropNaturally(world, i, j, k, l, f, i1);
    if (!world.isStatic) {
      Item item = null;

      if (this.blockFruit == Block.PUMPKIN) {
        item = Item.PUMPKIN_SEEDS;
      }

      if (this.blockFruit == Block.MELON) {
        item = Item.MELON_SEEDS;
      }

      for (int j1 = 0; j1 < 3; ++j1) {
        if (world.random.nextInt(15) <= l) {
          float f1 = 0.7F;
          float f2 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F;
          float f3 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F;
          float f4 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F;
          EntityItem entityitem =
              new EntityItem(
                  world,
                  (double) ((float) i + f2),
                  (double) ((float) j + f3),
                  (double) ((float) k + f4),
                  new ItemStack(item));

          entityitem.pickupDelay = 10;
          world.addEntity(entityitem);
        }
      }
    }
  }
Esempio n. 3
0
  public void dropRecord(World world, int i, int j, int k) {
    if (!world.isStatic) {
      TileEntityRecordPlayer tileentityrecordplayer =
          (TileEntityRecordPlayer) world.getTileEntity(i, j, k);

      if (tileentityrecordplayer != null) {
        ItemStack itemstack = tileentityrecordplayer.record;

        if (itemstack != null) {
          world.triggerEffect(1005, i, j, k, 0);
          world.a((String) null, i, j, k);
          tileentityrecordplayer.record = null;
          tileentityrecordplayer.update();
          world.setData(i, j, k, 0);
          float f = 0.7F;
          double d0 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
          double d1 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.2D + 0.6D;
          double d2 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
          ItemStack itemstack1 = itemstack.cloneItemStack();
          EntityItem entityitem =
              new EntityItem(world, (double) i + d0, (double) j + d1, (double) k + d2, itemstack1);

          entityitem.pickupDelay = 10;
          world.addEntity(entityitem);
        }
      }
    }
  }
Esempio n. 4
0
  @Override
  public void wasExploded(World world, int i, int j, int k, Explosion explosion) {
    if (!world.isStatic) {
      EntityTNTPrimed entitytntprimed =
          new EntityTNTPrimed(world, i + 0.5F, j + 0.5F, k + 0.5F, explosion.c());

      entitytntprimed.fuseTicks =
          world.random.nextInt(entitytntprimed.fuseTicks / 4) + entitytntprimed.fuseTicks / 8;
      world.addEntity(entitytntprimed);
    }
  }
Esempio n. 5
0
  public void a(World world, int i, int j, int k, int l, EntityLiving entityliving) {
    if (!world.isStatic) {
      if ((l & 1) == 1) {
        EntityTNTPrimed entitytntprimed =
            new EntityTNTPrimed(world, i + 0.5F, j + 0.5F, k + 0.5F, entityliving);

        world.addEntity(entitytntprimed);
        world.makeSound(entitytntprimed, "game.tnt.primed", 1.0F, 1.0F);
      }
    }
  }
Esempio n. 6
0
  public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
    if (!entityhuman.abilities.canInstantlyBuild) {
      --itemstack.count;
    }

    world.makeSound(entityhuman, "random.bow", 0.5F, 0.4F / (c.nextFloat() * 0.4F + 0.8F));
    if (!world.isStatic) {
      world.addEntity(new EntitySnowball(world, entityhuman));
    }

    return itemstack;
  }
Esempio n. 7
0
  protected void a(World world, int i, int j, int k, ItemStack itemstack) {
    if (!world.isStatic) {
      float f = 0.7F;
      double d0 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
      double d1 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
      double d2 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
      EntityItem entityitem =
          new EntityItem(world, (double) i + d0, (double) j + d1, (double) k + d2, itemstack);

      entityitem.pickupDelay = 10;
      world.addEntity(entityitem);
    }
  }
Esempio n. 8
0
  public void wasExploded(World world, BlockPosition blockposition, Explosion explosion) {
    if (!world.isClientSide) {
      EntityTNTPrimed entitytntprimed =
          new EntityTNTPrimed(
              world,
              (double) ((float) blockposition.getX() + 0.5F),
              (double) blockposition.getY(),
              (double) ((float) blockposition.getZ() + 0.5F),
              explosion.getSource());

      entitytntprimed.setFuseTicks(
          (short)
              (world.random.nextInt(entitytntprimed.getFuseTicks() / 4)
                  + entitytntprimed.getFuseTicks() / 8));
      world.addEntity(entitytntprimed);
    }
  }
Esempio n. 9
0
 protected boolean a(World var1, CuboidArea var2, int var3, int var4, int var5) {
   int var6 = this.a(var3, var5);
   int var7 = this.d(var4);
   int var8 = this.b(var3, var5);
   if (var2.b((fd) (new Position(var6, var7, var8)))) {
     EntityGuardian var9 = new EntityGuardian(var1);
     var9.a(true);
     var9.g(var9.bt());
     var9.setPositionRotation(
         (double) var6 + 0.5D, (double) var7, (double) var8 + 0.5D, 0.0F, 0.0F);
     var9.a(var1.E(new Position(var9)), (xq) null);
     var1.addEntity((Entity) var9);
     return true;
   } else {
     return false;
   }
 }
Esempio n. 10
0
  public void remove(World world, int i, int j, int k) {
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k);

    if (tileentitydispenser != null) {
      for (int l = 0; l < tileentitydispenser.getSize(); ++l) {
        ItemStack itemstack = tileentitydispenser.getItem(l);

        if (itemstack != null) {
          float f = this.a.nextFloat() * 0.8F + 0.1F;
          float f1 = this.a.nextFloat() * 0.8F + 0.1F;
          float f2 = this.a.nextFloat() * 0.8F + 0.1F;

          while (itemstack.count > 0) {
            int i1 = this.a.nextInt(21) + 10;

            if (i1 > itemstack.count) {
              i1 = itemstack.count;
            }

            itemstack.count -= i1;
            EntityItem entityitem =
                new EntityItem(
                    world,
                    (double) ((float) i + f),
                    (double) ((float) j + f1),
                    (double) ((float) k + f2),
                    new ItemStack(itemstack.id, i1, itemstack.getData()));

            if (itemstack.hasTag()) {
              entityitem.itemStack.setTag((NBTTagCompound) itemstack.getTag().clone());
            }

            float f3 = 0.05F;

            entityitem.motX = (double) ((float) this.a.nextGaussian() * f3);
            entityitem.motY = (double) ((float) this.a.nextGaussian() * f3 + 0.2F);
            entityitem.motZ = (double) ((float) this.a.nextGaussian() * f3);
            world.addEntity(entityitem);
          }
        }
      }
    }

    super.remove(world, i, j, k);
  }
Esempio n. 11
0
  public static Wolf spawn(Location location) {

    MinecraftServer server = MinecraftServer.getServer();
    WorldServer world = server.getWorldServer(0);
    for (WorldServer ws : server.worlds) {
      if (ws.getWorld().getName().equals(location.getWorld().getName())) {
        world = ws;
        break;
      }
    }
    World mcWorld = (World) ((CraftWorld) location.getWorld()).getHandle();
    final WolfNPC customEntity = new WolfNPC(world);
    customEntity.setLocation(
        location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    ((CraftLivingEntity) customEntity.getBukkitEntity()).setRemoveWhenFarAway(false);
    mcWorld.addEntity(customEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
    return (CraftWolf) customEntity.getBukkitEntity();
  }
  protected boolean a(World world, StructureBoundingBox structureboundingbox, int i, int j, int k) {
    int l = this.a(i, k);
    int i1 = this.d(j);
    int j1 = this.b(i, k);

    if (structureboundingbox.b((BaseBlockPosition) (new BlockPosition(l, i1, j1)))) {
      EntityGuardian entityguardian = new EntityGuardian(world);

      entityguardian.a(true);
      entityguardian.heal(entityguardian.getMaxHealth());
      entityguardian.setPositionRotation(
          (double) l + 0.5D, (double) i1, (double) j1 + 0.5D, 0.0F, 0.0F);
      entityguardian.prepare(world.E(new BlockPosition(entityguardian)), (GroupDataEntity) null);
      world.addEntity(entityguardian);
      return true;
    } else {
      return false;
    }
  }
Esempio n. 13
0
  public void remove(World world, int i, int j, int k, int l, int i1) {
    TileEntity tileentity = world.getTileEntity(i, j, k);

    if (tileentity instanceof TileEntityBrewingStand) {
      TileEntityBrewingStand tileentitybrewingstand = (TileEntityBrewingStand) tileentity;

      for (int j1 = 0; j1 < tileentitybrewingstand.getSize(); ++j1) {
        ItemStack itemstack = tileentitybrewingstand.getItem(j1);

        if (itemstack != null) {
          float f = this.a.nextFloat() * 0.8F + 0.1F;
          float f1 = this.a.nextFloat() * 0.8F + 0.1F;
          float f2 = this.a.nextFloat() * 0.8F + 0.1F;

          while (itemstack.count > 0) {
            int k1 = this.a.nextInt(21) + 10;

            if (k1 > itemstack.count) {
              k1 = itemstack.count;
            }

            itemstack.count -= k1;
            EntityItem entityitem =
                new EntityItem(
                    world,
                    (double) ((float) i + f),
                    (double) ((float) j + f1),
                    (double) ((float) k + f2),
                    new ItemStack(itemstack.id, k1, itemstack.getData()));
            float f3 = 0.05F;

            entityitem.motX = (double) ((float) this.a.nextGaussian() * f3);
            entityitem.motY = (double) ((float) this.a.nextGaussian() * f3 + 0.2F);
            entityitem.motZ = (double) ((float) this.a.nextGaussian() * f3);
            world.addEntity(entityitem);
          }
        }
      }
    }

    super.remove(world, i, j, k, l, i1);
  }
Esempio n. 14
0
  public boolean a(
      ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
    int i1 = world.getTypeId(i, j, k);

    if (BlockMinecartTrack.d(i1)) {
      if (!world.isStatic) {
        world.addEntity(
            new EntityMinecart(
                world,
                (double) ((float) i + 0.5F),
                (double) ((float) j + 0.5F),
                (double) ((float) k + 0.5F),
                this.a));
      }

      --itemstack.count;
      return true;
    } else {
      return false;
    }
  }
Esempio n. 15
0
  public void shootProjectile(EntityLiving target, float damage, Projectiles projectile) {
    World world = target.world;

    if (projectile == Projectiles.Arrow) {
      EntityArrow arrow = new MyPetArrow(world, entityMyPet, target, 1.6F, 1);
      arrow.b(damage);
      arrow.setCritical(false);
      entityMyPet.makeSound(
          "random.bow", 1.0F, 1.0F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F));
      world.addEntity(arrow);
    } else if (projectile == Projectiles.Snowball) {
      MyPetSnowball snowball = new MyPetSnowball(world, entityMyPet);
      double distanceX = target.locX - entityMyPet.locX;
      double distanceY = target.locY + target.getHeadHeight() - 1.100000023841858D - snowball.locY;
      double distanceZ = target.locZ - entityMyPet.locZ;
      float distance20percent =
          MathHelper.sqrt(distanceX * distanceX + distanceZ * distanceZ) * 0.2F;
      snowball.setDamage(damage);
      snowball.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1);
      entityMyPet.makeSound(
          "random.bow", 0.5F, 0.4F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F));
      world.addEntity(snowball);
    } else if (projectile == Projectiles.Egg) {
      MyPetEgg egg = new MyPetEgg(world, entityMyPet);
      double distanceX = target.locX - entityMyPet.locX;
      double distanceY = target.locY + target.getHeadHeight() - 1.100000023841858D - egg.locY;
      double distanceZ = target.locZ - entityMyPet.locZ;
      float distance20percent =
          MathHelper.sqrt(distanceX * distanceX + distanceZ * distanceZ) * 0.2F;
      egg.setDamage(damage);
      egg.shoot(distanceX, distanceY + distance20percent, distanceZ, 1.6F, 1);
      entityMyPet.makeSound(
          "random.bow", 0.5F, 0.4F / (entityMyPet.getRandom().nextFloat() * 0.4F + 0.8F));
      world.addEntity(egg);
    } else if (projectile == Projectiles.LargeFireball) {
      double distanceX = this.target.locX - entityMyPet.locX;
      double distanceY =
          this.target.getBoundingBox().b
              + (double) (this.target.length / 2.0F)
              - (0.5D + entityMyPet.locY + (double) (entityMyPet.length / 2.0F));
      double distanceZ = this.target.locZ - entityMyPet.locZ;
      MyPetLargeFireball largeFireball =
          new MyPetLargeFireball(world, entityMyPet, distanceX, distanceY, distanceZ);
      largeFireball.locY = (entityMyPet.locY + entityMyPet.length / 2.0F + 0.5D);
      largeFireball.setDamage(damage);
      world.addEntity(largeFireball);
      world.makeSound(
          entityMyPet.locX + 0.5D,
          entityMyPet.locY + 0.5D,
          entityMyPet.locZ + 0.5D,
          "mob.ghast.fireball",
          1.0F + entityMyPet.getRandom().nextFloat(),
          entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F);
    } else if (projectile == Projectiles.SmallFireball) {
      double distanceX = this.target.locX - entityMyPet.locX;
      double distanceY =
          this.target.getBoundingBox().b
              + (this.target.length / 2.0F)
              - (0.5D + entityMyPet.locY + (entityMyPet.length / 2.0F));
      double distanceZ = this.target.locZ - entityMyPet.locZ;
      MyPetSmallFireball smallFireball =
          new MyPetSmallFireball(world, entityMyPet, distanceX, distanceY, distanceZ);
      smallFireball.locY = (entityMyPet.locY + entityMyPet.length / 2.0F + 0.5D);
      smallFireball.setDamage(damage);
      world.addEntity(smallFireball);
      world.makeSound(
          entityMyPet.locX + 0.5D,
          entityMyPet.locY + 0.5D,
          entityMyPet.locZ + 0.5D,
          "mob.ghast.fireball",
          1.0F + entityMyPet.getRandom().nextFloat(),
          entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F);
    } else if (projectile == Projectiles.WitherSkull) {
      double distanceX = this.target.locX - entityMyPet.locX;
      double distanceY =
          this.target.getBoundingBox().b
              + (double) (this.target.length / 2.0F)
              - (0.5D + entityMyPet.locY + (double) (entityMyPet.length / 2.0F));
      double distanceZ = this.target.locZ - entityMyPet.locZ;
      MyPetWitherSkull witherSkull =
          new MyPetWitherSkull(world, entityMyPet, distanceX, distanceY, distanceZ);
      witherSkull.locY = (entityMyPet.locY + entityMyPet.length / 2.0F + 0.5D);
      witherSkull.setDamage(damage);
      world.addEntity(witherSkull);
      world.makeSound(
          entityMyPet.locX + 0.5D,
          entityMyPet.locY + 0.5D,
          entityMyPet.locZ + 0.5D,
          "mob.wither.shoot",
          1.0F + entityMyPet.getRandom().nextFloat(),
          entityMyPet.getRandom().nextFloat() * 0.7F + 0.3F);
    }
  }
Esempio n. 16
0
  /**
   * called when the player releases the use item button. Args: itemstack, world, entityplayer,
   * itemInUseCount
   */
  public void a(ItemStack var1, World var2, EntityHuman var3, int var4) {
    // Forge start
    int var5 = this.a(var1) - var4;
    ArrowLooseEvent var6 = new ArrowLooseEvent(var3, var1, var5);
    MinecraftForge.EVENT_BUS.post(var6);

    if (var6.isCanceled()) {
      return;
    }
    var5 = var6.charge;
    // Forge end
    boolean var7 =
        var3.abilities.canInstantlyBuild
            || EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_INFINITE.id, var1) > 0;

    if (var7 || var3.inventory.e(Item.ARROW.id)) {
      float var8 = (float) var5 / 20.0F;
      var8 = (var8 * var8 + var8 * 2.0F) / 3.0F;

      if ((double) var8 < 0.1D) {
        return;
      }

      if (var8 > 1.0F) {
        var8 = 1.0F;
      }

      EntityArrow var9 = new EntityArrow(var2, var3, var8 * 2.0F);

      if (var8 == 1.0F) {
        var9.e(true);
      }

      int var10 = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_DAMAGE.id, var1);

      if (var10 > 0) {
        var9.b(var9.c() + (double) var10 * 0.5D + 0.5D);
      }

      int var11 = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_KNOCKBACK.id, var1);

      if (var11 > 0) {
        var9.a(var11);
      }

      if (EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_FIRE.id, var1) > 0) {
        var9.setOnFire(100);
      }

      // CraftBukkit start
      org.bukkit.event.entity.EntityShootBowEvent event =
          org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(
              var3, var1, var9, var8);
      if (event.isCancelled()) {
        event.getProjectile().remove();
        return;
      }

      if (event.getProjectile() == var9.getBukkitEntity()) {
        var2.addEntity(var9);
      }
      // CraftBukkit end

      var1.damage(1, var3);
      var2.makeSound(var3, "random.bow", 1.0F, 1.0F / (d.nextFloat() * 0.4F + 1.2F) + var8 * 0.5F);

      if (var7) {
        var9.fromPlayer = 2;
      } else {
        var3.inventory.d(Item.ARROW.id);
      }
    }
  }
Esempio n. 17
0
  // CraftBukkit - priv to public
  public void dispense(World world, int i, int j, int k, Random random) {
    int l = world.getData(i, j, k);
    byte b0 = 0;
    byte b1 = 0;

    if (l == 3) {
      b1 = 1;
    } else if (l == 2) {
      b1 = -1;
    } else if (l == 5) {
      b0 = 1;
    } else {
      b0 = -1;
    }

    TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k);

    if (tileentitydispenser != null) {
      // CraftBukkit start
      int dispenseSlot = tileentitydispenser.findDispenseSlot();
      ItemStack itemstack = null;
      if (dispenseSlot > -1) {
        itemstack = tileentitydispenser.getContents()[dispenseSlot];

        // Copy item stack, because we want it to have 1 item
        itemstack =
            new ItemStack(itemstack.id, 1, itemstack.getData(), itemstack.getEnchantments());
      }
      // CraftBukkit end

      double d0 = (double) i + (double) b0 * 0.6D + 0.5D;
      double d1 = (double) j + 0.5D;
      double d2 = (double) k + (double) b1 * 0.6D + 0.5D;

      if (itemstack == null) {
        world.triggerEffect(1001, i, j, k, 0);
      } else {
        // CraftBukkit start
        double d3 = random.nextDouble() * 0.1D + 0.2D;
        double motX = (double) b0 * d3;
        double motY = 0.20000000298023224D;
        double motZ = (double) b1 * d3;
        motX += random.nextGaussian() * 0.007499999832361937D * 6.0D;
        motY += random.nextGaussian() * 0.007499999832361937D * 6.0D;
        motZ += random.nextGaussian() * 0.007499999832361937D * 6.0D;

        org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
        org.bukkit.inventory.ItemStack bukkitItem = new CraftItemStack(itemstack).clone();

        BlockDispenseEvent event =
            new BlockDispenseEvent(block, bukkitItem, new Vector(motX, motY, motZ));
        world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
          return;
        }

        if (event.getItem().equals(bukkitItem)) {
          // Actually remove the item
          tileentitydispenser.splitStack(dispenseSlot, 1);
        }

        motX = event.getVelocity().getX();
        motY = event.getVelocity().getY();
        motZ = event.getVelocity().getZ();

        itemstack = CraftItemStack.createNMSItemStack(event.getItem());
        // CraftBukkit end

        if (itemstack.id == Item.ARROW.id) {
          EntityArrow entityarrow = new EntityArrow(world, d0, d1, d2);

          entityarrow.shoot((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F);
          entityarrow.fromPlayer = true;
          world.addEntity(entityarrow);
          world.triggerEffect(1002, i, j, k, 0);
        } else if (itemstack.id == Item.EGG.id) {
          EntityEgg entityegg = new EntityEgg(world, d0, d1, d2);

          entityegg.a((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F);
          world.addEntity(entityegg);
          world.triggerEffect(1002, i, j, k, 0);
        } else if (itemstack.id == Item.SNOW_BALL.id) {
          EntitySnowball entitysnowball = new EntitySnowball(world, d0, d1, d2);

          entitysnowball.a((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F);
          world.addEntity(entitysnowball);
          world.triggerEffect(1002, i, j, k, 0);
        } else if (itemstack.id == Item.POTION.id && ItemPotion.c(itemstack.getData())) {
          EntityPotion entitypotion = new EntityPotion(world, d0, d1, d2, itemstack.getData());

          entitypotion.a((double) b0, 0.10000000149011612D, (double) b1, 1.375F, 3.0F);
          world.addEntity(entitypotion);
          world.triggerEffect(1002, i, j, k, 0);
        } else if (itemstack.id == Item.EXP_BOTTLE.id) {
          EntityThrownExpBottle entitythrownexpbottle =
              new EntityThrownExpBottle(world, d0, d1, d2);

          entitythrownexpbottle.a((double) b0, 0.10000000149011612D, (double) b1, 1.375F, 3.0F);
          world.addEntity(entitythrownexpbottle);
          world.triggerEffect(1002, i, j, k, 0);
        } else if (itemstack.id == Item.MONSTER_EGG.id) {
          ItemMonsterEgg.a(
              world,
              itemstack.getData(),
              d0 + (double) b0 * 0.3D,
              d1 - 0.3D,
              d2 + (double) b1 * 0.3D);
          world.triggerEffect(1002, i, j, k, 0);
        } else if (itemstack.id == Item.FIREBALL.id) {
          EntitySmallFireball entitysmallfireball =
              new EntitySmallFireball(
                  world,
                  d0 + (double) b0 * 0.3D,
                  d1,
                  d2 + (double) b1 * 0.3D,
                  (double) b0 + random.nextGaussian() * 0.05D,
                  random.nextGaussian() * 0.05D,
                  (double) b1 + random.nextGaussian() * 0.05D);

          world.addEntity(entitysmallfireball);
          world.triggerEffect(1009, i, j, k, 0);
        } else {
          EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack);
          // CraftBukkit start
          // double d3 = random.nextDouble() * 0.1D + 0.2D; // Moved up
          entityitem.motX = motX;
          entityitem.motY = motY;
          entityitem.motZ = motZ;
          // CraftBukkit end
          world.addEntity(entityitem);
          world.triggerEffect(1000, i, j, k, 0);
        }

        world.triggerEffect(2000, i, j, k, b0 + 1 + (b1 + 1) * 3);
      }
    }
  }
Esempio n. 18
0
  public void a(ItemStack itemstack, World world, EntityHuman entityhuman, int i) {
    boolean flag =
        entityhuman.abilities.canInstantlyBuild
            || EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_INFINITE.id, itemstack) > 0;

    if (flag || entityhuman.inventory.b(Items.ARROW)) {
      int j = this.d(itemstack) - i;
      float f = (float) j / 20.0F;

      f = (f * f + f * 2.0F) / 3.0F;
      if ((double) f < 0.1D) {
        return;
      }

      if (f > 1.0F) {
        f = 1.0F;
      }

      EntityArrow entityarrow = new EntityArrow(world, entityhuman, f * 2.0F);
      entityarrow.damage = 2.3D;

      if (f == 1.0F) {
        entityarrow.setCritical(true);
      }

      int k = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_DAMAGE.id, itemstack);

      if (k > 0) {
        entityarrow.b(entityarrow.j() + (double) k * 0.5D + 0.5D);
      }

      int l = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_KNOCKBACK.id, itemstack);

      if (l > 0) {
        entityarrow.a(l);
      }

      if (EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_FIRE.id, itemstack) > 0) {
        EntityCombustEvent event = new EntityCombustEvent(entityarrow.getBukkitEntity(), 100);
        entityarrow.world.getServer().getPluginManager().callEvent(event);

        if (!event.isCancelled()) {
          entityarrow.setOnFire(event.getDuration());
        }
      }

      // CraftBukkit start
      EntityShootBowEvent event =
          CraftEventFactory.callEntityShootBowEvent(entityhuman, itemstack, entityarrow, f);
      if (event.isCancelled()) {
        event.getProjectile().remove();
        return;
      }

      if (event.getProjectile() == entityarrow.getBukkitEntity()) {
        world.addEntity(entityarrow);
      }
      // CraftBukkit end

      itemstack.damage(1, entityhuman);

      world.makeSound(
          entityhuman, "random.bow", 1.0F, 1.0F / (g.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
      if (flag) {
        entityarrow.fromPlayer = 2;
      } else {
        entityhuman.inventory.a(Items.ARROW);
      }

      entityhuman.b(StatisticList.USE_ITEM_COUNT[Item.getId(this)]);
    }
  }
Esempio n. 19
0
  private void f(World world, BlockPosition blockposition) {
    ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection;
    int i;
    int j;

    if ((shapedetector_shapedetectorcollection =
            this.getDetectorSnowGolem().a(world, blockposition))
        != null) {
      BlockStateListPopulator blockList =
          new BlockStateListPopulator(
              world.getWorld()); // CraftBukkit - Use BlockStateListPopulator
      for (i = 0; i < this.getDetectorSnowGolem().b(); ++i) {
        ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(0, i, 0);

        // CraftBukkit start
        // world.setTypeAndData(shapedetectorblock.d(), Blocks.AIR.getBlockData(), 2);
        BlockPosition pos = shapedetectorblock.getPosition();
        blockList.setTypeId(pos.getX(), pos.getY(), pos.getZ(), 0);
        // CraftBukkit end
      }

      EntitySnowman entitysnowman = new EntitySnowman(world);
      BlockPosition blockposition1 = shapedetector_shapedetectorcollection.a(0, 2, 0).getPosition();

      entitysnowman.setPositionRotation(
          (double) blockposition1.getX() + 0.5D,
          (double) blockposition1.getY() + 0.05D,
          (double) blockposition1.getZ() + 0.5D,
          0.0F,
          0.0F);
      // CraftBukkit start
      if (world.addEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN)) {
        blockList.updateList();

        for (j = 0; j < 120; ++j) {
          world.addParticle(
              EnumParticle.SNOW_SHOVEL,
              (double) blockposition1.getX() + world.random.nextDouble(),
              (double) blockposition1.getY() + world.random.nextDouble() * 2.5D,
              (double) blockposition1.getZ() + world.random.nextDouble(),
              0.0D,
              0.0D,
              0.0D,
              new int[0]);
        }

        for (j = 0; j < this.getDetectorSnowGolem().b(); ++j) {
          ShapeDetectorBlock shapedetectorblock1 = shapedetector_shapedetectorcollection.a(0, j, 0);

          world.update(shapedetectorblock1.getPosition(), Blocks.AIR);
        }
      } // CraftBukkit end
    } else if ((shapedetector_shapedetectorcollection =
            this.getDetectorIronGolem().a(world, blockposition))
        != null) {
      BlockStateListPopulator blockList =
          new BlockStateListPopulator(
              world.getWorld()); // CraftBukkit - Use BlockStateListPopulator
      for (i = 0; i < this.getDetectorIronGolem().c(); ++i) {
        for (int k = 0; k < this.getDetectorIronGolem().b(); ++k) {
          // CraftBukkit start
          // world.setTypeAndData(shapedetectorcollection.a(i, k, 0).d(), Blocks.AIR.getBlockData(),
          // 2);
          BlockPosition pos = shapedetector_shapedetectorcollection.a(i, k, 0).getPosition();
          blockList.setTypeId(pos.getX(), pos.getY(), pos.getZ(), 0);
          // CraftBukkit end
        }
      }

      BlockPosition blockposition2 = shapedetector_shapedetectorcollection.a(1, 2, 0).getPosition();
      EntityIronGolem entityirongolem = new EntityIronGolem(world);

      entityirongolem.setPlayerCreated(true);
      entityirongolem.setPositionRotation(
          (double) blockposition2.getX() + 0.5D,
          (double) blockposition2.getY() + 0.05D,
          (double) blockposition2.getZ() + 0.5D,
          0.0F,
          0.0F);

      // CraftBukkit start
      if (world.addEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM)) {
        blockList.updateList();

        for (j = 0; j < 120; ++j) {
          world.addParticle(
              EnumParticle.SNOWBALL,
              (double) blockposition2.getX() + world.random.nextDouble(),
              (double) blockposition2.getY() + world.random.nextDouble() * 3.9D,
              (double) blockposition2.getZ() + world.random.nextDouble(),
              0.0D,
              0.0D,
              0.0D,
              new int[0]);
        }

        for (j = 0; j < this.getDetectorIronGolem().c(); ++j) {
          for (int l = 0; l < this.getDetectorIronGolem().b(); ++l) {
            ShapeDetectorBlock shapedetectorblock2 =
                shapedetector_shapedetectorcollection.a(j, l, 0);

            world.update(shapedetectorblock2.getPosition(), Blocks.AIR);
          }
        }
      } // CraftBukkit end
    }
  }
  public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
    World world = isourceblock.i();
    IPosition iposition = BlockDispenser.a(isourceblock);
    EnumDirection enumdirection = BlockDispenser.b(isourceblock.f());
    IProjectile iprojectile = this.a(world, iposition);

    // iprojectile.shoot((double) enumdirection.getAdjacentX(), (double) ((float)
    // enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ(), this.b(),
    // this.a());
    // CraftBukkit start
    ItemStack itemstack1 = itemstack.a(1);
    org.bukkit.block.Block block =
        world
            .getWorld()
            .getBlockAt(
                isourceblock.getBlockPosition().getX(),
                isourceblock.getBlockPosition().getY(),
                isourceblock.getBlockPosition().getZ());
    CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);

    BlockDispenseEvent event =
        new BlockDispenseEvent(
            block,
            craftItem.clone(),
            new org.bukkit.util.Vector(
                (double) enumdirection.getAdjacentX(),
                (double) ((float) enumdirection.getAdjacentY() + 0.1F),
                (double) enumdirection.getAdjacentZ()));
    if (!BlockDispenser.eventFired) {
      world.getServer().getPluginManager().callEvent(event);
    }

    if (event.isCancelled()) {
      itemstack.count++;
      return itemstack;
    }

    if (!event.getItem().equals(craftItem)) {
      itemstack.count++;
      // Chain to handler for new item
      ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
      IDispenseBehavior idispensebehavior =
          (IDispenseBehavior) BlockDispenser.N.get(eventStack.getItem());
      if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
        idispensebehavior.a(isourceblock, eventStack);
        return itemstack;
      }
    }

    iprojectile.shoot(
        event.getVelocity().getX(),
        event.getVelocity().getY(),
        event.getVelocity().getZ(),
        this.b(),
        this.a());
    ((Entity) iprojectile).projectileSource =
        new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource(
            (TileEntityDispenser) isourceblock.getTileEntity());
    // CraftBukkit end
    world.addEntity((Entity) iprojectile);
    // itemstack.a(1); // CraftBukkit - Handled during event processing
    return itemstack;
  }
  public UseResult interactWith(
      ItemStack var1,
      EntityHuman var2,
      World var3,
      BlockPosition var4,
      EnumUsedHand var5,
      EnumDirection var6,
      float var7,
      float var8,
      float var9) {
    if (var6 == EnumDirection.DOWN) {
      return UseResult.CANT_USE;
    } else {
      boolean var10 = var3.getType(var4).getBlock().isReplaceable(var3, var4);
      BlockPosition var11 = var10 ? var4 : var4.shift(var6);
      if (!var2.a(var11, var6, var1)) {
        return UseResult.CANT_USE;
      } else {
        BlockPosition var12 = var11.up();
        boolean var13 =
            !var3.isEmpty(var11) && !var3.getType(var11).getBlock().isReplaceable(var3, var11);
        var13 |= !var3.isEmpty(var12) && !var3.getType(var12).getBlock().isReplaceable(var3, var12);
        if (var13) {
          return UseResult.CANT_USE;
        } else {
          double var14 = (double) var11.getX();
          double var16 = (double) var11.getY();
          double var18 = (double) var11.getZ();
          List var20 =
              var3.getEntities(
                  (Entity) null,
                  (AxisAlignedBB)
                      AxisAlignedBB.a(
                          var14, var16, var18, var14 + 1.0D, var16 + 2.0D, var18 + 1.0D));
          if (!var20.isEmpty()) {
            return UseResult.CANT_USE;
          } else {
            if (!var3.isClientSide) {
              var3.setAir(var11);
              var3.setAir(var12);
              EntityArmorStand var21 =
                  new EntityArmorStand(var3, var14 + 0.5D, var16, var18 + 0.5D);
              float var22 =
                  (float)
                          MathHelper.floor(
                              (MathHelper.clampAngle(var2.yaw - 180.0F) + 22.5F) / 45.0F)
                      * 45.0F;
              var21.setPositionRotation(var14 + 0.5D, var16, var18 + 0.5D, var22, 0.0F);
              this.a(var21, var3.random);
              NBTTagCompound var23 = var1.getTag();
              if (var23 != null && var23.hasOfType("EntityTag", 10)) {
                NBTTagCompound var24 = new NBTTagCompound();
                var21.d(var24);
                var24.copyFrom(var23.getCompound("EntityTag"));
                var21.f(var24);
              }

              var3.addEntity((Entity) var21);
            }

            --var1.count;
            return UseResult.SUCCESS;
          }
        }
      }
    }
  }
Esempio n. 22
0
  public void a(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) {
    if (world.captureBlockStates) return; // CraftBukkit
    if (tileentityskull.getSkullType() == 1
        && blockposition.getY() >= 2
        && world.getDifficulty() != EnumDifficulty.PEACEFUL
        && !world.isStatic) {
      ShapeDetector shapedetector = this.l();
      ShapeDetectorCollection shapedetectorcollection = shapedetector.a(world, blockposition);

      if (shapedetectorcollection != null) {
        // CraftBukkit start - Use BlockStateListPopulator
        BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld());
        int i;

        for (i = 0; i < 3; ++i) {
          ShapeDetectorBlock shapedetectorblock = shapedetectorcollection.a(i, 0, 0);

          // CraftBukkit start
          // world.setTypeAndData(shapedetectorblock.d(),
          // shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true)), 2);
          BlockPosition pos = shapedetectorblock.d();
          IBlockData data = shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true));
          blockList.setTypeAndData(
              pos.getX(),
              pos.getY(),
              pos.getZ(),
              data.getBlock(),
              data.getBlock().toLegacyData(data),
              2);
          // CraftBukkit end
        }

        for (i = 0; i < shapedetector.c(); ++i) {
          for (int j = 0; j < shapedetector.b(); ++j) {
            ShapeDetectorBlock shapedetectorblock1 = shapedetectorcollection.a(i, j, 0);

            // CraftBukkit start
            // world.setTypeAndData(shapedetectorblock1.d(), Blocks.AIR.getBlockData(), 2);
            BlockPosition pos = shapedetectorblock1.d();
            blockList.setTypeAndData(pos.getX(), pos.getY(), pos.getZ(), Blocks.AIR, 0, 2);
            // CraftBukkit end
          }
        }

        BlockPosition blockposition1 = shapedetectorcollection.a(1, 0, 0).d();
        EntityWither entitywither = new EntityWither(world);
        BlockPosition blockposition2 = shapedetectorcollection.a(1, 2, 0).d();

        entitywither.setPositionRotation(
            (double) blockposition2.getX() + 0.5D,
            (double) blockposition2.getY() + 0.55D,
            (double) blockposition2.getZ() + 0.5D,
            shapedetectorcollection.b().k() == EnumAxis.X ? 0.0F : 90.0F,
            0.0F);
        entitywither.aG = shapedetectorcollection.b().k() == EnumAxis.X ? 0.0F : 90.0F;
        entitywither.n();
        Iterator iterator =
            world
                .a(EntityHuman.class, entitywither.getBoundingBox().grow(50.0D, 50.0D, 50.0D))
                .iterator();

        // CraftBukkit start
        if (world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) {
          while (iterator.hasNext()) {
            EntityHuman entityhuman = (EntityHuman) iterator.next();

            entityhuman.b((Statistic) AchievementList.I);
          }

          blockList.updateList();

          int k;

          for (k = 0; k < 120; ++k) {
            world.addParticle(
                EnumParticle.SNOWBALL,
                (double) blockposition1.getX() + world.random.nextDouble(),
                (double) (blockposition1.getY() - 2) + world.random.nextDouble() * 3.9D,
                (double) blockposition1.getZ() + world.random.nextDouble(),
                0.0D,
                0.0D,
                0.0D,
                new int[0]);
          }

          for (k = 0; k < shapedetector.c(); ++k) {
            for (int l = 0; l < shapedetector.b(); ++l) {
              ShapeDetectorBlock shapedetectorblock2 = shapedetectorcollection.a(k, l, 0);

              world.update(shapedetectorblock2.d(), Blocks.AIR);
            }
          }
        }
        // CraftBukkit end
      }
    }
  }