Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.20.1]Should Horse post LivingFallEvent? #9743

Closed
Ecdcaeb opened this issue Oct 8, 2023 · 1 comment
Closed

[1.20.1]Should Horse post LivingFallEvent? #9743

Ecdcaeb opened this issue Oct 8, 2023 · 1 comment

Comments

@Ecdcaeb
Copy link

Ecdcaeb commented Oct 8, 2023

Minecraft Version: 1.20.1

Forge Version: 47.2.1

Logs: NONE

Steps to Reproduce:
NONE

Description of issue:
CleanroomMC/Cleanroom#13
here is a issue of CleanroomMC(a fork of Forge of mc1.12.2)
It is noticed that Forge doesn't call LivingFallEvent when a horse(or a llama) falls in 47.2.1.

note: use parchment 2023.06.26-1.20.1
LivingEntity

public boolean causeFallDamage(float pFallDistance, float pMultiplier, DamageSource pSource) {
      float[] ret = net.minecraftforge.common.ForgeHooks.onLivingFall(this, pFallDistance, pMultiplier);//**here post event**
      if (ret == null) return false;
      pFallDistance = ret[0];
      pMultiplier = ret[1];

      boolean flag = super.causeFallDamage(pFallDistance, pMultiplier, pSource);
      int i = this.calculateFallDamage(pFallDistance, pMultiplier);
      if (i > 0) {
         this.playSound(this.getFallDamageSound(i), 1.0F, 1.0F);
         this.playBlockFallSound();
         this.hurt(pSource, (float)i);
         return true;
      } else {
         return flag;
      }
   }

AbstractHorse

public boolean causeFallDamage(float pFallDistance, float pMultiplier, DamageSource pSource) {
      if (pFallDistance > 1.0F) {
         this.playSound(SoundEvents.HORSE_LAND, 0.4F, 1.0F);
      }

      int i = this.calculateFallDamage(pFallDistance, pMultiplier);
      if (i <= 0) {
         return false;
      } else {
         this.hurt(pSource, (float)i);
         if (this.isVehicle()) {
            for(Entity entity : this.getIndirectPassengers()) {
               entity.hurt(pSource, (float)i);
            }
         }

         this.playBlockFallSound();
         return true;
      }
   }
protected int calculateFallDamage(float pDistance, float pDamageMultiplier) {
      return Mth.ceil((pDistance * 0.5F - 3.0F) * pDamageMultiplier);
   }

no event post here.

@Ecdcaeb Ecdcaeb added the Triage This request requires the active attention of the Triage Team. Requires labelling or reviews. label Oct 8, 2023
@Ecdcaeb Ecdcaeb changed the title Should Horse calls LivingFallEvent? Should Horse post LivingFallEvent? Oct 8, 2023
@Ecdcaeb Ecdcaeb changed the title Should Horse post LivingFallEvent? [1.20.1]Should Horse post LivingFallEvent? Oct 8, 2023
@autoforge autoforge bot removed the Triage This request requires the active attention of the Triage Team. Requires labelling or reviews. label Oct 9, 2023
@Ecdcaeb
Copy link
Author

Ecdcaeb commented Oct 12, 2023

@LexManos
hey lex.
Since we get the true parameters from event

+      var event = net.minecraftforge.event.ForgeEventFactory.onLivingFall(this, p_147187_, p_147188_);
+      if (event.isCanceled()) return false;
+      p_147187_ = event.getDistance();
+      p_147188_ = event.getDamageMultiplier();

should we post this event before the invoking of this method?
To prevent the second horse which do not super.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant