mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 19:49:35 +01:00
Retiring EntityDamageByProjectileEvent in favor of EntityDamageEvent.
By: sunkid <sunkid@iminurnetz.com>
This commit is contained in:
parent
920854a915
commit
8054b4db89
3 changed files with 27 additions and 11 deletions
|
@ -16,8 +16,21 @@ public interface Projectile extends Entity {
|
|||
/**
|
||||
* Set the shooter of this projectile
|
||||
*
|
||||
* @param shooter
|
||||
* the {@link LivingEntity} that shot this projectile
|
||||
* @param shooter the {@link LivingEntity} that shot this projectile
|
||||
*/
|
||||
public void setShooter(LivingEntity shooter);
|
||||
|
||||
/**
|
||||
* Determine if this projectile should bounce or not when it hits.
|
||||
*
|
||||
* @return true if it should bounce.
|
||||
*/
|
||||
public boolean doesBounce();
|
||||
|
||||
/**
|
||||
* Set whether or not this projectile should bounce or not when it hits something.
|
||||
*
|
||||
* @param doesBounce whether or not it should bounce.
|
||||
*/
|
||||
public void setBounce(boolean doesBounce);
|
||||
}
|
||||
|
|
|
@ -1,28 +1,25 @@
|
|||
package org.bukkit.event.entity;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Projectile;
|
||||
|
||||
/**
|
||||
* Called when an entity is damaged by a projectile
|
||||
*
|
||||
* @deprecated use {@link EntityDamageByEntityEvent} instead, where {@link EntityDamageByEntityEvent#getDamager()} will return the {@link Projectile}
|
||||
*/
|
||||
@Deprecated
|
||||
public class EntityDamageByProjectileEvent extends EntityDamageByEntityEvent {
|
||||
|
||||
private Projectile projectile;
|
||||
private boolean bounce;
|
||||
|
||||
public EntityDamageByProjectileEvent(Entity damagee, Projectile projectile, DamageCause cause, int damage) {
|
||||
this(projectile.getShooter(), damagee, projectile, cause, damage);
|
||||
}
|
||||
|
||||
public EntityDamageByProjectileEvent(Entity damager, Entity damagee, Projectile projectile, DamageCause cause, int damage) {
|
||||
super(damager, damagee, cause, damage);
|
||||
super(damager, projectile, DamageCause.PROJECTILE, damage);
|
||||
this.projectile = projectile;
|
||||
Random random = new Random();
|
||||
|
||||
this.bounce = random.nextBoolean();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,10 +32,10 @@ public class EntityDamageByProjectileEvent extends EntityDamageByEntityEvent {
|
|||
}
|
||||
|
||||
public void setBounce(boolean bounce) {
|
||||
this.bounce = bounce;
|
||||
projectile.setBounce(bounce);
|
||||
}
|
||||
|
||||
public boolean getBounce() {
|
||||
return bounce;
|
||||
return projectile.doesBounce();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,6 +77,12 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
|
|||
* Damage: variable
|
||||
*/
|
||||
ENTITY_ATTACK,
|
||||
/**
|
||||
* Damage caused when attacked by a projectile.
|
||||
*
|
||||
* Damage: variable
|
||||
*/
|
||||
PROJECTILE,
|
||||
/**
|
||||
* Damage caused by being put in a block
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue