当前位置: 首页>>代码示例>>Java>>正文


Java Block类代码示例

本文整理汇总了Java中com.protolambda.blocktopograph.map.Block的典型用法代码示例。如果您正苦于以下问题:Java Block类的具体用法?Java Block怎么用?Java Block使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Block类属于com.protolambda.blocktopograph.map包,在下文中一共展示了Block类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseTag

import com.protolambda.blocktopograph.map.Block; //导入依赖的package包/类
@Override
public String parseTag(Tag tag) {
    if (tag instanceof CompoundTag) {
        int damage = 0, id = 0, count = 0;

        for (Tag child : ((CompoundTag) tag).getValue()) {
            switch (child.getName()) {
                case "Count":
                    count = (byte) child.getValue();
                    break;
                case "Damage":
                    damage = (short) child.getValue();
                    break;
                case "id":
                    id = (short) child.getValue();
                    break;
            }
        }

        if (id == 0) {
            return "Empty";
        }

        Block block = Block.getBlock(id, damage);
        if (block == null || block.subName == null) {
            block = Block.getBlock(id, 0);

            if (block == null) {
                return String.format(format, "unknown", damage);
            }

            return String.format(format, block.name, damage);
        }

        return String.format(format, block.subName + " " + block.name, count);
    }
    
    return "";
}
 
开发者ID:jocopa3,项目名称:BlocktopographPC-GUI,代码行数:40,代码来源:ArmorTag.java

示例2: parseTag

import com.protolambda.blocktopograph.map.Block; //导入依赖的package包/类
@Override
public String parseTag(Tag tag) {
    if (tag instanceof ShortTag) {
        short id = ((ShortTag) tag).getValue();

        Block block = Block.getBlock(id, 0);
        if (block == null) {
            return String.format(format, "Unknown");
        }

        return String.format(format, block.name);
    }
    return "";
}
 
开发者ID:jocopa3,项目名称:BlocktopographPC-GUI,代码行数:15,代码来源:ItemIdTag.java

示例3: parseTag

import com.protolambda.blocktopograph.map.Block; //导入依赖的package包/类
@Override
public String parseTag(Tag tag) {
    if (tag instanceof CompoundTag) {
        int slot = 0, id = 0, count = 0, damage = 0;

        for (Tag child : ((CompoundTag) tag).getValue()) {
            switch (child.getName()) {
                case "Count":
                    count = (byte) child.getValue();
                    break;
                case "Damage":
                    damage = (short) child.getValue();
                    break;
                case "Slot":
                    slot = (byte) child.getValue();
                    break;
                case "id":
                    id = (short) child.getValue();
                    break;
            }
        }

        String blockString = "";

        if (showSlot && count <= 0) {
            blockString = "Empty";
        } else {
            Block block = Block.getBlock(id, damage);

            if (block == null || block.subName == null) {
                block = Block.getBlock(id, 0);

                if (block == null) {
                    blockString = "unknown";
                } else {

                    blockString = block.name;
                }
            } else {
                blockString = block.subName + " " + block.name;
            }
        }
        
        if (showSlot) {
            return String.format(format, slot, blockString, count);
        } else {
            return String.format(format, blockString, count);
        }
    }

    return "";
}
 
开发者ID:jocopa3,项目名称:BlocktopographPC-GUI,代码行数:53,代码来源:InventoryItemTag.java


注:本文中的com.protolambda.blocktopograph.map.Block类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。