本文整理汇总了Java中org.spongepowered.api.event.cause.entity.spawn.SpawnCause类的典型用法代码示例。如果您正苦于以下问题:Java SpawnCause类的具体用法?Java SpawnCause怎么用?Java SpawnCause使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpawnCause类属于org.spongepowered.api.event.cause.entity.spawn包,在下文中一共展示了SpawnCause类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: spawnMinions
import org.spongepowered.api.event.cause.entity.spawn.SpawnCause; //导入依赖的package包/类
public void spawnMinions(@Nullable Living target) {
int spawnCount = Math.max(3, getPlayers(PARTICIPANT).size());
for (Location<World> spawnPt : spawnPts) {
if (Probability.getChance(11)) {
for (int i = spawnCount; i > 0; --i) {
Zombie zombie = (Zombie) getRegion().getExtent().createEntity(EntityTypes.ZOMBIE, spawnPt.getPosition());
// TODO convert to Sponge Data API
((EntityZombie) zombie).setChild(true);
EntityHealthUtil.setMaxHealth(zombie, 1);
getRegion().getExtent().spawnEntity(zombie, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
if (target != null) {
zombie.setTarget(target);
}
}
}
}
}
示例2: apply
import org.spongepowered.api.event.cause.entity.spawn.SpawnCause; //导入依赖的package包/类
@Override
public Optional<Instruction<DamageCondition, Boss<Zombie, CatacombsBossDetail>>> apply(
DamageCondition damageCondition, Boss<Zombie, CatacombsBossDetail> zombieCatacombsBossDetailBoss
) {
Living bossEnt = zombieCatacombsBossDetailBoss.getTargetEntity().get();
Entity toHit = damageCondition.getAttacked();
toHit.setVelocity(EntityDirectionUtil.getFacingVector(bossEnt).mul(2));
Task.builder().execute(() -> {
Location<World> targetLoc = toHit.getLocation();
Task.builder().execute(() -> {
Lightning lightning = (Lightning) toHit.getWorld().createEntity(EntityTypes.LIGHTNING, targetLoc.getPosition());
toHit.getWorld().spawnEntity(lightning, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}).delay(750, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst());
}).delay(1500, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst());
return Optional.empty();
}
示例3: spawnBoss
import org.spongepowered.api.event.cause.entity.spawn.SpawnCause; //导入依赖的package包/类
public void spawnBoss(FreakyFourBoss boss, long delay) {
loadingBoss = true;
Task.builder().execute(() -> {
Entity entity = getRegion().getExtent().createEntity(boss.getEntityType(), getCenter(boss));
getRegion().getExtent().spawnEntity(entity, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
Boss<Living, ZoneBossDetail<FreakyFourInstance>> aBoss = new Boss<>(
(Living) entity,
new ZoneBossDetail<>(this)
);
bossManagers.get(boss).bind(aBoss);
bosses.put(boss, aBoss);
loadingBoss = false;
}).delayTicks(delay).submit(SkreePlugin.inst());
}
示例4: throwSlashPotion
import org.spongepowered.api.event.cause.entity.spawn.SpawnCause; //导入依赖的package包/类
private void throwSlashPotion(Location<World> location) {
PotionEffectType[] thrownTypes = new PotionEffectType[] {
PotionEffectTypes.INSTANT_DAMAGE, PotionEffectTypes.INSTANT_DAMAGE,
PotionEffectTypes.POISON, PotionEffectTypes.WEAKNESS
};
Entity entity = location.getExtent().createEntity(EntityTypes.SPLASH_POTION, location.getPosition());
entity.setVelocity(new Vector3d(
random.nextDouble() * .5 - .25,
random.nextDouble() * .4 + .1,
random.nextDouble() * .5 - .25
));
PotionEffectType type = Probability.pickOneOf(thrownTypes);
PotionEffect effect = PotionEffect.of(type, 2, type.isInstant() ? 1 : 15 * 20);
entity.offer(Keys.POTION_EFFECTS, Lists.newArrayList(effect));
getRegion().getExtent().spawnEntity(entity, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
示例5: throwSlashPotion
import org.spongepowered.api.event.cause.entity.spawn.SpawnCause; //导入依赖的package包/类
private void throwSlashPotion(Location<World> location) {
PotionEffectType[] thrownTypes = new PotionEffectType[] {
PotionEffectTypes.INSTANT_DAMAGE, PotionEffectTypes.INSTANT_DAMAGE,
PotionEffectTypes.POISON, PotionEffectTypes.WEAKNESS
};
Entity entity = location.getExtent().createEntity(EntityTypes.SPLASH_POTION, location.getPosition());
entity.setVelocity(new Vector3d(
random.nextDouble() * .5 - .25,
random.nextDouble() * .4 + .1,
random.nextDouble() * .5 - .25
));
PotionEffectType type = Probability.pickOneOf(thrownTypes);
PotionEffect effect = PotionEffect.of(type, 2, type.isInstant() ? 1 : 15 * 20);
entity.offer(Keys.POTION_EFFECTS, Lists.newArrayList(effect));
location.getExtent().spawnEntity(entity, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
示例6: spawnEntity
import org.spongepowered.api.event.cause.entity.spawn.SpawnCause; //导入依赖的package包/类
public void spawnEntity(Location<World> location, Vector3d velocity, CommandSource src)
{
velocity = velocity.mul(5);
Extent extent = location.getExtent();
Entity kitten = extent.createEntity(EntityTypes.OCELOT, location.getPosition());
kitten.offer(Keys.VELOCITY, velocity);
extent.spawnEntity(kitten, Cause.of(NamedCause.source(SpawnCause.builder().type(SpawnTypes.CUSTOM).build())));
}
示例7: spawnEntity
import org.spongepowered.api.event.cause.entity.spawn.SpawnCause; //导入依赖的package包/类
public void spawnEntity(Location<World> location, Player player, EntityType type, int amount)
{
for (int i = 1; i <= amount; i++)
{
Entity entity = location.getExtent().createEntity(type, location.getPosition());
location.getExtent().spawnEntity(entity, Cause.of(NamedCause.source(SpawnCause.builder().type(SpawnTypes.CUSTOM).build())));
}
}
示例8: spawnEntity
import org.spongepowered.api.event.cause.entity.spawn.SpawnCause; //导入依赖的package包/类
public void spawnEntity(Location<World> location, Vector3d velocity, CommandSource src)
{
Extent extent = location.getExtent();
Entity fireball = extent.createEntity(EntityTypes.FIREBALL, location.getPosition());
fireball.offer(Keys.VELOCITY, velocity);
extent.spawnEntity(fireball, Cause.of(NamedCause.source(SpawnCause.builder().type(SpawnTypes.CUSTOM).build())));
}
示例9: setupStormBringer
import org.spongepowered.api.event.cause.entity.spawn.SpawnCause; //导入依赖的package包/类
private void setupStormBringer() {
Sponge.getEventManager().registerListeners(
SkreePlugin.inst(),
new BossListener<>(bossManager, Skeleton.class)
);
List<Instruction<BindCondition, Boss<Skeleton, WildernessBossDetail>>> bindProcessor = bossManager.getBindProcessor();
bindProcessor.add((condition, boss) -> {
Optional<Skeleton> optBossEnt = boss.getTargetEntity();
if (optBossEnt.isPresent()) {
Skeleton bossEnt = optBossEnt.get();
bossEnt.offer(Keys.DISPLAY_NAME, Text.of("Storm Bringer"));
bossEnt.offer(Keys.CUSTOM_NAME_VISIBLE, true);
double bossHealth = 20 * 30 * boss.getDetail().getLevel();
setMaxHealth(bossEnt, bossHealth, true);
}
return Optional.empty();
});
List<Instruction<DamageCondition, Boss<Skeleton, WildernessBossDetail>>> damageProcessor = bossManager.getDamageProcessor();
damageProcessor.add((condition, boss) -> {
Entity eToHit = condition.getAttacked();
if (!(eToHit instanceof Living)) {
return Optional.empty();
}
Living toHit = (Living) eToHit;
Location<World> targetLocation = toHit.getLocation();
for (int i = boss.getDetail().getLevel() * Probability.getRangedRandom(1, 10); i >= 0; --i) {
Task.builder().execute(() -> {
Entity lightning = targetLocation.getExtent().createEntity(EntityTypes.LIGHTNING, targetLocation.getPosition());
targetLocation.getExtent().spawnEntity(
lightning, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build()
);
}).delayTicks(5 * (6 + i)).submit(SkreePlugin.inst());
}
return Optional.empty();
});
}
示例10: makeExplosiveTomb
import org.spongepowered.api.event.cause.entity.spawn.SpawnCause; //导入依赖的package包/类
private void makeExplosiveTomb(Location<World> targetLocation, Boss<Skeleton, WildernessBossDetail> boss) {
makeSphere(targetLocation, 3, 3, 3);
for (int i = 0; i < boss.getDetail().getLevel(); ++i) {
Entity explosive = targetLocation.getExtent().createEntity(EntityTypes.PRIMED_TNT, targetLocation.getPosition());
explosive.offer(Keys.FUSE_DURATION, 20 * 4);
targetLocation.getExtent().spawnEntity(
explosive, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build()
);
}
}
示例11: summon
import org.spongepowered.api.event.cause.entity.spawn.SpawnCause; //导入依赖的package包/类
public boolean summon(String wandererType, int level, Location<World> location) {
WanderingBoss<? extends Entity> wanderer = wanderers.get(wandererType);
if (wanderer == null) {
return false;
}
Entity entity = wanderer.createEntity(location);
boolean spawned = location.getExtent().spawnEntity(entity, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
if (!spawned) {
return false;
}
return wanderer.apply(entity, new WildernessBossDetail(level));
}
示例12: onEntitySpawn
import org.spongepowered.api.event.cause.entity.spawn.SpawnCause; //导入依赖的package包/类
@Listener
public void onEntitySpawn(SpawnEntityEvent event, @First SpawnCause spawnCause) {
for (Entity entity : event.getEntities()) {
if (isApplicable(entity)) {
SpawnType spawnType = spawnCause.getType();
if (spawnType != SpawnTypes.PLUGIN && !isLegalSpawn(entity)) {
event.setCancelled(true);
}
break;
}
}
}
示例13: spawnBoss
import org.spongepowered.api.event.cause.entity.spawn.SpawnCause; //导入依赖的package包/类
public void spawnBoss() {
Giant spawned = (Giant) getRegion().getExtent().createEntity(EntityTypes.GIANT, getRegion().getCenter());
getRegion().getExtent().spawnEntity(spawned, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
Boss<Giant, ZoneBossDetail<ShnugglesPrimeInstance>> boss = new Boss<>(spawned, new ZoneBossDetail<>(this));
bossManager.bind(boss);
this.boss = boss;
}
示例14: randomRockets
import org.spongepowered.api.event.cause.entity.spawn.SpawnCause; //导入依赖的package包/类
private static void randomRockets(JungleRaidInstance inst) {
if (inst.isFlagEnabled(JungleRaidFlag.RANDOM_ROCKETS)) {
for (final Player player : inst.getPlayers(PlayerClassifier.PARTICIPANT)) {
if (!Probability.getChance(30)) {
continue;
}
for (int i = 0; i < 5; i++) {
Task.builder().delayTicks(i * 4).execute(() -> {
Location targetLocation = player.getLocation();
Firework firework = (Firework) inst.getRegion().getExtent().createEntity(EntityTypes.FIREWORK, targetLocation.getPosition());
FireworkEffect fireworkEffect = FireworkEffect.builder()
.flicker(Probability.getChance(2))
.trail(Probability.getChance(2))
.color(Color.RED)
.fade(Color.YELLOW)
.shape(FireworkShapes.BURST)
.build();
firework.offer(Keys.FIREWORK_EFFECTS, Lists.newArrayList(fireworkEffect));
firework.offer(Keys.FIREWORK_FLIGHT_MODIFIER, Probability.getRangedRandom(2, 5));
inst.getRegion().getExtent().spawnEntity(
firework, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build()
);
}).submit(SkreePlugin.inst());
}
}
}
}
示例15: spawnChickens
import org.spongepowered.api.event.cause.entity.spawn.SpawnCause; //导入依赖的package包/类
private void spawnChickens() {
Vector3i bvMax = getRegion().getMaximumPoint();
Vector3i bvMin = getRegion().getMinimumPoint();
for (int i = 0; i < getPlayers(PARTICIPANT).size(); ++i) {
Location<World> testLoc = new Location<>(
getRegion().getExtent(),
Probability.getRangedRandom(bvMin.getX(), bvMax.getX()),
bvMax.getY() - 10,
Probability.getRangedRandom(bvMin.getZ(), bvMax.getZ())
);
Vector2d testPos = new Vector2d(testLoc.getX(), testLoc.getZ());
Vector2d originPos = new Vector2d(startingLocation.getX(), startingLocation.getZ());
if (testPos.distanceSquared(originPos) >= 70 * 70) {
--i;
continue;
}
Chicken chicken = (Chicken) testLoc.getExtent().createEntity(EntityTypes.CHICKEN, testLoc.getPosition());
chicken.offer(Keys.PERSISTS, false);
testLoc.getExtent().spawnEntity(
chicken,
Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build()
);
}
}