Search in sources :

Example 11 with ItemDropper

use of com.skelril.nitro.item.ItemDropper in project Skree by Skelril.

the class ArrowFishingHandler method onProjectileTickEvent.

@Listener
public void onProjectileTickEvent(ProjectileTickEvent event) {
    Projectile projectile = event.getTargetEntity();
    if (!(projectile instanceof Arrow) || Probability.getChance(3)) {
        return;
    }
    Location<World> loc = projectile.getLocation();
    if (MultiTypeRegistry.isWater(loc.getBlockType()) && checkVelocity(projectile.getVelocity())) {
        ProjectileSource source = projectile.getShooter();
        double modifier = 1;
        if (source instanceof Living) {
            modifier = 50;
        }
        Optional<ModifierService> optService = Sponge.getServiceManager().provide(ModifierService.class);
        int rolls = 1;
        if (optService.isPresent() && optService.get().isActive(UBER_ARROW_FISHING)) {
            if (source instanceof Living) {
                rolls = 15;
            } else {
                rolls = 5;
            }
        }
        new ItemDropper(loc).dropStacks(dropTable.getDrops(rolls, modifier), SpawnTypes.DROPPED_ITEM);
    }
}
Also used : Arrow(org.spongepowered.api.entity.projectile.arrow.Arrow) ItemDropper(com.skelril.nitro.item.ItemDropper) Living(org.spongepowered.api.entity.living.Living) ProjectileSource(org.spongepowered.api.entity.projectile.source.ProjectileSource) ModifierService(com.skelril.skree.service.ModifierService) World(org.spongepowered.api.world.World) Projectile(org.spongepowered.api.entity.projectile.Projectile) Listener(org.spongepowered.api.event.Listener)

Example 12 with ItemDropper

use of com.skelril.nitro.item.ItemDropper in project Skree by Skelril.

the class BrokenGlass method dropBrokenGlass.

private void dropBrokenGlass(Transaction<BlockSnapshot> block, int variant) {
    Optional<Location<World>> optOrigin = block.getOriginal().getLocation();
    if (!optOrigin.isPresent()) {
        return;
    }
    new ItemDropper(optOrigin.get()).dropStacks(Collections.singleton(tf(new ItemStack(this, 1, variant))), SpawnTypes.DROPPED_ITEM);
}
Also used : ItemDropper(com.skelril.nitro.item.ItemDropper) ItemStack(net.minecraft.item.ItemStack) Location(org.spongepowered.api.world.Location)

Example 13 with ItemDropper

use of com.skelril.nitro.item.ItemDropper in project Skree by Skelril.

the class BuildWorldWrapper method onEntitySpawn.

@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 Horse && entity.get(Keys.HORSE_VARIANT).get().equals(HorseVariants.SKELETON_HORSE))) {
            event.setCancelled(true);
            return;
        }
    }
}
Also used : Entity(org.spongepowered.api.entity.Entity) Egg(org.spongepowered.api.entity.projectile.Egg) ItemDropper(com.skelril.nitro.item.ItemDropper) Lightning(org.spongepowered.api.entity.weather.Lightning) Monster(org.spongepowered.api.entity.living.monster.Monster) Horse(org.spongepowered.api.entity.living.animal.Horse) BlockSpawnCause(org.spongepowered.api.event.cause.entity.spawn.BlockSpawnCause) Listener(org.spongepowered.api.event.Listener)

Example 14 with ItemDropper

use of com.skelril.nitro.item.ItemDropper in project Skree by Skelril.

the class JungleRaidEffectProcessor method distributor.

