예제 #1
0
  public static void setWorld(int id, WorldServer world) {
    if (world != null) {
      worlds.put(id, world);
      weakWorldMap.put(world, world);
      MinecraftServer.getServer().worldTickTimes.put(id, new long[100]);
      FMLLog.info(
          "Loading dimension %d (%s) (%s)",
          id, world.getWorldInfo().getWorldName(), world.getMinecraftServer());
    } else {
      worlds.remove(id);
      MinecraftServer.getServer().worldTickTimes.remove(id);
      FMLLog.info("Unloading dimension %d", id);
    }

    ArrayList<WorldServer> tmp = new ArrayList<WorldServer>();
    if (worlds.get(0) != null) tmp.add(worlds.get(0));
    if (worlds.get(-1) != null) tmp.add(worlds.get(-1));
    if (worlds.get(1) != null) tmp.add(worlds.get(1));

    for (Entry<Integer, WorldServer> entry : worlds.entrySet()) {
      int dim = entry.getKey();
      if (dim >= -1 && dim <= 1) {
        continue;
      }
      tmp.add(entry.getValue());
    }

    MinecraftServer.getServer().worldServers = tmp.toArray(new WorldServer[tmp.size()]);
  }
예제 #2
0
  /**
   * Generate one single component from the list. Min and max values from SubComponentData will be
   * ignored
   *
   * @param subCompData
   * @param rand
   * @return
   */
  protected BaseStructureComponent generateOneComponent(
      ArrayList<SubComponentData> subCompData, Random rand) {

    BaseStructureComponent result = null;
    Class<? extends BaseStructureComponent> resultClass = null;

    for (SubComponentData entry : subCompData) {
      if (entry.probability < rand.nextFloat()) {
        resultClass = entry.clazz;
        break;
      }
    }
    if (resultClass == null) {
      // as fallback
      int i = MathHelper.getRandomIntegerInRange(rand, 0, subCompData.size() - 1);
      resultClass = subCompData.get(i).clazz;
    }

    try {

      result = resultClass.getConstructor().newInstance();
    } catch (Throwable e) {
      FMLLog.info("Instantiating " + resultClass.getCanonicalName() + " failed");
      e.printStackTrace();
    }

    return result;
  }
예제 #3
0
 /**
  * Just takes the "clazz" member of the entry and tries to create a new instance of it
  *
  * <p>helper for generateSubComponents
  *
  * @param entry
  * @return
  */
 private BaseStructureComponent generateComponent(SubComponentData entry) {
   try {
     return entry.clazz.getConstructor().newInstance();
   } catch (Throwable e) {
     FMLLog.info("Instantiating " + entry.clazz.getCanonicalName() + " failed");
     e.printStackTrace();
   }
   return null;
 }
 public BlockOrangeSpectra(Fluid fluid, Material material) {
   super(fluid, material);
   setBlockName("OrangeSpectra");
   setLightLevel(1.0f);
   try {
     coloredlightscore.src.api.CLApi.setBlockColorRGB(this, 15, 10, 7);
   } catch (Throwable e) {
     FMLLog.info("The ColoredLightCore is not installed, or it didn't load properly");
   }
   // setCreativeTab(rainbowwater.tabFluids);
 }
예제 #5
0
  /**
   * Called to start the whole game off
   *
   * @param minecraft The minecraft instance being launched
   * @param resourcePackList The resource pack list we will populate with mods
   * @param resourceManager The resource manager
   */
  public void beginMinecraftLoading(
      Minecraft minecraft, List resourcePackList, ReloadableResourceManager resourceManager) {
    client = minecraft;
    this.resourcePackList = resourcePackList;
    this.resourceManager = resourceManager;
    this.resourcePackMap = Maps.newHashMap();
    if (minecraft.func_71355_q()) {
      FMLLog.severe("DEMO MODE DETECTED, FML will not work. Finishing now.");
      haltGame("FML will not run in demo mode", new RuntimeException());
      return;
    }

    //        TextureFXManager.instance().setClient(client);
    FMLCommonHandler.instance().beginLoading(this);
    new ModLoaderClientHelper(client);
    try {
      Class<?> optifineConfig =
          Class.forName("Config", false, Loader.instance().getModClassLoader());
      String optifineVersion = (String) optifineConfig.getField("VERSION").get(null);
      Map<String, Object> dummyOptifineMeta =
          ImmutableMap.<String, Object>builder()
              .put("name", "Optifine")
              .put("version", optifineVersion)
              .build();
      ModMetadata optifineMetadata =
          MetadataCollection.from(getClass().getResourceAsStream("optifinemod.info"), "optifine")
              .getMetadataForId("optifine", dummyOptifineMeta);
      optifineContainer = new DummyModContainer(optifineMetadata);
      FMLLog.info(
          "Forge Mod Loader has detected optifine %s, enabling compatibility features",
          optifineContainer.getVersion());
    } catch (Exception e) {
      optifineContainer = null;
    }
    try {
      Loader.instance().loadMods();
    } catch (WrongMinecraftVersionException wrong) {
      wrongMC = wrong;
    } catch (DuplicateModsFoundException dupes) {
      dupesFound = dupes;
    } catch (MissingModsException missing) {
      modsMissing = missing;
    } catch (ModSortingException sorting) {
      modSorting = sorting;
    } catch (CustomModLoadingErrorDisplayException custom) {
      FMLLog.log(
          Level.SEVERE, custom, "A custom exception was thrown by a mod, the game will now halt");
      customError = custom;
    } catch (LoaderException le) {
      haltGame(
          "There was a severe problem during mod loading that has caused the game to fail", le);
      return;
    }
  }
예제 #6
0
  private static <T extends Enchantment> T registerEnchantment(
      Class<? extends Enchantment> enchantmentClass,
      int weight,
      String configID,
      int default_value) {
    int start_value = AMCore.config.getConfigurableEnchantmentID(configID, default_value);
    int enchID = start_value;
    boolean fullcircle = true;
    do {
      if (Enchantment.enchantmentsList[enchID] == null) {
        fullcircle = false;
        break;
      }
      enchID++;
      enchID %= Enchantment.enchantmentsList.length;
    } while (enchID != start_value);

    if (fullcircle) {
      throw new ArrayIndexOutOfBoundsException(
          "All enchantment IDs are in use...can't find a free one to take!");
    }

    FMLLog.info(
        "Ars Magica 2 >> Attempting to set enchantment %s to ID %d (configured currently as %d)",
        configID, enchID, start_value);
    AMCore.config.updateConfigurableEnchantmentID(configID, enchID);

    try {
      T ench =
          (T) enchantmentClass.getConstructor(int.class, int.class).newInstance(enchID, weight);
      FMLLog.info("Ars Magica 2 >> Successfully registered enchanment!");
      return ench;
    } catch (Throwable t) {
      FMLLog.info("Ars Magica 2 >> Failed to register enchantment %s!", configID);
      t.printStackTrace();
    }
    return null;
  }
예제 #7
0
 private void initSpawnsForBiomeTypes(
     SpawnListEntry spawnListEntry,
     EnumCreatureType creatureType,
     Type[] types,
     Type[] exclusions) {
   if (spawnListEntry.itemWeight == 0) {
     FMLLog.info(
         "Ars Magica 2 >> Skipping spawn list entry for %s (as type %s), as the weight is set to 0.  This can be changed in config.",
         spawnListEntry.entityClass.getName(), creatureType.toString());
     return;
   }
   for (Type type : types) {
     initSpawnsForBiomes(
         BiomeDictionary.getBiomesForType(type), spawnListEntry, creatureType, exclusions);
   }
 }
예제 #8
0
 protected void recursivePopulate(
     World world, int xChunkCoord, int zChunkCoord, int origXChunkCoord, int origZChunkCoord) {
   Long key = Long.valueOf(ChunkCoordIntPair.chunkXZ2Int(xChunkCoord, zChunkCoord));
   if (structureMap.containsKey(key)) {
     BaseStructureStart start = structureMap.get(key);
     start.populateChunk(world, origXChunkCoord, origZChunkCoord);
   } else {
     FMLLog.info(
         "No "
             + this.getName()
             + " for population for coords "
             + (xChunkCoord * 16)
             + "/"
             + (zChunkCoord * 16)
             + ", that's weird...");
   }
 }
