Iron Wizard, fixed iron golem custom name

This commit is contained in:
libraryaddict 2015-08-27 14:18:10 -07:00
parent 102fcd8e73
commit 9d3f125c9e
16 changed files with 813 additions and 276 deletions

View File

@ -238,9 +238,10 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
}
int newId = UtilEnt.getNewEntityId();
sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier);
_entityMap.get(owner.getName()).put(spawnPacket.a, newId);
sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier, true);
_entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName);
_entityMap.get(owner.getName()).put(spawnPacket.a, newId);
break;
}
@ -249,11 +250,11 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
else if (packet instanceof PacketPlayOutEntityMetadata)
{
PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata)packet;
if (!_entityMap.get(owner.getName()).containsKey(metaPacket.a) && metaPacket.a != 777777 && !_ignoreSkulls.contains(metaPacket.a))
if (metaPacket.a != 777777 && !_ignoreSkulls.contains(metaPacket.a))
{
String entityName = "";
boolean nameShowing = false;
boolean nameShowing = _entityMap.get(owner.getName()).containsKey(metaPacket.a);
for (WatchableObject watchable : (List<WatchableObject>)metaPacket.b)
{
@ -266,17 +267,33 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
entityName = (String)watchable.b();
}
}
if (nameShowing && !entityName.isEmpty())
if (!_entityMap.get(owner.getName()).containsKey(metaPacket.a)
|| !_entityMap.get(owner.getName()).get(metaPacket.a).equals(entityName))
{
int newId = UtilEnt.getNewEntityId();
sendProtocolPackets(owner, metaPacket.a, newId, entityName, verifier);
_entityMap.get(owner.getName()).put(metaPacket.a, newId);
_entityNameMap.get(owner.getName()).put(metaPacket.a, entityName);
}
else if (!entityName.isEmpty())
{
_entityNameMap.get(owner.getName()).remove(metaPacket.a);
if (nameShowing && !entityName.isEmpty())
{
int newId;
if (_entityMap.get(owner.getName()).containsKey(metaPacket.a))
{
newId = _entityMap.get(owner.getName()).get(metaPacket.a);
}
else
{
newId = UtilEnt.getNewEntityId();
}
sendProtocolPackets(owner, metaPacket.a, newId, entityName, verifier,
!_entityMap.get(owner.getName()).containsKey(metaPacket.a));
_entityNameMap.get(owner.getName()).put(metaPacket.a, entityName);
_entityMap.get(owner.getName()).put(metaPacket.a, newId);
}
else if (!entityName.isEmpty())
{
_entityNameMap.get(owner.getName()).remove(metaPacket.a);
}
}
}
}
@ -447,7 +464,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
}
}
private void sendProtocolPackets(final Player owner, final int entityId, final int newEntityId, String entityName, final PacketVerifier packetList)
private void sendProtocolPackets(final Player owner, final int entityId, final int newEntityId, final String entityName, final PacketVerifier packetList, final boolean newPacket)
{
CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName);
_plugin.getServer().getPluginManager().callEvent(event);
@ -457,105 +474,116 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{
public void run()
{
final PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = newEntityId;
packet.b = (byte) 30;
packet.c = (int)EnumEntitySize.SIZE_2.a(100);
packet.d = (int)MathHelper.floor(64 * 32.0D);
packet.e = (int)EnumEntitySize.SIZE_2.a(100);
packet.i = (byte) ((int) (0 * 256.0F / 360.0F));
packet.j = (byte) ((int) (0 * 256.0F / 360.0F));
packet.k = (byte) ((int) (0 * 256.0F / 360.0F));
final DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle()));
double var2 = 3.9D;
double var4 = 0;
double var6 = 0;
double var8 = 0;
if (var4 < -var2)
{
var4 = -var2;
}
if (var6 < -var2)
{
var6 = -var2;
}
if (var8 < -var2)
{
var8 = -var2;
}
if (var4 > var2)
{
var4 = var2;
}
if (var6 > var2)
{
var6 = var2;
}
if (var8 > var2)
{
var8 = var2;
}
packet.f = (int)(var4 * 8000.0D);
packet.g = (int)(var6 * 8000.0D);
packet.h = (int)(var8 * 8000.0D);
final DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld)owner.getWorld()).getHandle()));
watcher.a(0, Byte.valueOf((byte)0));
watcher.a(1, Short.valueOf((short)300));
watcher.a(0, Byte.valueOf((byte) 0));
watcher.a(1, Short.valueOf((short) 300));
watcher.a(2, "");
watcher.a(3, Byte.valueOf((byte) 0));
watcher.a(4, Byte.valueOf((byte)0));
watcher.a(4, Byte.valueOf((byte) 0));
watcher.a(7, Integer.valueOf(0));
watcher.a(8, Byte.valueOf((byte)0));
watcher.a(9, Byte.valueOf((byte)0));
watcher.a(8, Byte.valueOf((byte) 0));
watcher.a(9, Byte.valueOf((byte) 0));
watcher.a(6, Float.valueOf(1.0F));
watcher.a(10, Byte.valueOf((byte)0));
watcher.a(10, Byte.valueOf((byte) 0));
// Set invisible
int i1 = watcher.getInt(0);
watcher.watch(0, Byte.valueOf((byte)(i1 | 1 << 5)));
// Set small
byte b1 = watcher.getByte(10);
b1 = (byte)(b1 | 0x1);
watcher.watch(10, Byte.valueOf(b1));
int i1 = watcher.getInt(0);
watcher.watch(0, Byte.valueOf((byte) (i1 | 1 << 5)));
// Set small
byte b1 = watcher.getByte(10);
b1 = (byte) (b1 | 0x1);
watcher.watch(10, Byte.valueOf(b1));
watcher.watch(2, finalEntityName);
watcher.watch(3, Byte.valueOf((byte)1));
packet.l = watcher;
packetList.bypassProcess(packet);
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
vehiclePacket.b = packet.a;
vehiclePacket.c = entityId;
packetList.bypassProcess(vehiclePacket);
watcher.watch(3, Byte.valueOf((byte) 1));
if (newPacket)
{
final PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = newEntityId;
packet.b = (byte) 30;
packet.c = (int) EnumEntitySize.SIZE_2.a(100);
packet.d = (int) MathHelper.floor(64 * 32.0D);
packet.e = (int) EnumEntitySize.SIZE_2.a(100);
packet.i = (byte) ((int) (0 * 256.0F / 360.0F));
packet.j = (byte) ((int) (0 * 256.0F / 360.0F));
packet.k = (byte) ((int) (0 * 256.0F / 360.0F));
double var2 = 3.9D;
double var4 = 0;
double var6 = 0;
double var8 = 0;
if (var4 < -var2)
{
var4 = -var2;
}
if (var6 < -var2)
{
var6 = -var2;
}
if (var8 < -var2)
{
var8 = -var2;
}
if (var4 > var2)
{
var4 = var2;
}
if (var6 > var2)
{
var6 = var2;
}
if (var8 > var2)
{
var8 = var2;
}
packet.f = (int) (var4 * 8000.0D);
packet.g = (int) (var6 * 8000.0D);
packet.h = (int) (var8 * 8000.0D);
packet.l = watcher;
packetList.bypassProcess(packet);
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
vehiclePacket.b = packet.a;
vehiclePacket.c = entityId;
packetList.bypassProcess(vehiclePacket);
}
else
{
PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata();
entityMetadata.a = newEntityId;
entityMetadata.b = watcher.c();
packetList.bypassProcess(entityMetadata);
}
/* TODO dynamic attach handling?
if (_entityVehicleMap.get(owner).containsValue(entityId))
{
vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
for (Entry<Integer, Integer> entry : _entityVehicleMap.get(owner).entrySet())
{
if (entry.getValue() == entityId)
vehiclePacket.b = entry.getKey();
}
vehiclePacket.c = packet.a;
vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
for (Entry<Integer, Integer> entry : _entityVehicleMap.get(owner).entrySet())
{
if (entry.getValue() == entityId)
vehiclePacket.b = entry.getKey();
}
vehiclePacket.c = packet.a;
}
*/
}

