13
0
geforkt von Mirrors/Paper

#1420: Fix DirectEntity and CausingEntity Damager for Creepers ignited by Player

By: Doc <nachito94@msn.com>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2024-06-15 06:47:48 +10:00
Ursprung 17fc7c0926
Commit c985be99a6
3 geänderte Dateien mit 20 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/world/damagesource/DamageSource.java
+++ b/net/minecraft/world/damagesource/DamageSource.java
@@ -21,6 +21,103 @@
@@ -21,6 +21,119 @@
private final Entity directEntity;
@Nullable
private final Vec3D damageSourcePosition;
@ -12,7 +12,8 @@
+ private boolean sweep = false;
+ private boolean melting = false;
+ private boolean poison = false;
+ private Entity customEntityDamager = null; // This field is a helper for when causing entity damage is not set by vanilla
+ private Entity customEntityDamager = null; // This field is a helper for when direct entity damage is not set by vanilla
+ private Entity customCausingEntityDamager = null; // This field is a helper for when causing entity damage is not set by vanilla
+
+ public DamageSource sweep() {
+ this.sweep = true;
@ -45,6 +46,10 @@
+ return (this.customEntityDamager != null) ? this.customEntityDamager : this.directEntity;
+ }
+
+ public Entity getCausingDamager() {
+ return (this.customCausingEntityDamager != null) ? this.customCausingEntityDamager : this.causingEntity;
+ }
+
+ public DamageSource customEntityDamager(Entity entity) {
+ // This method is not intended for change the causing entity if is already set
+ // also is only necessary if the entity passed is not the direct entity or different from the current causingEntity
@ -56,6 +61,17 @@
+ return damageSource;
+ }
+
+ public DamageSource customCausingEntityDamager(Entity entity) {
+ // This method is not intended for change the causing entity if is already set
+ // also is only necessary if the entity passed is not the direct entity or different from the current causingEntity
+ if (this.customCausingEntityDamager != null || this.directEntity == entity || this.causingEntity == entity) {
+ return this;
+ }
+ DamageSource damageSource = this.cloneInstance();
+ damageSource.customCausingEntityDamager = entity;
+ return damageSource;
+ }
+
+ public org.bukkit.block.Block getDirectBlock() {
+ return this.directBlock;
+ }

Datei anzeigen

@ -64,7 +64,7 @@
+ // CraftBukkit end
this.dead = true;
- this.level().explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, World.a.MOB);
+ this.level().explode(this, net.minecraft.world.level.Explosion.getDefaultDamageSource(this.level(), this).customEntityDamager(this.entityIgniter), null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB); // CraftBukkit
+ this.level().explode(this, net.minecraft.world.level.Explosion.getDefaultDamageSource(this.level(), this).customCausingEntityDamager(this.entityIgniter), null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB); // CraftBukkit
this.spawnLingeringCloud();
this.triggerOnDeathMobEffects(Entity.RemovalReason.KILLED);
- this.discard();

Datei anzeigen

@ -41,7 +41,7 @@ public class CraftDamageSource implements DamageSource {
@Override
public org.bukkit.entity.Entity getCausingEntity() {
net.minecraft.world.entity.Entity entity = this.getHandle().getEntity();
net.minecraft.world.entity.Entity entity = this.getHandle().getCausingDamager();
return (entity != null) ? entity.getBukkitEntity() : null;
}