Archiviert
13
0

Added minecart classes and World.spawn*Minecart(). Minecart.getPassenger() is still a stub that needs to be implemented (due to of a need of a MC entity -> CraftBukkit entity lookup) and StorageMinecart.getInventory() is waiting on the implementation of inventory.

Dieser Commit ist enthalten in:
sk89q 2011-01-02 21:41:57 -08:00 committet von Dinnerbone
Ursprung ca47ccf674
Commit 9d68035410
5 geänderte Dateien mit 151 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,69 @@
package org.bukkit.craftbukkit;
import net.minecraft.server.EntityMinecart;
import org.bukkit.LivingEntity;
import org.bukkit.Minecart;
import org.bukkit.Vector;
/**
* A minecart.
*
* @author sk89q
*/
public class CraftMinecart extends CraftVehicle implements Minecart {
/**
* Stores the minecart type ID, which is used by Minecraft to differentiate
* minecart types. Here we use subclasses.
*/
public enum Type {
Minecart(0),
StorageMinecart(1),
PoweredMinecart(2);
private final int id;
private Type(int id) {
this.id = id;
}
public int getID() {
return id;
}
}
protected EntityMinecart minecart;
public CraftMinecart(CraftServer server, EntityMinecart entity) {
super(server, entity);
minecart = entity;
}
@Override
public Vector getVelocity() {
return new Vector(minecart.s, minecart.t, minecart.u);
}
public void setVelocity(Vector vel) {
minecart.s = vel.getX();
minecart.t = vel.getY();
minecart.u = vel.getZ();
}
public LivingEntity getPassenger() {
// @TODO: Implement
return null;
}
public boolean isEmpty() {
return minecart.j == null;
}
public void setDamage(int damage) {
minecart.a = damage;
}
public int getDamage() {
return minecart.a;
}
}

Datei anzeigen

@ -0,0 +1,17 @@
package org.bukkit.craftbukkit;
import net.minecraft.server.EntityMinecart;
import org.bukkit.PoweredMinecart;
/**
* A powered minecart.
*
* @author sk89q
*/
public class CraftPoweredMinecart extends CraftMinecart
implements PoweredMinecart {
public CraftPoweredMinecart(CraftServer server, EntityMinecart entity) {
super(server, entity);
}
}

Datei anzeigen

@ -0,0 +1,17 @@
package org.bukkit.craftbukkit;
import net.minecraft.server.EntityMinecart;
import org.bukkit.StorageMinecart;
/**
* A storage minecart.
*
* @author sk89q
*/
public class CraftStorageMinecart extends CraftMinecart
implements StorageMinecart {
public CraftStorageMinecart(CraftServer server, EntityMinecart entity) {
super(server, entity);
}
}

Datei anzeigen

@ -0,0 +1,16 @@
package org.bukkit.craftbukkit;
import net.minecraft.server.Entity;
import org.bukkit.Vehicle;
/**
* A vehicle.
*
* @author sk89q
*/
public abstract class CraftVehicle extends CraftEntity implements Vehicle {
public CraftVehicle(CraftServer server, Entity entity) {
super(server, entity);
}
}

Datei anzeigen

@ -3,15 +3,19 @@ package org.bukkit.craftbukkit;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.minecraft.server.EntityMinecart;
import java.util.Random; import java.util.Random;
import net.minecraft.server.WorldGenBigTree; import net.minecraft.server.WorldGenBigTree;
import net.minecraft.server.WorldGenTrees;
import net.minecraft.server.WorldServer; import net.minecraft.server.WorldServer;
import net.minecraft.server.EntityArrow; import net.minecraft.server.EntityArrow;
import org.bukkit.Arrow; import org.bukkit.Arrow;
import org.bukkit.Block; import org.bukkit.Block;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Minecart;
import org.bukkit.PoweredMinecart;
import org.bukkit.StorageMinecart;
import org.bukkit.Vector; import org.bukkit.Vector;
import org.bukkit.World; import org.bukkit.World;
@ -88,6 +92,33 @@ public class CraftWorld implements World {
return new CraftArrow(world.getServer(), arrow); return new CraftArrow(world.getServer(), arrow);
} }
public Minecart spawnMinecart(Location loc) {
EntityMinecart minecart = new EntityMinecart(
world,
loc.getX(), loc.getY(), loc.getZ(),
CraftMinecart.Type.Minecart.getID());
world.a(minecart);
return new CraftMinecart(world.getServer(), minecart);
}
public StorageMinecart spawnStorageMinecart(Location loc) {
EntityMinecart minecart = new EntityMinecart(
world,
loc.getX(), loc.getY(), loc.getZ(),
CraftMinecart.Type.StorageMinecart.getID());
world.a(minecart);
return new CraftStorageMinecart(world.getServer(), minecart);
}
public PoweredMinecart spawnPoweredMinecart(Location loc) {
EntityMinecart minecart = new EntityMinecart(
world,
loc.getX(), loc.getY(), loc.getZ(),
CraftMinecart.Type.PoweredMinecart.getID());
world.a(minecart);
return new CraftPoweredMinecart(world.getServer(), minecart);
}
public boolean generateTree(Location loc) { public boolean generateTree(Location loc) {
WorldGenTrees treeGen = new WorldGenTrees(); WorldGenTrees treeGen = new WorldGenTrees();
return treeGen.a(world, rand, return treeGen.a(world, rand,