View File

@ -3,6 +3,7 @@ package mineplex.minecraft.game.core.boss;
import java.util.UUID;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilMath;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
@ -49,6 +50,11 @@ public abstract class EventCreature<T extends LivingEntity> implements Listener
_maxHealth = health;
_showHealthName = true;
}
public double getDifficulty()
{
return getEvent().getDifficulty();
}
protected final void spawnEntity()
{
@ -85,8 +91,9 @@ public abstract class EventCreature<T extends LivingEntity> implements Listener
name += " " + C.cWhite + "(" + healthString + C.cWhite + ")";
}
_entity.setCustomName(name);
_entity.setCustomName( name);
_entity.setCustomNameVisible(_useName);
System.out.print(name);
}
public void remove()

View File

@ -54,6 +54,7 @@ public abstract class WorldEvent implements Listener
// Block Restore
private BlockRestoreMap _blocks;
private boolean _instantSchematic;
private double _difficulty = 1;
public WorldEvent(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, String name,
Location cornerLocation)
@ -93,6 +94,11 @@ public abstract class WorldEvent implements Listener
}
}
public void setDifficulty(double difficulty)
{
_difficulty = difficulty;
}
public void setInstantSchematic(boolean instantSchematic)
{
_instantSchematic = instantSchematic;
@ -110,6 +116,11 @@ public abstract class WorldEvent implements Listener
});
}
public double getDifficulty()
{
return _difficulty;
}
public void loadMap(Runnable runnable)
{
if (_schematic == null)
@ -121,6 +132,11 @@ public abstract class WorldEvent implements Listener
setMap(map, runnable);
}
public Schematic getSchematic()
{
return _schematic;
}
public ConditionManager getCondition()
{
return _conditionManager;
@ -267,8 +283,8 @@ public abstract class WorldEvent implements Listener
{
_map = map;
SchematicRunnable task = new SchematicRunnable(_damageManager.getPlugin(), map.getSchematic(),
_cornerLocation.getBlock(), new Callback<List<BlockData>>()
SchematicRunnable task = new SchematicRunnable(_damageManager.getPlugin(), map.getSchematic(), _cornerLocation.getBlock(),
new Callback<List<BlockData>>()
{
@Override
public void run(List<BlockData> data)

View File

@ -24,7 +24,7 @@ import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemCaveIn;
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemEarthquake;
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemExplodingAura;
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemMeleeAttack;
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemRumble;
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemRupture;
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemWallExplode;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
@ -62,23 +62,23 @@ public class GolemCreature extends EventCreature<IronGolem>
_preferedCombos.put(GolemEarthquake.class, new Class[]
{
GolemBlockHail.class, GolemRumble.class
GolemBlockHail.class, GolemRupture.class
});
_preferedCombos.put(GolemMeleeAttack.class, new Class[]
{
GolemEarthquake.class, GolemRumble.class
GolemEarthquake.class, GolemRupture.class
});
_preferedCombos.put(GolemCaveIn.class, new Class[]
{
GolemMeleeAttack.class
GolemMeleeAttack.class
});
_preferedCombos.put(GolemBlockShot.class, new Class[]
{
GolemEarthquake.class
GolemEarthquake.class
});
_preferedCombos.put(GolemRumble.class, new Class[]
_preferedCombos.put(GolemRupture.class, new Class[]
{
GolemBlockShot.class
GolemBlockShot.class
});
}
@ -147,7 +147,7 @@ public class GolemCreature extends EventCreature<IronGolem>
double hp = getHealthPercent();
{ // Melee
ArrayList<Player> players = getPlayers(dist, 2.5);
ArrayList<Player> players = getPlayers(dist, UtilMath.r(10) == 0 ? 4 : 3);
if (!players.isEmpty())
{
@ -202,11 +202,11 @@ public class GolemCreature extends EventCreature<IronGolem>
if (!players.isEmpty())
{
weight.put(GolemRumble.class, (int) Math.min(5, dist.get(players.get(0))));
weight.put(GolemRupture.class, (int) Math.min(5, dist.get(players.get(0))));
}
}
if (_canCaveIn <= 0)// Cave in
if (_canCaveIn <= 0) // Cave in
{
ArrayList<Player> players = getPlayers(dist, 30);
@ -368,6 +368,7 @@ public class GolemCreature extends EventCreature<IronGolem>
}
Vector vec = null;
boolean superWalk = false;
if (target != null)
{
@ -384,6 +385,7 @@ public class GolemCreature extends EventCreature<IronGolem>
if (target != null && dist < 8)
{
vec.multiply(-1);
superWalk = true;
}
if (!UtilAlg.HasSight(getEntity().getLocation(),
@ -425,7 +427,8 @@ public class GolemCreature extends EventCreature<IronGolem>
{
// if (vec.length() > 1)
{
UtilEnt.CreatureMoveFast(getEntity(), getEntity().getLocation().add(vec), target != null ? 1.5F : 1.1F);
UtilEnt.CreatureMoveFast(getEntity(), getEntity().getLocation().add(vec),
(target != null ? 1.8F : 1.1F) + (superWalk ? 0.4F : 0));
}
}
@ -492,7 +495,7 @@ public class GolemCreature extends EventCreature<IronGolem>
if (modifier > 0)
{
event.AddMod("Ranged Resistance", modifier);
event.AddMod("Ranged Resistance", 1 - modifier);
}
else
{

View File

@ -168,8 +168,8 @@ public class GolemBlockHail extends GolemAbility
net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle();
Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ
+ nmsEntity.motZ);
Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY,
nmsEntity.locZ + nmsEntity.motZ);
MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false);
vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
@ -180,8 +180,7 @@ public class GolemBlockHail extends GolemAbility
vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c);
}
for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities(
((CraftEntity) cur).getHandle(),
for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities(((CraftEntity) cur).getHandle(),
((CraftEntity) cur).getHandle().boundingBox.a(((CraftEntity) cur).getHandle().motX,
((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2)))
{
@ -222,17 +221,15 @@ public class GolemBlockHail extends GolemAbility
// if (canDamage(victim))
{
getGolem()
.getEvent()
.getDamageManager()
.NewDamageEvent((LivingEntity) victim, getEntity(), null, DamageCause.CONTACT, 6, true, true, false,
"Iron Wizard Block Hail", "Iron Wizard Block Hail");
getGolem().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null,
DamageCause.CONTACT, 6 * getGolem().getDifficulty(), true, true, false, "Iron Wizard Block Hail",
"Iron Wizard Block Hail");
}
if (victim instanceof Player)
{
getGolem().getEvent().getCondition().Factory()
.Slow("Iron Wizard Block Hail", (LivingEntity) victim, getEntity(), 3, 2, false, false, false, false);
getGolem().getEvent().getCondition().Factory().Slow("Iron Wizard Block Hail", (LivingEntity) victim,
getEntity(), 3, 2, false, false, false, false);
}
fallingIterator.remove();
@ -247,8 +244,8 @@ public class GolemBlockHail extends GolemAbility
nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX));
nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY));
nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ));
float f2 = MathHelper.sqrt(nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ
* nmsEntity.motZ);
float f2 = MathHelper.sqrt(
nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ * nmsEntity.motZ);
nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D;
nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D;
nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D;
@ -261,8 +258,9 @@ public class GolemBlockHail extends GolemAbility
}
else
{
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), cur.getLocation()
.add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers());
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0),
cur.getLocation().add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL,
UtilServer.getPlayers());
}
}
}
@ -306,11 +304,9 @@ public class GolemBlockHail extends GolemAbility
{
if (canDamage(player))
{
getGolem()
.getEvent()
.getDamageManager()
.NewDamageEvent(player, getEntity(), null, DamageCause.CONTACT, 6, true, true, false,
"Iron Wizard Protection", "Iron Wizard Protection");
getGolem().getEvent().getDamageManager().NewDamageEvent(player, getEntity(), null,
DamageCause.CONTACT, 6 * getGolem().getDifficulty(), true, true, false,
"Iron Wizard Protection", "Iron Wizard Protection");
loc.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, Material.OBSIDIAN.getId());
loc.getWorld().playEffect(player.getEyeLocation(), Effect.STEP_SOUND, Material.OBSIDIAN.getId());
@ -435,12 +431,10 @@ public class GolemBlockHail extends GolemAbility
FallingBlock b = loc.getWorld().spawnFallingBlock(loc, floatingBlock.getMaterial(), (byte) 0);
b.setDropItem(false);
Vector vec = UtilAlg.calculateVelocity(
loc.toVector(),
_target.getLocation()
.toVector()
.add(new Vector(UtilMath.r(6 + (_currentLevel * 2)) - (2 + _currentLevel), 0, UtilMath
.r(6 + (_currentLevel * 2)) - (2 + _currentLevel))), 6);
Vector vec = UtilAlg.calculateVelocity(loc.toVector(),
_target.getLocation().toVector().add(new Vector(UtilMath.r(6 + (_currentLevel * 2)) - (2 + _currentLevel), 0,
UtilMath.r(6 + (_currentLevel * 2)) - (2 + _currentLevel))),
6);
b.setVelocity(vec);

View File

@ -110,8 +110,8 @@ public class GolemCaveIn extends GolemAbility
net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle();
Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ
+ nmsEntity.motZ);
Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY,
nmsEntity.locZ + nmsEntity.motZ);
MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false);
vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
@ -122,8 +122,7 @@ public class GolemCaveIn extends GolemAbility
vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c);
}
for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities(
((CraftEntity) cur).getHandle(),
for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities(((CraftEntity) cur).getHandle(),
((CraftEntity) cur).getHandle().boundingBox.a(((CraftEntity) cur).getHandle().motX,
((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2)))
{
@ -164,11 +163,9 @@ public class GolemCaveIn extends GolemAbility
if (canDamage(victim))
{
getGolem()
.getEvent()
.getDamageManager()
.NewDamageEvent((LivingEntity) victim, getEntity(), null, DamageCause.CONTACT, 6, true, true, false,
"Iron Wizard Cave In", "Iron Wizard Cave In");
getGolem().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null,
DamageCause.CONTACT, 6 * getGolem().getDifficulty(), true, true, false, "Iron Wizard Cave In",
"Iron Wizard Cave In");
}
cur.remove();
@ -183,8 +180,8 @@ public class GolemCaveIn extends GolemAbility
nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX));
nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY));
nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ));
float f2 = MathHelper.sqrt(nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ
* nmsEntity.motZ);
float f2 = MathHelper.sqrt(
nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ * nmsEntity.motZ);
nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D;
nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D;
nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D;
@ -196,8 +193,9 @@ public class GolemCaveIn extends GolemAbility
}
else
{
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), cur.getLocation()
.add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers());
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0),
cur.getLocation().add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL,
UtilServer.getPlayers());
}
}
}
@ -244,9 +242,27 @@ public class GolemCaveIn extends GolemAbility
}
}
}
blocks = UtilShapes.getSphereBlocks(l, 3, 3, true);
for (Location loc : blocks)
{
if (loc.getBlockY() >= l.getBlockY())
{
Block b = loc.getBlock();
if (b.getType() == Material.AIR)
{
_blocks.add(b);
b.setType(Material.FENCE);
}
}
}
}
if (_tick % 5 == 0)
{
for (Player player : UtilPlayer.getNearby(getLocation(), 2.5, true))
{
@ -256,9 +272,10 @@ public class GolemCaveIn extends GolemAbility
}
if (_tick < 200)
{
Location loc = getLocation();
loc.setY(loc.getY() + 8);
loc.setY(loc.getY() + 4);
for (int i = 0; i < 30; i++)
{
@ -295,8 +312,8 @@ public class GolemCaveIn extends GolemAbility
dist = 10;
}
Location l = players.get(UtilMath.r(players.size())).getLocation()
.add(UtilMath.r(dist * 2) - dist, 0, UtilMath.r(dist * 2) - dist);
Location l = players.get(UtilMath.r(players.size())).getLocation().add(UtilMath.r(dist * 2) - dist, 0,
UtilMath.r(dist * 2) - dist);
l.setY(loc.getY());
Block b = l.getBlock();
@ -320,6 +337,7 @@ public class GolemCaveIn extends GolemAbility
}
}
}
}
@Override

