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(); int newId = UtilEnt.getNewEntityId();
sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier); sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier, true);
_entityMap.get(owner.getName()).put(spawnPacket.a, newId);
_entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName); _entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName);
_entityMap.get(owner.getName()).put(spawnPacket.a, newId);
break; break;
} }
@ -250,10 +251,10 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata)packet; 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 = ""; String entityName = "";
boolean nameShowing = false; boolean nameShowing = _entityMap.get(owner.getName()).containsKey(metaPacket.a);
for (WatchableObject watchable : (List<WatchableObject>)metaPacket.b) for (WatchableObject watchable : (List<WatchableObject>)metaPacket.b)
{ {
@ -267,16 +268,32 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
} }
} }
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(); if (nameShowing && !entityName.isEmpty())
sendProtocolPackets(owner, metaPacket.a, newId, entityName, verifier); {
_entityMap.get(owner.getName()).put(metaPacket.a, newId); int newId;
_entityNameMap.get(owner.getName()).put(metaPacket.a, entityName);
} if (_entityMap.get(owner.getName()).containsKey(metaPacket.a))
else if (!entityName.isEmpty()) {
{ newId = _entityMap.get(owner.getName()).get(metaPacket.a);
_entityNameMap.get(owner.getName()).remove(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); CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName);
_plugin.getServer().getPluginManager().callEvent(event); _plugin.getServer().getPluginManager().callEvent(event);
@ -457,105 +474,116 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
public void run() public void run()
{ {
final PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); final DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle()));
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; watcher.a(0, Byte.valueOf((byte) 0));
double var4 = 0; watcher.a(1, Short.valueOf((short) 300));
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(2, ""); watcher.a(2, "");
watcher.a(3, Byte.valueOf((byte) 0)); 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(7, Integer.valueOf(0));
watcher.a(8, Byte.valueOf((byte)0)); watcher.a(8, Byte.valueOf((byte) 0));
watcher.a(9, Byte.valueOf((byte)0)); watcher.a(9, Byte.valueOf((byte) 0));
watcher.a(6, Float.valueOf(1.0F)); watcher.a(6, Float.valueOf(1.0F));
watcher.a(10, Byte.valueOf((byte)0)); watcher.a(10, Byte.valueOf((byte) 0));
// Set invisible // Set invisible
int i1 = watcher.getInt(0); int i1 = watcher.getInt(0);
watcher.watch(0, Byte.valueOf((byte)(i1 | 1 << 5))); watcher.watch(0, Byte.valueOf((byte) (i1 | 1 << 5)));
// Set small // Set small
byte b1 = watcher.getByte(10); byte b1 = watcher.getByte(10);
b1 = (byte)(b1 | 0x1); b1 = (byte) (b1 | 0x1);
watcher.watch(10, Byte.valueOf(b1)); watcher.watch(10, Byte.valueOf(b1));
watcher.watch(2, finalEntityName); watcher.watch(2, finalEntityName);
watcher.watch(3, Byte.valueOf((byte)1)); watcher.watch(3, Byte.valueOf((byte) 1));
packet.l = watcher; 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));
packetList.bypassProcess(packet); double var2 = 3.9D;
double var4 = 0;
double var6 = 0;
double var8 = 0;
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity(); if (var4 < -var2)
vehiclePacket.a = 0; {
vehiclePacket.b = packet.a; var4 = -var2;
vehiclePacket.c = entityId; }
packetList.bypassProcess(vehiclePacket); 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? /* TODO dynamic attach handling?
if (_entityVehicleMap.get(owner).containsValue(entityId)) if (_entityVehicleMap.get(owner).containsValue(entityId))
{ {
vehiclePacket = new PacketPlayOutAttachEntity(); vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0; vehiclePacket.a = 0;
for (Entry<Integer, Integer> entry : _entityVehicleMap.get(owner).entrySet()) for (Entry<Integer, Integer> entry : _entityVehicleMap.get(owner).entrySet())
{ {
if (entry.getValue() == entityId) if (entry.getValue() == entityId)
vehiclePacket.b = entry.getKey(); vehiclePacket.b = entry.getKey();
} }
vehiclePacket.c = packet.a; vehiclePacket.c = packet.a;
} }
*/ */
} }

View File

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

View File

@ -54,6 +54,7 @@ public abstract class WorldEvent implements Listener
// Block Restore // Block Restore
private BlockRestoreMap _blocks; private BlockRestoreMap _blocks;
private boolean _instantSchematic; private boolean _instantSchematic;
private double _difficulty = 1;
public WorldEvent(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, String name, public WorldEvent(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, String name,
Location cornerLocation) Location cornerLocation)
@ -93,6 +94,11 @@ public abstract class WorldEvent implements Listener
} }
} }
public void setDifficulty(double difficulty)
{
_difficulty = difficulty;
}
public void setInstantSchematic(boolean instantSchematic) public void setInstantSchematic(boolean instantSchematic)
{ {
_instantSchematic = instantSchematic; _instantSchematic = instantSchematic;
@ -110,6 +116,11 @@ public abstract class WorldEvent implements Listener
}); });
} }
public double getDifficulty()
{
return _difficulty;
}
public void loadMap(Runnable runnable) public void loadMap(Runnable runnable)
{ {
if (_schematic == null) if (_schematic == null)
@ -121,6 +132,11 @@ public abstract class WorldEvent implements Listener
setMap(map, runnable); setMap(map, runnable);
} }
public Schematic getSchematic()
{
return _schematic;
}
public ConditionManager getCondition() public ConditionManager getCondition()
{ {
return _conditionManager; return _conditionManager;
@ -267,8 +283,8 @@ public abstract class WorldEvent implements Listener
{ {
_map = map; _map = map;
SchematicRunnable task = new SchematicRunnable(_damageManager.getPlugin(), map.getSchematic(), SchematicRunnable task = new SchematicRunnable(_damageManager.getPlugin(), map.getSchematic(), _cornerLocation.getBlock(),
_cornerLocation.getBlock(), new Callback<List<BlockData>>() new Callback<List<BlockData>>()
{ {
@Override @Override
public void run(List<BlockData> data) 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.GolemEarthquake;
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemExplodingAura; 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.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.boss.ironwizard.abilities.GolemWallExplode;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
@ -62,23 +62,23 @@ public class GolemCreature extends EventCreature<IronGolem>
_preferedCombos.put(GolemEarthquake.class, new Class[] _preferedCombos.put(GolemEarthquake.class, new Class[]
{ {
GolemBlockHail.class, GolemRumble.class GolemBlockHail.class, GolemRupture.class
}); });
_preferedCombos.put(GolemMeleeAttack.class, new Class[] _preferedCombos.put(GolemMeleeAttack.class, new Class[]
{ {
GolemEarthquake.class, GolemRumble.class GolemEarthquake.class, GolemRupture.class
}); });
_preferedCombos.put(GolemCaveIn.class, new Class[] _preferedCombos.put(GolemCaveIn.class, new Class[]
{ {
GolemMeleeAttack.class GolemMeleeAttack.class
}); });
_preferedCombos.put(GolemBlockShot.class, new 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(); double hp = getHealthPercent();
{ // Melee { // Melee
ArrayList<Player> players = getPlayers(dist, 2.5); ArrayList<Player> players = getPlayers(dist, UtilMath.r(10) == 0 ? 4 : 3);
if (!players.isEmpty()) if (!players.isEmpty())
{ {
@ -202,11 +202,11 @@ public class GolemCreature extends EventCreature<IronGolem>
if (!players.isEmpty()) 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); ArrayList<Player> players = getPlayers(dist, 30);
@ -368,6 +368,7 @@ public class GolemCreature extends EventCreature<IronGolem>
} }
Vector vec = null; Vector vec = null;
boolean superWalk = false;
if (target != null) if (target != null)
{ {
@ -384,6 +385,7 @@ public class GolemCreature extends EventCreature<IronGolem>
if (target != null && dist < 8) if (target != null && dist < 8)
{ {
vec.multiply(-1); vec.multiply(-1);
superWalk = true;
} }
if (!UtilAlg.HasSight(getEntity().getLocation(), if (!UtilAlg.HasSight(getEntity().getLocation(),
@ -425,7 +427,8 @@ public class GolemCreature extends EventCreature<IronGolem>
{ {
// if (vec.length() > 1) // 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) if (modifier > 0)
{ {
event.AddMod("Ranged Resistance", modifier); event.AddMod("Ranged Resistance", 1 - modifier);
} }
else else
{ {

View File

@ -168,8 +168,8 @@ public class GolemBlockHail extends GolemAbility
net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle(); net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle();
Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY,
+ nmsEntity.motZ); nmsEntity.locZ + nmsEntity.motZ);
MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false); MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false);
vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); 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); vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c);
} }
for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities( for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities(((CraftEntity) cur).getHandle(),
((CraftEntity) cur).getHandle(),
((CraftEntity) cur).getHandle().boundingBox.a(((CraftEntity) cur).getHandle().motX, ((CraftEntity) cur).getHandle().boundingBox.a(((CraftEntity) cur).getHandle().motX,
((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2))) ((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2)))
{ {
@ -222,17 +221,15 @@ public class GolemBlockHail extends GolemAbility
// if (canDamage(victim)) // if (canDamage(victim))
{ {
getGolem() getGolem().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null,
.getEvent() DamageCause.CONTACT, 6 * getGolem().getDifficulty(), true, true, false, "Iron Wizard Block Hail",
.getDamageManager() "Iron Wizard Block Hail");
.NewDamageEvent((LivingEntity) victim, getEntity(), null, DamageCause.CONTACT, 6, true, true, false,
"Iron Wizard Block Hail", "Iron Wizard Block Hail");
} }
if (victim instanceof Player) if (victim instanceof Player)
{ {
getGolem().getEvent().getCondition().Factory() getGolem().getEvent().getCondition().Factory().Slow("Iron Wizard Block Hail", (LivingEntity) victim,
.Slow("Iron Wizard Block Hail", (LivingEntity) victim, getEntity(), 3, 2, false, false, false, false); getEntity(), 3, 2, false, false, false, false);
} }
fallingIterator.remove(); fallingIterator.remove();
@ -247,8 +244,8 @@ public class GolemBlockHail extends GolemAbility
nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX)); nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX));
nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY)); nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY));
nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ)); nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ));
float f2 = MathHelper.sqrt(nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ float f2 = MathHelper.sqrt(
* nmsEntity.motZ); nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ * nmsEntity.motZ);
nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D; nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D;
nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D; nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D;
nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D; nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D;
@ -261,8 +258,9 @@ public class GolemBlockHail extends GolemAbility
} }
else else
{ {
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), cur.getLocation() UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0),
.add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers()); 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)) if (canDamage(player))
{ {
getGolem() getGolem().getEvent().getDamageManager().NewDamageEvent(player, getEntity(), null,
.getEvent() DamageCause.CONTACT, 6 * getGolem().getDifficulty(), true, true, false,
.getDamageManager() "Iron Wizard Protection", "Iron Wizard Protection");
.NewDamageEvent(player, getEntity(), null, DamageCause.CONTACT, 6, true, true, false,
"Iron Wizard Protection", "Iron Wizard Protection");
loc.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, Material.OBSIDIAN.getId()); loc.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, Material.OBSIDIAN.getId());
loc.getWorld().playEffect(player.getEyeLocation(), 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); FallingBlock b = loc.getWorld().spawnFallingBlock(loc, floatingBlock.getMaterial(), (byte) 0);
b.setDropItem(false); b.setDropItem(false);
Vector vec = UtilAlg.calculateVelocity( Vector vec = UtilAlg.calculateVelocity(loc.toVector(),
loc.toVector(), _target.getLocation().toVector().add(new Vector(UtilMath.r(6 + (_currentLevel * 2)) - (2 + _currentLevel), 0,
_target.getLocation() UtilMath.r(6 + (_currentLevel * 2)) - (2 + _currentLevel))),
.toVector() 6);
.add(new Vector(UtilMath.r(6 + (_currentLevel * 2)) - (2 + _currentLevel), 0, UtilMath
.r(6 + (_currentLevel * 2)) - (2 + _currentLevel))), 6);
b.setVelocity(vec); 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(); net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle();
Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY,
+ nmsEntity.motZ); nmsEntity.locZ + nmsEntity.motZ);
MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false); MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false);
vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); 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); vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c);
} }
for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities( for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities(((CraftEntity) cur).getHandle(),
((CraftEntity) cur).getHandle(),
((CraftEntity) cur).getHandle().boundingBox.a(((CraftEntity) cur).getHandle().motX, ((CraftEntity) cur).getHandle().boundingBox.a(((CraftEntity) cur).getHandle().motX,
((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2))) ((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2)))
{ {
@ -164,11 +163,9 @@ public class GolemCaveIn extends GolemAbility
if (canDamage(victim)) if (canDamage(victim))
{ {
getGolem() getGolem().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null,
.getEvent() DamageCause.CONTACT, 6 * getGolem().getDifficulty(), true, true, false, "Iron Wizard Cave In",
.getDamageManager() "Iron Wizard Cave In");
.NewDamageEvent((LivingEntity) victim, getEntity(), null, DamageCause.CONTACT, 6, true, true, false,
"Iron Wizard Cave In", "Iron Wizard Cave In");
} }
cur.remove(); cur.remove();
@ -183,8 +180,8 @@ public class GolemCaveIn extends GolemAbility
nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX)); nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX));
nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY)); nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY));
nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ)); nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ));
float f2 = MathHelper.sqrt(nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ float f2 = MathHelper.sqrt(
* nmsEntity.motZ); nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ * nmsEntity.motZ);
nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D; nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D;
nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D; nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D;
nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D; nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D;
@ -196,8 +193,9 @@ public class GolemCaveIn extends GolemAbility
} }
else else
{ {
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), cur.getLocation() UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0),
.add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers()); 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) if (_tick % 5 == 0)
{ {
for (Player player : UtilPlayer.getNearby(getLocation(), 2.5, true)) for (Player player : UtilPlayer.getNearby(getLocation(), 2.5, true))
{ {
@ -256,9 +272,10 @@ public class GolemCaveIn extends GolemAbility
} }
if (_tick < 200) if (_tick < 200)
{ {
Location loc = getLocation(); Location loc = getLocation();
loc.setY(loc.getY() + 8); loc.setY(loc.getY() + 4);
for (int i = 0; i < 30; i++) for (int i = 0; i < 30; i++)
{ {
@ -295,8 +312,8 @@ public class GolemCaveIn extends GolemAbility
dist = 10; dist = 10;
} }
Location l = players.get(UtilMath.r(players.size())).getLocation() Location l = players.get(UtilMath.r(players.size())).getLocation().add(UtilMath.r(dist * 2) - dist, 0,
.add(UtilMath.r(dist * 2) - dist, 0, UtilMath.r(dist * 2) - dist); UtilMath.r(dist * 2) - dist);
l.setY(loc.getY()); l.setY(loc.getY());
Block b = l.getBlock(); Block b = l.getBlock();
@ -320,6 +337,7 @@ public class GolemCaveIn extends GolemAbility
} }
} }
} }
} }
@Override @Override

