From d9022018752eaab661a5eaaea55922411f943026 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Thu, 15 Sep 2011 01:23:52 +0100 Subject: [PATCH] Update for Minecraft 1.8 By: Dinnerbone --- paper-server/pom.xml | 2 +- .../org/bukkit/craftbukkit/CraftChunk.java | 14 ++++++---- .../org/bukkit/craftbukkit/CraftServer.java | 7 +++-- .../org/bukkit/craftbukkit/CraftWorld.java | 28 ++++++++----------- .../bukkit/craftbukkit/block/CraftBlock.java | 22 ++++++--------- .../craftbukkit/entity/CraftLivingEntity.java | 18 +++++++++--- 6 files changed, 46 insertions(+), 45 deletions(-) diff --git a/paper-server/pom.xml b/paper-server/pom.xml index 6b94dd1695..0a3967cc23 100644 --- a/paper-server/pom.xml +++ b/paper-server/pom.xml @@ -39,7 +39,7 @@ org.bukkit minecraft-server - 1.7.3 + 1.8 jar compile diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index 5ea5e01f22..b02b3d3745 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -154,7 +154,7 @@ public class CraftChunk implements Chunk { if (includeBiome || includeBiomeTempRain) { WorldChunkManager wcm = chunk.world.getWorldChunkManager(); - BiomeBase[] biomeBase = wcm.getBiomeData(getX() << 4, getZ() << 4, 16, 16); + BiomeBase[] biomeBase = wcm.b((BiomeBase[])null, getX() << 4, getZ() << 4, 16, 16); if (includeBiome) { biome = new BiomeBase[256]; @@ -164,8 +164,9 @@ public class CraftChunk implements Chunk { if (includeBiomeTempRain) { biomeTemp = new double[256]; biomeRain = new double[256]; - System.arraycopy(wcm.temperature, 0, biomeTemp, 0, biomeTemp.length); - System.arraycopy(wcm.rain, 0, biomeRain, 0, biomeRain.length); + //System.arraycopy(wcm.temperature, 0, biomeTemp, 0, biomeTemp.length); + //System.arraycopy(wcm.rain, 0, biomeRain, 0, biomeRain.length); + // TODO: Figure out new snapshot stuff } } World world = getWorld(); @@ -208,7 +209,7 @@ public class CraftChunk implements Chunk { if (includeBiome || includeBiomeTempRain) { WorldChunkManager wcm = world.getHandle().getWorldChunkManager(); - BiomeBase[] biomeBase = wcm.getBiomeData(x << 4, z << 4, 16, 16); + BiomeBase[] biomeBase = wcm.b((BiomeBase[])null, x << 4, z << 4, 16, 16); if (includeBiome) { biome = new BiomeBase[256]; @@ -218,8 +219,9 @@ public class CraftChunk implements Chunk { if (includeBiomeTempRain) { biomeTemp = new double[256]; biomeRain = new double[256]; - System.arraycopy(wcm.temperature, 0, biomeTemp, 0, biomeTemp.length); - System.arraycopy(wcm.rain, 0, biomeRain, 0, biomeRain.length); + //System.arraycopy(wcm.temperature, 0, biomeTemp, 0, biomeTemp.length); + //System.arraycopy(wcm.rain, 0, biomeRain, 0, biomeRain.length); + // TODO: Figure out new snapshot stuff } } return new EmptyChunkSnapshot(x, z, world.getName(), world.getFullTime(), biome, biomeTemp, biomeRain); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 5ce5204fd5..0038182066 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -50,6 +50,7 @@ import net.minecraft.server.Item; import net.minecraft.server.ItemStack; import net.minecraft.server.WorldMap; import net.minecraft.server.WorldMapCollection; +import net.minecraft.server.WorldSettings; import org.bukkit.*; import org.bukkit.permissions.Permissible; import org.bukkit.plugin.Plugin; @@ -79,7 +80,7 @@ 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.7.3"; + private final String protocolVersion = "1.8"; private final ServicesManager servicesManager = new SimpleServicesManager(); private final BukkitScheduler scheduler = new CraftScheduler(this); private final SimpleCommandMap commandMap = new SimpleCommandMap(this); @@ -489,7 +490,7 @@ public final class CraftServer implements Server { } int dimension = 10 + console.worlds.size(); - WorldServer internal = new WorldServer(console, new ServerNBTManager(new File("."), name, true), name, dimension, seed, environment, generator); + WorldServer internal = new WorldServer(console, new ServerNBTManager(new File("."), name, true), name, dimension, new WorldSettings(seed, getDefaultGameMode().getValue(), true), environment, generator); if (!(worlds.containsKey(name.toLowerCase()))) { return null; @@ -532,7 +533,7 @@ public final class CraftServer implements Server { ChunkCoordinates chunkcoordinates = internal.getSpawn(); internal.chunkProviderServer.getChunkAt(chunkcoordinates.x + j >> 4, chunkcoordinates.z + k >> 4); - while (internal.doLighting()) { + while (internal.v()) { ; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 0faf610eb1..98c98ad217 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -153,7 +153,7 @@ public class CraftWorld implements World { net.minecraft.server.Chunk chunk = world.chunkProviderServer.getOrCreateChunk(x, z); - if (save && !chunk.isEmpty()) { + if (save && !(chunk instanceof EmptyChunk)) { chunk.removeEntities(); world.chunkProviderServer.saveChunk(chunk); world.chunkProviderServer.saveChunkNOP(chunk); @@ -474,43 +474,37 @@ public class CraftWorld implements World { public Biome getBiome(int x, int z) { BiomeBase base = getHandle().getWorldChunkManager().getBiome(x, z); - if (base == BiomeBase.RAINFOREST) { - return Biome.RAINFOREST; - } else if (base == BiomeBase.SWAMPLAND) { + if (base == BiomeBase.SWAMPLAND) { return Biome.SWAMPLAND; - } else if (base == BiomeBase.SEASONAL_FOREST) { - return Biome.SEASONAL_FOREST; } else if (base == BiomeBase.FOREST) { return Biome.FOREST; - } else if (base == BiomeBase.SAVANNA) { - return Biome.SAVANNA; - } else if (base == BiomeBase.SHRUBLAND) { - return Biome.SHRUBLAND; } else if (base == BiomeBase.TAIGA) { return Biome.TAIGA; } else if (base == BiomeBase.DESERT) { return Biome.DESERT; } else if (base == BiomeBase.PLAINS) { return Biome.PLAINS; - } else if (base == BiomeBase.ICE_DESERT) { - return Biome.ICE_DESERT; - } else if (base == BiomeBase.TUNDRA) { - return Biome.TUNDRA; } else if (base == BiomeBase.HELL) { return Biome.HELL; } else if (base == BiomeBase.SKY) { return Biome.SKY; + } else if (base == BiomeBase.OCEAN) { + return Biome.OCEAN; + } else if (base == BiomeBase.EXTREME_HILLS) { + return Biome.EXTREME_HILLS; + } else if (base == BiomeBase.RIVER) { + return Biome.RIVER; } return null; } public double getTemperature(int x, int z) { - return getHandle().getWorldChunkManager().a((double[])null, x, z, 1, 1)[0]; + throw new UnsupportedOperationException("Not compatible with 1.8"); } public double getHumidity(int x, int z) { - return getHandle().getWorldChunkManager().getHumidity(x, z); + throw new UnsupportedOperationException("Not compatible with 1.8"); } public List getEntities() { @@ -810,7 +804,7 @@ public class CraftWorld implements World { loadChunk(chunkCoordX + x, chunkCoordZ + z); } else { if (isChunkLoaded(chunkCoordX + x, chunkCoordZ + z)) { - if (this.getHandle().getChunkAt(chunkCoordX + x, chunkCoordZ + z).isEmpty()) { + if (this.getHandle().getChunkAt(chunkCoordX + x, chunkCoordZ + z) instanceof EmptyChunk) { unloadChunk(chunkCoordX + x, chunkCoordZ + z, false); } else { unloadChunk(chunkCoordX + x, chunkCoordZ + z); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 139fc50f8f..40d66b5ec1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -222,32 +222,26 @@ public class CraftBlock implements Block { } public static final Biome biomeBaseToBiome(BiomeBase base) { - if (base == BiomeBase.RAINFOREST) { - return Biome.RAINFOREST; - } else if (base == BiomeBase.SWAMPLAND) { + if (base == BiomeBase.SWAMPLAND) { return Biome.SWAMPLAND; - } else if (base == BiomeBase.SEASONAL_FOREST) { - return Biome.SEASONAL_FOREST; } else if (base == BiomeBase.FOREST) { return Biome.FOREST; - } else if (base == BiomeBase.SAVANNA) { - return Biome.SAVANNA; - } else if (base == BiomeBase.SHRUBLAND) { - return Biome.SHRUBLAND; } else if (base == BiomeBase.TAIGA) { return Biome.TAIGA; } else if (base == BiomeBase.DESERT) { return Biome.DESERT; } else if (base == BiomeBase.PLAINS) { return Biome.PLAINS; - } else if (base == BiomeBase.ICE_DESERT) { - return Biome.ICE_DESERT; - } else if (base == BiomeBase.TUNDRA) { - return Biome.TUNDRA; } else if (base == BiomeBase.HELL) { return Biome.HELL; } else if (base == BiomeBase.SKY) { return Biome.SKY; + } else if (base == BiomeBase.RIVER) { + return Biome.RIVER; + } else if (base == BiomeBase.EXTREME_HILLS) { + return Biome.EXTREME_HILLS; + } else if (base == BiomeBase.OCEAN) { + return Biome.OCEAN; } return null; @@ -308,7 +302,7 @@ public class CraftBlock implements Block { } public PistonMoveReaction getPistonMoveReaction() { - return PistonMoveReaction.getById(net.minecraft.server.Block.byId[this.getTypeId()].material.j()); + return PistonMoveReaction.getById(net.minecraft.server.Block.byId[this.getTypeId()].material.l()); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 29e5ab4893..9c1cc85451 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -23,6 +23,8 @@ import java.util.List; import java.util.HashSet; import java.util.ArrayList; import java.util.Iterator; +import net.minecraft.server.DamageSource; +import org.bukkit.entity.HumanEntity; public class CraftLivingEntity extends CraftEntity implements LivingEntity { public CraftLivingEntity(final CraftServer server, final EntityLiving entity) { @@ -39,7 +41,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { } if (entity instanceof EntityPlayer && health == 0) { - ((EntityPlayer) entity).die((Entity) null); + ((EntityPlayer) entity).die(DamageSource.j); } getHandle().health = health; @@ -125,7 +127,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { public Arrow shootArrow() { net.minecraft.server.World world = ((CraftWorld) getWorld()).getHandle(); - EntityArrow arrow = new EntityArrow(world, getHandle()); + EntityArrow arrow = new EntityArrow(world, getHandle(), 1); world.addEntity(arrow); return (Arrow) arrow.getBukkitEntity(); @@ -174,11 +176,19 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { } public void damage(int amount) { - entity.damageEntity((Entity) null, amount); + entity.damageEntity(DamageSource.j, amount); } public void damage(int amount, org.bukkit.entity.Entity source) { - entity.damageEntity(((CraftEntity) source).getHandle(), amount); + DamageSource reason = DamageSource.a.j; + + if (source instanceof HumanEntity) { + reason = DamageSource.b(((CraftHumanEntity)source).getHandle()); + } else if (source instanceof LivingEntity) { + reason = DamageSource.a(((CraftLivingEntity)source).getHandle()); + } + + entity.damageEntity(reason, amount); } public Location getEyeLocation() {