Skip to content

Commit

Permalink
New spell effects, take 2 #408
Browse files Browse the repository at this point in the history
  • Loading branch information
matejdro committed Apr 20, 2015
1 parent 69d47c7 commit c270564
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/main/java/us/corenetwork/mantle/ParticleLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
public class ParticleLibrary
{

public static void broadcastParticleRing(EnumParticle particle, Location location, int haloRadius)
public static void broadcastParticleRing(EnumParticle particle, Location location, double haloRadius, double groupSpacing, int particlesPerGroup)
{
for (double angle = 0; angle < Math.PI * 2; angle += Math.PI / 12)
for (double angle = 0; angle < Math.PI * 2; angle += groupSpacing)
{
double particleX = location.getX() + haloRadius * Math.cos(angle);
double particleZ = location.getZ() + haloRadius * Math.sin(angle);

broadcastParticle(particle, new Location(location.getWorld(), particleX, location.getY(), particleZ), 0, 0, 0, 0, 2, null);
broadcastParticle(particle, new Location(location.getWorld(), particleX, location.getY(), particleZ), 0.25f, 0.5f, 0.25f, 0, particlesPerGroup, null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import us.corenetwork.mantle.spellbooks.EntityIterator;
import us.corenetwork.mantle.spellbooks.Spellbook;
import us.corenetwork.mantle.spellbooks.SpellbookItem;
import us.corenetwork.mantle.spellbooks.SpellbookUtil;


public class AllureBook extends Spellbook {
Expand Down Expand Up @@ -78,7 +79,7 @@ else if (entity instanceof Item)

Bukkit.getScheduler().runTask(MantlePlugin.instance, new PlayerShower(showerContents));

ParticleLibrary.broadcastParticleRing(EnumParticle.CRIT, player.getEyeLocation(), 2);
ParticleLibrary.broadcastParticle(EnumParticle.CRIT, SpellbookUtil.getPointInFrontOfPlayer(player.getEyeLocation(), 0.3), 0.3f, 0.3f, 0.3f, 0, 30, null);

return BookFinishAction.BROADCAST_AND_CONSUME;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public BookFinishAction onActivate(SpellbookItem item, PlayerInteractEvent event
}

Location effectLoc = player.getEyeLocation();
ParticleLibrary.broadcastParticleRing(EnumParticle.SPELL_WITCH, effectLoc, 2);
ParticleLibrary.broadcastParticleRing(EnumParticle.SPELL_WITCH, player.getEyeLocation(), 2, Math.PI / 12, 5);
effectLoc.getWorld().playSound(effectLoc, Sound.SKELETON_DEATH, 1f, 1f);
return BookFinishAction.BROADCAST_AND_CONSUME;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public BookFinishAction onActivate(SpellbookItem spellbookItem, PlayerInteractEv
Player player = event.getPlayer();

Location effectLoc;
boolean blockEffect;

Inventory inventory;
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock() != null && Util.isInventoryContainer(event.getClickedBlock().getTypeId()))
Expand All @@ -106,11 +107,13 @@ public BookFinishAction onActivate(SpellbookItem spellbookItem, PlayerInteractEv
InventoryHolder container = (InventoryHolder) event.getClickedBlock().getState();
inventory = container.getInventory();
effectLoc = Util.getLocationInBlockCenter(event.getClickedBlock());
blockEffect = true;
}
else
{
inventory = player.getInventory();
effectLoc = player.getEyeLocation();
blockEffect = false;
}

int freeInventorySlots = InventoryUtil.getFreeInventorySlots(inventory);
Expand Down Expand Up @@ -266,7 +269,11 @@ public int compare(ItemStack arg0, ItemStack arg1) {

player.updateInventory();

ParticleLibrary.broadcastParticleRing(EnumParticle.FLAME, effectLoc, 2);
if (blockEffect)
ParticleLibrary.broadcastParticle(EnumParticle.FLAME, effectLoc, 0.5f, 0.5f, 0.5f, 0, 200, null);
else
ParticleLibrary.broadcastParticle(EnumParticle.FLAME, SpellbookUtil.getPointInFrontOfPlayer(effectLoc, 0.3), 0.3f, 0.3f, 0.3f, 0, 30, null);

effectLoc.getWorld().playSound(effectLoc, Sound.FIRE, 1f, 1f);

if (anythingSmelted)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public BookFinishAction onActivate(SpellbookItem item, PlayerInteractEvent event

Inventory inventory;
Location effectLoc;
boolean blockEffect;

if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock() != null && Util.isInventoryContainer(event.getClickedBlock().getTypeId()))
{
//Check for claim if clicking on chest
Expand All @@ -81,11 +83,13 @@ public BookFinishAction onActivate(SpellbookItem item, PlayerInteractEvent event
InventoryHolder container = (InventoryHolder) event.getClickedBlock().getState();
inventory = container.getInventory();
effectLoc = Util.getLocationInBlockCenter(event.getClickedBlock());
blockEffect = true;
}
else
{
inventory = player.getInventory();
effectLoc = player.getEyeLocation();
blockEffect = false;
}

int freeInventorySlots = InventoryUtil.getFreeInventorySlots(inventory);
Expand Down Expand Up @@ -148,8 +152,12 @@ public BookFinishAction onActivate(SpellbookItem item, PlayerInteractEvent event
if (inventory.getType() == InventoryType.PLAYER)
player.updateInventory();

ParticleLibrary.broadcastParticleRing(EnumParticle.CRIT, effectLoc, 2);
effectLoc.getWorld().playSound(effectLoc, Sound.ANVIL_USE, 1f, 2f);
if (blockEffect)
ParticleLibrary.broadcastParticle(EnumParticle.CRIT, effectLoc, 0.5f, 0.5f, 0.5f, 0, 200, null);
else
ParticleLibrary.broadcastParticle(EnumParticle.CRIT, SpellbookUtil.getPointInFrontOfPlayer(effectLoc, 0.3), 0.3f, 0.3f, 0.3f, 0, 30, null);

effectLoc.getWorld().playSound(effectLoc, Sound.ANVIL_USE, 1f, 2f);

if (fusedSomething)
return BookFinishAction.BROADCAST_AND_CONSUME;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public BookFinishAction onActivate(SpellbookItem item, PlayerInteractEvent event
Player player = event.getPlayer();

Location effectLoc = player.getEyeLocation();
ParticleLibrary.broadcastParticleRing(EnumParticle.VILLAGER_HAPPY, effectLoc, 2);
ParticleLibrary.broadcastParticleRing(EnumParticle.VILLAGER_HAPPY, player.getEyeLocation(), 2, Math.PI / 12, 5);
event.getPlayer().playSound(effectLoc, Sound.LEVEL_UP, 1.0f, 1.0f);

Block baseBlock = event.getPlayer().getLocation().getBlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ protected BookFinishAction onActivateEntity(SpellbookItem spellbookItem, PlayerI
}

Location effectLoc = entity.getLocation();
effectLoc.setY(effectLoc.getY() + 1);
ParticleLibrary.broadcastParticleRing(EnumParticle.CRIT_MAGIC, effectLoc, 2);
effectLoc.setY(effectLoc.getY() + 1.5);
ParticleLibrary.broadcastParticle(EnumParticle.CRIT_MAGIC, effectLoc, 0.3f, 0.3f, 0.3f, 0, 30, null);
event.getPlayer().playSound(effectLoc, Sound.VILLAGER_YES, 1.0f, 1.0f);

return BookFinishAction.BROADCAST_AND_CONSUME;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public BookFinishAction onActivate(SpellbookItem item, PlayerInteractEvent event
Inventory inventory;
Inventory fuelInventory = player.getInventory();
Location effectLoc;
boolean blockEffect;
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock() != null && Util.isInventoryContainer(event.getClickedBlock().getTypeId()))
{
//Check for claim if clicking on chest
Expand All @@ -98,14 +99,19 @@ public BookFinishAction onActivate(SpellbookItem item, PlayerInteractEvent event
InventoryHolder container = (InventoryHolder) event.getClickedBlock().getState();
inventory = container.getInventory();
effectLoc = Util.getLocationInBlockCenter(event.getClickedBlock());
blockEffect = true;
}
else
{
inventory = player.getInventory();
effectLoc = player.getEyeLocation();
blockEffect = false;
}

ParticleLibrary.broadcastParticleRing(EnumParticle.FLAME, effectLoc, 2);
if (blockEffect)
ParticleLibrary.broadcastParticle(EnumParticle.FLAME, effectLoc, 0.5f, 0.5f, 0.5f, 0, 200, null);
else
ParticleLibrary.broadcastParticle(EnumParticle.FLAME, SpellbookUtil.getPointInFrontOfPlayer(effectLoc, 0.3), 0.3f, 0.3f, 0.3f, 0, 30, null);
effectLoc.getWorld().playSound(effectLoc, Sound.BLAZE_HIT, 0.5f, 0.3f);

boolean anythingSmelted = smith(inventory, fuelInventory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public TimeBook() {
public BookFinishAction onActivate(SpellbookItem item, PlayerInteractEvent event) {
curPlayer = event.getPlayer();

ParticleLibrary.broadcastParticleRing(EnumParticle.ENCHANTMENT_TABLE, curPlayer.getEyeLocation(), 2);
ParticleLibrary.broadcastParticle(EnumParticle.ENCHANTMENT_TABLE, SpellbookUtil.getPointInFrontOfPlayer(curPlayer.getEyeLocation(), 0.3), 0.3f, 0.3f, 0.3f, 0, 30, null);

for (int i = 0; i < curPlayer.getInventory().getSize() + 4; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public BookFinishAction onActivate(SpellbookItem item, PlayerInteractEvent event


Location effectLoc = player.getEyeLocation();
ParticleLibrary.broadcastParticleRing(EnumParticle.SLIME, effectLoc, 2);
ParticleLibrary.broadcastParticleRing(EnumParticle.SLIME, player.getEyeLocation(), 2, Math.PI / 12, 5);
effectLoc.getWorld().playSound(effectLoc, Sound.SLIME_WALK2, 2f, 1f);

if (slimeChunk)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public BookFinishAction onActivate(SpellbookItem item, PlayerInteractEvent event

Bukkit.getScheduler().runTaskLater(MantlePlugin.instance, new SprintingTimer(uuid), EFFECT_DURATION);

ParticleLibrary.broadcastParticleRing(EnumParticle.EXPLOSION_NORMAL, player.getEyeLocation(), 2);
ParticleLibrary.broadcastParticleRing(EnumParticle.EXPLOSION_NORMAL, player.getEyeLocation(), 2, Math.PI / 12, 5);

return BookFinishAction.BROADCAST_AND_CONSUME;
}
Expand Down

0 comments on commit c270564

Please sign in to comment.