Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@128691a Deprecate log4j logger method in `Plugin` PaperMC/Paper@2a306f5 Add Multi Block Change API (#7333) PaperMC/Paper@feb72b8 Update ASM EventExecutor generator patch to respect event handler return types. Fixes #7311 (#7317) PaperMC/Paper@dcca6cb Make tag presets unmodifiable (#7378) PaperMC/Paper@60e46ab Fix NotePlayEvent (#5180) PaperMC/Paper@512995c Updated Upstream (Bukkit/CraftBukkit/Spigot) (#7359) PaperMC/Paper@0a9602c [ci skip] Fix multiple ItemStack array nullability mistakes (#7055) PaperMC/Paper@9a19308 Lock Frozen Ticks API (#7207) PaperMC/Paper@a058ac0 Dolphin API (#7102) PaperMC/Paper@f6c7d53 Add configurable stronghold seed (#7334) PaperMC/Paper@7978121 More PotionEffectType API (#5737) PaperMC/Paper@9490475 Add STRUCTURE_TYPE registry entry (#6400) PaperMC/Paper@b164899 Update tiny-remapper PaperMC/Paper@f7dbd06 [ci skip] Update parameter mappings PaperMC/Paper@ca523ab [ci skip] Fix param mismatch from last commit PaperMC/Paper@2e99e5e Updated Upstream (Bukkit/CraftBukkit) (#7411) PaperMC/Paper@41263d9 [ci skip] Update paperweight to 1.3.4 PaperMC/Paper@3109dd8 Updated Upstream (Bukkit/CraftBukkit) (#7428) PaperMC/Paper@17eb884 Use a CHM for StructureTemplate.Pallete cache PaperMC/Paper@f79c0da Updated Upstream (Bukkit/CraftBukkit) PaperMC/Paper@2121aed Rebuild patches PaperMC/Paper@2ec04e0 Use correct headerLocation for regionfile initialisation PaperMC/Paper@f23c039 Fix infinite recursion in spawnCategoryForChunk/Position PaperMC/Paper@9940bca API for creating command sender which forwards feedback (#7432) PaperMC/Paper@46ed080 fix portal linking in upgraded chunks (fixes #7419) (#7438) PaperMC/Paper@6df4641 Use destination world when preloading spawn chunk (#7441) PaperMC/Paper@0cc2503 Implement World#regenerateChunk (#7425) PaperMC/Paper@00da098 Log exceptions thrown during chat processing (#7467) PaperMC/Paper@26734e8 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#7454) PaperMC/Paper@4a745f9 Optimize Util#sequence (#7115) PaperMC/Paper@2c8d48c Make Panda implement Sittable (#7414) PaperMC/Paper@2c4a589 Fix issues with LimitedRegion (#7343) PaperMC/Paper@3d91eca Fix cancelled snow bucket placement (#6751) PaperMC/Paper@9567753 Don't load plugins prefixed with a dot (#7392) PaperMC/Paper@92c777d Fix PlayerProfile BukkitObject serialization, deprecate setName and setId for removal (#7471) PaperMC/Paper@e6898ff Fix IllegalArgumentException for /paper mobcaps command (#7472) PaperMC/Paper@a8f2d67 - properly fix IllegalArgumentException in `/paper mobcaps` command
179 lines
11 KiB
Diff
179 lines
11 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: lexikiq <noellekiq@gmail.com>
|
|
Date: Fri, 18 Jun 2021 14:04:39 -0400
|
|
Subject: [PATCH] Add origin location to EntityDamageByBlockEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/damagesource/BadRespawnPointDamage.java b/src/main/java/net/minecraft/world/damagesource/BadRespawnPointDamage.java
|
|
index f5a18fb39eb69b2a9842d3f96aa1cd6a8dff6d9b..456d93305f524da6142bad320edb817b27c6c1e6 100644
|
|
--- a/src/main/java/net/minecraft/world/damagesource/BadRespawnPointDamage.java
|
|
+++ b/src/main/java/net/minecraft/world/damagesource/BadRespawnPointDamage.java
|
|
@@ -9,12 +9,20 @@ import net.minecraft.network.chat.TranslatableComponent;
|
|
import net.minecraft.world.entity.LivingEntity;
|
|
|
|
public class BadRespawnPointDamage extends DamageSource {
|
|
+ @Deprecated // Parchment
|
|
protected BadRespawnPointDamage() {
|
|
super("badRespawnPoint");
|
|
this.setScalesWithDifficulty();
|
|
this.setExplosion();
|
|
}
|
|
|
|
+ // Parchment start
|
|
+ protected BadRespawnPointDamage(org.bukkit.Location location) {
|
|
+ this();
|
|
+ location(location);
|
|
+ }
|
|
+ // Parchment end
|
|
+
|
|
@Override
|
|
public Component getLocalizedDeathMessage(LivingEntity entity) {
|
|
Component component = ComponentUtils.wrapInSquareBrackets(new TranslatableComponent("death.attack.badRespawnPoint.link")).withStyle((style) -> {
|
|
diff --git a/src/main/java/net/minecraft/world/damagesource/DamageSource.java b/src/main/java/net/minecraft/world/damagesource/DamageSource.java
|
|
index a828cad27fcd39f8bfbaefa97052a2a3b6650ee7..52cce7422c2a99e3de37f87ac704151682578718 100644
|
|
--- a/src/main/java/net/minecraft/world/damagesource/DamageSource.java
|
|
+++ b/src/main/java/net/minecraft/world/damagesource/DamageSource.java
|
|
@@ -77,6 +77,18 @@ public class DamageSource {
|
|
return this;
|
|
}
|
|
// Paper end
|
|
+ // Parchment start
|
|
+ private @Nullable org.bukkit.Location location;
|
|
+
|
|
+ public @Nullable org.bukkit.Location getLocation() {
|
|
+ return location;
|
|
+ }
|
|
+
|
|
+ public DamageSource location(@Nullable org.bukkit.Location location) {
|
|
+ this.location = location;
|
|
+ return this;
|
|
+ }
|
|
+ // Parchment end
|
|
|
|
public static DamageSource sting(LivingEntity attacker) {
|
|
return new EntityDamageSource("sting", attacker);
|
|
@@ -127,17 +139,24 @@ public class DamageSource {
|
|
}
|
|
|
|
public static DamageSource explosion(@Nullable Explosion explosion) {
|
|
- return DamageSource.explosion(explosion != null ? explosion.getSourceMob() : null);
|
|
+ return DamageSource.explosion(explosion != null ? explosion.getSourceMob() : null).location(explosion != null ? explosion.getBukkitLocation() : null); // Parchment
|
|
}
|
|
|
|
public static DamageSource explosion(@Nullable LivingEntity attacker) {
|
|
return attacker != null ? (new EntityDamageSource("explosion.player", attacker)).setScalesWithDifficulty().setExplosion() : (new DamageSource("explosion")).setScalesWithDifficulty().setExplosion();
|
|
}
|
|
|
|
+ @Deprecated // Parchment
|
|
public static DamageSource badRespawnPointExplosion() {
|
|
return new BadRespawnPointDamage();
|
|
}
|
|
|
|
+ // Parchment start
|
|
+ public static DamageSource badRespawnPointExplosion(org.bukkit.Location location) {
|
|
+ return new BadRespawnPointDamage(location);
|
|
+ }
|
|
+ // Parchment end
|
|
+
|
|
public String toString() {
|
|
return "DamageSource (" + this.msgId + ")";
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
|
index e17a3afa41fd628d2c4a3637ae19418e258a99b8..5a4489dff8b6ef70d52ba19ee8604b77d9c73791 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
|
@@ -101,10 +101,11 @@ public class EnderDragon extends Mob implements Enemy {
|
|
private final Node[] nodes = new Node[24];
|
|
private final int[] nodeAdjacency = new int[24];
|
|
private final BinaryHeap openSet = new BinaryHeap();
|
|
- private Explosion explosionSource = new Explosion(null, this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.BlockInteraction.DESTROY); // CraftBukkit - reusable source for CraftTNTPrimed.getSource()
|
|
+ private Explosion explosionSource; // Parchment - moved into constructor to fix null world
|
|
|
|
public EnderDragon(EntityType<? extends EnderDragon> entitytypes, Level world) {
|
|
super(EntityType.ENDER_DRAGON, world);
|
|
+ explosionSource = new Explosion(world, this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.BlockInteraction.DESTROY); // CraftBukkit - reusable source for CraftTNTPrimed.getSource() // Parchment - fix null world
|
|
this.subEntities = new EnderDragonPart[]{this.head, this.neck, this.body, this.tail1, this.tail2, this.tail3, this.wing1, this.wing2};
|
|
this.setHealth(this.getMaxHealth());
|
|
this.noPhysics = true;
|
|
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
|
index 97f99a06b8954b08af9f4156abe8abdad359349a..4b40ba434a88f241ffbbb1a58ba9015f4fc35cec 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
|
@@ -471,6 +471,13 @@ public class Explosion {
|
|
return this.toBlow;
|
|
}
|
|
|
|
+ // Parchment start
|
|
+ public @Nullable Location getBukkitLocation() {
|
|
+ if (this.level == null) return null;
|
|
+ return new Location(level.getWorld(), x, y, z);
|
|
+ }
|
|
+ // Parchment end
|
|
+
|
|
public static enum BlockInteraction {
|
|
|
|
NONE, BREAK, DESTROY;
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/BedBlock.java b/src/main/java/net/minecraft/world/level/block/BedBlock.java
|
|
index 20c0030d566012146021613325c6a979f392740e..a0a052095815ed63f06837155b48b0d84f404240 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/BedBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/BedBlock.java
|
|
@@ -145,7 +145,10 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock
|
|
world.removeBlock(blockposition1, false);
|
|
}
|
|
|
|
- world.explode((Entity) null, DamageSource.badRespawnPointExplosion(), (ExplosionDamageCalculator) null, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, 5.0F, true, Explosion.BlockInteraction.DESTROY);
|
|
+ // Parchment start
|
|
+ org.bukkit.Location location = new org.bukkit.Location(world.getWorld(), blockposition.getX() + 0.5D, blockposition.getY() + 0.5D, blockposition.getZ() + 0.5D);
|
|
+ world.explode((Entity) null, DamageSource.badRespawnPointExplosion(location), (ExplosionDamageCalculator) null, location.getX(), location.getY(), location.getZ(), 5.0F, true, Explosion.BlockInteraction.DESTROY);
|
|
+ // Parchment end
|
|
return InteractionResult.SUCCESS;
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java b/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java
|
|
index 86692a83fb9acd3a501da58e6d509865b49931fe..438ea548644aa9570a09fa4d4a06bde5f5c30567 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java
|
|
@@ -138,7 +138,10 @@ public class RespawnAnchorBlock extends Block {
|
|
return pos.equals(explodedPos) && bl2 ? Optional.of(Blocks.WATER.getExplosionResistance()) : super.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState);
|
|
}
|
|
};
|
|
- world.explode((Entity)null, DamageSource.badRespawnPointExplosion(), explosionDamageCalculator, (double)explodedPos.getX() + 0.5D, (double)explodedPos.getY() + 0.5D, (double)explodedPos.getZ() + 0.5D, 5.0F, true, Explosion.BlockInteraction.DESTROY);
|
|
+ // Parchment start
|
|
+ org.bukkit.Location location = new org.bukkit.Location(world.getWorld(), explodedPos.getX() + 0.5D, explodedPos.getY() + 0.5D, explodedPos.getZ() + 0.5D);
|
|
+ world.explode((Entity)null, DamageSource.badRespawnPointExplosion(location), explosionDamageCalculator, location.getX(), location.getY(), location.getZ(), 5.0F, true, Explosion.BlockInteraction.DESTROY);
|
|
+ // Parchment end
|
|
}
|
|
|
|
public static boolean canSetSpawn(Level world) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
index d2a1368eeff0704760432166e0910343512bbe4f..11ed21fb283a3ce80efd1d8a0ad027c47242ebc8 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -971,7 +971,7 @@ public class CraftEventFactory {
|
|
CraftEventFactory.entityDamage = null;
|
|
EntityDamageEvent event;
|
|
if (damager == null) {
|
|
- event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.BLOCK_EXPLOSION, modifiers, modifierFunctions);
|
|
+ event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.BLOCK_EXPLOSION, source.getLocation(), modifiers, modifierFunctions); // Parchment - add location
|
|
} else if (entity instanceof EnderDragon && /*PAIL FIXME ((EntityEnderDragon) entity).target == damager*/ false) {
|
|
event = new EntityDamageEvent(entity.getBukkitEntity(), DamageCause.ENTITY_EXPLOSION, modifiers, modifierFunctions);
|
|
} else {
|
|
@@ -1009,7 +1009,7 @@ public class CraftEventFactory {
|
|
|
|
return CraftEventFactory.callEntityDamageEvent(damager, entity, cause, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API
|
|
} else if (source == DamageSource.OUT_OF_WORLD) {
|
|
- EntityDamageEvent event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.VOID, modifiers, modifierFunctions);
|
|
+ EntityDamageEvent event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.VOID, entity.getBukkitEntity().getLocation(), modifiers, modifierFunctions); // Parchment - add location
|
|
event.setCancelled(cancelled);
|
|
CraftEventFactory.callEvent(event);
|
|
if (!event.isCancelled()) {
|
|
@@ -1019,7 +1019,7 @@ public class CraftEventFactory {
|
|
}
|
|
return event;
|
|
} else if (source == DamageSource.LAVA) {
|
|
- EntityDamageEvent event = (new EntityDamageByBlockEvent(CraftEventFactory.blockDamage, entity.getBukkitEntity(), DamageCause.LAVA, modifiers, modifierFunctions));
|
|
+ EntityDamageEvent event = (new EntityDamageByBlockEvent(CraftEventFactory.blockDamage, entity.getBukkitEntity(), DamageCause.LAVA, entity.getBukkitEntity().getLocation().toBlockLocation(), modifiers, modifierFunctions)); // Parchment - add location
|
|
event.setCancelled(cancelled);
|
|
|
|
Block damager = CraftEventFactory.blockDamage;
|