From 11e951693d31beba16ed1dca2111f1ccb9b8d91b Mon Sep 17 00:00:00 2001 From: cheaterpaul Date: Sat, 1 Jun 2024 13:20:07 +0200 Subject: [PATCH] change leap movement based on werewolf form --- .../api/entities/werewolf/WerewolfForm.java | 18 ++++++++++++------ .../entities/player/ModPlayerEventHandler.java | 4 +++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/api/java/de/teamlapen/werewolves/api/entities/werewolf/WerewolfForm.java b/src/api/java/de/teamlapen/werewolves/api/entities/werewolf/WerewolfForm.java index d4f1eb97..f0c4a226 100644 --- a/src/api/java/de/teamlapen/werewolves/api/entities/werewolf/WerewolfForm.java +++ b/src/api/java/de/teamlapen/werewolves/api/entities/werewolf/WerewolfForm.java @@ -10,11 +10,11 @@ public class WerewolfForm { private static final Map REGISTRY = new HashMap<>(); - public static final WerewolfForm NONE = new WerewolfForm("none", null, true, false, 0, 0F, true); - public static final WerewolfForm HUMAN = new WerewolfForm("human", null, true, true, 3, 0.05F, true); - public static final WerewolfForm BEAST = new WerewolfForm("beast", WerewolfSize.BEAST, false, true, 11, 0.2F, true); - public static final WerewolfForm BEAST4L = new WerewolfForm("beast4l", WerewolfSize.BEAST, false, true, 11, 0.3F, false); - public static final WerewolfForm SURVIVALIST = new WerewolfForm("survivalist", WerewolfSize.SURVIVAL, false, true, 11, 0.4F, false); + public static final WerewolfForm NONE = new WerewolfForm("none", null, true, false, 0, 0F, true, 0); + public static final WerewolfForm HUMAN = new WerewolfForm("human", null, true, true, 3, 0.05F, true, 0.16f); + public static final WerewolfForm BEAST = new WerewolfForm("beast", WerewolfSize.BEAST, false, true, 11, 0.2F, true, 0.32f); + public static final WerewolfForm BEAST4L = new WerewolfForm("beast4l", WerewolfSize.BEAST, false, true, 11, 0.3F, false, 0.32f); + public static final WerewolfForm SURVIVALIST = new WerewolfForm("survivalist", WerewolfSize.SURVIVAL, false, true, 11, 0.4F, false, 0.8f); @Nonnull private final String name; @@ -26,8 +26,9 @@ public class WerewolfForm { private final Component textComponent; private final float damageReduction; private final boolean hasArms; + private final float leapModifier; - WerewolfForm(@Nonnull String name, @Nullable Map sizeMap, boolean humanLike, boolean transformed, int skinTypes, float damageReduction, boolean hasArms) { + WerewolfForm(@Nonnull String name, @Nullable Map sizeMap, boolean humanLike, boolean transformed, int skinTypes, float damageReduction, boolean hasArms, float leapModifier) { if (REGISTRY.containsKey(name)) throw new IllegalStateException("this name already exists"); REGISTRY.put(name, this); if (sizeMap == null) { @@ -41,6 +42,7 @@ public class WerewolfForm { this.textComponent = Component.translatable("form.werewolves." + name); this.damageReduction = damageReduction; this.hasArms = hasArms; + this.leapModifier = leapModifier; } public boolean isHumanLike() { @@ -86,4 +88,8 @@ public static WerewolfForm getForm(String name) { public static Collection getAllForms() { return new ArrayList<>(REGISTRY.values()); } + + public float getLeapModifier() { + return leapModifier; + } } diff --git a/src/main/java/de/teamlapen/werewolves/entities/player/ModPlayerEventHandler.java b/src/main/java/de/teamlapen/werewolves/entities/player/ModPlayerEventHandler.java index 5cb75459..650c1d61 100644 --- a/src/main/java/de/teamlapen/werewolves/entities/player/ModPlayerEventHandler.java +++ b/src/main/java/de/teamlapen/werewolves/entities/player/ModPlayerEventHandler.java @@ -134,7 +134,9 @@ public void onJump(LivingEvent.LivingJumpEvent event) { if (!werewolf.getSpecialAttributes().leap) { werewolf.getSpecialAttributes().leap = true; Vec3 viewVector = entity.getViewVector(0); - entity.addDeltaMovement(new Vec3(viewVector.x, ((LivingEntityAccessor) entity).invokeGetJumpPower_werewolves() * 0.5, viewVector.z).multiply(0.8,0.8,0.8)); + Vec3 leap = new Vec3(viewVector.x, ((LivingEntityAccessor) entity).invokeGetJumpPower_werewolves() * 0.5, viewVector.z); + float leapModifier = werewolf.getForm().getLeapModifier(); + entity.addDeltaMovement(leap.multiply(leapModifier, leapModifier, leapModifier)); } }