View File

@ -96,9 +96,9 @@ public class GolemEarthquake extends GolemAbility
}
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.DIRT, 0),
_center.clone().add(x * range, 0.1, z * range), (x != 0) ? 0 : (range / 2), 0.1F, (z != 0) ? 0
: (range / 2), 0, (int) (range * 4), UtilParticle.ViewDist.NORMAL, UtilServer
.getPlayers());
_center.clone().add(x * range, 0.1, z * range), (x != 0) ? 0 : (range / 2), 0.1F,
(z != 0) ? 0 : (range / 2), 0, (int) (range * 4), UtilParticle.ViewDist.NORMAL,
UtilServer.getPlayers());
}
}
}
@ -138,14 +138,12 @@ public class GolemEarthquake extends GolemAbility
{
_damaged.add(player.getUniqueId());
getGolem()
.getEvent()
.getDamageManager()
.NewDamageEvent((LivingEntity) player, getEntity(), null, DamageCause.CONTACT, 12, false, true, false,
"Iron Wizard Earthquake", "Iron Wizard Earthquake");
getGolem().getEvent().getDamageManager().NewDamageEvent((LivingEntity) player, getEntity(), null,
DamageCause.CONTACT, 12 * getGolem().getDifficulty(), false, true, false, "Iron Wizard Earthquake",
"Iron Wizard Earthquake");
getGolem().getEvent().getCondition().Factory()
.Slow("Earthquake", (LivingEntity) player, getEntity(), 3, 1, false, false, false, false);
getGolem().getEvent().getCondition().Factory().Slow("Earthquake", (LivingEntity) player, getEntity(), 3, 1, false,
false, false, false);
// Velocity
UtilAction.velocity(player, UtilAlg.getTrajectory2d(getLocation().toVector(), player.getLocation().toVector()),

View File

@ -117,11 +117,8 @@ public class GolemExplodingAura extends GolemAbility
for (Player player : UtilPlayer.getNearby(getLocation(), 3, true))
{
getGolem()
.getEvent()
.getDamageManager()
.NewDamageEvent(player, getEntity(), null, DamageCause.CONTACT, 2, true, true, false,
"Iron Wizard Protection", "Iron Wizard Protection");
getGolem().getEvent().getDamageManager().NewDamageEvent(player, getEntity(), null, DamageCause.CONTACT,
2 * getGolem().getDifficulty(), true, true, false, "Iron Wizard Protection", "Iron Wizard Protection");
UtilAction.velocity(player, UtilAlg.getTrajectory(getEntity(), player), 1, true, 0.3, 0, 0.3, false);
}
}
@ -211,11 +208,11 @@ public class GolemExplodingAura extends GolemAbility
}
/*Iterator<Integer> itel = _blocksExplode.keySet().iterator();
while (itel.hasNext())
{
int key = itel.next();
if (_blocksExplode.get(key) < System.currentTimeMillis())
{
itel.remove();*/
@ -296,8 +293,8 @@ public class GolemExplodingAura extends GolemAbility
net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle();
Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ
+ nmsEntity.motZ);
Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY,
nmsEntity.locZ + nmsEntity.motZ);
MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false);
vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
@ -308,8 +305,7 @@ public class GolemExplodingAura extends GolemAbility
vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c);
}
for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities(
((CraftEntity) cur).getHandle(),
for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities(((CraftEntity) cur).getHandle(),
((CraftEntity) cur).getHandle().boundingBox.a(((CraftEntity) cur).getHandle().motX,
((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2)))
{
@ -350,20 +346,15 @@ public class GolemExplodingAura extends GolemAbility
// if (canDamage(victim))
{
getGolem()
.getEvent()
.getDamageManager()
.NewDamageEvent((LivingEntity) victim, getEntity(), null, DamageCause.CONTACT, 6, true, true, false,
"Blocky Iron Wizard Aura", "Blocky Iron Wizard Aura");
getGolem().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null,
DamageCause.CONTACT, 6 * getGolem().getDifficulty(), true, true, false, "Blocky Iron Wizard Aura",
"Blocky Iron Wizard Aura");
}
if (victim instanceof Player)
{
getGolem()
.getEvent()
.getCondition()
.Factory()
.Slow("Blocky Iron Wizard Aura", (LivingEntity) victim, getEntity(), 3, 2, false, false, false, false);
getGolem().getEvent().getCondition().Factory().Slow("Blocky Iron Wizard Aura", (LivingEntity) victim,
getEntity(), 3, 2, false, false, false, false);
}
fallingIterator.remove();
@ -390,8 +381,8 @@ public class GolemExplodingAura extends GolemAbility
nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX));
nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY));
nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ));
float f2 = MathHelper.sqrt(nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ
* nmsEntity.motZ);
float f2 = MathHelper.sqrt(
nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ * nmsEntity.motZ);
nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D;
nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D;
nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D;
@ -404,8 +395,9 @@ public class GolemExplodingAura extends GolemAbility
}
else
{
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), cur.getLocation()
.add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers());
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0),
cur.getLocation().add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL,
UtilServer.getPlayers());
}
}
}

