[ci skip] micro opt when applying block friction on flying ridable mobs

This commit is contained in:
granny
2025-06-29 23:28:54 -07:00
parent 04a9045d98
commit 175bb181af
3 changed files with 13 additions and 18 deletions

View File

@@ -177,7 +177,7 @@ index f0c452ddc4b299a930de261722cc41a89aa78eeb..8e8ddab59de508c84c4182e105a11554
protected ParticleOptions getInkParticle() {
return ParticleTypes.GLOW_SQUID_INK;
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
index 96e47e6145a4cce8c154a05f9b155c1ba74bfa6a..388d2e87696d9d3ec265355ec3602a03aa3151bb 100644
index 96e47e6145a4cce8c154a05f9b155c1ba74bfa6a..4f67ae2491d053d3d7261440c029da512dc1002b 100644
--- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java
@@ -238,9 +238,9 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
@@ -210,26 +210,21 @@ index 96e47e6145a4cce8c154a05f9b155c1ba74bfa6a..388d2e87696d9d3ec265355ec3602a03
@Override
protected void checkFallDamage(double y, boolean onGround, BlockState state, BlockPos pos) {
@@ -3026,6 +3027,26 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
@@ -3026,6 +3027,21 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
this.move(MoverType.SELF, this.getDeltaMovement());
this.setDeltaMovement(this.getDeltaMovement().scale(0.5));
} else {
+ // Purpur start - Ridables
+ if (this.getRider() != null && this.isControllable()) {
+ float f = 0.91F;
+ float friction = 0.91F;
+ if (this.onGround()) {
+ f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.91F;
+ friction = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.91F;
+ }
+
+ float f1 = 0.16277137F / (f * f * f);
+ f = 0.91F;
+ if (this.onGround()) {
+ f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.91F;
+ }
+
+ this.moveRelative(this.onGround() ? 0.1F * f1 : 0.02F, relative);
+ float frictionCompensation = 0.16277137F / (friction * friction * friction);
+ this.moveRelative(this.onGround() ? 0.1F * frictionCompensation : 0.02F, relative);
+ this.move(MoverType.SELF, this.getDeltaMovement());
+ this.setDeltaMovement(this.getDeltaMovement().scale(f));
+ this.setDeltaMovement(this.getDeltaMovement().scale(friction));
+ return;
+ }
+ // Purpur end - Ridables
@@ -237,7 +232,7 @@ index 96e47e6145a4cce8c154a05f9b155c1ba74bfa6a..388d2e87696d9d3ec265355ec3602a03
this.moveRelative(amount, relative);
this.move(MoverType.SELF, this.getDeltaMovement());
this.setDeltaMovement(this.getDeltaMovement().scale(0.91F));
@@ -3629,8 +3650,10 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
@@ -3629,8 +3645,10 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
this.pushEntities();
profilerFiller.pop();
// Paper start - Add EntityMoveEvent
@@ -250,7 +245,7 @@ index 96e47e6145a4cce8c154a05f9b155c1ba74bfa6a..388d2e87696d9d3ec265355ec3602a03
Location from = new Location(this.level().getWorld(), this.xo, this.yo, this.zo, this.yRotO, this.xRotO);
Location to = new Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
io.papermc.paper.event.entity.EntityMoveEvent event = new io.papermc.paper.event.entity.EntityMoveEvent(this.getBukkitLivingEntity(), from, to.clone());
@@ -3640,6 +3663,21 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
@@ -3640,6 +3658,21 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
this.absSnapTo(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
}
}

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Implement elytra settings
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
index bc26752293f8edd7d40bfc161b235c2a6eaf2c29..de3bb90db932cc452a81b0a2b267f00a51f0e47b 100644
index 7d0a8048cea101be9747a2b89713288f53ce6637..49089d7235857e2d788002c1bc6d0fe5979e7ec0 100644
--- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java
@@ -3719,7 +3719,18 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
@@ -3714,7 +3714,18 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
.filter(equipmentSlot1 -> canGlideUsing(this.getItemBySlot(equipmentSlot1), equipmentSlot1))
.toList();
EquipmentSlot equipmentSlot = Util.getRandom(list, this.random);

View File

@@ -35,7 +35,7 @@ index 34e0fbef06b0c7aededf27fe9dc64f3f6f33e3ae..ce3e5ec505ac37c820436bcf7c7d6452
this.type = entityType;
this.level = level;
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
index 78875973599112f8b5602bec78ce075aac0df94c..c935fe512480fe927d72570674579a5685bde366 100644
index eeb8e244f57a5c36b99c13dd20cc635694d83f34..70fa06167ad67bd201d37b1666960c9b69743c76 100644
--- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java
@@ -286,6 +286,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
@@ -62,7 +62,7 @@ index 78875973599112f8b5602bec78ce075aac0df94c..c935fe512480fe927d72570674579a56
this.lastHurtByPlayer = EntityReference.read(input, "last_hurt_by_player");
this.lastHurtByPlayerMemoryTime = input.getIntOr("last_hurt_by_player_memory_time", 0);
this.lastHurtByMob = EntityReference.read(input, "last_hurt_by_mob");
@@ -3686,6 +3689,32 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
@@ -3681,6 +3684,32 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
if (this.level() instanceof ServerLevel serverLevel && this.isSensitiveToWater() && this.isInWaterOrRain()) {
this.hurtServer(serverLevel, this.damageSources().drown(), 1.0F);
}