mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-21 15:59:26 +00:00
Fix explosion player velocity
The player velocity was not being talied correctly, and velocity was not sent when explosion effects were disabled in fps settings.
This commit is contained in:
@@ -294,18 +294,30 @@ index 7fb9ba3dadb1eca4a1000ea8cf4d13fed2b7db1e..7fb48e8924e7f6acfcaaecf284f9bf19
|
||||
if (flag && !player.getBukkitEntity().canSee(this.entity.getBukkitEntity())) { // Paper - only consider hits
|
||||
flag = false;
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index b5a66132f7ec10feb4682db38c80e5064e78f9f3..747ebfb09dcd4c619ee0543c8aa79c05416687a4 100644
|
||||
index b5a66132f7ec10feb4682db38c80e5064e78f9f3..35ec5faff8a1cad4c35ee075885889844534efc9 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1959,7 +1959,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
while (iterator.hasNext()) {
|
||||
@@ -1960,7 +1960,19 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
|
||||
|
||||
- if (entityplayer.distanceToSqr(x, y, z) < 4096.0D) {
|
||||
+ if (entityplayer.distanceToSqr(x, y, z) < 4096.0D && !entityplayer.visibility.isToggled(me.samsuik.sakura.player.visibility.Visibility.Setting.EXPLOSIONS)) { // Sakura - visibility api
|
||||
entityplayer.connection.send(new ClientboundExplodePacket(x, y, z, power, explosion.getToBlow(), (Vec3) explosion.getHitPlayers().get(entityplayer), explosion.getBlockInteraction(), explosion.getSmallExplosionParticles(), explosion.getLargeExplosionParticles(), explosion.getExplosionSound()));
|
||||
if (entityplayer.distanceToSqr(x, y, z) < 4096.0D) {
|
||||
- entityplayer.connection.send(new ClientboundExplodePacket(x, y, z, power, explosion.getToBlow(), (Vec3) explosion.getHitPlayers().get(entityplayer), explosion.getBlockInteraction(), explosion.getSmallExplosionParticles(), explosion.getLargeExplosionParticles(), explosion.getExplosionSound()));
|
||||
+ // Sakura start - visibility api; let players toggle explosion particles
|
||||
+ ParticleOptions smallParticle = explosion.getSmallExplosionParticles();
|
||||
+ ParticleOptions largeParticle = explosion.getLargeExplosionParticles();
|
||||
+ Vec3 position = new Vec3(x, y, z);
|
||||
+ // In 1.22 and later this should be replaced with sending the motion through a PlayerPositionPacket.
|
||||
+ // The problem here is SetEntityMotion is capped to 3.9 b/pt and the only other alternate mean was
|
||||
+ // implemented in 1.21.3. I believe it's best to just wait on this issue and deal with this hack.
|
||||
+ if (entityplayer.visibility.isToggled(me.samsuik.sakura.player.visibility.Visibility.Setting.EXPLOSIONS)) {
|
||||
+ position = new Vec3(0.0, -1024.0, 0.0);
|
||||
+ smallParticle = largeParticle = net.minecraft.core.particles.ParticleTypes.SMOKE;
|
||||
+ }
|
||||
+ entityplayer.connection.send(new ClientboundExplodePacket(position.x(), position.y(), position.z(), power, explosion.getToBlow(), (Vec3) explosion.getHitPlayers().get(entityplayer), explosion.getBlockInteraction(), smallParticle, largeParticle, explosion.getExplosionSound()));
|
||||
+ // Sakura end - visibility api; let players toggle explosion particles
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 6a4637eef14cbd84bbe26ef16f004b8f93367a3d..bed136477493365d62d1b82e8f7802513a394991 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
|
||||
@@ -23,10 +23,10 @@ index 0fd814f1d65c111266a2b20f86561839a4cef755..932f7a0d030d2d4932e6e6d4a5805e9b
|
||||
if (index >= 0) {
|
||||
diff --git a/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..d15eb10fa203236060b90c5fc1364564dec8753f
|
||||
index 0000000000000000000000000000000000000000..ce676a021dd375959e9403b237bad864cd2b7da2
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java
|
||||
@@ -0,0 +1,200 @@
|
||||
@@ -0,0 +1,201 @@
|
||||
+package me.samsuik.sakura.explosion.special;
|
||||
+
|
||||
+import io.papermc.paper.util.WorldUtil;
|
||||
@@ -113,6 +113,7 @@ index 0000000000000000000000000000000000000000..d15eb10fa203236060b90c5fc1364564
|
||||
+
|
||||
+ if (!this.wasCanceled) {
|
||||
+ this.level.notifyPlayersOfExplosion(this.x, this.y, this.z, this.radius(), this);
|
||||
+ this.getHitPlayers().clear();
|
||||
+ }
|
||||
+
|
||||
+ this.getToBlow().clear();
|
||||
@@ -435,7 +436,7 @@ index 0000000000000000000000000000000000000000..6bcef992766b901db34494a4d359ba33
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index ada18c755cee73620e6c0020674dd0a5a1d8f79d..00259cc930a0b1db38c3abbb5fcf7430d5f50079 100644
|
||||
index 352a8d62dd25c4c612abe016c7038bdfd13006f2..e68ea2ac656085fbe25eb19c14793889cdafab8c 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1964,6 +1964,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
@@ -451,7 +452,7 @@ index ada18c755cee73620e6c0020674dd0a5a1d8f79d..00259cc930a0b1db38c3abbb5fcf7430
|
||||
Iterator iterator = this.players.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -1974,7 +1980,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
@@ -1986,7 +1992,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -495,7 +496,7 @@ index dc9d72bc033735dd83d7b0f3fe79d0a51b9661ab..6cfa54da058939003576025cb0512e0b
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
index 103eca429d899f4d004ac0cb1996339e66543080..d10d2581c6dfdaf7518bead4f2340c1b63b4bc44 100644
|
||||
index 103eca429d899f4d004ac0cb1996339e66543080..b2ba5d761e21023ef4e3ee01c7318a7a586e650b 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
@@ -56,9 +56,11 @@ public class Explosion {
|
||||
@@ -578,7 +579,19 @@ index 103eca429d899f4d004ac0cb1996339e66543080..d10d2581c6dfdaf7518bead4f2340c1b
|
||||
// use initial cache value that is most likely to be used: the source position
|
||||
final ExplosionBlockCache initialCache;
|
||||
{
|
||||
@@ -994,7 +1011,7 @@ public class Explosion {
|
||||
@@ -757,7 +774,10 @@ public class Explosion {
|
||||
Player entityhuman = (Player) entity;
|
||||
|
||||
if (!entityhuman.isSpectator() && (!entityhuman.isCreative() || !entityhuman.getAbilities().flying) && !level.paperConfig().environment.disableExplosionKnockback) { // Paper - Option to disable explosion knockback
|
||||
- this.hitPlayers.put(entityhuman, vec3d1);
|
||||
+ // Sakura start - specialised explosions; tally player velocity
|
||||
+ final Vec3 explosionImpact = vec3d1;
|
||||
+ this.hitPlayers.compute(entityhuman, (p, v) -> v != null ? v.add(explosionImpact) : explosionImpact);
|
||||
+ // Sakura end - specialised explosions; tally player velocity
|
||||
}
|
||||
}
|
||||
|
||||
@@ -994,7 +1014,7 @@ public class Explosion {
|
||||
private BlockInteraction() {}
|
||||
}
|
||||
// Paper start - Optimize explosions
|
||||
|
||||
@@ -124,7 +124,7 @@ index a8008c7550488be34b51f4280f5569170b1ebd1d..2e5a46b9d27b930870c68dbde93d8731
|
||||
public String getDescriptionId() {
|
||||
return this.getOrCreateDescriptionId();
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
index d10d2581c6dfdaf7518bead4f2340c1b63b4bc44..f4b17c01ee6552df325ea02a2f6da22b14f6e78f 100644
|
||||
index b2ba5d761e21023ef4e3ee01c7318a7a586e650b..432acf2b2ef1ccb317c2c8052e2515ca35b2c718 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
@@ -262,7 +262,7 @@ public class Explosion {
|
||||
@@ -158,7 +158,7 @@ index d10d2581c6dfdaf7518bead4f2340c1b63b4bc44..f4b17c01ee6552df325ea02a2f6da22b
|
||||
private boolean clipsAnything(final Vec3 from, final Vec3 to,
|
||||
final io.papermc.paper.util.CollisionUtil.LazyEntityCollisionContext context,
|
||||
final ExplosionBlockCache[] blockCache,
|
||||
@@ -868,6 +883,16 @@ public class Explosion {
|
||||
@@ -871,6 +886,16 @@ public class Explosion {
|
||||
// CraftBukkit start - TNTPrimeEvent
|
||||
BlockState iblockdata = this.level.getBlockState(blockposition);
|
||||
Block block = iblockdata.getBlock();
|
||||
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Configure cannon physics by version
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/util/CollisionUtil.java b/src/main/java/io/papermc/paper/util/CollisionUtil.java
|
||||
index 299237a0c828e48425cc35a14d366020c78daefb..8014ebfb391825c31d9d1b39f5304a7e76b1ee44 100644
|
||||
index 86dee868320531e0fa076b6a78f3ea476c64b376..faadb4075bc1fddb7a55349907ee2b8c45ccd320 100644
|
||||
--- a/src/main/java/io/papermc/paper/util/CollisionUtil.java
|
||||
+++ b/src/main/java/io/papermc/paper/util/CollisionUtil.java
|
||||
@@ -1457,7 +1457,15 @@ public final class CollisionUtil {
|
||||
@@ -68,10 +68,10 @@ index 299237a0c828e48425cc35a14d366020c78daefb..8014ebfb391825c31d9d1b39f5304a7e
|
||||
if (xSmaller && z != 0.0) {
|
||||
z = performAABBCollisionsZ(axisalignedbb, z, aabbs);
|
||||
diff --git a/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java
|
||||
index d15eb10fa203236060b90c5fc1364564dec8753f..d67f9d241f6070a2c391df52146d48434e7e096a 100644
|
||||
index ce676a021dd375959e9403b237bad864cd2b7da2..7d3431dc41246e4967bc11e5605611c78a3153bf 100644
|
||||
--- a/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java
|
||||
+++ b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java
|
||||
@@ -172,9 +172,15 @@ public abstract class SpecialisedExplosion<T extends Entity> extends Explosion {
|
||||
@@ -173,9 +173,15 @@ public abstract class SpecialisedExplosion<T extends Entity> extends Explosion {
|
||||
|
||||
if (distanceFromBottom <= 1.0) {
|
||||
double x = entity.getX() - pos.x;
|
||||
@@ -481,7 +481,7 @@ index df2a37e57012333a618937e61cb5a99c3ef4a0f9..62d40333c42f673479db5e6312343161
|
||||
// Paper end - Option to prevent TNT from moving in water
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
index e0a9284bc0760306f1b295f35433f98c628b288a..6932856c7c9c41b6c7979c042db47f799c2f16cc 100644
|
||||
index d882b2b8b860932d648d54c6d1a1ca68597dde09..77f528bca7d8b4f17ec5319bc6f029111a2afae1 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
@@ -76,6 +76,7 @@ public class Explosion {
|
||||
@@ -546,7 +546,7 @@ index e0a9284bc0760306f1b295f35433f98c628b288a..6932856c7c9c41b6c7979c042db47f79
|
||||
|
||||
if (d11 != 0.0D) {
|
||||
d8 /= d11;
|
||||
@@ -1047,7 +1067,7 @@ public class Explosion {
|
||||
@@ -1050,7 +1070,7 @@ public class Explosion {
|
||||
// Sakura start - replace density cache
|
||||
float blockDensity = this.level.densityCache.getDensity(vec3d, entity);
|
||||
if (blockDensity == me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) {
|
||||
@@ -555,7 +555,7 @@ index e0a9284bc0760306f1b295f35433f98c628b288a..6932856c7c9c41b6c7979c042db47f79
|
||||
this.level.densityCache.putDensity(vec3d, entity, blockDensity);
|
||||
// Sakura end - replace density cache
|
||||
}
|
||||
@@ -1055,6 +1075,17 @@ public class Explosion {
|
||||
@@ -1058,6 +1078,17 @@ public class Explosion {
|
||||
return blockDensity;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ Subject: [PATCH] Add explosions dropping items config
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
index 31cf85345c9638b72d2b2b218d48408a5988210b..bc7a1d9bfbf6b9bdc9e987b8f06d7f5f8789847f 100644
|
||||
index 1482e80f30d2b0c34acd509dd3ea8f15a78aae95..b5eaab69d69ef69de8ba426c7711b3e775b82f08 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
@@ -945,6 +945,11 @@ public class Explosion {
|
||||
@@ -948,6 +948,11 @@ public class Explosion {
|
||||
this.level.densityCache.clear(-1);
|
||||
}
|
||||
// Sakura end - explosion density cache
|
||||
|
||||
@@ -5,10 +5,10 @@ Subject: [PATCH] Set entity impulse on explosion
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java
|
||||
index d67f9d241f6070a2c391df52146d48434e7e096a..9388ae5d02cd9ea7e7cafd366704855898deeefb 100644
|
||||
index 7d3431dc41246e4967bc11e5605611c78a3153bf..0c5e19770e09e318e8a732f8eac0ccd2ce240577 100644
|
||||
--- a/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java
|
||||
+++ b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java
|
||||
@@ -197,6 +197,7 @@ public abstract class SpecialisedExplosion<T extends Entity> extends Explosion {
|
||||
@@ -198,6 +198,7 @@ public abstract class SpecialisedExplosion<T extends Entity> extends Explosion {
|
||||
y *= exposure;
|
||||
z *= exposure;
|
||||
|
||||
@@ -17,7 +17,7 @@ index d67f9d241f6070a2c391df52146d48434e7e096a..9388ae5d02cd9ea7e7cafd3667048558
|
||||
entity.addDeltaMovement(x, y, z);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
index 6c638f249eb16e3bb09f16b404c70c28fa5a0532..c485873524aae2ce36a4a9e432a18c70a84cca3a 100644
|
||||
index 2b76d4eb6ef609c2f53ba6595abc656eb2bff056..1e327955020c73d51d09e1f9976d1c0c6855acf1 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
@@ -821,6 +821,7 @@ public class Explosion {
|
||||
|
||||
Reference in New Issue
Block a user