Fix DamageSource API
Uses the correct entity in the EntityDamageByEntity event Returns the correct entity for API's DamageSource#getCausingEntity
This commit is contained in:
@@ -16,10 +16,11 @@
|
||||
this.inFire = this.source(DamageTypes.IN_FIRE);
|
||||
this.campfire = this.source(DamageTypes.CAMPFIRE);
|
||||
this.lightningBolt = this.source(DamageTypes.LIGHTNING_BOLT);
|
||||
@@ -84,6 +90,16 @@
|
||||
@@ -83,7 +89,17 @@
|
||||
|
||||
private DamageSource source(ResourceKey<DamageType> key, @Nullable Entity source, @Nullable Entity attacker) {
|
||||
return new DamageSource(this.damageTypes.getOrThrow(key), source, attacker);
|
||||
}
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public DamageSource melting() {
|
||||
@@ -28,27 +29,21 @@
|
||||
+
|
||||
+ public DamageSource poison() {
|
||||
+ return this.poison;
|
||||
+ }
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
public DamageSource inFire() {
|
||||
return this.inFire;
|
||||
@@ -254,17 +270,29 @@
|
||||
@@ -254,7 +270,7 @@
|
||||
}
|
||||
|
||||
public DamageSource explosion(@Nullable Entity source, @Nullable Entity attacker) {
|
||||
- return this.source(attacker != null && source != null ? DamageTypes.PLAYER_EXPLOSION : DamageTypes.EXPLOSION, source, attacker);
|
||||
+ // CraftBukkit start
|
||||
+ return this.explosion(source, attacker, attacker != null && source != null ? DamageTypes.PLAYER_EXPLOSION : DamageTypes.EXPLOSION);
|
||||
+ return this.source(attacker != null && source != null ? DamageTypes.PLAYER_EXPLOSION : DamageTypes.EXPLOSION, source, attacker); // Paper - revert to vanilla
|
||||
}
|
||||
|
||||
+ public DamageSource explosion(@Nullable Entity entity, @Nullable Entity entity1, ResourceKey<DamageType> resourceKey) {
|
||||
+ return this.source(resourceKey, entity, entity1);
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
+
|
||||
public DamageSource sonicBoom(Entity attacker) {
|
||||
return this.source(DamageTypes.SONIC_BOOM, attacker);
|
||||
@@ -262,9 +278,15 @@
|
||||
}
|
||||
|
||||
public DamageSource badRespawnPointExplosion(Vec3 position) {
|
||||
|
||||
Reference in New Issue
Block a user