Update for 1.0.0

By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
CraftBukkit/Spigot 2011-11-20 00:01:14 -08:00
parent f37f615a88
commit be5fc81d31
25 changed files with 384 additions and 106 deletions

View file

@ -4,7 +4,7 @@
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<packaging>jar</packaging>
<version>1.8.1-R5-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
<name>CraftBukkit</name>
<url>http://www.bukkit.org</url>
<properties>
@ -18,14 +18,14 @@
</scm>
<distributionManagement>
<repository>
<id>repobo-rel</id>
<name>repo.bukkit.org Releases</name>
<url>http://repo.bukkit.org/content/repositories/libs-release-local</url>
<id>repobo-rel</id>
<name>repo.bukkit.org Releases</name>
<url>http://repo.bukkit.org/content/repositories/libs-release-local</url>
</repository>
<snapshotRepository>
<id>repobo-snap</id>
<name>repo.bukkit.org Snapshots</name>
<url>http://repo.bukkit.org/content/repositories/libs-snapshot-local</url>
<id>repobo-snap</id>
<name>repo.bukkit.org Snapshots</name>
<url>http://repo.bukkit.org/content/repositories/libs-snapshot-local</url>
</snapshotRepository>
</distributionManagement>
<repositories>
@ -44,14 +44,14 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.8.1-R5-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>minecraft-server</artifactId>
<version>1.8.1_01</version>
<version>1.9.RC1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>

View file