예제 #9
0
파일: Patcher.java 프로젝트: reteo/SI-Mods
  public static ToolMaterial patchToolMaterial(
      ToolMaterial toolmat,
      int harvestLevel,
      int maxUses,
      float efficiency,
      float damageVsEntity,
      int enchantability) {
    FMLLog.info("[si.core] [patcher] Patching ToolMaterial " + toolmat.name());

    new Reflector(toolmat)
        .set("field_78001_f", harvestLevel)
        .set("field_78002_g", maxUses)
        .set("field_78010_h", efficiency)
        .set("field_78011_i", damageVsEntity)
        .set("field_78008_j", enchantability);

    return toolmat;
  }
예제 #10
0
파일: Patcher.java 프로젝트: reteo/SI-Mods
  public static void patchTools() {

    FMLControlledNamespacedRegistry<Item> gamereg = GameData.getItemRegistry();

    @SuppressWarnings("unchecked")
    Set<String> allItems = GameData.getItemRegistry().getKeys();

    for (String itemname : allItems) {

      Item item = gamereg.getObject(itemname);
      if (item instanceof ItemTool || item instanceof ItemHoe || item instanceof ItemSword) {

        if (item.getClass().getCanonicalName().contains("Reika.RotaryCraft")) {
          continue;
        }

        ToolMaterial toolmat = null;
        String toolmatname = null;
        if (item instanceof ItemTool) toolmatname = ((ItemTool) item).getToolMaterialName();
        else if (item instanceof ItemHoe) toolmatname = ((ItemHoe) item).getToolMaterialName();
        else if (item instanceof ItemSword) toolmatname = ((ItemSword) item).getToolMaterialName();

        if (toolmatname == null) {
        } else {
          try {
            toolmat = ToolMaterial.valueOf(toolmatname);
          } catch (IllegalArgumentException e) {
            toolmat = null;
          }
        }

        if (toolmat == null) {
        } else {
          // Update the tool material
          if (item instanceof ItemTool) {
            if (item.getClass().getCanonicalName().contains("fi.dy.masa.enderutilities")) {
              Reflector endertoolreflector = new Reflector(item, ItemEnderTool.class);
              endertoolreflector
                  .set("material", toolmat)
                  .set("field_77865_bY", toolmat.getDamageVsEntity() + 2F)
                  .set("field_77864_a", toolmat.getEfficiencyOnProperMaterial());

            } else {
              Reflector itemreflector = new Reflector(item, ItemTool.class);
              Float damagemodifier = 0F;
              if (item instanceof ItemAxe) damagemodifier = 3F;
              if (item instanceof ItemPickaxe) damagemodifier = 2F;
              if (item instanceof ItemSpade) damagemodifier = 1F;

              itemreflector
                  .set("field_77862_b", toolmat)
                  .set("field_77865_bY", toolmat.getDamageVsEntity() + damagemodifier)
                  .set("field_77864_a", toolmat.getEfficiencyOnProperMaterial());
            }
          }
          if (item instanceof ItemHoe) {
            new Reflector(item, ItemHoe.class).set("field_77843_a", toolmat);
          }
          if (item instanceof ItemSword) {
            new Reflector(item, ItemSword.class)
                .set("field_150933_b", toolmat)
                .set("field_150934_a", toolmat.getDamageVsEntity() + 4F);
          }

          // Update the max damage
          if (item.getMaxDamage() > 0) item.setMaxDamage(toolmat.getMaxUses());

          if (item instanceof ItemTool)
            FMLLog.info(
                "[si.core] [tool patcher] is a "
                    + ((ItemTool) item).getToolMaterialName()
                    + " tool");
          if (item instanceof ItemHoe)
            FMLLog.info(
                "[si.core] [tool patcher] is a " + ((ItemHoe) item).getToolMaterialName() + " hoe");
          if (item instanceof ItemSword)
            FMLLog.info(
                "[si.core] [tool patcher] is a "
                    + ((ToolMaterial) new Reflector(item, ItemSword.class).get("field_150933_b"))
                        .name()
                    + " weapon (basically a sword)");
        }
      }
    }
  }
예제 #11
0
  @Override
  public void execute(
      INetworkManager network, FMLNetworkHandler handler, NetHandler netHandler, String userName) {
    Map<String, ModContainer> indexedModList =
        Maps.newHashMap(Loader.instance().getIndexedModList());
    List<String> missingClientMods = Lists.newArrayList();
    List<String> versionIncorrectMods = Lists.newArrayList();

    for (String m : missingMods) {
      ModContainer mc = indexedModList.get(m);
      NetworkModHandler networkMod = handler.findNetworkModHandler(mc);
      if (networkMod.requiresClientSide()) {
        missingClientMods.add(m);
      }
    }

    for (Entry<String, String> modVersion : modVersions.entrySet()) {
      ModContainer mc = indexedModList.get(modVersion.getKey());
      NetworkModHandler networkMod = handler.findNetworkModHandler(mc);
      if (!networkMod.acceptVersion(modVersion.getValue())) {
        versionIncorrectMods.add(modVersion.getKey());
      }
    }

    Packet250CustomPayload pkt = new Packet250CustomPayload();
    pkt.field_73630_a = "FML";
    if (missingClientMods.size() > 0 || versionIncorrectMods.size() > 0) {
      pkt.field_73629_c =
          FMLPacket.makePacket(MOD_MISSING, missingClientMods, versionIncorrectMods);
      Logger.getLogger("Minecraft")
          .info(
              String.format(
                  "User %s connection failed: missing %s, bad versions %s",
                  userName, missingClientMods, versionIncorrectMods));
      FMLLog.info(
          "User %s connection failed: missing %s, bad versions %s",
          userName, missingClientMods, versionIncorrectMods);
      // Mark this as bad
      FMLNetworkHandler.setHandlerState(
          (NetLoginHandler) netHandler, FMLNetworkHandler.MISSING_MODS_OR_VERSIONS);
      pkt.field_73628_b = pkt.field_73629_c.length;
      network.func_74429_a(pkt);
    } else {
      pkt.field_73629_c = FMLPacket.makePacket(MOD_IDENTIFIERS, netHandler);
      Logger.getLogger("Minecraft")
          .info(String.format("User %s connecting with mods %s", userName, modVersions.keySet()));
      FMLLog.info("User %s connecting with mods %s", userName, modVersions.keySet());
      pkt.field_73628_b = pkt.field_73629_c.length;
      network.func_74429_a(pkt);
      NBTTagList itemList = new NBTTagList();
      GameData.writeItemData(itemList);
      byte[][] registryPackets = FMLPacket.makePacketSet(MOD_IDMAP, itemList);
      for (int i = 0; i < registryPackets.length; i++) {
        network.func_74429_a(PacketDispatcher.getPacket("FML", registryPackets[i]));
      }
    }

    // reset the continuation flag - we have completed extra negotiation and the login should
    // complete now
    NetLoginHandler.func_72531_a((NetLoginHandler) netHandler, true);
  }