View File

@ -36,7 +36,7 @@ public class GolemMeleeAttack extends GolemAbility
@Override
public Player getTarget()
{
return getTarget(2);
return getTarget(4);
}
@Override
@ -55,7 +55,7 @@ public class GolemMeleeAttack extends GolemAbility
{
_attacked = true;
for (Player target : UtilPlayer.getNearby(getLocation(), 2.5, true))
for (Player target : UtilPlayer.getNearby(getLocation(), 4, true))
{
if (target.getVelocity().length() > 0.5)
{
@ -64,17 +64,13 @@ public class GolemMeleeAttack extends GolemAbility
UtilEnt.CreatureLook(getEntity(), target);
getGolem()
.getEvent()
.getDamageManager()
.NewDamageEvent(target, getEntity(), null, DamageCause.ENTITY_ATTACK, 6, false, true, false,
"Iron Wizard Melee Attack", "Iron Wizard Melee Attack");
getGolem().getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.ENTITY_ATTACK,
6 * getGolem().getDifficulty(), false, true, false, "Iron Wizard Melee Attack", "Iron Wizard Melee Attack");
Vector vec = getLocation().getDirection();
vec.setY(0).normalize().multiply(0.2);
vec.setY(1);
vec.setY(0).normalize().setY(0.5).multiply(2.4);
UtilAction.velocity(target, vec, 1.4, false, 0, 0, 2, false);
UtilAction.velocity(target, vec);
getGolem().getEvent().getCondition().Factory().Falling("Iron Wizard Throw", target, getEntity(), 3, false, false);

View File

@ -185,19 +185,17 @@ public class GolemRumble extends GolemAbility
if (canDamage(entity))
{
getGolem()
.getEvent()
.getDamageManager()
.NewDamageEvent((LivingEntity) entity, getEntity(), null, DamageCause.CONTACT, 4, false, true,
false, "Iron Wizard Rumble", "Iron Wizard Rumble");
getGolem().getEvent().getDamageManager().NewDamageEvent((LivingEntity) entity, getEntity(), null,
DamageCause.CONTACT, 4 * getGolem().getDifficulty(), false, true, false, "Iron Wizard Rumble",
"Iron Wizard Rumble");
}
UtilAction.velocity(entity, _vec.clone(), 1.5, true, 0, 0.2, 1, true);
if (entity instanceof Player)
{
getGolem().getEvent().getCondition().Factory()
.Slow("Rumble", (LivingEntity) entity, getEntity(), 3, 1, false, false, false, false);
getGolem().getEvent().getCondition().Factory().Slow("Rumble", (LivingEntity) entity, getEntity(), 3, 1,
false, false, false, false);
}
}
}

