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; package mineplex.minecraft.game.core.boss.snake;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -150,8 +151,7 @@ public class SnakeCreature extends EventCreature<Silverfish>
return; 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--)
{ {
@ -184,12 +184,14 @@ public class SnakeCreature extends EventCreature<Silverfish>
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) 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.DataWatcher;
import net.minecraft.server.v1_7_R4.Packet; import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityEquipment; 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.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_7_R4.PacketPlayOutRelEntityMoveLook; import net.minecraft.server.v1_7_R4.PacketPlayOutRelEntityMoveLook;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving; import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
@ -19,6 +20,7 @@ public class SnakeSegment
private int _entityId = UtilEnt.getNewEntityId(); private int _entityId = UtilEnt.getNewEntityId();
private Vector _entityLocation; private Vector _entityLocation;
private ItemStack _item; private ItemStack _item;
private Vector _prevDir = new Vector();
public SnakeSegment(Vector location, ItemStack item) public SnakeSegment(Vector location, ItemStack item)
{ {
@ -31,9 +33,10 @@ public class SnakeSegment
return _entityId; return _entityId;
} }
public Packet moveEntity(Vector newLocation) public Packet[] moveEntity(Vector newLocation)
{ {
Vector toMove = newLocation.clone().subtract(_entityLocation); Vector toMove = newLocation.clone().subtract(_entityLocation);
Packet packet1;
int x = (int) Math.floor(32 * toMove.getX()); int x = (int) Math.floor(32 * toMove.getX());
int y = (int) Math.floor(32 * toMove.getY()); int y = (int) Math.floor(32 * toMove.getY());
@ -49,10 +52,10 @@ public class SnakeSegment
relMove.b = (byte) x; relMove.b = (byte) x;
relMove.c = (byte) y; relMove.c = (byte) y;
relMove.d = (byte) z; relMove.d = (byte) z;
relMove.e = (byte) (int) (UtilAlg.GetYaw(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); //relMove.f = (byte) (int) (UtilAlg.GetPitch(toMove) * 256.0F / 360.0F);
return relMove; packet1 = relMove;
} }
else else
{ {
@ -67,11 +70,45 @@ public class SnakeSegment
teleportPacket.b = x; teleportPacket.b = x;
teleportPacket.c = y; teleportPacket.c = y;
teleportPacket.d = z; teleportPacket.d = z;
teleportPacket.e = (byte) (int) (UtilAlg.GetYaw(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); //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() public Vector getLocation()

View File

@ -26,12 +26,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.boss.BossAbility; import mineplex.minecraft.game.core.boss.BossAbility;
import mineplex.minecraft.game.core.boss.EventCreature; 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.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; import mineplex.minecraft.game.core.boss.spider.attacks.SpiderEggplosm;
public class SpiderCreature extends EventCreature<Spider> public class SpiderCreature extends EventCreature<Spider>