當前位置: 首頁>>代碼示例>>Java>>正文


Java CreatureSpawner.getCreatureTypeName方法代碼示例

本文整理匯總了Java中org.bukkit.block.CreatureSpawner.getCreatureTypeName方法的典型用法代碼示例。如果您正苦於以下問題:Java CreatureSpawner.getCreatureTypeName方法的具體用法?Java CreatureSpawner.getCreatureTypeName怎麽用?Java CreatureSpawner.getCreatureTypeName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.block.CreatureSpawner的用法示例。


在下文中一共展示了CreatureSpawner.getCreatureTypeName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateFrom

import org.bukkit.block.CreatureSpawner; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public void updateFrom(Block block, Set<Material> restrictedMaterials) {
    if (block == null) {
        isValid = false;
        return;
    }
    if (!block.getChunk().isLoaded()) {
        block.getChunk().load(true);
        return;
    }

    Material blockMaterial = block.getType();
    if (restrictedMaterials != null && restrictedMaterials.contains(blockMaterial)) {
        isValid = false;
        return;
    }
    // Look for special block states
    extraData = null;

    material = blockMaterial;
    data = (short)block.getData();

    try {
        BlockState blockState = block.getState();
        if (material == Material.FLOWER_POT || blockState instanceof InventoryHolder || blockState instanceof Sign) {
            extraData = new BlockTileEntity(NMSUtils.getTileEntityData(block.getLocation()));
        } else if (blockState instanceof CommandBlock){
            // This seems to occasionally throw exceptions...
            CommandBlock command = (CommandBlock)blockState;
            extraData = new BlockCommand(command.getCommand(), command.getName());
        } else if (blockState instanceof Skull) {
            Skull skull = (Skull)blockState;
            data = (short)skull.getSkullType().ordinal();
            extraData = new BlockSkull(CompatibilityUtils.getSkullProfile(skull), skull.getSkullType(), skull.getRotation());
        } else if (blockState instanceof CreatureSpawner) {
            CreatureSpawner spawner = (CreatureSpawner)blockState;
            extraData = new BlockMobSpawner(spawner.getCreatureTypeName());
        } else if (blockMaterial == Material.STANDING_BANNER || blockMaterial == Material.WALL_BANNER) {
            if (blockState != null && blockState instanceof Banner) {
                Banner banner = (Banner)blockState;
                DyeColor color = banner.getBaseColor();
                extraData = new BlockBanner(banner.getPatterns(), color);
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    isValid = true;
}
 
開發者ID:elBukkit,項目名稱:MagicLib,代碼行數:51,代碼來源:MaterialAndData.java

示例2: 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();
    }
}
 
開發者ID:JCThePants,項目名稱:NucleusFramework,代碼行數:51,代碼來源:SerializableBlockEntity.java


注:本文中的org.bukkit.block.CreatureSpawner.getCreatureTypeName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。