mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
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. By: Andrew Ardill <andrew.ardill@gmail.com>
This commit is contained in:
parent
ddc6442b3b
commit
4a3c54648b
2 changed files with 46 additions and 11 deletions
|
@ -278,7 +278,7 @@ public class CraftBlock implements Block {
|
||||||
case DISPENSER:
|
case DISPENSER:
|
||||||
return new CraftDispenser(this);
|
return new CraftDispenser(this);
|
||||||
case MOB_SPAWNER:
|
case MOB_SPAWNER:
|
||||||
return new CraftMobSpawner(this);
|
return new CraftCreatureSpawner(this);
|
||||||
case NOTE_BLOCK:
|
case NOTE_BLOCK:
|
||||||
return new CraftNoteBlock(this);
|
return new CraftNoteBlock(this);
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -2,41 +2,42 @@ package org.bukkit.craftbukkit.block;
|
||||||
|
|
||||||
import net.minecraft.server.TileEntityMobSpawner;
|
import net.minecraft.server.TileEntityMobSpawner;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.CreatureSpawner;
|
||||||
import org.bukkit.block.MobSpawner;
|
import org.bukkit.block.MobSpawner;
|
||||||
import org.bukkit.craftbukkit.CraftWorld;
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
|
import org.bukkit.entity.CreatureType;
|
||||||
import org.bukkit.entity.MobType;
|
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 CraftWorld world;
|
||||||
private final TileEntityMobSpawner spawner;
|
private final TileEntityMobSpawner spawner;
|
||||||
|
|
||||||
public CraftMobSpawner(final Block block) {
|
public CraftCreatureSpawner(final Block block) {
|
||||||
super(block);
|
super(block);
|
||||||
|
|
||||||
world = (CraftWorld)block.getWorld();
|
world = (CraftWorld)block.getWorld();
|
||||||
spawner = (TileEntityMobSpawner)world.getTileEntityAt(getX(), getY(), getZ());
|
spawner = (TileEntityMobSpawner)world.getTileEntityAt(getX(), getY(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public MobType getMobType() {
|
public CreatureType getCreatureType() {
|
||||||
return MobType.fromName(spawner.h);
|
return CreatureType.fromName(spawner.h);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMobType(MobType mobType) {
|
public void setCreatureType(CreatureType creatureType) {
|
||||||
spawner.h = mobType.getName();
|
spawner.h = creatureType.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMobTypeId() {
|
public String getCreatureTypeId() {
|
||||||
return spawner.h;
|
return spawner.h;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMobTypeId(String mobType) {
|
public void setCreatureTypeId(String creatureType) {
|
||||||
// Verify input
|
// Verify input
|
||||||
MobType type = MobType.fromName(mobType);
|
CreatureType type = CreatureType.fromName(creatureType);
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
spawner.h = type.getName();
|
spawner.h = type.getName();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDelay() {
|
public int getDelay() {
|
||||||
|
@ -46,4 +47,38 @@ public class CraftMobSpawner extends CraftBlockState implements MobSpawner {
|
||||||
public void setDelay(int delay) {
|
public void setDelay(int delay) {
|
||||||
spawner.e = 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();
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue