From 0703f4f4581f810d8aaee2674ea6ced189a662aa Mon Sep 17 00:00:00 2001 From: Andrew Ardill Date: Thu, 17 Feb 2011 14:47:33 +1100 Subject: [PATCH] Updated to use CreatureType and CreatureSpawner Nothing will break as a result of the refactoring of MobType due to deprecated code being left in. These will be removed after 1 week, enough time for plugin devs time to migrate. --- .../java/net/minecraft/server/EntityEgg.java | 3 +- .../bukkit/craftbukkit/block/CraftBlock.java | 2 +- ...Spawner.java => CraftCreatureSpawner.java} | 55 +++++++++++++++---- 3 files changed, 48 insertions(+), 12 deletions(-) rename src/main/java/org/bukkit/craftbukkit/block/{CraftMobSpawner.java => CraftCreatureSpawner.java} (52%) diff --git a/src/main/java/net/minecraft/server/EntityEgg.java b/src/main/java/net/minecraft/server/EntityEgg.java index adb823e11e..875b4f3d18 100644 --- a/src/main/java/net/minecraft/server/EntityEgg.java +++ b/src/main/java/net/minecraft/server/EntityEgg.java @@ -3,6 +3,7 @@ package net.minecraft.server; import java.util.List; // CraftBukkit start +import org.bukkit.entity.CreatureType; import org.bukkit.entity.Egg; import org.bukkit.entity.MobType; import org.bukkit.entity.Player; @@ -189,7 +190,7 @@ public class EntityEgg extends Entity { if (!hatching) { numHatching = 0; } - MobType hatchingType = MobType.CHICKEN; + CreatureType hatchingType = CreatureType.CHICKEN; if (this.ak instanceof EntityPlayer) { CraftServer server = ((WorldServer) this.world).getServer(); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 55f8422fa2..f1ff00f302 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -278,7 +278,7 @@ public class CraftBlock implements Block { case DISPENSER: return new CraftDispenser(this); case MOB_SPAWNER: - return new CraftMobSpawner(this); + return new CraftCreatureSpawner(this); case NOTE_BLOCK: return new CraftNoteBlock(this); default: diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftMobSpawner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java similarity index 52% rename from src/main/java/org/bukkit/craftbukkit/block/CraftMobSpawner.java rename to src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java index 9cc283ec87..660400d649 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftMobSpawner.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java @@ -2,41 +2,42 @@ package org.bukkit.craftbukkit.block; import net.minecraft.server.TileEntityMobSpawner; import org.bukkit.block.Block; +import org.bukkit.block.CreatureSpawner; import org.bukkit.block.MobSpawner; import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.entity.CreatureType; import org.bukkit.entity.MobType; -public class CraftMobSpawner extends CraftBlockState implements MobSpawner { +public class CraftCreatureSpawner extends CraftBlockState implements CreatureSpawner, MobSpawner { private final CraftWorld world; private final TileEntityMobSpawner spawner; - public CraftMobSpawner(final Block block) { + public CraftCreatureSpawner(final Block block) { super(block); world = (CraftWorld)block.getWorld(); spawner = (TileEntityMobSpawner)world.getTileEntityAt(getX(), getY(), getZ()); } - public MobType getMobType() { - return MobType.fromName(spawner.h); + public CreatureType getCreatureType() { + return CreatureType.fromName(spawner.h); } - public void setMobType(MobType mobType) { - spawner.h = mobType.getName(); + public void setCreatureType(CreatureType creatureType) { + spawner.h = creatureType.getName(); } - public String getMobTypeId() { + public String getCreatureTypeId() { return spawner.h; } - public void setMobTypeId(String mobType) { + public void setCreatureTypeId(String creatureType) { // Verify input - MobType type = MobType.fromName(mobType); + CreatureType type = CreatureType.fromName(creatureType); if (type == null) { return; } spawner.h = type.getName(); - } public int getDelay() { @@ -46,4 +47,38 @@ public class CraftMobSpawner extends CraftBlockState implements MobSpawner { public void setDelay(int delay) { spawner.e = delay; } + + /** + * @deprecated + */ + public MobType getMobType() { + return MobType.fromName(spawner.h); + } + + /** + * @deprecated + */ + public void setMobType(MobType mobType) { + spawner.h = mobType.getName(); + + } + + /** + * @deprecated + */ + public String getMobTypeId() { + return spawner.h; + } + + /** + * @deprecated + */ + public void setMobTypeId(String mobType) { + // Verify input + MobType type = MobType.fromName(mobType); + if (type == null) { + return; + } + spawner.h = type.getName(); + } }