Increase max controllable speed

This commit is contained in:
fullwall 2020-01-12 21:08:29 +09:00
parent 41f4c6e1b4
commit cd21b9fb8a

View File

@ -34,8 +34,8 @@ import net.citizensnpcs.util.Util;
/** /**
* Persists the controllable status for /npc controllable * Persists the controllable status for /npc controllable
* *
* A controllable {@link NPC} can be mounted by a {@link Player} using right click or /npc mount and moved around using * A controllable {@link NPC} can be mounted by a {@link Player} using right
* e.g. arrow keys. * click or /npc mount and moved around using e.g. arrow keys.
*/ */
@TraitName("controllable") @TraitName("controllable")
public class Controllable extends Trait implements Toggleable, CommandConfigurable { public class Controllable extends Trait implements Toggleable, CommandConfigurable {
@ -134,8 +134,7 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
/** /**
* Attempts to mount the {@link NPC} onto the supplied {@link Player}. * Attempts to mount the {@link NPC} onto the supplied {@link Player}.
* *
* @param toMount * @param toMount the player to mount
* the player to mount
* @return whether the mount was successful * @return whether the mount was successful
*/ */
public boolean mount(Player toMount) { public boolean mount(Player toMount) {
@ -160,16 +159,16 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
if (NMS.getPassengers(npc.getEntity()).contains(npc.getEntity())) if (NMS.getPassengers(npc.getEntity()).contains(npc.getEntity()))
return; return;
switch (performed) { switch (performed) {
case RIGHT_CLICK_BLOCK: case RIGHT_CLICK_BLOCK:
case RIGHT_CLICK_AIR: case RIGHT_CLICK_AIR:
controller.rightClick(event); controller.rightClick(event);
break; break;
case LEFT_CLICK_BLOCK: case LEFT_CLICK_BLOCK:
case LEFT_CLICK_AIR: case LEFT_CLICK_AIR:
controller.leftClick(event); controller.leftClick(event);
break; break;
default: default:
break; break;
} }
} }
@ -210,10 +209,10 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
} }
/** /**
* Configures the explicit typei.e. whether the NPC should be controlled as if it was a certain {@link EntityType}. * Configures the explicit typei.e. whether the NPC should be controlled as if
* it was a certain {@link EntityType}.
* *
* @param type * @param type the explicit type
* the explicit type
*/ */
public void setExplicitType(EntityType type) { public void setExplicitType(EntityType type) {
this.explicitType = type; this.explicitType = type;
@ -239,8 +238,8 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
} }
/** /**
* Sets whether the {@link Player} attempting to mount the {@link NPC} must actually own the {@link NPC} to mount * Sets whether the {@link Player} attempting to mount the {@link NPC} must
* it. * actually own the {@link NPC} to mount it.
* *
* @see Owner#isOwnedBy(org.bukkit.command.CommandSender) * @see Owner#isOwnedBy(org.bukkit.command.CommandSender)
*/ */
@ -272,17 +271,17 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
new Vector(passenger.getVelocity().getX() * speedMod, 0D, passenger.getVelocity().getZ() * speedMod)); new Vector(passenger.getVelocity().getX() * speedMod, 0D, passenger.getVelocity().getZ() * speedMod));
double newSpeed = Math.sqrt(vel.getX() * vel.getX() + vel.getZ() * vel.getZ()); double newSpeed = Math.sqrt(vel.getX() * vel.getX() + vel.getZ() * vel.getZ());
if (newSpeed > 0.35D) { if (newSpeed > 0.5D) {
double movementFactor = 0.35D / newSpeed; double movementFactor = 0.5D / newSpeed;
vel = vel.multiply(new Vector(movementFactor, 1, movementFactor)); vel = vel.multiply(new Vector(movementFactor, 1, movementFactor));
newSpeed = 0.35D; newSpeed = 0.5D;
} }
handle.setVelocity(vel); handle.setVelocity(vel);
if (newSpeed > oldSpeed && speed < 0.35D) { if (newSpeed > oldSpeed && speed < 0.5D) {
return (float) Math.min(0.35D, (speed + ((0.35D - speed) / 35.0D))); return (float) Math.min(0.5D, (speed + ((0.5D - speed) / 50.0D)));
} else { } else {
return (float) Math.max(0.07D, (speed - ((speed - 0.07D) / 35.0D))); return (float) Math.max(0.07D, (speed - ((speed - 0.07D) / 50.0D)));
} }
} }
@ -405,15 +404,14 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
} }
/** /**
* Register a movement controller for a certain {@link EntityType} to be used for {@link NPC}s with that type. * Register a movement controller for a certain {@link EntityType} to be used
* for {@link NPC}s with that type.
* *
* Default controllers are registered for BAT, BLAZE, ENDER_DRAGON, GHAST, WITHER and PARROT using * Default controllers are registered for BAT, BLAZE, ENDER_DRAGON, GHAST,
* {@link PlayerInputAirController}. * WITHER and PARROT using {@link PlayerInputAirController}.
* *
* @param type * @param type the entity type
* the entity type * @param clazz the controller class
* @param clazz
* the controller class
*/ */
public static void registerControllerType(EntityType type, Class<? extends MovementController> clazz) { public static void registerControllerType(EntityType type, Class<? extends MovementController> clazz) {
try { try {