LivingEntity safeFallDistance
This commit is contained in:
86
patches/server/0086-LivingEntity-safeFallDistance.patch
Normal file
86
patches/server/0086-LivingEntity-safeFallDistance.patch
Normal file
@@ -0,0 +1,86 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sun, 5 May 2019 12:58:45 -0500
|
||||
Subject: [PATCH] LivingEntity safeFallDistance
|
||||
|
||||
Original code by PurpurMC, licensed under MIT
|
||||
You can find the original code on https://github.com/PurpurMC/Purpur
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 638fb5ea3409d2531135567dc03f6319fa849db4..ccaf4c3090b33c9911bac76ae62c6b916349dc74 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -251,6 +251,7 @@ public abstract class LivingEntity extends Entity {
|
||||
// CraftBukkit start
|
||||
public int expToDrop;
|
||||
public int maxAirTicks = 300;
|
||||
+ public float safeFallDistance = 3.0F; // Purpur
|
||||
public boolean forceDrops;
|
||||
public ArrayList<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
|
||||
public final org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes;
|
||||
@@ -346,8 +347,8 @@ public abstract class LivingEntity extends Entity {
|
||||
this.tryAddSoulSpeed();
|
||||
}
|
||||
|
||||
- if (!this.level.isClientSide && this.fallDistance > 3.0F && onGround) {
|
||||
- float f = (float) Mth.ceil(this.fallDistance - 3.0F);
|
||||
+ if (!this.level.isClientSide && this.fallDistance > this.safeFallDistance && onGround) { // Purpur
|
||||
+ float f = (float) Mth.ceil(this.fallDistance - this.safeFallDistance); // Purpur
|
||||
|
||||
if (!landedState.isAir()) {
|
||||
double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D);
|
||||
@@ -1922,7 +1923,7 @@ public abstract class LivingEntity extends Entity {
|
||||
MobEffectInstance mobeffect = this.getEffect(MobEffects.JUMP);
|
||||
float f2 = mobeffect == null ? 0.0F : (float) (mobeffect.getAmplifier() + 1);
|
||||
|
||||
- return Mth.ceil((fallDistance - 3.0F - f2) * damageMultiplier);
|
||||
+ return Mth.ceil((fallDistance - this.safeFallDistance - f2) * damageMultiplier); // Purpur
|
||||
}
|
||||
|
||||
protected void playBlockFallSound() {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
||||
index a726006888bbbdb290bcda3ac4fd45d68ba51b79..829753b2a811e97a16189d932f03f4f652b185c6 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
||||
@@ -286,7 +286,7 @@ public abstract class AbstractHorse extends Animal implements ContainerListener,
|
||||
|
||||
@Override
|
||||
protected int calculateFallDamage(float fallDistance, float damageMultiplier) {
|
||||
- return Mth.ceil((fallDistance * 0.5F - 3.0F) * damageMultiplier);
|
||||
+ return Mth.ceil((fallDistance * 0.5F - this.safeFallDistance) * damageMultiplier);
|
||||
}
|
||||
|
||||
protected int getInventorySize() {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Giant.java b/src/main/java/net/minecraft/world/entity/monster/Giant.java
|
||||
index 0d578ab12c874bd2daccc4322a3fe1abafa4bc18..a183226bb0cf01c5aaf7babe1d08fa9ab7388648 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Giant.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Giant.java
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.world.level.LevelReader;
|
||||
public class Giant extends Monster {
|
||||
public Giant(EntityType<? extends Giant> type, Level world) {
|
||||
super(type, world);
|
||||
+ this.safeFallDistance = 10.0F; // Purpur
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
index c022751e3b45469cc0ad6732e2d6ff08918bafa4..1dcfe129ec3633de67404ab5ab72cdcee31d3d9d 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
@@ -920,4 +920,16 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
throw new IllegalArgumentException(entityCategory + " is an unrecognized entity category");
|
||||
}
|
||||
// Paper end
|
||||
+
|
||||
+ // Purpur start
|
||||
+ @Override
|
||||
+ public float getSafeFallDistance() {
|
||||
+ return getHandle().safeFallDistance;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setSafeFallDistance(float safeFallDistance) {
|
||||
+ getHandle().safeFallDistance = safeFallDistance;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
}
|
||||
Reference in New Issue
Block a user