Cleanup damage source a bit (#12106)

This commit is contained in:
Lulu13022002
2025-02-16 20:14:00 +01:00
committed by GitHub
parent 608f004a2c
commit 7bee99714a
31 changed files with 135 additions and 215 deletions

View File

@@ -51,6 +51,8 @@ public interface DamageSource {
* be present if an entity did not cause the damage.
*
* @return the location, or null if none
* @apiNote the world of the location might be null for positioned-only damage source
* not caused by any entity
*/
@Nullable
public Location getDamageLocation();
@@ -66,6 +68,8 @@ public interface DamageSource {
* returned.
*
* @return the source of the location or null.
* @apiNote the world of the location might be null for positioned-only damage source
* not caused by any entity
*/
@Nullable
public Location getSourceLocation();

View File

@@ -23,7 +23,7 @@ public class EntityDamageByBlockEvent extends EntityDamageEvent {
@Deprecated(since = "1.20.4", forRemoval = true)
public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) {
this(damager, (damager != null) ? damager.getState() : null, damagee, cause, (damager != null) ? DamageSource.builder(DamageType.GENERIC).withDamageLocation(damager.getLocation()).build() : DamageSource.builder(DamageType.GENERIC).build(), damage);
this(damager, (damager != null) ? damager.getState() : null, damagee, cause, DamageSource.builder(DamageType.GENERIC).build(), damage);
}
public EntityDamageByBlockEvent(@Nullable final Block damager, @Nullable final BlockState damagerState, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, final double damage) {

View File

@@ -17,7 +17,7 @@ public class EntityDamageByEntityEvent extends EntityDamageEvent {
@Deprecated(since = "1.20.4", forRemoval = true)
public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) {
this(damager, damagee, cause, DamageSource.builder(DamageType.GENERIC).withCausingEntity(damager).withDirectEntity(damager).build(), damage);
this(damager, damagee, cause, DamageSource.builder(DamageType.GENERIC).build(), damage);
}
@Deprecated
@@ -29,7 +29,7 @@ public class EntityDamageByEntityEvent extends EntityDamageEvent {
@Deprecated(since = "1.20.4", forRemoval = true)
public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
this(damager, damagee, cause, DamageSource.builder(DamageType.GENERIC).withCausingEntity(damager).withDirectEntity(damager).build(), modifiers, modifierFunctions);
this(damager, damagee, cause, DamageSource.builder(DamageType.GENERIC).build(), modifiers, modifierFunctions);
}
@Deprecated
@@ -65,7 +65,7 @@ public class EntityDamageByEntityEvent extends EntityDamageEvent {
* {@inheritDoc}
* <p>
* The {@link DamageSource#getDirectEntity()} may be different from the {@link #getDamager()}
* if the Minecraft damage source did not originally include an damager entity, but one was included
* if the damage source did not originally include a damager entity, but one was included
* for this event {@link #getDamager()}.
*/
@Override