Added Botania Transmutation effect for Alfheim bees.

Refactored the Aura provider code to not depend on Thaumcraft & allow for other modes of providing aura to bees.
Added Mana Apiary Booster.
Added Botania lexicon integration for Alfheim bee, Mana apiary booster.
This commit is contained in:
MysteriousAges committed 2015-04-24 14:45:21 -07:00
1 parent 549433e445
commit 83f82decd8
20 files changed
+389 -84

No files matched your search

@@ -6,33 +6,33 @@ import java.util.Map;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import magicbees.bees.AuraChargeType;
import magicbees.bees.AuraCharge;
public class AuraCharges {
private static final String auraChargesTagName = "AuraCharges";
private final Map<AuraChargeType, Long> charges = new HashMap<AuraChargeType, Long>(AuraChargeType.values().length);
private final Map<AuraCharge, Long> charges = new HashMap<AuraCharge, Long>(AuraCharge.values().length);
public void start(AuraChargeType auraChargeType, World worldObj) {
public void start(AuraCharge auraChargeType, World worldObj) {
charges.put(auraChargeType, worldObj.getTotalWorldTime());
}
public boolean isActive(AuraChargeType auraChargeType) {
public boolean isActive(AuraCharge auraChargeType) {
return charges.keySet().contains(auraChargeType);
}
public boolean isExpired(AuraChargeType auraChargeType, World worldObj) {
public boolean isExpired(AuraCharge auraChargeType, World worldObj) {
Long chargeStart = charges.get(auraChargeType);
return chargeStart == null || chargeStart + auraChargeType.duration <= worldObj.getTotalWorldTime();
}
public void stop(AuraChargeType AuraChargeType) {
public void stop(AuraCharge AuraChargeType) {
charges.remove(AuraChargeType);
}
public void writeToNBT(NBTTagCompound nbtTagCompound) {
NBTTagCompound auraChargeTags = new NBTTagCompound();
for (Map.Entry<AuraChargeType, Long> chargeEntry : charges.entrySet()) {
for (Map.Entry<AuraCharge, Long> chargeEntry : charges.entrySet()) {
String chargeName = chargeEntry.getKey().toString();
Long chargeStart = chargeEntry.getValue();
auraChargeTags.setLong(chargeName, chargeStart);
@@ -42,7 +42,7 @@ public class AuraCharges {
public void readFromNBT(NBTTagCompound nbtTagCompound) {
NBTTagCompound auraChargeTags = nbtTagCompound.getCompoundTag(auraChargesTagName);
for (AuraChargeType auraCharge : AuraChargeType.values()) {
for (AuraCharge auraCharge : AuraCharge.values()) {
String chargeName = auraCharge.toString();
Long chargeStart = auraChargeTags.getLong(chargeName);
if (chargeStart > 0) {
@@ -53,7 +53,7 @@ public class AuraCharges {
public int writeToFlags() {
int flags = 0;
for (AuraChargeType auraChargeType : charges.keySet()) {
for (AuraCharge auraChargeType : charges.keySet()) {
flags |= auraChargeType.flag;
}
return flags;
@@ -61,7 +61,7 @@ public class AuraCharges {
public void readFromFlags(int flags) {
charges.clear();
for (AuraChargeType auraCharge : AuraChargeType.values()) {
for (AuraCharge auraCharge : AuraCharge.values()) {
if ((flags & auraCharge.flag) > 0) {
charges.put(auraCharge, 0L);
}
@@ -4,7 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import magicbees.bees.AuraChargeType;
import magicbees.bees.AuraCharge;
import magicbees.api.bees.IMagicApiaryAuraProvider;
import magicbees.bees.BeeManager;
import magicbees.main.CommonProxy;
@@ -632,15 +632,15 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
}
public boolean isProductionBoosted() {
return auraCharges.isActive(AuraChargeType.PRODUCTION);
return auraCharges.isActive(AuraCharge.PRODUCTION);
}
public boolean isDeathRateBoosted() {
return auraCharges.isActive(AuraChargeType.DEATH);
return auraCharges.isActive(AuraCharge.DEATH);
}
public boolean isMutationBoosted() {
return auraCharges.isActive(AuraChargeType.MUTATION);
return auraCharges.isActive(AuraCharge.MUTATION);
}
private void updateAuraProvider() {
@@ -654,9 +654,9 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
}
boolean auraChargesChanged = false;
for (AuraChargeType chargeType : AuraChargeType.values()) {
if (!auraCharges.isActive(chargeType) && auraProvider.getCharge(chargeType)) {
auraCharges.start(chargeType, worldObj);
for (AuraCharge charge : AuraCharge.values()) {
if (!auraCharges.isActive(charge) && auraProvider.getCharge(charge.type)) {
auraCharges.start(charge, worldObj);
auraChargesChanged = true;
}
}
@@ -669,9 +669,9 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
private void tickCharges() {
boolean auraChargesChanged = false;
for (AuraChargeType chargeType : AuraChargeType.values()) {
if (auraCharges.isActive(chargeType) && auraCharges.isExpired(chargeType, worldObj) && (auraProvider == null || !auraProvider.getCharge(chargeType))) {
auraCharges.stop(chargeType);
for (AuraCharge charge : AuraCharge.values()) {
if (auraCharges.isActive(charge) && auraCharges.isExpired(charge, worldObj) && (auraProvider == null || !auraProvider.getCharge(charge.type))) {
auraCharges.stop(charge);
auraChargesChanged = true;
}
}
@@ -0,0 +1,161 @@
package magicbees.tileentity;
import java.util.HashMap;
import java.util.Map;
import magicbees.api.bees.AuraChargeType;
import magicbees.api.bees.IMagicApiaryAuraProvider;
import magicbees.bees.AuraCharge;
import magicbees.main.CommonProxy;
import magicbees.main.utils.compat.BotaniaHelper;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import vazkii.botania.api.mana.IManaReceiver;
import cpw.mods.fml.common.Optional;
@Optional.InterfaceList({
@Optional.Interface(iface = "vazkii.botania.api.mana.IManaReceiver", modid = BotaniaHelper.Name)
})
public class TileEntityManaAuraProvider extends TileEntity implements IMagicApiaryAuraProvider, IManaReceiver {
public static final String tileEntityName = CommonProxy.DOMAIN + ".manaAuraProvider";
private static final int MAX_CHARGES = 4;
private static final int MANA_PER_CHARGE = 4000;
private static final int MAX_MANA = MANA_PER_CHARGE * 4;
private static class ManaAuraCharge {
int charges;
int mana;
public int[] toArray() {
return new int[]{charges, mana};
}
public void fromArray(int[] array) {
if (array.length == 2) {
charges = array[0];
mana = array[1];
}
}
}
private final Map<AuraCharge, ManaAuraCharge> currentCharges;
private int currentMana;
public TileEntityManaAuraProvider() {
super();
AuraCharge[] auraChargeTypes = AuraCharge.values();
currentCharges = new HashMap<AuraCharge, ManaAuraCharge>(auraChargeTypes.length);
for (AuraCharge auraChargeType : auraChargeTypes) {
currentCharges.put(auraChargeType, new ManaAuraCharge());
}
}
@Override
public void updateEntity() {
long tick = worldObj.getTotalWorldTime();
int manaForCharge = currentMana / 5;
if (manaForCharge > 0) {
for (Map.Entry<AuraCharge, ManaAuraCharge> currentCharge : currentCharges.entrySet()) {
AuraCharge type = currentCharge.getKey();
ManaAuraCharge auraCharge = currentCharge.getValue();
if (auraCharge.charges < MAX_CHARGES && (tick % type.tickRate) == 0 && currentMana > 0) {
auraCharge.mana += manaForCharge;
if (auraCharge.mana > MANA_PER_CHARGE) {
auraCharge.mana -= MANA_PER_CHARGE;
auraCharge.charges++;
}
}
}
}
}
@Override
public boolean getMutationCharge() {
return getCharge(AuraChargeType.MUTATION);
}
@Override
public boolean getDeathRateCharge() {
return getCharge(AuraChargeType.DEATH);
}
@Override
public boolean getProductionCharge() {
return getCharge(AuraChargeType.PRODUCTION);
}
@Override
public boolean getCharge(AuraChargeType auraChargeType) {
ManaAuraCharge charge = currentCharges.get(AuraCharge.fromChargeType(auraChargeType));
if (charge == null) {
return false;
}
if (charge.charges > 0) {
charge.charges--;
return true;
}
return false;
}
@Override
@Optional.Method(modid = BotaniaHelper.Name)
public int getCurrentMana() {
return currentMana;
}
@Override
@Optional.Method(modid = BotaniaHelper.Name)
public boolean canRecieveManaFromBursts() {
return true;
}
@Override
@Optional.Method(modid = BotaniaHelper.Name)
public boolean isFull() {
return currentMana == MAX_MANA;
}
@Override
@Optional.Method(modid = BotaniaHelper.Name)
public void recieveMana(int amount) {
currentMana = (currentMana + amount > MAX_MANA) ? MAX_MANA : currentMana + amount;
}
@Override
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
for (Map.Entry<AuraCharge, ManaAuraCharge> charge : currentCharges.entrySet()) {
String auraName = charge.getKey().toString();
int[] array = tag.getIntArray(auraName);
ManaAuraCharge auraCharge = charge.getValue();
auraCharge.fromArray(array);
}
}
@Override
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
for (Map.Entry<AuraCharge, ManaAuraCharge> charge : currentCharges.entrySet()) {
String auraName = charge.getKey().toString();
ManaAuraCharge auraCharge = charge.getValue();
int[] array = auraCharge.toArray();
tag.setIntArray(auraName, array);
}
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound compound = new NBTTagCompound();
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, compound);
}
}
@@ -3,8 +3,8 @@ package magicbees.tileentity;
import java.util.HashMap;
import java.util.Map;
import magicbees.api.bees.IAuraChargeType;
import magicbees.bees.AuraChargeType;
import magicbees.api.bees.AuraChargeType;
import magicbees.bees.AuraCharge;
import magicbees.api.bees.IMagicApiaryAuraProvider;
import magicbees.main.CommonProxy;
import net.minecraft.nbt.NBTTagCompound;
@@ -18,8 +18,16 @@ public class TileEntityVisAuraProvider extends TileEntity implements IMagicApiar
private static final int MAX_CHARGES = 10;
private static final int VIS_PER_CHARGE = 8;
private static Map<AuraChargeType, Aspect> aspectMap;
static {
aspectMap = new HashMap<AuraChargeType, Aspect>(AuraChargeType.values().length);
aspectMap.put(AuraChargeType.MUTATION, Aspect.WATER);
aspectMap.put(AuraChargeType.DEATH, Aspect.ENTROPY);
aspectMap.put(AuraChargeType.PRODUCTION, Aspect.AIR);
}
private static class AuraCharge {
private static class VisAuraCharge {
int charges;
int vis;
@@ -35,15 +43,15 @@ public class TileEntityVisAuraProvider extends TileEntity implements IMagicApiar
}
}
private final Map<AuraChargeType, AuraCharge> currentCharges;
private final Map<AuraCharge, VisAuraCharge> currentCharges;
public TileEntityVisAuraProvider() {
super();
AuraChargeType[] auraChargeTypes = AuraChargeType.values();
currentCharges = new HashMap<AuraChargeType, AuraCharge>(auraChargeTypes.length);
for (AuraChargeType auraChargeType : auraChargeTypes) {
currentCharges.put(auraChargeType, new AuraCharge());
AuraCharge[] auraChargeTypes = AuraCharge.values();
currentCharges = new HashMap<AuraCharge, VisAuraCharge>(auraChargeTypes.length);
for (AuraCharge auraChargeType : auraChargeTypes) {
currentCharges.put(auraChargeType, new VisAuraCharge());
}
}
@@ -52,12 +60,12 @@ public class TileEntityVisAuraProvider extends TileEntity implements IMagicApiar
long tick = worldObj.getTotalWorldTime();
for (Map.Entry<AuraChargeType, AuraCharge> currentCharge : currentCharges.entrySet()) {
AuraChargeType type = currentCharge.getKey();
AuraCharge auraCharge = currentCharge.getValue();
for (Map.Entry<AuraCharge, VisAuraCharge> currentCharge : currentCharges.entrySet()) {
AuraCharge type = currentCharge.getKey();
VisAuraCharge auraCharge = currentCharge.getValue();
if (auraCharge.charges < MAX_CHARGES && (tick % type.tickRate) == 0) {
auraCharge.vis += getVisFromNet(type.aspect);
auraCharge.vis += getVisFromNet(aspectMap.get(type));
if (auraCharge.vis >= VIS_PER_CHARGE) {
auraCharge.vis -= VIS_PER_CHARGE;
auraCharge.charges++;
@@ -86,8 +94,8 @@ public class TileEntityVisAuraProvider extends TileEntity implements IMagicApiar
}
@Override
public boolean getCharge(IAuraChargeType auraChargeType) {
AuraCharge auraCharge = currentCharges.get(auraChargeType);
public boolean getCharge(AuraChargeType auraChargeType) {
VisAuraCharge auraCharge = currentCharges.get(AuraCharge.fromChargeType(auraChargeType));
if (auraCharge == null) {
return false;
}
@@ -103,10 +111,10 @@ public class TileEntityVisAuraProvider extends TileEntity implements IMagicApiar
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
for (Map.Entry<AuraChargeType, AuraCharge> charge : currentCharges.entrySet()) {
for (Map.Entry<AuraCharge, VisAuraCharge> charge : currentCharges.entrySet()) {
String auraName = charge.getKey().toString();
int[] array = tag.getIntArray(auraName);
AuraCharge auraCharge = charge.getValue();
VisAuraCharge auraCharge = charge.getValue();
auraCharge.fromArray(array);
}
}
@@ -115,9 +123,9 @@ public class TileEntityVisAuraProvider extends TileEntity implements IMagicApiar
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
for (Map.Entry<AuraChargeType, AuraCharge> charge : currentCharges.entrySet()) {
for (Map.Entry<AuraCharge, VisAuraCharge> charge : currentCharges.entrySet()) {
String auraName = charge.getKey().toString();
AuraCharge auraCharge = charge.getValue();
VisAuraCharge auraCharge = charge.getValue();
int[] array = auraCharge.toArray();
tag.setIntArray(auraName, array);
}