View File

@ -96,9 +96,9 @@ public class GolemEarthquake extends GolemAbility
} }
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.DIRT, 0), 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 _center.clone().add(x * range, 0.1, z * range), (x != 0) ? 0 : (range / 2), 0.1F,
: (range / 2), 0, (int) (range * 4), UtilParticle.ViewDist.NORMAL, UtilServer (z != 0) ? 0 : (range / 2), 0, (int) (range * 4), UtilParticle.ViewDist.NORMAL,
.getPlayers()); UtilServer.getPlayers());
} }
} }
} }
@ -138,14 +138,12 @@ public class GolemEarthquake extends GolemAbility
{ {
_damaged.add(player.getUniqueId()); _damaged.add(player.getUniqueId());
getGolem() getGolem().getEvent().getDamageManager().NewDamageEvent((LivingEntity) player, getEntity(), null,
.getEvent() DamageCause.CONTACT, 12 * getGolem().getDifficulty(), false, true, false, "Iron Wizard Earthquake",
.getDamageManager() "Iron Wizard Earthquake");
.NewDamageEvent((LivingEntity) player, getEntity(), null, DamageCause.CONTACT, 12, false, true, false,
"Iron Wizard Earthquake", "Iron Wizard Earthquake");
getGolem().getEvent().getCondition().Factory() getGolem().getEvent().getCondition().Factory().Slow("Earthquake", (LivingEntity) player, getEntity(), 3, 1, false,
.Slow("Earthquake", (LivingEntity) player, getEntity(), 3, 1, false, false, false, false); false, false, false);
// Velocity // Velocity
UtilAction.velocity(player, UtilAlg.getTrajectory2d(getLocation().toVector(), player.getLocation().toVector()), 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)) for (Player player : UtilPlayer.getNearby(getLocation(), 3, true))
{ {
getGolem() getGolem().getEvent().getDamageManager().NewDamageEvent(player, getEntity(), null, DamageCause.CONTACT,
.getEvent() 2 * getGolem().getDifficulty(), true, true, false, "Iron Wizard Protection", "Iron Wizard Protection");
.getDamageManager()
.NewDamageEvent(player, getEntity(), null, DamageCause.CONTACT, 2, true, true, false,
"Iron Wizard Protection", "Iron Wizard Protection");
UtilAction.velocity(player, UtilAlg.getTrajectory(getEntity(), player), 1, true, 0.3, 0, 0.3, false); UtilAction.velocity(player, UtilAlg.getTrajectory(getEntity(), player), 1, true, 0.3, 0, 0.3, false);
} }
} }
@ -296,8 +293,8 @@ public class GolemExplodingAura extends GolemAbility
net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle(); net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle();
Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY,
+ nmsEntity.motZ); nmsEntity.locZ + nmsEntity.motZ);
MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false); MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false);
vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); 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); vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c);
} }
for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities( for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities(((CraftEntity) cur).getHandle(),
((CraftEntity) cur).getHandle(),
((CraftEntity) cur).getHandle().boundingBox.a(((CraftEntity) cur).getHandle().motX, ((CraftEntity) cur).getHandle().boundingBox.a(((CraftEntity) cur).getHandle().motX,
((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2))) ((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2)))
{ {
@ -350,20 +346,15 @@ public class GolemExplodingAura extends GolemAbility
// if (canDamage(victim)) // if (canDamage(victim))
{ {
getGolem() getGolem().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null,
.getEvent() DamageCause.CONTACT, 6 * getGolem().getDifficulty(), true, true, false, "Blocky Iron Wizard Aura",
.getDamageManager() "Blocky Iron Wizard Aura");
.NewDamageEvent((LivingEntity) victim, getEntity(), null, DamageCause.CONTACT, 6, true, true, false,
"Blocky Iron Wizard Aura", "Blocky Iron Wizard Aura");
} }
if (victim instanceof Player) if (victim instanceof Player)
{ {
getGolem() getGolem().getEvent().getCondition().Factory().Slow("Blocky Iron Wizard Aura", (LivingEntity) victim,
.getEvent() getEntity(), 3, 2, false, false, false, false);
.getCondition()
.Factory()
.Slow("Blocky Iron Wizard Aura", (LivingEntity) victim, getEntity(), 3, 2, false, false, false, false);
} }
fallingIterator.remove(); fallingIterator.remove();
@ -390,8 +381,8 @@ public class GolemExplodingAura extends GolemAbility
nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX)); nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX));
nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY)); nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY));
nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ)); nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ));
float f2 = MathHelper.sqrt(nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ float f2 = MathHelper.sqrt(
* nmsEntity.motZ); nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ * nmsEntity.motZ);
nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D; nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D;
nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D; nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D;
nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D; nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D;
@ -404,8 +395,9 @@ public class GolemExplodingAura extends GolemAbility
} }
else else
{ {
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), cur.getLocation() UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0),
.add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers()); 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 @Override
public Player getTarget() public Player getTarget()
{ {
return getTarget(2); return getTarget(4);
} }
@Override @Override
@ -55,7 +55,7 @@ public class GolemMeleeAttack extends GolemAbility
{ {
_attacked = true; _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) if (target.getVelocity().length() > 0.5)
{ {
@ -64,17 +64,13 @@ public class GolemMeleeAttack extends GolemAbility
UtilEnt.CreatureLook(getEntity(), target); UtilEnt.CreatureLook(getEntity(), target);
getGolem() getGolem().getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.ENTITY_ATTACK,
.getEvent() 6 * getGolem().getDifficulty(), false, true, false, "Iron Wizard Melee Attack", "Iron Wizard Melee Attack");
.getDamageManager()
.NewDamageEvent(target, getEntity(), null, DamageCause.ENTITY_ATTACK, 6, false, true, false,
"Iron Wizard Melee Attack", "Iron Wizard Melee Attack");
Vector vec = getLocation().getDirection(); Vector vec = getLocation().getDirection();
vec.setY(0).normalize().multiply(0.2); vec.setY(0).normalize().setY(0.5).multiply(2.4);
vec.setY(1);
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); 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)) if (canDamage(entity))
{ {
getGolem() getGolem().getEvent().getDamageManager().NewDamageEvent((LivingEntity) entity, getEntity(), null,
.getEvent() DamageCause.CONTACT, 4 * getGolem().getDifficulty(), false, true, false, "Iron Wizard Rumble",
.getDamageManager() "Iron Wizard Rumble");
.NewDamageEvent((LivingEntity) entity, getEntity(), null, DamageCause.CONTACT, 4, false, true,
false, "Iron Wizard Rumble", "Iron Wizard Rumble");
} }
UtilAction.velocity(entity, _vec.clone(), 1.5, true, 0, 0.2, 1, true); UtilAction.velocity(entity, _vec.clone(), 1.5, true, 0, 0.2, 1, true);
if (entity instanceof Player) if (entity instanceof Player)
{ {
getGolem().getEvent().getCondition().Factory() getGolem().getEvent().getCondition().Factory().Slow("Rumble", (LivingEntity) entity, getEntity(), 3, 1,
.Slow("Rumble", (LivingEntity) entity, getEntity(), 3, 1, false, false, false, false); 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(); net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle();
Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY,
+ nmsEntity.motZ); nmsEntity.locZ + nmsEntity.motZ);
MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false); MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false);
vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ); 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); vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c);
} }
for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities( for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities(((CraftEntity) cur).getHandle(),
((CraftEntity) cur).getHandle(),
((CraftEntity) cur).getHandle().boundingBox.a(((CraftEntity) cur).getHandle().motX, ((CraftEntity) cur).getHandle().boundingBox.a(((CraftEntity) cur).getHandle().motX,
((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2))) ((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2)))
{ {
@ -193,11 +192,9 @@ public class GolemWallExplode extends GolemAbility
if (canDamage(victim)) if (canDamage(victim))
{ {
getGolem() getGolem().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null,
.getEvent() DamageCause.CONTACT, 6 * getGolem().getDifficulty(), true, true, false, "Iron Wizard Wall Explosion",
.getDamageManager() "Iron Wizard Wall Explosion");
.NewDamageEvent((LivingEntity) victim, getEntity(), null, DamageCause.CONTACT, 6, true, true, false,
"Iron Wizard Wall Explosion", "Iron Wizard Wall Explosion");
} }
cur.remove(); cur.remove();
@ -216,8 +213,8 @@ public class GolemWallExplode extends GolemAbility
nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX)); nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX));
nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY)); nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY));
nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ)); nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ));
float f2 = MathHelper.sqrt(nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ float f2 = MathHelper.sqrt(
* nmsEntity.motZ); nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ * nmsEntity.motZ);
nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D; nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D;
nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D; nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D;
nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D; nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D;
@ -229,8 +226,9 @@ public class GolemWallExplode extends GolemAbility
} }
else else
{ {
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), cur.getLocation() UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0),
.add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers()); 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.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilShapes; import mineplex.core.common.util.UtilShapes;
import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilWorld;
@ -34,8 +37,8 @@ import nautilus.game.arcade.kit.Kit;
public class BossBattles extends TeamGame public class BossBattles extends TeamGame
{ {
private WorldEvent _currentBoss; private WorldEvent _currentBoss;
private BattleBoss _chosenBoss = BattleBoss.values()[UtilMath.r(BattleBoss private BattleBoss _chosenBoss = BattleBoss.values()[UtilMath
.values().length)]; .r(BattleBoss.values().length)];
private ArrayList<BossDisplay> _displays = new ArrayList<BossDisplay>(); private ArrayList<BossDisplay> _displays = new ArrayList<BossDisplay>();
public BossBattles(ArcadeManager manager) public BossBattles(ArcadeManager manager)
@ -47,7 +50,7 @@ public class BossBattles extends TeamGame
new KitAssassin(manager), new KitAssassin(manager),
}, new String[] }, 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 the event was cancelled, we don't need to run a cleanup
if (_currentBoss.getState() == EventState.COMPLETE) if (_currentBoss.getState() == EventState.COMPLETE)
_currentBoss.cleanup(); _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) public void setPicked(Player player, BattleBoss battleBoss)
@ -170,11 +155,64 @@ public class BossBattles extends TeamGame
for (BossDisplay display : _displays) for (BossDisplay display : _displays)
{ {
HandlerList.unregisterAll(display); HandlerList.unregisterAll(display);
display.removeHologram();
display.removeBoss();
} }
_displays.clear(); _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 @EventHandler
public void onGamePrepare(GameStateChangeEvent event) public void onGamePrepare(GameStateChangeEvent event)
{ {
@ -194,8 +232,8 @@ public class BossBattles extends TeamGame
{ {
Location loc = locations.get(i).clone(); Location loc = locations.get(i).clone();
loc.setDirection(UtilAlg.getTrajectory(loc, Manager.GetLobby() loc.setDirection(UtilAlg.getTrajectory(loc,
.GetSpawn())); Manager.GetLobby().GetSpawn()));
Constructor<? extends BossDisplay> constructor = boss Constructor<? extends BossDisplay> constructor = boss
.getBossDisplay().getConstructor(BossBattles.class, .getBossDisplay().getConstructor(BossBattles.class,
@ -208,9 +246,10 @@ public class BossBattles extends TeamGame
getArcadeManager().getPlugin()); getArcadeManager().getPlugin());
bossDisplay.start(); bossDisplay.start();
bossDisplay.spawnHologram();
System.out.print("Registered " System.out.print(
+ bossDisplay.getClass().getSimpleName()); "Registered " + bossDisplay.getClass().getSimpleName());
} }
catch (Exception e) catch (Exception e)
{ {
@ -261,17 +300,17 @@ public class BossBattles extends TeamGame
if (clazz != SlimeBoss.class) if (clazz != SlimeBoss.class)
{ {
worldEvent = (WorldEvent) con.newInstance( worldEvent = (WorldEvent) con.newInstance(
getArcadeManager().GetDamage(), getArcadeManager() getArcadeManager().GetDamage(),
.GetBlockRestore(), getArcadeManager() getArcadeManager().GetBlockRestore(),
.GetCondition(), centerLocation); getArcadeManager().GetCondition(), centerLocation);
} }
else else
{ {
worldEvent = (WorldEvent) con.newInstance( worldEvent = (WorldEvent) con.newInstance(
getArcadeManager().GetDamage(), getArcadeManager() getArcadeManager().GetDamage(),
.GetBlockRestore(), getArcadeManager() getArcadeManager().GetBlockRestore(),
.GetCondition(), getArcadeManager() getArcadeManager().GetCondition(),
.GetProjectile(), centerLocation); getArcadeManager().GetProjectile(), centerLocation);
} }
} }
} }
@ -285,10 +324,11 @@ public class BossBattles extends TeamGame
private void setNewBoss(BattleBoss boss) private void setNewBoss(BattleBoss boss)
{ {
_currentBoss = createInstance(boss.getBoss(), new Location( _currentBoss = createInstance(boss.getBoss(),
WorldData.World, 0, 6, 0)); new Location(WorldData.World, 0, 6, 0));
_currentBoss.setInstantSchematic(true); _currentBoss.setInstantSchematic(true);
_currentBoss.setDifficulty(0.6);
_currentBoss.loadMap(); _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.BattleBoss;
import nautilus.game.arcade.game.games.bossbattles.BossBattles; import nautilus.game.arcade.game.games.bossbattles.BossBattles;
import java.util.ArrayList;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; 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 public abstract class BossDisplay implements Listener
{ {
private Location _bossLocation; private Location _bossLocation;
protected BossBattles Plugin; protected BossBattles Plugin;
private BattleBoss _boss; private BattleBoss _boss;
private Hologram _hologram;
private ArrayList<Entity> _entities = new ArrayList<Entity>();
public BossDisplay(BossBattles plugin, BattleBoss boss, Location location) public BossDisplay(BossBattles plugin, BattleBoss boss, Location location)
{ {
@ -20,6 +31,37 @@ public abstract class BossDisplay implements Listener
_bossLocation = location; _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() public Location getLocation()
{ {
return _bossLocation; return _bossLocation;
@ -30,8 +72,33 @@ public abstract class BossDisplay implements Listener
Plugin.setPicked(player, _boss); Plugin.setPicked(player, _boss);
} }
public abstract void removeBoss(); public void removeBoss()
{
for (Entity entity : _entities)
{
entity.remove();
}
}
public abstract void start(); 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; package nautilus.game.arcade.game.games.bossbattles.displays;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import nautilus.game.arcade.game.games.bossbattles.BattleBoss; import nautilus.game.arcade.game.games.bossbattles.BattleBoss;
import nautilus.game.arcade.game.games.bossbattles.BossBattles; import nautilus.game.arcade.game.games.bossbattles.BossBattles;
@ -31,23 +32,39 @@ public class IronWizardDisplay extends BossDisplay
setChosen(event.getPlayer()); setChosen(event.getPlayer());
} }
@Override
public void removeBoss()
{
_golem.remove();
}
@Override @Override
public void start() public void start()
{ {
Plugin.CreatureAllowOverride = true; Plugin.CreatureAllowOverride = true;
_golem = (IronGolem) getLocation().getWorld().spawnEntity( _golem = (IronGolem) getLocation().getWorld().spawnEntity(getLocation(),
getLocation(), EntityType.IRON_GOLEM); EntityType.IRON_GOLEM);
_golem.teleport(getLocation()); _golem.teleport(getLocation());
UtilEnt.Vegetate(_golem); UtilEnt.Vegetate(_golem);
Plugin.CreatureAllowOverride = false; 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; package nautilus.game.arcade.game.games.bossbattles.displays;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import nautilus.game.arcade.game.games.bossbattles.BattleBoss; import nautilus.game.arcade.game.games.bossbattles.BattleBoss;
import nautilus.game.arcade.game.games.bossbattles.BossBattles; import nautilus.game.arcade.game.games.bossbattles.BossBattles;
@ -32,12 +33,6 @@ public class SlimeKingDisplay extends BossDisplay
setChosen(event.getPlayer()); setChosen(event.getPlayer());
} }
@Override
public void removeBoss()
{
_slime.remove();
}
@Override @Override
public void start() public void start()
{ {
@ -52,6 +47,28 @@ public class SlimeKingDisplay extends BossDisplay
UtilEnt.Vegetate(_slime); UtilEnt.Vegetate(_slime);
Plugin.CreatureAllowOverride = false; 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);
} }
} }