Search in sources :

Example 1 with SpawnCause

use of org.spongepowered.api.event.cause.entity.spawn.SpawnCause in project Skree by Skelril.

the class WildernessWorldWrapper method onItemDrop.

@Listener
public void onItemDrop(DropItemEvent.Destruct event, @Named(NamedCause.SOURCE) BlockSpawnCause spawnCause) {
    BlockSnapshot blockSnapshot = spawnCause.getBlockSnapshot();
    Optional<Location<World>> optLocation = blockSnapshot.getLocation();
    if (!optLocation.isPresent()) {
        return;
    }
    Location<World> loc = optLocation.get();
    if (!markedOrePoints.remove(loc)) {
        return;
    }
    Optional<Integer> optLevel = getLevel(loc);
    if (!optLevel.isPresent()) {
        return;
    }
    List<ItemStackSnapshot> itemStacks = new ArrayList<>();
    event.getEntities().forEach((entity -> {
        if (entity instanceof Item) {
            ItemStackSnapshot snapshot = ((Item) entity).item().get();
            itemStacks.add(getPoolItemDrop(snapshot));
        }
    }));
    addPool(loc, () -> itemStacks);
}
Also used : WorldService(com.skelril.skree.service.WorldService) StormBringer(com.skelril.skree.content.world.wilderness.wanderer.StormBringer) Value(org.spongepowered.api.data.value.mutable.Value) ChangeBlockEvent(org.spongepowered.api.event.block.ChangeBlockEvent) ModifierService(com.skelril.skree.service.ModifierService) ItemStack(org.spongepowered.api.item.inventory.ItemStack) SkreePlugin(com.skelril.skree.SkreePlugin) TextColor(org.spongepowered.api.text.format.TextColor) org.spongepowered.api.entity(org.spongepowered.api.entity) TypeCollections.ore(com.skelril.skree.content.registry.TypeCollections.ore) Living(org.spongepowered.api.entity.living.Living) ForgeTransformer.tf(com.skelril.nitro.transformer.ForgeTransformer.tf) ItemDropper(com.skelril.nitro.item.ItemDropper) Location(org.spongepowered.api.world.Location) ItemEnchantment(org.spongepowered.api.data.meta.ItemEnchantment) Extent(org.spongepowered.api.world.extent.Extent) BlockTypes(org.spongepowered.api.block.BlockTypes) CustomItemTypes(com.skelril.skree.content.registry.item.CustomItemTypes) BlockState(org.spongepowered.api.block.BlockState) HealthData(org.spongepowered.api.data.manipulator.mutable.entity.HealthData) Egg(org.spongepowered.api.entity.projectile.Egg) Cancellable(org.spongepowered.api.event.Cancellable) PlayerCombatParser(com.skelril.nitro.combat.PlayerCombatParser) World(org.spongepowered.api.world.World) HandTypes(org.spongepowered.api.data.type.HandTypes) NamedCause(org.spongepowered.api.event.cause.NamedCause) Player(org.spongepowered.api.entity.living.player.Player) RespawnPlayerEvent(org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent) EntityHealthPrinter(com.skelril.nitro.entity.EntityHealthPrinter) PrimedTNT(org.spongepowered.api.entity.explosive.PrimedTNT) java.util(java.util) DestructEntityEvent(org.spongepowered.api.event.entity.DestructEntityEvent) Vector3d(com.flowpowered.math.vector.Vector3d) GameModes(org.spongepowered.api.entity.living.player.gamemode.GameModes) Supplier(java.util.function.Supplier) GraveDigger(com.skelril.skree.content.world.wilderness.wanderer.GraveDigger) Lists(com.google.common.collect.Lists) MathExt(com.skelril.nitro.numeric.MathExt) Text(org.spongepowered.api.text.Text) DropTableEntryImpl(com.skelril.nitro.droptable.DropTableEntryImpl) TextColors(org.spongepowered.api.text.format.TextColors) DimensionTypes(org.spongepowered.api.world.DimensionTypes) Nullable(javax.annotation.Nullable) SpawnEntityEvent(org.spongepowered.api.event.entity.SpawnEntityEvent) Enchantments(org.spongepowered.api.item.Enchantments) DropTable(com.skelril.nitro.droptable.DropTable) SpawnTypes(org.spongepowered.api.event.cause.entity.spawn.SpawnTypes) Validate(org.apache.commons.lang3.Validate) MasterDropTable(com.skelril.nitro.droptable.MasterDropTable) ItemStackFactory.newItemStack(com.skelril.nitro.item.ItemStackFactory.newItemStack) QuantityBoundedItemStackConfig(com.skelril.nitro.registry.dynamic.QuantityBoundedItemStackConfig) CombinedText(com.skelril.nitro.text.CombinedText) Wither(org.spongepowered.api.entity.living.monster.Wither) SimpleDropResolver(com.skelril.nitro.droptable.resolver.SimpleDropResolver) SpawnCause(org.spongepowered.api.event.cause.entity.spawn.SpawnCause) ItemStackSnapshot(org.spongepowered.api.item.inventory.ItemStackSnapshot) DropItemEvent(org.spongepowered.api.event.item.inventory.DropItemEvent) EnchantmentUtil(com.skelril.nitro.data.util.EnchantmentUtil) TimedRunnable(com.skelril.nitro.time.TimedRunnable) ParticleEffect(org.spongepowered.api.effect.particle.ParticleEffect) Fangz(com.skelril.skree.content.world.wilderness.wanderer.Fangz) ParticleTypes(org.spongepowered.api.effect.particle.ParticleTypes) DamageEntityEvent(org.spongepowered.api.event.entity.DamageEntityEvent) Title(org.spongepowered.api.text.title.Title) CollideEntityEvent(org.spongepowered.api.event.entity.CollideEntityEvent) Transaction(org.spongepowered.api.data.Transaction) BlockSpawnCause(org.spongepowered.api.event.cause.entity.spawn.BlockSpawnCause) TextStyles(org.spongepowered.api.text.format.TextStyles) Sponge(org.spongepowered.api.Sponge) Tuple(org.spongepowered.api.util.Tuple) PvPService(com.skelril.skree.service.PvPService) Cause(org.spongepowered.api.event.cause.Cause) Explosion(org.spongepowered.api.world.explosion.Explosion) Named(org.spongepowered.api.event.filter.cause.Named) BlockType(org.spongepowered.api.block.BlockType) First(org.spongepowered.api.event.filter.cause.First) BlockSnapshot(org.spongepowered.api.block.BlockSnapshot) EntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource) Keys(org.spongepowered.api.data.key.Keys) MainWorldWrapper(com.skelril.skree.content.world.main.MainWorldWrapper) WanderingBoss(com.skelril.skree.content.world.wilderness.wanderer.WanderingBoss) WorldEffectWrapperImpl(com.skelril.skree.service.internal.world.WorldEffectWrapperImpl) GRAVE_STONE(com.skelril.skree.content.registry.block.CustomBlockTypes.GRAVE_STONE) CofferResolver(com.skelril.skree.content.droptable.CofferResolver) Function(java.util.function.Function) SlipperySingleHitDiceRoller(com.skelril.nitro.droptable.roller.SlipperySingleHitDiceRoller) Boss(org.spongepowered.api.entity.living.monster.Boss) IntegratedRunnable(com.skelril.nitro.time.IntegratedRunnable) BlockChangeFlag(org.spongepowered.api.world.BlockChangeFlag) Task(org.spongepowered.api.scheduler.Task) Probability(com.skelril.nitro.probability.Probability) Fireball(org.spongepowered.api.entity.projectile.explosive.fireball.Fireball) PlaceHolderText(com.skelril.nitro.text.PlaceHolderText) Creeper(org.spongepowered.api.entity.living.monster.Creeper) ItemStackConfig(com.skelril.nitro.registry.dynamic.ItemStackConfig) IndirectEntityDamageSource(org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource) Modifiers(com.skelril.skree.content.modifier.Modifiers) Monster(org.spongepowered.api.entity.living.monster.Monster) TimeUnit(java.util.concurrent.TimeUnit) DamageModifier(org.spongepowered.api.event.cause.entity.damage.DamageModifier) DropTableImpl(com.skelril.nitro.droptable.DropTableImpl) MessageChannel(org.spongepowered.api.text.channel.MessageChannel) Projectile(org.spongepowered.api.entity.projectile.Projectile) Listener(org.spongepowered.api.event.Listener) ItemType(org.spongepowered.api.item.ItemType) SECONDS(java.util.concurrent.TimeUnit.SECONDS) BlockSnapshot(org.spongepowered.api.block.BlockSnapshot) ItemStackSnapshot(org.spongepowered.api.item.inventory.ItemStackSnapshot) World(org.spongepowered.api.world.World) Location(org.spongepowered.api.world.Location) Listener(org.spongepowered.api.event.Listener)

