Skip to content

Commit

Permalink
Use CustomPotion to expand the potion list
Browse files Browse the repository at this point in the history
  • Loading branch information
Clashsoft committed Apr 13, 2014
1 parent 02ea4d5 commit 3f2435d
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions BrewingAPI.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package clashsoft.brewingapi;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
Expand All @@ -21,10 +19,12 @@
import clashsoft.brewingapi.potion.PotionList;
import clashsoft.brewingapi.potion.type.IPotionType;
import clashsoft.brewingapi.tileentity.TileEntityBrewingStand2;
import clashsoft.cslib.minecraft.CSLib;
import clashsoft.cslib.minecraft.ClashsoftMod;
import clashsoft.cslib.minecraft.block.CSBlocks;
import clashsoft.cslib.minecraft.command.CSCommand;
import clashsoft.cslib.minecraft.item.CSItems;
import clashsoft.cslib.minecraft.potion.CustomPotion;
import clashsoft.cslib.minecraft.update.CSUpdate;
import clashsoft.cslib.minecraft.util.CSConfig;
import clashsoft.cslib.reflect.CSReflection;
Expand All @@ -49,7 +49,6 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemReed;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;

Expand Down Expand Up @@ -106,7 +105,7 @@ public class BrewingAPI extends ClashsoftMod

static
{
expandPotionList(64);
CustomPotion.expandPotionList(64);
}

public BrewingAPI()
Expand Down Expand Up @@ -257,23 +256,5 @@ public void onEntityUpdate(LivingUpdateEvent event)
}
}
}

public static void expandPotionList(int size)
{
if (Potion.potionTypes.length < size)
{
try
{
Field f = CSReflection.getField(Potion.class, 0);
CSReflection.setModifier(f, Modifier.FINAL, false);
Potion[] potionTypes = new Potion[size];
System.arraycopy(Potion.potionTypes, 0, potionTypes, 0, Potion.potionTypes.length);
f.set(null, potionTypes);
}
catch (Exception e)
{
CSLog.error(e);
}
}
}

}

0 comments on commit 3f2435d

Please sign in to comment.