From 593952fa108444cfb58547fa3d5274f9cf3fbed1 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 27 Nov 2017 16:05:38 +0000 Subject: [PATCH] Fix the sledge mount's offset --- .../gadgets/mount/types/MountSledge.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/mount/types/MountSledge.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/mount/types/MountSledge.java index 9fd3723ee..73c75fdf0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/mount/types/MountSledge.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/mount/types/MountSledge.java @@ -1,10 +1,13 @@ package mineplex.core.gadget.gadgets.mount.types; import java.util.Arrays; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -14,6 +17,9 @@ import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilText; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.mount.Mount; @@ -39,7 +45,7 @@ public class MountSledge extends Mount @Override public MountSledgeData spawnMount(Player player) { - Location location = player.getLocation().subtract(0, 1.5, 0); + Location location = player.getLocation().subtract(0, 0.5, 0); ArmorStand front = player.getWorld().spawn(location, ArmorStand.class); ArmorStand back = player.getWorld().spawn(location, ArmorStand.class); @@ -62,17 +68,33 @@ public class MountSledge extends Mount return; } + Set toRemove = new HashSet<>(); + for (MountSledgeData data : _active.values()) { + if (data.getOwner().getVehicle() == null) + { + toRemove.add(data.getOwner()); + } + ArmorStand front = data.Front; ArmorStand back = data.Back; + Location playerLocation = data.getOwner().getLocation(); playerLocation.setPitch(0); - Vector direction = playerLocation.getDirection().multiply(0.1); + Vector direction = playerLocation.getDirection().multiply(0.5); - front.teleport(front.getLocation().add(direction)); - back.teleport(back.getLocation().add(direction)); + Location newLocation = back.getLocation().add(direction); + ((CraftEntity) back).getHandle().setPositionRotation(newLocation.getX(), newLocation.getY(), newLocation.getZ(), playerLocation.getYaw(), 0); + + newLocation.add(direction.multiply(1.6)); + newLocation.setYaw(playerLocation.getYaw()); + front.teleport(newLocation); + + UtilParticle.PlayParticleToAll(ParticleType.SNOW_SHOVEL, playerLocation, 0.3F, 0, 0.3F, 0.1F, 2, ViewDist.NORMAL); } + + toRemove.forEach(this::disable); } class MountSledgeData extends MountData