Exemple #1
0
  @Override
  public boolean spawnMinecraftEntity(MyPetMinecraftEntity entity, org.bukkit.World bukkitWorld) {
    if (entity != null) {
      World world = ((CraftWorld) bukkitWorld).getHandle();
      return world.addEntity(((EntityMyPet) entity), CreatureSpawnEvent.SpawnReason.CUSTOM);
    }

    return false;
  }
Exemple #2
0
  public static Cow 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 = ((CraftWorld) location.getWorld()).getHandle();
    final CowNPC customEntity = new CowNPC(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 (CraftCow) customEntity.getBukkitEntity();
  }
Exemple #3
0
 public Boolean canSpawn(Location loc, AxisAlignedBB bb) {
   net.minecraft.server.v1_9_R1.World mcWorld = ((CraftWorld) loc.getWorld()).getHandle();
   return getBlockBBsInBB(loc.getWorld(), bb).isEmpty() && !mcWorld.containsLiquid(bb);
 }
Exemple #4
0
  @Override
  protected void bC() {

    ++this.deathTicks;
    if (this.deathTicks == 20) {
      int i;

      if (!this.world.isClientSide
          && (this.lastDamageByPlayerTime > 0 || this.alwaysGivesExp())
          && this.bd()
          && this.world.getGameRules().getBoolean("doMobLoot")) {
        i = this.getExpValue(this.killer);

        while (i > 0) {
          int j = EntityExperienceOrb.getOrbValue(i);

          i -= j;
          // this.world.addEntity(new EntityExperienceOrb(this.world,
          // this.locX, this.locY, this.locZ, j));
        }

        World world = this.getWorld();
        org.bukkit.World BukkitWorld = world.getWorld();

        if (this.killer instanceof EntityPlayer) {

          Player player = (Player) this.killer.getBukkitEntity();
          int playerLevel = player.getLevel();

          Location loc = new Location(BukkitWorld, this.locX, this.locY, this.locZ);

          for (int orbQuantity = CustomEntityExperienceOrb.getOrbQuantity(playerLevel, MobLevel);
              orbQuantity > 0;
              orbQuantity--) {
            Bukkit.getServer()
                .broadcastMessage("[BETA] Zombie xp orb (" + orbQuantity + ") distribution");

            Entity orb = new CustomEntityExperienceOrb(this.world, this.MobLevel, playerLevel);
            AdditionalMobSpawner.spawnEntity(orb, CustomEntityExperienceOrb.orbLoc(loc, 2));
          }
        }
      }

      this.die();

      for (i = 0; i < 20; i++) {
        double d0 = this.random.nextGaussian() * 0.02D;
        double d1 = this.random.nextGaussian() * 0.02D;
        double d2 = this.random.nextGaussian() * 0.02D;

        this.world.addParticle(
            EnumParticle.EXPLOSION_NORMAL,
            this.locX + this.random.nextFloat() * this.width * 2.0F - this.width,
            this.locY + this.random.nextFloat() * this.length,
            this.locZ + this.random.nextFloat() * this.width * 2.0F - this.width,
            d0,
            d1,
            d2,
            new int[0]);
      }
    }
  }