net.minecraft.block.Block.getSubBlocks()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中net.minecraft.block.Block.getSubBlocks()方法的一些代码示例,展示了Block.getSubBlocks()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.getSubBlocks()方法的具体详情如下:
包路径:net.minecraft.block.Block
类名称:Block
方法名:getSubBlocks

Block.getSubBlocks介绍

暂无

代码示例

代码示例来源:origin: Vazkii/Botania

private void addBlock(Block block) {
  ItemStack stack = new ItemStack(block);
  block.getSubBlocks(this, list);
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

b.getSubBlocks( b.getCreativeTabToDisplayOn(), tmpList );
for( final ItemStack l : tmpList )

代码示例来源:origin: Ellpeck/ActuallyAdditions

public void add(Block block){
    if(block != null){
      block.getSubBlocks(INSTANCE, this.list);
    }
  }
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

public ItemBlockTorqueTile(Block block) {
  super(block);
  if (!(block instanceof IRotatableBlock)) {
    throw new IllegalArgumentException("Must be a rotatable block!!");
  }
  rotatable = (IRotatableBlock) block;
  NonNullList<ItemStack> subBlocks = NonNullList.create();
  block.getSubBlocks(block.getCreativeTabToDisplayOn(), subBlocks);
  setHasSubtypes(subBlocks.size() > 1);
}

代码示例来源:origin: mezz/JustEnoughItems

private void addBlockAndSubBlocks(StackHelper stackHelper, @Nullable Block block, List<ItemStack> itemList, Set<String> itemNameSet) {
  if (block == null) {
    return;
  }
  Item item = Item.getItemFromBlock(block);
  if (item == Items.AIR) {
    return;
  }
  for (CreativeTabs itemTab : item.getCreativeTabs()) {
    NonNullList<ItemStack> subBlocks = NonNullList.create();
    try {
      block.getSubBlocks(itemTab, subBlocks);
    } catch (RuntimeException | LinkageError e) {
      String itemStackInfo = ErrorUtil.getItemStackInfo(new ItemStack(item));
      Log.get().error("Failed to getSubBlocks {}", itemStackInfo, e);
    }
    for (ItemStack subBlock : subBlocks) {
      if (subBlock == null) {
        Log.get().error("Found null subBlock of {}", block);
      } else if (subBlock.isEmpty()) {
        Log.get().error("Found empty subBlock of {}", block);
      } else {
        addItemStack(stackHelper, subBlock, itemList, itemNameSet);
      }
    }
  }
}

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

@SideOnly(Side.CLIENT)
public MOGuideEntry setStackIcons(Block block) {
  NonNullList<ItemStack> stacks = NonNullList.create();
  block.getSubBlocks(CreativeTabs.SEARCH, stacks);
  if (stacks.size() > 0) {
    this.stackIcons = new ItemStack[stacks.size()];
    this.stackIcons = stacks.toArray(this.stackIcons);
  } else {
    this.stackIcons = new ItemStack[]{new ItemStack(block)};
  }
  return this;
}

代码示例来源:origin: Darkhax-Minecraft/Bookshelf

block.getSubBlocks(null, subBlocks);

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

public static void registerToNormal(Block block) {
  final String resourcePath = block.getRegistryName().toString();
  ModelLoader.setCustomStateMapper(block, new DefaultStateMapper() {
    protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
      return new ModelResourceLocation(resourcePath, "normal");
    }
  });
  NonNullList<ItemStack> subBlocks = NonNullList.create();
  block.getSubBlocks(null, subBlocks);
  for (ItemStack stack : subBlocks) {
    IBlockState state = block.getStateFromMeta(stack.getMetadata());
    ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), stack.getMetadata(), new ModelResourceLocation(resourcePath, "inventory"));
  }
}

代码示例来源:origin: raoulvdberge/refinedstorage

@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
  if (!isInCreativeTab(tab)) {
    return;
  }
  if (RS.INSTANCE.config.hideCovers) {
    ItemStack stack = new ItemStack(this);
    setItem(stack, HIDDEN_COVER_ALTERNATIVE);
    items.add(stack);
    return;
  }
  for (Block block : Block.REGISTRY) {
    Item item = Item.getItemFromBlock(block);
    if (item == Items.AIR) {
      continue;
    }
    NonNullList<ItemStack> subBlocks = NonNullList.create();
    block.getSubBlocks(CreativeTabs.SEARCH, subBlocks);
    for (ItemStack subBlock : subBlocks) {
      if (CoverManager.isValidCover(subBlock)) {
        ItemStack stack = new ItemStack(this);
        setItem(stack, subBlock);
        items.add(stack);
      }
    }
  }
}

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

public static void registerWithMapper(Block block) {
  if (block != null) {
    final String resourcePath = block.getRegistryName().toString();
    ModelLoader.setCustomStateMapper(block, new DefaultStateMapper() {
      protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
        return new ModelResourceLocation(resourcePath, this.getPropertyString(state.getProperties()));
      }
    });
    NonNullList<ItemStack> subBlocks = NonNullList.create();
    block.getSubBlocks(null, subBlocks);
    for (ItemStack stack : subBlocks) {
      IBlockState state = block.getStateFromMeta(stack.getMetadata());
      ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), stack.getMetadata(), new ModelResourceLocation(resourcePath, getPropertyString(state.getProperties())));
    }
  }
}

代码示例来源:origin: CoFH/ThermalExpansion

logBlock.getSubBlocks(logBlock.getCreativeTabToDisplayOn(), logVariants);

相关文章

Block类方法