예제 #12
0
  @SuppressWarnings("unused")
  public static final void init() {

    /*
     *
     * Debug Parameters area
     *
     */

    // Logs
    if (!DEBUG) {
      FMLLog.info("Development mode not enabled.");
    } else if (DEBUG) {
      FMLLog.info("Development mode enabled.");
    } else {
      FMLLog.info("Development mode not set.");
    }

    /*
     * End Debug
     */

    // Blood Steel Equipment

    // Item Init
    tutPickaxe =
        new BloodSteelPickaxe(tutMaterial)
            .setUnlocalizedName("BloodSteelPickaxe")
            .setCreativeTab(TMCreativeTabs.tabTools)
            .setTextureName(Strings.MODID + ":BloodSteelPickaxe");
    tutAxe =
        new BloodSteelAxe(tutMaterial)
            .setUnlocalizedName("BloodSteelAxe")
            .setCreativeTab(TMCreativeTabs.tabTools)
            .setTextureName(Strings.MODID + ":BloodSteelAxe");
    tutSword =
        new BloodSteelSword(tutMaterial)
            .setUnlocalizedName("BloodSteelSword")
            .setCreativeTab(TMCreativeTabs.tabCombat)
            .setTextureName(Strings.MODID + ":BloodSteelSword");
    tutHoe =
        new BloodSteelHoe(tutMaterial)
            .setUnlocalizedName("BloodSteelHoe")
            .setCreativeTab(TMCreativeTabs.tabTools)
            .setTextureName(Strings.MODID + ":BloodSteelHoe");
    tutSpade =
        new BloodSteelSpade(tutMaterial)
            .setUnlocalizedName("BloodSteelSpade")
            .setCreativeTab(TMCreativeTabs.tabTools)
            .setTextureName(Strings.MODID + ":BloodSteelSpade");
    tutHelmet =
        new BloodSteelArmor(tutArmorMaterial, MiscUtils.proxy.addArmor("BloodSteelArmor"), 0)
            .setUnlocalizedName("BloodSteelHelmet")
            .setCreativeTab(TMCreativeTabs.tabCombat)
            .setTextureName(Strings.MODID + ":BloodSteelHelmet");
    tutPlate =
        new BloodSteelArmor(tutArmorMaterial, MiscUtils.proxy.addArmor("BloodSteelArmor"), 1)
            .setUnlocalizedName("BloodSteelPlate")
            .setCreativeTab(TMCreativeTabs.tabCombat)
            .setTextureName(Strings.MODID + ":BloodSteelPlate");
    tutPants =
        new BloodSteelArmor(tutArmorMaterial, MiscUtils.proxy.addArmor("BloodSteelArmor"), 2)
            .setUnlocalizedName("BloodSteelPants")
            .setCreativeTab(TMCreativeTabs.tabCombat)
            .setTextureName(Strings.MODID + ":BloodSteelPants");
    tutBoots =
        new BloodSteelArmor(tutArmorMaterial, MiscUtils.proxy.addArmor("BloodSteelArmor"), 3)
            .setUnlocalizedName("BloodSteelBoots")
            .setCreativeTab(TMCreativeTabs.tabCombat)
            .setTextureName(Strings.MODID + ":BloodSteelBoots");

    // Registry
    GameRegistry.registerItem(tutPickaxe, tutPickaxe.getUnlocalizedName());
    GameRegistry.registerItem(tutAxe, tutAxe.getUnlocalizedName());
    GameRegistry.registerItem(tutSword, tutSword.getUnlocalizedName());
    GameRegistry.registerItem(tutHoe, tutHoe.getUnlocalizedName());
    GameRegistry.registerItem(tutSpade, tutSpade.getUnlocalizedName());
    GameRegistry.registerItem(tutHelmet, tutHelmet.getUnlocalizedName());
    GameRegistry.registerItem(tutPlate, tutPlate.getUnlocalizedName());
    GameRegistry.registerItem(tutPants, tutPants.getUnlocalizedName());
    GameRegistry.registerItem(tutBoots, tutBoots.getUnlocalizedName());

    // EnderIO Resources
    if (Loader.isModLoaded("EnderIO") == true || DEBUG) {
      FMLLog.info("EnderIO Found - Loading Resources");
      // Item Init
      itemPlateSoularium =
          new Item()
              .setUnlocalizedName("itemPlateSoularium")
              .setCreativeTab(TMCreativeTabs.tabMisc)
              .setTextureName(Strings.MODID + ":itemPlateSoularium");
      ;
      itemPlateRedstoneAlloy =
          new Item()
              .setUnlocalizedName("itemPlateRedstoneAlloy")
              .setCreativeTab(TMCreativeTabs.tabMisc)
              .setTextureName(Strings.MODID + ":itemPlateRedstoneAlloy");
      ;
      itemPlateElectricalSteel =
          new Item()
              .setUnlocalizedName("itemPlateElectricalSteel")
              .setCreativeTab(TMCreativeTabs.tabMisc)
              .setTextureName(Strings.MODID + ":itemPlateElectricalSteel");
      ;
      itemPlatePulsatingIron =
          new Item()
              .setUnlocalizedName("itemPlatePulsatingIron")
              .setCreativeTab(TMCreativeTabs.tabMisc)
              .setTextureName(Strings.MODID + ":itemPlatePulsatingIron");
      ;
      itemPlateEnergeticAlloy =
          new Item()
              .setUnlocalizedName("itemPlateEnergeticAlloy")
              .setCreativeTab(TMCreativeTabs.tabMisc)
              .setTextureName(Strings.MODID + ":itemPlateEnergeticAlloy");
      ;
      itemPlateVibrantAlloy =
          new Item()
              .setUnlocalizedName("itemPlateVibrantAlloy")
              .setCreativeTab(TMCreativeTabs.tabMisc)
              .setTextureName(Strings.MODID + ":itemPlateVibrantAlloy");
      ;
      itemPlateConductiveIron =
          new Item()
              .setUnlocalizedName("itemPlateConductiveIron")
              .setCreativeTab(TMCreativeTabs.tabMisc)
              .setTextureName(Strings.MODID + ":itemPlateConductiveIron");
      ;
      itemPlateDarkSteel =
          new Item()
              .setUnlocalizedName("itemPlateDarkSteel")
              .setCreativeTab(TMCreativeTabs.tabMisc)
              .setTextureName(Strings.MODID + ":itemPlateDarkSteel");
      ;

      // Registry
      GameRegistry.registerItem(itemPlateSoularium, "itemPlateSoularium");
      GameRegistry.registerItem(itemPlateRedstoneAlloy, "itemPlateRedstoneAlloy");
      GameRegistry.registerItem(itemPlateElectricalSteel, "itemPlateElectricalSteel");
      GameRegistry.registerItem(itemPlatePulsatingIron, "itemPlatePulsatingIron");
      GameRegistry.registerItem(itemPlateEnergeticAlloy, "itemPlateEnergeticAlloy");
      GameRegistry.registerItem(itemPlateVibrantAlloy, "itemPlateVibrantAlloy");
      GameRegistry.registerItem(itemPlateConductiveIron, "itemPlateConductiveIron");
      GameRegistry.registerItem(itemPlateDarkSteel, "itemPlateDarkSteel");
    } else {
      FMLLog.info("EnderIO not Found - Skipping Resources");
    }

    // Big Reactors
    if (Loader.isModLoaded("BigReactors") == true || DEBUG) {
      FMLLog.info("BigReactors Found - Loading Resources");
      // Item Init
      itemPlateBlutonium =
          new Item()
              .setUnlocalizedName("itemPlateBlutonium")
              .setCreativeTab(TMCreativeTabs.tabMisc)
              .setTextureName(Strings.MODID + ":itemPlateBlutonium");
      ;
      itemPlateCyanite =
          new Item()
              .setUnlocalizedName("itemPlateCyanite")
              .setCreativeTab(TMCreativeTabs.tabMisc)
              .setTextureName(Strings.MODID + ":itemPlateCyanite");
      ;
      itemPlateLudicrite =
          new Item()
              .setUnlocalizedName("itemPlateLudicrite")
              .setCreativeTab(TMCreativeTabs.tabMisc)
              .setTextureName(Strings.MODID + ":itemPlateLudicrite");
      ;

      // Registry
      GameRegistry.registerItem(itemPlateBlutonium, "itemPlateBlutonium");
      GameRegistry.registerItem(itemPlateCyanite, "itemPlateCyanite");
      GameRegistry.registerItem(itemPlateLudicrite, "itemPlateLudicrite");

    } else {
      FMLLog.info("BigReactors not Found - Skipping Resources");
    }

    // Thaumcraft
    if (Loader.isModLoaded("Thaumcraft") == true || DEBUG) {
      FMLLog.info("Thaumcraft Found - Loading Resources");
      // Item Init
      itemPlateVoidMetal =
          new Item()
              .setUnlocalizedName("itemPlateVoidMetal")
              .setCreativeTab(TMCreativeTabs.tabMisc)
              .setTextureName(Strings.MODID + ":itemPlateVoidMetal");
      ;

      // Registry
      GameRegistry.registerItem(itemPlateVoidMetal, "itemPlateVoidMetal");

    } else {
      FMLLog.info("Thaumcraft not Found - Skipping Resources");
    }

    // ExtraUtils
    if (Loader.isModLoaded("ExtraUtilities") == true || DEBUG) {
      FMLLog.info("ExtraUtils Found - Loading Resources");
      // Item Init
      itemPlateBedrockium =
          new Item()
              .setUnlocalizedName("itemPlateBedrockium")
              .setCreativeTab(TMCreativeTabs.tabMisc)
              .setTextureName(Strings.MODID + ":itemPlateBedrockium");
      ;

      // Registry
      GameRegistry.registerItem(itemPlateBedrockium, "itemPlateBedrockium");

    } else {
      FMLLog.info("ExtraUtils not Found - Skipping Resources");
    }

    // Pneumaticraft
    if (Loader.isModLoaded("PneumaticCraft") == true || DEBUG) {
      FMLLog.info("Pneumaticraft Found - Loading Resources");
      // Item Init
      itemPlateCompressedIron =
          new Item()
              .setUnlocalizedName("itemPlateCompressedIron")
              .setCreativeTab(TMCreativeTabs.tabMisc)
              .setTextureName(Strings.MODID + ":itemPlateCompressedIron");
      ;

      // Registry
      GameRegistry.registerItem(itemPlateCompressedIron, "itemPlateCompressedIron");

    } else {
      FMLLog.info("Pneumaticraft not Found - Skipping Resources");
    }

    // Simply Jetpacks
    if (Loader.isModLoaded("simplyjetpacks") == true || DEBUG) {
      FMLLog.info("SimplyJetpacks Found - Loading Resources");
      // Item Init
      itemPlateEnrichedSoularium =
          new RarityUncommon()
              .setUnlocalizedName("itemPlateEnrichedSoularium")
              .setCreativeTab(TMCreativeTabs.tabMisc)
              .setTextureName(Strings.MODID + ":itemPlateSoularium");
      ;

      // Registry
      GameRegistry.registerItem(itemPlateEnrichedSoularium, "itemPlateEnrichedSoularium");

    } else {
      FMLLog.info("SimplyJetpacks not Found - Skipping Resources");
    }

    // rfTools
    if (Loader.isModLoaded("rftools") == true || DEBUG) {
      FMLLog.info("rfTools Found - Loading Resources");
      // Item Init
      itemPlateDimensionShard =
          new Item()
              .setUnlocalizedName("itemPlateDimensionShard")
              .setCreativeTab(TMCreativeTabs.tabMisc)
              .setTextureName(Strings.MODID + ":itemPlateDimensionShard");
      ;

      // Registry
      GameRegistry.registerItem(itemPlateDimensionShard, "itemPlateDimensionShard");

    } else {
      FMLLog.info("rfTools not Found - Skipping Resources");
    }

    /*
     * Misc Items
     */

    // Blood Steel Ingot
    itemIngotBloodSteel =
        new Item()
            .setUnlocalizedName("itemIngotBloodSteel")
            .setCreativeTab(TMCreativeTabs.tabMisc)
            .setTextureName(Strings.MODID + ":itemIngotBloodSteel");
    ;
    GameRegistry.registerItem(itemIngotBloodSteel, "itemIngotBloodSteel");
    // Blood Steel Ingot
    itemPlateBloodSteel =
        new Item()
            .setUnlocalizedName("itemPlateBloodSteel")
            .setCreativeTab(TMCreativeTabs.tabMisc)
            .setTextureName(Strings.MODID + ":itemPlateBloodSteel");
    ;
    GameRegistry.registerItem(itemPlateBloodSteel, "itemPlateBloodSteel");
  }
