mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-29 19:41:50 +01:00
Clean up jump implementation and remove left click to jump
This commit is contained in:
parent
b6b160e99b
commit
9c4b0f41d2
@ -2,8 +2,6 @@ package net.citizensnpcs.trait;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
import net.citizensnpcs.Settings.Setting;
|
||||
@ -241,7 +239,6 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
|
||||
|
||||
@Override
|
||||
public void leftClick(PlayerInteractEvent event) {
|
||||
jump();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -283,23 +280,24 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
|
||||
newSpeed = 0.35D;
|
||||
}
|
||||
|
||||
boolean shouldJump = false;
|
||||
try {
|
||||
if (JUMP_FIELD.getBoolean(handle.passenger)) {
|
||||
if (handle.onGround && jumpTicks == 0) {
|
||||
JUMP_METHOD.invoke(handle, (Object[]) null);
|
||||
jumpTicks = 10;
|
||||
}
|
||||
} else {
|
||||
jumpTicks = 0;
|
||||
}
|
||||
jumpTicks = Math.max(0, jumpTicks - 1);
|
||||
if (JUMP_FIELD != null)
|
||||
shouldJump = JUMP_FIELD.getBoolean(handle.passenger);
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (shouldJump) {
|
||||
if (handle.onGround && jumpTicks == 0) {
|
||||
jump();
|
||||
jumpTicks = 10;
|
||||
}
|
||||
} else {
|
||||
jumpTicks = 0;
|
||||
}
|
||||
jumpTicks = Math.max(0, jumpTicks - 1);
|
||||
|
||||
if (newSpeed > oldSpeed && this.speed < 0.35D) {
|
||||
this.speed = Math.min(0.35D, (this.speed + ((0.35D - this.speed) / 35.0D)));
|
||||
@ -325,22 +323,7 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
|
||||
|
||||
private static final Map<EntityType, Class<? extends MovementController>> controllerTypes = Maps
|
||||
.newEnumMap(EntityType.class);
|
||||
|
||||
private static Field JUMP_FIELD;
|
||||
private static Method JUMP_METHOD = null;
|
||||
|
||||
static {
|
||||
JUMP_FIELD = NMS.getField(EntityLiving.class, "bd");
|
||||
JUMP_FIELD.setAccessible(true);
|
||||
try {
|
||||
JUMP_METHOD = EntityLiving.class.getDeclaredMethod("ba", (Class<?>[]) null);
|
||||
JUMP_METHOD.setAccessible(true);
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private static final Field JUMP_FIELD = NMS.getField(EntityLiving.class, "bd");
|
||||
|
||||
static {
|
||||
controllerTypes.put(EntityType.BAT, AirController.class);
|
||||
|
@ -1,15 +0,0 @@
|
||||
members:
|
||||
"org/bukkit/entity/Damageable _INVALID_damage (I)V": damage
|
||||
"org/bukkit/entity/Damageable _INVALID_damage (ILorg/bukkit/entity/Entity;)V": damage
|
||||
"org/bukkit/entity/Damageable _INVALID_getHealth ()I": getHealth
|
||||
"org/bukkit/entity/Damageable _INVALID_setHealth (I)V": setHealth
|
||||
"org/bukkit/entity/Damageable _INVALID_getMaxHealth ()I": getMaxHealth
|
||||
"org/bukkit/entity/Damageable _INVALID_setMaxHealth (I)V": setMaxHealth
|
||||
"org/bukkit/entity/LivingEntity _INVALID_getLastDamage ()I": getLastDamage
|
||||
"org/bukkit/entity/LivingEntity _INVALID_setLastDamage (I)V": setLastDamage
|
||||
"org/bukkit/event/entity/EntityDamageEvent _INVALID_getDamage ()I": getDamage
|
||||
"org/bukkit/event/entity/EntityDamageEvent _INVALID_setDamage (I)V": setDamage
|
||||
"org/bukkit/event/vehicle/VehicleDamageEvent _INVALID_getDamage ()I": getDamage
|
||||
"org/bukkit/event/vehicle/VehicleDamageEvent _INVALID_setDamage (I)V": setDamage
|
||||
"org/bukkit/event/entity/EntityRegainHealthEvent _INVALID_getAmount ()I": getAmount
|
||||
"org/bukkit/event/entity/EntityRegainHealthEvent _INVALID_setAmount (I)V": setAmount
|
Loading…
Reference in New Issue
Block a user