示例#1
0
 public BlockHandler(Block bloc, String... names) {
   super(names[0]);
   this.block = bloc;
   if (block != null) {
     block
         .setBlockName(names[0])
         .setBlockTextureName(names[1])
         .setCreativeTab(Steamcraft.steamTab); // finalizing the block
     if (names.length > 2) {
       oreName = names[2];
     }
     if (block.hasTileEntity(0)) {
       GameRegistry.registerTileEntity(
           block.createTileEntity(null, 0).getClass(), block.getUnlocalizedName());
     }
   }
 }
  @Override
  public void registerBlock(
      ModManager manager,
      String name,
      String modPrefix,
      Block block,
      Class<? extends ItemBlock> itemBlock) {
    super.registerBlock(manager, name, modPrefix, block, itemBlock);

    // Set block name if it is missing
    if (block.getUnlocalizedName() == null || block.getUnlocalizedName().contains("null")) {
      block.setBlockName((modPrefix != null ? modPrefix : "") + name);
    }

    // Set texture name if it is missing
    if (modPrefix != null && (block.textureName == null || block.textureName.isEmpty())) {
      block.setBlockTextureName(modPrefix + name);
    }

    // Sets creative tab if it is missing
    if (manager.defaultTab != null && block.getCreativeTabToDisplayOn() == null) {
      block.setCreativeTab(manager.defaultTab);
    }
  }
  @EventHandler
  public void init(FMLInitializationEvent event) {
    NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());

    logger.info("Registering chunk load handler");
    ForgeChunkManager.setForcedChunkLoadingCallback(this, new ChunkLoadingHandler());
    chunkLoadViewer = new ChunkLoadViewDataProxy(chunkSightRange);
    FMLCommonHandler.instance().bus().register(chunkLoadViewer);

    proxy.registerKeyHandler();

    proxy.registerRendering();

    loadConfigs(true);

    logger.info("Registering pipes");
    loadPipes();

    triggerPipeClosed = new TriggerPipeClosed("APClosed");
    ActionManager.registerTriggerProvider(new GateProvider());

    if (allowWRRemove) {
      // Additional Pipes
      GameRegistry.addRecipe(
          new ItemStack(pipeItemsTeleport), new Object[] {"A", 'A', pipePowerTeleport});
      GameRegistry.addRecipe(
          new ItemStack(pipeItemsTeleport), new Object[] {"A", 'A', pipeLiquidsTeleport});
      GameRegistry.addRecipe(
          new ItemStack(pipeItemsRedStone), new Object[] {"A", 'A', pipeLiquidsRedstone});
      // BC Liquid
      GameRegistry.addRecipe(
          new ItemStack(BuildCraftTransport.pipeItemsCobblestone),
          new Object[] {"A", 'A', BuildCraftTransport.pipeFluidsCobblestone});
      GameRegistry.addRecipe(
          new ItemStack(BuildCraftTransport.pipeItemsGold),
          new Object[] {"A", 'A', BuildCraftTransport.pipeFluidsGold});
      GameRegistry.addRecipe(
          new ItemStack(BuildCraftTransport.pipeItemsIron),
          new Object[] {"A", 'A', BuildCraftTransport.pipeFluidsIron});
      GameRegistry.addRecipe(
          new ItemStack(BuildCraftTransport.pipeItemsStone),
          new Object[] {"A", 'A', BuildCraftTransport.pipeFluidsStone});
      GameRegistry.addRecipe(
          new ItemStack(BuildCraftTransport.pipeItemsWood),
          new Object[] {"A", 'A', BuildCraftTransport.pipeFluidsWood});
      // BC Power
      GameRegistry.addRecipe(
          new ItemStack(BuildCraftTransport.pipeItemsGold),
          new Object[] {"A", 'A', BuildCraftTransport.pipePowerGold});
      GameRegistry.addRecipe(
          new ItemStack(BuildCraftTransport.pipeItemsStone),
          new Object[] {"A", 'A', BuildCraftTransport.pipePowerStone});
      GameRegistry.addRecipe(
          new ItemStack(BuildCraftTransport.pipeItemsWood),
          new Object[] {"A", 'A', BuildCraftTransport.pipePowerWood});
    }

    // ChunkLoader
    blockChunkLoader = new BlockChunkLoader();
    blockChunkLoader.setBlockName("TeleportTether");
    GameRegistry.registerBlock(blockChunkLoader, ItemBlock.class, "chunkLoader");
    GameRegistry.registerTileEntity(TileChunkLoader.class, "TeleportTether");
    GameRegistry.addRecipe(
        new ItemStack(blockChunkLoader),
        new Object[] {
          "iii", "iLi", "iii", 'i', Items.iron_ingot, 'L', new ItemStack(Items.dye, 1, 4)
        });
  }