Aggregations

Vector3d (com.flowpowered.math.vector.Vector3d)1 Lists (com.google.common.collect.Lists)1 PlayerCombatParser (com.skelril.nitro.combat.PlayerCombatParser)1 EnchantmentUtil (com.skelril.nitro.data.util.EnchantmentUtil)1 DropTable (com.skelril.nitro.droptable.DropTable)1 DropTableEntryImpl (com.skelril.nitro.droptable.DropTableEntryImpl)1 DropTableImpl (com.skelril.nitro.droptable.DropTableImpl)1 MasterDropTable (com.skelril.nitro.droptable.MasterDropTable)1 SimpleDropResolver (com.skelril.nitro.droptable.resolver.SimpleDropResolver)1 SlipperySingleHitDiceRoller (com.skelril.nitro.droptable.roller.SlipperySingleHitDiceRoller)1 EntityHealthPrinter (com.skelril.nitro.entity.EntityHealthPrinter)1 ItemDropper (com.skelril.nitro.item.ItemDropper)1 ItemStackFactory.newItemStack (com.skelril.nitro.item.ItemStackFactory.newItemStack)1 MathExt (com.skelril.nitro.numeric.MathExt)1 Probability (com.skelril.nitro.probability.Probability)1 ItemStackConfig (com.skelril.nitro.registry.dynamic.ItemStackConfig)1 QuantityBoundedItemStackConfig (com.skelril.nitro.registry.dynamic.QuantityBoundedItemStackConfig)1 CombinedText (com.skelril.nitro.text.CombinedText)1 PlaceHolderText (com.skelril.nitro.text.PlaceHolderText)1 IntegratedRunnable (com.skelril.nitro.time.IntegratedRunnable)1