From 05ecfb8ff09dbe63a3e9a4d6bbdb6fea79c8bddb Mon Sep 17 00:00:00 2001 From: Mini-Chiss Date: Sat, 29 Aug 2015 16:33:35 -0700 Subject: [PATCH] snake workin! --- .../mineplex/core/common/util/UtilMath.java | 2 +- .../game/core/boss/snake/SnakeCreature.java | 20 +++++++++---------- .../game/core/boss/snake/SnakeSegment.java | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java index 7c5f2ce64..abe69d33e 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java @@ -65,7 +65,7 @@ public class UtilMath public static double offset(Vector a, Vector b) { - return a.subtract(b).length(); + return a.clone().subtract(b).length(); } public static double offsetSquared(Entity a, Entity b) 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 834b05133..02e9f0803 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 @@ -36,8 +36,9 @@ public class SnakeCreature extends EventCreature private ArrayList _canSee = new ArrayList(); private Location _waypoint; + private Vector _velocity = new Vector(0,0,0); - private boolean _enabled = false; + private boolean _enabled = true; public SnakeCreature(WorldEvent event, Location spawnLocation) { @@ -60,15 +61,13 @@ public class SnakeCreature extends EventCreature new ItemStack(i == 0 ? Material.EMERALD_BLOCK : Material.STONE)); _segments.add(tail); - - break; } } private void getNewWaypoint() { //Bukkit.broadcastMessage("NEW WAYPOINT!"); - _waypoint = getSpawnLocation().clone().add(Math.random() * 80 - 40, Math.random() * 24 - 24, Math.random() * 80 - 40); + _waypoint = getSpawnLocation().clone().add(Math.random() * 60 - 30, Math.random() * 24 - 16, Math.random() * 60 - 30); } @EventHandler @@ -162,13 +161,16 @@ public class SnakeCreature extends EventCreature if (i == 0) { - //Vector moveTo = UtilAlg.getTrajectory(vec, _waypoint.toVector()).multiply(0.1); + Vector moveTo = UtilAlg.getTrajectory(vec, _waypoint.toVector()); - Vector moveTo = new Vector(0,0.1,0); + _velocity.add(moveTo.multiply(0.04)); - Bukkit.broadcastMessage("Loc: " + UtilWorld.vecToStrClean(moveTo)); + if (_velocity.length() > 0.5) + _velocity.normalize().multiply(0.5); - vec.add(moveTo); + //Bukkit.broadcastMessage("Loc: " + UtilWorld.vecToStrClean(moveTo)); + + vec.add(_velocity); //Bukkit.broadcastMessage("Loc: " + UtilWorld.vecToStrClean(vec)); @@ -176,8 +178,6 @@ public class SnakeCreature extends EventCreature { getNewWaypoint(); } - - _enabled = false; } else { 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 2a2c1aaf7..c2fa15bfd 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 @@ -84,7 +84,7 @@ public class SnakeSegment PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); DataWatcher watcher = new DataWatcher(null); - watcher.a(0, (byte) 0); + watcher.a(0, (byte) 32); watcher.a(1, 0); packet.a = getId();