예제 #13
0
  /**
   * Complete the energy transfer. Called internally on server tick end.
   *
   * @return Amount of energy SENT to all acceptors
   */
  private float doProduce() {
    float sent = 0.0F;

    if (!this.availableAcceptors.isEmpty()) {
      float energyNeeded = this.totalRequested;
      float energyAvailable = this.totalEnergy;
      float reducor = 1.0F;
      float energyStorageReducor = 1.0F;

      if (energyNeeded > energyAvailable) {
        // If not enough energy, try reducing what goes into energy storage (if any)
        energyNeeded -= this.totalStorageExcess;
        // If there's still not enough, put the minimum into energy storage (if any) and, anyhow,
        // reduce everything proportionately
        if (energyNeeded > energyAvailable) {
          energyStorageReducor = 0F;
          reducor = energyAvailable / energyNeeded;
        } else {
          // Energyavailable exceeds the total needed but only if storage does not fill all in one
          // go - this is a common situation
          energyStorageReducor = (energyAvailable - energyNeeded) / this.totalStorageExcess;
        }
      }

      float currentSending;
      float sentToAcceptor;
      int tierProduced = Math.min(this.producersTierGC, this.networkTierGC);

      TileEntity debugTE = null;
      try {
        for (TileEntity tileEntity : this.availableAcceptors) {
          debugTE = tileEntity;
          // Exit the loop if there is no energy left at all (should normally not happen, should be
          // some even for the last acceptor)
          if (sent >= energyAvailable) {
            break;
          }

          // The base case is to give each acceptor what it is requesting
          currentSending = this.energyRequests.get(tileEntity);

          // If it's an energy store, we may need to damp it down if energyStorageReducor is less
          // than 1
          if (currentSending > EnergyNetwork.ENERGY_STORAGE_LEVEL) {
            currentSending =
                EnergyNetwork.ENERGY_STORAGE_LEVEL
                    + (currentSending - EnergyNetwork.ENERGY_STORAGE_LEVEL) * energyStorageReducor;
          }

          // Reduce everything proportionately if there is not enough energy for all needs
          currentSending *= reducor;

          if (currentSending > energyAvailable - sent) {
            currentSending = energyAvailable - sent;
          }

          ForgeDirection sideFrom = this.availableconnectedDirections.get(tileEntity);

          if (tileEntity instanceof IElectrical) {
            sentToAcceptor =
                ((IElectrical) tileEntity)
                    .receiveElectricity(sideFrom, currentSending, tierProduced, true);
          } else if (isRF2Loaded && tileEntity instanceof IEnergyReceiver) {
            final int currentSendinginRF =
                (currentSending >= Integer.MAX_VALUE / EnergyConfigHandler.TO_RF_RATIO)
                    ? Integer.MAX_VALUE
                    : (int) (currentSending * EnergyConfigHandler.TO_RF_RATIO);
            sentToAcceptor =
                ((IEnergyReceiver) tileEntity).receiveEnergy(sideFrom, currentSendinginRF, false)
                    / EnergyConfigHandler.TO_RF_RATIO;
          } else if (isMekLoaded && tileEntity instanceof IStrictEnergyAcceptor) {
            sentToAcceptor =
                (float)
                        ((IStrictEnergyAcceptor) tileEntity)
                            .transferEnergyToAcceptor(
                                sideFrom, currentSending * EnergyConfigHandler.TO_MEKANISM_RATIO)
                    / EnergyConfigHandler.TO_MEKANISM_RATIO;
          } else if (isRF1Loaded && tileEntity instanceof IEnergyHandler) {
            final int currentSendinginRF =
                (currentSending >= Integer.MAX_VALUE / EnergyConfigHandler.TO_RF_RATIO)
                    ? Integer.MAX_VALUE
                    : (int) (currentSending * EnergyConfigHandler.TO_RF_RATIO);
            sentToAcceptor =
                ((IEnergyHandler) tileEntity).receiveEnergy(sideFrom, currentSendinginRF, false)
                    / EnergyConfigHandler.TO_RF_RATIO;
          } else if (isIC2Loaded && tileEntity instanceof IEnergySink) {
            double energySendingIC2 = currentSending * EnergyConfigHandler.TO_IC2_RATIO;
            if (energySendingIC2 >= 1D) {
              double result = 0;
              try {
                if (EnergyUtil.voltageParameterIC2) {
                  result =
                      (Double)
                          EnergyUtil.injectEnergyIC2.invoke(
                              tileEntity, sideFrom, energySendingIC2, 120D);
                } else {
                  result =
                      (Double)
                          EnergyUtil.injectEnergyIC2.invoke(tileEntity, sideFrom, energySendingIC2);
                }
              } catch (Exception ex) {
                if (ConfigManagerCore.enableDebug) {
                  ex.printStackTrace();
                }
              }
              sentToAcceptor = currentSending - (float) result / EnergyConfigHandler.TO_IC2_RATIO;
              if (sentToAcceptor < 0F) {
                sentToAcceptor = 0F;
              }
            } else {
              sentToAcceptor = 0F;
            }
          } else if (isBCLoaded
              && EnergyConfigHandler.getBuildcraftVersion() == 6
              && MjAPI.getMjBattery(tileEntity, MjAPI.DEFAULT_POWER_FRAMEWORK, sideFrom) != null)
          // New BC API
          {
            sentToAcceptor =
                (float)
                        MjAPI.getMjBattery(tileEntity, MjAPI.DEFAULT_POWER_FRAMEWORK, sideFrom)
                            .addEnergy(currentSending * EnergyConfigHandler.TO_BC_RATIO)
                    / EnergyConfigHandler.TO_BC_RATIO;
          } else if (isBCLoaded && tileEntity instanceof IPowerReceptor)
          // Legacy BC API
          {
            PowerReceiver receiver = ((IPowerReceptor) tileEntity).getPowerReceiver(sideFrom);

            if (receiver != null) {
              double toSendBC =
                  Math.min(
                      currentSending * EnergyConfigHandler.TO_BC_RATIO, receiver.powerRequest());
              sentToAcceptor =
                  (float)
                          receiver.receiveEnergy(
                              buildcraft.api.power.PowerHandler.Type.PIPE, toSendBC, sideFrom)
                      / EnergyConfigHandler.TO_BC_RATIO;
            } else {
              sentToAcceptor = 0F;
            }
          } else {
            sentToAcceptor = 0F;
          }

          if (sentToAcceptor / currentSending > 1.002F && sentToAcceptor > 0.01F) {
            if (!this.spamstop) {
              FMLLog.info(
                  "Energy network: acceptor took too much energy, offered "
                      + currentSending
                      + ", took "
                      + sentToAcceptor
                      + ". "
                      + tileEntity.toString());
              this.spamstop = true;
            }
            sentToAcceptor = currentSending;
          }

          sent += sentToAcceptor;
        }
      } catch (Exception e) {
        GCLog.severe("DEBUG Energy network loop issue, please report this");
        if (debugTE != null)
          GCLog.severe(
              "Problem was likely caused by tile in dim "
                  + debugTE.getWorldObj().provider.dimensionId
                  + " at "
                  + debugTE.xCoord
                  + ","
                  + debugTE.yCoord
                  + ","
                  + debugTE.zCoord
                  + " Type:"
                  + debugTE.getClass().getSimpleName());
      }
    }

    if (EnergyNetwork.tickCount % 200 == 0) {
      this.spamstop = false;
    }

    float returnvalue = sent;
    if (returnvalue > this.totalEnergy) {
      returnvalue = this.totalEnergy;
    }
    if (returnvalue < 0F) {
      returnvalue = 0F;
    }
    return returnvalue;
  }
