Search in sources :

Example 1 with DustOptions

use of org.bukkit.Particle.DustOptions in project Spirits by xNuminousx.

the class Intoxicate method effect.

public void effect(int points, float size, Entity target, Location location) {
    Color color = Color.fromBGR(blue, green, red);
    DustOptions dustOptions = new DustOptions(color, 1);
    LivingEntity le = (LivingEntity) target;
    for (int i = 0; i < 6; i++) {
        currPoint += 360 / points;
        if (currPoint > 360) {
            currPoint = 0;
        }
        double angle = currPoint * Math.PI / 180 * Math.cos(Math.PI);
        double x = size * (Math.PI * 4 - angle) * Math.cos(angle + i);
        double y = 1.2 * Math.cos(angle) + 1.2;
        double z = size * (Math.PI * 4 - angle) * Math.sin(angle + i);
        location.add(x, y, z);
        player.getWorld().spawnParticle(Particle.REDSTONE, location, 1, 0, 0, 0, 0, dustOptions);
        location.subtract(x, y, z);
    }
    if (System.currentTimeMillis() - time > potInt) {
        for (PotionEffect targetEffect : le.getActivePotionEffects()) {
            if (isPositiveEffect(targetEffect.getType())) {
                le.removePotionEffect(targetEffect.getType());
            }
        }
        bPlayer.addCooldown(this);
    }
    if (System.currentTimeMillis() - time > harmInt) {
        le.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 100, 1), true);
        le.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, 1000, 1), true);
        le.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 300, 1), true);
        DamageHandler.damageEntity(player, selfDamage, this);
        bPlayer.addCooldown(this);
        remove();
        return;
    }
    if (new Random().nextInt(20) == 0) {
        player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ENDER_EYE_DEATH, 1, -1);
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Random(java.util.Random) PotionEffect(org.bukkit.potion.PotionEffect) Color(org.bukkit.Color) DustOptions(org.bukkit.Particle.DustOptions)

Example 2 with DustOptions

use of org.bukkit.Particle.DustOptions in project Spirits by xNuminousx.

the class Alleviate method progressSanctity.

public void progressSanctity(int points, float size) {
    Color color = Color.fromBGR(blue, green, red);
    DustOptions dustOptions = new DustOptions(color, 1);
    if (playingAlleviate) {
        return;
    } else {
        Location location = player.getLocation();
        for (int i = 0; i < 6; i++) {
            currPoint += 360 / points;
            if (currPoint > 360) {
                currPoint = 0;
            }
            double angle = currPoint * Math.PI / 180 * Math.cos(Math.PI);
            double x = size * (Math.PI * 4 - angle) * Math.cos(angle + i);
            double y = 1.2 * Math.cos(angle) + 1.2;
            double z = size * (Math.PI * 4 - angle) * Math.sin(angle + i);
            location.add(x, y, z);
            player.getWorld().spawnParticle(Particle.REDSTONE, location, 1, 0, 0, 0, 0, dustOptions);
            // GeneralMethods.displayColoredParticle(location, selfHexColor);
            location.subtract(x, y, z);
        }
        if (System.currentTimeMillis() > time + chargeTime) {
            for (PotionEffect playerEffects : player.getActivePotionEffects()) {
                if (isNegativeEffect(playerEffects.getType()) && removeNegPots) {
                    player.removePotionEffect(playerEffects.getType());
                }
            }
            player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, healDuration * 100, 1), true);
            player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, nightVisDuration * 100, 1));
            bPlayer.addCooldown(this, selfCooldown);
            remove();
            return;
        }
    }
    if (!player.isSneaking()) {
        bPlayer.addCooldown(this, selfCooldown);
    }
    if (new Random().nextInt(20) == 0) {
        player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ENDER_EYE_DEATH, 1, 1);
    }
}
Also used : Random(java.util.Random) PotionEffect(org.bukkit.potion.PotionEffect) Color(org.bukkit.Color) DustOptions(org.bukkit.Particle.DustOptions) Location(org.bukkit.Location)

Example 3 with DustOptions

use of org.bukkit.Particle.DustOptions in project DragonsOnline by UniverseCraft.

the class AuraAddon method initialize.

@Override
public void initialize(GameObject gameObject) {
    NPC npc = (NPC) gameObject;
    Entity entity = npc.getEntity();
    BukkitRunnable auraRunnable = new BukkitRunnable() {

        private Vector add = new Vector(1.5, 0.0, 0.0);

        private double theta = 10 * Math.PI / 180;

        private double y_step = 0.07;

        private double y_max = 2.1;

        @Override
        public void run() {
            Location at = entity.getLocation().add(add);
            entity.getWorld().spawnParticle(Particle.REDSTONE, at.getX(), at.getY(), at.getZ(), 2, new DustOptions(Color.RED, 1.0f));
            add.setX(add.getX() * Math.cos(theta) - add.getZ() * Math.sin(theta));
            add.setZ(add.getX() * Math.sin(theta) + add.getZ() * Math.cos(theta));
            add.setY((add.getY() + y_step) % y_max);
        }
    };
    auraRunnable.runTaskTimer(Dragons.getInstance(), 0L, 2L);
    auraRunnables.put(npc, auraRunnable);
}
Also used : NPC(mc.dragons.core.gameobject.npc.NPC) Entity(org.bukkit.entity.Entity) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) DustOptions(org.bukkit.Particle.DustOptions) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location)

Example 4 with DustOptions

use of org.bukkit.Particle.DustOptions in project Spirits by xNuminousx.

the class Alleviate method progressAlleviate.

public void progressAlleviate(int points, float size, Entity target, Location location) {
    Color color = Color.fromBGR(blue, green, red);
    DustOptions dustOptions = new DustOptions(color, 1);
    playingAlleviate = true;
    LivingEntity le = (LivingEntity) target;
    for (int i = 0; i < 6; i++) {
        currPoint += 360 / points;
        if (currPoint > 360) {
            currPoint = 0;
        }
        double angle = currPoint * Math.PI / 180 * Math.cos(Math.PI);
        double x = size * (Math.PI * 4 - angle) * Math.cos(angle + i);
        double y = 1.2 * Math.cos(angle) + 1.2;
        double z = size * (Math.PI * 4 - angle) * Math.sin(angle + i);
        location.add(x, y, z);
        player.getWorld().spawnParticle(Particle.REDSTONE, location, 1, 0, 0, 0, 0, dustOptions);
        // GeneralMethods.displayColoredParticle(location, hexColor);
        location.subtract(x, y, z);
    }
    if (System.currentTimeMillis() - time > potInt) {
        for (PotionEffect targetEffect : le.getActivePotionEffects()) {
            if (isNegativeEffect(targetEffect.getType())) {
                le.removePotionEffect(targetEffect.getType());
            }
        }
        bPlayer.addCooldown(this, otherCooldown);
    }
    if (System.currentTimeMillis() - time > healInt) {
        le.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 100, 1), true);
        DamageHandler.damageEntity(player, selfDamage, this);
        bPlayer.addCooldown(this, otherCooldown);
        remove();
        return;
    }
    if (!player.isSneaking()) {
        bPlayer.addCooldown(this, otherCooldown);
    }
    if (new Random().nextInt(20) == 0) {
        target.getWorld().playSound(target.getLocation(), Sound.ENTITY_ENDER_EYE_DEATH, 1, 1);
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Random(java.util.Random) PotionEffect(org.bukkit.potion.PotionEffect) Color(org.bukkit.Color) DustOptions(org.bukkit.Particle.DustOptions)

Example 5 with DustOptions

use of org.bukkit.Particle.DustOptions in project RoseStacker by Rosewood-Development.

the class StackingThread method processNametags.

public void processNametags() {
    if (!this.dynamicEntityTags && !this.dynamicItemTags && !this.dynamicBlockTags)
        return;
    List<Player> players = this.targetWorld.getPlayers();
    if (players.isEmpty())
        return;
    // Handle dynamic stack tags
    NMSHandler nmsHandler = NMSAdapter.getHandler();
    Set<EntityType> validEntities = StackerUtils.getStackableEntityTypes();
    boolean displaySingleEntityTags = Setting.ENTITY_DISPLAY_TAGS_SINGLE.getBoolean();
    boolean displaySingleItemTags = Setting.ITEM_DISPLAY_TAGS_SINGLE.getBoolean();
    List<Entity> entities = new ArrayList<>();
    entities.addAll(this.stackedEntities.values().stream().filter(x -> x.getStackSize() > 1 || displaySingleEntityTags).map(StackedEntity::getEntity).filter(Objects::nonNull).filter(x -> validEntities.contains(x.getType())).collect(Collectors.toList()));
    entities.addAll(this.stackedItems.values().stream().filter(x -> x.getStackSize() > 1 || displaySingleItemTags).map(StackedItem::getItem).collect(Collectors.toList()));
    for (Player player : players) {
        if (player.getWorld() != this.targetWorld)
            continue;
        ItemStack itemStack = player.getInventory().getItemInMainHand();
        boolean displayStackingToolParticles = ItemUtils.isStackingTool(itemStack);
        for (Entity entity : entities) {
            if (entity.getType() == EntityType.PLAYER)
                continue;
            if ((entity.getType() == EntityType.DROPPED_ITEM || entity.getType() == EntityType.ARMOR_STAND) && (entity.getCustomName() == null || !entity.isCustomNameVisible()))
                continue;
            double distanceSqrd;
            try {
                // The locations can end up comparing cross-world if the player/entity switches worlds mid-loop due to being async
                distanceSqrd = player.getLocation().distanceSquared(entity.getLocation());
            } catch (Exception e) {
                continue;
            }
            if (distanceSqrd > StackerUtils.ASSUMED_ENTITY_VISIBILITY_RANGE)
                continue;
            boolean visible;
            if (this.dynamicItemTags && entity.getType() == EntityType.DROPPED_ITEM) {
                visible = distanceSqrd < this.itemDynamicViewRangeSqrd;
                if (this.itemDynamicWallDetection)
                    visible &= EntityUtils.hasLineOfSight(player, entity, 0.75, true);
            } else if (this.dynamicBlockTags && entity.getType() == EntityType.ARMOR_STAND) {
                visible = distanceSqrd < this.blockSpawnerDynamicViewRangeSqrd;
                if (this.blockDynamicWallDetection)
                    visible &= EntityUtils.hasLineOfSight(player, entity, 0.75, true);
            } else if (this.dynamicEntityTags) {
                visible = distanceSqrd < this.entityDynamicViewRangeSqrd;
                if (this.entityDynamicWallDetection)
                    visible &= EntityUtils.hasLineOfSight(player, entity, 0.75, true);
            } else
                continue;
            if (entity.getType() != EntityType.ARMOR_STAND && entity instanceof LivingEntity) {
                LivingEntity livingEntity = (LivingEntity) entity;
                StackedEntity stackedEntity = this.getStackedEntity(livingEntity);
                if (stackedEntity != null)
                    nmsHandler.updateEntityNameTagForPlayer(player, entity, stackedEntity.getDisplayName(), stackedEntity.isDisplayNameVisible() && visible);
                // Spawn particles for holding the stacking tool
                if (visible && displayStackingToolParticles) {
                    Location location = entity.getLocation().add(0, livingEntity.getEyeHeight(true) + 0.75, 0);
                    DustOptions dustOptions;
                    if (PersistentDataUtils.isUnstackable(livingEntity)) {
                        dustOptions = StackerUtils.UNSTACKABLE_DUST_OPTIONS;
                    } else {
                        dustOptions = StackerUtils.STACKABLE_DUST_OPTIONS;
                    }
                    player.spawnParticle(Particle.REDSTONE, location, 1, 0.0, 0.0, 0.0, 0.0, dustOptions);
                }
            } else {
                nmsHandler.updateEntityNameTagVisibilityForPlayer(player, entity, visible);
            }
        }
    }
}
Also used : StackedEntityDataEntry(dev.rosewood.rosestacker.nms.storage.StackedEntityDataEntry) EntityUtils(dev.rosewood.rosestacker.utils.EntityUtils) Player(org.bukkit.entity.Player) ItemUtils(dev.rosewood.rosestacker.utils.ItemUtils) PreDropStackedItemsEvent(dev.rosewood.rosestacker.event.PreDropStackedItemsEvent) EntityStackSettings(dev.rosewood.rosestacker.stack.settings.EntityStackSettings) StackSettingManager(dev.rosewood.rosestacker.manager.StackSettingManager) Block(org.bukkit.block.Block) Location(org.bukkit.Location) World(org.bukkit.World) Map(java.util.Map) PersistentDataUtils(dev.rosewood.rosestacker.utils.PersistentDataUtils) Chunk(org.bukkit.Chunk) ItemStackSettings(dev.rosewood.rosestacker.stack.settings.ItemStackSettings) Material(org.bukkit.Material) Bukkit(org.bukkit.Bukkit) Setting(dev.rosewood.rosestacker.manager.ConfigurationManager.Setting) Entity(org.bukkit.entity.Entity) Predicate(java.util.function.Predicate) ItemStackClearEvent(dev.rosewood.rosestacker.event.ItemStackClearEvent) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) UUID(java.util.UUID) EntityType(org.bukkit.entity.EntityType) LivingEntity(org.bukkit.entity.LivingEntity) EntityCacheManager(dev.rosewood.rosestacker.manager.EntityCacheManager) Collectors(java.util.stream.Collectors) RosePlugin(dev.rosewood.rosegarden.RosePlugin) EntityUnstackEvent(dev.rosewood.rosestacker.event.EntityUnstackEvent) StackedEntityDataStorage(dev.rosewood.rosestacker.nms.storage.StackedEntityDataStorage) ItemStack(org.bukkit.inventory.ItemStack) Objects(java.util.Objects) StackManager(dev.rosewood.rosestacker.manager.StackManager) List(java.util.List) Entry(java.util.Map.Entry) BukkitTask(org.bukkit.scheduler.BukkitTask) Optional(java.util.Optional) StackerUtils(dev.rosewood.rosestacker.utils.StackerUtils) NPCsHook(dev.rosewood.rosestacker.hook.NPCsHook) DustOptions(org.bukkit.Particle.DustOptions) Item(org.bukkit.entity.Item) WorldGuardHook(dev.rosewood.rosestacker.hook.WorldGuardHook) HashMap(java.util.HashMap) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) DataUtils(dev.rosewood.rosestacker.utils.DataUtils) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ItemStackEvent(dev.rosewood.rosestacker.event.ItemStackEvent) NMSHandler(dev.rosewood.rosestacker.nms.NMSHandler) SpawnReason(org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason) CreatureSpawner(org.bukkit.block.CreatureSpawner) Particle(org.bukkit.Particle) Vector(org.bukkit.util.Vector) EntityStackEvent(dev.rosewood.rosestacker.event.EntityStackEvent) EntityStackClearEvent(dev.rosewood.rosestacker.event.EntityStackClearEvent) ArmorStand(org.bukkit.entity.ArmorStand) NMSAdapter(dev.rosewood.rosestacker.nms.NMSAdapter) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) ArrayList(java.util.ArrayList) NMSHandler(dev.rosewood.rosestacker.nms.NMSHandler) EntityType(org.bukkit.entity.EntityType) LivingEntity(org.bukkit.entity.LivingEntity) DustOptions(org.bukkit.Particle.DustOptions) ItemStack(org.bukkit.inventory.ItemStack) Location(org.bukkit.Location)

