Port to new mc-dev format.

By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
CraftBukkit/Spigot 2011-01-29 22:50:29 +01:00
parent 785e22677c
commit 6820f5de76
14 changed files with 84 additions and 106 deletions

View file

@ -26,7 +26,7 @@
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>minecraft-server</artifactId> <artifactId>minecraft-server</artifactId>
<version>1.2_01</version> <version>1.2_01_01</version>
<type>jar</type> <type>jar</type>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>

View file

@ -7,7 +7,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.minecraft.server.EntityPlayerMP; import net.minecraft.server.EntityPlayer;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.PropertyManager; import net.minecraft.server.PropertyManager;
import net.minecraft.server.ServerConfigurationManager; import net.minecraft.server.ServerConfigurationManager;
@ -70,7 +70,7 @@ public final class CraftServer implements Server {
} }
public Player[] getOnlinePlayers() { public Player[] getOnlinePlayers() {
List<EntityPlayerMP> online = server.b; List<EntityPlayer> online = server.b;
Player[] players = new Player[online.size()]; Player[] players = new Player[online.size()];
for (int i = 0; i < players.length; i++) { for (int i = 0; i < players.length; i++) {
@ -109,7 +109,7 @@ public final class CraftServer implements Server {
return players.length; return players.length;
} }
public Player getPlayer(final EntityPlayerMP entity) { public Player getPlayer(final EntityPlayer entity) {
return entity.a.getPlayer(); return entity.a.getPlayer();
} }

View file

@ -37,7 +37,7 @@ public class CraftWorld implements World {
CraftBlock block = blockCache.get(loc); CraftBlock block = blockCache.get(loc);
if (block == null) { if (block == null) {
block = new CraftBlock(this, x, y, z, world.a(x, y, z), (byte)world.b(x, y, z)); block = new CraftBlock(this, x, y, z, world.getTypeId(x, y, z), (byte)world.getData(x, y, z));
blockCache.put(loc, block); blockCache.put(loc, block);
} else { } else {
block.update(); block.update();
@ -47,7 +47,7 @@ public class CraftWorld implements World {
} }
public int getBlockTypeIdAt(int x, int y, int z) { public int getBlockTypeIdAt(int x, int y, int z) {
return world.a(x, y, z); return world.getTypeId(x, y, z);
} }
public int getHighestBlockYAt(int x, int z) { public int getHighestBlockYAt(int x, int z) {
@ -55,7 +55,7 @@ public class CraftWorld implements World {
} }
public Location getSpawnLocation() { public Location getSpawnLocation() {
return new Location(this, world.m, world.e(world.m, world.o), world.o); return new Location(this, world.spawnX, world.e(world.spawnX, world.spawnZ), world.spawnZ);
} }
public Chunk getChunkAt(int x, int z) { public Chunk getChunkAt(int x, int z) {
@ -86,8 +86,8 @@ public class CraftWorld implements World {
public Block updateBlock(int x, int y, int z) { public Block updateBlock(int x, int y, int z) {
BlockCoordinate loc = new BlockCoordinate(x, y, z); BlockCoordinate loc = new BlockCoordinate(x, y, z);
CraftBlock block = (CraftBlock)blockCache.get(loc); CraftBlock block = (CraftBlock)blockCache.get(loc);
final int type = world.a(x, y, z); final int type = world.getTypeId(x, y, z);
final byte data = (byte)world.b(x, y, z); final byte data = (byte)world.getData(x, y, z);
if (block == null) { if (block == null) {
block = new CraftBlock(this, x, y, z, type, data); block = new CraftBlock(this, x, y, z, type, data);
@ -202,31 +202,8 @@ public class CraftWorld implements World {
return treeGen.a(world, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); return treeGen.a(world, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
} }
/**@deprecated*/
public CraftEntity toCraftEntity(net.minecraft.server.Entity entity) {
if (entity instanceof CraftMappable) {
return ((CraftMappable)entity).getCraftEntity();
} else if (entity instanceof EntityItem) {
return new CraftItemDrop(world.getServer(), (EntityItem)entity);
} else if (entity instanceof EntityArrow) {
return new CraftArrow(world.getServer(), (EntityArrow)entity);
} else if (entity instanceof EntityEgg) {
return new CraftEgg(world.getServer(), (EntityEgg)entity);
} else if (entity instanceof EntityPlayerMP) {
return new CraftPlayer(world.getServer(), (EntityPlayerMP)entity);
} else if (entity instanceof EntitySnowball) {
return new CraftSnowball(world.getServer(), (EntitySnowball)entity);
} else if (entity instanceof EntityPlayer) {
return new CraftHumanEntity(world.getServer(), (EntityPlayer)entity);
} else if (entity instanceof EntityLiving) {
return new CraftLivingEntity(world.getServer(), (EntityLiving)entity);
} else {
return null;
}
}
public TileEntity getTileEntityAt(final int x, final int y, final int z) { public TileEntity getTileEntityAt(final int x, final int y, final int z) {
return world.m(x, y, z); return world.getTileEntity(x, y, z);
} }
public String getName() { public String getName() {

View file

@ -5,7 +5,8 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.Location; import org.bukkit.Location;
import net.minecraft.server.MobSpawnerBase;
import net.minecraft.server.BiomeBase;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.CraftChunk; import org.bukkit.craftbukkit.CraftChunk;
@ -306,31 +307,31 @@ public class CraftBlock implements Block {
public Biome getBiome() { public Biome getBiome() {
// TODO: This may not be 100% accurate; investigate into getting per-block instead of per-chunk // TODO: This may not be 100% accurate; investigate into getting per-block instead of per-chunk
MobSpawnerBase base = world.getHandle().a().a(chunk.getX(), chunk.getZ()); BiomeBase base = world.getHandle().a().a(chunk.getX(), chunk.getZ());
if (base == MobSpawnerBase.a) { if (base == BiomeBase.RAINFOREST) {
return Biome.RAINFOREST; return Biome.RAINFOREST;
} else if (base == MobSpawnerBase.b) { } else if (base == BiomeBase.SWAMPLAND) {
return Biome.SWAMPLAND; return Biome.SWAMPLAND;
} else if (base == MobSpawnerBase.c) { } else if (base == BiomeBase.SEASONAL_FOREST) {
return Biome.SEASONAL_FOREST; return Biome.SEASONAL_FOREST;
} else if (base == MobSpawnerBase.d) { } else if (base == BiomeBase.FOREST) {
return Biome.FOREST; return Biome.FOREST;
} else if (base == MobSpawnerBase.e) { } else if (base == BiomeBase.SAVANNA) {
return Biome.SAVANNA; return Biome.SAVANNA;
} else if (base == MobSpawnerBase.f) { } else if (base == BiomeBase.SHRUBLAND) {
return Biome.SHRUBLAND; return Biome.SHRUBLAND;
} else if (base == MobSpawnerBase.g) { } else if (base == BiomeBase.TAIGA) {
return Biome.TAIGA; return Biome.TAIGA;
} else if (base == MobSpawnerBase.h) { } else if (base == BiomeBase.DESERT) {
return Biome.DESERT; return Biome.DESERT;
} else if (base == MobSpawnerBase.i) { } else if (base == BiomeBase.PLAINS) {
return Biome.PLAINS; return Biome.PLAINS;
} else if (base == MobSpawnerBase.j) { } else if (base == BiomeBase.ICE_DESERT) {
return Biome.ICE_DESERT; return Biome.ICE_DESERT;
} else if (base == MobSpawnerBase.k) { } else if (base == BiomeBase.TUNDRA) {
return Biome.TUNDRA; return Biome.TUNDRA;
} else if (base == MobSpawnerBase.l) { } else if (base == BiomeBase.HELL) {
return Biome.HELL; return Biome.HELL;
} }
@ -346,8 +347,8 @@ public class CraftBlock implements Block {
} }
public void update() { public void update() {
type = world.getHandle().a(x, y, z); type = world.getHandle().getTypeId(x, y, z);
data = (byte)world.getHandle().b(x, y, z); data = (byte)world.getHandle().getData(x, y, z);
light = (byte)world.getHandle().j(x, y, z); light = (byte)world.getHandle().j(x, y, z);
} }
} }

View file

@ -1,12 +1,12 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityAnimals; import net.minecraft.server.EntityAnimal;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Animals; import org.bukkit.entity.Animals;
public class CraftAnimals extends CraftCreature implements Animals{ public class CraftAnimals extends CraftCreature implements Animals{
public CraftAnimals(CraftServer server, EntityAnimals entity) { public CraftAnimals(CraftServer server, EntityAnimal entity) {
super(server, entity); super(server, entity);
} }

View file

@ -17,21 +17,21 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
} }
public Location getLocation() { public Location getLocation() {
return new Location(getWorld(), entity.p, entity.q, entity.r, entity.v, entity.w); return new Location(getWorld(), entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch);
} }
public Vector getVelocity() { public Vector getVelocity() {
return new Vector(entity.s, entity.t, entity.u); return new Vector(entity.motX, entity.motY, entity.motZ);
} }
public void setVelocity(Vector vel) { public void setVelocity(Vector vel) {
entity.s = vel.getX(); entity.motX = vel.getX();
entity.t = vel.getY(); entity.motY = vel.getY();
entity.u = vel.getZ(); entity.motZ = vel.getZ();
} }
public World getWorld() { public World getWorld() {
return ((WorldServer)entity.l).getWorld(); return ((WorldServer)entity.world).getWorld();
} }
public void teleportTo(Location location) { public void teleportTo(Location location) {
@ -43,7 +43,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
} }
public int getEntityId() { public int getEntityId() {
return entity.g; return entity.id;
} }
public Entity getHandle() { public Entity getHandle() {

View file

@ -1,13 +1,13 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityZombieSimple; import net.minecraft.server.EntityGiantZombie;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Giant; import org.bukkit.entity.Giant;
public class CraftGiant extends CraftMonster implements Giant { public class CraftGiant extends CraftMonster implements Giant {
public CraftGiant(CraftServer server, EntityZombieSimple entity) { public CraftGiant(CraftServer server, EntityGiantZombie entity) {
super(server, entity); super(server, entity);
} }

View file

@ -1,7 +1,7 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityPlayer; import net.minecraft.server.EntityHuman;
import org.bukkit.entity.HumanEntity; import org.bukkit.entity.HumanEntity;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
@ -10,28 +10,28 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
private EntityPlayer entity; private EntityHuman entity;
private CraftInventoryPlayer inventory; private CraftInventoryPlayer inventory;
public CraftHumanEntity(final CraftServer server, final EntityPlayer entity) { public CraftHumanEntity(final CraftServer server, final EntityHuman entity) {
super(server, entity); super(server, entity);
this.entity = entity; this.entity = entity;
this.inventory = new CraftInventoryPlayer( entity.an ); this.inventory = new CraftInventoryPlayer( entity.inventory );
} }
public String getName() { public String getName() {
return entity.aw; return entity.name;
} }
@Override @Override
public EntityPlayer getHandle() { public EntityHuman getHandle() {
return entity; return entity;
} }
public void setHandle(final EntityPlayer entity) { public void setHandle(final EntityHuman entity) {
super.setHandle((EntityPlayer)entity); super.setHandle((EntityHuman)entity);
this.entity = entity; this.entity = entity;
this.inventory = new CraftInventoryPlayer( entity.an ); this.inventory = new CraftInventoryPlayer( entity.inventory );
} }
public CraftInventoryPlayer getInventory() { public CraftInventoryPlayer getInventory() {

View file

@ -24,7 +24,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
} }
public int getHealth() { public int getHealth() {
return entity.aZ; return entity.health;
} }
public void setHealth(int health) { public void setHealth(int health) {
@ -32,7 +32,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
throw new IllegalArgumentException("Health must be between 0 and 200"); throw new IllegalArgumentException("Health must be between 0 and 200");
} }
entity.aZ = health; entity.health = health;
} }
@Override @Override
@ -72,11 +72,11 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
} }
public boolean isInsideVehicle() { public boolean isInsideVehicle() {
return entity.k != null; return entity.vehicle != null;
} }
public boolean leaveVehicle() { public boolean leaveVehicle() {
if (entity.k == null) { if (entity.vehicle == null) {
return false; return false;
} }
@ -85,13 +85,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
} }
public Vehicle getVehicle() { public Vehicle getVehicle() {
if (entity.k == null) { if (entity.vehicle == null) {
return null; return null;
} }
org.bukkit.entity.Entity vehicle = (entity.k.getBukkitEntity()); org.bukkit.entity.Entity vehicle = (entity.vehicle.getBukkitEntity());
if (vehicle instanceof Vehicle) { if (vehicle instanceof Vehicle) {
return (Vehicle)vehicle; return (Vehicle) vehicle;
} }
return null; return null;

View file

@ -1,13 +1,13 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityMobs; import net.minecraft.server.EntityMonster;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Monster; import org.bukkit.entity.Monster;
public class CraftMonster extends CraftCreature implements Monster { public class CraftMonster extends CraftCreature implements Monster {
public CraftMonster(CraftServer server, EntityMobs entity) { public CraftMonster(CraftServer server, EntityMonster entity) {
super(server, entity); super(server, entity);
} }

View file

@ -2,8 +2,8 @@ package org.bukkit.craftbukkit.entity;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.SocketAddress; import java.net.SocketAddress;
import net.minecraft.server.EntityHuman;
import net.minecraft.server.EntityPlayer; import net.minecraft.server.EntityPlayer;
import net.minecraft.server.EntityPlayerMP;
import net.minecraft.server.Packet; import net.minecraft.server.Packet;
import net.minecraft.server.Packet3Chat; import net.minecraft.server.Packet3Chat;
import net.minecraft.server.Packet6SpawnPosition; import net.minecraft.server.Packet6SpawnPosition;
@ -12,10 +12,10 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class CraftPlayer extends CraftHumanEntity implements Player { public class CraftPlayer extends CraftHumanEntity implements Player {
private EntityPlayerMP entity; private EntityPlayer entity;
private String name; private String name;
public CraftPlayer(CraftServer server, EntityPlayerMP entity) { public CraftPlayer(CraftServer server, EntityPlayer entity) {
super(server, entity); super(server, entity);
this.name = getName(); this.name = getName();
this.entity = entity; this.entity = entity;
@ -31,8 +31,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public boolean isOnline() { public boolean isOnline() {
for (Object obj: server.getHandle().b) { for (Object obj: server.getHandle().b) {
EntityPlayerMP player = (EntityPlayerMP) obj; EntityPlayer player = (EntityPlayer) obj;
if (player.aw.equalsIgnoreCase(getName())) { if (player.name.equalsIgnoreCase(getName())) {
return true; return true;
} }
} }
@ -49,12 +49,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
@Override @Override
public EntityPlayerMP getHandle() { public EntityPlayer getHandle() {
return entity; return entity;
} }
public void setHandle(final EntityPlayerMP entity) { public void setHandle(final EntityPlayer entity) {
super.setHandle((EntityPlayer) entity); super.setHandle((EntityHuman) entity);
this.entity = entity; this.entity = entity;
} }

View file

@ -15,7 +15,7 @@ public abstract class CraftVehicle extends CraftEntity implements Vehicle {
} }
public Entity getPassenger() { public Entity getPassenger() {
return isEmpty()?null:(getHandle().j.getBukkitEntity()); return isEmpty() ? null : (getHandle().passenger.getBukkitEntity());
} }
public boolean setPassenger(Entity passenger) { public boolean setPassenger(Entity passenger) {
@ -28,15 +28,15 @@ public abstract class CraftVehicle extends CraftEntity implements Vehicle {
} }
public boolean isEmpty() { public boolean isEmpty() {
return getHandle().j == null; return getHandle().passenger == null;
} }
public boolean eject() { public boolean eject() {
if (getHandle().j == null) { if (getHandle().passenger == null) {
return false; return false;
} }
getHandle().j.setPassengerOf(null); getHandle().passenger.setPassengerOf(null);
return true; return true;
} }
} }

View file

@ -1,13 +1,13 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityWaterMob; import net.minecraft.server.EntityWaterAnimal;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.WaterMob; import org.bukkit.entity.WaterMob;
public class CraftWaterMob extends CraftCreature implements WaterMob { public class CraftWaterMob extends CraftCreature implements WaterMob {
public CraftWaterMob(CraftServer server, EntityWaterMob entity) { public CraftWaterMob(CraftServer server, EntityWaterAnimal entity) {
super(server, entity); super(server, entity);
} }

View file

@ -8,9 +8,9 @@ public class CraftItemStack extends ItemStack {
public CraftItemStack(net.minecraft.server.ItemStack item) { public CraftItemStack(net.minecraft.server.ItemStack item) {
super( super(
item != null ? item.c : 0, item != null ? item.id: 0,
item != null ? item.a : 0, item != null ? item.count : 0,
(byte)(item != null ? item.d : 0) (byte)(item != null ? item.damage : 0)
); );
this.item = item; this.item = item;
} }
@ -55,14 +55,14 @@ public class CraftItemStack extends ItemStack {
@Override @Override
public Material getType() { public Material getType() {
super.setTypeId(item != null ? item.c : 0); // sync, needed? super.setTypeId(item != null ? item.id : 0); // sync, needed?
return super.getType(); return super.getType();
} }
@Override @Override
public int getTypeId() { public int getTypeId() {
super.setTypeId(item != null ? item.c : 0); // sync, needed? super.setTypeId(item != null ? item.id : 0); // sync, needed?
return item != null ? item.c : 0; return item != null ? item.id : 0;
} }
@Override @Override
@ -76,16 +76,16 @@ public class CraftItemStack extends ItemStack {
item = new net.minecraft.server.ItemStack(type, 1, 0); item = new net.minecraft.server.ItemStack(type, 1, 0);
super.setAmount(1); super.setAmount(1);
} else { } else {
item.c = type; item.id = type;
super.setTypeId(item.c); super.setTypeId(item.id);
} }
} }
} }
@Override @Override
public int getAmount() { public int getAmount() {
super.setAmount(item != null ? item.a : 0); // sync, needed? super.setAmount(item != null ? item.count : 0); // sync, needed?
return (item != null ? item.a : 0); return (item != null ? item.count : 0);
} }
@Override @Override
@ -96,7 +96,7 @@ public class CraftItemStack extends ItemStack {
item = null; item = null;
} else { } else {
super.setAmount(amount); super.setAmount(amount);
item.a = amount; item.count = amount;
} }
} }
@ -105,15 +105,15 @@ public class CraftItemStack extends ItemStack {
// Ignore damage if item is null // Ignore damage if item is null
if (item != null) { if (item != null) {
super.setDamage(damage); super.setDamage(damage);
item.d = damage; item.damage = damage;
} }
} }
@Override @Override
public byte getDamage() { public byte getDamage() {
if (item != null) { if (item != null) {
super.setDamage((byte) item.d); // sync, needed? super.setDamage((byte) item.damage); // sync, needed?
return (byte) item.d; return (byte) item.damage;
} else { } else {
return 0; return 0;
} }