Change wizards spells to use conditions for potion effects

This commit is contained in:
libraryaddict 2015-03-17 18:07:43 +13:00
parent 03d77abed3
commit 41469b198a
4 changed files with 318 additions and 311 deletions

View File

@ -34,307 +34,313 @@ import net.minecraft.server.v1_7_R4.World;
public class CustomExplosion extends Explosion
{
private Player _owner;
private boolean _damageOwner;
private int _i = 16;
private World _world;
private DamageManager _manager;
private String _damageReason;
private boolean _dropItems = true;
private boolean _damageBlocksEqually;
private boolean _createFire;
private boolean _ignoreRate = true;
private Player _owner;
private boolean _damageOwner;
private int _i = 16;
private World _world;
private DamageManager _manager;
private String _damageReason;
private boolean _dropItems = true;
private boolean _damageBlocksEqually;
private boolean _createFire;
private boolean _ignoreRate = true;
public CustomExplosion(DamageManager manager, Location loc, float explosionSize, String deathCause)
{
super(((CraftWorld) loc.getWorld()).getHandle(), null, loc.getX(), loc.getY(), loc.getZ(), explosionSize);
_world = ((CraftWorld) loc.getWorld()).getHandle();
_manager = manager;
_damageReason = deathCause;
}
public CustomExplosion setIgnoreRate(boolean ignoreRate)
{
_ignoreRate = ignoreRate;
return this;
}
public CustomExplosion(DamageManager manager, Location loc, float explosionSize, String deathCause)
{
super(((CraftWorld) loc.getWorld()).getHandle(), null, loc.getX(), loc.getY(), loc.getZ(), explosionSize);
_world = ((CraftWorld) loc.getWorld()).getHandle();
_manager = manager;
_damageReason = deathCause;
}
public CustomExplosion setBlocksDamagedEqually(boolean damageEqually)
{
_damageBlocksEqually = damageEqually;
return this;
}
public CustomExplosion setIgnoreRate(boolean ignoreRate)
{
_ignoreRate = ignoreRate;
return this;
}
public CustomExplosion explode()
{
// Explode the explosion
a();
a(true);
public CustomExplosion setDamageBlocks(boolean damageBlocks)
{
b = damageBlocks;
return this;
}
return this;
}
public CustomExplosion setBlocksDamagedEqually(boolean damageEqually)
{
_damageBlocksEqually = damageEqually;
return this;
}
public CustomExplosion setDropItems(boolean dropItems)
{
_dropItems = dropItems;
public CustomExplosion explode()
{
// Explode the explosion
a();
a(true);
return this;
}
return this;
}
public CustomExplosion setPlayer(Player player, boolean damageExplosionOwner)
{
_owner = player;
_damageOwner = damageExplosionOwner;
public CustomExplosion setDropItems(boolean dropItems)
{
_dropItems = dropItems;
return this;
}
return this;
}
@Override
public void a()
{
if (this.size < 0.1F)
{
return;
}
public CustomExplosion setPlayer(Player player, boolean damageExplosionOwner)
{
_owner = player;
_damageOwner = damageExplosionOwner;
float f = this.size;
HashSet hashset = new HashSet();
return this;
}
for (int i = 0; i < this._i; i++)
{
for (int j = 0; j < this._i; j++)
{
for (int k = 0; k < this._i; k++)
{
if ((i == 0) || (i == this._i - 1) || (j == 0) || (j == this._i - 1) || (k == 0) || (k == this._i - 1))
{
double d3 = i / (this._i - 1.0F) * 2.0F - 1.0F;
double d4 = j / (this._i - 1.0F) * 2.0F - 1.0F;
double d5 = k / (this._i - 1.0F) * 2.0F - 1.0F;
double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
@Override
public void a()
{
if (this.size < 0.1F)
{
return;
}
d3 /= d6;
d4 /= d6;
d5 /= d6;
float f1 = this.size * (0.7F + this._world.random.nextFloat() * 0.6F);
float f = this.size;
HashSet hashset = new HashSet();
double d0 = this.posX;
double d1 = this.posY;
double d2 = this.posZ;
for (int i = 0; i < this._i; i++)
{
for (int j = 0; j < this._i; j++)
{
for (int k = 0; k < this._i; k++)
{
if ((i == 0) || (i == this._i - 1) || (j == 0) || (j == this._i - 1) || (k == 0) || (k == this._i - 1))
{
double d3 = i / (this._i - 1.0F) * 2.0F - 1.0F;
double d4 = j / (this._i - 1.0F) * 2.0F - 1.0F;
double d5 = k / (this._i - 1.0F) * 2.0F - 1.0F;
double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F)
{
int l = MathHelper.floor(d0);
int i1 = MathHelper.floor(d1);
int j1 = MathHelper.floor(d2);
Block block = this._world.getType(l, i1, j1);
d3 /= d6;
d4 /= d6;
d5 /= d6;
float f1 = this.size * (0.7F + this._world.random.nextFloat() * 0.6F);
if (block.getMaterial() != Material.AIR)
{
float f3 = this.source != null ? this.source.a(this, this._world, l, i1, j1, block)
: (_damageBlocksEqually ? Blocks.DIRT : block).a(this.source);
double d0 = this.posX;
double d1 = this.posY;
double d2 = this.posZ;
f1 -= (f3 + 0.3F) * f2;
}
for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F)
{
int l = MathHelper.floor(d0);
int i1 = MathHelper.floor(d1);
int j1 = MathHelper.floor(d2);
Block block = this._world.getType(l, i1, j1);
if ((f1 > 0.0F)
&& ((this.source == null) || (this.source.a(this, this._world, l, i1, j1, block, f1)))
&& (i1 < 256) && (i1 >= 0))
{
hashset.add(new ChunkPosition(l, i1, j1));
}
if (block.getMaterial() != Material.AIR)
{
float f3 = this.source != null ? this.source.a(this, this._world, l, i1, j1, block)
: (_damageBlocksEqually ? Blocks.DIRT : block).a(this.source);
d0 += d3 * f2;
d1 += d4 * f2;
d2 += d5 * f2;
}
}
}
}
}
f1 -= (f3 + 0.3F) * f2;
}
this.blocks.addAll(hashset);
this.size *= 2.0F;
_i = MathHelper.floor(this.posX - this.size - 1.0D);
int j = MathHelper.floor(this.posX + this.size + 1.0D);
int k = MathHelper.floor(this.posY - this.size - 1.0D);
int k1 = MathHelper.floor(this.posY + this.size + 1.0D);
int l1 = MathHelper.floor(this.posZ - this.size - 1.0D);
int i2 = MathHelper.floor(this.posZ + this.size + 1.0D);
List list = this._world.getEntities(this.source, AxisAlignedBB.a(_i, k, l1, j, k1, i2));
Vec3D vec3d = Vec3D.a(this.posX, this.posY, this.posZ);
if ((f1 > 0.0F)
&& ((this.source == null) || (this.source.a(this, this._world, l, i1, j1, block, f1)))
&& (i1 < 256) && (i1 >= 0))
{
hashset.add(new ChunkPosition(l, i1, j1));
}
for (int j2 = 0; j2 < list.size(); j2++)
{
Entity entity = (Entity) list.get(j2);
d0 += d3 * f2;
d1 += d4 * f2;
d2 += d5 * f2;
}
}
}
}
}
if (entity.getBukkitEntity() == _owner && !_damageOwner)
continue;
this.blocks.addAll(hashset);
this.size *= 2.0F;
_i = MathHelper.floor(this.posX - this.size - 1.0D);
int j = MathHelper.floor(this.posX + this.size + 1.0D);
int k = MathHelper.floor(this.posY - this.size - 1.0D);
int k1 = MathHelper.floor(this.posY + this.size + 1.0D);
int l1 = MathHelper.floor(this.posZ - this.size - 1.0D);
int i2 = MathHelper.floor(this.posZ + this.size + 1.0D);
List list = this._world.getEntities(this.source, AxisAlignedBB.a(_i, k, l1, j, k1, i2));
Vec3D vec3d = Vec3D.a(this.posX, this.posY, this.posZ);
double d7 = entity.f(this.posX, this.posY, this.posZ) / this.size;
for (int j2 = 0; j2 < list.size(); j2++)
{
Entity entity = (Entity) list.get(j2);
if (d7 <= 1.0D)
{
double d0 = entity.locX - this.posX;
double d1 = entity.locY + entity.getHeadHeight() - this.posY;
double d2 = entity.locZ - this.posZ;
double d8 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
if (entity.getBukkitEntity() == _owner && !_damageOwner)
continue;
if (d8 != 0.0D)
{
d0 /= d8;
d1 /= d8;
d2 /= d8;
double d9 = this._world.a(vec3d, entity.boundingBox);
double d10 = (1.0D - d7) * d9;
int damage = (int) ((d10 * d10 + d10) / 2.0D * 8.0D * this.size + 1.0D);
double d7 = entity.f(this.posX, this.posY, this.posZ) / this.size;
if (entity.getBukkitEntity() instanceof LivingEntity)
{
_manager.NewDamageEvent((LivingEntity) entity.getBukkitEntity(), _owner, null,
DamageCause.ENTITY_EXPLOSION, damage, true, _ignoreRate, false, _damageReason, _damageReason);
}
else
{
CraftEventFactory.entityDamage = this.source;
if (!entity.damageEntity(DamageSource.explosion(this), damage))
; // Yeah I don't get this either. But its in the source.
CraftEventFactory.entityDamage = null;
}
if (d7 <= 1.0D)
{
double d0 = entity.locX - this.posX;
double d1 = entity.locY + entity.getHeadHeight() - this.posY;
double d2 = entity.locZ - this.posZ;
double d8 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
double d11 = EnchantmentProtection.a(entity, d10);
if (d8 != 0.0D)
{
d0 /= d8;
d1 /= d8;
d2 /= d8;
double d9 = this._world.a(vec3d, entity.boundingBox);
double d10 = (1.0D - d7) * d9;
int damage = (int) ((d10 * d10 + d10) / 2.0D * 8.0D * this.size + 1.0D);
entity.motX += d0 * d11;
entity.motY += d1 * d11;
entity.motZ += d2 * d11;
if ((entity instanceof EntityHuman))
{
this.b().put(entity, Vec3D.a(d0 * d10, d1 * d10, d2 * d10));
}
}
}
}
if (entity.getBukkitEntity() instanceof LivingEntity)
{
_manager.NewDamageEvent((LivingEntity) entity.getBukkitEntity(), _owner, null,
DamageCause.ENTITY_EXPLOSION, damage, true, _ignoreRate, false, _damageReason, _damageReason);
}
else
{
CraftEventFactory.entityDamage = this.source;
if (!entity.damageEntity(DamageSource.explosion(this), damage))
; // Yeah I don't get this either. But its in the source.
CraftEventFactory.entityDamage = null;
}
this.size = f;
}
double d11 = EnchantmentProtection.a(entity, d10);
@Override
public void a(boolean flag)
{
this._world.makeSound(this.posX, this.posY, this.posZ, "random.explode", 4.0F,
(1.0F + (this._world.random.nextFloat() - this._world.random.nextFloat()) * 0.2F) * 0.7F);
if ((this.size >= 2.0F) && (this.b))
this._world.addParticle("hugeexplosion", this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D);
else
{
this._world.addParticle("largeexplode", this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D);
}
entity.motX += d0 * d11;
entity.motY += d1 * d11;
entity.motZ += d2 * d11;
if ((entity instanceof EntityHuman))
{
this.b().put(entity, Vec3D.a(d0 * d10, d1 * d10, d2 * d10));
}
}
}
}
if (this.b)
{
org.bukkit.World bworld = this._world.getWorld();
this.size = f;
}
List blockList = new ArrayList();
ChunkPosition cpos;
for (int i1 = this.blocks.size() - 1; i1 >= 0; i1--)
{
cpos = (ChunkPosition) this.blocks.get(i1);
org.bukkit.block.Block bblock = bworld.getBlockAt(cpos.x, cpos.y, cpos.z);
if (bblock.getType() != org.bukkit.Material.AIR)
{
blockList.add(bblock);
}
}
@Override
public void a(boolean flag)
{
this._world.makeSound(this.posX, this.posY, this.posZ, "random.explode", 4.0F,
(1.0F + (this._world.random.nextFloat() - this._world.random.nextFloat()) * 0.2F) * 0.7F);
if ((this.size >= 2.0F) && (this.b))
this._world.addParticle("hugeexplosion", this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D);
else
{
this._world.addParticle("largeexplode", this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D);
}
ExplosionEvent event = _owner == null ? new ExplosionEvent(blockList) : new ExplosionEvent(blockList, _owner);
this._world.getServer().getPluginManager().callEvent(event);
if (this.b)
{
org.bukkit.World bworld = this._world.getWorld();
this.blocks.clear();
List blockList = new ArrayList();
ChunkPosition cpos;
for (int i1 = this.blocks.size() - 1; i1 >= 0; i1--)
{
cpos = (ChunkPosition) this.blocks.get(i1);
org.bukkit.block.Block bblock = bworld.getBlockAt(cpos.x, cpos.y, cpos.z);
if (bblock.getType() != org.bukkit.Material.AIR)
{
blockList.add(bblock);
}
}
for (org.bukkit.block.Block bblock : event.GetBlocks())
{
ChunkPosition coords = new ChunkPosition(bblock.getX(), bblock.getY(), bblock.getZ());
this.blocks.add(coords);
}
ExplosionEvent event = _owner == null ? new ExplosionEvent(blockList) : new ExplosionEvent(blockList, _owner);
this._world.getServer().getPluginManager().callEvent(event);
if (event.GetBlocks().isEmpty())
{
this.wasCanceled = true;
return;
}
this.blocks.clear();
Iterator iterator = this.blocks.iterator();
for (org.bukkit.block.Block bblock : event.GetBlocks())
{
ChunkPosition coords = new ChunkPosition(bblock.getX(), bblock.getY(), bblock.getZ());
this.blocks.add(coords);
}
while (iterator.hasNext())
{
ChunkPosition chunkposition = (ChunkPosition) iterator.next();
int i = chunkposition.x;
int j = chunkposition.y;
int k = chunkposition.z;
Block block = this._world.getType(i, j, k);
this._world.spigotConfig.antiXrayInstance.updateNearbyBlocks(this._world, i, j, k);
if (flag)
{
double d0 = i + this._world.random.nextFloat();
double d1 = j + this._world.random.nextFloat();
double d2 = k + this._world.random.nextFloat();
double d3 = d0 - this.posX;
double d4 = d1 - this.posY;
double d5 = d2 - this.posZ;
double d6 = MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
if (event.GetBlocks().isEmpty())
{
this.wasCanceled = true;
return;
}
d3 /= d6;
d4 /= d6;
d5 /= d6;
double d7 = 0.5D / (d6 / this.size + 0.1D);
Iterator iterator = this.blocks.iterator();
d7 *= (this._world.random.nextFloat() * this._world.random.nextFloat() + 0.3F);
d3 *= d7;
d4 *= d7;
d5 *= d7;
this._world.addParticle("explode", (d0 + this.posX * 1.0D) / 2.0D, (d1 + this.posY * 1.0D) / 2.0D,
(d2 + this.posZ * 1.0D) / 2.0D, d3, d4, d5);
this._world.addParticle("smoke", d0, d1, d2, d3, d4, d5);
}
while (iterator.hasNext())
{
ChunkPosition chunkposition = (ChunkPosition) iterator.next();
int i = chunkposition.x;
int j = chunkposition.y;
int k = chunkposition.z;
Block block = this._world.getType(i, j, k);
this._world.spigotConfig.antiXrayInstance.updateNearbyBlocks(this._world, i, j, k);
if (flag)
{
double d0 = i + this._world.random.nextFloat();
double d1 = j + this._world.random.nextFloat();
double d2 = k + this._world.random.nextFloat();
double d3 = d0 - this.posX;
double d4 = d1 - this.posY;
double d5 = d2 - this.posZ;
double d6 = MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
if (block.getMaterial() != Material.AIR)
{
if (block.a(this) && _dropItems)
{
block.dropNaturally(this._world, i, j, k, this._world.getData(i, j, k), size, 0);
}
d3 /= d6;
d4 /= d6;
d5 /= d6;
double d7 = 0.5D / (d6 / this.size + 0.1D);
this._world.setTypeAndData(i, j, k, Blocks.AIR, 0, 3);
block.wasExploded(this._world, i, j, k, this);
}
}
}
d7 *= (this._world.random.nextFloat() * this._world.random.nextFloat() + 0.3F);
d3 *= d7;
d4 *= d7;
d5 *= d7;
this._world.addParticle("explode", (d0 + this.posX * 1.0D) / 2.0D, (d1 + this.posY * 1.0D) / 2.0D,
(d2 + this.posZ * 1.0D) / 2.0D, d3, d4, d5);
this._world.addParticle("smoke", d0, d1, d2, d3, d4, d5);
}
if (this._createFire)
{
Iterator iterator = this.blocks.iterator();
if (block.getMaterial() != Material.AIR)
{
if (block.a(this) && _dropItems)
{
block.dropNaturally(this._world, i, j, k, this._world.getData(i, j, k), size, 0);
}
while (iterator.hasNext())
{
ChunkPosition chunkposition = (ChunkPosition) iterator.next();
int i = chunkposition.x;
int j = chunkposition.y;
int k = chunkposition.z;
Block block = this._world.getType(i, j, k);
Block block1 = this._world.getType(i, j - 1, k);
this._world.setTypeAndData(i, j, k, Blocks.AIR, 0, 3);
block.wasExploded(this._world, i, j, k, this);
}
}
}
if ((block.getMaterial() == Material.AIR) && (block1.j()) && (new Random().nextInt(3) == 0))
{
if (!CraftEventFactory.callBlockIgniteEvent(this._world, i, j, k, this).isCancelled())
this._world.setTypeUpdate(i, j, k, Blocks.FIRE);
}
}
}
if (this._createFire)
{
Iterator iterator = this.blocks.iterator();
PacketPlayOutExplosion explosion = new PacketPlayOutExplosion(this.posX, this.posY, this.posZ, this.size,
new ArrayList(), null);
for (Player p : Bukkit.getOnlinePlayers())
((CraftPlayer) p).getHandle().playerConnection.sendPacket(explosion);
}
while (iterator.hasNext())
{
ChunkPosition chunkposition = (ChunkPosition) iterator.next();
int i = chunkposition.x;
int j = chunkposition.y;
int k = chunkposition.z;
Block block = this._world.getType(i, j, k);
Block block1 = this._world.getType(i, j - 1, k);
if ((block.getMaterial() == Material.AIR) && (block1.j()) && (new Random().nextInt(3) == 0))
{
if (!CraftEventFactory.callBlockIgniteEvent(this._world, i, j, k, this).isCancelled())
this._world.setTypeUpdate(i, j, k, Blocks.FIRE);
}
}
}
PacketPlayOutExplosion explosion = new PacketPlayOutExplosion(this.posX, this.posY, this.posZ, this.size,
new ArrayList(), null);
for (Player p : Bukkit.getOnlinePlayers())
((CraftPlayer) p).getHandle().playerConnection.sendPacket(explosion);
}
}

View File

@ -60,7 +60,7 @@ public class SpellHealingRune extends Spell implements SpellClick
firstTeleport.setY(firstTeleport.getBlockY());
HealingRune healingRune = new HealingRune(firstTeleport, getSpellLevel(player));
HealingRune healingRune = new HealingRune(Wizards, firstTeleport, getSpellLevel(player));
_healingRunes.add(healingRune);

View File

@ -4,8 +4,6 @@ import nautilus.game.arcade.game.games.wizards.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class SpellSpeedBoost extends Spell implements SpellClick
{
@ -15,7 +13,7 @@ public class SpellSpeedBoost extends Spell implements SpellClick
int ticks = 30 * getSpellLevel(p) * 20;
int potionLevel = getSpellLevel(p);
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, ticks, potionLevel), true);
Wizards.getArcadeManager().GetCondition().Factory().Speed("Speed Boost", p, p, ticks, potionLevel, false, false, false);
charge(p);
}

View File

@ -6,6 +6,7 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilShapes;
import nautilus.game.arcade.game.games.wizards.Wizards;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
@ -16,66 +17,68 @@ import org.bukkit.potion.PotionEffectType;
public class HealingRune
{
private Location _location;
private int _ticksToLive;
private double _runeSize;
private Location _location;
private int _ticksToLive;
private double _runeSize;
private Wizards _wizards;
public HealingRune(Location location, int spellLevel)
{
_location = location;
_ticksToLive = 100 + (spellLevel * 60);
_runeSize = 2 + (spellLevel * .5D);
}
public HealingRune(Wizards wizards, Location location, int spellLevel)
{
_location = location;
_ticksToLive = 100 + (spellLevel * 60);
_runeSize = 2 + (spellLevel * .5D);
_wizards = wizards;
}
public boolean onTick()
{
for (Player player : Bukkit.getOnlinePlayers())
{
if (player.getGameMode() == GameMode.CREATIVE)
{
continue;
}
public boolean onTick()
{
for (Player player : Bukkit.getOnlinePlayers())
{
if (player.getGameMode() == GameMode.CREATIVE)
{
continue;
}
Location loc = player.getLocation().clone();
Location loc = player.getLocation().clone();
if (loc.getY() >= _location.getY() && loc.getY() <= _location.getY() + 2)
{
loc.setY(_location.getY());
if (loc.getY() >= _location.getY() && loc.getY() <= _location.getY() + 2)
{
loc.setY(_location.getY());
if (loc.distance(_location) <= _runeSize)
{
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 50, 0));
}
}
}
if (loc.distance(_location) <= _runeSize)
{
_wizards.getArcadeManager().GetCondition().Factory().Regen("Healing Rune", player, null, 50, 0, false, false, true);
}
}
}
double currentY = 0;
ArrayList<Location> locs = UtilShapes.getDistancedCircle(_location, 0.2D, _runeSize);
double addY = 1.5D / locs.size();
double currentY = 0;
ArrayList<Location> locs = UtilShapes.getDistancedCircle(_location, 0.2D, _runeSize);
double addY = 1.5D / locs.size();
int a = UtilMath.r(locs.size());
for (int b = 0; b < 2; b++)
{
for (int i = 0; i < locs.size(); i++)
{
a++;
int a = UtilMath.r(locs.size());
for (int b = 0; b < 2; b++)
{
for (int i = 0; i < locs.size(); i++)
{
a++;
if (i % 30 == _ticksToLive % 30)
{
Location loc = locs.get(a % locs.size());
if (i % 30 == _ticksToLive % 30)
{
Location loc = locs.get(a % locs.size());
UtilParticle.PlayParticle(ParticleType.HEART, loc.clone().add(0, currentY, 0), 0, 0, 0, 0, 1);
}
UtilParticle.PlayParticle(ParticleType.HEART, loc.clone().add(0, currentY, 0), 0, 0, 0, 0, 1);
}
currentY += addY;
}
}
currentY += addY;
}
}
if (_ticksToLive-- <= 0)
{
return true;
}
if (_ticksToLive-- <= 0)
{
return true;
}
return false;
}
return false;
}
}