Fixed #184
This commit is contained in:
parent
6232506dce
commit
6628fe0499
|
@ -8,6 +8,7 @@ import net.minecraft.potion.Potion;
|
|||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import biomesoplenty.api.BOPPotionHelper;
|
||||
import biomesoplenty.common.helpers.BOPReflectionHelper;
|
||||
import biomesoplenty.common.potions.PotionParalysis;
|
||||
import biomesoplenty.common.potions.PotionPossession;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
@ -23,12 +24,6 @@ public class BOPPotions
|
|||
intializePotions();
|
||||
}
|
||||
|
||||
private static void intializePotions()
|
||||
{
|
||||
registerPotion(new PotionParalysis(getNextID(), true, 16767262).setPotionName("potion.paralysis"));
|
||||
registerPotion(new PotionPossession(getNextID(), true, 1280).setPotionName("potion.possession"));
|
||||
}
|
||||
|
||||
private static void extendPotionsArray()
|
||||
{
|
||||
FMLCommonHandler.instance().getFMLLogger().log(Level.INFO, "[BiomesOPlenty] Extending Potions Array.");
|
||||
|
@ -37,33 +32,13 @@ public class BOPPotions
|
|||
Potion[] potionTypes = new Potion[potionOffset + MAXNEWPOTIONS];
|
||||
System.arraycopy(Potion.potionTypes, 0, potionTypes, 0, potionOffset);
|
||||
|
||||
Field field = null;
|
||||
Field[] fields = Potion.class.getDeclaredFields();
|
||||
BOPReflectionHelper.setPrivateFinalValue(Potion.class, null, potionTypes, "potionTypes", "field_76425_a");
|
||||
}
|
||||
|
||||
for (Field f : fields)
|
||||
{
|
||||
if (f.getName().equals("potionTypes") || f.getName().equals("potionTypes"))
|
||||
{
|
||||
field = f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
field.setAccessible(true);
|
||||
|
||||
Field modfield = Field.class.getDeclaredField("modifiers");
|
||||
modfield.setAccessible(true);
|
||||
modfield.setInt(field, field.getModifiers() & ~Modifier.FINAL);
|
||||
|
||||
field.set(null, potionTypes);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("[BiomesOPlenty] Severe error, please report this to the mod author:");
|
||||
System.err.println(e);
|
||||
}
|
||||
private static void intializePotions()
|
||||
{
|
||||
registerPotion(new PotionParalysis(getNextID(), true, 16767262).setPotionName("potion.paralysis"));
|
||||
registerPotion(new PotionPossession(getNextID(), true, 1280).setPotionName("potion.possession"));
|
||||
}
|
||||
|
||||
public static int getNextID()
|
||||
|
|
|
@ -35,30 +35,21 @@ public class BOPReflectionHelper
|
|||
}
|
||||
}
|
||||
|
||||
public static <T, E> void setPrivateFinalValue(Class <? super T > classToAccess, T instance, E value, String fieldName, String obfFieldName)
|
||||
public static <T, E> void setPrivateFinalValue(Class <? super T > classToAccess, T instance, E value, String... fieldNames)
|
||||
{
|
||||
Field field = null;
|
||||
Field field = ReflectionHelper.findField(classToAccess, ObfuscationReflectionHelper.remapFieldNames(classToAccess.getName(), fieldNames));
|
||||
|
||||
try
|
||||
{
|
||||
if (isDeobfuscated)
|
||||
{
|
||||
field = ReflectionHelper.findField(classToAccess, fieldName);
|
||||
}
|
||||
else
|
||||
{
|
||||
field = ReflectionHelper.findField(classToAccess, ObfuscationReflectionHelper.remapFieldNames(classToAccess.getName(), obfFieldName));
|
||||
}
|
||||
try
|
||||
{
|
||||
Field modifiersField = Field.class.getDeclaredField("modifiers");
|
||||
modifiersField.setAccessible(true);
|
||||
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
|
||||
|
||||
Field modifiersField = Field.class.getDeclaredField("modifiers");
|
||||
modifiersField.setAccessible(true);
|
||||
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
|
||||
|
||||
field.set(instance, value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
field.set(instance, value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue