From cbaaee60d9111c3cce0cd44745eb6c4088ed1ac9 Mon Sep 17 00:00:00 2001 From: Mysticate Date: Fri, 21 Aug 2015 13:00:08 -0400 Subject: [PATCH] Removed mob spectating method from evolving. --- .../mineplex/core/common/util/UtilAlg.java | 21 ++++- .../game/games/evolution/Evolution.java | 2 +- .../games/evolution/evolve/EvolveData.java | 86 +++++++++++-------- .../games/evolution/evolve/PlatformToken.java | 2 +- 4 files changed, 68 insertions(+), 43 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java index ab8f4dfdb..807dbccb5 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java @@ -5,10 +5,8 @@ import java.util.List; import java.util.Set; import java.util.TreeSet; - - - import org.bukkit.Location; +import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -408,4 +406,21 @@ public class UtilAlg return bestLoc; } + + public static Location getNearestCornerLocation(Location near, Block block) + { + ArrayList corners = new ArrayList(); + + corners.add(block.getLocation().clone()); + corners.add(block.getLocation().clone().add(.999, 0, 0)); + corners.add(block.getLocation().clone().add(.999, 0, .999)); + corners.add(block.getLocation().clone().add(0, 0, .999)); + + corners.add(block.getLocation().clone().add(0, .999, 0)); + corners.add(block.getLocation().clone().add(.999, .999, 0)); + corners.add(block.getLocation().clone().add(.999, .999, .999)); + corners.add(block.getLocation().clone().add(0, .999, .999)); + + return UtilAlg.findClosest(near, corners); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java index 89ff75804..a1d4e84bf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java @@ -216,7 +216,7 @@ public class Evolution extends SoloGame @EventHandler(priority = EventPriority.LOWEST) public void endNoEvolve(GameStateChangeEvent event) { - if (event.GetState() != GameState.Prepare) + if (event.GetState() != GameState.Live) return; if (_evoPlatforms.size() <= 0) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/EvolveData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/EvolveData.java index f4c5e59cd..0eb0a12ab 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/EvolveData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/EvolveData.java @@ -8,7 +8,6 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -16,11 +15,9 @@ import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; -import mineplex.core.disguise.disguises.DisguiseArmorStand; import mineplex.core.hologram.Hologram; import mineplex.core.hologram.Hologram.HologramTarget; import mineplex.core.hologram.HologramManager; -import mineplex.core.packethandler.PacketPlayOutCamera; import nautilus.game.arcade.game.games.evolution.EvoKit; import nautilus.game.arcade.game.games.evolution.events.EvolutionBeginEvent; import nautilus.game.arcade.game.games.evolution.events.EvolutionEndEvent; @@ -49,7 +46,6 @@ import org.bukkit.Material; import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; -import org.bukkit.entity.Zombie; import org.bukkit.util.Vector; public class EvolveData @@ -66,7 +62,7 @@ public class EvolveData private final long _preEvolve; private final long _postEvolve; - private EvolveManager _manager; +// private EvolveManager _manager; private HologramManager _holoManager; private final PlatformToken _token; @@ -74,8 +70,8 @@ public class EvolveData private boolean _active = true; private final Player _player; - private Zombie _zombie; - private DisguiseArmorStand _disguise; +// private Zombie _zombie; +// private DisguiseArmorStand _disguise; private final Location _eggLoc; private final SimpleEntry _eggLocData; @@ -95,7 +91,7 @@ public class EvolveData _preEvolve = 3200; _postEvolve = 3400; - _manager = manager; +// _manager = manager; _holoManager = holo; _token = token; @@ -114,8 +110,8 @@ public class EvolveData Bukkit.getServer().getPluginManager().callEvent(new EvolutionBeginEvent(_player)); setupViewingToken(_eFrom); - spawnZombie(); - setupZombie(); +// spawnZombie(); +// setupZombie(); setupPlayer(); setupEgg(); setupHologram(holo, _eFrom, from); @@ -138,37 +134,51 @@ public class EvolveData private void setupViewingToken(EntityInsentient ent) { - Vector viewing = UtilAlg.getTrajectory(_token.Viewing, _token.Platform.clone().add(0.5, (ent.boundingBox.e - ent.boundingBox.b) / 2 - 1, 0.5)); + Location center = _token.Platform.clone().add(0.5, (ent.boundingBox.e - ent.boundingBox.b) / 2 - 1, 0.5); + Location offset = UtilAlg.getNearestCornerLocation(_token.Viewing, center.getBlock()); + + center.setX(offset.getX()); + center.setZ(offset.getZ()); + + Vector viewing = UtilAlg.getTrajectory(_token.Viewing, offset); _token.Viewing.setPitch(UtilAlg.GetPitch(viewing)); } - private void spawnZombie() - { - _manager.Host.CreatureAllowOverride = true; - _zombie = (Zombie) _player.getWorld().spawnEntity(_token.Viewing, EntityType.ZOMBIE); - _manager.Host.CreatureAllowOverride = true; - UtilEnt.Vegetate(_zombie, true); - - _disguise = new DisguiseArmorStand(_zombie); - _disguise.setInvisible(true); - - _manager.Host.Manager.GetDisguise().disguise(_disguise); - } - - private void setupZombie() - { - _disguise.setHeadPosition(_token.Viewing.getDirection()); - - _disguise.UpdateDataWatcher(); - _manager.Host.Manager.GetDisguise().updateDisguise(_disguise); -// ((CraftZombie) _zombie).getHandle().getControllerLook().a(((CraftZombie) _zombie).getHandle(), _token.Viewing.getYaw(), _token.Viewing.getPitch()); - } +// private void spawnZombie() +// { +// _manager.Host.CreatureAllowOverride = true; +// _zombie = (Zombie) _player.getWorld().spawnEntity(_token.Viewing, EntityType.ZOMBIE); +// _manager.Host.CreatureAllowOverride = true; +// UtilEnt.Vegetate(_zombie, true); +// UtilEnt.ghost(_zombie, true, true); +// +// _disguise = new DisguiseArmorStand(_zombie); +// +// _disguise.setInvisible(true); +// _disguise.Global = false; +// +// _manager.Host.Manager.GetDisguise().disguise(_disguise, _player); +// } +// +// private void setupZombie() +// { +// _zombie.teleport(_token.Viewing); +// +// _disguise.setHeadPosition(_token.Viewing.getDirection()); +// +//// _disguise.UpdateDataWatcher(); +// _manager.Host.Manager.GetDisguise().updateDisguise(_disguise); +// +// } private void setupPlayer() { - _player.teleport(_token.Store); + _player.teleport(_token.Viewing); - UtilPlayer.sendPacket(_player, new PacketPlayOutCamera(_zombie.getEntityId())); +// _player.teleport(_token.Store); +// _player.teleport(_token.Viewing); + +// UtilPlayer.sendPacket(_player, new PacketPlayOutCamera(_zombie.getEntityId())); } private void setupHologram(HologramManager manager, EntityInsentient entity, EvoKit kit) @@ -197,7 +207,7 @@ public class EvolveData return true; } - setupZombie(); +// setupZombie(); teleport(); //Hasn't ended yet @@ -221,7 +231,7 @@ public class EvolveData despawn(_eFrom); setupViewingToken(_eTo); - setupZombie(); +// setupZombie(); setupPlayer(); setupHologram(_holoManager, _eTo, _to); @@ -277,8 +287,8 @@ public class EvolveData if (_holo != null) _holo.stop(); - UtilPlayer.sendPacket(_player, new PacketPlayOutCamera(_player)); - _zombie.remove(); +// UtilPlayer.sendPacket(_player, new PacketPlayOutCamera(_player)); +// _zombie.remove(); try { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/PlatformToken.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/PlatformToken.java index a8fc52e90..1525f2dd2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/PlatformToken.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/evolve/PlatformToken.java @@ -10,7 +10,7 @@ public class PlatformToken */ public final Location Platform; - public final Location Viewing; + public final Location Viewing; /**This was when I was using a spectate packet. Will be used again once I can have teh armorstand : >>>>>>>>*/ public final Location Store; public PlatformToken(Location platform, Location viewing, Location store)