示例#1
0
 @Override
 public void addModAsResource(ModContainer container) {
   Class<?> resourcePackType = container.getCustomResourcePackClass();
   if (resourcePackType != null) {
     try {
       ResourcePack pack =
           (ResourcePack)
               resourcePackType.getConstructor(ModContainer.class).newInstance(container);
       resourcePackList.add(pack);
       resourcePackMap.put(container.getModId(), pack);
     } catch (NoSuchMethodException e) {
       FMLLog.log(
           Level.SEVERE,
           "The container %s (type %s) returned an invalid class for it's resource pack.",
           container.getName(),
           container.getClass().getName());
       return;
     } catch (Exception e) {
       FMLLog.log(
           Level.SEVERE,
           e,
           "An unexpected exception occurred constructing the custom resource pack for %s",
           container.getName());
       throw Throwables.propagate(e);
     }
   }
 }
示例#2
0
  @SubscribeEvent
  public void onCrashReportEvent(CrashReportEvent event) {
    if (!diagnostics) return;
    if (event.getHeader().length() > 0) {
      return;
    }
    Throwable t = event.getThrowable();
    if (t instanceof LoaderException
        || t instanceof InvocationTargetException
        || t instanceof ReportedException) {
      t = t.getCause();
    }
    if (t == null) {
      return;
    }
    try {
      event.setHeader(handleThrowable(t));
    } catch (Throwable t2) {
      // Ignore any errors. We don't want to f**k up the crash reports.
    }
    List<ModContainer> mods = Utils.getModsFromStackTrace(event.getThrowable().getStackTrace());
    Set<ModContainer> s = Sets.newHashSet();
    ModContainer active = Loader.instance().activeModContainer();
    if (!mods.isEmpty() || (active != null && !active.getModId().equals("SquidAPI"))) {
      CrashReportCategory c = event.createCategory("Possibly involved mods");
      if (active != null && !active.getModId().equals("SquidAPI"))
        c.addCrashSection(
            active.getName(),
            String.format(
                "Version: %s. Main class: %s. Source: %s. Url: %s. Checksum: %s.",
                active.getVersion(),
                active.getMod().getClass().getName(),
                active.getSource().getName(),
                active.getMetadata().url,
                getChecksum(active.getSource())));
      for (ModContainer mod : mods) {
        if (!s.contains(mod)) {
          c.addCrashSection(
              mod.getName(),
              String.format(
                  "Version: %s. Main class: %s. Source: %s. Url: %s. Checksum: %s.",
                  mod.getVersion(),
                  mod.getMod().getClass().getName(),
                  mod.getSource().getName(),
                  mod.getMetadata().url,
                  getChecksum(mod.getSource())));
          s.add(mod);
        }
      }
    }
    try {
      if (Utils.isCoolSquid()) {
        event.setHeader("DRM!!! IT'S DRMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM!!!!!!!!!");
      }
    } catch (Throwable t2) {

    }
  }
  @Override
  public void addRecyclingRecipe(ItemStack recycledItem, String... blacklist) {

    bufferedRecyclingItems.add(recycledItem);
    if (blacklist.length > 0) {
      ModContainer mc = Loader.instance().activeModContainer();
      BluePower.log.info(
          (mc != null ? mc.getName() : "Unknown mod")
              + " added to the Alloy Furnace recycling blacklist: "
              + Arrays.toString(blacklist));
      Collections.addAll(this.blacklist, blacklist);
    }
  }
 @Override
 protected InputStream getInputStreamByName(String resourceName) throws IOException {
   try {
     return super.getInputStreamByName(resourceName);
   } catch (IOException ioe) {
     if ("pack.mcmeta".equals(resourceName)) {
       FMLLog.log(
           container.getName(),
           Level.WARNING,
           "Mod %s is missing a pack.mcmeta file, things may not work well",
           container.getName());
       return new ByteArrayInputStream(
           ("{\n"
                   + " \"pack\": {\n"
                   + "   \"description\": \"dummy FML pack for "
                   + container.getName()
                   + "\",\n"
                   + "   \"pack_format\": 1\n"
                   + "}\n"
                   + "}")
               .getBytes(Charsets.UTF_8));
     } else throw ioe;
   }
 }
  @Override

  /** Adds the buttons (and other controls) to the screen in question. */
  public void initGui() {
    for (ModContainer mod : mods) {
      listWidth = Math.max(listWidth, getFontRenderer().getStringWidth(mod.getName()) + 10);
      listWidth = Math.max(listWidth, getFontRenderer().getStringWidth(mod.getVersion()) + 10);
    }
    listWidth = Math.min(listWidth, 150);
    StringTranslate translations = StringTranslate.getInstance();
    this.controlList.add(
        new GuiSmallButton(
            6, this.width / 2 - 75, this.height - 38, translations.translateKey("gui.done")));
    this.modList = new GuiSlotModList(this, mods, listWidth);
    this.modList.registerScrollButtons(this.controlList, 7, 8);
  }
