當前位置: 首頁>>代碼示例>>Java>>正文


Java Egg類代碼示例

本文整理匯總了Java中org.spongepowered.api.entity.projectile.Egg的典型用法代碼示例。如果您正苦於以下問題:Java Egg類的具體用法?Java Egg怎麽用?Java Egg使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Egg類屬於org.spongepowered.api.entity.projectile包,在下文中一共展示了Egg類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: valueOf

import org.spongepowered.api.entity.projectile.Egg; //導入依賴的package包/類
static ProjectileType valueOf(Entity entity) {
    if (entity instanceof Arrow) {
        return ARROW;
    } else if (entity instanceof Snowball) {
        return SNOWBALL;
    } else if (entity instanceof Egg) {
        return EGG;
    } else if (entity instanceof LargeFireball) {
        return LARGE_FIREBALL;
    } else if (entity instanceof WitherSkull) {
        return WITHER_SKULL;
    } else if (entity instanceof SmallFireball) {
        return SMALL_FIREBALL;
    } else if (entity instanceof EnderPearl) {
        return ENDERPEARL;
    } else if (entity instanceof ThrownExpBottle) {
        return THROWN_EXP_BOTTLE;
    } else {
        return null;
    }
}
 
開發者ID:AfterKraft,項目名稱:KraftRPG-API,代碼行數:22,代碼來源:DamageManager.java

示例2: onEntitySpawn

import org.spongepowered.api.entity.projectile.Egg; //導入依賴的package包/類
@Listener
public void onEntitySpawn(SpawnEntityEvent event) {
  List<Entity> entities = event.getEntities();

  Optional<BlockSpawnCause> optBlockCause = event.getCause().first(BlockSpawnCause.class);
  for (Entity entity : entities) {
    if (!isApplicable(entity)) {
      continue;
    }

    if (entity instanceof Lightning) {
      ((Lightning) entity).setEffect(true);
      continue;
    }

    if (entity instanceof Egg && optBlockCause.isPresent()) {
      new ItemDropper(entity.getLocation()).dropStacks(
          Lists.newArrayList(newItemStack(ItemTypes.EGG)), SpawnTypes.DISPENSE
      );
      event.setCancelled(true);
      return;
    }

    if (entity instanceof Monster || (entity instanceof SkeletonHorse)) {
      event.setCancelled(true);
      return;
    }
  }
}
 
開發者ID:Skelril,項目名稱:Skree,代碼行數:30,代碼來源:BuildWorldWrapper.java

示例3: onEntitySpawn

import org.spongepowered.api.entity.projectile.Egg; //導入依賴的package包/類
@Listener
public void onEntitySpawn(SpawnEntityEvent event) {
  List<Entity> entities = event.getEntities();

  Optional<BlockSpawnCause> optBlockCause = event.getCause().first(BlockSpawnCause.class);
  for (Entity entity : entities) {
    Location<World> loc = entity.getLocation();
    Optional<Integer> optLevel = getLevel(loc);

    if (!optLevel.isPresent()) {
      continue;
    }
    int level = optLevel.get();

    if (entity instanceof Egg && optBlockCause.isPresent()) {
      PrimedTNT explosive = (PrimedTNT) entity.getLocation().getExtent().createEntity(
          EntityTypes.PRIMED_TNT,
          entity.getLocation().getPosition()
      );

      explosive.setVelocity(entity.getVelocity());
      explosive.offer(Keys.FUSE_DURATION, 20 * 4);

      // TODO used to have a 1/4 chance of creating fire
      entity.getLocation().getExtent().spawnEntity(
          explosive, Cause.source(SpawnCause.builder().type(SpawnTypes.DISPENSE).build()).build()
      );

      event.setCancelled(true);
      return;
    }

    if (level > 1) {
      // TODO move damage modification
      if (entity instanceof Monster) {
        HealthData healthData = ((Monster) entity).getHealthData();
        double curMax = healthData.maxHealth().get();

        if (curMax <= 80) { // TODO do this a better way, but for now it prevents super mobs

          double newMax = curMax * getHealthMod(level);

          healthData.set(Keys.MAX_HEALTH, newMax);
          healthData.set(Keys.HEALTH, newMax);

          entity.offer(healthData);
        }

        // Wandering Bosses
        Collection<String> wanderers = wanderingMobManager.getSupportedWanderersOfType(entity.getType());
        for (String wanderer : wanderers) {
          if (wanderingMobManager.chanceBind(wanderer, level, entity)) {
            break;
          }
        }
      }
    }

    Optional<Value<Integer>> optExplosiveRadius = Optional.empty();
    // Optional<Value<Integer>> optExplosiveRadius = event.getEntity().getValue(Keys.EXPLOSIVE_RADIUS);

    if (optExplosiveRadius.isPresent()) {
      Value<Integer> explosiveRadius = optExplosiveRadius.get();
      int min = explosiveRadius.get();

      entity.offer(
          Keys.EXPLOSION_RADIUS,
          Optional.of(MathExt.bound((min + level) / 2, min, entity instanceof Fireball ? 4 : 9))
      );
    }
  }
}
 
開發者ID:Skelril,項目名稱:Skree,代碼行數:73,代碼來源:WildernessWorldWrapper.java

示例4: of

import org.spongepowered.api.entity.projectile.Egg; //導入依賴的package包/類
public static PoreEgg of(Egg handle) {
    return WrapperConverter.of(PoreEgg.class, handle);
}
 
開發者ID:LapisBlue,項目名稱:Pore,代碼行數:4,代碼來源:PoreEgg.java

示例5: PoreEgg

import org.spongepowered.api.entity.projectile.Egg; //導入依賴的package包/類
protected PoreEgg(Egg handle) {
    super(handle);
}
 
開發者ID:LapisBlue,項目名稱:Pore,代碼行數:4,代碼來源:PoreEgg.java

示例6: getHandle

import org.spongepowered.api.entity.projectile.Egg; //導入依賴的package包/類
@Override
public Egg getHandle() {
    return (Egg) super.getHandle();
}
 
開發者ID:LapisBlue,項目名稱:Pore,代碼行數:5,代碼來源:PoreEgg.java


注:本文中的org.spongepowered.api.entity.projectile.Egg類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。