Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-19 21:10:10 +01:00
Implemented the concept of a projectile.
Dieser Commit ist enthalten in:
Ursprung
546e1306d8
Commit
155874eec9
@ -10,6 +10,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.entity.CraftVehicle;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
|
||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
@ -21,6 +22,7 @@ import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public abstract class Entity {
|
||||
@ -142,6 +144,13 @@ public abstract class Entity {
|
||||
}
|
||||
|
||||
public void die() {
|
||||
// CraftBukkit start
|
||||
if (this.getBukkitEntity() instanceof Projectile && !(this instanceof EntityFish)) {
|
||||
ProjectileHitEvent event = new ProjectileHitEvent((Projectile) this.getBukkitEntity());
|
||||
CraftServer server = ((WorldServer) this.world).getServer();
|
||||
server.getPluginManager().callEvent(event);
|
||||
}
|
||||
// CraftBukkit end
|
||||
this.dead = true;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@ import java.util.List;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
@ -165,25 +167,25 @@ public class EntityArrow extends Entity {
|
||||
// CraftBukkit start
|
||||
boolean stick;
|
||||
if (entity instanceof EntityLiving) {
|
||||
CraftServer server = ((WorldServer) this.world).getServer();
|
||||
CraftServer server = this.world.getServer();
|
||||
|
||||
// TODO decide if we should create DamageCause.ARROW, DamageCause.PROJECTILE
|
||||
// or leave as DamageCause.ENTITY_ATTACK
|
||||
org.bukkit.entity.Entity shooter = (this.shooter == null) ? null : this.shooter.getBukkitEntity();
|
||||
org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity();
|
||||
org.bukkit.entity.Entity projectile = this.getBukkitEntity();
|
||||
Projectile projectile = (Projectile) this.getBukkitEntity();
|
||||
// TODO deal with arrows being fired from a non-entity
|
||||
DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
|
||||
int damage = 4;
|
||||
|
||||
EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
|
||||
EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(damagee, projectile, damageCause, damage);
|
||||
server.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle();
|
||||
|
||||
if (event.isCancelled()) {
|
||||
stick = !event.getBounce();
|
||||
} else {
|
||||
// this function returns if the arrow should stick in or not, i.e. !bounce
|
||||
stick = movingobjectposition.entity.damageEntity(this.shooter, event.getDamage());
|
||||
} else {
|
||||
// event was cancelled, get if the arrow should bounce or not
|
||||
stick = !event.getBounce();
|
||||
}
|
||||
} else {
|
||||
stick = movingobjectposition.entity.damageEntity(this.shooter, 4);
|
||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.entity.Egg;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
@ -21,7 +22,7 @@ public class EntityEgg extends Entity {
|
||||
private int e = 0;
|
||||
private boolean f = false;
|
||||
public int a = 0;
|
||||
private EntityLiving thrower;
|
||||
public EntityLiving thrower; // CraftBukkit private -> public
|
||||
private int h;
|
||||
private int i = 0;
|
||||
|
||||
@ -155,23 +156,21 @@ public class EntityEgg extends Entity {
|
||||
if (movingobjectposition.entity != null) {
|
||||
boolean stick;
|
||||
if (movingobjectposition.entity instanceof EntityLiving) {
|
||||
CraftServer server = ((WorldServer) this.world).getServer();
|
||||
org.bukkit.entity.Entity shooter = (this.thrower == null) ? null : this.thrower.getBukkitEntity();
|
||||
CraftServer server = this.world.getServer();
|
||||
org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity();
|
||||
org.bukkit.entity.Entity projectile = this.getBukkitEntity();
|
||||
Projectile projectile = (Projectile) this.getBukkitEntity();
|
||||
DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
|
||||
int damage = 0;
|
||||
|
||||
// TODO @see EntityArrow#162
|
||||
EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
|
||||
EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(damagee, projectile, damageCause, damage);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
// this function returns if the egg should stick or not, i.e. !bounce
|
||||
stick = movingobjectposition.entity.damageEntity(this.thrower, event.getDamage());
|
||||
} else {
|
||||
// event was cancelled, get if the egg should bounce or not
|
||||
if (event.isCancelled()) {
|
||||
stick = !event.getBounce();
|
||||
} else {
|
||||
// this function returns if the egg should stick in or not, i.e. !bounce
|
||||
stick = movingobjectposition.entity.damageEntity(this.thrower, event.getDamage());
|
||||
}
|
||||
} else {
|
||||
stick = movingobjectposition.entity.damageEntity(this.thrower, 0);
|
||||
@ -191,7 +190,7 @@ public class EntityEgg extends Entity {
|
||||
CreatureType hatchingType = CreatureType.CHICKEN;
|
||||
|
||||
if (this.thrower instanceof EntityPlayer) {
|
||||
CraftServer server = ((WorldServer) this.world).getServer();
|
||||
CraftServer server = this.world.getServer();
|
||||
Player player = (this.thrower == null) ? null : (Player) this.thrower.getBukkitEntity();
|
||||
|
||||
PlayerEggThrowEvent event = new PlayerEggThrowEvent(player, (Egg) this.getBukkitEntity(), hatching, (byte) numHatching, hatchingType);
|
||||
|
@ -6,6 +6,8 @@ import java.util.List;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
import org.bukkit.entity.Explosive;
|
||||
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
@ -45,6 +47,11 @@ public class EntityFireball extends Entity {
|
||||
this.setPosition(this.locX, this.locY, this.locZ);
|
||||
this.height = 0.0F;
|
||||
this.motX = this.motY = this.motZ = 0.0D;
|
||||
// CraftBukkit start (added setDirection method)
|
||||
setDirection(d0, d1, d2);
|
||||
}
|
||||
|
||||
public void setDirection(double d0, double d1, double d2) {
|
||||
d0 += this.random.nextGaussian() * 0.4D;
|
||||
d1 += this.random.nextGaussian() * 0.4D;
|
||||
d2 += this.random.nextGaussian() * 0.4D;
|
||||
@ -127,23 +134,23 @@ public class EntityFireball extends Entity {
|
||||
if (movingobjectposition.entity != null) {
|
||||
boolean stick;
|
||||
if (movingobjectposition.entity instanceof EntityLiving) {
|
||||
CraftServer server = ((WorldServer) this.world).getServer();
|
||||
org.bukkit.entity.Entity shooter = (this.shooter == null) ? null : this.shooter.getBukkitEntity();
|
||||
CraftServer server = this.world.getServer();
|
||||
org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity();
|
||||
org.bukkit.entity.Entity projectile = this.getBukkitEntity();
|
||||
Projectile projectile = (Projectile) this.getBukkitEntity();
|
||||
DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
|
||||
int damage = 0;
|
||||
|
||||
// TODO @see EntityArrow#162
|
||||
EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
|
||||
EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(damagee, projectile, damageCause, damage);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
// this function returns if the fireball should stick or not, i.e. !bounce
|
||||
stick = movingobjectposition.entity.damageEntity(this.shooter, event.getDamage());
|
||||
} else {
|
||||
// event was cancelled, get if the fireball should bounce or not
|
||||
this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle();
|
||||
|
||||
if (event.isCancelled()) {
|
||||
stick = !event.getBounce();
|
||||
} else {
|
||||
// this function returns if the fireball should stick in or not, i.e. !bounce
|
||||
stick = movingobjectposition.entity.damageEntity(this.shooter, event.getDamage());
|
||||
}
|
||||
} else {
|
||||
stick = movingobjectposition.entity.damageEntity(this.shooter, 0);
|
||||
@ -153,7 +160,7 @@ public class EntityFireball extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
CraftServer server = ((WorldServer) this.world).getServer();
|
||||
CraftServer server = this.world.getServer();
|
||||
|
||||
ExplosionPrimeEvent event = new ExplosionPrimeEvent((Explosive) CraftEntity.getEntity(server, this));
|
||||
|
||||
@ -161,12 +168,11 @@ public class EntityFireball extends Entity {
|
||||
if (!event.isCancelled()) {
|
||||
// give 'this' instead of (Entity) null so we know what causes the damage
|
||||
this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire());
|
||||
this.die();
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
// this.die() // # CraftBukkit
|
||||
this.die();
|
||||
}
|
||||
|
||||
this.locX += this.motX;
|
||||
|
@ -4,6 +4,7 @@ import java.util.List;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
@ -193,23 +194,21 @@ public class EntityFish extends Entity {
|
||||
// TODO add EntityDamagedByProjectileEvent : fishing hook?
|
||||
boolean stick;
|
||||
if (movingobjectposition.entity instanceof EntityLiving) {
|
||||
CraftServer server = ((WorldServer) this.world).getServer();
|
||||
org.bukkit.entity.Entity shooter = (this.owner == null) ? null : this.owner.getBukkitEntity();
|
||||
CraftServer server = this.world.getServer();
|
||||
org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity();
|
||||
org.bukkit.entity.Entity projectile = this.getBukkitEntity();
|
||||
Projectile projectile = (Projectile) this.getBukkitEntity();
|
||||
DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
|
||||
int damage = 0;
|
||||
|
||||
// TODO @see EntityArrow#162
|
||||
EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
|
||||
EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(damagee, projectile, damageCause, damage);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
// this function returns if the fish should stick or not, i.e. !bounce
|
||||
stick = movingobjectposition.entity.damageEntity(this.owner, event.getDamage());
|
||||
} else {
|
||||
// event was cancelled, get if the fish should bounce or not
|
||||
if (event.isCancelled()) {
|
||||
stick = !event.getBounce();
|
||||
} else {
|
||||
// this function returns if the fish should stick in or not, i.e. !bounce
|
||||
stick = movingobjectposition.entity.damageEntity(this.owner, event.getDamage());
|
||||
}
|
||||
} else {
|
||||
stick = movingobjectposition.entity.damageEntity(this.owner, 0);
|
||||
|
@ -4,6 +4,8 @@ import java.util.List;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
@ -17,7 +19,7 @@ public class EntitySnowball extends Entity {
|
||||
private int e = 0;
|
||||
private boolean f = false;
|
||||
public int a = 0;
|
||||
private EntityLiving shooter;
|
||||
public EntityLiving shooter; // CraftBukkit private -> public
|
||||
private int h;
|
||||
private int i = 0;
|
||||
|
||||
@ -151,23 +153,22 @@ public class EntitySnowball extends Entity {
|
||||
if (movingobjectposition.entity != null) {
|
||||
boolean stick;
|
||||
if (movingobjectposition.entity instanceof EntityLiving) {
|
||||
CraftServer server = ((WorldServer) this.world).getServer();
|
||||
org.bukkit.entity.Entity shooter = (this.shooter == null) ? null : this.shooter.getBukkitEntity();
|
||||
CraftServer server = this.world.getServer();
|
||||
org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity();
|
||||
org.bukkit.entity.Entity projectile = this.getBukkitEntity();
|
||||
Projectile projectile = (Projectile) this.getBukkitEntity();
|
||||
DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
|
||||
int damage = 0;
|
||||
|
||||
// TODO @see EntityArrow#162
|
||||
EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
|
||||
EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(damagee, projectile, damageCause, damage);
|
||||
server.getPluginManager().callEvent(event);
|
||||
this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle();
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
// this function returns if the snowball should stick or not, i.e. !bounce
|
||||
stick = movingobjectposition.entity.damageEntity(this.shooter, event.getDamage());
|
||||
} else {
|
||||
// event was cancelled, get if the snowball should bounce or not
|
||||
if (event.isCancelled()) {
|
||||
stick = !event.getBounce();
|
||||
} else {
|
||||
// this function returns if the snowball should stick in or not, i.e. !bounce
|
||||
stick = movingobjectposition.entity.damageEntity(this.shooter, event.getDamage());
|
||||
}
|
||||
} else {
|
||||
stick = movingobjectposition.entity.damageEntity(this.shooter, 0);
|
||||
|
@ -248,7 +248,16 @@ public class EntityTrackerEntry {
|
||||
return new Packet23VehicleSpawn(this.tracker, 61);
|
||||
} else if (this.tracker instanceof EntityFireball) {
|
||||
EntityFireball entityfireball = (EntityFireball) this.tracker;
|
||||
Packet23VehicleSpawn packet23vehiclespawn = new Packet23VehicleSpawn(this.tracker, 63, ((EntityFireball) this.tracker).shooter.id);
|
||||
// CraftBukkit start - added check for null shooter
|
||||
// Packet23VehicleSpawn packet23vehiclespawn = new Packet23VehicleSpawn(this.tracker, 63, ((EntityFireball) this.tracker).shooter.id);
|
||||
|
||||
Packet23VehicleSpawn packet23vehiclespawn;
|
||||
if (((EntityFireball) this.tracker).shooter != null) {
|
||||
packet23vehiclespawn = new Packet23VehicleSpawn(this.tracker, 63, ((EntityFireball) this.tracker).shooter.id);
|
||||
} else {
|
||||
packet23vehiclespawn = new Packet23VehicleSpawn(this.tracker, 63, 1);
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
packet23vehiclespawn.e = (int) (entityfireball.c * 8000.0D);
|
||||
packet23vehiclespawn.f = (int) (entityfireball.d * 8000.0D);
|
||||
|
@ -1,13 +1,14 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import org.bukkit.entity.Arrow;
|
||||
import net.minecraft.server.EntityArrow;
|
||||
import net.minecraft.server.EntityLiving;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
/**
|
||||
* Represents an arrow.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class CraftArrow extends CraftEntity implements Arrow {
|
||||
public CraftArrow(CraftServer server, EntityArrow entity) {
|
||||
@ -18,4 +19,19 @@ public class CraftArrow extends CraftEntity implements Arrow {
|
||||
public String toString() {
|
||||
return "CraftArrow";
|
||||
}
|
||||
|
||||
public LivingEntity getShooter() {
|
||||
if (((EntityArrow) getHandle()).shooter != null) {
|
||||
return (LivingEntity) ((EntityArrow) getHandle()).shooter.getBukkitEntity();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public void setShooter(LivingEntity shooter) {
|
||||
if (shooter instanceof CraftLivingEntity) {
|
||||
((EntityArrow) getHandle()).shooter = (EntityLiving) ((CraftLivingEntity) shooter).entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityEgg;
|
||||
import net.minecraft.server.EntityLiving;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Egg;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
/**
|
||||
* An egg.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class CraftEgg extends CraftEntity implements Egg {
|
||||
public CraftEgg(CraftServer server, EntityEgg entity) {
|
||||
@ -18,4 +19,19 @@ public class CraftEgg extends CraftEntity implements Egg {
|
||||
public String toString() {
|
||||
return "CraftEgg";
|
||||
}
|
||||
|
||||
public LivingEntity getShooter() {
|
||||
if (((EntityEgg) getHandle()).thrower != null) {
|
||||
return (LivingEntity) ((EntityEgg) getHandle()).thrower.getBukkitEntity();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public void setShooter(LivingEntity shooter) {
|
||||
if (shooter instanceof CraftLivingEntity) {
|
||||
((EntityEgg) getHandle()).thrower = (EntityLiving) ((CraftLivingEntity) shooter).entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityFireball;
|
||||
import net.minecraft.server.EntityLiving;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
/**
|
||||
* A Fireball.
|
||||
@ -33,4 +36,27 @@ public class CraftFireball extends CraftEntity implements Fireball {
|
||||
public void setYield(float yield) {
|
||||
((EntityFireball) getHandle()).yield = yield;
|
||||
}
|
||||
|
||||
public LivingEntity getShooter() {
|
||||
if (((EntityFireball) getHandle()).shooter != null) {
|
||||
return (LivingEntity) ((EntityFireball) getHandle()).shooter.getBukkitEntity();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public void setShooter(LivingEntity shooter) {
|
||||
if (shooter instanceof CraftLivingEntity) {
|
||||
((EntityFireball) getHandle()).shooter = (EntityLiving) ((CraftLivingEntity) shooter).entity;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector getDirection() {
|
||||
return new Vector(((EntityFireball) getHandle()).c, ((EntityFireball) getHandle()).d, ((EntityFireball) getHandle()).e);
|
||||
}
|
||||
|
||||
public void setDirection(Vector direction) {
|
||||
((EntityFireball) getHandle()).setDirection(direction.getX(), direction.getY(), direction.getZ());
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityFish;
|
||||
import net.minecraft.server.EntityHuman;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Fish;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
/**
|
||||
* A Fish.
|
||||
*
|
||||
* @author Cogito
|
||||
*/
|
||||
public class CraftFish extends CraftEntity implements Fish {
|
||||
public CraftFish(CraftServer server, EntityFish entity) {
|
||||
@ -19,4 +19,20 @@ public class CraftFish extends CraftEntity implements Fish {
|
||||
public String toString() {
|
||||
return "CraftFish";
|
||||
}
|
||||
|
||||
public LivingEntity getShooter() {
|
||||
if (((EntityFish) getHandle()).owner != null) {
|
||||
return (LivingEntity) ((EntityFish) getHandle()).owner.getBukkitEntity();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public void setShooter(LivingEntity shooter) {
|
||||
if (shooter instanceof CraftHumanEntity) {
|
||||
((EntityFish) getHandle()).owner = (EntityHuman) ((CraftHumanEntity) shooter).entity;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityLiving;
|
||||
import net.minecraft.server.EntitySnowball;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Snowball;
|
||||
|
||||
/**
|
||||
* A snowball.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class CraftSnowball extends CraftEntity implements Snowball {
|
||||
public CraftSnowball(CraftServer server, EntitySnowball entity) {
|
||||
@ -18,4 +19,18 @@ public class CraftSnowball extends CraftEntity implements Snowball {
|
||||
public String toString() {
|
||||
return "CraftSnowball";
|
||||
}
|
||||
|
||||
public LivingEntity getShooter() {
|
||||
if (((EntitySnowball) getHandle()).shooter != null) {
|
||||
return (LivingEntity) ((EntitySnowball) getHandle()).shooter.getBukkitEntity();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setShooter(LivingEntity shooter) {
|
||||
if (shooter instanceof CraftLivingEntity) {
|
||||
((EntitySnowball) getHandle()).shooter = (EntityLiving) ((CraftLivingEntity) shooter).entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren