Improved spider.
This commit is contained in:
parent
70f3ccf703
commit
f2485854ef
@ -2,7 +2,9 @@ package mineplex.core.mount.types;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -24,6 +26,7 @@ import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import net.minecraft.server.v1_7_R4.EntityLiving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -150,6 +153,8 @@ public class MountSpider extends HorseMount
|
||||
}
|
||||
}
|
||||
|
||||
private Set<Horse> _jumpCancel = new HashSet<Horse>();
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void doubleJump(PlayerToggleFlightEvent event)
|
||||
{
|
||||
@ -169,6 +174,10 @@ public class MountSpider extends HorseMount
|
||||
if (disguise != null && ((disguise instanceof DisguiseChicken && !((DisguiseChicken)disguise).isBaby()) || disguise instanceof DisguiseBat || disguise instanceof DisguiseEnderman || disguise instanceof DisguiseWither))
|
||||
return;
|
||||
|
||||
Horse horse = GetActive().get(event.getPlayer());
|
||||
|
||||
_jumpCancel.remove(horse);
|
||||
|
||||
event.setCancelled(true);
|
||||
player.setFlying(false);
|
||||
|
||||
@ -176,10 +185,10 @@ public class MountSpider extends HorseMount
|
||||
player.setAllowFlight(false);
|
||||
|
||||
//Velocity
|
||||
UtilAction.velocity(GetActive().get(event.getPlayer()), 1.4, 0.2, 1, true);
|
||||
UtilAction.velocity(horse, 1.4, 0.38, 1, true);
|
||||
|
||||
//Sound
|
||||
player.playSound(player.getLocation(), Sound.SPIDER_IDLE, .4F, 1.0F);
|
||||
player.playSound(horse.getLocation(), Sound.SPIDER_IDLE, .4F, 1.0F);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -187,7 +196,7 @@ public class MountSpider extends HorseMount
|
||||
{
|
||||
for (Player player : GetActive().keySet())
|
||||
{
|
||||
Horse horse = GetActive().get(player);
|
||||
final Horse horse = GetActive().get(player);
|
||||
|
||||
if (!UtilEnt.isGrounded(horse))
|
||||
continue;
|
||||
@ -198,7 +207,7 @@ public class MountSpider extends HorseMount
|
||||
final boolean accessable = jump.isAccessible();
|
||||
|
||||
jump.setAccessible(true);
|
||||
boolean isJumping = jump.getBoolean(player);
|
||||
boolean isJumping = jump.getBoolean(((CraftPlayer) player).getHandle());
|
||||
|
||||
jump.setAccessible(accessable);
|
||||
|
||||
@ -211,7 +220,21 @@ public class MountSpider extends HorseMount
|
||||
//Not jumping anymore
|
||||
((CraftPlayer) player).getHandle().f(false);
|
||||
|
||||
UtilAction.velocity(horse, new Vector(horse.getVelocity().getX(), 0.3, horse.getVelocity().getZ()));
|
||||
_jumpCancel.add(horse);
|
||||
|
||||
//Prevent jump effect when the mount double jumps
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (!_jumpCancel.contains(horse))
|
||||
return;
|
||||
|
||||
_jumpCancel.remove(horse);
|
||||
UtilAction.velocity(horse, new Vector(horse.getVelocity().getX(), 0.5, horse.getVelocity().getZ()).multiply(horse.getVelocity().length()));
|
||||
}
|
||||
}, 5);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user