3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-16 21:10:17 +01:00

Implemented the concept of a projectile.

Dieser Commit ist enthalten in:
sunkid 2011-06-18 08:10:31 -07:00 committet von EvilSeph
Ursprung 546e1306d8
Commit 155874eec9
12 geänderte Dateien mit 174 neuen und 60 gelöschten Zeilen

Datei anzeigen

@ -10,6 +10,7 @@ import org.bukkit.Bukkit;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.entity.CraftVehicle; import org.bukkit.craftbukkit.entity.CraftVehicle;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Vehicle; import org.bukkit.entity.Vehicle;
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent; import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
import org.bukkit.event.vehicle.VehicleExitEvent; 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.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.ProjectileHitEvent;
// CraftBukkit end // CraftBukkit end
public abstract class Entity { public abstract class Entity {
@ -142,6 +144,13 @@ public abstract class Entity {
} }
public void die() { 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; this.dead = true;
} }

Datei anzeigen

@ -4,6 +4,8 @@ import java.util.List;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.CraftServer; 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.EntityDamageByProjectileEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
@ -165,25 +167,25 @@ public class EntityArrow extends Entity {
// CraftBukkit start // CraftBukkit start
boolean stick; boolean stick;
if (entity instanceof EntityLiving) { 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 // TODO decide if we should create DamageCause.ARROW, DamageCause.PROJECTILE
// or leave as DamageCause.ENTITY_ATTACK // 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 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 // TODO deal with arrows being fired from a non-entity
DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK; DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
int damage = 4; int damage = 4;
EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage); EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(damagee, projectile, damageCause, damage);
server.getPluginManager().callEvent(event); 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 // this function returns if the arrow should stick in or not, i.e. !bounce
stick = movingobjectposition.entity.damageEntity(this.shooter, event.getDamage()); stick = movingobjectposition.entity.damageEntity(this.shooter, event.getDamage());
} else {
// event was cancelled, get if the arrow should bounce or not
stick = !event.getBounce();
} }
} else { } else {
stick = movingobjectposition.entity.damageEntity(this.shooter, 4); stick = movingobjectposition.entity.damageEntity(this.shooter, 4);

Datei anzeigen

@ -6,6 +6,7 @@ import java.util.List;
import org.bukkit.entity.CreatureType; import org.bukkit.entity.CreatureType;
import org.bukkit.entity.Egg; import org.bukkit.entity.Egg;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.entity.EntityDamageByProjectileEvent; import org.bukkit.event.entity.EntityDamageByProjectileEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
@ -21,7 +22,7 @@ public class EntityEgg extends Entity {
private int e = 0; private int e = 0;
private boolean f = false; private boolean f = false;
public int a = 0; public int a = 0;
private EntityLiving thrower; public EntityLiving thrower; // CraftBukkit private -> public
private int h; private int h;
private int i = 0; private int i = 0;
@ -155,23 +156,21 @@ public class EntityEgg extends Entity {
if (movingobjectposition.entity != null) { if (movingobjectposition.entity != null) {
boolean stick; boolean stick;
if (movingobjectposition.entity instanceof EntityLiving) { if (movingobjectposition.entity instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.world).getServer(); CraftServer server = this.world.getServer();
org.bukkit.entity.Entity shooter = (this.thrower == null) ? null : this.thrower.getBukkitEntity();
org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity(); 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; DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
int damage = 0; int damage = 0;
// TODO @see EntityArrow#162 // 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); server.getPluginManager().callEvent(event);
if (!event.isCancelled()) { 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
stick = !event.getBounce(); 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 { } else {
stick = movingobjectposition.entity.damageEntity(this.thrower, 0); stick = movingobjectposition.entity.damageEntity(this.thrower, 0);
@ -191,7 +190,7 @@ public class EntityEgg extends Entity {
CreatureType hatchingType = CreatureType.CHICKEN; CreatureType hatchingType = CreatureType.CHICKEN;
if (this.thrower instanceof EntityPlayer) { 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(); Player player = (this.thrower == null) ? null : (Player) this.thrower.getBukkitEntity();
PlayerEggThrowEvent event = new PlayerEggThrowEvent(player, (Egg) this.getBukkitEntity(), hatching, (byte) numHatching, hatchingType); PlayerEggThrowEvent event = new PlayerEggThrowEvent(player, (Egg) this.getBukkitEntity(), hatching, (byte) numHatching, hatchingType);

Datei anzeigen

@ -6,6 +6,8 @@ import java.util.List;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.entity.Explosive; 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.EntityDamageByProjectileEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; 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.setPosition(this.locX, this.locY, this.locZ);
this.height = 0.0F; this.height = 0.0F;
this.motX = this.motY = this.motZ = 0.0D; 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; d0 += this.random.nextGaussian() * 0.4D;
d1 += this.random.nextGaussian() * 0.4D; d1 += this.random.nextGaussian() * 0.4D;
d2 += this.random.nextGaussian() * 0.4D; d2 += this.random.nextGaussian() * 0.4D;
@ -127,23 +134,23 @@ public class EntityFireball extends Entity {
if (movingobjectposition.entity != null) { if (movingobjectposition.entity != null) {
boolean stick; boolean stick;
if (movingobjectposition.entity instanceof EntityLiving) { if (movingobjectposition.entity instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.world).getServer(); CraftServer server = this.world.getServer();
org.bukkit.entity.Entity shooter = (this.shooter == null) ? null : this.shooter.getBukkitEntity();
org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity(); 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; DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
int damage = 0; int damage = 0;
// TODO @see EntityArrow#162 // 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); server.getPluginManager().callEvent(event);
if (!event.isCancelled()) { this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle();
// this function returns if the fireball should stick or not, i.e. !bounce
stick = movingobjectposition.entity.damageEntity(this.shooter, event.getDamage()); if (event.isCancelled()) {
} else {
// event was cancelled, get if the fireball should bounce or not
stick = !event.getBounce(); 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 { } else {
stick = movingobjectposition.entity.damageEntity(this.shooter, 0); 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)); ExplosionPrimeEvent event = new ExplosionPrimeEvent((Explosive) CraftEntity.getEntity(server, this));
@ -161,12 +168,11 @@ public class EntityFireball extends Entity {
if (!event.isCancelled()) { if (!event.isCancelled()) {
// give 'this' instead of (Entity) null so we know what causes the damage // 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.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire());
this.die();
} }
// CraftBukkit end // CraftBukkit end
} }
// this.die() // # CraftBukkit this.die();
} }
this.locX += this.motX; this.locX += this.motX;

Datei anzeigen

@ -4,6 +4,7 @@ import java.util.List;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.EntityDamageByProjectileEvent; import org.bukkit.event.entity.EntityDamageByProjectileEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
@ -193,23 +194,21 @@ public class EntityFish extends Entity {
// TODO add EntityDamagedByProjectileEvent : fishing hook? // TODO add EntityDamagedByProjectileEvent : fishing hook?
boolean stick; boolean stick;
if (movingobjectposition.entity instanceof EntityLiving) { if (movingobjectposition.entity instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.world).getServer(); CraftServer server = this.world.getServer();
org.bukkit.entity.Entity shooter = (this.owner == null) ? null : this.owner.getBukkitEntity();
org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity(); 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; DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
int damage = 0; int damage = 0;
// TODO @see EntityArrow#162 // 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); server.getPluginManager().callEvent(event);
if (!event.isCancelled()) { 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
stick = !event.getBounce(); 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 { } else {
stick = movingobjectposition.entity.damageEntity(this.owner, 0); stick = movingobjectposition.entity.damageEntity(this.owner, 0);

Datei anzeigen

@ -4,6 +4,8 @@ import java.util.List;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.CraftServer; 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.EntityDamageByProjectileEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
@ -17,7 +19,7 @@ public class EntitySnowball extends Entity {
private int e = 0; private int e = 0;
private boolean f = false; private boolean f = false;
public int a = 0; public int a = 0;
private EntityLiving shooter; public EntityLiving shooter; // CraftBukkit private -> public
private int h; private int h;
private int i = 0; private int i = 0;
@ -151,23 +153,22 @@ public class EntitySnowball extends Entity {
if (movingobjectposition.entity != null) { if (movingobjectposition.entity != null) {
boolean stick; boolean stick;
if (movingobjectposition.entity instanceof EntityLiving) { if (movingobjectposition.entity instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.world).getServer(); CraftServer server = this.world.getServer();
org.bukkit.entity.Entity shooter = (this.shooter == null) ? null : this.shooter.getBukkitEntity();
org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity(); 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; DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
int damage = 0; int damage = 0;
// TODO @see EntityArrow#162 // 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); server.getPluginManager().callEvent(event);
this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle();
if (!event.isCancelled()) { 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
stick = !event.getBounce(); 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 { } else {
stick = movingobjectposition.entity.damageEntity(this.shooter, 0); stick = movingobjectposition.entity.damageEntity(this.shooter, 0);

Datei anzeigen

@ -248,7 +248,16 @@ public class EntityTrackerEntry {
return new Packet23VehicleSpawn(this.tracker, 61); return new Packet23VehicleSpawn(this.tracker, 61);
} else if (this.tracker instanceof EntityFireball) { } else if (this.tracker instanceof EntityFireball) {
EntityFireball entityfireball = (EntityFireball) this.tracker; 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.e = (int) (entityfireball.c * 8000.0D);
packet23vehiclespawn.f = (int) (entityfireball.d * 8000.0D); packet23vehiclespawn.f = (int) (entityfireball.d * 8000.0D);

Datei anzeigen

@ -1,13 +1,14 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import org.bukkit.entity.Arrow;
import net.minecraft.server.EntityArrow; import net.minecraft.server.EntityArrow;
import net.minecraft.server.EntityLiving;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
/** /**
* Represents an arrow. * Represents an arrow.
*
* @author sk89q
*/ */
public class CraftArrow extends CraftEntity implements Arrow { public class CraftArrow extends CraftEntity implements Arrow {
public CraftArrow(CraftServer server, EntityArrow entity) { public CraftArrow(CraftServer server, EntityArrow entity) {
@ -18,4 +19,19 @@ public class CraftArrow extends CraftEntity implements Arrow {
public String toString() { public String toString() {
return "CraftArrow"; 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;
}
}
} }

Datei anzeigen

@ -1,13 +1,14 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityEgg; import net.minecraft.server.EntityEgg;
import net.minecraft.server.EntityLiving;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Egg; import org.bukkit.entity.Egg;
import org.bukkit.entity.LivingEntity;
/** /**
* An egg. * An egg.
*
* @author sk89q
*/ */
public class CraftEgg extends CraftEntity implements Egg { public class CraftEgg extends CraftEntity implements Egg {
public CraftEgg(CraftServer server, EntityEgg entity) { public CraftEgg(CraftServer server, EntityEgg entity) {
@ -18,4 +19,19 @@ public class CraftEgg extends CraftEntity implements Egg {
public String toString() { public String toString() {
return "CraftEgg"; 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;
}
}
} }

Datei anzeigen

@ -1,9 +1,12 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityFireball; import net.minecraft.server.EntityFireball;
import net.minecraft.server.EntityLiving;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Fireball; import org.bukkit.entity.Fireball;
import org.bukkit.entity.LivingEntity;
import org.bukkit.util.Vector;
/** /**
* A Fireball. * A Fireball.
@ -33,4 +36,27 @@ public class CraftFireball extends CraftEntity implements Fireball {
public void setYield(float yield) { public void setYield(float yield) {
((EntityFireball) getHandle()).yield = 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());
}
} }

Datei anzeigen

@ -1,14 +1,14 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityFish; import net.minecraft.server.EntityFish;
import net.minecraft.server.EntityHuman;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Fish; import org.bukkit.entity.Fish;
import org.bukkit.entity.LivingEntity;
/** /**
* A Fish. * A Fish.
*
* @author Cogito
*/ */
public class CraftFish extends CraftEntity implements Fish { public class CraftFish extends CraftEntity implements Fish {
public CraftFish(CraftServer server, EntityFish entity) { public CraftFish(CraftServer server, EntityFish entity) {
@ -19,4 +19,20 @@ public class CraftFish extends CraftEntity implements Fish {
public String toString() { public String toString() {
return "CraftFish"; 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;
}
}
} }

Datei anzeigen

@ -1,13 +1,14 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityLiving;
import net.minecraft.server.EntitySnowball; import net.minecraft.server.EntitySnowball;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Snowball; import org.bukkit.entity.Snowball;
/** /**
* A snowball. * A snowball.
*
* @author sk89q
*/ */
public class CraftSnowball extends CraftEntity implements Snowball { public class CraftSnowball extends CraftEntity implements Snowball {
public CraftSnowball(CraftServer server, EntitySnowball entity) { public CraftSnowball(CraftServer server, EntitySnowball entity) {
@ -18,4 +19,18 @@ public class CraftSnowball extends CraftEntity implements Snowball {
public String toString() { public String toString() {
return "CraftSnowball"; 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;
}
}
} }