Aggregations

DustOptions (org.bukkit.Particle.DustOptions)6 Random (java.util.Random)3 LivingEntity (org.bukkit.entity.LivingEntity)3 Color (org.bukkit.Color)2 Location (org.bukkit.Location)2 Particle (org.bukkit.Particle)2 PotionEffect (org.bukkit.potion.PotionEffect)2 RosePlugin (dev.rosewood.rosegarden.RosePlugin)1 EntityStackClearEvent (dev.rosewood.rosestacker.event.EntityStackClearEvent)1 EntityStackEvent (dev.rosewood.rosestacker.event.EntityStackEvent)1 EntityUnstackEvent (dev.rosewood.rosestacker.event.EntityUnstackEvent)1 ItemStackClearEvent (dev.rosewood.rosestacker.event.ItemStackClearEvent)1 ItemStackEvent (dev.rosewood.rosestacker.event.ItemStackEvent)1 PreDropStackedItemsEvent (dev.rosewood.rosestacker.event.PreDropStackedItemsEvent)1 NPCsHook (dev.rosewood.rosestacker.hook.NPCsHook)1 WorldGuardHook (dev.rosewood.rosestacker.hook.WorldGuardHook)1 Setting (dev.rosewood.rosestacker.manager.ConfigurationManager.Setting)1 EntityCacheManager (dev.rosewood.rosestacker.manager.EntityCacheManager)1 StackManager (dev.rosewood.rosestacker.manager.StackManager)1 StackSettingManager (dev.rosewood.rosestacker.manager.StackSettingManager)1