mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
parent
eb450b6025
commit
f3655a41ab
1 changed files with 16 additions and 17 deletions
|
@ -1,7 +1,7 @@
|
||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||||
Date: Mon, 2 Aug 2021 10:10:40 +0200
|
Date: Mon, 2 Aug 2021 10:10:40 +0200
|
||||||
Subject: [PATCH] Improve boat collision performance
|
Subject: [PATCH] Check distance in entity interactions
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
|
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
|
||||||
|
@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
.filter(fileSystemProvider -> fileSystemProvider.getScheme().equalsIgnoreCase("jar"))
|
.filter(fileSystemProvider -> fileSystemProvider.getScheme().equalsIgnoreCase("jar"))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElseThrow(() -> new IllegalStateException("No jar file system provider found"));
|
.orElseThrow(() -> new IllegalStateException("No jar file system provider found"));
|
||||||
+ public static final double COLLISION_EPSILON = 1.0E-7; // Paper - Improve boat collision performance
|
+ public static final double COLLISION_EPSILON = 1.0E-7; // Paper - Check distance in entity interactions
|
||||||
private static Consumer<String> thePauser = message -> {
|
private static Consumer<String> thePauser = message -> {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,32 +25,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
Entity entity = source.getDirectEntity();
|
Entity entity = source.getDirectEntity();
|
||||||
|
|
||||||
- if (entity instanceof LivingEntity) {
|
- if (entity instanceof LivingEntity) {
|
||||||
+ if (entity instanceof LivingEntity && entity.distanceToSqr(this) <= (200.0D * 200.0D)) { // Paper - Improve boat collision performance
|
+ if (entity instanceof LivingEntity && entity.distanceToSqr(this) <= (200.0D * 200.0D)) { // Paper - Check distance in entity interactions
|
||||||
LivingEntity entityliving = (LivingEntity) entity;
|
LivingEntity entityliving = (LivingEntity) entity;
|
||||||
|
|
||||||
this.blockUsingShield(entityliving);
|
this.blockUsingShield(entityliving);
|
||||||
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
double d0 = 0.0D;
|
d0 = source.getSourcePosition().x() - this.getX();
|
||||||
double d1 = 0.0D;
|
d1 = source.getSourcePosition().z() - this.getZ();
|
||||||
Entity entity2 = source.getDirectEntity();
|
}
|
||||||
-
|
+ // Paper start - Check distance in entity interactions; see for loop in knockback method
|
||||||
- if (entity2 instanceof Projectile) {
|
+ if (Math.abs(d0) > 200) {
|
||||||
+ // Paper start - improve boat collision performance
|
|
||||||
+ final boolean far = entity2.distanceToSqr(this) > (200.0D * 200.0D);
|
|
||||||
+ if (far) {
|
|
||||||
+ d0 = Math.random() - Math.random();
|
+ d0 = Math.random() - Math.random();
|
||||||
|
+ }
|
||||||
|
+ if (Math.abs(d1) > 200) {
|
||||||
+ d1 = Math.random() - Math.random();
|
+ d1 = Math.random() - Math.random();
|
||||||
+ } else if (entity2 instanceof Projectile) {
|
+ }
|
||||||
+ // Paper end - improve boat collision performance
|
+ // Paper end - Check distance in entity interactions
|
||||||
Projectile iprojectile = (Projectile) entity2;
|
|
||||||
DoubleDoubleImmutablePair doubledoubleimmutablepair = iprojectile.calculateHorizontalHurtKnockbackDirection(this, source);
|
|
||||||
|
|
||||||
|
this.knockback(0.4000000059604645D, d0, d1, entity1, entity1 == null ? io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.DAMAGE : io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // CraftBukkit // Paper - knockback events
|
||||||
|
if (!flag) {
|
||||||
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
this.hurtCurrentlyUsedShield((float) -event.getDamage(DamageModifier.BLOCKING));
|
this.hurtCurrentlyUsedShield((float) -event.getDamage(DamageModifier.BLOCKING));
|
||||||
Entity entity = damagesource.getDirectEntity();
|
Entity entity = damagesource.getDirectEntity();
|
||||||
|
|
||||||
- if (!damagesource.is(DamageTypeTags.IS_PROJECTILE) && entity instanceof LivingEntity) { // Paper - Fix shield disable inconsistency
|
- if (!damagesource.is(DamageTypeTags.IS_PROJECTILE) && entity instanceof LivingEntity) { // Paper - Fix shield disable inconsistency
|
||||||
+ if (!damagesource.is(DamageTypeTags.IS_PROJECTILE) && entity instanceof LivingEntity && entity.distanceToSqr(this) <= (200.0D * 200.0D)) { // Paper - Fix shield disable inconsistency & improve boat collision performance
|
+ if (!damagesource.is(DamageTypeTags.IS_PROJECTILE) && entity instanceof LivingEntity && entity.distanceToSqr(this) <= (200.0D * 200.0D)) { // Paper - Fix shield disable inconsistency & Check distance in entity interactions
|
||||||
this.blockUsingShield((LivingEntity) entity);
|
this.blockUsingShield((LivingEntity) entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +62,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
|
|
||||||
if (this.level().noCollision(this, this.getBoundingBox().move(0.0D, d2 - this.getY(), 0.0D))) {
|
if (this.level().noCollision(this, this.getBoundingBox().move(0.0D, d2 - this.getY(), 0.0D))) {
|
||||||
- this.setPos(this.getX(), d2, this.getZ());
|
- this.setPos(this.getX(), d2, this.getZ());
|
||||||
+ this.move(MoverType.SELF, new Vec3(0.0D, d2 - this.getY(), 0.0D)); // Paper - improve boat collision performance
|
+ this.move(MoverType.SELF, new Vec3(0.0D, d2 - this.getY(), 0.0D)); // Paper - Check distance in entity interactions // TODO Still needed?
|
||||||
this.setDeltaMovement(this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D));
|
this.setDeltaMovement(this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D));
|
||||||
this.lastYd = 0.0D;
|
this.lastYd = 0.0D;
|
||||||
}
|
}
|
Loading…
Reference in a new issue