Search in sources :

Example 1 with Item

use of org.bukkit.entity.Item in project EliteMobs by MagmaGuy.

the class MinorPowerPowerStance method itemEffect.

//Secondary effect particle processing
//    private void particleEffect(Entity entity, Particle particle, int particleAmount, double v, double v1, double v2, double v3) {
//        if (ConfigValues.defaultConfig.getBoolean("Turn on visual effects for natural or plugin-spawned EliteMobs")) {
//
//            if (ConfigValues.defaultConfig.getBoolean("Turn off visual effects for non-natural or non-plugin-spawned EliteMobs")
//                    && !entity.hasMetadata(MetadataHandler.NATURAL_MOB_MD)) {
//
//                return;
//
//            }
//
//            processID = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
//
//                float counter = 0;
//
//                public void run() {
//
//                    List<Location> particleLocations = powerStanceMath.cylindricalPowerStance(entity, radiusHorizontal, radiusVertical, speedHorizontal, speedVertical, counter);
//
//                    Location location1 = particleLocations.get(0);
//                    Location location2 = particleLocations.get(1);
//
//                    entity.getWorld().spawnParticle(particle, location1, particleAmount, v, v1, v2, v3);
//                    entity.getWorld().spawnParticle(particle, location2, particleAmount, v, v1, v2, v3);
//
//                    if (!entity.isValid()) {
//
//                        Bukkit.getScheduler().cancelTask(processID);
//
//                    }
//
//                    counter++;
//
//                }
//
//            }, 1L, 1L);
//
//        }
//
//    }
//    public void attackConfusing(Entity entity) {
//
//        particleEffect(entity, Particle.SPELL_MOB, 5, 0, 0, 0, 0.01);
//
//    }
//
//    public void invulnerabilityFireEffect(Entity entity) {
//
//        particleEffect(entity, Particle.FLAME, 5, 0, 0, 0, 0.01);
//
//    }
//Secondary effect item processing
public void itemEffect(Entity entity) {
    if (ConfigValues.defaultConfig.getBoolean("Turn on visual effects for natural or plugin-spawned EliteMobs")) {
        if (ConfigValues.defaultConfig.getBoolean("Turn off visual effects for non-natural or non-plugin-spawned EliteMobs") && !entity.hasMetadata(MetadataHandler.NATURAL_MOB_MD)) {
            return;
        }
        if (entity.hasMetadata(MetadataHandler.VISUAL_EFFECT_MD)) {
            return;
        }
        entity.setMetadata("VisualEffect", new FixedMetadataValue(plugin, true));
        //contains all items around a given entity
        HashMap<Integer, HashMap<Integer, List<Item>>> powerItemLocationTracker = new HashMap<>();
        new BukkitRunnable() {

            int attackArrowCounter = 0;

            int attackBlindingCounter = 0;

            int attackFireCounter = 0;

            int attackFireballCounter = 0;

            int attackFreezeCounter = 0;

            int attackGravityCounter = 0;

            int attackPoisonCounter = 0;

            int attackPushCounter = 0;

            int attackWeaknessCounter = 0;

            int attackWebCounter = 0;

            int attackWitherCounter = 0;

            int bonusLootCounter = 0;

            int doubleDamageCounter = 0;

            int doubleHealthCounter = 0;

            int invisibilityCounter = 0;

            int invulnerabilityArrowCounter = 0;

            int invulnerabilityFallDamageCounter = 0;

            int invulnerabilityKnockbackCounter = 0;

            int movementSpeedCounter = 0;

            int tauntCounter = 0;

            public void run() {
                //                    int effectQuantity = 0;
                int effectIteration = 0;
                //apply new positioning
                if (entity.hasMetadata(MetadataHandler.ATTACK_ARROW_MD)) {
                    ItemStack itemStack = new ItemStack(Material.ARROW, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackArrowCounter);
                    effectIteration++;
                    attackArrowCounter++;
                    if (attackArrowCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackArrowCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ATTACK_BLINDING_MD)) {
                    ItemStack itemStack = new ItemStack(Material.EYE_OF_ENDER, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackBlindingCounter);
                    effectIteration++;
                    attackBlindingCounter++;
                    if (attackBlindingCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackBlindingCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ATTACK_FIRE_MD)) {
                    ItemStack itemStack = new ItemStack(Material.LAVA_BUCKET, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackFireCounter);
                    effectIteration++;
                    attackFireCounter++;
                    if (attackFireCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackFireCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ATTACK_FIREBALL_MD)) {
                    ItemStack itemStack = new ItemStack(Material.FIREBALL, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackFireballCounter);
                    effectIteration++;
                    attackFireballCounter++;
                    if (attackFireballCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackFireballCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ATTACK_FREEZE_MD)) {
                    ItemStack itemStack = new ItemStack(Material.PACKED_ICE, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackFreezeCounter);
                    effectIteration++;
                    attackFreezeCounter++;
                    if (attackFreezeCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackFreezeCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ATTACK_GRAVITY_MD)) {
                    ItemStack itemStack = new ItemStack(Material.ELYTRA, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackGravityCounter);
                    effectIteration++;
                    attackGravityCounter++;
                    if (attackGravityCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackGravityCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ATTACK_POISON_MD)) {
                    ItemStack itemStack = new ItemStack(Material.EMERALD, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackPoisonCounter);
                    effectIteration++;
                    attackPoisonCounter++;
                    if (attackPoisonCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackPoisonCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ATTACK_PUSH_MD)) {
                    ItemStack itemStack = new ItemStack(Material.PISTON_BASE, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackPushCounter);
                    effectIteration++;
                    attackPushCounter++;
                    if (attackPushCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackPushCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ATTACK_WEAKNESS_MD)) {
                    ItemStack itemStack = new ItemStack(Material.TOTEM, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackWeaknessCounter);
                    effectIteration++;
                    attackWeaknessCounter++;
                    if (attackWeaknessCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackWeaknessCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ATTACK_WEB_MD)) {
                    ItemStack itemStack = new ItemStack(Material.WEB, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackWebCounter);
                    effectIteration++;
                    attackWebCounter++;
                    if (attackWebCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackWebCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ATTACK_WITHER_MD)) {
                    ItemStack itemStack = new ItemStack(Material.SKULL_ITEM, 1, (short) 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackWitherCounter);
                    effectIteration++;
                    attackWitherCounter++;
                    if (attackWitherCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        attackWitherCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.BONUS_LOOT_MD)) {
                    ItemStack itemStack = new ItemStack(Material.CHEST, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, bonusLootCounter);
                    effectIteration++;
                    bonusLootCounter++;
                    if (bonusLootCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        bonusLootCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.DOUBLE_DAMAGE_MD)) {
                    ItemStack itemStack = new ItemStack(Material.GOLD_SWORD, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, doubleDamageCounter);
                    effectIteration++;
                    doubleDamageCounter++;
                    if (doubleDamageCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        doubleDamageCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.DOUBLE_HEALTH_MD)) {
                    ItemStack itemStack = new ItemStack(Material.SHIELD, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, doubleHealthCounter);
                    effectIteration++;
                    doubleHealthCounter++;
                    if (doubleHealthCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        doubleHealthCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.INVISIBILITY_MD)) {
                    ItemStack itemStack = new ItemStack(Material.THIN_GLASS, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, invisibilityCounter);
                    effectIteration++;
                    invisibilityCounter++;
                    if (invisibilityCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        invisibilityCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.INVULNERABILITY_ARROW_MD)) {
                    ItemStack itemStack = new ItemStack(Material.SPECTRAL_ARROW, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, invulnerabilityArrowCounter);
                    effectIteration++;
                    invulnerabilityArrowCounter++;
                    if (invulnerabilityArrowCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        invulnerabilityArrowCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.INVULNERABILITY_FALL_DAMAGE_MD)) {
                    ItemStack itemStack = new ItemStack(Material.FEATHER, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, invulnerabilityFallDamageCounter);
                    effectIteration++;
                    invulnerabilityFallDamageCounter++;
                    if (invulnerabilityFallDamageCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        invulnerabilityFallDamageCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.INVULNERABILITY_KNOCKBACK_MD)) {
                    ItemStack itemStack = new ItemStack(Material.ANVIL, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, invulnerabilityKnockbackCounter);
                    effectIteration++;
                    invulnerabilityKnockbackCounter++;
                    if (invulnerabilityKnockbackCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        invulnerabilityKnockbackCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.MOVEMENT_SPEED_MD)) {
                    ItemStack itemStack = new ItemStack(Material.GOLD_BOOTS, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, movementSpeedCounter);
                    effectIteration++;
                    movementSpeedCounter++;
                    if (movementSpeedCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        movementSpeedCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.TAUNT_MD)) {
                    ItemStack itemStack = new ItemStack(Material.JUKEBOX, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, tauntCounter);
                    effectIteration++;
                    tauntCounter++;
                    if (tauntCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        tauntCounter = 0;
                    }
                }
                if (!entity.isValid() || entity.isDead()) {
                    for (int i = 0; i < powerItemLocationTracker.size(); i++) {
                        for (int j = 0; j < trackAmount; j++) {
                            for (int h = 0; h < itemsPerTrack; h++) {
                                powerItemLocationTracker.get(i).get(j).get(h).remove();
                                powerItemLocationTracker.get(i).get(j).get(h).removeMetadata(MetadataHandler.MAJOR_VISUAL_EFFECT_MD, plugin);
                            }
                        }
                    }
                    entity.removeMetadata(MetadataHandler.MAJOR_VISUAL_EFFECT_MD, plugin);
                    cancel();
                    return;
                }
            }
        }.runTaskTimer(plugin, 0, 5);
    }
}
Also used : Item(org.bukkit.entity.Item) HashMap(java.util.HashMap) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) ItemStack(org.bukkit.inventory.ItemStack)

