#1390: Improve internal handling of damage sources

By: Doc <nachito94@msn.com>
This commit is contained in:
CraftBukkit/Spigot
2024-05-04 08:15:51 +10:00
parent f01e218606
commit 066665a979
12 changed files with 72 additions and 48 deletions

View File

@@ -776,7 +776,7 @@
+ return;
+ }
+
+ if (!this.hurt(this.damageSources().lightningBolt().customCausingEntity(entitylightning), 5.0F)) {
+ if (!this.hurt(this.damageSources().lightningBolt().customEntityDamager(entitylightning), 5.0F)) {
+ return;
+ }
+ // CraftBukkit end

View File

@@ -15,7 +15,7 @@
@Override
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
- this.hurt(this.damageSources().lightningBolt(), Float.MAX_VALUE);
+ this.hurt(this.damageSources().lightningBolt().customCausingEntity(entitylightning), Float.MAX_VALUE); // CraftBukkit
+ this.hurt(this.damageSources().lightningBolt().customEntityDamager(entitylightning), Float.MAX_VALUE); // CraftBukkit
}
@Override

View File

@@ -65,7 +65,7 @@
this.dead = true;
- this.level().explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, World.a.MOB);
- this.discard();
+ this.level().explode(this, net.minecraft.world.level.Explosion.getDefaultDamageSource(this.level(), this).customCausingEntity(this.entityIgniter), null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB); // CraftBukkit
+ this.level().explode(this, this.level().damageSources().explosion(this, this.entityIgniter, net.minecraft.world.damagesource.DamageTypes.EXPLOSION), null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB); // CraftBukkit
+ this.discard(EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause
this.spawnLingeringCloud();
+ // CraftBukkit start

View File

@@ -1,12 +1,11 @@
--- a/net/minecraft/world/entity/projectile/EntityEnderPearl.java
+++ b/net/minecraft/world/entity/projectile/EntityEnderPearl.java
@@ -18,6 +18,14 @@
@@ -18,6 +18,13 @@
import net.minecraft.world.phys.MovingObjectPosition;
import net.minecraft.world.phys.MovingObjectPositionEntity;
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.entity.EntityRemoveEvent;
+import org.bukkit.event.player.PlayerTeleportEvent;
@@ -15,7 +14,7 @@
public class EntityEnderPearl extends EntityProjectileThrowable {
public EntityEnderPearl(EntityTypes<? extends EntityEnderPearl> entitytypes, World world) {
@@ -54,23 +62,34 @@
@@ -54,23 +61,34 @@
EntityPlayer entityplayer = (EntityPlayer) entity;
if (entityplayer.connection.isAcceptingMessages() && entityplayer.level() == this.level() && !entityplayer.isSleeping()) {
@@ -57,13 +56,13 @@
- entity.hurt(this.damageSources().fall(), 5.0F);
+ entityplayer.connection.teleport(teleEvent.getTo());
+ entity.resetFallDistance();
+ entity.hurt(this.damageSources().fall().customCausingEntity(this), 5.0F); // CraftBukkit
+ entity.hurt(this.damageSources().fall().customEntityDamager(this), 5.0F); // CraftBukkit
+ }
+ // CraftBukkit end
this.level().playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_TELEPORT, SoundCategory.PLAYERS);
}
} else if (entity != null) {
@@ -78,7 +97,7 @@
@@ -78,7 +96,7 @@
entity.resetFallDistance();
}
@@ -72,7 +71,7 @@
}
}
@@ -88,7 +107,7 @@
@@ -88,7 +106,7 @@
Entity entity = this.getOwner();
if (entity instanceof EntityPlayer && !entity.isAlive() && this.level().getGameRules().getBoolean(GameRules.RULE_ENDER_PEARLS_VANISH_ON_DEATH)) {
@@ -81,7 +80,7 @@
} else {
super.tick();
}
@@ -100,7 +119,7 @@
@@ -100,7 +118,7 @@
public Entity changeDimension(WorldServer worldserver) {
Entity entity = this.getOwner();

View File

@@ -25,7 +25,7 @@
if (entityliving.isAlive() && !entityliving.isInvulnerable() && entityliving != entityliving1) {
if (entityliving1 == null) {
- entityliving.hurt(this.damageSources().magic(), 6.0F);
+ entityliving.hurt(this.damageSources().magic().customCausingEntity(this), 6.0F); // CraftBukkit
+ entityliving.hurt(this.damageSources().magic().customEntityDamager(this), 6.0F); // CraftBukkit
} else {
if (entityliving1.isAlliedTo((Entity) entityliving)) {
return;