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);
}
}
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);
}
}
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);
}
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);
}
}
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);
}
}
}
}
Aggregations