-Added config option for potion ids

-Small modification to obsidian golem texture
This commit is contained in:
makeo committed 2015-12-24 16:52:56 +01:00
1 parent 0417f2c938
commit df5548fa3c
5 files changed
+46 -15

No files matched your search

@@ -75,8 +75,6 @@ public class CommonProxy implements IGuiHandler {
FMLCommonHandler.instance().bus().register(worldEventHandler);
MinecraftForge.EVENT_BUS.register(new EventHandlerEntity());
RegisteredPotions.init();
AuraEffects.AER.getTickInterval(); //initalize AuraEffects
RegisteredRecipes.init();
@@ -91,6 +89,8 @@ public class CommonProxy implements IGuiHandler {
}
public void postInitalize() {
RegisteredPotions.init();
RegisteredResearches.init();
RegisteredIntegrations.init();
@@ -1,6 +1,7 @@
package makeo.gadomancy.common.data.config;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import java.io.File;
@@ -65,5 +66,18 @@ public class ModConfig {
renderParticleDistance = config.getInt("particleRenderDistance", "general", 100, 5, 1000, "Defines, how close a player has to be towards the particle origin to see the particles created by it.");
enableAdditionalNodeTypes = config.getBoolean("enableAdditionalNodeTypes", "general", true, "Enables our custom node types. This might solve some compatibility issues (e.g. WitchingGadgets). You have to change this client- and server-side! Only change when you experience issues with special mods' features ONLY not working when using the mod together with Gadomancy.");
config.addCustomCategoryComment("potions", "Use the following if you have problems with conflicting potion ids. If the entry is set to '-1' it will try to automatically find a free potion id.");
}
public static int loadPotionId(String name) {
Property prop = config.get("potions", name, -1);
prop.setLanguageKey(name);
int result = prop.getInt(-1);
return result < -1 ? -1 : result;
}
public static void save() {
config.save();
}
}
@@ -10,8 +10,8 @@ import thaumcraft.api.aspects.Aspect;
* <p/>
* Created by makeo @ 11.12.2015 20:50
*/
public class PotionLetsGargamelItUp extends PotionCustomTexture {
public PotionLetsGargamelItUp(int id) {
public class PotionEldritch extends PotionCustomTexture {
public PotionEldritch(int id) {
super(id, false, Aspect.ELDRITCH.getColor(), Aspect.ELDRITCH.getImage());
setPotionName("potion.eldritch");
}
@@ -1,10 +1,10 @@
package makeo.gadomancy.common.registration;
import makeo.gadomancy.common.potions.PotionAchromatic;
import makeo.gadomancy.common.potions.PotionBuffGolem;
import makeo.gadomancy.common.potions.PotionLetsGargamelItUp;
import makeo.gadomancy.common.potions.PotionMiningLuck;
import makeo.gadomancy.common.potions.PotionVisAffinity;
import cpw.mods.fml.common.FMLLog;
import makeo.gadomancy.common.Gadomancy;
import makeo.gadomancy.common.data.config.ModConfig;
import makeo.gadomancy.common.potions.*;
import makeo.gadomancy.common.potions.PotionEldritch;
import makeo.gadomancy.common.utils.Injector;
import net.minecraft.potion.Potion;
@@ -21,22 +21,39 @@ public class RegisteredPotions {
public static PotionMiningLuck POTION_LUCK;
public static PotionBuffGolem BUFF_GOLEM;
public static PotionAchromatic ACHROMATIC;
public static PotionLetsGargamelItUp ELDRITCH;
public static PotionEldritch ELDRITCH;
public static PotionVisAffinity VIS_DISCOUNT;
public static void init() {
POTION_LUCK = registerPotion(PotionMiningLuck.class);
BUFF_GOLEM = registerPotion(PotionBuffGolem.class);
ACHROMATIC = registerPotion(PotionAchromatic.class);
ELDRITCH = registerPotion(PotionLetsGargamelItUp.class);
ELDRITCH = registerPotion(PotionEldritch.class);
VIS_DISCOUNT = registerPotion(PotionVisAffinity.class);
ModConfig.save();
}
private static <T extends Potion> T registerPotion(Class<T> potionClass) {
int id = Potion.potionTypes.length;
Potion[] potions = new Potion[Potion.potionTypes.length + 1];
System.arraycopy(Potion.potionTypes, 0, potions, 0, Potion.potionTypes.length);
Potion.potionTypes = potions;
int id = ModConfig.loadPotionId(potionClass.getSimpleName());
if(id == -1) {
id = Potion.potionTypes.length;
}
if(id > 127) {
FMLLog.warning("The potion id '" + id + "' of potion '" + Gadomancy.NAME + ":" + potionClass.getSimpleName() + "' is bigger then 127 this might cause errors. Please consider changing the config.");
}
if(id >= Potion.potionTypes.length) {
Potion[] potions = new Potion[Potion.potionTypes.length + 1];
System.arraycopy(Potion.potionTypes, 0, potions, 0, Potion.potionTypes.length);
Potion.potionTypes = potions;
} else if(Potion.potionTypes[id] != null) {
Potion conflict = Potion.potionTypes[id];
throw new RuntimeException("Potion id conflict! Do not report this bug you just have to change the configuration files. Failed to register potion '"
+ Gadomancy.NAME + ":" + potionClass.getSimpleName() + "' with id '" + id
+ "'. Another potion with this id already exists: " + conflict.getName() + " (as " + conflict.getClass().getName() + ")");
}
return new Injector(potionClass).invokeConstructor(int.class, id);
}