From 7d70dbf92782e637ed168f7e14dfce41f8e0635a Mon Sep 17 00:00:00 2001 From: Noah van der Aa <ndvdaa@gmail.com> Date: Sat, 14 Dec 2024 14:47:37 +0100 Subject: [PATCH] net.minecraft.world.damagesource --- .../damagesource/DamageSource.java.patch | 11 +++--- .../damagesource/DamageSources.java.patch | 38 +++++++------------ 2 files changed, 18 insertions(+), 31 deletions(-) rename paper-server/patches/{unapplied => sources}/net/minecraft/world/damagesource/DamageSource.java.patch (97%) rename paper-server/patches/{unapplied => sources}/net/minecraft/world/damagesource/DamageSources.java.patch (63%) diff --git a/paper-server/patches/unapplied/net/minecraft/world/damagesource/DamageSource.java.patch b/paper-server/patches/sources/net/minecraft/world/damagesource/DamageSource.java.patch similarity index 97% rename from paper-server/patches/unapplied/net/minecraft/world/damagesource/DamageSource.java.patch rename to paper-server/patches/sources/net/minecraft/world/damagesource/DamageSource.java.patch index 65bbca9531..44ed121c0f 100644 --- a/paper-server/patches/unapplied/net/minecraft/world/damagesource/DamageSource.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/damagesource/DamageSource.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/damagesource/DamageSource.java +++ b/net/minecraft/world/damagesource/DamageSource.java -@@ -21,7 +21,106 @@ +@@ -20,6 +_,105 @@ private final Entity directEntity; @Nullable private final Vec3 damageSourcePosition; @@ -14,7 +14,7 @@ + private boolean poison = false; + @Nullable + private Entity customEventDamager = null; // This field is a helper for when causing entity damage is not set by vanilla // Paper - fix DamageSource API - ++ + public DamageSource sweep() { + this.sweep = true; + return this; @@ -103,11 +103,10 @@ + return damageSource; + } + // CraftBukkit end -+ + + @Override public String toString() { - return "DamageSource (" + this.type().msgId() + ")"; - } -@@ -163,4 +262,18 @@ +@@ -134,4 +_,18 @@ public Holder<DamageType> typeHolder() { return this.type; } diff --git a/paper-server/patches/unapplied/net/minecraft/world/damagesource/DamageSources.java.patch b/paper-server/patches/sources/net/minecraft/world/damagesource/DamageSources.java.patch similarity index 63% rename from paper-server/patches/unapplied/net/minecraft/world/damagesource/DamageSources.java.patch rename to paper-server/patches/sources/net/minecraft/world/damagesource/DamageSources.java.patch index ef590e6374..9e1a0a8d8b 100644 --- a/paper-server/patches/unapplied/net/minecraft/world/damagesource/DamageSources.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/damagesource/DamageSources.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/damagesource/DamageSources.java +++ b/net/minecraft/world/damagesource/DamageSources.java -@@ -43,9 +43,15 @@ +@@ -42,9 +_,15 @@ private final DamageSource stalagmite; private final DamageSource outsideBorder; private final DamageSource genericKill; @@ -8,20 +8,18 @@ + private final DamageSource melting; + private final DamageSource poison; - public DamageSources(RegistryAccess registryManager) { - this.damageTypes = registryManager.lookupOrThrow(Registries.DAMAGE_TYPE); + public DamageSources(RegistryAccess registry) { + this.damageTypes = registry.lookupOrThrow(Registries.DAMAGE_TYPE); + this.melting = this.source(DamageTypes.ON_FIRE).melting(); + this.poison = this.source(DamageTypes.MAGIC).poison(); + // CraftBukkit end this.inFire = this.source(DamageTypes.IN_FIRE); this.campfire = this.source(DamageTypes.CAMPFIRE); this.lightningBolt = this.source(DamageTypes.LIGHTNING_BOLT); -@@ -83,7 +89,17 @@ +@@ -84,6 +_,16 @@ + return new DamageSource(this.damageTypes.getOrThrow(damageTypeKey), causingEntity, directEntity); + } - 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() { + return this.melting; @@ -29,34 +27,24 @@ + + public DamageSource poison() { + return this.poison; - } ++ } + // CraftBukkit end - ++ public DamageSource inFire() { return this.inFire; -@@ -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); -+ return this.source(attacker != null && source != null ? DamageTypes.PLAYER_EXPLOSION : DamageTypes.EXPLOSION, source, attacker); // Paper - revert to vanilla - } - - public DamageSource sonicBoom(Entity attacker) { -@@ -262,9 +278,15 @@ +@@ -261,7 +_,13 @@ } public DamageSource badRespawnPointExplosion(Vec3 position) { - return new DamageSource(this.damageTypes.getOrThrow(DamageTypes.BAD_RESPAWN_POINT), position); + // CraftBukkit start + return this.badRespawnPointExplosion(position, null); - } - ++ } ++ + public DamageSource badRespawnPointExplosion(Vec3 vec3d, org.bukkit.block.BlockState blockState) { + return new DamageSource(this.damageTypes.getOrThrow(DamageTypes.BAD_RESPAWN_POINT), vec3d).directBlockState(blockState); + // CraftBukkit end -+ } -+ - public DamageSource outOfBorder() { - return this.outsideBorder; } + + public DamageSource outOfBorder() {