Archiviert
13
0

Added passenger methods to Vehicle/LivingEntity.

Dieser Commit ist enthalten in:
sk89q 2011-01-07 16:26:08 -08:00
Ursprung e968096fc7
Commit c9efe94545
4 geänderte Dateien mit 50 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -829,7 +829,10 @@ public abstract class Entity {
return (double) J * 0.75D;
}
public void e(Entity entity) {
public void setPassengerOf(Entity entity) {
// e(null) doesn't really fly for overloaded methods,
// so this method is needed
d = 0.0D;
e = 0.0D;
if (entity == null) {
@ -856,6 +859,10 @@ public abstract class Entity {
entity.j = this;
}
public void e(Entity entity) {
setPassengerOf(entity);
}
public Vec3D C() {
return null;
}

Datei anzeigen

@ -5,6 +5,7 @@ import net.minecraft.server.Entity;
import net.minecraft.server.WorldServer;
import org.bukkit.Location;
import org.bukkit.Vector;
import org.bukkit.Vehicle;
import org.bukkit.World;
public abstract class CraftEntity implements org.bukkit.Entity {

Datei anzeigen

@ -11,6 +11,7 @@ import org.bukkit.Arrow;
import org.bukkit.Egg;
import org.bukkit.LivingEntity;
import org.bukkit.Snowball;
import org.bukkit.Vehicle;
public class CraftLivingEntity extends CraftEntity implements LivingEntity {
private EntityLiving entity;
@ -61,11 +62,36 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
return new CraftSnowball(server, snowball);
}
@Override
public Arrow shootArrow() {
net.minecraft.server.World world = ((CraftWorld)getWorld()).getHandle();
EntityArrow snowball = new EntityArrow(world, entity);
world.a(snowball);
return new CraftArrow(server, snowball);
}
public boolean isInsideVehicle() {
return entity.k != null;
}
public boolean leaveVehicle() {
if (entity.k == null) {
return false;
}
entity.setPassengerOf(null);
return true;
}
public Vehicle getVehicle() {
if (entity.k == null) {
return null;
}
org.bukkit.Entity vehicle = ((CraftWorld)getWorld()).toCraftEntity(entity.k);
if (vehicle instanceof Vehicle) {
return (Vehicle)vehicle;
}
return null;
}
}

Datei anzeigen

@ -18,7 +18,21 @@ public abstract class CraftVehicle extends CraftEntity implements Vehicle {
return ((CraftWorld)getWorld()).toCraftEntity(getHandle().j);
}
public boolean setPassenger(Entity passenger) {
((CraftEntity)passenger).getHandle().setPassengerOf(getHandle());
return true;
}
public boolean isEmpty() {
return getHandle().j == null;
}
public boolean eject() {
if (getHandle().j == null) {
return false;
}
getHandle().j.setPassengerOf(null);
return true;
}
}