mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 11:06:29 +01:00
SPIGOT-949: Fix damage cooldown reducing explosion knockback
This commit is contained in:
parent
53fac9f1b6
commit
9a17f01ff1
@ -41,16 +41,17 @@
|
||||
private static final AxisAlignedBB a = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
|
||||
private static int entityCount;
|
||||
private int id;
|
||||
@@ -79,6 +111,8 @@
|
||||
@@ -79,6 +111,9 @@
|
||||
private boolean invulnerable;
|
||||
protected UUID uniqueID;
|
||||
private final CommandObjectiveExecutor au;
|
||||
+ public boolean valid; // CraftBukkit
|
||||
+ public org.bukkit.projectiles.ProjectileSource projectileSource; // CraftBukkit - For projectiles only
|
||||
+ public boolean forceExplosionKnockback; // CraftBukkit - SPIGOT-949
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
@@ -152,6 +186,33 @@
|
||||
@@ -152,6 +187,33 @@
|
||||
}
|
||||
|
||||
protected void setYawPitch(float f, float f1) {
|
||||
@ -84,7 +85,7 @@
|
||||
this.yaw = f % 360.0F;
|
||||
this.pitch = f1 % 360.0F;
|
||||
}
|
||||
@@ -188,7 +249,7 @@
|
||||
@@ -188,7 +250,7 @@
|
||||
int i = this.L();
|
||||
|
||||
if (this.ak) {
|
||||
@ -93,7 +94,7 @@
|
||||
if (this.vehicle == null && this.al++ >= i) {
|
||||
this.al = i;
|
||||
this.portalCooldown = this.aq();
|
||||
@@ -265,6 +326,27 @@
|
||||
@@ -265,6 +327,27 @@
|
||||
protected void burnFromLava() {
|
||||
if (!this.fireProof) {
|
||||
this.damageEntity(DamageSource.LAVA, 4.0F);
|
||||
@ -121,7 +122,7 @@
|
||||
this.setOnFire(15);
|
||||
}
|
||||
}
|
||||
@@ -302,6 +384,22 @@
|
||||
@@ -302,6 +385,22 @@
|
||||
this.a(this.getBoundingBox().c(d0, d1, d2));
|
||||
this.recalcPosition();
|
||||
} else {
|
||||
@ -144,7 +145,7 @@
|
||||
this.world.methodProfiler.a("move");
|
||||
double d3 = this.locX;
|
||||
double d4 = this.locY;
|
||||
@@ -522,6 +620,26 @@
|
||||
@@ -522,6 +621,26 @@
|
||||
block.a(this.world, this);
|
||||
}
|
||||
|
||||
@ -171,7 +172,7 @@
|
||||
if (this.s_() && !flag && this.vehicle == null) {
|
||||
double d21 = this.locX - d3;
|
||||
double d22 = this.locY - d4;
|
||||
@@ -532,7 +650,7 @@
|
||||
@@ -532,7 +651,7 @@
|
||||
}
|
||||
|
||||
if (block != null && this.onGround) {
|
||||
@ -180,7 +181,7 @@
|
||||
}
|
||||
|
||||
this.M = (float) ((double) this.M + (double) MathHelper.sqrt(d21 * d21 + d23 * d23) * 0.6D);
|
||||
@@ -550,9 +668,12 @@
|
||||
@@ -550,9 +669,12 @@
|
||||
}
|
||||
|
||||
this.a(blockposition, block);
|
||||
@ -193,7 +194,7 @@
|
||||
try {
|
||||
this.checkBlockCollisions();
|
||||
} catch (Throwable throwable) {
|
||||
@@ -562,6 +683,8 @@
|
||||
@@ -562,6 +684,8 @@
|
||||
this.appendEntityCrashDetails(crashreportsystemdetails);
|
||||
throw new ReportedException(crashreport);
|
||||
}
|
||||
@ -202,7 +203,7 @@
|
||||
|
||||
boolean flag2 = this.U();
|
||||
|
||||
@@ -569,7 +692,16 @@
|
||||
@@ -569,7 +693,16 @@
|
||||
this.burn(1);
|
||||
if (!flag2) {
|
||||
++this.fireTicks;
|
||||
@ -220,7 +221,7 @@
|
||||
this.setOnFire(8);
|
||||
}
|
||||
}
|
||||
@@ -675,7 +807,7 @@
|
||||
@@ -675,7 +808,7 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -229,7 +230,7 @@
|
||||
if (!this.fireProof) {
|
||||
this.damageEntity(DamageSource.FIRE, (float) i);
|
||||
}
|
||||
@@ -818,6 +950,13 @@
|
||||
@@ -818,6 +951,13 @@
|
||||
}
|
||||
|
||||
public void spawnIn(World world) {
|
||||
@ -243,7 +244,7 @@
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@@ -1010,6 +1149,18 @@
|
||||
@@ -1010,6 +1150,18 @@
|
||||
try {
|
||||
nbttagcompound.set("Pos", this.a(new double[] { this.locX, this.locY, this.locZ}));
|
||||
nbttagcompound.set("Motion", this.a(new double[] { this.motX, this.motY, this.motZ}));
|
||||
@ -262,7 +263,7 @@
|
||||
nbttagcompound.set("Rotation", this.a(new float[] { this.yaw, this.pitch}));
|
||||
nbttagcompound.setFloat("FallDistance", this.fallDistance);
|
||||
nbttagcompound.setShort("Fire", (short) this.fireTicks);
|
||||
@@ -1020,6 +1171,11 @@
|
||||
@@ -1020,6 +1172,11 @@
|
||||
nbttagcompound.setInt("PortalCooldown", this.portalCooldown);
|
||||
nbttagcompound.setLong("UUIDMost", this.getUniqueID().getMostSignificantBits());
|
||||
nbttagcompound.setLong("UUIDLeast", this.getUniqueID().getLeastSignificantBits());
|
||||
@ -274,7 +275,7 @@
|
||||
if (this.getCustomName() != null && this.getCustomName().length() > 0) {
|
||||
nbttagcompound.setString("CustomName", this.getCustomName());
|
||||
nbttagcompound.setBoolean("CustomNameVisible", this.getCustomNameVisible());
|
||||
@@ -1057,6 +1213,8 @@
|
||||
@@ -1057,6 +1214,8 @@
|
||||
this.motX = nbttaglist1.d(0);
|
||||
this.motY = nbttaglist1.d(1);
|
||||
this.motZ = nbttaglist1.d(2);
|
||||
@ -283,7 +284,7 @@
|
||||
if (Math.abs(this.motX) > 10.0D) {
|
||||
this.motX = 0.0D;
|
||||
}
|
||||
@@ -1068,6 +1226,7 @@
|
||||
@@ -1068,6 +1227,7 @@
|
||||
if (Math.abs(this.motZ) > 10.0D) {
|
||||
this.motZ = 0.0D;
|
||||
}
|
||||
@ -291,7 +292,7 @@
|
||||
|
||||
this.lastX = this.P = this.locX = nbttaglist.d(0);
|
||||
this.lastY = this.Q = this.locY = nbttaglist.d(1);
|
||||
@@ -1103,6 +1262,58 @@
|
||||
@@ -1103,6 +1263,58 @@
|
||||
this.setPosition(this.locX, this.locY, this.locZ);
|
||||
}
|
||||
|
||||
@ -350,7 +351,7 @@
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT");
|
||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded");
|
||||
@@ -1164,6 +1375,12 @@
|
||||
@@ -1164,6 +1376,12 @@
|
||||
|
||||
public EntityItem a(ItemStack itemstack, float f) {
|
||||
if (itemstack.count != 0 && itemstack.getItem() != null) {
|
||||
@ -363,7 +364,7 @@
|
||||
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack);
|
||||
|
||||
entityitem.p();
|
||||
@@ -1277,17 +1494,70 @@
|
||||
@@ -1277,17 +1495,70 @@
|
||||
return (double) this.length * 0.75D;
|
||||
}
|
||||
|
||||
@ -434,7 +435,7 @@
|
||||
if (this.vehicle != null) {
|
||||
this.vehicle.passenger = null;
|
||||
}
|
||||
@@ -1406,10 +1676,49 @@
|
||||
@@ -1406,10 +1677,49 @@
|
||||
}
|
||||
|
||||
public void onLightningStrike(EntityLightning entitylightning) {
|
||||
@ -486,7 +487,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1550,32 +1859,83 @@
|
||||
@@ -1550,32 +1860,83 @@
|
||||
if (!this.world.isClientSide && !this.dead) {
|
||||
this.world.methodProfiler.a("changeDimension");
|
||||
MinecraftServer minecraftserver = MinecraftServer.getServer();
|
||||
@ -574,7 +575,7 @@
|
||||
}
|
||||
|
||||
this.dead = true;
|
||||
@@ -1670,6 +2030,11 @@
|
||||
@@ -1670,6 +2031,11 @@
|
||||
}
|
||||
|
||||
public void setCustomName(String s) {
|
||||
@ -586,7 +587,7 @@
|
||||
this.datawatcher.watch(2, s);
|
||||
}
|
||||
|
||||
@@ -1721,7 +2086,26 @@
|
||||
@@ -1721,7 +2087,26 @@
|
||||
}
|
||||
|
||||
public void a(AxisAlignedBB axisalignedbb) {
|
||||
|
@ -275,7 +275,11 @@
|
||||
this.getEquipment(4).damage((int) (f * 4.0F + this.random.nextFloat() * f * 2.0F), this);
|
||||
f *= 0.75F;
|
||||
}
|
||||
@@ -606,16 +719,34 @@
|
||||
@@ -603,19 +716,38 @@
|
||||
|
||||
if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) {
|
||||
if (f <= this.lastDamage) {
|
||||
+ this.forceExplosionKnockback = true; // CraftBukkit - SPIGOT-949 - for vanilla consistency, cooldown does not prevent explosion knockback
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -312,7 +316,7 @@
|
||||
this.aw = 0.0F;
|
||||
Entity entity = damagesource.getEntity();
|
||||
|
||||
@@ -721,11 +852,19 @@
|
||||
@@ -721,11 +853,19 @@
|
||||
}
|
||||
|
||||
if (this.ba() && this.world.getGameRules().getBoolean("doMobLoot")) {
|
||||
@ -332,7 +336,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -785,8 +924,13 @@
|
||||
@@ -785,8 +925,13 @@
|
||||
int i = MathHelper.f((f - 3.0F - f2) * f1);
|
||||
|
||||
if (i > 0) {
|
||||
@ -347,7 +351,7 @@
|
||||
int j = MathHelper.floor(this.locX);
|
||||
int k = MathHelper.floor(this.locY - 0.20000000298023224D);
|
||||
int l = MathHelper.floor(this.locZ);
|
||||
@@ -830,7 +974,7 @@
|
||||
@@ -830,7 +975,7 @@
|
||||
int i = 25 - this.br();
|
||||
float f1 = f * (float) i;
|
||||
|
||||
@ -356,7 +360,7 @@
|
||||
f = f1 / 25.0F;
|
||||
}
|
||||
|
||||
@@ -844,8 +988,9 @@
|
||||
@@ -844,8 +989,9 @@
|
||||
int i;
|
||||
int j;
|
||||
float f1;
|
||||
@ -368,7 +372,7 @@
|
||||
i = (this.getEffect(MobEffectList.RESISTANCE).getAmplifier() + 1) * 5;
|
||||
j = 25 - i;
|
||||
f1 = f * (float) j;
|
||||
@@ -871,22 +1016,121 @@
|
||||
@@ -871,22 +1017,121 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -497,7 +501,7 @@
|
||||
}
|
||||
|
||||
public CombatTracker bs() {
|
||||
@@ -1240,7 +1484,8 @@
|
||||
@@ -1240,7 +1485,8 @@
|
||||
if (f > 0.0025000002F) {
|
||||
f3 = 1.0F;
|
||||
f2 = (float) Math.sqrt((double) f) * 3.0F;
|
||||
@ -507,7 +511,7 @@
|
||||
}
|
||||
|
||||
if (this.az > 0.0F) {
|
||||
@@ -1413,6 +1658,13 @@
|
||||
@@ -1413,6 +1659,13 @@
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
Entity entity = (Entity) list.get(i);
|
||||
|
||||
@ -521,7 +525,7 @@
|
||||
this.s(entity);
|
||||
}
|
||||
}
|
||||
@@ -1425,6 +1677,18 @@
|
||||
@@ -1425,6 +1678,18 @@
|
||||
|
||||
public void mount(Entity entity) {
|
||||
if (this.vehicle != null && entity == null) {
|
||||
|
@ -49,23 +49,24 @@
|
||||
hashset.add(blockposition);
|
||||
}
|
||||
|
||||
@@ -112,7 +125,14 @@
|
||||
@@ -112,7 +125,15 @@
|
||||
double d12 = (double) this.world.a(vec3d, entity.getBoundingBox());
|
||||
double d13 = (1.0D - d7) * d12;
|
||||
|
||||
- entity.damageEntity(DamageSource.explosion(this), (float) ((int) ((d13 * d13 + d13) / 2.0D * 8.0D * (double) f3 + 1.0D)));
|
||||
+ // entity.damageEntity(DamageSource.explosion(this), (float) ((int) ((d13 * d13 + d13) / 2.0D * 8.0D * (double) f3 + 1.0D)));+ // CraftBukkit start
|
||||
+ CraftEventFactory.entityDamage = source;
|
||||
+ entity.forceExplosionKnockback = false;
|
||||
+ boolean wasDamaged = entity.damageEntity(DamageSource.explosion(this), (float) ((int) ((d13 * d13 + d13) / 2.0D * 8.0D * (double) f3 + 1.0D)));
|
||||
+ CraftEventFactory.entityDamage = null;
|
||||
+ if (!wasDamaged && !(entity instanceof EntityTNTPrimed || entity instanceof EntityFallingBlock)) {
|
||||
+ if (!wasDamaged && !(entity instanceof EntityTNTPrimed || entity instanceof EntityFallingBlock) && !entity.forceExplosionKnockback) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
double d14 = EnchantmentProtection.a(entity, d13);
|
||||
|
||||
entity.motX += d8 * d14;
|
||||
@@ -140,6 +160,50 @@
|
||||
@@ -140,6 +161,50 @@
|
||||
BlockPosition blockposition;
|
||||
|
||||
if (this.b) {
|
||||
@ -116,7 +117,7 @@
|
||||
iterator = this.blocks.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -170,7 +234,8 @@
|
||||
@@ -170,7 +235,8 @@
|
||||
|
||||
if (block.getMaterial() != Material.AIR) {
|
||||
if (block.a(this)) {
|
||||
@ -126,7 +127,7 @@
|
||||
}
|
||||
|
||||
this.world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3);
|
||||
@@ -185,7 +250,11 @@
|
||||
@@ -185,7 +251,11 @@
|
||||
while (iterator.hasNext()) {
|
||||
blockposition = (BlockPosition) iterator.next();
|
||||
if (this.world.getType(blockposition).getBlock().getMaterial() == Material.AIR && this.world.getType(blockposition.down()).getBlock().o() && this.c.nextInt(3) == 0) {
|
||||
@ -139,7 +140,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,7 +266,9 @@
|
||||
@@ -197,7 +267,9 @@
|
||||
}
|
||||
|
||||
public EntityLiving getSource() {
|
||||
|
Loading…
Reference in New Issue
Block a user