From 368ed955eacbee6c55f0e188a83fc6b0423c7e0f Mon Sep 17 00:00:00 2001 From: Mini-Chiss Date: Sat, 29 Aug 2015 18:58:12 -0700 Subject: [PATCH 1/2] qwrwr --- .../game/core/boss/snake/SnakeCreature.java | 55 ++++++++++++------- .../game/core/boss/snake/SnakeSegment.java | 8 +++ 2 files changed, 44 insertions(+), 19 deletions(-) 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 8c8dea852..990fe489f 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 @@ -7,8 +7,11 @@ import java.util.Iterator; import java.util.List; import org.bukkit.Bukkit; +import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.entity.Silverfish; import org.bukkit.event.EventHandler; @@ -19,6 +22,7 @@ import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; @@ -41,6 +45,8 @@ public class SnakeCreature extends EventCreature private boolean _enabled = true; + private double _speed = 0.75; + private int _ticks = 0; public SnakeCreature(WorldEvent event, Location spawnLocation) @@ -155,7 +161,7 @@ public class SnakeCreature extends EventCreature ArrayList packets = new ArrayList(); - for (int i = _segments.size() - 1; i >= 0; i--) + for (int i = 0 ; i < _segments.size() ; i++) { SnakeSegment seg = _segments.get(i); @@ -163,22 +169,13 @@ public class SnakeCreature extends EventCreature if (i == 0) { - Vector moveTo = UtilAlg.getTrajectory(vec, _waypoint.toVector()); + Vector direction = UtilAlg.getTrajectory(vec, _waypoint.toVector()); -// Vector target = vec.clone().add(moveTo.multiply(3)); -// -// //MATHS -// double speed = 10d; -// double right = -Math.sin(_ticks/speed) * 4; -// double up = Math.cos(_ticks/speed) * 4; -// -// target.add(UtilAlg.getRight(vec).multiply(right)); -// target.add(UtilAlg.getUp(vec).multiply(up)); + + _velocity.add(direction.multiply(0.1 * _speed)); - _velocity.add(moveTo.normalize().multiply(0.04)); - - if (_velocity.length() > 0.5) - _velocity.normalize().multiply(0.5); + if (_velocity.length() > _speed) + _velocity.normalize().multiply(_speed); // Bukkit.broadcastMessage("Loc: " + UtilWorld.vecToStrClean(moveTo)); @@ -186,14 +183,23 @@ public class SnakeCreature extends EventCreature // Bukkit.broadcastMessage("Loc: " + UtilWorld.vecToStrClean(vec)); - if (UtilMath.offset(vec, _waypoint.toVector()) < 5) + if (UtilMath.offset(vec, _waypoint.toVector()) < 6) { getNewWaypoint(); } } else { - vec = _segments.get(i - 1).getLocation(); + Vector infront = _segments.get(i - 1).getLocation(); + Vector behind = _segments.get(i - 1).getLastLocation(); + + vec = infront.clone().add(UtilAlg.getTrajectory(infront, behind).multiply(_seperator)); + } + + Block block = _waypoint.getWorld().getBlockAt(seg.getLocation().getBlockX(),seg.getLocation().getBlockY(),seg.getLocation().getBlockZ()).getRelative(BlockFace.UP); + if (block.getType() != Material.AIR && UtilBlock.isVisible(block)) + { + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType()); } packets.addAll(Arrays.asList(seg.moveEntity(vec))); @@ -210,8 +216,19 @@ public class SnakeCreature extends EventCreature @EventHandler public void command(PlayerCommandPreprocessEvent event) { - if (event.getMessage().contains("start")) - _enabled = true; + if (event.getMessage().contains("speed")) + { + try + { + _speed = Double.parseDouble(event.getMessage().split(" ")[1]); + + Bukkit.broadcastMessage("SPEED " + _speed); + } + catch (Exception e) + { + + } + } } } 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 2d3fe6e84..817d44178 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 @@ -19,6 +19,7 @@ public class SnakeSegment { private int _entityId = UtilEnt.getNewEntityId(); private Vector _entityLocation; + private Vector _entityLastLocation; private ItemStack _item; private Vector _prevDir = new Vector(); @@ -35,6 +36,8 @@ public class SnakeSegment public Packet[] moveEntity(Vector newLocation) { + _entityLastLocation = _entityLocation.clone(); + Vector toMove = newLocation.clone().subtract(_entityLocation); Packet packet1; @@ -115,6 +118,11 @@ public class SnakeSegment { return _entityLocation.clone(); } + + public Vector getLastLocation() + { + return _entityLastLocation.clone(); + } public Packet[] getSpawn() { From cbab8861d81f5c75ce9bcc31a693d9966cc603db Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sat, 29 Aug 2015 18:58:33 -0700 Subject: [PATCH 2/2] SNakes!! --- .../game/core/boss/snake/SnakeCreature.java | 2 +- .../game/core/boss/snake/SnakeSegment.java | 20 +++++++++---------- .../game/core/boss/spider/SpiderBoss.java | 2 +- .../game/core/boss/spider/SpiderCreature.java | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) 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 8c8dea852..9abca892c 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 @@ -61,7 +61,7 @@ public class SnakeCreature extends EventCreature for (int i = 0; i < getHealth() / 50; i++) { SnakeSegment tail = new SnakeSegment(getSpawnLocation().toVector().subtract(dir.clone().multiply(-i)), - new ItemStack(i == 0 ? Material.EMERALD_BLOCK : Material.STONE)); + new ItemStack(i == 0 ? Material.CHEST : Material.DROPPER)); _segments.add(tail); } 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 2d3fe6e84..af77be3d2 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 @@ -52,8 +52,8 @@ 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); packet1 = relMove; } @@ -70,15 +70,15 @@ 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); packet1 = teleportPacket; } - toMove.normalize(); + Vector vec = new Vector(UtilAlg.GetPitch(toMove), UtilAlg.GetYaw(toMove), 0); - if (toMove.equals(_prevDir)) + if (vec.equals(_prevDir)) { return new Packet[] { @@ -86,14 +86,14 @@ public class SnakeSegment }; } - _prevDir = toMove; + _prevDir = vec; DataWatcher watcher = new DataWatcher(null); - watcher.a(0, (byte) 32); + watcher.a(0, (byte) 0); watcher.a(1, 0); watcher.a(10, (byte) 0); - watcher.a(11, toMove); + watcher.a(11, vec); for (int i = 12; i < 17; i++) { @@ -121,7 +121,7 @@ public class SnakeSegment PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); DataWatcher watcher = new DataWatcher(null); - watcher.a(0, (byte) 32); + watcher.a(0, (byte) 0); watcher.a(1, 0); packet.a = getId(); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderBoss.java index 3d328e7d1..e1f0bacca 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/spider/SpiderBoss.java @@ -17,7 +17,7 @@ public class SpiderBoss extends WorldEvent public SpiderBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, Location cornerLocation) { - super(damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation); + super(damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation, "schematic/Golem.schematic"); } @Override 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 1650fe3a3..a63dce73b 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 @@ -137,7 +137,7 @@ public class SpiderCreature extends EventCreature { try { - ability = (BossAbility) entry.getKey().getConstructor(GolemCreature.class).newInstance(this); + ability = (BossAbility) entry.getKey().getConstructor(SpiderCreature.class).newInstance(this); if (ability.getTarget() == null) {