Example 2 with Item

use of org.bukkit.entity.Item in project EliteMobs by MagmaGuy.

the class MinorPowerPowerStance method itemInitializer.

private Item itemInitializer(ItemStack itemStack, Location location) {
    Item item = location.getWorld().dropItem(location, itemStack);
    item.setPickupDelay(Integer.MAX_VALUE);
    item.setMetadata(MetadataHandler.MAJOR_VISUAL_EFFECT_MD, new FixedMetadataValue(plugin, 0));
    item.setGravity(false);
    return item;
}
Also used : Item(org.bukkit.entity.Item) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue)

Example 3 with Item

use of org.bukkit.entity.Item in project EliteMobs by MagmaGuy.

the class MinorPowerPowerStance method itemProcessor.

public void itemProcessor(HashMap<Integer, HashMap<Integer, List<Item>>> powerItemLocationTracker, ItemStack itemStack, int effectIteration, Entity entity, int counter) {
    boolean effectAlreadyPresent = false;
    if (!powerItemLocationTracker.isEmpty()) {
        for (int i = 0; i < powerItemLocationTracker.size(); i++) {
            if (powerItemLocationTracker.get(i).get(0).get(0).getItemStack().getType().equals(itemStack.getType())) {
                effectAlreadyPresent = true;
                break;
            }
        }
    }
    HashMap<Integer, List<Vector>> trackHashMap = MinorPowerStanceMath.majorPowerLocationConstructor(trackAmount, itemsPerTrack, counter);
    Location centerLocation = entity.getLocation().add(new Vector(0, 1, 0));
    if (!effectAlreadyPresent) {
        HashMap<Integer, List<Item>> tempMap = new HashMap<>();
        for (int i = 0; i < trackAmount; i++) {
            List<Item> newItemList = new ArrayList<>();
            for (int j = 0; j < itemsPerTrack; j++) {
                newItemList.add(itemInitializer(itemStack, entity.getLocation()));
            }
            //same format as trackHashMap
            tempMap.put(i, newItemList);
        }
        powerItemLocationTracker.put(effectIteration, tempMap);
    } else {
        //iterate through the tracks
        for (int i = 0; i < trackAmount; i++) {
            for (int j = 0; j < itemsPerTrack; j++) {
                Item item = powerItemLocationTracker.get(effectIteration).get(i).get(j);
                Location newLocation = new Location(entity.getWorld(), trackHashMap.get(i).get(j).getX(), trackHashMap.get(i).get(j).getY(), trackHashMap.get(i).get(j).getZ()).add(centerLocation);
                Location currentLocation = item.getLocation();
                if (counter % (29) == 0 || item.getWorld() != entity.getWorld()) {
                    item.teleport(item.getLocation());
                //                        counter--;
                //                        Location itemLocation = new Location(entity.getWorld(), trackHashMap.get(i).get(j).getX(),
                //                                trackHashMap.get(i).get(j).getY(), trackHashMap.get(i).get(j).getZ()).add(centerLocation);
                //
                //                        itemLocation.add(new Vector(0, Math.cos(counter), 0));
                //                        Bukkit.getLogger().info("test");
                //
                //                        //teleport is accurate at slower update rates, but when teleporting every tick can get an error margin of up to 2 meters
                //                        item.teleport(itemLocation);
                //
                //                        counter++;
                }
                //                    newLocation.add(new Vector(0, Math.cos(counter), 0));
                Vector vector = (newLocation.subtract(currentLocation)).toVector();
                vector = vector.multiply(0.3);
                item.setVelocity(vector);
            }
        }
    }
}
Also used : Item(org.bukkit.entity.Item) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location)

