当前位置: 首页>>代码示例>>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;未经允许,请勿转载。