geforkt von Mirrors/Paper
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;
|
import java.util.List;
|
||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
|
import org.bukkit.entity.CreatureType;
|
||||||
import org.bukkit.entity.Egg;
|
import org.bukkit.entity.Egg;
|
||||||
import org.bukkit.entity.MobType;
|
import org.bukkit.entity.MobType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -189,7 +190,7 @@ public class EntityEgg extends Entity {
|
|||||||
if (!hatching) {
|
if (!hatching) {
|
||||||
numHatching = 0;
|
numHatching = 0;
|
||||||
}
|
}
|
||||||
MobType hatchingType = MobType.CHICKEN;
|
CreatureType hatchingType = CreatureType.CHICKEN;
|
||||||
|
|
||||||
if (this.ak instanceof EntityPlayer) {
|
if (this.ak instanceof EntityPlayer) {
|
||||||
CraftServer server = ((WorldServer) this.world).getServer();
|
CraftServer server = ((WorldServer) this.world).getServer();
|
||||||
|
@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren