本文整理匯總了Java中org.bukkit.block.CreatureSpawner.getDelay方法的典型用法代碼示例。如果您正苦於以下問題:Java CreatureSpawner.getDelay方法的具體用法?Java CreatureSpawner.getDelay怎麽用?Java CreatureSpawner.getDelay使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.block.CreatureSpawner
的用法示例。
在下文中一共展示了CreatureSpawner.getDelay方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: SerializableBlockEntity
import org.bukkit.block.CreatureSpawner; //導入方法依賴的package包/類
/**
* Constructor.
*
* @param blockState The {@link org.bukkit.block.BlockState} that needs to be serialized.
*/
public SerializableBlockEntity(BlockState blockState) {
PreCon.notNull(blockState);
_location = blockState.getLocation();
_material = blockState.getType();
_data = blockState.getRawData();
if (blockState instanceof InventoryHolder) {
_contents = ((InventoryHolder) blockState).getInventory().getContents();
}
if (blockState instanceof CommandBlock) {
CommandBlock commandBlock = (CommandBlock)blockState;
_commandName = commandBlock.getName();
_command = commandBlock.getCommand();
}
if (blockState instanceof CreatureSpawner) {
CreatureSpawner spawner = (CreatureSpawner)blockState;
_creatureTypeName = spawner.getCreatureTypeName();
_creatureDelay = spawner.getDelay();
}
if (blockState instanceof NoteBlock) {
NoteBlock noteBlock = (NoteBlock)blockState;
_noteTone = noteBlock.getNote().getTone();
_noteOctave = noteBlock.getNote().getOctave();
_noteSharped = noteBlock.getNote().isSharped();
}
if (blockState instanceof Sign) {
Sign sign = (Sign)blockState;
_signLines = sign.getLines().clone();
}
if (blockState instanceof Skull) {
Skull skull = (Skull)blockState;
_skullType = skull.getSkullType();
_skullRotation = skull.getRotation();
_skullOwner = skull.getOwner();
}
}
示例2: Spawner
import org.bukkit.block.CreatureSpawner; //導入方法依賴的package包/類
public Spawner(Block block, BlockFace face) {
super(false);
CreatureSpawner originalSpawner = (CreatureSpawner) block.getState();
EntityType originalEntityType = originalSpawner.getSpawnedType();
int originalEntityDelay = originalSpawner.getDelay();
Location blockLocation = block.getLocation();
int blockX = blockLocation.getBlockX();
int blockY = blockLocation.getBlockY();
int blockZ = blockLocation.getBlockZ();
Block newSpawn = block.getWorld().getBlockAt(blockLocation);
switch (face) {
case NORTH:
newSpawn = block.getWorld().getBlockAt(blockX, blockY, blockZ + 1);
break;
case EAST:
newSpawn = block.getWorld().getBlockAt(blockX - 1, blockY, blockZ);
break;
case SOUTH:
newSpawn = block.getWorld().getBlockAt(blockX, blockY, blockZ - 1);
break;
case WEST:
newSpawn = block.getWorld().getBlockAt(blockX + 1, blockY, blockZ);
break;
case UP:
newSpawn = block.getWorld().getBlockAt(blockX, blockY - 1, blockZ);
break;
case DOWN:
newSpawn = block.getWorld().getBlockAt(blockX, blockY + 1, blockZ);
break;
}
if (newSpawn.getType().equals(Material.AIR)) {
block.setType(Material.AIR);
newSpawn.setType(Material.MOB_SPAWNER);
BlockState blockState = newSpawn.getState();
((CreatureSpawner) blockState).setSpawnedType(originalEntityType);
((CreatureSpawner) blockState).setDelay(originalEntityDelay);
blockState.update(true);
}
}