Snakes anyone?

This commit is contained in:
libraryaddict 2015-08-29 16:43:40 -07:00
parent 05ecfb8ff0
commit e2e0756b9f
3 changed files with 69 additions and 35 deletions

View File

@ -1,6 +1,7 @@
package mineplex.minecraft.game.core.boss.snake;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@ -36,7 +37,7 @@ public class SnakeCreature extends EventCreature<Silverfish>
private ArrayList<Player> _canSee = new ArrayList<Player>();
private Location _waypoint;
private Vector _velocity = new Vector(0,0,0);
private Vector _velocity = new Vector(0, 0, 0);
private boolean _enabled = true;
@ -53,7 +54,7 @@ public class SnakeCreature extends EventCreature<Silverfish>
UtilEnt.ghost(getEntity(), true, false);
Vector dir = new Vector(UtilMath.rr(1, true), 0, UtilMath.rr(1, true)).normalize().multiply(_seperator);
getNewWaypoint();
getNewWaypoint();
for (int i = 0; i < getHealth() / 50; i++)
{
@ -66,7 +67,7 @@ public class SnakeCreature extends EventCreature<Silverfish>
private void getNewWaypoint()
{
//Bukkit.broadcastMessage("NEW WAYPOINT!");
// Bukkit.broadcastMessage("NEW WAYPOINT!");
_waypoint = getSpawnLocation().clone().add(Math.random() * 60 - 30, Math.random() * 24 - 16, Math.random() * 60 - 30);
}
@ -150,10 +151,9 @@ public class SnakeCreature extends EventCreature<Silverfish>
return;
}
Packet[] packets = new Packet[_segments.size()];
ArrayList<Packet> packets = new ArrayList<Packet>();
for (int i = _segments.size()-1; i>=0; i--)
for (int i = _segments.size() - 1; i >= 0; i--)
{
SnakeSegment seg = _segments.get(i);
@ -168,11 +168,11 @@ public class SnakeCreature extends EventCreature<Silverfish>
if (_velocity.length() > 0.5)
_velocity.normalize().multiply(0.5);
//Bukkit.broadcastMessage("Loc: " + UtilWorld.vecToStrClean(moveTo));
// Bukkit.broadcastMessage("Loc: " + UtilWorld.vecToStrClean(moveTo));
vec.add(_velocity);
//Bukkit.broadcastMessage("Loc: " + UtilWorld.vecToStrClean(vec));
// Bukkit.broadcastMessage("Loc: " + UtilWorld.vecToStrClean(vec));
if (UtilMath.offset(vec, _waypoint.toVector()) < 5)
{
@ -181,15 +181,17 @@ public class SnakeCreature extends EventCreature<Silverfish>
}
else
{
vec = _segments.get(i-1).getLocation();
vec = _segments.get(i - 1).getLocation();
}
packets[i] = seg.moveEntity(vec);
packets.addAll(Arrays.asList(seg.moveEntity(vec)));
}
Packet[] packetArray = packets.toArray(new Packet[0]);
for (Player player : _canSee)
{
UtilPlayer.sendPacket(player, packets);
UtilPlayer.sendPacket(player, packetArray);
}
}

View File

@ -10,6 +10,7 @@ import mineplex.core.common.util.UtilEnt;
import net.minecraft.server.v1_7_R4.DataWatcher;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityEquipment;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_7_R4.PacketPlayOutRelEntityMoveLook;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
@ -19,6 +20,7 @@ public class SnakeSegment
private int _entityId = UtilEnt.getNewEntityId();
private Vector _entityLocation;
private ItemStack _item;
private Vector _prevDir = new Vector();
public SnakeSegment(Vector location, ItemStack item)
{
@ -31,9 +33,10 @@ public class SnakeSegment
return _entityId;
}
public Packet moveEntity(Vector newLocation)
public Packet[] moveEntity(Vector newLocation)
{
Vector toMove = newLocation.clone().subtract(_entityLocation);
Packet packet1;
int x = (int) Math.floor(32 * toMove.getX());
int y = (int) Math.floor(32 * toMove.getY());
@ -49,10 +52,10 @@ public class SnakeSegment
relMove.b = (byte) x;
relMove.c = (byte) y;
relMove.d = (byte) z;
relMove.e = (byte) (int) (UtilAlg.GetYaw(toMove) * 256.0F / 360.0F);
relMove.f = (byte) (int) (UtilAlg.GetPitch(toMove) * 256.0F / 360.0F);
//relMove.e = (byte) (int) (UtilAlg.GetYaw(toMove) * 256.0F / 360.0F);
//relMove.f = (byte) (int) (UtilAlg.GetPitch(toMove) * 256.0F / 360.0F);
return relMove;
packet1 = relMove;
}
else
{
@ -67,11 +70,45 @@ public class SnakeSegment
teleportPacket.b = x;
teleportPacket.c = y;
teleportPacket.d = z;
teleportPacket.e = (byte) (int) (UtilAlg.GetYaw(toMove) * 256.0F / 360.0F);
teleportPacket.f = (byte) (int) (UtilAlg.GetPitch(toMove) * 256.0F / 360.0F);
//teleportPacket.e = (byte) (int) (UtilAlg.GetYaw(toMove) * 256.0F / 360.0F);
//teleportPacket.f = (byte) (int) (UtilAlg.GetPitch(toMove) * 256.0F / 360.0F);
return teleportPacket;
packet1 = teleportPacket;
}
toMove.normalize();
if (toMove.equals(_prevDir))
{
return new Packet[]
{
packet1
};
}
_prevDir = toMove;
DataWatcher watcher = new DataWatcher(null);
watcher.a(0, (byte) 32);
watcher.a(1, 0);
watcher.a(10, (byte) 0);
watcher.watch(11, toMove);
for (int i = 12; i < 17; i++)
{
watcher.a(i, new Vector(0, 0, 0));
}
PacketPlayOutEntityMetadata meta = new PacketPlayOutEntityMetadata();
meta.a = getId();
meta.b = watcher.c();
return new Packet[]
{
packet1, meta
};
}
public Vector getLocation()

View File

@ -26,12 +26,7 @@ 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>