This commit is contained in:
Mini-Chiss 2015-08-29 13:38:40 -07:00
parent d2bc4b8cb4
commit b7b81ecaaa
4 changed files with 37 additions and 205 deletions

View File

@ -16,7 +16,7 @@ public class SnakeBoss extends WorldEvent
public SnakeBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, String name,
Location cornerLocation)
{
super(damageManager, blockRestore, conditionManager, name, cornerLocation);
super(damageManager, blockRestore, conditionManager, "Snaaaake", cornerLocation, "schematic/Golem.schematic");
}
@Override

View File

@ -1,163 +1,32 @@
package nautilus.game.arcade.game.games.bossbattles.displays;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.NumberConversions;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
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.snake.SnakeSegment;
import nautilus.game.arcade.game.games.bossbattles.BattleBoss;
import nautilus.game.arcade.game.games.bossbattles.BossBattles;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.IronGolem;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.Slime;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEntityEvent;
public class SnakeDisplay extends BossDisplay
{
private ArrayList<SnakeSegment> _snakeTail = new ArrayList<SnakeSegment>();
private double _seperator = 0.5;
private ArrayList<Player> _canSee = new ArrayList<Player>();
private Entity _entity;
private float _yaw;
private float _pitch;
private Sheep _sheep;
public SnakeDisplay(BossBattles plugin, BattleBoss boss, Location location)
public SnakeDisplay(BossBattles plugin, BattleBoss boss,
Location location)
{
super(plugin, boss, location);
}
@Override
public String getDisplayName()
{
return C.cDGreen + "Snake";
}
@Override
public void removeBoss()
{
int[] ids = new int[_snakeTail.size()];
for (int a = 0; a < _snakeTail.size(); a++)
{
ids[a] = _snakeTail.get(a).getId();
}
Packet destroy = new PacketPlayOutEntityDestroy(ids);
for (Player player : _canSee)
{
UtilPlayer.sendPacket(player, destroy);
}
_entity.remove();
}
@Override
public void start()
{
Vector dir = new Vector(UtilMath.rr(1, true), 0, UtilMath.rr(1, true))
.normalize().multiply(_seperator);
for (int i = 0; i < 20; i++)
{
Vector loc = getLocation().toVector()
.subtract(dir.clone().multiply(-i));
SnakeSegment tail = new SnakeSegment(loc, new ItemStack(
i == 0 ? Material.COBBLESTONE : Material.STONE));
_snakeTail.add(tail);
}
Plugin.CreatureAllowOverride = true;
_entity = getLocation().getWorld().spawnEntity(getLocation(),
EntityType.IRON_GOLEM);
UtilEnt.Vegetate(_entity);
((LivingEntity) _entity).addPotionEffect(
new PotionEffect(PotionEffectType.INVISIBILITY, 10000, 0));
Plugin.CreatureAllowOverride = false;
addEntity(_entity);
}
@EventHandler
public void onSecond(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
ArrayList<Player> canSee = new ArrayList<Player>();
for (Player player : getLocation().getWorld().getPlayers())
{
if (player.getLocation().distance(getLocation()) < 120)
{
canSee.add(player);
}
}
Iterator<Player> itel2 = _canSee.iterator();
int[] ids = new int[_snakeTail.size()];
for (int a = 0; a < _snakeTail.size(); a++)
{
ids[a] = _snakeTail.get(a).getId();
}
Packet destroy = new PacketPlayOutEntityDestroy(ids);
while (itel2.hasNext())
{
Player player = itel2.next();
if (!canSee.contains(player))
{
itel2.remove();
UtilPlayer.sendPacket(player, destroy);
}
}
for (Player player : canSee)
{
if (!_canSee.contains(player))
{
_canSee.add(player);
for (SnakeSegment tail : _snakeTail)
{
UtilPlayer.sendPacket(player, tail.getSpawn());
}
}
}
}
@EventHandler
public void onInteract(PlayerInteractEntityEvent event)
{
if (!event.getRightClicked().equals(_entity))
if (!event.getRightClicked().equals(_sheep))
{
return;
}
@ -165,78 +34,41 @@ public class SnakeDisplay extends BossDisplay
setChosen(event.getPlayer());
}
public void setYaw(float yaw)
@Override
public void start()
{
_yaw = (yaw + 720) % 360;
Plugin.CreatureAllowOverride = true;
_sheep = (Sheep) getLocation().getWorld().spawnEntity(getLocation(),
EntityType.SHEEP);
_sheep.teleport(getLocation());
UtilEnt.Vegetate(_sheep);
Plugin.CreatureAllowOverride = false;
addEntity(_sheep);
}
public void setPitch(float pitch)
@Override
public String getDisplayName()
{
_pitch = (pitch + 720) % 360;
return C.cDGreen + "SNAAAAAAAAAAAAAAAAAKE";
}
public float getPitch()
@Override
public void spawnHologram()
{
return _pitch;
}
super.spawnHologram();
public float getYaw()
{
return _yaw;
}
@EventHandler
public void onTick(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
{
return;
}
Packet[] packets = new Packet[_snakeTail.size()];
for (int i = 0; i < _snakeTail.size(); i++)
{
SnakeSegment tail = _snakeTail.get(i);
Vector vector = new Vector();
if (i == 0)
{
setPitch(getPitch() + 3);
double rotX = getYaw();
double rotY = getPitch();
vector.setY(-Math.sin(Math.toRadians(rotY)));
double xz = Math.cos(Math.toRadians(rotY));
vector.setX(-xz * Math.sin(Math.toRadians(rotX)));
vector.setZ(xz * Math.cos(Math.toRadians(rotX)));
vector.normalize().multiply(0.2);
}
else
{
SnakeSegment t = _snakeTail.get(i - 1);
vector = t.getPrevious().clone().subtract(tail.getLocation());
}
packets[i] = tail
.moveEntity(tail.getLocation().clone().add(vector));
}
for (Player player : _canSee)
{
UtilPlayer.sendPacket(player, packets);
}
getHologram().setFollowEntity(_sheep);
}
@Override
public Location getHologramLocation()
{
return getLocation().clone().add(0, 3, 0);
return _sheep.getEyeLocation().add(0, 0.1, 0);
}
}