View File

@ -0,0 +1,348 @@
package mineplex.minecraft.game.core.boss.ironwizard.abilities;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.common.util.UtilTime;
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
public class GolemRupture extends GolemAbility
{
private ArrayList<Entry<Location, Location>> _ruptures = new ArrayList<Entry<Location, Location>>();
private HashMap<Location, Long> _ruptureTime = new HashMap<Location, Long>();
private ArrayList<String> _targetted = new ArrayList<String>();
private int _rupturesLeft;
private int _tick;
private ArrayList<Item> _items = new ArrayList<Item>();
private int _ticksFinished;
public GolemRupture(GolemCreature creature)
{
super(creature);
if (creature.getHealthPercent() > 0.75)
{
_rupturesLeft = 2;
}
else if (creature.getHealthPercent() > 0.5)
{
_rupturesLeft = 5;
}
else
{
_rupturesLeft = 10;
}
}
@Override
public boolean canMove()
{
return false;
}
@EventHandler
public void HopperPickup(InventoryPickupItemEvent event)
{
if (_items.contains(event.getItem()))
event.setCancelled(true);
}
@EventHandler
public void ItemDestroy(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (_items.isEmpty())
return;
Iterator<Item> itemIterator = _items.iterator();
while (itemIterator.hasNext())
{
Item item = itemIterator.next();
if (item.isDead() || !item.isValid())
{
item.remove();
itemIterator.remove();
}
else if (UtilEnt.isGrounded(item) || item.getTicksLived() > 60)
{
item.getWorld().playEffect(item.getLocation(), Effect.STEP_SOUND, item.getItemStack().getTypeId());
item.remove();
itemIterator.remove();
}
}
}
@Override
public boolean inProgress()
{
return false;
}
@Override
public boolean hasFinished()
{
return _rupturesLeft <= 0 && _ruptures.isEmpty() && --_ticksFinished <= 0;
}
@Override
public void setFinished()
{
for (Item item : _items)
{
item.remove();
}
}
@Override
public void tick()
{
Iterator<Entry<Location, Location>> itel = _ruptures.iterator();
while (itel.hasNext())
{
Entry<Location, Location> entry = itel.next();
if (entry.getKey().distance(entry.getValue()) > 0)
{
Vector vec = entry.getValue().toVector().subtract(entry.getKey().toVector());
if (vec.length() > 1)
{
vec = vec.normalize();
}
entry.getKey().add(vec);
}
if (entry.getKey().distance(entry.getValue()) < 0.1)
{
if (!_ruptureTime.containsKey(entry.getKey()))
{
_ruptureTime.put(entry.getKey(), System.currentTimeMillis());
}
else if (UtilTime.elapsed(_ruptureTime.get(entry.getKey()), 150))
{
itel.remove();
explodeRupture(entry.getKey());
}
}
}
if (_tick % 10 == 0 && _rupturesLeft > 0)
{
_rupturesLeft--;
Location loc = getLocation().add(UtilMath.random.nextFloat() - 0.5, 0, UtilMath.random.nextFloat() - 0.5);
loc.setY(loc.getBlockY());
for (int y = 0; y > -3; y--)
{
if (!UtilBlock.airFoliage(loc.getBlock().getRelative(0, y, 0)))
{
loc.setY(loc.getY() + y);
break;
}
}
Player player = getTarget();
if (player != null)
{
_targetted.add(player.getName());
Location target = player.getLocation();
target.setY(loc.getY());
_ruptures.add(new HashMap.SimpleEntry(loc, target));
}
else
{
_rupturesLeft = 0;
}
}
for (Entry<Location, Location> entry : _ruptures)
{
entry.getKey().getWorld().playSound(entry.getKey(), Sound.DIG_GRAVEL, 2.5F, 0.9F);
// if (_tick % 3 == 0)
{
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.DIRT, 0),
entry.getKey().clone().add(0, 1.1, 0), 1F, 0, 1F, 0, 70, ViewDist.NORMAL, UtilServer.getPlayers());
}
}
_tick++;
}
@Override
public Player getTarget()
{
Player target = null;
double dist = 0;
for (Player player : UtilPlayer.getNearby(getLocation(), 30, true))
{
if (!player.hasLineOfSight(getEntity()))
{
continue;
}
if (_targetted.contains(player.getName()))
{
continue;
}
double d = player.getLocation().distance(getLocation());
if (d < 7)
{
continue;
}
boolean valid = true;
for (Entry<Location, Location> loc : _ruptures)
{
if (loc.getValue().distance(player.getLocation()) < 1.5)
{
valid = false;
break;
}
}
if (!valid)
{
continue;
}
if (target == null || dist > d)
{
target = player;
dist = d;
}
}
return target;
}
private void explodeRupture(Location loc)
{
loc.add(0, 1.1, 0);
loc.setX(loc.getBlockX() + 0.5);
loc.setZ(loc.getBlockZ() + 0.5);
// Fling
HashMap<LivingEntity, Double> targets = UtilEnt.getInRadius(loc, 3.5);
for (LivingEntity cur : targets.keySet())
{
// Velocity
UtilAction.velocity(cur,
UtilAlg.getTrajectory2d(loc.toVector().add(new Vector(0.5, 0, 0.5)), cur.getLocation().toVector()),
0.8 + 0.8 * targets.get(cur), true, 0, 0.4 + 1.0 * targets.get(cur), 1.4, true);
// Condition
getGolem().getEvent().getCondition().Factory().Falling("Rupture", cur, getEntity(), 10, false, true);
// Damage Event
getGolem().getEvent().getDamageManager().NewDamageEvent(cur, getEntity(), null, DamageCause.CUSTOM,
4 * getGolem().getDifficulty(), false, true, false, "Iron Wizard", "Rupture");
}
ArrayList<Block> blocks = new ArrayList<Block>();
for (int x = -3; x <= 3; x++)
{
for (int z = -3; z <= 3; z++)
{
for (int y = 0; y <= 1; y++)
{
for (int i = 0; i < 2; i++)
{
if (Math.sqrt(x * x + z * z + y * y) <= 3)
{
blocks.add(loc.clone().add(x, y, z).getBlock());
}
}
}
}
}
Collections.shuffle(blocks);
// Blocks
int done = 0;
Iterator<Block> itel = blocks.iterator();
while (done < 30 && itel.hasNext())
{
Block block = itel.next();
Vector vec = new Vector(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5).normalize();
if (!UtilBlock.airFoliage(block))
continue;
// Add Directional
vec.add(UtilAlg.getTrajectory(loc.getBlock().getLocation(), block.getLocation().add(0.5, 0, 0.5)));
// Add Up
vec.add(new Vector(0, 1.6, 0));
vec.normalize();
// Scale
vec.multiply(0.1 + 0.3 * Math.random() + 0.6);
// Block!
Item item = loc.getWorld().dropItem(block.getLocation().add(0.5, 0, 0.5), new ItemStack(Material.DIRT.getId(), 0));
item.setVelocity(vec);
item.setPickupDelay(50000);
_items.add(item);
// Effect
loc.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.DIRT.getId());
done++;
}
_ticksFinished = 20;
}
}

