Skip to content

Commit

Permalink
change leap movement based on werewolf form
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheaterpaul committed Jun 7, 2024
1 parent afbfa47 commit 11e9516
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

public class WerewolfForm {
private static final Map<String, WerewolfForm> 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;
Expand All @@ -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<Pose, EntityDimensions> sizeMap, boolean humanLike, boolean transformed, int skinTypes, float damageReduction, boolean hasArms) {
WerewolfForm(@Nonnull String name, @Nullable Map<Pose, EntityDimensions> 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) {
Expand All @@ -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() {
Expand Down Expand Up @@ -86,4 +88,8 @@ public static WerewolfForm getForm(String name) {
public static Collection<WerewolfForm> getAllForms() {
return new ArrayList<>(REGISTRY.values());
}

public float getLeapModifier() {
return leapModifier;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down

0 comments on commit 11e9516

Please sign in to comment.