diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/snake/SnakeCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/snake/SnakeCreature.java index 02e9f0803..7aa873534 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/snake/SnakeCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/snake/SnakeCreature.java @@ -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; @@ -34,10 +35,10 @@ public class SnakeCreature extends EventCreature private ArrayList _segments = new ArrayList(); private double _seperator = 0.5; private ArrayList _canSee = new ArrayList(); - + private Location _waypoint; - private Vector _velocity = new Vector(0,0,0); - + private Vector _velocity = new Vector(0, 0, 0); + private boolean _enabled = true; public SnakeCreature(WorldEvent event, Location spawnLocation) @@ -53,8 +54,8 @@ public class SnakeCreature extends EventCreature 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++) { SnakeSegment tail = new SnakeSegment(getSpawnLocation().toVector().subtract(dir.clone().multiply(-i)), @@ -64,9 +65,9 @@ public class SnakeCreature extends EventCreature } } - private void getNewWaypoint() + 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,30 +151,29 @@ public class SnakeCreature extends EventCreature return; } - Packet[] packets = new Packet[_segments.size()]; + ArrayList packets = new ArrayList(); - - for (int i = _segments.size()-1; i>=0; i--) + for (int i = _segments.size() - 1; i >= 0; i--) { SnakeSegment seg = _segments.get(i); - + Vector vec = seg.getLocation().clone(); if (i == 0) { Vector moveTo = UtilAlg.getTrajectory(vec, _waypoint.toVector()); - + _velocity.add(moveTo.multiply(0.04)); - + 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) { getNewWaypoint(); @@ -181,18 +181,20 @@ public class SnakeCreature extends EventCreature } 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); } } - + @EventHandler public void command(PlayerCommandPreprocessEvent event) { diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/snake/SnakeSegment.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/snake/SnakeSegment.java index c2fa15bfd..d7681817e 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/snake/SnakeSegment.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/snake/SnakeSegment.java @@ -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() diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderCreature.java index d3b5877a0..1650fe3a3 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderCreature.java @@ -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