Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-17 12:00:07 +01:00
4bc15f13aa
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: e2160a18 Make MapCursor#type not depends on deprecated values CraftBukkit Changes: 6ce172642 SPIGOT-7761: Ender pearl does not damage or spawn endermites f5a63f734 SPIGOT-7759: Chunk not there when requested in ChunkUnloadEvent 28287259c Remove unused import eb9a7dde0 SPIGOT-7757: Cannot set item in Stonecutter Inventory f8be9d752 Move deserialized removed unhandled tags to dedicated removedTags a7e576186 Fix potential mutability issue with CraftMetaItem copy constructor 995885452 SPIGOT-7741: Vanilla ItemComponent in commands can't remove components 9ef69aa0b PR-1284: Move ItemType <-> ItemMeta linking to a centralized place 3e82eafbe PR-1420: Fix DirectEntity and CausingEntity Damager for Creepers ignited by Player c23daa71f SPIGOT-7751: Fix crash caused by arrows from trial spawners Make MapCursor#type not depends on deprecated values SPIGOT-7761: Ender pearl does not damage or spawn endermites
102 Zeilen
7.3 KiB
Diff
102 Zeilen
7.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: dodison <kacpik@mapik.eu>
|
|
Date: Mon, 26 Jul 2021 17:32:36 +0200
|
|
Subject: [PATCH] Add critical damage API
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/damagesource/DamageSource.java b/src/main/java/net/minecraft/world/damagesource/DamageSource.java
|
|
index c1d121d83591ca1b5bf9d9406c9622b4f24eafef..aee26dd78953ff43306aaa64161f5b9edcdd4b83 100644
|
|
--- a/src/main/java/net/minecraft/world/damagesource/DamageSource.java
|
|
+++ b/src/main/java/net/minecraft/world/damagesource/DamageSource.java
|
|
@@ -276,4 +276,18 @@ public class DamageSource {
|
|
public Holder<DamageType> typeHolder() {
|
|
return this.type;
|
|
}
|
|
+
|
|
+ // Paper start - add critical damage API
|
|
+ private boolean critical;
|
|
+ public boolean isCritical() {
|
|
+ return this.critical;
|
|
+ }
|
|
+ public DamageSource critical() {
|
|
+ return this.critical(true);
|
|
+ }
|
|
+ public DamageSource critical(boolean critical) {
|
|
+ this.critical = critical;
|
|
+ return this;
|
|
+ }
|
|
+ // Paper end - add critical damage API
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
index c89b7cf63d067895bbd07f43eef467ff1861f625..536a4e3c26e83f359083bde19832a962628244fa 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
@@ -1292,6 +1292,7 @@ public abstract class Player extends LivingEntity {
|
|
|
|
flag2 = flag2 && !this.level().paperConfig().entities.behavior.disablePlayerCrits; // Paper - Toggleable player crits
|
|
if (flag2) {
|
|
+ damagesource = damagesource.critical(true); // Paper start - critical damage API
|
|
f *= 1.5F;
|
|
}
|
|
|
|
@@ -1352,7 +1353,7 @@ public abstract class Player extends LivingEntity {
|
|
float f7 = this.getEnchantedDamage(entityliving2, f6, damagesource) * f2;
|
|
|
|
// CraftBukkit start - Only apply knockback if the damage hits
|
|
- if (entityliving2.hurt(this.damageSources().playerAttack(this).sweep(), f7)) {
|
|
+ if (entityliving2.hurt(this.damageSources().playerAttack(this).sweep().critical(flag2), f7)) { // Paper - add critical damage API
|
|
entityliving2.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SWEEP_ATTACK); // CraftBukkit // Paper - knockback events
|
|
}
|
|
// CraftBukkit end
|
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
|
index f7dab560a1f98e494303ba4c5fd3d82fb78e9503..64bc4a668f635a6765ededd22246294e50c5297f 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
|
@@ -422,6 +422,7 @@ public abstract class AbstractArrow extends Projectile {
|
|
entityliving.setLastHurtMob(entity);
|
|
}
|
|
|
|
+ if (this.isCritArrow()) damagesource = damagesource.critical(); // Paper - add critical damage API
|
|
boolean flag = entity.getType() == EntityType.ENDERMAN;
|
|
int k = entity.getRemainingFireTicks();
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
index 18b2a6db3adee2ac2630d500005e0a4034cfbad7..76e262cc2d6686096eb7b58b6e7343c2a0ecafe5 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -1065,7 +1065,7 @@ public class CraftEventFactory {
|
|
return CraftEventFactory.callEntityDamageEvent(source.getDirectBlock(), source.getDirectBlockState(), entity, DamageCause.BLOCK_EXPLOSION, bukkitDamageSource, modifiers, modifierFunctions, cancelled);
|
|
}
|
|
DamageCause damageCause = (damager.getBukkitEntity() instanceof org.bukkit.entity.TNTPrimed) ? DamageCause.BLOCK_EXPLOSION : DamageCause.ENTITY_EXPLOSION;
|
|
- return CraftEventFactory.callEntityDamageEvent(damager, entity, damageCause, bukkitDamageSource, modifiers, modifierFunctions, cancelled);
|
|
+ return CraftEventFactory.callEntityDamageEvent(damager, entity, damageCause, bukkitDamageSource, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API
|
|
} else if (damager != null || source.getDirectEntity() != null) {
|
|
DamageCause cause = (source.isSweep()) ? DamageCause.ENTITY_SWEEP_ATTACK : DamageCause.ENTITY_ATTACK;
|
|
|
|
@@ -1091,7 +1091,7 @@ public class CraftEventFactory {
|
|
cause = DamageCause.MAGIC;
|
|
}
|
|
|
|
- return CraftEventFactory.callEntityDamageEvent(damager, entity, cause, bukkitDamageSource, modifiers, modifierFunctions, cancelled);
|
|
+ return CraftEventFactory.callEntityDamageEvent(damager, entity, cause, bukkitDamageSource, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API
|
|
} else if (source.is(DamageTypes.FELL_OUT_OF_WORLD)) {
|
|
return CraftEventFactory.callEntityDamageEvent(source.getDirectBlock(), source.getDirectBlockState(), entity, DamageCause.VOID, bukkitDamageSource, modifiers, modifierFunctions, cancelled);
|
|
} else if (source.is(DamageTypes.LAVA)) {
|
|
@@ -1151,13 +1151,13 @@ public class CraftEventFactory {
|
|
cause = DamageCause.CUSTOM;
|
|
}
|
|
|
|
- return CraftEventFactory.callEntityDamageEvent((Entity) null, entity, cause, bukkitDamageSource, modifiers, modifierFunctions, cancelled);
|
|
+ return CraftEventFactory.callEntityDamageEvent((Entity) null, entity, cause, bukkitDamageSource, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API
|
|
}
|
|
|
|
- private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, org.bukkit.damage.DamageSource bukkitDamageSource, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions, boolean cancelled) {
|
|
+ private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, org.bukkit.damage.DamageSource bukkitDamageSource, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions, boolean cancelled, boolean critical) { // Paper - add critical damage API
|
|
EntityDamageEvent event;
|
|
if (damager != null) {
|
|
- event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, bukkitDamageSource, modifiers, modifierFunctions);
|
|
+ event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, bukkitDamageSource, modifiers, modifierFunctions, critical);
|
|
} else {
|
|
event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, bukkitDamageSource, modifiers, modifierFunctions);
|
|
}
|