예제 #14
0
  @Override
  public void onUpdate() {
    super.onUpdate();
    if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) {
      float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
      prevRotationYaw =
          rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
      prevRotationPitch =
          rotationPitch = (float) ((Math.atan2(motionY, f) * 180D) / 3.1415927410125732D);
    }
    if (arrowShake > 0) {
      arrowShake--;
    }
    if (inGround) {
      int i = worldObj.getBlockId(xTile, yTile, zTile);
      int j = worldObj.getBlockMetadata(xTile, yTile, zTile);
      if (i != inTile || j != inData) {
        inGround = false;
        motionX *= rand.nextFloat() * 0.2F;
        motionY *= rand.nextFloat() * 0.2F;
        motionZ *= rand.nextFloat() * 0.2F;
        ticksInGround = 0;
        ticksFlying = 0;
      } else {
        ticksInGround++;
        tickInGround();
        if (ticksInGround == ttlInGround) {
          setDead();
        }
        return;
      }
    } else {
      ticksFlying++;
    }
    tickFlying();
    Vec3 vec3d = Vec3.createVectorHelper(posX, posY, posZ);
    Vec3 vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
    MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);
    vec3d = Vec3.createVectorHelper(posX, posY, posZ);
    vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
    if (movingobjectposition != null) {
      vec3d1 =
          Vec3.createVectorHelper(
              movingobjectposition.hitVec.xCoord,
              movingobjectposition.hitVec.yCoord,
              movingobjectposition.hitVec.zCoord);
    }
    Entity entity = null;
    List list =
        worldObj.getEntitiesWithinAABBExcludingEntity(
            this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
    double d = 0.0D;
    for (int k = 0; k < list.size(); k++) {
      Entity entity2 = (Entity) list.get(k);
      if (!canBeShot(entity2)) {
        continue;
      }
      float f3 = hitBox;
      AxisAlignedBB axisalignedbb = entity2.boundingBox.expand(f3, f3, f3);
      MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
      if (movingobjectposition1 == null) {
        continue;
      }
      double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);
      if (d1 < d || d == 0.0D) {
        entity = entity2;
        d = d1;
      }
    }

    if (entity != null) {
      movingobjectposition = new MovingObjectPosition(entity);
    }
    if (movingobjectposition != null && (entity != shooter || ticksFlying > 2) && (onHit())) {
      Entity entity1 = movingobjectposition.entityHit;
      if (entity1 != null) {
        if (!worldObj.isRemote) {
          if (onHitTarget(entity1) && hasTorchAttachment == false) {
            if ((entity1 instanceof EntityLiving) && !(entity1 instanceof EntityPlayer)) {
              ++((EntityLiving) entity1).arrowHitTempCounter;
            }

            entity1.attackEntityFrom(
                DamageSource.causePlayerDamage((EntityPlayer) shooter),
                this.arrowCritical ? dmg * 2 : dmg);
            setDead();
          }
        }
      } else {
        xTile = movingobjectposition.blockX;
        yTile = movingobjectposition.blockY;
        zTile = movingobjectposition.blockZ;
        inTile = worldObj.getBlockId(xTile, yTile, zTile);
        inData = worldObj.getBlockMetadata(xTile, yTile, zTile);
        Block block = Block.blocksList[inTile];
        if (block != null && !(block instanceof BlockFlower)) {
          if (onHitBlock(movingobjectposition)) {
            motionX = (float) (movingobjectposition.hitVec.xCoord - posX);
            motionY = (float) (movingobjectposition.hitVec.yCoord - posY);
            motionZ = (float) (movingobjectposition.hitVec.zCoord - posZ);
            float f2 =
                MathHelper.sqrt_double(motionX * motionX + motionY * motionY + motionZ * motionZ);
            posX -= (motionX / (double) f2) * 0.05000000074505806D;
            posY -= (motionY / (double) f2) * 0.05000000074505806D;
            posZ -= (motionZ / (double) f2) * 0.05000000074505806D;
            inGround = true;
            arrowShake = 7;
            this.arrowCritical = false;
          }
        }
      }
    }
    if (movingobjectposition != null && !worldObj.isRemote) {
      Entity entity1 = movingobjectposition.entityHit;
      if (entity1 != null && entity1 instanceof EntityLiving && entity1 != shooter) {
        if (hasExplosiveAttachment && ((EntityLiving) entity1).arrowHitTempCounter < 10) {
          this.worldObj.createExplosion(
              this,
              (int) Math.floor(((EntityLiving) entity1).posX),
              (int) ((EntityLiving) entity1).posY,
              (int) Math.floor(((EntityLiving) entity1).posZ),
              1);
        }

        if (hasIceAttachment) {
          ((EntityLiving) entity1)
              .addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 280, 3));
        }

        if (hasPoisonAttachment) {
          ((EntityLiving) entity1).addPotionEffect(new PotionEffect(Potion.poison.id, 280, 3));
        }

        if (hasLightningAttachment) {
          this.worldObj.addWeatherEffect(
              new EntityLightningBolt(this.worldObj, entity1.posX, entity1.posY, entity1.posZ));
          this.setDead();
        }
      }
    }

    FMLLog.info("" + this.inGround);

    posX += motionX;
    posZ += motionZ;
    posY += motionY;
    handleMotionUpdate();
    float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
    rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
    for (rotationPitch = (float) ((Math.atan2(motionY, f1) * 180D) / 3.1415927410125732D);
        rotationPitch - prevRotationPitch < -180F;
        prevRotationPitch -= 360F) {}
    for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) {}
    for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) {}
    for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) {}
    rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
    rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
    setPosition(posX, posY, posZ);
  }
