ShulkerData.java 文件源码

java
阅读 22 收藏 0 点赞 0 评论 0

项目:TNE-Bukkit 作者:
@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;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号