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


Java BlockStateMeta.getBlockState方法代码示例

本文整理汇总了Java中org.bukkit.inventory.meta.BlockStateMeta.getBlockState方法的典型用法代码示例。如果您正苦于以下问题:Java BlockStateMeta.getBlockState方法的具体用法?Java BlockStateMeta.getBlockState怎么用?Java BlockStateMeta.getBlockState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.inventory.meta.BlockStateMeta的用法示例。


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

示例1: setBoxInventory

import org.bukkit.inventory.meta.BlockStateMeta; //导入方法依赖的package包/类
public void setBoxInventory(Inventory inventory){
	if(item.getItemMeta() instanceof BlockStateMeta){
		BlockStateMeta im = (BlockStateMeta)item.getItemMeta();
		if(im.getBlockState() instanceof ShulkerBox){
			ShulkerBox shulker = (ShulkerBox) im.getBlockState();
			shulker.getInventory().setContents(inventory.getContents());
			im.setBlockState(shulker);
			item.setItemMeta(im);
			return;
		}
	}
	return;
}
 
开发者ID:DamoclesProject,项目名称:Damocles,代码行数:14,代码来源:NBTHandler.java

示例2: getBoxInventory

import org.bukkit.inventory.meta.BlockStateMeta; //导入方法依赖的package包/类
public Inventory getBoxInventory(){
	Inventory inv = Bukkit.createInventory(null, 27, "Bank");
	if(item.getItemMeta() instanceof BlockStateMeta){
		BlockStateMeta im = (BlockStateMeta)item.getItemMeta();
		if(im.getBlockState() instanceof ShulkerBox){
			ShulkerBox shulker = (ShulkerBox) im.getBlockState();
			inv.setContents(shulker.getInventory().getContents());
			return inv;
		}
	}
	return inv;
}
 
开发者ID:DamoclesProject,项目名称:Damocles,代码行数:13,代码来源:NBTHandler.java

示例3: containsBook

