mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 03:15:07 +00:00
No longer use the raw potion array, use potio registry
This commit is contained in:
1 parent
b01e9dfed7
commit
08de553593
9 files changed
+26
-21
No files matched your search
@@ -22,6 +22,7 @@ import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.brew.Brew;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
@@ -52,8 +53,8 @@ public class TileIncensePlate extends TileSimpleInventory implements ISidedInven
|
||||
if(!worldObj.isRemote) {
|
||||
List<EntityPlayer> players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(pos.getX() + 0.5 - RANGE, pos.getY() + 0.5 - RANGE, pos.getZ() + 0.5 - RANGE, pos.getX() + 0.5 + RANGE, pos.getY() + 0.5 + RANGE, pos.getZ() + 0.5 + RANGE));
|
||||
for(EntityPlayer player : players) {
|
||||
PotionEffect currentEffect = player.getActivePotionEffect(Potion.potionTypes[effect.getPotionID()]);
|
||||
boolean nightVision = effect.getPotionID() == Potion.nightVision.id;
|
||||
PotionEffect currentEffect = player.getActivePotionEffect(GameData.getPotionRegistry().getObjectById(effect.getPotionID()));
|
||||
boolean nightVision = effect.getPotionID() == Potion.nightVision.getId();
|
||||
if(currentEffect == null || currentEffect.getDuration() < (nightVision ? 205 : 3)) {
|
||||
PotionEffect applyEffect = new PotionEffect(effect.getPotionID(), nightVision ? 285 : 80, effect.getAmplifier(), true, true);
|
||||
player.addPotionEffect(applyEffect);
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
*/
|
||||
package vazkii.botania.common.brew;
|
||||
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
|
||||
public class BrewModPotion extends BrewMod {
|
||||
|
||||
public BrewModPotion(String key, int cost, PotionEffect... effects) {
|
||||
super(key, Potion.potionTypes[effects[0].getPotionID()].getLiquidColor(), cost, effects);
|
||||
super(key, GameData.getPotionRegistry().getObjectById(effects[0].getPotionID()).getLiquidColor(), cost, effects);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ package vazkii.botania.common.brew;
|
||||
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
import vazkii.botania.api.brew.Brew;
|
||||
import vazkii.botania.common.lib.LibBrewNames;
|
||||
|
||||
@@ -67,7 +68,7 @@ public class ModBrews {
|
||||
|
||||
public static void initTC() {
|
||||
Potion warpWardPotion = null;
|
||||
for(Potion potion : Potion.potionTypes)
|
||||
for(Potion potion : GameData.getPotionRegistry().typeSafeIterable())
|
||||
if(potion != null && potion.getName().equals("potion.warpward")) {
|
||||
warpWardPotion = potion;
|
||||
break;
|
||||
|
||||
@@ -31,8 +31,8 @@ public class ModPotions {
|
||||
public static Potion clear;
|
||||
|
||||
public static void init() {
|
||||
if(Potion.potionTypes.length < 256)
|
||||
extendPotionArray();
|
||||
// if(Potion.potionTypes.length < 256)
|
||||
// extendPotionArray(); todo 1.8 this should be unnecessary thanks to potion registry
|
||||
|
||||
soulCross = new PotionSoulCross();
|
||||
featherfeet = new PotionFeatherfeet();
|
||||
|
||||
@@ -101,7 +101,7 @@ public final class ConfigHandler {
|
||||
public static int mushroomQuantity = 40;
|
||||
|
||||
private static boolean verifiedPotionArray = false;
|
||||
private static int potionArrayLimit = 0;
|
||||
private static int potionArrayLimit = 0; // todo 1.8 potion things should be unneeded thanks to potion registry
|
||||
|
||||
public static int potionIDSoulCross = 91;
|
||||
public static int potionIDFeatherfeet = 92;
|
||||
@@ -282,12 +282,12 @@ public final class ConfigHandler {
|
||||
desc = "The quantity of Botania mushrooms to generate underground, in the world, defaults to 40, the lower the number the less patches generate.";
|
||||
mushroomQuantity = loadPropInt("worldgen.mushroom.quantity", desc, mushroomQuantity);
|
||||
|
||||
potionIDSoulCross = loadPropPotionId(LibPotionNames.SOUL_CROSS, potionIDSoulCross);
|
||||
potionIDFeatherfeet = loadPropPotionId(LibPotionNames.FEATHER_FEET, potionIDFeatherfeet);
|
||||
potionIDEmptiness = loadPropPotionId(LibPotionNames.EMPTINESS, potionIDEmptiness);
|
||||
potionIDBloodthirst = loadPropPotionId(LibPotionNames.BLOODTHIRST, potionIDBloodthirst);
|
||||
potionIDAllure = loadPropPotionId(LibPotionNames.ALLURE, potionIDAllure);
|
||||
potionIDClear = loadPropPotionId(LibPotionNames.CLEAR, potionIDClear);
|
||||
// potionIDSoulCross = loadPropPotionId(LibPotionNames.SOUL_CROSS, potionIDSoulCross); todo 1.8 should be unneeded thanks to potion registry
|
||||
// potionIDFeatherfeet = loadPropPotionId(LibPotionNames.FEATHER_FEET, potionIDFeatherfeet);
|
||||
// potionIDEmptiness = loadPropPotionId(LibPotionNames.EMPTINESS, potionIDEmptiness);
|
||||
// potionIDBloodthirst = loadPropPotionId(LibPotionNames.BLOODTHIRST, potionIDBloodthirst);
|
||||
// potionIDAllure = loadPropPotionId(LibPotionNames.ALLURE, potionIDAllure);
|
||||
// potionIDClear = loadPropPotionId(LibPotionNames.CLEAR, potionIDClear);
|
||||
|
||||
if(config.hasChanged())
|
||||
config.save();
|
||||
|
||||
@@ -49,6 +49,7 @@ import net.minecraft.world.EnumDifficulty;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
import org.lwjgl.opengl.ARBShaderObjects;
|
||||
|
||||
import vazkii.botania.api.boss.IBotaniaBossWithShader;
|
||||
@@ -578,7 +579,7 @@ public class EntityDoppleganger extends EntityCreature implements IBotaniaBossWi
|
||||
List<PotionEffect> remove = new ArrayList();
|
||||
Collection<PotionEffect> active = player.getActivePotionEffects();
|
||||
for(PotionEffect effect : active)
|
||||
if(effect.getDuration() < 200 && effect.getIsAmbient() && !ReflectionHelper.<Boolean, Potion>getPrivateValue(Potion.class, Potion.potionTypes[effect.getPotionID()], LibObfuscation.IS_BAD_EFFECT))
|
||||
if(effect.getDuration() < 200 && effect.getIsAmbient() && !GameData.getPotionRegistry().getObjectById(effect.getPotionID()).isBadEffect())
|
||||
remove.add(effect);
|
||||
|
||||
active.removeAll(remove);
|
||||
|
||||
@@ -25,6 +25,7 @@ import net.minecraft.stats.Achievement;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.brew.Brew;
|
||||
import vazkii.botania.api.brew.IBrewItem;
|
||||
@@ -78,7 +79,7 @@ public abstract class ItemBrewBase extends ItemMod implements IBrewItem, IPickup
|
||||
if(!world.isRemote) {
|
||||
for(PotionEffect effect : getBrew(stack).getPotionEffects(stack)) {
|
||||
PotionEffect newEffect = new PotionEffect(effect.getPotionID(), effect.getDuration(), effect.getAmplifier(), true, true);
|
||||
Potion potion = Potion.potionTypes[newEffect.getPotionID()];
|
||||
Potion potion = GameData.getPotionRegistry().getObjectById(effect.getPotionID());
|
||||
if(potion.isInstant())
|
||||
potion.affectEntity(player, player, player, newEffect.getAmplifier(), 1F);
|
||||
else player.addPotionEffect(newEffect);
|
||||
@@ -137,7 +138,7 @@ public abstract class ItemBrewBase extends ItemMod implements IBrewItem, IPickup
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) {
|
||||
Brew brew = getBrew(stack);
|
||||
for(PotionEffect effect : brew.getPotionEffects(stack)) {
|
||||
Potion potion = Potion.potionTypes[effect.getPotionID()];
|
||||
Potion potion = GameData.getPotionRegistry().getObjectById(effect.getPotionID());
|
||||
EnumChatFormatting format = potion.isBadEffect() ? EnumChatFormatting.RED : EnumChatFormatting.GRAY;
|
||||
list.add(format + StatCollector.translateToLocal(effect.getEffectName()) + (effect.getAmplifier() == 0 ? "" : " " + StatCollector.translateToLocal("botania.roman" + (effect.getAmplifier() + 1))) + EnumChatFormatting.GRAY + (potion.isInstant() ? "" : " (" + Potion.getDurationString(effect) + ")"));
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.brew.Brew;
|
||||
import vazkii.botania.api.brew.IBrewContainer;
|
||||
@@ -79,7 +80,7 @@ public class ItemIncenseStick extends ItemMod implements IBrewItem, IBrewContain
|
||||
|
||||
addStringToTooltip(EnumChatFormatting.LIGHT_PURPLE + String.format(StatCollector.translateToLocal("botaniamisc.brewOf"), StatCollector.translateToLocal(brew.getUnlocalizedName(stack))), list);
|
||||
for(PotionEffect effect : brew.getPotionEffects(stack)) {
|
||||
Potion potion = Potion.potionTypes[effect.getPotionID()];
|
||||
Potion potion = GameData.getPotionRegistry().getObjectById(effect.getPotionID());
|
||||
EnumChatFormatting format = potion.isBadEffect() ? EnumChatFormatting.RED : EnumChatFormatting.GRAY;
|
||||
PotionEffect longEffect = new PotionEffect(effect.getPotionID(), effect.getDuration() * TIME_MULTIPLIER, effect.getAmplifier(), false, true);
|
||||
addStringToTooltip(" " + format + StatCollector.translateToLocal(effect.getEffectName()) + (effect.getAmplifier() == 0 ? "" : " " + StatCollector.translateToLocal("botania.roman" + (effect.getAmplifier() + 1))) + EnumChatFormatting.GRAY + (potion.isInstant() ? "" : " (" + Potion.getDurationString(longEffect) + ")"), list);
|
||||
@@ -106,7 +107,7 @@ public class ItemIncenseStick extends ItemMod implements IBrewItem, IBrewContain
|
||||
|
||||
@Override
|
||||
public ItemStack getItemForBrew(Brew brew, ItemStack stack) {
|
||||
if(!brew.canInfuseIncense() || brew.getPotionEffects(stack).size() != 1 || Potion.potionTypes[brew.getPotionEffects(stack).get(0).getPotionID()].isInstant())
|
||||
if(!brew.canInfuseIncense() || brew.getPotionEffects(stack).size() != 1 || GameData.getPotionRegistry().getObjectById(brew.getPotionEffects(stack).get(0).getPotionID()).isInstant())
|
||||
return null;
|
||||
|
||||
ItemStack brewStack = new ItemStack(this);
|
||||
|
||||
@@ -94,7 +94,7 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
|
||||
|
||||
addStringToTooltip(EnumChatFormatting.LIGHT_PURPLE + String.format(StatCollector.translateToLocal("botaniamisc.brewOf"), StatCollector.translateToLocal(brew.getUnlocalizedName(stack))), list);
|
||||
for(PotionEffect effect : brew.getPotionEffects(stack)) {
|
||||
Potion potion = Potion.potionTypes[effect.getPotionID()];
|
||||
Potion potion = GameData.getPotionRegistry().getObjectById(effect.getPotionID());
|
||||
EnumChatFormatting format = potion.isBadEffect() ? EnumChatFormatting.RED : EnumChatFormatting.GRAY;
|
||||
addStringToTooltip(" " + format + StatCollector.translateToLocal(effect.getEffectName()) + (effect.getAmplifier() == 0 ? "" : " " + StatCollector.translateToLocal("botania.roman" + (effect.getAmplifier() + 1))), list);
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
|
||||
float cost = (float) brew.getManaCost(stack) / effect.getDuration() / (1 + effect.getAmplifier()) * 2.5F;
|
||||
boolean doRand = cost < 1;
|
||||
if(ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), false)) {
|
||||
PotionEffect currentEffect = player.getActivePotionEffect(Potion.potionTypes[effect.getPotionID()]);
|
||||
PotionEffect currentEffect = player.getActivePotionEffect(GameData.getPotionRegistry().getObjectById(effect.getPotionID()));
|
||||
boolean nightVision = effect.getPotionID() == Potion.nightVision.id;
|
||||
if(currentEffect == null || currentEffect.getDuration() < (nightVision ? 205 : 3)) {
|
||||
PotionEffect applyEffect = new PotionEffect(effect.getPotionID(), nightVision ? 285 : 80, effect.getAmplifier(), true, true);
|
||||
|
||||
Reference in new issue
Block a user