本文整理汇总了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;
}
}
示例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;
}
}
}
示例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))
);
}
}
}
示例4: of
import org.spongepowered.api.entity.projectile.Egg; //导入依赖的package包/类
public static PoreEgg of(Egg handle) {
return WrapperConverter.of(PoreEgg.class, handle);
}
示例5: PoreEgg
import org.spongepowered.api.entity.projectile.Egg; //导入依赖的package包/类
protected PoreEgg(Egg handle) {
super(handle);
}
示例6: getHandle
import org.spongepowered.api.entity.projectile.Egg; //导入依赖的package包/类
@Override
public Egg getHandle() {
return (Egg) super.getHandle();
}