예제 #15
0
파일: GameData.java 프로젝트: Kobata/FML
  public static List<String> injectWorldIDMap(
      Map<String, Integer> dataList,
      Set<Integer> blockedIds,
      Map<String, String> blockAliases,
      Map<String, String> itemAliases,
      boolean injectFrozenData,
      boolean isLocalWorld) {
    FMLLog.info(
        "Injecting existing block and item data into this %s instance",
        FMLCommonHandler.instance().getEffectiveSide().isServer() ? "server" : "client");
    Map<String, Integer[]> remaps = Maps.newHashMap();
    LinkedHashMap<String, Integer> missingMappings = new LinkedHashMap<String, Integer>();
    getMain().testConsistency();
    getMain().iBlockRegistry.dump();
    getMain().iItemRegistry.dump();

    GameData newData = new GameData();

    for (int id : blockedIds) {
      newData.block(id);
    }

    for (Map.Entry<String, String> entry : blockAliases.entrySet()) {
      newData.iBlockRegistry.addAlias(entry.getKey(), entry.getValue());
    }

    for (Map.Entry<String, String> entry : itemAliases.entrySet()) {
      newData.iItemRegistry.addAlias(entry.getKey(), entry.getValue());
    }

    // process blocks and items in the world, blocks in the first pass, items in the second
    // blocks need to be added first for proper ItemBlock handling
    for (int pass = 0; pass < 2; pass++) {
      boolean isBlock = (pass == 0);

      for (Entry<String, Integer> entry : dataList.entrySet()) {
        String itemName = entry.getKey();
        int newId = entry.getValue();

        // names starting with 0x1 are blocks, skip if the type isn't handled by this pass
        if ((itemName.charAt(0) == '\u0001') != isBlock) continue;

        itemName = itemName.substring(1);
        int currId =
            isBlock
                ? getMain().iBlockRegistry.getId(itemName)
                : getMain().iItemRegistry.getId(itemName);

        if (currId == -1) {
          FMLLog.info("Found a missing id from the world %s", itemName);
          missingMappings.put(entry.getKey(), newId);
          continue; // no block/item -> nothing to add
        } else if (currId != newId) {
          FMLLog.fine(
              "Fixed %s id mismatch %s: %d (init) -> %d (map).",
              isBlock ? "block" : "item", itemName, currId, newId);
          remaps.put(itemName, new Integer[] {currId, newId});
        }

        // register
        if (isBlock) {
          currId =
              newData.registerBlock(getMain().iBlockRegistry.getRaw(itemName), itemName, newId);
        } else {
          currId = newData.registerItem(getMain().iItemRegistry.getRaw(itemName), itemName, newId);
        }

        if (currId != newId) {
          throw new IllegalStateException(
              String.format(
                  "Can't map %s %s to id %d, already occupied by %s, blocked %b, ItemBlock %b",
                  isBlock ? "block" : "item",
                  itemName,
                  newId,
                  isBlock
                      ? newData.iBlockRegistry.getRaw(newId)
                      : newData.iItemRegistry.getRaw(newId),
                  newData.blockedIds.contains(newId),
                  isBlock ? false : (getMain().iItemRegistry.getRaw(currId) instanceof ItemBlock)));
        }
      }
    }

    List<String> missedMappings =
        Loader.instance().fireMissingMappingEvent(missingMappings, isLocalWorld, newData, remaps);
    if (!missedMappings.isEmpty()) return missedMappings;

    if (injectFrozenData) // add blocks + items missing from the map
    {
      Map<String, Integer> missingBlocks =
          frozen.iBlockRegistry.getEntriesNotIn(newData.iBlockRegistry);
      Map<String, Integer> missingItems =
          frozen.iItemRegistry.getEntriesNotIn(newData.iItemRegistry);

      if (!missingBlocks.isEmpty() || !missingItems.isEmpty()) {
        FMLLog.info("Injecting new block and item data into this server instance.");

        for (int pass = 0; pass < 2; pass++) {
          boolean isBlock = pass == 0;
          Map<String, Integer> missing = (pass == 0) ? missingBlocks : missingItems;

          for (Entry<String, Integer> entry : missing.entrySet()) {
            String itemName = entry.getKey();
            int currId = entry.getValue();
            int newId;

            if (isBlock) {
              newId =
                  newData.registerBlock(frozen.iBlockRegistry.getRaw(itemName), itemName, currId);
            } else {
              newId = newData.registerItem(frozen.iItemRegistry.getRaw(itemName), itemName, currId);
            }

            FMLLog.info(
                "Injected new block/item %s: %d (init) -> %d (map).", itemName, currId, newId);

            if (newId != currId) // a new id was assigned
            {
              remaps.put(itemName, new Integer[] {entry.getValue(), newId});
            }
          }
        }
      }
    }

    newData.testConsistency();
    getMain().set(newData);

    getMain().iBlockRegistry.dump();
    getMain().iItemRegistry.dump();
    Loader.instance().fireRemapEvent(remaps);
    // The id map changed, ensure we apply object holders
    ObjectHolderRegistry.INSTANCE.applyObjectHolders();
    return ImmutableList.of();
  }
예제 #16
0
파일: GameData.java 프로젝트: Kobata/FML
  public static List<String> processIdRematches(
      Iterable<MissingMapping> missedMappings,
      boolean isLocalWorld,
      GameData gameData,
      Map<String, Integer[]> remaps) {
    List<String> failed = Lists.newArrayList();
    List<String> ignored = Lists.newArrayList();
    List<String> warned = Lists.newArrayList();
    List<String> defaulted = Lists.newArrayList();

    for (MissingMapping remap : missedMappings) {
      FMLMissingMappingsEvent.Action action = remap.getAction();

      if (action == FMLMissingMappingsEvent.Action.REMAP) {
        // block/item re-mapped, finish the registration with the new name/object, but the old id
        int currId, newId;
        String newName;

        if (remap.type == Type.BLOCK) {
          currId = getMain().iBlockRegistry.getId((Block) remap.getTarget());
          newName = getMain().iBlockRegistry.getNameForObject(remap.getTarget());
          FMLLog.fine("The Block %s is being remapped to %s.", remap.name, newName);

          newId = gameData.registerBlock((Block) remap.getTarget(), newName, remap.id);
          gameData.iBlockRegistry.addAlias(remap.name, newName);
        } else {
          currId = getMain().iItemRegistry.getId((Item) remap.getTarget());
          newName = getMain().iItemRegistry.getNameForObject(remap.getTarget());
          FMLLog.fine("The Item %s is being remapped to %s.", remap.name, newName);

          newId = gameData.registerItem((Item) remap.getTarget(), newName, remap.id);
          gameData.iItemRegistry.addAlias(remap.name, newName);
        }

        if (newId != remap.id) throw new IllegalStateException();

        if (currId != newId) {
          FMLLog.info(
              "Fixed %s id mismatch %s: %d (init) -> %d (map).",
              remap.type == Type.BLOCK ? "block" : "item", newName, currId, newId);
          remaps.put(newName, new Integer[] {currId, newId});
        }
      } else {
        // block item missing, warn as requested and block the id
        if (action == FMLMissingMappingsEvent.Action.DEFAULT) {
          defaulted.add(remap.name);
        } else if (action == FMLMissingMappingsEvent.Action.IGNORE) {
          ignored.add(remap.name);
        } else if (action == FMLMissingMappingsEvent.Action.FAIL) {
          failed.add(remap.name);
        } else if (action == FMLMissingMappingsEvent.Action.WARN) {
          warned.add(remap.name);
        }

        gameData.block(remap.id); // prevent the id from being reused later
      }
    }

    if (!defaulted.isEmpty()) {
      String text =
          "Forge Mod Loader detected missing blocks/items.\n\n"
              + "There are "
              + defaulted.size()
              + " missing blocks and items in this save.\n"
              + "If you continue the missing blocks/items will get removed.\n"
              + "A world backup will be automatically created in your saves directory.\n\n"
              + "Missing Blocks/Items:\n";

      for (String s : defaulted) text += s + "\n";

      boolean confirmed = StartupQuery.confirm(text);
      if (!confirmed) StartupQuery.abort();

      try {
        ZipperUtil.backupWorld();
      } catch (IOException e) {
        StartupQuery.notify("The world backup couldn't be created.\n\n" + e);
        StartupQuery.abort();
      }

      warned.addAll(defaulted);
    }
    if (!failed.isEmpty()) {
      FMLLog.severe(
          "This world contains blocks and items that refuse to be remapped. The world will not be loaded");
      return failed;
    }
    if (!warned.isEmpty()) {
      FMLLog.severe("This world contains block and item mappings that may cause world breakage");
      return failed;
    } else if (!ignored.isEmpty()) {
      FMLLog.fine("There were %d missing mappings that have been ignored", ignored.size());
    }
    return failed;
  }
