mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 23:10:16 +01:00
Merge remote branch 'upstream/master'
By: durron597 <martin.jared@gmail.com>
This commit is contained in:
commit
87883daeb5
12 changed files with 243 additions and 27 deletions
|
@ -0,0 +1,15 @@
|
|||
package org.bukkit.craftbukkit;
|
||||
|
||||
import org.bukkit.Arrow;
|
||||
import net.minecraft.server.EntityArrow;
|
||||
|
||||
/**
|
||||
* Represents an arrow.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class CraftArrow extends CraftEntity implements Arrow {
|
||||
CraftArrow(CraftServer server, EntityArrow entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package org.bukkit.craftbukkit;
|
||||
|
||||
import org.bukkit.ArrowEntity;
|
||||
import net.minecraft.server.EntityArrow;
|
||||
|
||||
/**
|
||||
* Represents an arrow.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class CraftArrowEntity extends CraftEntity implements ArrowEntity {
|
||||
CraftArrowEntity(CraftServer server, EntityArrow entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package org.bukkit.craftbukkit;
|
||||
|
||||
import net.minecraft.server.EntityEgg;
|
||||
import org.bukkit.Egg;
|
||||
|
||||
/**
|
||||
* An egg.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class CraftEgg extends CraftEntity implements Egg {
|
||||
public CraftEgg(CraftServer server, EntityEgg ent) {
|
||||
super(server, ent);
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import net.minecraft.server.WorldServer;
|
|||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class CraftEntity implements org.bukkit.Entity {
|
||||
public abstract class CraftEntity implements org.bukkit.Entity {
|
||||
protected final CraftServer server;
|
||||
private Entity entity;
|
||||
|
||||
|
|
|
@ -2,8 +2,13 @@
|
|||
package org.bukkit.craftbukkit;
|
||||
|
||||
import net.minecraft.server.Entity;
|
||||
import net.minecraft.server.EntityEgg;
|
||||
import net.minecraft.server.EntityLiving;
|
||||
import net.minecraft.server.EntitySnowball;
|
||||
|
||||
import org.bukkit.Egg;
|
||||
import org.bukkit.LivingEntity;
|
||||
import org.bukkit.Snowball;
|
||||
|
||||
public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
private EntityLiving entity;
|
||||
|
@ -39,4 +44,18 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||
public String toString() {
|
||||
return "CraftLivingEntity{" + "id=" + getEntityID() + '}';
|
||||
}
|
||||
|
||||
public Egg throwEgg() {
|
||||
net.minecraft.server.World world = ((CraftWorld)getWorld()).getHandle();
|
||||
EntityEgg egg = new EntityEgg(world, entity);
|
||||
world.a(egg);
|
||||
return new CraftEgg(server, egg);
|
||||
}
|
||||
|
||||
public Snowball throwSnowball() {
|
||||
net.minecraft.server.World world = ((CraftWorld)getWorld()).getHandle();
|
||||
EntitySnowball snowball = new EntitySnowball(world, entity);
|
||||
world.a(snowball);
|
||||
return new CraftSnowball(server, snowball);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function to convert an MC entity to an appropriate CraftBukkit
|
||||
* entity.
|
||||
*
|
||||
* @param server
|
||||
* @param minecart
|
||||
* @return
|
||||
*/
|
||||
public static CraftMinecart getCraftMinecart(CraftServer server,
|
||||
EntityMinecart minecart) {
|
||||
if (minecart.d == Type.StorageMinecart.getID()) {
|
||||
return new CraftStorageMinecart(server, minecart);
|
||||
} else if (minecart.d == Type.PoweredMinecart.getID()) {
|
||||
return new CraftPoweredMinecart(server, minecart);
|
||||
} else {
|
||||
return new CraftMinecart(server, minecart);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -15,17 +15,15 @@ import org.bukkit.plugin.java.JavaPluginLoader;
|
|||
|
||||
public final class CraftServer implements Server {
|
||||
private final String serverName = "Craftbukkit";
|
||||
private final String serverVersion;
|
||||
private final String serverVersion = "1.1";
|
||||
private final PluginManager pluginManager = new SimplePluginManager(this);
|
||||
|
||||
protected final MinecraftServer console;
|
||||
protected final ServerConfigurationManager server;
|
||||
|
||||
public CraftServer(MinecraftServer instance, String ver) {
|
||||
serverVersion = ver;
|
||||
|
||||
console = instance;
|
||||
server = console.f;
|
||||
public CraftServer(MinecraftServer console, ServerConfigurationManager server) {
|
||||
this.console = console;
|
||||
this.server = server;
|
||||
|
||||
pluginManager.RegisterInterface(JavaPluginLoader.class);
|
||||
|
||||
|
@ -55,7 +53,7 @@ public final class CraftServer implements Server {
|
|||
}
|
||||
|
||||
public Player[] getOnlinePlayers() {
|
||||
List<EntityPlayerMP> online = server.b;
|
||||
List<EntityPlayerMP> online = server.b;
|
||||
Player[] players = new Player[online.size()];
|
||||
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package org.bukkit.craftbukkit;
|
||||
|
||||
import net.minecraft.server.EntitySnowball;
|
||||
import org.bukkit.Snowball;
|
||||
|
||||
/**
|
||||
* A snowball.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class CraftSnowball extends CraftEntity implements Snowball {
|
||||
public CraftSnowball(CraftServer server, EntitySnowball ent) {
|
||||
super(server, ent);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -3,15 +3,20 @@ package org.bukkit.craftbukkit;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.server.EntityMinecart;
|
||||
import java.util.Random;
|
||||
import net.minecraft.server.WorldGenBigTree;
|
||||
import net.minecraft.server.WorldGenTrees;
|
||||
import net.minecraft.server.WorldServer;
|
||||
import net.minecraft.server.EntityArrow;
|
||||
import org.bukkit.ArrowEntity;
|
||||
import net.minecraft.server.WorldGenTrees;
|
||||
import org.bukkit.Arrow;
|
||||
import org.bukkit.Block;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Minecart;
|
||||
import org.bukkit.PoweredMinecart;
|
||||
import org.bukkit.StorageMinecart;
|
||||
import org.bukkit.Vector;
|
||||
import org.bukkit.World;
|
||||
|
||||
|
@ -79,13 +84,40 @@ public class CraftWorld implements World {
|
|||
return world;
|
||||
}
|
||||
|
||||
public ArrowEntity spawnArrow(Location loc, Vector velocity, float speed,
|
||||
public Arrow spawnArrow(Location loc, Vector velocity, float speed,
|
||||
float spread) {
|
||||
EntityArrow arrow = new EntityArrow(world);
|
||||
arrow.c(loc.getX(), loc.getY(), loc.getZ());
|
||||
world.a(arrow);
|
||||
arrow.a(velocity.getX(), velocity.getY(), velocity.getZ(), speed, spread);
|
||||
return new CraftArrowEntity(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) {
|
||||
|
|
Loading…
Reference in a new issue