示例#6
0
	@EventHandler
	public void load(FMLInitializationEvent evt)
	{
		if (!Loader.isModLoaded("Railcraft"))
		{
			return;
		}
		try
		{
			String id = Block.blockRegistry.getNameForObject(MineFactoryReloadedCore.factoryDecorativeStoneBlock);
			FMLInterModComms.sendMessage("Railcraft", "balast", String.format("%s@%s", id, 8));
			FMLInterModComms.sendMessage("Railcraft", "balast", String.format("%s@%s", id, 9));
			// white sand? black sand?

			Object rockCrusher = Class.forName("mods.railcraft.api.crafting.RailcraftCraftingManager").getField("rockCrusher").get(null);
			Method createNewRecipe = Class.forName("mods.railcraft.api.crafting.IRockCrusherCraftingManager").getMethod("createNewRecipe", ItemStack.class, boolean.class, boolean.class);
			Method addOutput = Class.forName("mods.railcraft.api.crafting.IRockCrusherRecipe").getMethod("addOutput", ItemStack.class, float.class);

			Object recipe = createNewRecipe.invoke(rockCrusher, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 10), true, false);
			addOutput.invoke(recipe, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 2), 1.0f); // Paved Blackstone -> Cobble 

			recipe = createNewRecipe.invoke(rockCrusher, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 11), true, false);
			addOutput.invoke(recipe, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 3), 1.0f); // Paved Whitestone -> Cobble

			recipe = createNewRecipe.invoke(rockCrusher, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 0), true, false);
			addOutput.invoke(recipe, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 2), 1.0f); // Smooth Blackstone -> Cobble 

			recipe = createNewRecipe.invoke(rockCrusher, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 1), true, false);
			addOutput.invoke(recipe, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 3), 1.0f); // Smooth Whitestone -> Cobble

			recipe = createNewRecipe.invoke(rockCrusher, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 2), true, false);
			addOutput.invoke(recipe, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 8), 1.0f); // Cobble Blackstone -> Gravel + flint
			addOutput.invoke(recipe, new ItemStack(Items.flint, 1, 0), 0.05f);

			recipe = createNewRecipe.invoke(rockCrusher, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 3), true, false);
			addOutput.invoke(recipe, new ItemStack(MineFactoryReloadedCore.factoryDecorativeStoneBlock, 1, 9), 1.0f); // Cobble Whitestone -> Gravel + flint
			addOutput.invoke(recipe, new ItemStack(Items.flint, 1, 0), 0.05f);
		}
		catch (Throwable _)
		{
			ModContainer This = FMLCommonHandler.instance().findContainerFor(this);
			FMLLog.log(This.getModId(), Level.WARN, "There was a problem loading %s.", This.getName());
			_.printStackTrace();
		}
	}
 @Override
 public String getPackName() {
   return "FMLFileResourcePack:" + container.getName();
 }
  @Override

  /** Draws the screen and all the components in it. */
  public void drawScreen(int p_571_1_, int p_571_2_, float p_571_3_) {
    this.modList.drawScreen(p_571_1_, p_571_2_, p_571_3_);
    this.drawCenteredString(this.fontRenderer, "Mod List", this.width / 2, 16, 0xFFFFFF);
    int offset = this.listWidth + 20;
    if (selectedMod != null) {
      GL11.glEnable(GL11.GL_BLEND);
      if (!selectedMod.getMetadata().autogenerated) {
        int shifty = 35;
        if (!selectedMod.getMetadata().logoFile.isEmpty()) {
          int texture = this.mc.renderEngine.getTexture(selectedMod.getMetadata().logoFile);
          GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
          this.mc.renderEngine.bindTexture(texture);
          Dimension dim = TextureFXManager.instance().getTextureDimensions(texture);
          int top = 32;
          Tessellator tess = Tessellator.instance;
          tess.startDrawingQuads();
          tess.addVertexWithUV(offset, top + dim.height, zLevel, 0, 1);
          tess.addVertexWithUV(offset + dim.width, top + dim.height, zLevel, 1, 1);
          tess.addVertexWithUV(offset + dim.width, top, zLevel, 1, 0);
          tess.addVertexWithUV(offset, top, zLevel, 0, 0);
          tess.draw();

          shifty += 65;
        }
        this.fontRenderer.drawStringWithShadow(
            selectedMod.getMetadata().name, offset, shifty, 0xFFFFFF);
        shifty += 12;

        shifty =
            drawLine(
                String.format(
                    "Version: %s (%s)",
                    selectedMod.getMetadata().version, selectedMod.getVersion()),
                offset,
                shifty);
        shifty =
            drawLine(
                String.format("Mod State: %s", Loader.instance().getModState(selectedMod)),
                offset,
                shifty);
        if (!selectedMod.getMetadata().credits.isEmpty()) {
          shifty =
              drawLine(
                  String.format("Credits: %s", selectedMod.getMetadata().credits), offset, shifty);
        }
        shifty =
            drawLine(
                String.format("Authors: %s", selectedMod.getMetadata().getAuthorList()),
                offset,
                shifty);
        shifty = drawLine(String.format("URL: %s", selectedMod.getMetadata().url), offset, shifty);
        shifty =
            drawLine(
                selectedMod.getMetadata().childMods.isEmpty()
                    ? "No child mods for this mod"
                    : String.format("Child mods: %s", selectedMod.getMetadata().getChildModList()),
                offset,
                shifty);
        this.getFontRenderer()
            .drawSplitString(
                selectedMod.getMetadata().description,
                offset,
                shifty + 10,
                this.width - offset - 20,
                0xDDDDDD);
      } else {
        offset = (this.listWidth + this.width) / 2;
        this.drawCenteredString(this.fontRenderer, selectedMod.getName(), offset, 35, 0xFFFFFF);
        this.drawCenteredString(
            this.fontRenderer,
            String.format("Version: %s", selectedMod.getVersion()),
            offset,
            45,
            0xFFFFFF);
        this.drawCenteredString(
            this.fontRenderer,
            String.format("Mod State: %s", Loader.instance().getModState(selectedMod)),
            offset,
            55,
            0xFFFFFF);
        this.drawCenteredString(
            this.fontRenderer, "No mod information found", offset, 65, 0xDDDDDD);
        this.drawCenteredString(
            this.fontRenderer,
            "Ask your mod author to provide a mod mcmod.info file",
            offset,
            75,
            0xDDDDDD);
      }
      GL11.glDisable(GL11.GL_BLEND);
    }
    super.drawScreen(p_571_1_, p_571_2_, p_571_3_);
  }