From b3aedca8456f5242faf41e965d7f1ed1777ec35d Mon Sep 17 00:00:00 2001 From: LemonCaramel Date: Thu, 27 Jun 2024 21:40:55 +0900 Subject: [PATCH] #20240627.0 --- ...6-Add-More-API-for-EntityDamageEvent.patch | 311 ------------------ patches/0006-Add-more-Damage-API.patch | 210 ++++++++++++ patches/0021-Add-ItemStack-Utilities.patch | 4 +- patches/0023-Add-more-Explosion-API.patch | 190 +++++++---- 4 files changed, 339 insertions(+), 376 deletions(-) delete mode 100644 patches/0006-Add-More-API-for-EntityDamageEvent.patch create mode 100644 patches/0006-Add-more-Damage-API.patch diff --git a/patches/0006-Add-More-API-for-EntityDamageEvent.patch b/patches/0006-Add-More-API-for-EntityDamageEvent.patch deleted file mode 100644 index eae1abac2..000000000 --- a/patches/0006-Add-More-API-for-EntityDamageEvent.patch +++ /dev/null @@ -1,311 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: LemonCaramel -Date: Sun, 8 Aug 2021 03:05:54 +0900 -Subject: [PATCH] Add more API for EntityDamageEvent - - -diff --git a/src/main/java/moe/caramel/daydream/world/DamageMata.java b/src/main/java/moe/caramel/daydream/world/DamageMata.java -new file mode 100644 -index 0000000000000000000000000000000000000000..aca7b9e9076a6c48cf3f27f42f841cd076dca587 ---- /dev/null -+++ b/src/main/java/moe/caramel/daydream/world/DamageMata.java -@@ -0,0 +1,244 @@ -+package moe.caramel.daydream.world; -+ -+import org.bukkit.entity.Entity; -+import org.bukkit.util.Vector; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+import java.util.Map; -+ -+/** -+ * 대미지 메타데이터 -+ */ -+public interface DamageMata { -+ -+ int NO_DATA = -1; -+ -+ // ============================================== -+ -+ /** -+ * NMS DamageSource를 가져옵니다. -+ * -+ * @return NMS DamageSource -+ */ -+ @NotNull -+ Object getDamageSource(); -+ -+ /** -+ * 배고픔 고갈 정도를 가져옵니다. -+ * -+ * @return 배고픔 고갈 정도 -+ */ -+ float getFoodExhaustion(); -+ -+ /** -+ * 간접 공격의 여부를 가져옵니다. -+ * -+ * @return 간접 공격의 여부 -+ */ -+ boolean isIndirect(); -+ -+ /** -+ * 이 엔티티의 공격자를 가져옵니다. -+ * 예시) 화살 -+ * -+ * @return 공격자 -+ */ -+ @Nullable -+ Entity getDirectEntity(); -+ -+ /** -+ * (존재하는 경우) 이 엔티티의 실제 공격자를 가져옵니다. -+ * 예시) 화살을 발사한 공격자를 반환 -+ * -+ * @return 실제 공격자 -+ */ -+ @Nullable -+ Entity getEntity(); -+ -+ /** -+ * 이 대미지 소스의 ID를 가져옵니다. -+ * -+ * @return 대미지 소스의 ID -+ */ -+ @NotNull -+ String getId(); -+ -+ /** -+ * 난이도에 따라 대미지 스케일이 변하는지 여부를 가져옵니다. -+ * -+ * @return 가변 스케일 여부 -+ */ -+ boolean scalesWithDifficulty(); -+ -+ /** -+ * 이 대미지 소스의 발생 위치를 가져옵니다. -+ * (일반적으로 BadRespawnPoint에서 발생) -+ * -+ * @return 이 대미지 소스의 발생 위치 -+ */ -+ @Nullable -+ Vector getSourcePosition(); -+ -+ /** -+ * 크리티컬 대미지 여부를 가져옵니다. -+ * -+ * @return 크리티컬 대미지 여부 -+ */ -+ boolean isCritical(); -+ -+ /** -+ * 검에 의한 쓸기 공격 여부를 가져옵니다. -+ * -+ * @return 쓸기 공격 여부 -+ */ -+ boolean isSweep(); -+ -+ /** -+ * 눈골렘이 녹아 발생한 대미지인지 확인합니다. -+ * -+ * @return 눈골렘이 녹아 발생한 대미지 여부 -+ */ -+ boolean isMelting(); -+ -+ /** -+ * 독 포션에 의한 대미지인지 확인합니다. -+ * -+ * @return 독 포션에 의한 대미지 여부 -+ */ -+ boolean isPoison(); -+ -+ // ====================== (DamageTypes) -+ -+ boolean isTypeInFire(); -+ boolean isTypeLightningBolt(); -+ boolean isTypeOnFire(); -+ boolean isTypeLava(); -+ boolean isTypeHotFloor(); -+ boolean isTypeInWall(); -+ boolean isTypeCramming(); -+ boolean isTypeDrown(); -+ boolean isTypeStarve(); -+ boolean isTypeCactus(); -+ boolean isTypeFall(); -+ boolean isTypeFlyIntoWall(); -+ boolean isTypeFellOutOfWorld(); -+ boolean isTypeGeneric(); -+ boolean isTypeMagic(); -+ boolean isTypeWither(); -+ boolean isTypeDragonBreath(); -+ boolean isTypeDryOut(); -+ boolean isTypeSweetBerryBush(); -+ boolean isTypeFreeze(); -+ boolean isTypeStalagmite(); -+ boolean isTypeFallingBlock(); -+ boolean isTypeFallingAnvil(); -+ boolean isTypeFallingStalactite(); -+ boolean isTypeSting(); -+ boolean isTypeMobAttack(); -+ boolean isTypeMobAttackNoAggro(); -+ boolean isTypePlayerAttack(); -+ boolean isTypeArrow(); -+ boolean isTypeTrident(); -+ boolean isTypeMobProjectile(); -+ boolean isTypeFireworks(); -+ boolean isTypeFireball(); -+ boolean isTypeUnattributedFireball(); -+ boolean isTypeWitherSkull(); -+ boolean isTypeThrown(); -+ boolean isTypeIndirectMagic(); -+ boolean isTypeThorns(); -+ boolean isTypeExplosion(); -+ boolean isTypePlayerExplosion(); -+ boolean isTypeSonicBoom(); -+ boolean isTypeBadRespawnPoint(); -+ boolean isTypeOutsideBorder(); -+ boolean isTypeGenericKill(); -+ -+ // ====================== (Tags) -+ -+ boolean hasTagDamagesHelmet(); -+ boolean hasTagBreezeImmuneTo(); -+ boolean hasTagBypassesArmor(); -+ boolean hasTagBypassesShield(); -+ boolean hasTagBypassesInvulnerability(); -+ boolean hasTagBypassesCooldown(); -+ boolean hasTagBypassesEffects(); -+ boolean hasTagBypassesResistance(); -+ boolean hasTagBypassesEnchantments(); -+ boolean hasTagIsFire(); -+ boolean hasTagIsProjectile(); -+ boolean hasTagWitchResistantTo(); -+ boolean hasTagIsExplosion(); -+ boolean hasTagIsFall(); -+ boolean hasTagIsDrowning(); -+ boolean hasTagIsFreezing(); -+ boolean hasTagIsLighting(); -+ boolean hasTagNoAnger(); -+ boolean hasTagNoImpact(); -+ boolean hasTagAlwaysMostSignificantFall(); -+ boolean hasTagWitherImmuneTo(); -+ boolean hasTagIgnitesArmorStands(); -+ boolean hasTagBurnsArmorStands(); -+ boolean hasTagAvoidsGuardianThorns(); -+ boolean hasTagAlwaysTriggersSilverfish(); -+ boolean hasTagAlwaysHurtsEnderDragons(); -+ boolean hasTagNoKnockback(); -+ boolean hasTagAlwaysKillsArmorStands(); -+ boolean hasTagCanBreakArmorStand(); -+ -+ // ============================================== -+ -+ /** -+ * 사용자 지정 메타데이터를 가져옵니다. -+ * 초기 값은 {@code null}입니다. -+ * -+ * @return 사용자 지정 메타데이터 -+ */ -+ @Nullable -+ Map getMetadata(); -+ -+ /** -+ * 사용자 지정 메타데이터를 설정합니다. -+ * 데이터를 추가하는 것이 아닌 완전히 덮어 씌웁니다. -+ * -+ * @param metadata 사용자 지정 메타데이터 -+ */ -+ void setMetadata(final @Nullable Map metadata); -+ -+ // ============================================== -+ -+ /** -+ * 대상 엔티티에게 설정될 무적 시간을 가져옵니다. -+ * LivingEntity가 아닌 경우 {@link #NO_DATA}를 반환합니다. -+ * -+ * @return 무적 시간 -+ */ -+ int getNoDamageTick(); -+ -+ /** -+ * 대상 엔티티의 무적 시간을 설정합니다. -+ * LivingEntity가 아닌 경우 값이 적용되지 않습니다. -+ * -+ * @param ticks 무적 시간 -+ */ -+ void setNoDamageTick(final int ticks); -+ -+ // ============================================== -+ -+ /** -+ * 대미지 처리 이후 받게 될 강제된 넉백을 가져옵니다. -+ * -+ * @return 대미지 처리 이후 받게 될 넉백 -+ */ -+ @Nullable -+ Vector getOverrideKnockback(); -+ -+ /** -+ * 대미지 처리 이후 받게 될 넉백을 강제로 설정합니다. -+ * {@code null}인 경우 바닐라의 설정을 따르며, {@link Vector}의 -+ * 크기가 0인 경우 넉백을 적용하지 않습니다. -+ * -+ * @param knockback 대미지 처리 이후 받게 될 넉백 -+ */ -+ void setOverrideKnockback(final @Nullable Vector knockback); -+} -diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java -index b9a07b2db8a3dcdb72c33c8ceda129921b2c02f1..d0a42ee3e77f3a8db323e3c2eca1ded9e205d1ab 100644 ---- a/src/main/java/org/bukkit/UnsafeValues.java -+++ b/src/main/java/org/bukkit/UnsafeValues.java -@@ -302,4 +302,6 @@ public interface UnsafeValues { - // Paper end - lifecycle event API - - @NotNull java.util.List computeTooltipLines(@NotNull ItemStack itemStack, @NotNull io.papermc.paper.inventory.tooltip.TooltipContext tooltipContext, @Nullable org.bukkit.entity.Player player); // Paper - expose itemstack tooltip lines -+ -+ @NotNull moe.caramel.daydream.world.DamageMata getDamageMeta(@NotNull Object damageSource); // Daydream - Add more API for EntityDamageEvent - } -diff --git a/src/main/java/org/bukkit/damage/DamageSource.java b/src/main/java/org/bukkit/damage/DamageSource.java -index 7635610e56c051ce3c8a876911ba5cd0a9248496..f4b2ba6610ce3119f612047b6452777a91c8d30e 100644 ---- a/src/main/java/org/bukkit/damage/DamageSource.java -+++ b/src/main/java/org/bukkit/damage/DamageSource.java -@@ -13,6 +13,16 @@ import org.jetbrains.annotations.Nullable; - @ApiStatus.Experimental - public interface DamageSource { - -+ // Daydream start - Add more API for EntityDamageEvent -+ /** -+ * 대미지 메타데이터를 가져옵니다. -+ * -+ * @return 대미지 메타데이터 -+ */ -+ @NotNull -+ public moe.caramel.daydream.world.DamageMata getDamageMeta(); -+ // Daydream end - Add more API for EntityDamageEvent -+ - /** - * Get the {@link DamageType}. - * -diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java -index 446b3ffd5caca5344be1c250475679834cd0d4a2..31d1cd2e0cbefad6a4bbb10d9d3a4b5d6e954c09 100644 ---- a/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java -+++ b/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java -@@ -59,6 +59,18 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { - this.damageSource = damageSource; - } - -+ // Daydream start - Add more API for EntityDamageEvent -+ /** -+ * 대미지 메타데이터를 가져옵니다. -+ * -+ * @return 대미지 메타데이터 -+ */ -+ @NotNull -+ public moe.caramel.daydream.world.DamageMata getDamageMeta() { -+ return damageSource.getDamageMeta(); -+ } -+ // Daydream end - Add more API for EntityDamageEvent -+ - @Override - public boolean isCancelled() { - return cancelled; diff --git a/patches/0006-Add-more-Damage-API.patch b/patches/0006-Add-more-Damage-API.patch new file mode 100644 index 000000000..613530c5e --- /dev/null +++ b/patches/0006-Add-more-Damage-API.patch @@ -0,0 +1,210 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: LemonCaramel +Date: Sun, 8 Aug 2021 03:05:54 +0900 +Subject: [PATCH] Add more Damage API + + +diff --git a/src/main/java/moe/caramel/daydream/world/DamageMata.java b/src/main/java/moe/caramel/daydream/world/DamageMata.java +new file mode 100644 +index 0000000000000000000000000000000000000000..ce5d5aeb96b65f705b436647c963b7f087431e1d +--- /dev/null ++++ b/src/main/java/moe/caramel/daydream/world/DamageMata.java +@@ -0,0 +1,71 @@ ++package moe.caramel.daydream.world; ++ ++import org.bukkit.damage.DamageSource; ++import org.jetbrains.annotations.NotNull; ++import java.util.Map; ++ ++/** ++ * 대미지 메타데이터 ++ */ ++public interface DamageMata { ++ ++ /** ++ * NMS DamageSource를 가져옵니다. ++ * ++ * @return NMS DamageSource ++ */ ++ @NotNull ++ Object getRawDamageSource(); ++ ++ /** ++ * DamageSource를 가져옵니다. ++ * ++ * @return DamageSource ++ */ ++ @NotNull ++ DamageSource getDamageSource(); ++ ++ /** ++ * 사용자 지정 메타데이터를 가져옵니다. ++ * ++ * @return 사용자 지정 메타데이터 ++ */ ++ @NotNull ++ Map getMetadata(); ++ ++ // ============================================== ++ ++ int NO_DATA = -1; ++ ++ /** ++ * 대상 엔티티에게 설정될 무적 시간을 가져옵니다. ++ * LivingEntity가 아닌 경우 {@link #NO_DATA}를 반환합니다. ++ * ++ * @return 무적 시간 ++ */ ++ int getNoDamageTick(); ++ ++ /** ++ * 대상 엔티티의 무적 시간을 설정합니다. ++ * LivingEntity가 아닌 경우 값이 적용되지 않습니다. ++ * ++ * @param ticks 무적 시간 ++ */ ++ void setNoDamageTick(final int ticks); ++ ++ /** ++ * 대미지 처리 이후 엔티티가 받게 될 넉백의 비활성화 여부를 가져옵니다. ++ * ++ * @return 넉백 비활성화 여부, {@link org.bukkit.damage.DamageType}에 ++ * {@link org.bukkit.Tag#DAMAGE_TYPE_NO_KNOCKBACK}가 있는 경우에도 ++ * {@code true}를 반환합니다. ++ */ ++ boolean isKnockbackDisabled(); ++ ++ /** ++ * 대미지 처리 이후 엔티티가 받게 될 넉백의 비활성화 여부를 설정합니다. ++ * ++ * @param disabled 넉백 비활성화 여부 ++ */ ++ void setKnockbackDisabled(final boolean disabled); ++} +diff --git a/src/main/java/org/bukkit/Tag.java b/src/main/java/org/bukkit/Tag.java +index 8ca9c7c8d0d6138c825d765c270c29bce11fe09e..e904c68a31c234b8d3e8bac96ebdca8fc5526643 100644 +--- a/src/main/java/org/bukkit/Tag.java ++++ b/src/main/java/org/bukkit/Tag.java +@@ -1005,6 +1005,39 @@ public interface Tag extends Keyed { + Tag GAME_EVENT_ALLAY_CAN_LISTEN = Bukkit.getTag(REGISTRY_GAME_EVENTS, NamespacedKey.minecraft("allay_can_listen"), GameEvent.class); + // Paper end + ++ // Daydream start - Add more Damage API ++ String REGISTRY_DAMAGE_TYPE = "damage_type"; ++ Tag DAMAGE_TYPE_DAMAGES_HELMET = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("damages_helmet"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_BREEZE_IMMUNE_TO = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("breeze_immune_to"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_BYPASSES_ARMOR = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("bypasses_armor"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_BYPASSES_SHIELD = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("bypasses_shield"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_BYPASSES_INVULNERABILITY = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("bypasses_invulnerability"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_BYPASSES_COOLDOWN = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("bypasses_cooldown"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_BYPASSES_EFFECTS = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("bypasses_effects"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_BYPASSES_RESISTANCE = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("bypasses_resistance"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_BYPASSES_ENCHANTMENTS = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("bypasses_enchantments"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_IS_FIRE = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("is_fire"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_IS_PROJECTILE = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("is_projectile"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_WITCH_RESISTANT_TO = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("witch_resistant_to"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_IS_EXPLOSION = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("is_explosion"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_IS_FALL = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("is_fall"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_IS_DROWNING = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("is_drowning"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_IS_FREEZING = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("is_freezing"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_IS_LIGHTNING = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("is_lightning"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_NO_ANGER = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("no_anger"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_NO_IMPACT = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("no_impact"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_ALWAYS_MOST_SIGNIFICANT_FALL = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("always_most_significant_fall"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_WITHER_IMMUNE_TO = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("wither_immune_to"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_IGNITES_ARMOR_STANDS = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("ignites_armor_stands"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_BURNS_ARMOR_STANDS = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("burns_armor_stands"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_AVOIDS_GUARDIAN_THORNS = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("avoids_guardian_thorns"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_ALWAYS_TRIGGERS_SILVERFISH = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("always_triggers_silverfish"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_ALWAYS_HURTS_ENDER_DRAGONS = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("always_hurts_ender_dragons"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_NO_KNOCKBACK = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("no_knockback"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_ALWAYS_KILLS_ARMOR_STANDS = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("always_kills_armor_stands"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_CAN_BREAK_ARMOR_STAND = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("can_break_armor_stand"), org.bukkit.damage.DamageType.class); ++ // Daydream end - Add more Damage API ++ + /** + * Returns whether or not this tag has an entry for the specified item. + * +diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java +index b9a07b2db8a3dcdb72c33c8ceda129921b2c02f1..13b1902c7d289dfae60a453aab248d308459aded 100644 +--- a/src/main/java/org/bukkit/UnsafeValues.java ++++ b/src/main/java/org/bukkit/UnsafeValues.java +@@ -302,4 +302,6 @@ public interface UnsafeValues { + // Paper end - lifecycle event API + + @NotNull java.util.List computeTooltipLines(@NotNull ItemStack itemStack, @NotNull io.papermc.paper.inventory.tooltip.TooltipContext tooltipContext, @Nullable org.bukkit.entity.Player player); // Paper - expose itemstack tooltip lines ++ ++ @NotNull moe.caramel.daydream.world.DamageMata getDamageMeta(@NotNull Object damageSource); // Daydream - Add more Damage API + } +diff --git a/src/main/java/org/bukkit/damage/DamageSource.java b/src/main/java/org/bukkit/damage/DamageSource.java +index 7635610e56c051ce3c8a876911ba5cd0a9248496..e08a7f64bfbd9116f8a4a814732939a7c0c7155a 100644 +--- a/src/main/java/org/bukkit/damage/DamageSource.java ++++ b/src/main/java/org/bukkit/damage/DamageSource.java +@@ -13,6 +13,44 @@ import org.jetbrains.annotations.Nullable; + @ApiStatus.Experimental + public interface DamageSource { + ++ // Daydream start - Add more Damage API ++ /** ++ * 대미지 메타데이터를 가져옵니다. ++ * ++ * @return 대미지 메타데이터 ++ */ ++ @NotNull ++ public moe.caramel.daydream.world.DamageMata getDamageMeta(); ++ ++ /** ++ * 크리티컬 대미지 여부를 가져옵니다. ++ * ++ * @return 크리티컬 대미지 여부 ++ */ ++ boolean isCritical(); ++ ++ /** ++ * 검에 의한 쓸기 공격 여부를 가져옵니다. ++ * ++ * @return 쓸기 공격 여부 ++ */ ++ boolean isSweep(); ++ ++ /** ++ * 눈골렘이 녹아 발생한 대미지인지 확인합니다. ++ * ++ * @return 눈골렘이 녹아 발생한 대미지 여부 ++ */ ++ boolean isMelting(); ++ ++ /** ++ * 독 포션에 의한 대미지인지 확인합니다. ++ * ++ * @return 독 포션에 의한 대미지 여부 ++ */ ++ boolean isPoison(); ++ // Daydream end - Add more Damage API ++ + /** + * Get the {@link DamageType}. + * +diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java +index 446b3ffd5caca5344be1c250475679834cd0d4a2..16fd4324962bd5acea9770740059a82cfb914f06 100644 +--- a/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java ++++ b/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java +@@ -59,6 +59,18 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { + this.damageSource = damageSource; + } + ++ // Daydream start - Add more Damage API ++ /** ++ * 대미지 메타데이터를 가져옵니다. ++ * ++ * @return 대미지 메타데이터 ++ */ ++ @NotNull ++ public moe.caramel.daydream.world.DamageMata getDamageMeta() { ++ return damageSource.getDamageMeta(); ++ } ++ // Daydream end - Add more Damage API ++ + @Override + public boolean isCancelled() { + return cancelled; diff --git a/patches/0021-Add-ItemStack-Utilities.patch b/patches/0021-Add-ItemStack-Utilities.patch index cb01422e4..7c1951f5c 100644 --- a/patches/0021-Add-ItemStack-Utilities.patch +++ b/patches/0021-Add-ItemStack-Utilities.patch @@ -5,13 +5,13 @@ Subject: [PATCH] Add ItemStack Utilities diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java -index d0a42ee3e77f3a8db323e3c2eca1ded9e205d1ab..a868eb8c227e330abe00f695655dd24a1a7c51eb 100644 +index 13b1902c7d289dfae60a453aab248d308459aded..ba16e4ab7e5bef33e5fbd79106d2dabdf7e566ea 100644 --- a/src/main/java/org/bukkit/UnsafeValues.java +++ b/src/main/java/org/bukkit/UnsafeValues.java @@ -304,4 +304,18 @@ public interface UnsafeValues { @NotNull java.util.List computeTooltipLines(@NotNull ItemStack itemStack, @NotNull io.papermc.paper.inventory.tooltip.TooltipContext tooltipContext, @Nullable org.bukkit.entity.Player player); // Paper - expose itemstack tooltip lines - @NotNull moe.caramel.daydream.world.DamageMata getDamageMeta(@NotNull Object damageSource); // Daydream - Add more API for EntityDamageEvent + @NotNull moe.caramel.daydream.world.DamageMata getDamageMeta(@NotNull Object damageSource); // Daydream - Add more Damage API + + // Daydream start - Add ItemStack Utilities + /** diff --git a/patches/0023-Add-more-Explosion-API.patch b/patches/0023-Add-more-Explosion-API.patch index e54c5c9ac..f0ba97b9e 100644 --- a/patches/0023-Add-more-Explosion-API.patch +++ b/patches/0023-Add-more-Explosion-API.patch @@ -5,13 +5,13 @@ Subject: [PATCH] Add more Explosion API diff --git a/src/main/java/moe/caramel/daydream/world/DamageMata.java b/src/main/java/moe/caramel/daydream/world/DamageMata.java -index aca7b9e9076a6c48cf3f27f42f841cd076dca587..b7995e0ea84dbe9c4a517ebcf5ccdcd99ac67fc3 100644 +index ce5d5aeb96b65f705b436647c963b7f087431e1d..5ae4e9f6ce1b2eaeed74894d42d54ff507881f2c 100644 --- a/src/main/java/moe/caramel/daydream/world/DamageMata.java +++ b/src/main/java/moe/caramel/daydream/world/DamageMata.java -@@ -241,4 +241,14 @@ public interface DamageMata { - * @param knockback 대미지 처리 이후 받게 될 넉백 +@@ -68,4 +68,14 @@ public interface DamageMata { + * @param disabled 넉백 비활성화 여부 */ - void setOverrideKnockback(final @Nullable Vector knockback); + void setKnockbackDisabled(final boolean disabled); + + // ============================================== + @@ -20,18 +20,19 @@ index aca7b9e9076a6c48cf3f27f42f841cd076dca587..b7995e0ea84dbe9c4a517ebcf5ccdcd9 + * + * @return 폭발 래퍼 + */ -+ @Nullable ++ @org.jetbrains.annotations.Nullable + Explosion getExplosion(); } diff --git a/src/main/java/moe/caramel/daydream/world/Explosion.java b/src/main/java/moe/caramel/daydream/world/Explosion.java new file mode 100644 -index 0000000000000000000000000000000000000000..394159310ec31777c5c423f94405d9ec3721e95a +index 0000000000000000000000000000000000000000..a37e3050ef3250c9e78ee13cef20527de9438b32 --- /dev/null +++ b/src/main/java/moe/caramel/daydream/world/Explosion.java -@@ -0,0 +1,122 @@ +@@ -0,0 +1,131 @@ +package moe.caramel.daydream.world; + +import org.bukkit.World; ++import org.bukkit.damage.DamageSource; +import org.bukkit.entity.HumanEntity; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; @@ -51,6 +52,41 @@ index 0000000000000000000000000000000000000000..394159310ec31777c5c423f94405d9ec + World getWorld(); + + /** ++ * {@link DamageSource}를 가져옵니다. ++ * ++ * @return {@link DamageSource} ++ */ ++ @NotNull ++ DamageSource getDamageSource(); ++ ++ /** ++ * 폭발의 메타데이터를 가져옵니다. ++ * ({@link DamageMata#getMetadata()}와 동일) ++ * ++ * @return 메타데이터 ++ */ ++ @NotNull ++ Map getMetadata(); ++ ++ /** ++ * 이 폭발의 넉백 제거 활성화 여부를 설정합니다. ++ * ({@link DamageMata#setKnockbackDisabled(boolean)}와 동일) ++ * ++ * @param mark 넉백 제거가 활성화 여부 ++ */ ++ void markNoKnockback(boolean mark); ++ ++ /** ++ * 이 폭발에 넉백 제거가 활성화 되어있는지 가져옵니다. ++ * ({@link DamageMata#isKnockbackDisabled()}와 동일) ++ * ++ * @return 넉백 제거 여부, {@link org.bukkit.damage.DamageType}에 ++ * {@link org.bukkit.Tag#DAMAGE_TYPE_CARAMEL$EXPLOSION_NO_KNOCKBACK}가 ++ * 있는 경우에도 {@code true}를 반환합니다. ++ */ ++ boolean markedNoKnockback(); ++ ++ /** + * 폭발 시 방화 여부를 가져옵니다. + * + * @return 방화 여부 @@ -88,25 +124,11 @@ index 0000000000000000000000000000000000000000..394159310ec31777c5c423f94405d9ec + /** + * 이 폭발에 블록이 영향받는지를 가져옵니다. + * -+ * @return 블록이 영향받는지 ++ * @return 블록이 영향받는지 여부 + */ + boolean interactsWithBlocks(); + + /** -+ * 이 폭발의 넉백 제거 활성화 여부를 설정합니다. -+ * -+ * @param mark 넉백 제거가 활성화 여부 -+ */ -+ void markNoKnockback(boolean mark); -+ -+ /** -+ * 이 폭발에 넉백 제거가 활성화 되어있는지 가져옵니다. -+ * -+ * @return 넉백 제거가 활성화 여부 -+ */ -+ boolean markedNoKnockback(); -+ -+ /** + * 이 폭발에 영향을 받는 플레이어 목록을 가져옵니다. + * + * @return 플레이어 목록 및 벡터 @@ -127,35 +149,38 @@ index 0000000000000000000000000000000000000000..394159310ec31777c5c423f94405d9ec + void clearHitPlayers(); + + /** -+ * 폭발의 메타데이터를 가져옵니다. -+ * -+ * @return 메타데이터 -+ */ -+ @NotNull -+ Map getMetadata(); -+ -+ /** + * 폭발을 시작합니다. + */ + void explode(); + + /** -+ * 폭발을 마무리합니다. -+ */ -+ void finalizeExplosion(); -+ -+ /** -+ * 폭발이 취소되었는지 여부를 가져옵니다. ++ * 폭발이 이벤트에 의해 취소되었는지 여부를 가져옵니다. + * + * @return 폭발 취소의 여부 + */ + boolean wasCancelled(); +} +diff --git a/src/main/java/org/bukkit/Tag.java b/src/main/java/org/bukkit/Tag.java +index e904c68a31c234b8d3e8bac96ebdca8fc5526643..3cef22f1ecf71ac93e5a51a8b7e6e25899e7ffe6 100644 +--- a/src/main/java/org/bukkit/Tag.java ++++ b/src/main/java/org/bukkit/Tag.java +@@ -1037,6 +1037,11 @@ public interface Tag extends Keyed { + Tag DAMAGE_TYPE_ALWAYS_KILLS_ARMOR_STANDS = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("always_kills_armor_stands"), org.bukkit.damage.DamageType.class); + Tag DAMAGE_TYPE_CAN_BREAK_ARMOR_STAND = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, NamespacedKey.minecraft("can_break_armor_stand"), org.bukkit.damage.DamageType.class); + // Daydream end - Add more Damage API ++ // Daydream start - Add more Explosion API ++ Tag DAMAGE_TYPE_CARAMEL$EXPLOSION_NO_KNOCKBACK = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, new NamespacedKey("caramel", "explosion_no_knockback"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_CARAMEL$EXPLOSION_NO_BLOCK_BREAK = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, new NamespacedKey("caramel", "explosion_no_block_break"), org.bukkit.damage.DamageType.class); ++ Tag DAMAGE_TYPE_CARAMEL$EXPLOSION_NO_HURT_ENTTIY = Bukkit.getTag(REGISTRY_DAMAGE_TYPE, new NamespacedKey("caramel", "explosion_no_hurt_entity"), org.bukkit.damage.DamageType.class); ++ // Daydream end - Add more Explosion API + + /** + * Returns whether or not this tag has an entry for the specified item. diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java -index 9743c964b66e8f7ff1c4abe4187b95cadab62ce3..51fbae9e05c0894a21d145406ee56fb105a7bc6c 100644 +index c40c594887f5e23734c5477290c17df4c0f2ad6d..67a16f6bf6744c6934d90f3d0294b42dc3f09bfd 100644 --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java -@@ -2168,6 +2168,182 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient +@@ -2168,6 +2168,242 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient */ public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, @Nullable Entity source); @@ -274,11 +299,70 @@ index 9743c964b66e8f7ff1c4abe4187b95cadab62ce3..51fbae9e05c0894a21d145406ee56fb1 + * explode and finalize should be called. + */ + @NotNull -+ public moe.caramel.daydream.world.Explosion explosion( ++ default moe.caramel.daydream.world.Explosion explosion( + double x, double y, double z, float power, boolean setFire, @NotNull ExplosionAction explosionAction, + @NotNull Particle largeParticle, @Nullable T largeData, + @NotNull Particle smallParticle, @Nullable T smallData, + @NotNull String sound, @Nullable Entity source ++ ) { ++ return explosion(x, y, z, power, setFire, explosionAction, largeParticle, largeData, smallParticle, smallData, sound, null, source); ++ } ++ ++ /** ++ * Creates explosion at given coordinates with given power and optionally ++ * setting blocks on fire or breaking blocks. ++ * ++ * @param x X coordinate ++ * @param y Y coordinate ++ * @param z Z coordinate ++ * @param power The power of explosion, where 4F is TNT ++ * @param setFire Whether or not to set blocks on fire ++ * @param explosionAction Explosion action ++ * @param largeParticle Large particle ++ * @param largeData Large particle data ++ * @param smallParticle Small particle ++ * @param smallData Small particle data ++ * @param sound Explosion sound ++ * @param source the source entity, used for tracking damage ++ * @return returns the Explosion wrapper. Explosion is not enabled, ++ * explode and finalize should be called. ++ */ ++ @NotNull ++ default moe.caramel.daydream.world.Explosion explosion( ++ double x, double y, double z, float power, boolean setFire, @NotNull ExplosionAction explosionAction, ++ @NotNull Particle largeParticle, @Nullable T largeData, ++ @NotNull Particle smallParticle, @Nullable T smallData, ++ @NotNull Sound sound, @Nullable Entity source ++ ) { ++ return explosion(x, y, z, power, setFire, explosionAction, largeParticle, largeData, smallParticle, smallData, sound, null, source); ++ }; ++ ++ /** ++ * Creates explosion at given coordinates with given power and optionally ++ * setting blocks on fire or breaking blocks. ++ * ++ * @param x X coordinate ++ * @param y Y coordinate ++ * @param z Z coordinate ++ * @param power The power of explosion, where 4F is TNT ++ * @param setFire Whether or not to set blocks on fire ++ * @param explosionAction Explosion action ++ * @param largeParticle Large particle ++ * @param largeData Large particle data ++ * @param smallParticle Small particle ++ * @param smallData Small particle data ++ * @param sound Explosion sound ++ * @param damageSource damageSource the damage source ++ * @param source the source entity, used for tracking damage ++ * @return returns the Explosion wrapper. Explosion is not enabled, ++ * explode and finalize should be called. ++ */ ++ @NotNull ++ public moe.caramel.daydream.world.Explosion explosion( ++ double x, double y, double z, float power, boolean setFire, @NotNull ExplosionAction explosionAction, ++ @NotNull Particle largeParticle, @Nullable T largeData, ++ @NotNull Particle smallParticle, @Nullable T smallData, ++ @NotNull String sound, @Nullable org.bukkit.damage.DamageSource damageSource, @Nullable Entity source + ); + + /** @@ -296,6 +380,7 @@ index 9743c964b66e8f7ff1c4abe4187b95cadab62ce3..51fbae9e05c0894a21d145406ee56fb1 + * @param smallParticle Small particle + * @param smallData Small particle data + * @param sound Explosion sound ++ * @param damageSource damageSource the damage source + * @param source the source entity, used for tracking damage + * @return returns the Explosion wrapper. Explosion is not enabled, + * explode and finalize should be called. @@ -305,7 +390,7 @@ index 9743c964b66e8f7ff1c4abe4187b95cadab62ce3..51fbae9e05c0894a21d145406ee56fb1 + double x, double y, double z, float power, boolean setFire, @NotNull ExplosionAction explosionAction, + @NotNull Particle largeParticle, @Nullable T largeData, + @NotNull Particle smallParticle, @Nullable T smallData, -+ @NotNull Sound sound, @Nullable Entity source ++ @NotNull Sound sound, @Nullable org.bukkit.damage.DamageSource damageSource, @Nullable Entity source + ); + + /** @@ -338,27 +423,6 @@ index 9743c964b66e8f7ff1c4abe4187b95cadab62ce3..51fbae9e05c0894a21d145406ee56fb1 /** * Creates explosion at given coordinates with given power * -diff --git a/src/main/java/org/bukkit/entity/TNTPrimed.java b/src/main/java/org/bukkit/entity/TNTPrimed.java -index 87e717c9ea61b0cbf536bc62fa829ddcfae5ad8c..517de12da7faf7394f56382fd26dd3766e9e3b8e 100644 ---- a/src/main/java/org/bukkit/entity/TNTPrimed.java -+++ b/src/main/java/org/bukkit/entity/TNTPrimed.java -@@ -86,4 +86,16 @@ public interface TNTPrimed extends Explosive { - @org.jetbrains.annotations.NotNull - org.bukkit.block.data.BlockData getBlockData(); - // Paper end -+ -+ // Daydream start - Add more Explosion API -+ /** -+ * {@link TNTPrimed}의 폭발 래퍼를 가져옵니다. -+ * -+ * @return 폭발이 완료되지 않은 상태로 반환되며, -+ * {@link org.bukkit.event.entity.ExplosionPrimeEvent}가 -+ * 취소된 경우 {@code null}을 반환합니다. -+ */ -+ @Nullable -+ moe.caramel.daydream.world.Explosion getExplosion(); -+ // Daydream end - Add more Explosion API - } diff --git a/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java b/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java index 7dcbb75170296c1dd1d784a032bf369602328b29..e6eb7694d572fb6409c3ab88194ff6ba4347d319 100644 --- a/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java @@ -394,7 +458,7 @@ index 7dcbb75170296c1dd1d784a032bf369602328b29..e6eb7694d572fb6409c3ab88194ff6ba @Override diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java -index 31d1cd2e0cbefad6a4bbb10d9d3a4b5d6e954c09..9afa99fcf1a41efb4fe07484757eed9d6ccd5c98 100644 +index 16fd4324962bd5acea9770740059a82cfb914f06..1382e5c54ed7522643dbf48e7cdd7c3f53778c84 100644 --- a/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java +++ b/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java @@ -69,6 +69,16 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { @@ -411,7 +475,7 @@ index 31d1cd2e0cbefad6a4bbb10d9d3a4b5d6e954c09..9afa99fcf1a41efb4fe07484757eed9d + public moe.caramel.daydream.world.Explosion getExplosion() { + return getDamageMeta().getExplosion(); + } - // Daydream end - Add more API for EntityDamageEvent + // Daydream end - Add more Damage API @Override diff --git a/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java b/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java