use of org.spongepowered.api.entity.projectile.Snowball in project Skree by Skelril.
the class PatientXInstance method freezeBlocks.
public void freezeBlocks(int percentage, boolean throwExplosives) {
ice.forAll((pt) -> {
BlockType aboveType = getRegion().getExtent().getBlockType(pt.add(0, 1, 0));
BlockType belowType = getRegion().getExtent().getBlockType(pt.add(0, -1, 0));
if (aboveType == BlockTypes.AIR && belowType == BlockTypes.WATER || belowType == BlockTypes.FLOWING_WATER) {
if (percentage >= 100) {
getRegion().getExtent().setBlockType(pt, BlockTypes.ICE, Cause.source(SkreePlugin.container()).build());
return;
}
BlockType curType = getRegion().getExtent().getBlockType(pt);
if (curType == BlockTypes.PACKED_ICE || curType == BlockTypes.ICE) {
getRegion().getExtent().setBlockType(pt, BlockTypes.WATER, Cause.source(SkreePlugin.container()).build());
if (!Probability.getChance(config.snowBallChance) || !throwExplosives)
return;
Location target = new Location<>(getRegion().getExtent(), pt.add(0, 1, 0));
for (int i = Probability.getRandom(3); i > 0; i--) {
Snowball melvin = (Snowball) getRegion().getExtent().createEntity(EntityTypes.SNOWBALL, target.getPosition());
melvin.setVelocity(new Vector3d(0, Probability.getRangedRandom(.25, 1), 0));
getRegion().getExtent().spawnEntity(melvin, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
} else if (Probability.getChance(percentage, 100)) {
getRegion().getExtent().setBlockType(pt, BlockTypes.PACKED_ICE, Cause.source(SkreePlugin.container()).build());
}
}
});
}
use of org.spongepowered.api.entity.projectile.Snowball in project Skree by Skelril.
the class MainWorldWrapper method createFor.
private PlayerCombatParser createFor(Cancellable event) {
return new PlayerCombatParser() {
@Override
public void processPvP(Player attacker, Player defender, @Nullable Entity indirectSource) {
Optional<PvPService> optService = Sponge.getServiceManager().provide(PvPService.class);
if (optService.isPresent()) {
PvPService service = optService.get();
if (service.getPvPState(attacker).allowByDefault() && service.getPvPState(defender).allowByDefault()) {
return;
}
}
if (!(indirectSource instanceof Snowball) || !lobby.contains(attacker)) {
attacker.sendMessage(Text.of(TextColors.RED, "PvP is opt-in only in the main world!"));
event.setCancelled(true);
}
}
@Override
public void processNonLivingAttack(DamageSource attacker, Player defender) {
if (attacker.getType() == DamageTypes.VOID) {
defender.setLocation(defender.getWorld().getSpawnLocation());
defender.offer(Keys.FALL_DISTANCE, 0F);
event.setCancelled(true);
}
}
};
}
use of org.spongepowered.api.entity.projectile.Snowball in project Skree by Skelril.
the class JungleRaidEffectListener method onProjectileHit.
@Listener
public void onProjectileHit(CollideEvent.Impact event, @First Entity entity) {
Optional<JungleRaidInstance> optInst = manager.getApplicableZone(entity);
if (!optInst.isPresent())
return;
JungleRaidInstance inst = optInst.get();
if (inst.getState() != JungleRaidState.IN_PROGRESS) {
return;
}
int explosionSize = 2;
if (entity.getType() == EntityTypes.TIPPED_ARROW) {
if (inst.isFlagEnabled(JungleRaidFlag.TORMENT_ARROWS)) {
ProjectileSource shooter = ((Arrow) entity).getShooter();
CuboidContainmentPredicate predicate = new CuboidContainmentPredicate(entity.getLocation().getPosition(), 16, 16, 16);
for (Entity e : entity.getNearbyEntities(en -> predicate.test(en.getLocation().getPosition()))) {
if (e.equals(shooter))
continue;
if (e instanceof Living && shooter instanceof Living) {
e.damage(1, IndirectEntityDamageSource.builder().type(DamageTypes.PROJECTILE).entity(entity).proxySource((Living) shooter).build());
if (Probability.getChance(5)) {
EntityHealthUtil.heal((Living) shooter, 1);
}
}
}
}
if (inst.isFlagEnabled(JungleRaidFlag.EXPLOSIVE_ARROWS)) {
if (inst.isFlagEnabled(JungleRaidFlag.SUPER))
explosionSize = 4;
} else
return;
}
if (entity instanceof Snowball) {
if (inst.isFlagEnabled(JungleRaidFlag.GRENADES)) {
if (inst.isFlagEnabled(JungleRaidFlag.SUPER))
explosionSize = 10;
else
explosionSize = 6;
} else
return;
}
if (entity instanceof ThrownPotion) {
return;
}
entity.getLocation().getExtent().triggerExplosion(Explosion.builder().radius(explosionSize).location(entity.getLocation()).shouldDamageEntities(true).shouldBreakBlocks(true).build(), Cause.source(SkreePlugin.container()).build());
}
Aggregations