private static void distributor(JungleRaidInstance inst) {
    FlagEffectData data = inst.getFlagData();
    boolean isSuddenDeath = inst.isSuddenDeath();
    if (isSuddenDeath) {
        data.amt = 100;
    }
    if (inst.isFlagEnabled(JungleRaidFlag.END_OF_DAYS) || inst.isFlagEnabled(JungleRaidFlag.GRENADES) || inst.isFlagEnabled(JungleRaidFlag.POTION_PLUMMET) || isSuddenDeath) {
        Vector3i bvMax = inst.getRegion().getMaximumPoint();
        Vector3i bvMin = inst.getRegion().getMinimumPoint();
        for (int i = 0; i < Probability.getRangedRandom(data.amt / 3, data.amt); i++) {
            Location<World> testLoc = new Location<>(inst.getRegion().getExtent(), Probability.getRangedRandom(bvMin.getX(), bvMax.getX()), bvMax.getY(), Probability.getRangedRandom(bvMin.getZ(), bvMax.getZ()));
            if (testLoc.getBlockType() != BlockTypes.AIR)
                continue;
            if (inst.isFlagEnabled(JungleRaidFlag.END_OF_DAYS) || isSuddenDeath) {
                PrimedTNT explosive = (PrimedTNT) inst.getRegion().getExtent().createEntity(EntityTypes.PRIMED_TNT, testLoc.getPosition());
                explosive.setVelocity(new Vector3d(random.nextDouble() * 2.0 - 1, random.nextDouble() * 2 * -1, random.nextDouble() * 2.0 - 1));
                explosive.offer(Keys.FUSE_DURATION, 20 * 4);
                // TODO used to have a 1/4 chance of creating fire
                inst.getRegion().getExtent().spawnEntity(explosive, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
            }
            if (inst.isFlagEnabled(JungleRaidFlag.POTION_PLUMMET)) {
                PotionEffectType type = Probability.pickOneOf(Sponge.getRegistry().getAllOf(PotionEffectType.class));
                for (int ii = Probability.getRandom(5); ii > 0; --ii) {
                    ThrownPotion potion = (ThrownPotion) inst.getRegion().getExtent().createEntity(EntityTypes.SPLASH_POTION, testLoc.getPosition());
                    potion.setVelocity(new Vector3d(random.nextDouble() * 2.0 - 1, 0, random.nextDouble() * 2.0 - 1));
                    potion.offer(Keys.POTION_EFFECTS, Lists.newArrayList(PotionEffect.of(type, 1, type.isInstant() ? 1 : 20 * 10)));
                    inst.getRegion().getExtent().spawnEntity(potion, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
                }
            }
            if (inst.isFlagEnabled(JungleRaidFlag.GRENADES)) {
                new ItemDropper(testLoc).dropStacks(Lists.newArrayList(newItemStack(ItemTypes.SNOWBALL, Probability.getRandom(3))), SpawnTypes.PLUGIN);
            }
        }
        if (data.amt < 150 && Probability.getChance(inst.isFlagEnabled(JungleRaidFlag.SUPER) ? 9 : 25))
            ++data.amt;
    }
}
Also used : PrimedTNT(org.spongepowered.api.entity.explosive.PrimedTNT) ItemDropper(com.skelril.nitro.item.ItemDropper) Vector3d(com.flowpowered.math.vector.Vector3d) PotionEffectType(org.spongepowered.api.effect.potion.PotionEffectType) Vector3i(com.flowpowered.math.vector.Vector3i) ThrownPotion(org.spongepowered.api.entity.projectile.ThrownPotion) World(org.spongepowered.api.world.World) Location(org.spongepowered.api.world.Location)

Aggregations

ItemDropper (com.skelril.nitro.item.ItemDropper)14 ItemStack (org.spongepowered.api.item.inventory.ItemStack)9 ItemStackFactory.newItemStack (com.skelril.nitro.item.ItemStackFactory.newItemStack)5 Listener (org.spongepowered.api.event.Listener)4 Vector3d (com.flowpowered.math.vector.Vector3d)3 Player (org.spongepowered.api.entity.living.player.Player)3 Vector3i (com.flowpowered.math.vector.Vector3i)2 ModifierService (com.skelril.skree.service.ModifierService)2 ArrayList (java.util.ArrayList)2 ItemStack (net.minecraft.item.ItemStack)2 Entity (org.spongepowered.api.entity.Entity)2 Monster (org.spongepowered.api.entity.living.monster.Monster)2 EntityDamageSource (org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource)2 IndirectEntityDamageSource (org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource)2 Inventory (org.spongepowered.api.item.inventory.Inventory)2 Location (org.spongepowered.api.world.Location)2 World (org.spongepowered.api.world.World)2 EditSession (com.sk89q.worldedit.EditSession)1 MaxChangedBlocksException (com.sk89q.worldedit.MaxChangedBlocksException)1 Vector (com.sk89q.worldedit.Vector)1