View File

@ -139,8 +139,8 @@ public class GolemWallExplode extends GolemAbility
net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle();
Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ
+ nmsEntity.motZ);
Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY,
nmsEntity.locZ + nmsEntity.motZ);
MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false);
vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
@ -151,8 +151,7 @@ public class GolemWallExplode extends GolemAbility
vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c);
}
for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities(
((CraftEntity) cur).getHandle(),
for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities(((CraftEntity) cur).getHandle(),
((CraftEntity) cur).getHandle().boundingBox.a(((CraftEntity) cur).getHandle().motX,
((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2)))
{
@ -193,11 +192,9 @@ public class GolemWallExplode extends GolemAbility
if (canDamage(victim))
{
getGolem()
.getEvent()
.getDamageManager()
.NewDamageEvent((LivingEntity) victim, getEntity(), null, DamageCause.CONTACT, 6, true, true, false,
"Iron Wizard Wall Explosion", "Iron Wizard Wall Explosion");
getGolem().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null,
DamageCause.CONTACT, 6 * getGolem().getDifficulty(), true, true, false, "Iron Wizard Wall Explosion",
"Iron Wizard Wall Explosion");
}
cur.remove();
@ -216,8 +213,8 @@ public class GolemWallExplode extends GolemAbility
nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX));
nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY));
nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ));
float f2 = MathHelper.sqrt(nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ
* nmsEntity.motZ);
float f2 = MathHelper.sqrt(
nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ * nmsEntity.motZ);
nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D;
nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D;
nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D;
@ -229,8 +226,9 @@ public class GolemWallExplode extends GolemAbility
}
else
{
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), cur.getLocation()
.add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers());
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0),
cur.getLocation().add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL,
UtilServer.getPlayers());
}
}
}