import org.bukkit.inventory.meta.BlockStateMeta; //导入方法依赖的package包/类
public static boolean containsBook(ItemStack item) {
    if (item.hasItemMeta() && item.getItemMeta() instanceof BlockStateMeta) {
        BlockStateMeta blockStateMeta = (BlockStateMeta) item.getItemMeta();
        if (blockStateMeta.hasBlockState() && blockStateMeta.getBlockState() instanceof InventoryHolder) {
            InventoryHolder inventoryHolder = (InventoryHolder) blockStateMeta.getBlockState();
            for (ItemStack itemStack : inventoryHolder.getInventory().getContents()) {
                if (itemStack != null && itemStack.getType() != Material.AIR &&
                        itemStack.hasItemMeta() && itemStack.getItemMeta() instanceof BookMeta) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
开发者ID:NyaaCat,项目名称:HamsterEcoHelper,代码行数:16,代码来源:MarketManager.java

示例4: fromItemStack

import org.bukkit.inventory.meta.BlockStateMeta; //导入方法依赖的package包/类
public static SignContent fromItemStack(ItemStack item) {
    SignContent content = new SignContent();
    if (item.hasItemMeta() && item.getItemMeta() instanceof BlockStateMeta) {
        BlockStateMeta blockStateMeta = (BlockStateMeta) item.getItemMeta();
        if (blockStateMeta.hasBlockState() && blockStateMeta.getBlockState() instanceof Sign) {
            Sign sign = ((Sign) blockStateMeta.getBlockState());
            for (int i = 0; i < 4; i++) {
                content.setLine(i, sign.getLine(i));
            }
        }
    }
    return content;
}
 
开发者ID:NyaaCat,项目名称:NyaaUtils,代码行数:14,代码来源:SignContent.java

示例5: toItemStack

import org.bukkit.inventory.meta.BlockStateMeta; //导入方法依赖的package包/类
public ItemStack toItemStack(ItemStack item) {
    if (item.getItemMeta() instanceof BlockStateMeta) {
        BlockStateMeta blockStateMeta = (BlockStateMeta) item.getItemMeta();
        if (blockStateMeta.getBlockState() instanceof Sign) {
            Sign sign = ((Sign) blockStateMeta.getBlockState());
            for (int i = 0; i < 4; i++) {
                sign.setLine(i, getLine(i));
            }
            blockStateMeta.setBlockState(sign);
        }
        item.setItemMeta(blockStateMeta);
    }
    return item;
}
 
开发者ID:NyaaCat,项目名称:NyaaUtils,代码行数:15,代码来源:SignContent.java

示例6: applyMeta

import org.bukkit.inventory.meta.BlockStateMeta; //导入方法依赖的package包/类
/**
 * Applies meta to a shield
 *
 * @param itemStack  shield item
 * @param bannerMeta banner meta
 * @return shield item
 */
public static ItemStack applyMeta(ItemStack itemStack, BannerMeta bannerMeta) {
	if(itemStack.getType() != Material.SHIELD && itemStack.getType() != Material.BANNER) {
		throw new IllegalArgumentException("Passed ItemStack is not a shield nor a banner");
	}

	ItemMeta meta = itemStack.getItemMeta();
	BlockStateMeta blockStateMeta = (BlockStateMeta) meta;
	Banner banner = (Banner) blockStateMeta.getBlockState();
	applyMeta(banner, bannerMeta);
	banner.update();
	blockStateMeta.setBlockState(banner);
	itemStack.setItemMeta(blockStateMeta);
	return itemStack;
}
 
开发者ID:MarcinWieczorek,项目名称:NovaGuilds,代码行数:22,代码来源:BannerUtils.java

示例7: initialize

import org.bukkit.inventory.meta.BlockStateMeta; //导入方法依赖的package包/类
@Override
public SerialItemData initialize(ItemStack stack) {
  TNE.debug("ShulkerData.initialize.");
  if(SerialItem.isShulker(stack.getType())) {
    TNE.debug("Passed shulker check");
    ItemMeta meta = stack.getItemMeta();
    if(meta instanceof BlockStateMeta) {
      TNE.debug("Is BlockStateMeta");
      BlockStateMeta state = (BlockStateMeta)meta;
      if(state.getBlockState() instanceof ShulkerBox) {
        TNE.debug("Is ShulkerBox BlockState");
        valid = true;
        ShulkerBox shulker = (ShulkerBox)state.getBlockState();
        Inventory inventory = shulker.getInventory();
        TNE.debug("Initializing shulker box..");
        for(int i = 0; i < inventory.getSize(); i++) {
          if(inventory.getItem(i) == null || inventory.getItem(i).getType().equals(Material.AIR)) {
            if(items.containsKey(i)) {
              items.remove(i);
              TNE.debug("Removing item from slot " + i);
            }
          } else {
            TNE.debug("Adding Item: " + inventory.getItem(i).getType().name());
            TNE.debug("Item Slot: " + i);
            items.put(i, new SerialItem(inventory.getItem(i)));
          }
        }
      }
    }
  }
  return this;
}
 
开发者ID:TheNewEconomy,项目名称:TNE-Bukkit,代码行数:33,代码来源:ShulkerData.java

示例8: getItemJsonStripped

import org.bukkit.inventory.meta.BlockStateMeta; //导入方法依赖的package包/类
private String getItemJsonStripped(ItemStack item) {
    ItemStack cloned = item.clone();
    if (cloned.hasItemMeta() && cloned.getItemMeta() instanceof BookMeta) {
        return ItemStackUtils.itemToJson(removeBookContent(cloned));
    }
    if (cloned.hasItemMeta() && cloned.getItemMeta() instanceof BlockStateMeta) {
        BlockStateMeta blockStateMeta = (BlockStateMeta) cloned.getItemMeta();
        if (blockStateMeta.hasBlockState() && blockStateMeta.getBlockState() instanceof InventoryHolder) {
            InventoryHolder inventoryHolder = (InventoryHolder) blockStateMeta.getBlockState();
            ArrayList<ItemStack> items = new ArrayList<>();
            for (int i = 0; i < inventoryHolder.getInventory().getSize(); i++) {
                ItemStack itemStack = inventoryHolder.getInventory().getItem(i);
                if (itemStack != null && itemStack.getType() != Material.AIR) {
                    if (items.size() < 5) {
                        if (itemStack.hasItemMeta()) {
                            if (itemStack.getItemMeta().hasLore()) {
                                ItemMeta meta = itemStack.getItemMeta();
                                meta.setLore(new ArrayList<String>());
                                itemStack.setItemMeta(meta);
                            }
                            if (itemStack.getItemMeta() instanceof BookMeta) {
                                itemStack = removeBookContent(itemStack);
                            }
                        }
                        items.add(itemStack);
                    } else {
                        items.add(new ItemStack(Material.STONE));
                    }
                }
            }
            inventoryHolder.getInventory().clear();
            for (int i = 0; i < items.size(); i++) {
                inventoryHolder.getInventory().setItem(i, items.get(i));
            }
            blockStateMeta.setBlockState((BlockState) inventoryHolder);
            cloned.setItemMeta(blockStateMeta);
            return ItemStackUtils.itemToJson(cloned);
        }
    }
    return ItemStackUtils.itemToJson(cloned);
}
 
开发者ID:NyaaCat,项目名称:NyaaCore,代码行数:42,代码来源:Message.java

示例9: getSpawnerType

import org.bukkit.inventory.meta.BlockStateMeta; //导入方法依赖的package包/类
@Override
public EntityType getSpawnerType(ItemStack item) {
    BlockStateMeta bsm = (BlockStateMeta) item.getItemMeta();
    CreatureSpawner bs = (CreatureSpawner) bsm.getBlockState();
    return bs.getSpawnedType();
}
 
开发者ID:novucs,项目名称:factions-top,代码行数:7,代码来源:Craftbukkit18R3.java


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