Example 4 with Item

use of org.bukkit.entity.Item in project Denizen-For-Bukkit by DenizenScript.

the class ItemMergesScriptEvent method onItemMerges.

@EventHandler
public void onItemMerges(ItemMergeEvent event) {
    Item entity = event.getEntity();
    Item target = event.getTarget();
    location = new dLocation(target.getLocation());
    item = new dItem(entity.getItemStack());
    this.entity = new dEntity(entity);
    cancelled = event.isCancelled();
    this.event = event;
    fire();
    event.setCancelled(cancelled);
}
Also used : net.aufdemrand.denizen.objects.dItem(net.aufdemrand.denizen.objects.dItem) Item(org.bukkit.entity.Item) net.aufdemrand.denizen.objects.dItem(net.aufdemrand.denizen.objects.dItem) net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) net.aufdemrand.denizen.objects.dLocation(net.aufdemrand.denizen.objects.dLocation) EventHandler(org.bukkit.event.EventHandler)

Example 5 with Item

use of org.bukkit.entity.Item in project Denizen-For-Bukkit by DenizenScript.

the class PlayerPicksUpScriptEvent method onPlayerPicksUp.

@EventHandler
public void onPlayerPicksUp(PlayerPickupItemEvent event) {
    if (dEntity.isNPC(event.getPlayer())) {
        return;
    }
    Item itemEntity = event.getItem();
    UUID itemUUID = itemEntity.getUniqueId();
    if (editedItems.contains(itemUUID)) {
        editedItems.remove(itemUUID);
        return;
    }
    location = new dLocation(itemEntity.getLocation());
    item = new dItem(itemEntity.getItemStack());
    entity = new dEntity(itemEntity);
    cancelled = event.isCancelled();
    itemChanged = false;
    this.event = event;
    fire();
    if (itemChanged) {
        itemEntity.setItemStack(item.getItemStack());
        editedItems.add(itemUUID);
        event.setCancelled(true);
    } else {
        event.setCancelled(cancelled);
    }
}
Also used : net.aufdemrand.denizen.objects.dItem(net.aufdemrand.denizen.objects.dItem) Item(org.bukkit.entity.Item) net.aufdemrand.denizen.objects.dItem(net.aufdemrand.denizen.objects.dItem) net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) UUID(java.util.UUID) net.aufdemrand.denizen.objects.dLocation(net.aufdemrand.denizen.objects.dLocation) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Item (org.bukkit.entity.Item)17 net.aufdemrand.denizen.objects.dEntity (net.aufdemrand.denizen.objects.dEntity)7 net.aufdemrand.denizen.objects.dItem (net.aufdemrand.denizen.objects.dItem)7 EventHandler (org.bukkit.event.EventHandler)7 net.aufdemrand.denizen.objects.dLocation (net.aufdemrand.denizen.objects.dLocation)6 ItemStack (org.bukkit.inventory.ItemStack)5 HashMap (java.util.HashMap)4 FixedMetadataValue (org.bukkit.metadata.FixedMetadataValue)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Location (org.bukkit.Location)3 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)3 Entity (org.bukkit.entity.Entity)2 Player (org.bukkit.entity.Player)2 Vector (org.bukkit.util.Vector)2 ItemActionInfo (com.gamingmesh.jobs.actions.ItemActionInfo)1 JobsPlayer (com.gamingmesh.jobs.container.JobsPlayer)1 UUID (java.util.UUID)1 ChangeResult (me.botsko.prism.appliers.ChangeResult)1 ChangeResultType (me.botsko.prism.appliers.ChangeResultType)1