View File

@ -7,10 +7,13 @@ import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.common.util.UtilWorld;
@ -34,8 +37,8 @@ import nautilus.game.arcade.kit.Kit;
public class BossBattles extends TeamGame
{
private WorldEvent _currentBoss;
private BattleBoss _chosenBoss = BattleBoss.values()[UtilMath.r(BattleBoss
.values().length)];
private BattleBoss _chosenBoss = BattleBoss.values()[UtilMath
.r(BattleBoss.values().length)];
private ArrayList<BossDisplay> _displays = new ArrayList<BossDisplay>();
public BossBattles(ArcadeManager manager)
@ -47,7 +50,7 @@ public class BossBattles extends TeamGame
new KitAssassin(manager),
}, new String[]
{
"Fight some bosses"
"Fight some bosses"
});
}
@ -114,24 +117,6 @@ public class BossBattles extends TeamGame
// If the event was cancelled, we don't need to run a cleanup
if (_currentBoss.getState() == EventState.COMPLETE)
_currentBoss.cleanup();
_currentBoss = null;
Damage = false;
SpectatorSpawn = UtilWorld.averageLocation(GetTeamList().get(0)
.GetSpawns());
for (Player player : GetPlayers(false))
{
if (!IsAlive(player))
{
RespawnPlayer(player);
}
else
{
player.teleport(GetTeamList().get(0).GetSpawn());
}
}
}
public void setPicked(Player player, BattleBoss battleBoss)
@ -170,11 +155,64 @@ public class BossBattles extends TeamGame
for (BossDisplay display : _displays)
{
HandlerList.unregisterAll(display);
display.removeHologram();
display.removeBoss();
}
_displays.clear();
}
@EventHandler(priority = EventPriority.HIGH)
public void onPrepare(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Prepare)
{
return;
}
double distAway = Math.max(_currentBoss.getSchematic().getWidth(),
_currentBoss.getSchematic().getLength()) / 2;
distAway += Math.min(20, distAway * 0.2);
for (Location loc : GetTeamList().get(0).GetSpawns())
{
double maxDist = loc.toVector().setY(0).length();
Vector vec = UtilAlg.getTrajectory2d(new Vector(), loc.toVector());
loc.setX(0);
loc.setZ(0);
loc.add(vec.multiply(Math.min(maxDist, distAway)));
vec.normalize().multiply(-1);
boolean foundSafe = false;
for (int i = 0; i < 50; i++)
{
for (int y = 200; y > 0; y--)
{
loc.setY(y);
if (UtilBlock.solid(loc.getBlock().getRelative(0, -1, 0)))
{
foundSafe = true;
break;
}
}
if (foundSafe)
{
break;
}
loc.add(vec);
}
}
}
@EventHandler
public void onGamePrepare(GameStateChangeEvent event)
{
@ -194,8 +232,8 @@ public class BossBattles extends TeamGame
{
Location loc = locations.get(i).clone();
loc.setDirection(UtilAlg.getTrajectory(loc, Manager.GetLobby()
.GetSpawn()));
loc.setDirection(UtilAlg.getTrajectory(loc,
Manager.GetLobby().GetSpawn()));
Constructor<? extends BossDisplay> constructor = boss
.getBossDisplay().getConstructor(BossBattles.class,
@ -208,9 +246,10 @@ public class BossBattles extends TeamGame
getArcadeManager().getPlugin());
bossDisplay.start();
bossDisplay.spawnHologram();
System.out.print("Registered "
+ bossDisplay.getClass().getSimpleName());
System.out.print(
"Registered " + bossDisplay.getClass().getSimpleName());
}
catch (Exception e)
{
@ -261,17 +300,17 @@ public class BossBattles extends TeamGame
if (clazz != SlimeBoss.class)
{
worldEvent = (WorldEvent) con.newInstance(
getArcadeManager().GetDamage(), getArcadeManager()
.GetBlockRestore(), getArcadeManager()
.GetCondition(), centerLocation);
getArcadeManager().GetDamage(),
getArcadeManager().GetBlockRestore(),
getArcadeManager().GetCondition(), centerLocation);
}
else
{
worldEvent = (WorldEvent) con.newInstance(
getArcadeManager().GetDamage(), getArcadeManager()
.GetBlockRestore(), getArcadeManager()
.GetCondition(), getArcadeManager()
.GetProjectile(), centerLocation);
getArcadeManager().GetDamage(),
getArcadeManager().GetBlockRestore(),
getArcadeManager().GetCondition(),
getArcadeManager().GetProjectile(), centerLocation);
}
}
}
@ -285,10 +324,11 @@ public class BossBattles extends TeamGame
private void setNewBoss(BattleBoss boss)
{
_currentBoss = createInstance(boss.getBoss(), new Location(
WorldData.World, 0, 6, 0));
_currentBoss = createInstance(boss.getBoss(),
new Location(WorldData.World, 0, 6, 0));
_currentBoss.setInstantSchematic(true);
_currentBoss.setDifficulty(0.6);
_currentBoss.loadMap();
}