예제 #17
0
  public void init() {

    PlayerSpellsDamageTerrain =
        get(CATEGORY_GENERAL, KEY_PlayerSpellsDamageTerrain, true).getBoolean(true);
    NPCSpellsDamageTerrain =
        get(CATEGORY_GENERAL, KEY_NPCSpellsDamageTerrain, false).getBoolean(false);

    DamageMultiplier =
        (float)
            get(
                    CATEGORY_GENERAL,
                    KEY_DamageMultiplier,
                    1.0,
                    "How much the damage in Ars Magica is scaled.")
                .getDouble(1.0);

    UseSpecialRenderers =
        get(
                CATEGORY_GENERAL,
                KEY_UseSpecialRenderers,
                true,
                "Render spell effects on equipped scrolls rather than the scroll itself (only applies to the in-game one, the one on your hotbar remains unchanged)")
            .getBoolean(true);

    boolean def = !Loader.isModLoaded("NotEnoughItems");
    DisplayManaInInventory =
        get(
                CATEGORY_GENERAL,
                KEY_DisplayManaInInventory,
                def,
                "This will toggle mana display on and off in your inventory.  Default 'O' key in game.")
            .getBoolean(def);

    FrictionCoefficient =
        (float)
            get(
                    CATEGORY_GENERAL,
                    KEY_FrictionCoefficient,
                    0.8,
                    "This is the multiplier used to determine velocity lost when a spell projectile bounces. 0.0 is a complete stop, 1.0 is no loss.")
                .getDouble(0.8);

    Property retroWorldGenProp =
        get(
            CATEGORY_GENERAL,
            KEY_RetroactiveWorldGen,
            false,
            "Set this to true to enable retroactive worldgen for Ars Magica structures and ores.  *WARNING* This may break your save!  Do a backup first!  Note: This will automatically turn off after running the game once.");
    RetroWorldGen = retroWorldGenProp.getBoolean(false);

    if (RetroWorldGen) {
      retroWorldGenProp.set(false);
    }

    secondarySkillTreeTierCap =
        get(
                CATEGORY_GENERAL,
                KEY_SecondarySkillTreeTierCap,
                99,
                "Sets how far a player may progress into secondary skill trees.")
            .getInt();
    mageVillagerProfessionID = get(CATEGORY_GENERAL, KEY_MageVillagerProfessionID, 29).getInt();

    manaHudPosition =
        new AMVector2(
            get(CATEGORY_UI, KEY_ManaHudPositionX, 0.7104166746139526)
                .getDouble(0.7104166746139526),
            get(CATEGORY_UI, KEY_ManaHudPositionY, 0.9137254953384399)
                .getDouble(0.9137254953384399));
    burnoutHudPosition =
        new AMVector2(
            get(CATEGORY_UI, KEY_BurnoutHudPositionX, 0.13333334028720856)
                .getDouble(0.13333334028720856),
            get(CATEGORY_UI, KEY_BurnoutHudPositionY, 0.9176470637321472)
                .getDouble(0.9176470637321472));
    positiveBuffsPosition =
        new AMVector2(
            get(CATEGORY_UI, KEY_BuffsPositivePositionX, 0.5145833492279053)
                .getDouble(0.5145833492279053),
            get(CATEGORY_UI, KEY_BuffsPositivePositionY, 0.47843137383461)
                .getDouble(0.47843137383461));
    negativeBuffsPosition =
        new AMVector2(
            get(CATEGORY_UI, KEY_BuffsNegativePositionX, 0.46666666865348816)
                .getDouble(0.46666666865348816),
            get(CATEGORY_UI, KEY_BuffsNegativePositionY, 0.47843137383461)
                .getDouble(0.47843137383461));
    levelPosition =
        new AMVector2(
            get(CATEGORY_UI, KEY_LevelPositionX, 0.49791666865348816)
                .getDouble(0.49791666865348816),
            get(CATEGORY_UI, KEY_LevelPositionY, 0.8117647171020508).getDouble(0.8117647171020508));
    affinityPosition =
        new AMVector2(
            get(CATEGORY_UI, KEY_AffinityPositionX, 0.9770833253860474)
                .getDouble(0.9770833253860474),
            get(CATEGORY_UI, KEY_AffinityPositionY, 0.9).getDouble(0.9));
    armorPositionChest =
        new AMVector2(
            get(CATEGORY_UI, KEY_ArmorPositionChestX, 0.004166666883975267)
                .getDouble(0.004166666883975267),
            get(CATEGORY_UI, KEY_ArmorPositionChestY, 0.5568627715110779)
                .getDouble(0.5568627715110779));
    armorPositionHead =
        new AMVector2(
            get(CATEGORY_UI, KEY_ArmorPositionHeadX, 0.004166666883975267)
                .getDouble(0.004166666883975267),
            get(CATEGORY_UI, KEY_ArmorPositionHeadY, 0.5176470875740051)
                .getDouble(0.5176470875740051));
    armorPositionLegs =
        new AMVector2(
            get(CATEGORY_UI, KEY_ArmorPositionLegsX, 0.004166666883975267)
                .getDouble(0.004166666883975267),
            get(CATEGORY_UI, KEY_ArmorPositionLegsY, 0.5960784554481506)
                .getDouble(0.5960784554481506));
    armorPositionBoots =
        new AMVector2(
            get(CATEGORY_UI, KEY_ArmorPositionBootsX, 0.004166666883975267)
                .getDouble(0.004166666883975267),
            get(CATEGORY_UI, KEY_ArmorPositionBootsY, 0.6352941393852234)
                .getDouble(0.6352941393852234));
    xpBarPosition =
        new AMVector2(
            get(CATEGORY_UI, KEY_XPBarPositionX, 0.31041666865348816)
                .getDouble(0.31041666865348816),
            get(CATEGORY_UI, KEY_XPBarPositionY, 0.7843137383460999).getDouble(0.7843137383460999));
    contingencyPosition =
        new AMVector2(
            get(CATEGORY_UI, KEY_ContingencyPositionX, 0.0020833334419876337)
                .getDouble(0.0020833334419876337),
            get(CATEGORY_UI, KEY_ContingencyPositionY, 0.9333333373069763)
                .getDouble(0.9333333373069763));

    manaNumericPosition =
        new AMVector2(
            get(CATEGORY_UI, KEY_ManaNumericPositionX, 0.7437499761581421)
                .getDouble(0.7437499761581421),
            get(CATEGORY_UI, KEY_ManaNumericPositionY, 0.8941176533699036)
                .getDouble(0.8941176533699036));
    burnoutNumericPosition =
        new AMVector2(
            get(CATEGORY_UI, KEY_BurnoutNumericPositionX, 0.21041665971279144)
                .getDouble(0.21041665971279144),
            get(CATEGORY_UI, KEY_BurnoutNumericPositionY, 0.9058823585510254)
                .getDouble(0.9058823585510254));
    XPNumericPosition =
        new AMVector2(
            get(CATEGORY_UI, KEY_XPNumericPositionX, 0.47083333134651184)
                .getDouble(0.47083333134651184),
            get(CATEGORY_UI, KEY_XPNumericPositionY, 0.7450980544090271)
                .getDouble(0.7450980544090271));
    SpellBookPosition =
        new AMVector2(
            get(CATEGORY_UI, KEY_SpellBookPositionX, 0.0).getDouble(0.0),
            get(CATEGORY_UI, KEY_SpellBookPositionY, 0.0).getDouble(0.0));

    showHudMinimally =
        get(
                CATEGORY_UI,
                KEY_ShowHudMinimally,
                false,
                "Set this to true to only show the AM HUD when a spell is equipped")
            .getBoolean(false);
    showArmorUI = get(CATEGORY_UI, KEY_ShowArmorUI, true).getBoolean(true);
    showBuffs = get(CATEGORY_UI, KEY_ShowBuffs, true).getBoolean(true);
    showNumerics = get(CATEGORY_UI, KEY_ShowNumerics, false).getBoolean(false);
    showXPAlways = get(CATEGORY_UI, KEY_ShowXPAlways, false).getBoolean(false);
    showHudBars = get(CATEGORY_UI, KEY_ShowHUDBars, true).getBoolean(true);

    witchwoodForestID = get(CATEGORY_GENERAL, KEY_WitchwoodForestBiomeID, 100).getInt();
    witchwoodLeafParticles =
        get(
                CATEGORY_GENERAL,
                KEY_witchwoodLeavesFall,
                true,
                "Disable this if you experience low FPS in witchwood forests")
            .getBoolean(true);
    enableWitchwoodForest =
        get(
                CATEGORY_GENERAL,
                KEY_EnableWitchwoodForest,
                true,
                "Disable this if you prefer the witchwood forest to not generate")
            .getBoolean(true);
    witchwoodForestRarity =
        get(
                CATEGORY_GENERAL,
                KEY_WitchwoodForestRarity,
                6,
                "Sets how rare witchwood forests are.  Lower is more rare.")
            .getInt();

    moonstoneMeteorsDestroyTerrain =
        get(
                CATEGORY_GENERAL,
                KEY_moonstoneMeteorsDestroyTerrain,
                true,
                "Should moonstone meteors destroy terrain when landing?  Keep in mind they will never land on anything other than grass.")
            .getBoolean(true);

    suggestSpellNames =
        get(
                CATEGORY_GENERAL,
                KEY_moonstoneMeteorsDestroyTerrain,
                true,
                "Set this to true to allow AM2 to get random spell names from Seventh Sanctum, and suggest them when naming spells.  Naturally, an internet connection is required.  Keep in mind, while I try to keep things family friendly, it's possible that not all names generated are so.")
            .getBoolean(true);

    forgeSmeltsVillagers =
        get(
                CATEGORY_GENERAL,
                KEY_ForgeSmeltsVillagers,
                true,
                "Set this to true to have the forge component smelt villagers into emeralds.  This counts as an attack and lowers your reputation.")
            .getBoolean(true);

    everstoneRepairRate = get(CATEGORY_GENERAL, KEY_EverstoneRepairRate, 180).getInt();

    stagedCompendium =
        get(
                CATEGORY_GENERAL,
                KEY_StagedCompendium,
                true,
                "Set this to false to have the compendium show everything, and not unlock as you go.")
            .getBoolean(true);

    colourblindMode =
        get(
                CATEGORY_GENERAL,
                KEY_ColourblindMode,
                false,
                "Set this to true to have AM2 list out colours for skill points and essence types rather than showing them as a colour.")
            .getBoolean(false);

    candlesAreRovingLights =
        get(
                CATEGORY_GENERAL,
                KEY_CandlesAreRovingLights,
                true,
                "Set this to false to disable candles being able to act as roving lights, which improves performance.")
            .getBoolean(true);

    allowCompendiumUpdates =
        get(
                CATEGORY_GENERAL,
                KEY_AllowCompendiumUpdates,
                true,
                "If true, AM2 will automatically download compendium updates when available for your mod version.")
            .getBoolean(true);
    allowVersionChecks =
        get(
                CATEGORY_GENERAL,
                KEY_AllowVersionChecks,
                true,
                "If true, AM2 will notify you via the compendium when new versions are available.  It will not spam chat on login.  You will not be notified of updates that are not for your current Minecraft version.")
            .getBoolean(true);

    meteorMinSpawnLevel =
        get(
                CATEGORY_GENERAL,
                KEY_MeteorMinSpawnLevel,
                10,
                "You must reach this magic level before Moonstone meteors will fall near you.")
            .getInt();

    hazardousGateways =
        get(
                CATEGORY_GENERAL,
                KEY_HazardousGateways,
                true,
                "Set this to false in order to disable gateways sending you partial distances if you don't have enough power.")
            .getBoolean(true);

    ArmorXPInfusionFactor =
        get(
                CATEGORY_GENERAL,
                KEY_ArmorXPInfusionFactor,
                1.0,
                "Alter this to change the rate at which armor XP infuses.")
            .getDouble();
    disarmAffectsPlayers =
        get(
                CATEGORY_GENERAL,
                KEY_DisarmAffectsPlayers,
                true,
                "If false, disarm won't work on players.")
            .getBoolean(true);
    manaCap =
        get(
                CATEGORY_GENERAL,
                KEY_ManaCap,
                0,
                "Sets the maximum mana a player can have (0 for no cap)")
            .getDouble(0);

    digBreaksTileEntities =
        get(
                CATEGORY_GENERAL,
                KEY_DigBreaksTEs,
                true,
                "Can the dig component break blocks that have a tile entity?")
            .getBoolean(true);

    savePowerOnWorldSave =
        get(
                CATEGORY_GENERAL,
                KEY_SavePowerOnWorldSave,
                true,
                "Set this to false if you are experiencing tick lage due to AM2 saving power data alongside the world save.  This will instead cache the power data in memory to be saved later.  This comes with more risk in the event of a crash, and a larger memory footprint, but increased performance. Can be used alongside chunk unload save config. Power data is still always saved at world unload (server shutdown).")
            .getBoolean(true);

    canDryadsDespawn =
        get(
                CATEGORY_MOBS,
                KEY_CanDryadsDespawn,
                true,
                "Set this to false if you don't want dryads to despawn.")
            .getBoolean(true);

    enderAffinityAbilityCooldown =
        get(
                CATEGORY_GENERAL,
                KEY_EnderAffinityAbilityCooldown,
                100,
                "Set this to the number of ticks between ender affinity teleports.")
            .getInt();

    String digBlacklistString =
        get(
                CATEGORY_GENERAL,
                KEY_DigDisabledBlocks,
                "",
                "Comma-separated list of block IDs that dig cannot break.  If a block is flagged as unbreackable in code, Dig will already be unable to break it.  There is no need to set it here (eg, bedrock, etc.).  Dig also makes use of Forge block harvest checks.  This is mainly for fine-tuning.")
            .getString();
    digBlacklist = digBlacklistString.split(",");

    String worldgenBlackList =
        get(
                CATEGORY_GENERAL,
                KEY_WorldgenBlacklist,
                "-27,-28,-29",
                "Comma-separated list of dimension IDs that AM should *not* do worldgen in.")
            .getString();
    String[] split = worldgenBlackList.split(",");
    worldgenBlacklist = new int[split.length];
    int count = 0;
    for (String s : split) {
      if (s.equals("")) continue;
      try {
        worldgenBlacklist[count] = Integer.parseInt(s.trim());
      } catch (Throwable t) {
        FMLLog.info("Ars Magica >> Malformed item in worldgen blacklist (%s).  Skipping.", s);
        t.printStackTrace();
        worldgenBlacklist[count] = -1;
      } finally {
        count++;
      }
    }

    String apBlockBL =
        get(
                CATEGORY_GENERAL,
                KEY_Appropriation_Block_Blacklist,
                "",
                "Comma-separated list of block IDs that appropriation cannot pick up.")
            .getString();
    appropriationBlockBlacklist = apBlockBL.split(",");

    String apEntBL =
        get(
                CATEGORY_GENERAL,
                KEY_Appropriation_Mob_Blacklist,
                "",
                "Comma-separated list of *fully qualified* Entity class names that appropriation cannot pick up - example, am2.entities.EntityDryad.  They are case sensitive.")
            .getString();
    split = apEntBL.split(",");
    appropriationMobBlacklist = new Class[split.length];
    count = 0;
    for (String s : split) {
      if (s.equals("")) continue;
      try {
        appropriationMobBlacklist[count] = Class.forName(s);
      } catch (Throwable t) {
        FMLLog.info(
            "Ars Magica >> Malformed item in appropriation entity blacklist (%s).  Skipping.", s);
        t.printStackTrace();
        appropriationMobBlacklist[count] = null;
      } finally {
        count++;
      }
    }

    initDirectProperties();

    save();
  }