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

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

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

Block.setTranslationKey介绍

暂无

代码示例

代码示例来源:origin: thraaawn/CompactMachines

@Override
  public Block setTranslationKey(String name) {
    if(!name.startsWith(CompactMachines3.MODID + ".")) {
      name = CompactMachines3.MODID + "." + name;
    }
    return super.setTranslationKey(name);
  }
}

代码示例来源:origin: TerraFirmaCraft/TerraFirmaCraft

private static <T extends Block> T register(IForgeRegistry<Block> r, String name, T block)
{
  block.setRegistryName(MOD_ID, name);
  block.setTranslationKey(MOD_ID + "." + name.replace('/', '.'));
  r.register(block);
  return block;
}

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

/**
 * Registers a block to the game. This will also set the unlocalized name, and creative tab
 * if {@link #tab} has been set. The block will also be cached in {@link #blocks}.
 *
 * @param block The block to register.
 * @param itemBlock The ItemBlock for the block.
 * @param id The id to register the block with.
 * @return The block being registered.
 */
public Block registerBlock (@Nonnull Block block, @Nonnull ItemBlock itemBlock, @Nonnull String id) {
  block.setRegistryName(this.modid, id);
  block.setTranslationKey(this.modid + "." + id.toLowerCase().replace("_", "."));
  this.blocks.add(block);
  this.registerItem(itemBlock, id);
  if (this.tab != null) {
    block.setCreativeTab(this.tab);
  }
  if (block instanceof IColorfulBlock) {
    this.coloredBlocks.add(block);
  }
  if (block instanceof ITileEntityBlock) {
    this.tileProviders.add((ITileEntityBlock) block);
  }
  return block;
}

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

public static void registerBlock(Block block, ItemBlockBase itemBlock, String name, boolean addTab){
  block.setTranslationKey(ActuallyAdditions.MODID+"."+name);
  block.setRegistryName(ActuallyAdditions.MODID, name);
  RegistryHandler.BLOCKS_TO_REGISTER.add(block);
  itemBlock.setRegistryName(block.getRegistryName());
  RegistryHandler.ITEMS_TO_REGISTER.add(itemBlock);
  block.setCreativeTab(addTab ? CreativeTab.INSTANCE : null);
  IMCHandler.doBlockIMC(block);
  if(block instanceof IColorProvidingBlock){
    ActuallyAdditions.PROXY.addColoredBlock(block);
  }
}

代码示例来源:origin: PrinceOfAmber/Cyclic

public static void registerBlock(@Nonnull Block b, ItemBlock ib, @Nonnull String name, @Nullable GuideCategory cat, boolean inCreativeTab) {
 if (inCreativeTab) {
  b.setCreativeTab(ModCyclic.TAB);
 }
 b.setRegistryName(new ResourceLocation(Const.MODID, name));
 b.setTranslationKey(name);
 if (b instanceof IHasConfig) {
  ConfigRegistry.register((IHasConfig) b);
 }
 if (ib != null) {
  ib.setRegistryName(b.getRegistryName()); // ok good this should work yes? yes! http://mcforge.readthedocs.io/en/latest/blocks/blocks/#registering-a-block
  ItemRegistry.itemList.add(ib);
 }
 blocks.add(b);
 if (cat != null) {
  if (ib == null) {
   GuideRegistry.register(cat, b);
  }
  else {
   GuideRegistry.register(cat, ib);
  }
 }
}

代码示例来源:origin: Esteemed-Innovation/Esteemed-Innovation

/**
 * Sets up a Block with an unlocalized name, a registry name, an optional creative tab, and registers it to the
 * Block registry.
 * @param event The event to register on
 * @param startingBlock The block to start with
 * @param path The name of the block, excluding the EI mod ID
 * @param tab The creative tab to add it to. Use null to not add it to any tab. You will have to cast the null to
 *                      {@link CreativeTabs}.
 * @return The registered block (ItemBlock is not returned).
 */
protected Block setup(RegistryEvent.Register<Block> event, Block startingBlock, String path, CreativeTabs tab) {
  startingBlock.setTranslationKey(Constants.EI_MODID + ":" + path);
  if (tab != null) {
    startingBlock.setCreativeTab(tab);
  }
  startingBlock.setRegistryName(Constants.EI_MODID, path);
  event.getRegistry().register(startingBlock);
  return startingBlock;
}

代码示例来源:origin: ForestryMC/ForestryMC

protected <T extends Block> void registerBlock(T block, @Nullable ItemBlock itemBlock, String name) {
  if (ModuleManager.getInternalHandler().getStage() != InternalModuleHandler.Stage.REGISTER) {
    throw new RuntimeException("Tried to register Block outside of REGISTER");
  }
  if (!name.equals(name.toLowerCase(Locale.ENGLISH))) {
    Log.error("Name must be lowercase");
  }
  block.setTranslationKey("for." + name);
  block.setRegistryName(name);
  ForgeRegistries.BLOCKS.register(block);
  Proxies.common.registerBlock(block);
  MigrationHelper.addBlockName(name);
  if (itemBlock != null) {
    itemBlock.setRegistryName(name);
    ForgeRegistries.ITEMS.register(itemBlock);
    Proxies.common.registerItem(itemBlock);
    MigrationHelper.addItemName(name);
  }
}

代码示例来源:origin: NanamiArihara/FoodCraft-Reloaded

@Load(value = LoaderState.CONSTRUCTING)
public void registerBlocks() {
  for (Field field : FCRBlocks.class.getFields()) {
    field.setAccessible(true);
    RegBlock anno = field.getAnnotation(RegBlock.class);
    if (anno==null) continue;
    try {
      Block block = (Block) field.get(null);
      RegisterManager.getInstance().putRegister(block.setRegistryName(FoodCraftReloadedMod.MODID, NameBuilder.buildRegistryName(anno.value())).setTranslationKey(NameBuilder.buildUnlocalizedName(anno.value())));
      // Register item block.
      Class<? extends ItemBlock> itemClass = anno.itemClass();
      Constructor<? extends ItemBlock> con = itemClass.getConstructor(Block.class);
      con.setAccessible(true);
      RegisterManager.getInstance().putRegister(con.newInstance(block).setRegistryName(block.getRegistryName()).setTranslationKey(block.getTranslationKey()));
      Arrays.asList(anno.oreDict()).forEach(s -> OreDictionary.registerOre(s, block));
    } catch (Exception e) {
      FoodCraftReloaded.getLogger().warn("Un-able to register block " + field.toGenericString(), e);
    }
  }
}

代码示例来源:origin: ForestryMC/ForestryMC

private static void createBlock(Fluids forestryFluid) {
  Fluid fluid = forestryFluid.getFluid();
  Preconditions.checkNotNull(fluid);
  Block fluidBlock = fluid.getBlock();
  if (Config.isBlockEnabled(forestryFluid.getTag())) {
    if (fluidBlock == null) {
      fluidBlock = forestryFluid.makeBlock();
      if (fluidBlock != null) {
        String name = "fluid." + forestryFluid.getTag();
        fluidBlock.setTranslationKey("forestry." + name);
        fluidBlock.setRegistryName(name);
        ForgeRegistries.BLOCKS.register(fluidBlock);
        ItemBlock itemBlock = new ItemBlock(fluidBlock);
        itemBlock.setRegistryName(name);
        ForgeRegistries.ITEMS.register(itemBlock);
        Proxies.render.registerFluidStateMapper(fluidBlock, forestryFluid);
        if (forestryFluid.getOtherContainers().isEmpty()) {
          FluidRegistry.addBucketForFluid(fluid);
        }
      }
    } else {
      ResourceLocation resourceLocation = ForgeRegistries.BLOCKS.getKey(fluidBlock);
      Log.warning("Pre-existing {} fluid block detected, deferring to {}:{}, "
        + "this may cause issues if the server/client have different mod load orders, "
        + "recommended that you disable all but one instance of {} fluid blocks via your configs.", fluid.getName(), resourceLocation.getNamespace(), resourceLocation.getPath(), fluid.getName());
    }
  }
}

相关文章

Block类方法