Merge remote-tracking branch 'origin/clans-beta' into clans-beta
This commit is contained in:
commit
9ad39c1fe7
@ -176,7 +176,7 @@ public class SnakeCreature extends EventCreature<Silverfish>
|
||||
vec = _segments.get(i-1).getLocation();
|
||||
}
|
||||
|
||||
packets[i] = seg.moveEntity(vec);
|
||||
packets[i] = seg.moveEntity(new Vector(UtilMath.rr(10, true), 12, UtilMath.rr(10, true)));
|
||||
}
|
||||
|
||||
for (Player player : _canSee)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mineplex.minecraft.game.core.boss.snake;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@ -75,7 +76,7 @@ public class SnakeSegment
|
||||
|
||||
public Vector getLocation()
|
||||
{
|
||||
return _entityLocation;
|
||||
return _entityLocation.clone();
|
||||
}
|
||||
|
||||
public Packet[] getSpawn()
|
||||
@ -86,29 +87,42 @@ public class SnakeSegment
|
||||
watcher.a(0, (byte) 0);
|
||||
watcher.a(1, 0);
|
||||
|
||||
watcher.a(10, (byte) 0);
|
||||
|
||||
for (int i = 11; i < 17; i++)
|
||||
{
|
||||
watcher.a(i, new Vector(0, 0, 0));
|
||||
}
|
||||
|
||||
packet.a = getId();
|
||||
packet.b = 30;
|
||||
packet.c = (int) Math.floor(_entityLocation.getX() * 32);
|
||||
packet.d = (int) Math.floor(_entityLocation.getY() * 32);
|
||||
packet.e = (int) Math.floor(_entityLocation.getZ() * 32);
|
||||
packet.l = watcher;
|
||||
|
||||
PacketPlayOutEntityEquipment packet2 = new PacketPlayOutEntityEquipment();
|
||||
if (_item != null)
|
||||
{
|
||||
watcher.a(10, (byte) 0);
|
||||
|
||||
packet2.a = getId();
|
||||
packet2.b = 4;
|
||||
packet2.c = CraftItemStack.asNMSCopy(_item);
|
||||
|
||||
return new Packet[]
|
||||
for (int i = 11; i < 17; i++)
|
||||
{
|
||||
packet, packet2
|
||||
};
|
||||
watcher.a(i, new Vector(0, 0, 0));
|
||||
}
|
||||
|
||||
packet.b = 30;
|
||||
|
||||
PacketPlayOutEntityEquipment packet2 = new PacketPlayOutEntityEquipment();
|
||||
|
||||
packet2.a = getId();
|
||||
packet2.b = 4;
|
||||
packet2.c = CraftItemStack.asNMSCopy(_item);
|
||||
|
||||
return new Packet[]
|
||||
{
|
||||
packet, packet2
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.b = EntityType.MAGMA_CUBE.getTypeId();
|
||||
|
||||
return new Packet[]
|
||||
{
|
||||
packet
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,69 @@
|
||||
package mineplex.minecraft.game.core.boss.spider;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
import mineplex.minecraft.game.core.boss.EventState;
|
||||
import mineplex.minecraft.game.core.boss.WorldEvent;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
|
||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
|
||||
public class SpiderBoss extends WorldEvent
|
||||
{
|
||||
|
||||
public SpiderBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager,
|
||||
Location cornerLocation)
|
||||
{
|
||||
super(damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStart()
|
||||
{
|
||||
Bukkit.broadcastMessage("Custom Start");
|
||||
spawnGolem(getCenterLocation());
|
||||
setState(EventState.LIVE);
|
||||
announceStart();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this slime boss has been defeated
|
||||
*/
|
||||
private void checkDeath()
|
||||
{
|
||||
if (getCreatures().size() == 0)
|
||||
{
|
||||
setState(EventState.COMPLETE);
|
||||
Bukkit.broadcastMessage("FINISHED!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCreature(EventCreature creature)
|
||||
{
|
||||
super.removeCreature(creature);
|
||||
|
||||
if (creature instanceof GolemCreature)
|
||||
{
|
||||
checkDeath();
|
||||
}
|
||||
}
|
||||
|
||||
public SpiderMinionCreature spawnMinion(Location location)
|
||||
{
|
||||
SpiderMinionCreature slimeCreature = new SpiderMinionCreature(this, location, 2500);
|
||||
registerCreature(slimeCreature);
|
||||
return slimeCreature;
|
||||
}
|
||||
|
||||
private SpiderCreature spawnGolem(Location location)
|
||||
{
|
||||
SpiderCreature slimeCreature = new SpiderCreature(this, location, 2500);
|
||||
registerCreature(slimeCreature);
|
||||
return slimeCreature;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,316 @@
|
||||
package mineplex.minecraft.game.core.boss.spider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Spider;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
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.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemBoss;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemBlockHail;
|
||||
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.GolemSlam;
|
||||
import mineplex.minecraft.game.core.boss.spider.attacks.SpiderEggplosm;
|
||||
|
||||
public class SpiderCreature extends EventCreature<Spider>
|
||||
{
|
||||
private ArrayList<BossAbility> _currentAbilities = new ArrayList<BossAbility>();
|
||||
private int _lastAbility;
|
||||
private long _lastWalked;
|
||||
private long _reverseWalk;
|
||||
private Location _standing;
|
||||
private Vector _afkWalk = new Vector();
|
||||
|
||||
public SpiderCreature(SpiderBoss boss, Location location, double maxHealth)
|
||||
{
|
||||
super(boss, location, "Brood Mother", true, maxHealth, Spider.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void spawnCustom()
|
||||
{
|
||||
UtilEnt.Vegetate(getEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dieCustom()
|
||||
{
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTick(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<BossAbility> itel = _currentAbilities.iterator();
|
||||
boolean canDoNew = _currentAbilities.size() < 3;
|
||||
|
||||
while (itel.hasNext())
|
||||
{
|
||||
BossAbility ability = itel.next();
|
||||
|
||||
if (ability.hasFinished())
|
||||
{
|
||||
itel.remove();
|
||||
ability.setFinished();
|
||||
_lastAbility = 20;// _currentAbility.getCooldown();
|
||||
|
||||
HandlerList.unregisterAll(ability);
|
||||
System.out.print("Unregistered golem ability " + ability.getClass().getSimpleName());
|
||||
}
|
||||
else if (!ability.inProgress())
|
||||
{
|
||||
canDoNew = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (_lastAbility-- <= 0 && canDoNew && UtilBlock.solid(getEntity().getLocation().getBlock().getRelative(BlockFace.DOWN)))
|
||||
{
|
||||
HashMap<Class, Integer> weight = new HashMap<Class, Integer>();
|
||||
HashMap<Player, Double> dist = new HashMap<Player, Double>();
|
||||
|
||||
for (Player player : UtilPlayer.getNearby(getEntity().getLocation(), 50, true))
|
||||
{
|
||||
if (player.hasLineOfSight(getEntity()))
|
||||
{
|
||||
dist.put(player, player.getLocation().distance(getEntity().getLocation()));
|
||||
}
|
||||
}
|
||||
|
||||
if (!dist.isEmpty())
|
||||
{
|
||||
{// Egg explosion
|
||||
ArrayList<Player> players = getPlayers(dist, 30);
|
||||
|
||||
if (!players.isEmpty())
|
||||
{
|
||||
weight.put(SpiderEggplosm.class, 4);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
for (BossAbility ability : _currentAbilities)
|
||||
{
|
||||
weight.remove(ability.getClass());
|
||||
}
|
||||
|
||||
BossAbility ability = null;
|
||||
|
||||
if (!weight.isEmpty())
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (Integer entry : weight.values())
|
||||
{
|
||||
i += entry;
|
||||
}
|
||||
|
||||
for (int a = 0; a < 10; a++)
|
||||
{
|
||||
int luckyNumber = UtilMath.r(i);
|
||||
|
||||
for (Entry<Class, Integer> entry : weight.entrySet())
|
||||
{
|
||||
luckyNumber -= entry.getValue();
|
||||
|
||||
if (luckyNumber <= 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
ability = (BossAbility) entry.getKey().getConstructor(GolemCreature.class).newInstance(this);
|
||||
|
||||
if (ability.getTarget() == null)
|
||||
{
|
||||
ability = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ability != null && ability.getTarget() != null)
|
||||
{
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(ability, getEvent().getPlugin());
|
||||
|
||||
System.out.print("Spider boss is using " + ability.getClass().getSimpleName());
|
||||
|
||||
_currentAbilities.add(ability);
|
||||
}
|
||||
|
||||
_lastAbility = 10;
|
||||
}
|
||||
|
||||
boolean canMove = true;
|
||||
|
||||
for (BossAbility ability : _currentAbilities)
|
||||
{
|
||||
ability.tick();
|
||||
|
||||
if (!ability.canMove())
|
||||
{
|
||||
canMove = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (canMove)
|
||||
{
|
||||
Player target = null;
|
||||
double dist = 0;
|
||||
|
||||
for (Player player : UtilPlayer.getNearby(getEntity().getLocation(), 50, true))
|
||||
{
|
||||
if (!player.hasLineOfSight(getEntity()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
double d = player.getLocation().distance(getEntity().getLocation());
|
||||
|
||||
if (d > 1.5 && (d < 7 || d > 15) && (target == null || (d < 50 && dist > d)))
|
||||
{
|
||||
target = player;
|
||||
dist = d;
|
||||
}
|
||||
}
|
||||
|
||||
Vector vec = null;
|
||||
boolean superWalk = false;
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
vec = target.getLocation().subtract(getEntity().getLocation()).toVector();
|
||||
vec.setY(getEntity().getLocation().getY());
|
||||
|
||||
double len = vec.length();
|
||||
|
||||
vec.setX(vec.getX() * (UtilMath.random.nextDouble() / 3D));
|
||||
vec.setZ(vec.getZ() * (UtilMath.random.nextDouble() / 3D));
|
||||
|
||||
vec.multiply(len);
|
||||
|
||||
if (target != null && dist < 8)
|
||||
{
|
||||
vec.multiply(-1);
|
||||
superWalk = true;
|
||||
}
|
||||
|
||||
if (!UtilAlg.HasSight(getEntity().getLocation(),
|
||||
getEntity().getLocation().add(vec.clone().normalize().multiply(2))))
|
||||
{
|
||||
_reverseWalk = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
if (!UtilTime.elapsed(_reverseWalk, 4000))
|
||||
{
|
||||
vec.multiply(-1);
|
||||
}
|
||||
|
||||
}
|
||||
else if (!UtilTime.elapsed(_lastWalked, 7000))
|
||||
{
|
||||
vec = _afkWalk;
|
||||
}
|
||||
else if (UtilTime.elapsed(_lastWalked, 12000))
|
||||
{
|
||||
_afkWalk = new Vector();
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Vector vector = new Vector(UtilMath.r(20) - 10, 0, UtilMath.r(20) - 10);
|
||||
|
||||
if (UtilAlg.HasSight(getEntity().getLocation(),
|
||||
getEntity().getLocation().add(vector.clone().normalize().multiply(2))))
|
||||
{
|
||||
vec = _afkWalk = vector;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_lastWalked = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
if (vec != null)
|
||||
{
|
||||
// if (vec.length() > 1)
|
||||
{
|
||||
UtilEnt.CreatureMoveFast(getEntity(), getEntity().getLocation().add(vec),
|
||||
(target != null ? 1.8F : 1.1F) + (superWalk ? 0.4F : 0));
|
||||
}
|
||||
}
|
||||
|
||||
_standing = getEntity().getLocation();
|
||||
}
|
||||
else
|
||||
{
|
||||
Location l = getEntity().getLocation();
|
||||
|
||||
_standing.setYaw(l.getYaw());
|
||||
_standing.setPitch(l.getPitch());
|
||||
_standing.setY(l.getY());
|
||||
|
||||
getEntity().teleport(_standing);
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<Player> getPlayers(final HashMap<Player, Double> map, double maxDist)
|
||||
{
|
||||
ArrayList<Player> list = new ArrayList<Player>();
|
||||
|
||||
for (Player p : map.keySet())
|
||||
{
|
||||
if (map.get(p) <= maxDist)
|
||||
{
|
||||
list.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(list, new Comparator<Player>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public int compare(Player o1, Player o2)
|
||||
{
|
||||
return Double.compare(map.get(o2), map.get(o1));
|
||||
}
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package mineplex.minecraft.game.core.boss.spider;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.CaveSpider;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
|
||||
public class SpiderMinionCreature extends EventCreature<CaveSpider>
|
||||
{
|
||||
public SpiderMinionCreature(SpiderBoss boss, Location location, double maxHealth)
|
||||
{
|
||||
super(boss, location, "Spider Minion", false, maxHealth, CaveSpider.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void spawnCustom()
|
||||
{
|
||||
UtilEnt.Vegetate(getEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dieCustom()
|
||||
{
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTick(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player target = UtilPlayer.getClosest(getEntity().getLocation());
|
||||
|
||||
UtilEnt.CreatureMoveFast(getEntity(), target.getLocation(), 1.4F);
|
||||
|
||||
if (UtilMath.r(50) == 0)
|
||||
{
|
||||
getEntity().getWorld().playSound(getEntity().getLocation(), Sound.SPIDER_IDLE, 2.5F, 1);
|
||||
}
|
||||
|
||||
if (target.getLocation().distance(getEntity().getLocation()) < 2)
|
||||
{
|
||||
Vector vec = UtilAlg.getTrajectory2d(getEntity(), target);
|
||||
vec.multiply(0.4).setY(0.3);
|
||||
|
||||
getEntity().setVelocity(vec);
|
||||
|
||||
getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.ENTITY_ATTACK,
|
||||
6 * getDifficulty(), true, false, false, "Spider Minion Attack", "Spider Minion Attack");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,232 @@
|
||||
package mineplex.minecraft.game.core.boss.spider.attacks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Spider;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
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.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderBoss;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderCreature;
|
||||
import net.minecraft.server.v1_7_R4.MathHelper;
|
||||
import net.minecraft.server.v1_7_R4.MovingObjectPosition;
|
||||
import net.minecraft.server.v1_7_R4.Vec3D;
|
||||
|
||||
public class SpiderEggplosm extends BossAbility<SpiderCreature, Spider>
|
||||
{
|
||||
private int _eggsToSpray = 30;
|
||||
private HashMap<Block, Long> _eggs = new HashMap<Block, Long>();
|
||||
private ArrayList<FallingBlock> _fallingBlocks = new ArrayList<FallingBlock>();
|
||||
private int _tick;
|
||||
private float _yaw;
|
||||
private float _addYaw;
|
||||
|
||||
public SpiderEggplosm(SpiderCreature creature)
|
||||
{
|
||||
super(creature);
|
||||
|
||||
_addYaw = 360F / _eggsToSpray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMove()
|
||||
{
|
||||
return inProgress();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent event)
|
||||
{
|
||||
if (UtilPlayer.isSpectator(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (event.getPlayer().getGameMode() == GameMode.CREATIVE)
|
||||
return;
|
||||
|
||||
Block block = event.getTo().getBlock().getRelative(BlockFace.DOWN);
|
||||
|
||||
if (!_eggs.containsKey(block))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_eggs.remove(block);
|
||||
|
||||
block.setType(Material.AIR);
|
||||
block.getWorld().playSound(block.getLocation(), Sound.FALL_BIG, 2.5F, 0F);
|
||||
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.DRAGON_EGG, 0),
|
||||
block.getLocation().add(0.5, 0.6, 0.5), 0.6F, 0.5F, 0.6F, 0, 100, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inProgress()
|
||||
{
|
||||
return _eggsToSpray > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFinished()
|
||||
{
|
||||
return _eggsToSpray <= 0 && _fallingBlocks.isEmpty() && _eggs.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFinished()
|
||||
{
|
||||
for (FallingBlock block : _fallingBlocks)
|
||||
{
|
||||
block.remove();
|
||||
}
|
||||
|
||||
for (Block b : _eggs.keySet())
|
||||
{
|
||||
b.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (_eggsToSpray > 0 && _tick % 10 == 0)
|
||||
{
|
||||
_eggsToSpray--;
|
||||
|
||||
UtilEnt.CreatureLook(getEntity(), 0, _yaw);
|
||||
|
||||
_yaw += _addYaw;
|
||||
|
||||
Vector vec = getEntity().getLocation().getDirection();
|
||||
|
||||
vec.setY(0).normalize().setY(0.4 + (UtilMath.rr(0.4, false)));
|
||||
|
||||
FallingBlock block = getLocation().getWorld().spawnFallingBlock(vec.toLocation(getLocation().getWorld()),
|
||||
Material.WEB, (byte) 0);
|
||||
block.setDropItem(false);
|
||||
|
||||
_fallingBlocks.add(block);
|
||||
}
|
||||
else
|
||||
{
|
||||
Iterator<Entry<Block, Long>> itel = _eggs.entrySet().iterator();
|
||||
|
||||
while (itel.hasNext())
|
||||
{
|
||||
Entry<Block, Long> entry = itel.next();
|
||||
|
||||
if (entry.getValue() < System.currentTimeMillis())
|
||||
{
|
||||
itel.remove();
|
||||
entry.getKey().setType(Material.AIR);
|
||||
entry.getKey().getWorld().playEffect(entry.getKey().getLocation(), Effect.STEP_SOUND,
|
||||
Material.DRAGON_EGG.getId());
|
||||
((SpiderBoss) getBoss().getEvent()).spawnMinion(entry.getKey().getLocation().add(0.5, 0.1, 0.5));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<FallingBlock> fallingIterator = _fallingBlocks.iterator();
|
||||
|
||||
while (fallingIterator.hasNext())
|
||||
{
|
||||
FallingBlock cur = fallingIterator.next();
|
||||
|
||||
if (cur.isDead() || !cur.isValid() || cur.getTicksLived() > 400
|
||||
|| !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
|
||||
{
|
||||
fallingIterator.remove();
|
||||
|
||||
Block block = cur.getLocation().getBlock();
|
||||
block.setType(Material.DRAGON_EGG);
|
||||
_eggs.put(block, System.currentTimeMillis() + 10000 + UtilMath.r(10000));
|
||||
|
||||
// Expire
|
||||
if (cur.getTicksLived() > 400
|
||||
|| !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
|
||||
{
|
||||
cur.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
cur.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false);
|
||||
vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
|
||||
vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + nmsEntity.motZ);
|
||||
|
||||
if (finalObjectPosition != null)
|
||||
{
|
||||
vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c);
|
||||
}
|
||||
|
||||
if (finalObjectPosition != null)
|
||||
{
|
||||
Block block = cur.getWorld().getBlockAt(finalObjectPosition.b, finalObjectPosition.c, finalObjectPosition.d);
|
||||
|
||||
if (!UtilBlock.airFoliage(block) && !block.isLiquid())
|
||||
{
|
||||
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);
|
||||
nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D;
|
||||
nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D;
|
||||
nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D;
|
||||
|
||||
block.setType(Material.DRAGON_EGG);
|
||||
_eggs.put(block, System.currentTimeMillis() + 10000 + UtilMath.r(10000));
|
||||
|
||||
fallingIterator.remove();
|
||||
cur.remove();
|
||||
}
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.bossbattles;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemBoss;
|
||||
import mineplex.minecraft.game.core.boss.slimeking.SlimeBoss;
|
||||
import mineplex.minecraft.game.core.boss.snake.SnakeBoss;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderBoss;
|
||||
import nautilus.game.arcade.game.games.bossbattles.displays.*;
|
||||
|
||||
import org.bukkit.Material;
|
||||
@ -14,7 +15,9 @@ public enum BattleBoss
|
||||
|
||||
SNAKE(SnakeBoss.class, SnakeDisplay.class),
|
||||
|
||||
SLIME(SlimeBoss.class, SlimeKingDisplay.class);
|
||||
SLIME(SlimeBoss.class, SlimeKingDisplay.class),
|
||||
|
||||
SPIDER(SpiderBoss.class, SpiderDisplay.class);
|
||||
|
||||
private Class _bossClass;
|
||||
private Class<? extends BossDisplay> _bossDisplay;
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
@ -31,6 +32,15 @@ public abstract class BossDisplay implements Listener
|
||||
_bossLocation = location;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityInteractEvent(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if (_entities.contains(event.getRightClicked()))
|
||||
{
|
||||
setChosen(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
public void addEntity(Entity entity)
|
||||
{
|
||||
_entities.add(entity);
|
||||
|
@ -21,29 +21,14 @@ public class IronWizardDisplay extends BossDisplay
|
||||
super(plugin, boss, location);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if (!event.getRightClicked().equals(_golem))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setChosen(event.getPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
{
|
||||
Plugin.CreatureAllowOverride = true;
|
||||
|
||||
_golem = (IronGolem) getLocation().getWorld().spawnEntity(getLocation(),
|
||||
EntityType.IRON_GOLEM);
|
||||
_golem.teleport(getLocation());
|
||||
UtilEnt.Vegetate(_golem);
|
||||
|
||||
Plugin.CreatureAllowOverride = false;
|
||||
|
||||
addEntity(_golem);
|
||||
}
|
||||
|
||||
|
@ -22,22 +22,9 @@ public class SlimeKingDisplay extends BossDisplay
|
||||
super(plugin, boss, location);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if (!event.getRightClicked().equals(_slime))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setChosen(event.getPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
{
|
||||
Plugin.CreatureAllowOverride = true;
|
||||
|
||||
_slime = (Slime) getLocation().getWorld().spawnEntity(getLocation(),
|
||||
EntityType.SLIME);
|
||||
_slime.setSize(4);
|
||||
@ -46,8 +33,6 @@ public class SlimeKingDisplay extends BossDisplay
|
||||
|
||||
UtilEnt.Vegetate(_slime);
|
||||
|
||||
Plugin.CreatureAllowOverride = false;
|
||||
|
||||
addEntity(_slime);
|
||||
}
|
||||
|
||||
|
@ -17,28 +17,14 @@ public class SnakeDisplay extends BossDisplay
|
||||
{
|
||||
private Sheep _sheep;
|
||||
|
||||
public SnakeDisplay(BossBattles plugin, BattleBoss boss,
|
||||
Location location)
|
||||
public SnakeDisplay(BossBattles plugin, BattleBoss boss, Location location)
|
||||
{
|
||||
super(plugin, boss, location);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if (!event.getRightClicked().equals(_sheep))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setChosen(event.getPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
{
|
||||
Plugin.CreatureAllowOverride = true;
|
||||
|
||||
_sheep = (Sheep) getLocation().getWorld().spawnEntity(getLocation(),
|
||||
EntityType.SHEEP);
|
||||
|
||||
@ -46,8 +32,6 @@ public class SnakeDisplay extends BossDisplay
|
||||
|
||||
UtilEnt.Vegetate(_sheep);
|
||||
|
||||
Plugin.CreatureAllowOverride = false;
|
||||
|
||||
addEntity(_sheep);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,42 @@
|
||||
package nautilus.game.arcade.game.games.bossbattles.displays;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
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;
|
||||
|
||||
public class SpiderDisplay extends BossDisplay
|
||||
{
|
||||
|
||||
public SpiderDisplay(BossBattles plugin, BattleBoss boss, Location location)
|
||||
{
|
||||
super(plugin, boss, location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
return C.cDBlue + "Brood Mother";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
{
|
||||
Entity entity = getLocation().getWorld().spawnEntity(getLocation(),
|
||||
EntityType.SPIDER);
|
||||
|
||||
UtilEnt.Vegetate(entity);
|
||||
this.addEntity(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getHologramLocation()
|
||||
{
|
||||
return getLocation().clone().add(0, 2, 0);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user