[Bleeding] Added EntityType to replace CreatureType.

By: Celtic Minstrel <celtic.minstrel.ca@some.place>
This commit is contained in:
CraftBukkit/Spigot
2012-02-06 00:19:23 -05:00
parent 0126ce2b16
commit 8d2559e42a
48 changed files with 277 additions and 83 deletions

View File

@@ -1,10 +1,12 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.TileEntityMobSpawner;
import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.EntityType;
public class CraftCreatureSpawner extends CraftBlockState implements CreatureSpawner {
private final CraftWorld world;
@@ -17,25 +19,48 @@ public class CraftCreatureSpawner extends CraftBlockState implements CreatureSpa
spawner = (TileEntityMobSpawner) world.getTileEntityAt(getX(), getY(), getZ());
}
@Deprecated
public CreatureType getCreatureType() {
return CreatureType.fromName(spawner.mobName);
}
public EntityType getSpawnedType() {
return EntityType.fromName(spawner.mobName);
}
@Deprecated
public void setCreatureType(CreatureType creatureType) {
spawner.mobName = creatureType.getName();
}
public void setSpawnedType(EntityType creatureType) {
if (!creatureType.isAlive() || !creatureType.isSpawnable()) {
throw new IllegalArgumentException("Can't spawn non-living entities from mob spawners!");
}
spawner.mobName = creatureType.getName();
}
public String getCreatureTypeId() {
return spawner.mobName;
}
public void setCreatureTypeId(String creatureType) {
@Deprecated
public void setCreatureTypeId(String creatureName) {
setCreatureTypeByName(creatureName);
}
public String getCreatureTypeName() {
return spawner.mobName;
}
public void setCreatureTypeByName(String creatureType) {
// Verify input
CreatureType type = CreatureType.fromName(creatureType);
EntityType type = EntityType.fromName(creatureType);
if (type == null) {
return;
}
spawner.mobName = type.getName();
setSpawnedType(type);
}
public int getDelay() {