View File

@ -3,15 +3,26 @@ package nautilus.game.arcade.game.games.bossbattles.displays;
import nautilus.game.arcade.game.games.bossbattles.BattleBoss;
import nautilus.game.arcade.game.games.bossbattles.BossBattles;
import java.util.ArrayList;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.hologram.Hologram;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public abstract class BossDisplay implements Listener
{
private Location _bossLocation;
protected BossBattles Plugin;
private BattleBoss _boss;
private Hologram _hologram;
private ArrayList<Entity> _entities = new ArrayList<Entity>();
public BossDisplay(BossBattles plugin, BattleBoss boss, Location location)
{
@ -20,6 +31,37 @@ public abstract class BossDisplay implements Listener
_bossLocation = location;
}
public void addEntity(Entity entity)
{
_entities.add(entity);
}
@EventHandler
public void preventMovement(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
{
return;
}
for (Entity entity : _entities)
{
Location loc = entity.getLocation();
if (loc.distance(_bossLocation) > 0.1)
{
loc = _bossLocation.clone();
loc.setY(entity.getLocation().getY());
loc.setDirection(
UtilAlg.getTrajectory2d(entity.getLocation(), loc));
entity.teleport(loc);
}
}
}
public abstract String getDisplayName();
public Location getLocation()
{
return _bossLocation;
@ -30,8 +72,33 @@ public abstract class BossDisplay implements Listener
Plugin.setPicked(player, _boss);
}
public abstract void removeBoss();
public void removeBoss()
{
for (Entity entity : _entities)
{
entity.remove();
}
}
public abstract void start();
public void spawnHologram()
{
_hologram = new Hologram(Plugin.getArcadeManager().getHologramManager(),
getHologramLocation(), getDisplayName());
_hologram.start();
}
public Hologram getHologram()
{
return _hologram;
}
public void removeHologram()
{
_hologram.stop();
}
public abstract Location getHologramLocation();
}

View File

@ -1,5 +1,6 @@
package nautilus.game.arcade.game.games.bossbattles.displays;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEnt;
import nautilus.game.arcade.game.games.bossbattles.BattleBoss;
import nautilus.game.arcade.game.games.bossbattles.BossBattles;
@ -31,23 +32,39 @@ public class IronWizardDisplay extends BossDisplay
setChosen(event.getPlayer());
}
@Override
public void removeBoss()
{
_golem.remove();
}
@Override
public void start()
{
Plugin.CreatureAllowOverride = true;
_golem = (IronGolem) getLocation().getWorld().spawnEntity(
getLocation(), EntityType.IRON_GOLEM);
_golem = (IronGolem) getLocation().getWorld().spawnEntity(getLocation(),
EntityType.IRON_GOLEM);
_golem.teleport(getLocation());
UtilEnt.Vegetate(_golem);
Plugin.CreatureAllowOverride = false;
addEntity(_golem);
}
@Override
public String getDisplayName()
{
return C.cGray + "Iron Wizard";
}
@Override
public Location getHologramLocation()
{
return _golem.getEyeLocation().add(0, 0.3, 0);
}
@Override
public void spawnHologram()
{
super.spawnHologram();
getHologram().setFollowEntity(_golem);
}
}

View File

@ -1,5 +1,6 @@
package nautilus.game.arcade.game.games.bossbattles.displays;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEnt;
import nautilus.game.arcade.game.games.bossbattles.BattleBoss;
import nautilus.game.arcade.game.games.bossbattles.BossBattles;
@ -32,12 +33,6 @@ public class SlimeKingDisplay extends BossDisplay
setChosen(event.getPlayer());
}
@Override
public void removeBoss()
{
_slime.remove();
}
@Override
public void start()
{
@ -52,6 +47,28 @@ public class SlimeKingDisplay extends BossDisplay
UtilEnt.Vegetate(_slime);
Plugin.CreatureAllowOverride = false;
addEntity(_slime);
}
@Override
public String getDisplayName()
{
return C.cDGreen + "Slime King";
}
@Override
public void spawnHologram()
{
super.spawnHologram();
getHologram().setFollowEntity(_slime);
}
@Override
public Location getHologramLocation()
{
return _slime.getEyeLocation().add(0, 0.1, 0);
}
}