@ -82,7 +82,6 @@ import org.yaml.snakeyaml.error.MarkedYAMLException;
public final class CraftServer implements Server {
private final String serverName = "Craftbukkit";
private final String serverVersion;
private final String protocolVersion = "1.8.1";
private final String bukkitVersion = Versioning.getBukkitVersion();
private final ServicesManager servicesManager = new SimpleServicesManager();
private final BukkitScheduler scheduler = new CraftScheduler(this);
@ -105,7 +104,7 @@ public final class CraftServer implements Server {
this.serverVersion = CraftServer.class.getPackage().getImplementationVersion();
Bukkit.setServer(this);
if (!Main.useConsole) {
getLogger().info("Console input is disabled due to --noconsole command argument");
}
@ -114,17 +113,17 @@ public final class CraftServer implements Server {
configuration.options().copyDefaults(true);
configuration.setDefaults(YamlConfiguration.loadConfiguration(getClass().getClassLoader().getResourceAsStream("configurations/bukkit.yml")));
saveConfig();
loadPlugins();
enablePlugins(PluginLoadOrder.STARTUP);
ChunkCompressionThread.startThread();
}
private File getConfigFile() {
return (File)console.options.valueOf("bukkit-settings");
}
private void saveConfig() {
try {
configuration.save(getConfigFile());
@ -195,9 +194,9 @@ public final class CraftServer implements Server {
}
public String getVersion() {
return serverVersion + " (MC: " + protocolVersion + ")";
return serverVersion + " (MC: " + console.getVersion() + ")";
}
public String getBukkitVersion() {
return bukkitVersion;
}
@ -471,7 +470,7 @@ public final class CraftServer implements Server {
@Override
public String toString() {
return "CraftServer{" + "serverName=" + serverName + ",serverVersion=" + serverVersion + ",protocolVersion=" + protocolVersion + '}';
return "CraftServer{" + "serverName=" + serverName + ",serverVersion=" + serverVersion + ",minecraftVersion=" + console.getVersion() + '}';
}
public World createWorld(String name, World.Environment environment) {
@ -519,7 +518,8 @@ public final class CraftServer implements Server {
}
int dimension = 10 + console.worlds.size();
WorldServer internal = new WorldServer(console, new ServerNBTManager(getWorldContainer(), name, true), name, dimension, new WorldSettings(creator.seed(), getDefaultGameMode().getValue(), true), creator.environment(), generator);
boolean hardcore = false;
WorldServer internal = new WorldServer(console, new ServerNBTManager(getWorldContainer(), name, true), name, dimension, new WorldSettings(creator.seed(), getDefaultGameMode().getValue(), true, hardcore), creator.environment(), generator);
if (!(worlds.containsKey(name.toLowerCase()))) {
return null;
@ -908,7 +908,7 @@ public final class CraftServer implements Server {
}
}
}
public File getWorldContainer() {
return new File(configuration.getString("settings.world-container", "."));
}

View file

@ -353,16 +353,16 @@ public class CraftWorld implements World {
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
switch (type) {
case BIG_TREE:
return new WorldGenBigTree().generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
return new WorldGenBigTree(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
case BIRCH:
return new WorldGenForest().generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
return new WorldGenForest(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
case REDWOOD:
return new WorldGenTaiga2().generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
return new WorldGenTaiga2(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
case TALL_REDWOOD:
return new WorldGenTaiga1().generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
case TREE:
default:
return new WorldGenTrees().generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
return new WorldGenTrees(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
}
}
@ -677,8 +677,12 @@ public class CraftWorld implements World {
}
}
@SuppressWarnings("unchecked")
public <T extends Entity> T spawn(Location location, Class<T> clazz) throws IllegalArgumentException {
return spawn(location, clazz, SpawnReason.CUSTOM);
}
@SuppressWarnings("unchecked")
public <T extends Entity> T spawn(Location location, Class<T> clazz, SpawnReason reason) throws IllegalArgumentException {
if (location == null || clazz == null) {
throw new IllegalArgumentException("Location or entity class cannot be null");
}
@ -694,19 +698,26 @@ public class CraftWorld implements World {
// order is important for some of these
if (Boat.class.isAssignableFrom(clazz)) {
entity = new EntityBoat(world, x, y, z);
} else if (Egg.class.isAssignableFrom(clazz)) {
entity = new EntityEgg(world, x, y, z);
} else if (FallingSand.class.isAssignableFrom(clazz)) {
entity = new EntityFallingSand(world, x, y, z, 0, 0);
} else if (Fireball.class.isAssignableFrom(clazz)) {
entity = new EntityFireball(world);
if (SmallFireball.class.isAssignableFrom(clazz)) {
entity = new EntitySmallFireball(world);
} else {
entity = new EntityFireball(world);
}
((EntityFireball) entity).setPositionRotation(x, y, z, yaw, pitch);
Vector direction = location.getDirection().multiply(10);
((EntityFireball) entity).setDirection(direction.getX(), direction.getY(), direction.getZ());
} else if (Snowball.class.isAssignableFrom(clazz)) {
entity = new EntitySnowball(world, x, y, z);
} else if (Projectile.class.isAssignableFrom(clazz)) {
if (Snowball.class.isAssignableFrom(clazz)) {
entity = new EntitySnowball(world, x, y, z);
} else if (Egg.class.isAssignableFrom(clazz)) {
entity = new EntityEgg(world, x, y, z);
} else if (EnderPearl.class.isAssignableFrom(clazz)) {
entity = new EntityEnderPearl(world, x, y, z);
}
} else if (Minecart.class.isAssignableFrom(clazz)) {
if (PoweredMinecart.class.isAssignableFrom(clazz)) {
entity = new EntityMinecart(world, x, y, z, CraftMinecart.Type.PoweredMinecart.getId());
} else if (StorageMinecart.class.isAssignableFrom(clazz)) {
@ -714,16 +725,22 @@ public class CraftWorld implements World {
} else {
entity = new EntityMinecart(world, x, y, z, CraftMinecart.Type.Minecart.getId());
}
} else if (Arrow.class.isAssignableFrom(clazz)) {
entity = new EntityArrow(world);
entity.setPositionRotation(x, y, z, 0, 0);
} else if (EnderSignal.class.isAssignableFrom(clazz)) {
entity = new EntityEnderSignal(world, x, y, z);
} else if (LivingEntity.class.isAssignableFrom(clazz)) {
if (Chicken.class.isAssignableFrom(clazz)) {
entity = new EntityChicken(world);
} else if (Cow.class.isAssignableFrom(clazz)) {
entity = new EntityCow(world);
if (MushroomCow.class.isAssignableFrom(clazz)) {
entity = new EntityMushroomCow(world);
} else {
entity = new EntityCow(world);
}
} else if (Snowman.class.isAssignableFrom(clazz)) {
entity = new EntitySnowman(world);
} else if (Creeper.class.isAssignableFrom(clazz)) {
entity = new EntityCreeper(world);
} else if (Ghast.class.isAssignableFrom(clazz)) {
@ -739,13 +756,11 @@ public class CraftWorld implements World {
} else if (Slime.class.isAssignableFrom(clazz)) {
entity = new EntitySlime(world);
} else if (Spider.class.isAssignableFrom(clazz)) {
if (CaveSpider.class.isAssignableFrom(clazz)) {
entity = new EntityCaveSpider(world);
} else {
entity = new EntitySpider(world);
}
} else if (Squid.class.isAssignableFrom(clazz)) {
entity = new EntitySquid(world);
} else if (Wolf.class.isAssignableFrom(clazz)) {
@ -758,12 +773,19 @@ public class CraftWorld implements World {
entity = new EntitySilverfish(world);
} else if (Enderman.class.isAssignableFrom(clazz)) {
entity = new EntityEnderman(world);
} else if (Blaze.class.isAssignableFrom(clazz)) {
entity = new EntityBlaze(world);
} else if (Villager.class.isAssignableFrom(clazz)) {
entity = new EntityVillager(world);
} else if (ComplexLivingEntity.class.isAssignableFrom(clazz)) {
if (EnderDragon.class.isAssignableFrom(clazz)) {
entity = new EntityEnderDragon(world);
}
}
if (entity != null) {
entity.setLocation(x, y, z, pitch, yaw);
}
} else if (Painting.class.isAssignableFrom(clazz)) {
Block block = getBlockAt(location);
BlockFace face = BlockFace.SELF;
@ -778,22 +800,22 @@ public class CraftWorld implements World {
}
int dir;
switch(face) {
case EAST:
default:
dir = 0;
break;
case NORTH:
dir = 1;
break;
case WEST:
dir = 2;
break;
case SOUTH:
dir = 3;;
break;
case EAST:
default:
dir = 0;
break;
case NORTH:
dir = 1;
break;
case WEST:
dir = 2;
break;
case SOUTH:
dir = 3;;
break;
}
entity = new EntityPainting(world, (int) x, (int) y, (int) z, dir);
if (!((EntityPainting)entity).i()) {
if (!((EntityPainting) entity).j()) {
entity = null;
}
} else if (TNTPrimed.class.isAssignableFrom(clazz)) {
@ -812,7 +834,7 @@ public class CraftWorld implements World {
}
if (entity != null) {
world.addEntity(entity);
world.addEntity(entity, reason);
return (T) entity.getBukkitEntity();
}

View file

@ -0,0 +1,11 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityMonster;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Blaze;
public class CraftBlaze extends CraftMonster implements Blaze {
public CraftBlaze(CraftServer server, EntityMonster entity) {
super(server, entity);
}
}

View file

@ -0,0 +1,17 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityComplex;
import net.minecraft.server.EntityLiving;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.ComplexLivingEntity;
public abstract class CraftComplexLivingEntity extends CraftLivingEntity implements ComplexLivingEntity {
public CraftComplexLivingEntity(CraftServer server, EntityLiving entity) {
super(server, entity);
}
@Override
public EntityComplex getHandle() {
return (EntityComplex)super.getHandle();
}
}

View file

@ -0,0 +1,22 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.Entity;
import net.minecraft.server.EntityComplexPart;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.ComplexEntityPart;
import org.bukkit.entity.ComplexLivingEntity;
public class CraftComplexPart extends CraftEntity implements ComplexEntityPart {
public CraftComplexPart(CraftServer server, Entity entity) {
super(server, entity);
}
public ComplexLivingEntity getParent() {
return (ComplexLivingEntity)getHandle().a.getBukkitEntity();
}
@Override
public EntityComplexPart getHandle() {
return (EntityComplexPart)super.getHandle();
}
}

View file

@ -1,14 +1,10 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityEgg;
import net.minecraft.server.EntityLiving;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Egg;
import org.bukkit.entity.LivingEntity;
public class CraftEgg extends AbstractProjectile implements Egg {
public class CraftEgg extends CraftProjectile implements Egg {
public CraftEgg(CraftServer server, EntityEgg entity) {
super(server, entity);
}
@ -17,19 +13,4 @@ public class CraftEgg extends AbstractProjectile implements Egg {
public String toString() {
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;
}
}
}

View file

@ -0,0 +1,32 @@
package org.bukkit.craftbukkit.entity;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import java.util.Set;
import net.minecraft.server.EntityComplexPart;
import net.minecraft.server.EntityEnderDragon;
import net.minecraft.server.EntityLiving;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.ComplexEntityPart;
import org.bukkit.entity.EnderDragon;
public class CraftEnderDragon extends CraftComplexLivingEntity implements EnderDragon {
public CraftEnderDragon(CraftServer server, EntityLiving entity) {
super(server, entity);
}
public Set<ComplexEntityPart> getParts() {
Builder<ComplexEntityPart> builder = ImmutableSet.builder();
for (EntityComplexPart part : getHandle().f) {
builder.add((ComplexEntityPart)part.getBukkitEntity());
}
return builder.build();
}
@Override
public EntityEnderDragon getHandle() {
return (EntityEnderDragon)super.getHandle();
}
}

View file

@ -0,0 +1,17 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.Entity;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.EnderDragonPart;
public class CraftEnderDragonPart extends CraftComplexPart implements EnderDragonPart {
public CraftEnderDragonPart(CraftServer server, Entity entity) {
super(server, entity);
}
@Override
public EnderDragon getParent() {
return (EnderDragon)super.getParent();
}
}

View file

@ -0,0 +1,16 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.Entity;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EnderPearl;
public class CraftEnderPearl extends CraftProjectile implements EnderPearl {
public CraftEnderPearl(CraftServer server, Entity entity) {
super(server, entity);
}
@Override
public String toString() {
return "CraftEnderPearl";
}
}

View file

@ -0,0 +1,16 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.Entity;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EnderSignal;
public class CraftEnderSignal extends CraftEntity implements EnderSignal {
public CraftEnderSignal(CraftServer server, Entity entity) {
super(server, entity);
}
@Override
public String toString() {
return "CraftEnderSignal";
}
}

View file

@ -41,7 +41,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
// Animals
if (entity instanceof EntityAnimal) {
if (entity instanceof EntityChicken) { return new CraftChicken(server, (EntityChicken) entity); }
else if (entity instanceof EntityCow) { return new CraftCow(server, (EntityCow) entity); }
else if (entity instanceof EntityCow) {
if (entity instanceof EntityMushroomCow) { return new CraftMushroomCow(server, (EntityMushroomCow) entity); }
else { return new CraftCow(server, (EntityCow) entity); }
}
else if (entity instanceof EntityPig) { return new CraftPig(server, (EntityPig) entity); }
else if (entity instanceof EntityWolf) { return new CraftWolf(server, (EntityWolf) entity); }
else if (entity instanceof EntitySheep) { return new CraftSheep(server, (EntitySheep) entity); }
@ -58,6 +61,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
else if (entity instanceof EntitySilverfish) { return new CraftSilverfish(server, (EntitySilverfish) entity); }
else if (entity instanceof EntityGiantZombie) { return new CraftGiant(server, (EntityGiantZombie) entity); }
else if (entity instanceof EntitySkeleton) { return new CraftSkeleton(server, (EntitySkeleton) entity); }
else if (entity instanceof EntityBlaze) { return new CraftBlaze(server, (EntityBlaze) entity); }
else if (entity instanceof EntitySpider) {
if (entity instanceof EntityCaveSpider) { return new CraftCaveSpider(server, (EntityCaveSpider) entity); }
else { return new CraftSpider(server, (EntitySpider) entity); }
@ -70,6 +74,8 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
if (entity instanceof EntitySquid) { return new CraftSquid(server, (EntitySquid) entity); }
else { return new CraftWaterMob(server, (EntityWaterAnimal) entity); }
}
else if (entity instanceof EntitySnowman) { return new CraftSnowman(server, (EntityCreature) entity); }
else if (entity instanceof EntityVillager) { return new CraftVillager(server, (EntityVillager) entity); }
else { return new CraftCreature(server, (EntityCreature) entity); }
}
// Slimes are a special (and broken) case
@ -79,14 +85,31 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
if (entity instanceof EntityGhast) { return new CraftGhast(server, (EntityGhast) entity); }
else { return new CraftFlying(server, (EntityFlying) entity); }
}
else if (entity instanceof EntityComplex) {
if (entity instanceof EntityEnderDragon) { return new CraftEnderDragon(server, (EntityEnderDragon) entity); }
}
else { return new CraftLivingEntity(server, (EntityLiving) entity); }
}
else if (entity instanceof EntityComplexPart) {
EntityComplexPart part = (EntityComplexPart)entity;
if (part.a instanceof EntityEnderDragon) { return new CraftEnderDragonPart(server, (EntityComplexPart)entity); }
else { return new CraftComplexPart(server, (EntityComplexPart) entity); }
}
else if (entity instanceof EntityExperienceOrb) { return new CraftExperienceOrb(server, (EntityExperienceOrb) entity); }
else if (entity instanceof EntityArrow) { return new CraftArrow(server, (EntityArrow) entity); }
else if (entity instanceof EntityBoat) { return new CraftBoat(server, (EntityBoat) entity); }
else if (entity instanceof EntityEgg) { return new CraftEgg(server, (EntityEgg) entity); }
else if (entity instanceof EntityProjectile) {
if (entity instanceof EntityEgg) { return new CraftEgg(server, (EntityEgg) entity); }
else if (entity instanceof EntitySnowball) { return new CraftSnowball(server, (EntitySnowball) entity); }
else if (entity instanceof EntityPotion) { return new CraftThrownPotion(server, (EntityPotion) entity); }
else if (entity instanceof EntityEnderPearl) { return new CraftEnderPearl(server, (EntityEnderPearl) entity); }
}
else if (entity instanceof EntityFallingSand) { return new CraftFallingSand(server, (EntityFallingSand) entity); }
else if (entity instanceof EntityFireball) { return new CraftFireball(server, (EntityFireball) entity); }
else if (entity instanceof EntityFireball) {
if (entity instanceof EntitySmallFireball) { return new CraftSmallFireball(server, (EntitySmallFireball) entity); }
else { return new CraftFireball(server, (EntityFireball) entity); }
}
else if (entity instanceof EntityEnderSignal) { return new CraftEnderSignal(server, (EntityEnderSignal) entity); }
else if (entity instanceof EntityFishingHook) { return new CraftFish(server, (EntityFishingHook) entity); }
else if (entity instanceof EntityItem) { return new CraftItem(server, (EntityItem) entity); }
else if (entity instanceof EntityWeather) {
@ -107,9 +130,9 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}
}
else if (entity instanceof EntityPainting) { return new CraftPainting(server, (EntityPainting) entity); }
else if (entity instanceof EntitySnowball) { return new CraftSnowball(server, (EntitySnowball) entity); }
else if (entity instanceof EntityTNTPrimed) { return new CraftTNTPrimed(server, (EntityTNTPrimed) entity); }
else throw new IllegalArgumentException("Unknown entity");
throw new IllegalArgumentException("Unknown entity");
}
public Location getLocation() {

View file

@ -32,19 +32,23 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
}
public int getHealth() {
return getHandle().health;
return getHandle().getHealth();
}
public void setHealth(int health) {
if ((health < 0) || (health > 200)) {
throw new IllegalArgumentException("Health must be between 0 and 200");
if ((health < 0) || (health > getMaxHealth())) {
throw new IllegalArgumentException("Health must be between 0 and " + getMaxHealth());
}
if (entity instanceof EntityPlayer && health == 0) {
((EntityPlayer) entity).die(DamageSource.GENERIC);
}
getHandle().health = health;
getHandle().setHealth(health);
}
public int getMaxHealth() {
return getHandle().getMaxHealth();
}
@Override

View file

@ -34,11 +34,11 @@ public class CraftMinecart extends CraftVehicle implements Minecart {
}
public void setDamage(int damage) {
minecart.damage = damage;
minecart.setDamage(damage);
}
public int getDamage() {
return minecart.damage;
return minecart.getDamage();
}
public double getMaxSpeed() {

View file

@ -0,0 +1,11 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityCow;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.MushroomCow;
public class CraftMushroomCow extends CraftCow implements MushroomCow {
public CraftMushroomCow(CraftServer server, EntityCow entity) {
super(server, entity);
}
}

View file

@ -40,12 +40,12 @@ public class CraftPainting extends CraftEntity implements Painting {
}
public boolean setArt(Art art, boolean force) {
EntityPainting painting = getHandle();
EntityPainting painting = this.getHandle();
EnumArt oldArt = painting.e;
EnumArt newArt = CraftArt.BukkitToNotch(art);
painting.e = newArt;
painting.b(painting.a);
if(!force && !painting.i()) {
if (!force && !painting.j()) {
// Revert painting since it doesn't fit
painting.e = oldArt;
painting.b(painting.a);
@ -70,7 +70,7 @@ public class CraftPainting extends CraftEntity implements Painting {
painting.b = block.getX();
painting.c = block.getY();
painting.d = block.getZ();
switch(face) {
switch (face) {
case EAST:
default:
getHandle().b(0);
@ -85,7 +85,7 @@ public class CraftPainting extends CraftEntity implements Painting {
getHandle().b(3);
break;
}
if(!force && !painting.i()) {
if (!force && !painting.j()) {
// Revert painting since it doesn't fit
painting.b = x;
painting.c = y;
@ -98,7 +98,7 @@ public class CraftPainting extends CraftEntity implements Painting {
}
public BlockFace getFacing() {
switch(getHandle().a) {
switch (this.getHandle().a) {
case 0:
default:
return BlockFace.EAST;

View file

@ -489,7 +489,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
public int getLevel() {
return getHandle().expLevel;
return (int)getHandle().expLevel;
}
public void setLevel(int level) {

View file

@ -0,0 +1,32 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityLiving;
import net.minecraft.server.EntityProjectile;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Projectile;
public abstract class CraftProjectile extends AbstractProjectile implements Projectile {
public CraftProjectile(CraftServer server, net.minecraft.server.Entity entity) {
super(server, entity);
}
public LivingEntity getShooter() {
if (getHandle().shooter instanceof EntityLiving) {
return (LivingEntity)getHandle().shooter.getBukkitEntity();
}
return null;
}
public void setShooter(LivingEntity shooter) {
if (shooter instanceof CraftLivingEntity) {
getHandle().shooter = (EntityLiving)((CraftLivingEntity)shooter).entity;
}
}
@Override
public EntityProjectile getHandle() {
return (EntityProjectile)entity;
}
}

View file

@ -0,0 +1,12 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityFireball;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.SmallFireball;
public class CraftSmallFireball extends CraftFireball implements SmallFireball {
public CraftSmallFireball(CraftServer server, EntityFireball entity) {
super(server, entity);
}
}

View file

@ -1,13 +1,10 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityLiving;
import net.minecraft.server.EntitySnowball;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Snowball;
public class CraftSnowball extends AbstractProjectile implements Snowball {
public class CraftSnowball extends CraftProjectile implements Snowball {
public CraftSnowball(CraftServer server, EntitySnowball entity) {
super(server, entity);
}
@ -16,18 +13,4 @@ public class CraftSnowball extends AbstractProjectile implements Snowball {
public String toString() {
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;
}
}
}

View file

@ -0,0 +1,11 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityCreature;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Snowman;
public class CraftSnowman extends CraftCreature implements Snowman {
public CraftSnowman(CraftServer server, EntityCreature entity) {
super(server, entity);
}
}

View file

@ -0,0 +1,16 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.Entity;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.ThrownPotion;
public class CraftThrownPotion extends CraftProjectile implements ThrownPotion {
public CraftThrownPotion(CraftServer server, Entity entity) {
super(server, entity);
}
@Override
public String toString() {
return "CraftThrownPotion";
}
}

View file

@ -0,0 +1,17 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityCreature;
import net.minecraft.server.EntityVillager;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Villager;
public class CraftVillager extends CraftCreature implements Villager {
public CraftVillager(CraftServer server, EntityCreature entity) {
super(server, entity);
}
@Override
public EntityVillager getHandle() {
return (EntityVillager)super.getHandle();
}
}

View file

@ -2,10 +2,16 @@ package org.bukkit.craftbukkit.generator;
import java.util.List;
import java.util.Random;
import net.minecraft.server.BiomeBase;
import net.minecraft.server.Chunk;
import net.minecraft.server.ChunkCoordIntPair;
import net.minecraft.server.ChunkPosition;
import net.minecraft.server.EnumCreatureType;
import net.minecraft.server.IChunkProvider;
import net.minecraft.server.IProgressUpdate;
import net.minecraft.server.World;
import net.minecraft.server.WorldChunkManager;
import net.minecraft.server.WorldGenStronghold;
import net.minecraft.server.WorldServer;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
@ -14,6 +20,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
private final ChunkGenerator generator;
private final WorldServer world;
private final Random random;
private final WorldGenStronghold strongholdGen = new WorldGenStronghold();
public CustomChunkGenerator(World world, long seed, ChunkGenerator generator) {
this.world = (WorldServer) world;
@ -61,11 +68,29 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
return getOrCreateChunk(x, z);
}
@Override
public boolean canSpawn(org.bukkit.World world, int x, int z) {
return generator.canSpawn(world, x, z);
}
@Override
public List<BlockPopulator> getDefaultPopulators(org.bukkit.World world) {
return generator.getDefaultPopulators(world);
}
public List a(EnumCreatureType type, int x, int y, int z) {
WorldChunkManager worldchunkmanager = world.getWorldChunkManager();
if (worldchunkmanager == null) {
return null;
} else {
BiomeBase biomebase = worldchunkmanager.a(new ChunkCoordIntPair(x >> 4, z >> 4));
return biomebase == null ? null : biomebase.a(type);
}
}
public ChunkPosition a(World world, String type, int x, int y, int z) {
return "Stronghold".equals(type) && this.strongholdGen != null ? this.strongholdGen.a(world, x, y, z) : null;
}
}

View file

@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.server.Chunk;
import net.minecraft.server.ChunkPosition;
import net.minecraft.server.EnumCreatureType;
import net.minecraft.server.IChunkProvider;
import net.minecraft.server.IProgressUpdate;
import net.minecraft.server.World;
@ -56,4 +58,12 @@ public class NormalChunkGenerator extends InternalChunkGenerator {
public boolean canSave() {
return provider.canSave();
}
public List a(EnumCreatureType ect, int i, int i1, int i2) {
return provider.a(ect, i, i1, i2);
}
public ChunkPosition a(World world, String string, int i, int i1, int i2) {
return provider.a(world, string, i, i1, i2);
}
}