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.
Dieser Commit ist enthalten in:
Ursprung
5f940cf764
Commit
0703f4f458
@ -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();
|
||||
|
@ -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:
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren