Files
ParchmentMC/patches/server/0005-Add-origin-location-to-EntityDamageByBlockEvent.patch
Lexi Larkin 930b419022 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@bd496d0 [ci skip] shuffle patches and rebuild
PaperMC/Paper@79f2aa3 Update Velocity natives (#8387)
PaperMC/Paper@21661a7 Fix jigsaw block kicking user (#8404)
PaperMC/Paper@017af78 [ci skip] Added the missing "d" character (#8267)
PaperMC/Paper@8a7dd61 Mark parsed PoiChunks with data as not loaded (#8405)
PaperMC/Paper@7d3a882 Do not log throwable for duplicate entity adds
PaperMC/Paper@8d69cfc Reduce allocation rate for checkBlock
PaperMC/Paper@c6d7375 use BlockFormEvent for mud converting into clay (#8398)
PaperMC/Paper@14c32bc Fix wrong yaw and pitch of CommandSourceStack#getBukkitLocation (#8411)
PaperMC/Paper@f5fa691 Don't print full packages in new chunk system classes
PaperMC/Paper@2534e5c Fix other jigsaw related disconnect bug (#8414)
PaperMC/Paper@e9618f8 Add system property to dump stack on bad plugin class access (#8417)
PaperMC/Paper@6d14093 Add getDrops to BlockState and isPreferredTool to BlockData (#8284)
PaperMC/Paper@ec76e36 Fix a handful of vanilla bugs (#8187)
PaperMC/Paper@ec3cfa9 Only create paper.yml-README.txt on config conversion (#8334)
PaperMC/Paper@928bcc8 Updated Upstream (Bukkit/CraftBukkit) (#8430)
PaperMC/Paper@616db71 Fix nothing mlg (#8432)
PaperMC/Paper@011caa4 [ci skip] Minor patch cleanup
PaperMC/Paper@15e1748 Avoid resizing of ArrayList in ChunkMap#getPlayers (#8416)
PaperMC/Paper@ad3d357 Remove unnecessary onTrackingStart during nav warning
PaperMC/Paper@9d63b07 Fix custom piglin interest items (#8097)
PaperMC/Paper@ff67f1f EntityPickupItemEvent fixes (#8096)
PaperMC/Paper@bcb4220 Correctly handle interactions with items on cooldown (#8008)
PaperMC/Paper@60c973e Exempt players in creative/spectator from nether ceiling damage (#8427)
PaperMC/Paper@77a50b9 Add Unmodifiable annotations to getDrops methods (#8440)
PaperMC/Paper@c389b1c Fix configs that relied on outdated min/max y levels (#6986)
PaperMC/Paper@57555b8 Add missing structure set seed configs (#8030)
PaperMC/Paper@b097a24 Expose isUnderWater to Entity (#8454)
PaperMC/Paper@6b26cfc Add missing Entity + Projectile API (#7632)
PaperMC/Paper@de2d2d4 Add PlayerInventorySlotChangeEvent (#7321)
PaperMC/Paper@f7c8d79 Fix stacktrace in server tests
PaperMC/Paper@b9cf1ac Fix a classloading issue in tests (#8459)
PaperMC/Paper@7fe34e9 Make CraftMinecartTNT public
PaperMC/Paper@514a606 Elder Guardian appearance API (#8455)
PaperMC/Paper@2094011 Update settings directory path in exceptions (#7968)
PaperMC/Paper@0bdf997 Avoid cycle deprecation (#8466)
PaperMC/Paper@eb68bd4 Allow changing bed's 'occupied' property (#8458)
PaperMC/Paper@b560034 Avoid usages of RecipeChoice#getItemStack() (#8453)
PaperMC/Paper@603df98 FIx bedrock patterns (#8474)
PaperMC/Paper@ec00f99 Fix package for PlayerInventorySlotChangeEvent (#8475)
PaperMC/Paper@236a296 Add LivingEntity#swingHand(EquipmentSlot) convenience method (#8456)
PaperMC/Paper@7d64d7c Add converted Slot number to PlayerInventorySlotChangeEvent (#8482)
PaperMC/Paper@ed2c88b Add LivingEntity knockback API (#8479)
PaperMC/Paper@e1d4b26 Fix another case of missing chat headers
PaperMC/Paper@f7da209 Fix inconsistent isChunkLoaded calls
PaperMC/Paper@3dcfec4 Add stacktrace deobfuscation in more places (#8484)
PaperMC/Paper@eb49418 [ci skip] Update workflow dependencies (#8489)
PaperMC/Paper@a163a96 Load Allay duplication cooldown as a long (#8410)
PaperMC/Paper@7187cab Detect headless JREs (#8491)
PaperMC/Paper@60da35e fixed entity vehicle collision event not called (#5053)
PaperMC/Paper@5cdb5f9 Optimized dirt and snow spreading (#5124)
PaperMC/Paper@3d50709 Add MaterialTags for the different Types of Tools (#8049)
PaperMC/Paper@6ea5aa3 Added EntityToggleSitEvent (#7579)
PaperMC/Paper@58483c1 Add fire-tick-delay option (#8037)
PaperMC/Paper@4e67c73 Add config setting for grindstone overstacking (#8156)
PaperMC/Paper@d713b47 Add EquipmentSlot convenience methods (#8477)
PaperMC/Paper@6665076 Add Moving Piston API (#7019)
PaperMC/Paper@0b8f40c Don't fire EntityToggleSitEvent on deserialization & reorder some api patches (#8495)
PaperMC/Paper@05bd9d6 Ignore impossible spawn tick (#8493)
PaperMC/Paper@b8131a0 Mark chunks as saved after saving them
PaperMC/Paper@44ce9b3 Updated Upstream (Bukkit/Spigot) (#8445)
PaperMC/Paper@1c1aeb2 Only limit global sounds to same world if limiting radius (#8499)
PaperMC/Paper@519cb4b Move classes added to net.minecraft.server to paper packages (#8500)
PaperMC/Paper@fc5ae5b Fix incorrect handling of mustNotSave
PaperMC/Paper@25cd3ee Add dirty flag to chunk tick lists
PaperMC/Paper@7b3b593 [ci skip] Update checkout action in workflow (#8510)
PaperMC/Paper@36869cc Fix new block data in EntityChangeBlockEvent for silverfish when mobGriefing isn't enabled (#8099)
PaperMC/Paper@2432233 Add allow server listing & text filtering client options (#7595)
PaperMC/Paper@954e6f0 Fix a bunch more forceDrops for dropping items (#8095)
PaperMC/Paper@32d95e9 Track projectile source for fireworks from dispensers (#8044)
PaperMC/Paper@0249750 Fix EntityArgument suggestion permissions to align with  EntitySelector#checkPermissions (#8511)
PaperMC/Paper@8acb05d Make CommandSyntaxException implement ComponentMessageThrowable (#8513)
PaperMC/Paper@c264018 [ci skip] Undo modification to removed patches in latest commit (#8512)
PaperMC/Paper@304ab35 [ci skip] Remove old todo file
PaperMC/Paper@8a4b752 Fix wrong descriptor in ASMEventExecutorGenerator (#8506)
PaperMC/Paper@b743144 Fix MC-147659 (#8423)
PaperMC/Paper@aaf5e39 Deprecate unused VehicleEntityCollisionEvent methods (#8498)
PaperMC/Paper@13cf546 Fix pumpkin growth modifier (#8517)
PaperMC/Paper@b3b04f2 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#8515)
PaperMC/Paper@93b2246 Fix EntityCombustEvent cancellation issues (#8529)
PaperMC/Paper@4a9c9b3 Build updates
PaperMC/Paper@e30b082 Fix setting difficulity inside of API (Fixes #8533)
PaperMC/Paper@ebc0f6b Call PlayerLaunchProjectileEvent for trident (#8027)
PaperMC/Paper@ab1c072 Remove old redundant fix (#8530)
PaperMC/Paper@8ee344f [ci-skip] Rename Paper stop tp Paper end. (#8539)
PaperMC/Paper@3d15120 Fix Advancement#getDisplay() api break (#8541)
PaperMC/Paper@2b47227 Update Commodore modifications (#8542)
PaperMC/Paper@df5fb94 Properly resend entities (#7041)
PaperMC/Paper@3e9f39f Prevent compass from loading chunks
PaperMC/Paper@3ac1a8d Cleanup misc import from last commit
PaperMC/Paper@e6ee4cd Updated Upstream (CraftBukkit) (#8548)
PaperMC/Paper@117579c Add PrePlayerAttackEntityEvent (#8369)
PaperMC/Paper@112fa18 Show exception when headless JRE detection is triggered (#8559)
PaperMC/Paper@5f4952f Cleanup reputation API + back with an EnumMap instead of array (#8258)
PaperMC/Paper@564356d ensure reset EnderDragon boss event name (#8562)
PaperMC/Paper@7955bcc fix MC-252817 (green map markers do not dissappear) (#8545)
PaperMC/Paper@e22dacf update yarn param mappings (#8563)
PaperMC/Paper@2151112 Fix/improve Affects Spawning API (#7329)
PaperMC/Paper@84b5d4a Reorder bukkit damage source entity for explosion (#8553)
PaperMC/Paper@b4c1ae6 Fix MC-121048 (#8429)
PaperMC/Paper@825cb43 [ci skip] Add .fleet/ folder to .gitignore (#8574)
PaperMC/Paper@669fed4 Fix MC-179072 (#8421)
PaperMC/Paper@8f498dc Sync chunk load command improvements (#8554)
PaperMC/Paper@3299886 [ci skip] Add TheFruxz to the license MIT list (#8575)
PaperMC/Paper@0a6f100 Add more collision code skipping logic (#7581)
PaperMC/Paper@76503f8 Strip coordinates from lodestone compasses (#8561)
PaperMC/Paper@b95d4b2 Moving ATs from the at file to individual patches (#8573)
PaperMC/Paper@4a3ae59 [ci skip] Add check for git repo (#8578)
PaperMC/Paper@a7df847 Add Player Warden Warning API (#8470)
PaperMC/Paper@3ab194e Avoid a cubed max search distance for POIs (#8576)
PaperMC/Paper@55a16d8 Fix Varint21FrameDecoder cached length buf usage
PaperMC/Paper@e6e37ba Add api to resolve components (#7648)
PaperMC/Paper@7168438 [ci skip] Rework workflows to support optional paperclip build (#8583)
PaperMC/Paper@da230d5 More vanilla friendly methods to update trades (#8478)
PaperMC/Paper@8aff07a Add /paper dumplisteners command (#8507)
PaperMC/Paper@b8919a7 pr command action fixes (#8591)
PaperMC/Paper@185fa48 Fix chest relooting mechanics (#8580)
PaperMC/Paper@b4beac0 Fixes potential issues arising from optimizing getPlayerByUUID (#8585)
PaperMC/Paper@f637b1a Fix async entity add due to fungus trees (#7626)
PaperMC/Paper@414ea80 ItemStack damage API (#7801)
PaperMC/Paper@d98c370 Add displayName methods for advancements (#8584)
PaperMC/Paper@44bb599 Add Tick TemporalUnit (#5445)
PaperMC/Paper@9f7eef8 Friction API (#6611)
PaperMC/Paper@4048d3e Allow using degrees for ArmorStand rotations (#7847)
PaperMC/Paper@f59c802 Schoolable Fish API (#7089)
PaperMC/Paper@21b964a Added ability to control player's insomnia and phantoms spawning (#6500)
PaperMC/Paper@f1583fc Add `/paper dumplisteners tofile` and increase detail of command output (#8592)
PaperMC/Paper@28b4027 Fix packet duplicating at some points (#8566)
PaperMC/Paper@309133e Fix preemptive connection dropping during shutdown process (#8546)
PaperMC/Paper@8796175 Handle legacy quirk in the console formatter (#8434)
PaperMC/Paper@54daefa Fix whitespace error in recent patch
PaperMC/Paper@41ab602 [ci skip] couple more fixes for build pr jar label (#8599)
PaperMC/Paper@c40f8d5 Sync offhand slot in menus (#7341)
PaperMC/Paper@425baed Fully deserialise persistent anger post async load (#8560)
PaperMC/Paper@ec6a9a3 Updated Upstream (Bukkit/CraftBukkit) (#8604)
PaperMC/Paper@96fdafd Player Entity Tracking Events (#4722)
PaperMC/Paper@407a445 Fix dumplisteners missing folder creation
PaperMC/Paper@b07d5e0 Limit pet look distance (#8612)
PaperMC/Paper@476ef25 Add missing Fluid type (#8608)
2022-12-06 16:54:38 -05:00

184 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 968c915cc494bb3c57169b7b3640002c3a4a8810..0c2b2cb4be57b11d748d13a0ec24b7470619267f 100644
--- a/src/main/java/net/minecraft/world/damagesource/BadRespawnPointDamage.java
+++ b/src/main/java/net/minecraft/world/damagesource/BadRespawnPointDamage.java
@@ -7,12 +7,20 @@ import net.minecraft.network.chat.HoverEvent;
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(Component.translatable("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 67bce77093dcc126098731047447da2031e3388d..051cf78fe9f7700e1f639c804f35903c8079eae9 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,7 +139,7 @@ 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) {
@@ -138,10 +150,17 @@ public class DamageSource {
return (new EntityDamageSource("sonic_boom", attacker)).bypassArmor().bypassEnchantments().setMagic();
}
+ @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 b786bd5178a605a5dfb7682b7cb809646895aea3..d986103d2d20be4514ce91fe27e42d0f7f1ca72b 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
@@ -98,7 +98,7 @@ 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;// = new Explosion(null, this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.BlockInteraction.DESTROY); // CraftBukkit - reusable source for CraftTNTPrimed.getSource() // Parchment - moved into constructor to fix null world
// Paper start - add var for save custom podium
@Nullable
private BlockPos podium;
@@ -106,6 +106,7 @@ public class EnderDragon extends Mob implements Enemy {
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); // 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 31708d1e94b557896d42199aa0bc6ed26a4c6d8a..786d43a991b94a355d8f52e81f5aa41cc11cfcb1 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -477,6 +477,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 654a859a37bf991c7a7fa8a44a3d20f8feb223db..52e6c9ea22273759ea9a827125bf561a62272ad9 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 6be6adf73dc48ebbac22fe2a9be635f675f18cb1..e814c791137da2a10f4d4dd65f201fc220399975 100644
--- a/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java
@@ -148,7 +148,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 a37bc950d24acee9889aded042ed2bc3a0d76929..e9847ba8dde5b9efb5214973f1399460ddcf930f 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -970,7 +970,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 {
@@ -1010,7 +1010,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()) {
@@ -1020,7 +1020,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;