From b7b81ecaaae3629a550b1adbaed5fa235cc6e003 Mon Sep 17 00:00:00 2001 From: Mini-Chiss Date: Sat, 29 Aug 2015 13:38:40 -0700 Subject: [PATCH] snake --- .../game/core/boss/snake/SnakeBoss.java | 2 +- .../game/games/bossbattles/BattleBoss.java | 2 +- .../game/games/bossbattles/BossBattles.java | 2 +- .../bossbattles/displays/SnakeDisplay.java | 236 +++--------------- 4 files changed, 37 insertions(+), 205 deletions(-) diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/snake/SnakeBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/snake/SnakeBoss.java index 5fe76e901..a64d59878 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/snake/SnakeBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/snake/SnakeBoss.java @@ -16,7 +16,7 @@ public class SnakeBoss extends WorldEvent public SnakeBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, String name, Location cornerLocation) { - super(damageManager, blockRestore, conditionManager, name, cornerLocation); + super(damageManager, blockRestore, conditionManager, "Snaaaake", cornerLocation, "schematic/Golem.schematic"); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BattleBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BattleBoss.java index 4af9f32a3..23f6280ef 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BattleBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BattleBoss.java @@ -10,7 +10,7 @@ import org.bukkit.inventory.ItemStack; public enum BattleBoss { - GOLEM(GolemBoss.class, IronWizardDisplay.class), + GOLEM(GolemBoss.class, IronWizardDisplay.class), SNAKE(SnakeBoss.class, SnakeDisplay.class), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java index 6cadf9887..963c96d1d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java @@ -42,7 +42,7 @@ public class BossBattles extends TeamGame .r(BattleBoss.values().length)]; private ArrayList _displays = new ArrayList(); - public BossBattles(ArcadeManager manager) + public BossBattles(ArcadeManager manager) { super(manager, GameType.BossBattles, new Kit[] { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/displays/SnakeDisplay.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/displays/SnakeDisplay.java index 998273540..06d38bd77 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/displays/SnakeDisplay.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/displays/SnakeDisplay.java @@ -1,163 +1,32 @@ package nautilus.game.arcade.game.games.bossbattles.displays; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.util.NumberConversions; -import org.bukkit.util.Vector; - import mineplex.core.common.util.C; import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.boss.snake.SnakeSegment; import nautilus.game.arcade.game.games.bossbattles.BattleBoss; import nautilus.game.arcade.game.games.bossbattles.BossBattles; -import net.minecraft.server.v1_7_R4.Packet; -import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy; + +import org.bukkit.Location; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.Sheep; +import org.bukkit.entity.Slime; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEntityEvent; public class SnakeDisplay extends BossDisplay { - private ArrayList _snakeTail = new ArrayList(); - private double _seperator = 0.5; - private ArrayList _canSee = new ArrayList(); - private Entity _entity; - private float _yaw; - private float _pitch; + private Sheep _sheep; - public SnakeDisplay(BossBattles plugin, BattleBoss boss, Location location) + public SnakeDisplay(BossBattles plugin, BattleBoss boss, + Location location) { super(plugin, boss, location); } - @Override - public String getDisplayName() - { - return C.cDGreen + "Snake"; - } - - @Override - public void removeBoss() - { - int[] ids = new int[_snakeTail.size()]; - - for (int a = 0; a < _snakeTail.size(); a++) - { - ids[a] = _snakeTail.get(a).getId(); - } - - Packet destroy = new PacketPlayOutEntityDestroy(ids); - - for (Player player : _canSee) - { - UtilPlayer.sendPacket(player, destroy); - } - - _entity.remove(); - } - - @Override - public void start() - { - Vector dir = new Vector(UtilMath.rr(1, true), 0, UtilMath.rr(1, true)) - .normalize().multiply(_seperator); - - for (int i = 0; i < 20; i++) - { - Vector loc = getLocation().toVector() - .subtract(dir.clone().multiply(-i)); - - SnakeSegment tail = new SnakeSegment(loc, new ItemStack( - i == 0 ? Material.COBBLESTONE : Material.STONE)); - _snakeTail.add(tail); - } - - Plugin.CreatureAllowOverride = true; - - _entity = getLocation().getWorld().spawnEntity(getLocation(), - EntityType.IRON_GOLEM); - UtilEnt.Vegetate(_entity); - ((LivingEntity) _entity).addPotionEffect( - new PotionEffect(PotionEffectType.INVISIBILITY, 10000, 0)); - - Plugin.CreatureAllowOverride = false; - - addEntity(_entity); - } - - @EventHandler - public void onSecond(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - { - return; - } - - ArrayList canSee = new ArrayList(); - - for (Player player : getLocation().getWorld().getPlayers()) - { - if (player.getLocation().distance(getLocation()) < 120) - { - canSee.add(player); - } - } - - Iterator itel2 = _canSee.iterator(); - - int[] ids = new int[_snakeTail.size()]; - - for (int a = 0; a < _snakeTail.size(); a++) - { - ids[a] = _snakeTail.get(a).getId(); - } - - Packet destroy = new PacketPlayOutEntityDestroy(ids); - - while (itel2.hasNext()) - { - Player player = itel2.next(); - - if (!canSee.contains(player)) - { - itel2.remove(); - UtilPlayer.sendPacket(player, destroy); - } - } - - for (Player player : canSee) - { - if (!_canSee.contains(player)) - { - _canSee.add(player); - - for (SnakeSegment tail : _snakeTail) - { - UtilPlayer.sendPacket(player, tail.getSpawn()); - } - } - } - } - @EventHandler public void onInteract(PlayerInteractEntityEvent event) { - if (!event.getRightClicked().equals(_entity)) + if (!event.getRightClicked().equals(_sheep)) { return; } @@ -165,78 +34,41 @@ public class SnakeDisplay extends BossDisplay setChosen(event.getPlayer()); } - public void setYaw(float yaw) + @Override + public void start() { - _yaw = (yaw + 720) % 360; + Plugin.CreatureAllowOverride = true; + + _sheep = (Sheep) getLocation().getWorld().spawnEntity(getLocation(), + EntityType.SHEEP); + + _sheep.teleport(getLocation()); + + UtilEnt.Vegetate(_sheep); + + Plugin.CreatureAllowOverride = false; + + addEntity(_sheep); } - public void setPitch(float pitch) + @Override + public String getDisplayName() { - _pitch = (pitch + 720) % 360; + return C.cDGreen + "SNAAAAAAAAAAAAAAAAAKE"; } - public float getPitch() + @Override + public void spawnHologram() { - return _pitch; - } + super.spawnHologram(); - public float getYaw() - { - return _yaw; - } - - @EventHandler - public void onTick(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - { - return; - } - - Packet[] packets = new Packet[_snakeTail.size()]; - - for (int i = 0; i < _snakeTail.size(); i++) - { - SnakeSegment tail = _snakeTail.get(i); - Vector vector = new Vector(); - - if (i == 0) - { - setPitch(getPitch() + 3); - - double rotX = getYaw(); - double rotY = getPitch(); - - vector.setY(-Math.sin(Math.toRadians(rotY))); - - double xz = Math.cos(Math.toRadians(rotY)); - - vector.setX(-xz * Math.sin(Math.toRadians(rotX))); - vector.setZ(xz * Math.cos(Math.toRadians(rotX))); - - vector.normalize().multiply(0.2); - } - else - { - SnakeSegment t = _snakeTail.get(i - 1); - - vector = t.getPrevious().clone().subtract(tail.getLocation()); - } - - packets[i] = tail - .moveEntity(tail.getLocation().clone().add(vector)); - } - - for (Player player : _canSee) - { - UtilPlayer.sendPacket(player, packets); - } + getHologram().setFollowEntity(_sheep); } @Override public Location getHologramLocation() { - return getLocation().clone().add(0, 3, 0); + return _sheep.getEyeLocation().add(0, 0.1, 0); } }