mirror of
https://github.com/GTNewHorizons/MagicBees.git
synced 2026-11-21 04:32:34 +00:00
Spotless
This commit is contained in:
156 files changed
+14896
-13422
No files matched your search
@@ -2,69 +2,67 @@ package magicbees.tileentity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import magicbees.bees.AuraCharge;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import magicbees.bees.AuraCharge;
|
||||
|
||||
public class AuraCharges {
|
||||
private static final String auraChargesTagName = "AuraCharges";
|
||||
private static final String auraChargesTagName = "AuraCharges";
|
||||
|
||||
private final Map<AuraCharge, Long> charges = new HashMap<AuraCharge, Long>(AuraCharge.values().length);
|
||||
private final Map<AuraCharge, Long> charges = new HashMap<AuraCharge, Long>(AuraCharge.values().length);
|
||||
|
||||
public void start(AuraCharge auraChargeType, World worldObj) {
|
||||
charges.put(auraChargeType, worldObj.getTotalWorldTime());
|
||||
}
|
||||
public void start(AuraCharge auraChargeType, World worldObj) {
|
||||
charges.put(auraChargeType, worldObj.getTotalWorldTime());
|
||||
}
|
||||
|
||||
public boolean isActive(AuraCharge auraChargeType) {
|
||||
return charges.keySet().contains(auraChargeType);
|
||||
}
|
||||
public boolean isActive(AuraCharge auraChargeType) {
|
||||
return charges.keySet().contains(auraChargeType);
|
||||
}
|
||||
|
||||
public boolean isExpired(AuraCharge auraChargeType, World worldObj) {
|
||||
Long chargeStart = charges.get(auraChargeType);
|
||||
return chargeStart == null || chargeStart + auraChargeType.duration <= worldObj.getTotalWorldTime();
|
||||
}
|
||||
public boolean isExpired(AuraCharge auraChargeType, World worldObj) {
|
||||
Long chargeStart = charges.get(auraChargeType);
|
||||
return chargeStart == null || chargeStart + auraChargeType.duration <= worldObj.getTotalWorldTime();
|
||||
}
|
||||
|
||||
public void stop(AuraCharge AuraChargeType) {
|
||||
charges.remove(AuraChargeType);
|
||||
}
|
||||
public void stop(AuraCharge AuraChargeType) {
|
||||
charges.remove(AuraChargeType);
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagCompound auraChargeTags = new NBTTagCompound();
|
||||
for (Map.Entry<AuraCharge, Long> chargeEntry : charges.entrySet()) {
|
||||
String chargeName = chargeEntry.getKey().toString();
|
||||
Long chargeStart = chargeEntry.getValue();
|
||||
auraChargeTags.setLong(chargeName, chargeStart);
|
||||
}
|
||||
nbtTagCompound.setTag(auraChargesTagName, auraChargeTags);
|
||||
}
|
||||
public void writeToNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagCompound auraChargeTags = new NBTTagCompound();
|
||||
for (Map.Entry<AuraCharge, Long> chargeEntry : charges.entrySet()) {
|
||||
String chargeName = chargeEntry.getKey().toString();
|
||||
Long chargeStart = chargeEntry.getValue();
|
||||
auraChargeTags.setLong(chargeName, chargeStart);
|
||||
}
|
||||
nbtTagCompound.setTag(auraChargesTagName, auraChargeTags);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagCompound auraChargeTags = nbtTagCompound.getCompoundTag(auraChargesTagName);
|
||||
for (AuraCharge auraCharge : AuraCharge.values()) {
|
||||
String chargeName = auraCharge.toString();
|
||||
Long chargeStart = auraChargeTags.getLong(chargeName);
|
||||
if (chargeStart > 0) {
|
||||
charges.put(auraCharge, chargeStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
||||
NBTTagCompound auraChargeTags = nbtTagCompound.getCompoundTag(auraChargesTagName);
|
||||
for (AuraCharge auraCharge : AuraCharge.values()) {
|
||||
String chargeName = auraCharge.toString();
|
||||
Long chargeStart = auraChargeTags.getLong(chargeName);
|
||||
if (chargeStart > 0) {
|
||||
charges.put(auraCharge, chargeStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int writeToFlags() {
|
||||
int flags = 0;
|
||||
for (AuraCharge auraChargeType : charges.keySet()) {
|
||||
flags |= auraChargeType.flag;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
public int writeToFlags() {
|
||||
int flags = 0;
|
||||
for (AuraCharge auraChargeType : charges.keySet()) {
|
||||
flags |= auraChargeType.flag;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
public void readFromFlags(int flags) {
|
||||
charges.clear();
|
||||
for (AuraCharge auraCharge : AuraCharge.values()) {
|
||||
if ((flags & auraCharge.flag) > 0) {
|
||||
charges.put(auraCharge, 0L);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void readFromFlags(int flags) {
|
||||
charges.clear();
|
||||
for (AuraCharge auraCharge : AuraCharge.values()) {
|
||||
if ((flags & auraCharge.flag) > 0) {
|
||||
charges.put(auraCharge, 0L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,7 @@
|
||||
package magicbees.tileentity;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.apiculture.DefaultBeeListener;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
@@ -25,9 +13,15 @@ import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.core.IErrorState;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import magicbees.bees.BeeManager;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
/**
|
||||
* Simulates enough of a bee house to fire the bee effects. =D
|
||||
@@ -36,211 +30,204 @@ import magicbees.bees.BeeManager;
|
||||
*/
|
||||
public class EffectJarHousing implements IBeeHousing {
|
||||
|
||||
private static final IErrorLogic errorLogic = new JarErrorLogic();
|
||||
private static final Iterable<IBeeListener> beeListeners = ImmutableSet.<IBeeListener>of(new DefaultBeeListener());
|
||||
private static final Iterable<IBeeModifier> beeModifiers = ImmutableSet.<IBeeModifier>of(new JarHousingModifier());
|
||||
private static final IErrorLogic errorLogic = new JarErrorLogic();
|
||||
private static final Iterable<IBeeListener> beeListeners = ImmutableSet.<IBeeListener>of(new DefaultBeeListener());
|
||||
private static final Iterable<IBeeModifier> beeModifiers = ImmutableSet.<IBeeModifier>of(new JarHousingModifier());
|
||||
|
||||
private final IBeekeepingLogic beekeepingLogic;
|
||||
private final TileEntityEffectJar jarEntity;
|
||||
private final BiomeGenBase biome;
|
||||
private final IBeeHousingInventory inventory;
|
||||
private final IBeekeepingLogic beekeepingLogic;
|
||||
private final TileEntityEffectJar jarEntity;
|
||||
private final BiomeGenBase biome;
|
||||
private final IBeeHousingInventory inventory;
|
||||
|
||||
public EffectJarHousing(TileEntityEffectJar entity) {
|
||||
this.jarEntity = entity;
|
||||
this.biome = entity.getWorldObj().getBiomeGenForCoords(entity.xCoord, entity.zCoord);
|
||||
this.inventory = new JarBeeHousingInventory(entity);
|
||||
this.beekeepingLogic = BeeManager.beeRoot.createBeekeepingLogic(this);
|
||||
}
|
||||
public EffectJarHousing(TileEntityEffectJar entity) {
|
||||
this.jarEntity = entity;
|
||||
this.biome = entity.getWorldObj().getBiomeGenForCoords(entity.xCoord, entity.zCoord);
|
||||
this.inventory = new JarBeeHousingInventory(entity);
|
||||
this.beekeepingLogic = BeeManager.beeRoot.createBeekeepingLogic(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkCoordinates getCoordinates() {
|
||||
return new ChunkCoordinates(jarEntity.xCoord, jarEntity.yCoord, jarEntity.zCoord);
|
||||
}
|
||||
@Override
|
||||
public ChunkCoordinates getCoordinates() {
|
||||
return new ChunkCoordinates(jarEntity.xCoord, jarEntity.yCoord, jarEntity.zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeGenBase getBiome() {
|
||||
return biome;
|
||||
}
|
||||
@Override
|
||||
public BiomeGenBase getBiome() {
|
||||
return biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
return EnumTemperature.getFromBiome(biome, jarEntity.xCoord, jarEntity.yCoord, jarEntity.zCoord);
|
||||
}
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
return EnumTemperature.getFromBiome(biome, jarEntity.xCoord, jarEntity.yCoord, jarEntity.zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
return EnumHumidity.getFromValue(biome.rainfall);
|
||||
}
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
return EnumHumidity.getFromValue(biome.rainfall);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockLightValue() {
|
||||
return jarEntity.getWorldObj().getBlockLightValue(jarEntity.xCoord, jarEntity.yCoord + 1, jarEntity.zCoord);
|
||||
}
|
||||
@Override
|
||||
public int getBlockLightValue() {
|
||||
return jarEntity.getWorldObj().getBlockLightValue(jarEntity.xCoord, jarEntity.yCoord + 1, jarEntity.zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBlockSeeTheSky() {
|
||||
return jarEntity.getWorldObj().canBlockSeeTheSky(jarEntity.xCoord, jarEntity.yCoord + 1, jarEntity.zCoord);
|
||||
}
|
||||
@Override
|
||||
public boolean canBlockSeeTheSky() {
|
||||
return jarEntity.getWorldObj().canBlockSeeTheSky(jarEntity.xCoord, jarEntity.yCoord + 1, jarEntity.zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return jarEntity.getWorldObj();
|
||||
}
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return jarEntity.getWorldObj();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfile getOwner() {
|
||||
return jarEntity.getOwner();
|
||||
}
|
||||
@Override
|
||||
public GameProfile getOwner() {
|
||||
return jarEntity.getOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getBeeFXCoordinates() {
|
||||
return Vec3.createVectorHelper(jarEntity.xCoord + 0.5f, jarEntity.yCoord + 0.5f, jarEntity.zCoord + 0.5f);
|
||||
}
|
||||
@Override
|
||||
public Vec3 getBeeFXCoordinates() {
|
||||
return Vec3.createVectorHelper(jarEntity.xCoord + 0.5f, jarEntity.yCoord + 0.5f, jarEntity.zCoord + 0.5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IErrorLogic getErrorLogic() {
|
||||
return errorLogic;
|
||||
}
|
||||
@Override
|
||||
public IErrorLogic getErrorLogic() {
|
||||
return errorLogic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBeeHousingInventory getBeeInventory() {
|
||||
return inventory;
|
||||
}
|
||||
@Override
|
||||
public IBeeHousingInventory getBeeInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBeekeepingLogic getBeekeepingLogic() {
|
||||
return beekeepingLogic;
|
||||
}
|
||||
@Override
|
||||
public IBeekeepingLogic getBeekeepingLogic() {
|
||||
return beekeepingLogic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IBeeModifier> getBeeModifiers() {
|
||||
return beeModifiers;
|
||||
}
|
||||
@Override
|
||||
public Iterable<IBeeModifier> getBeeModifiers() {
|
||||
return beeModifiers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IBeeListener> getBeeListeners() {
|
||||
return beeListeners;
|
||||
}
|
||||
@Override
|
||||
public Iterable<IBeeListener> getBeeListeners() {
|
||||
return beeListeners;
|
||||
}
|
||||
|
||||
private static class JarBeeHousingInventory implements IBeeHousingInventory {
|
||||
private final TileEntityEffectJar jarEntity;
|
||||
private static class JarBeeHousingInventory implements IBeeHousingInventory {
|
||||
private final TileEntityEffectJar jarEntity;
|
||||
|
||||
public JarBeeHousingInventory(TileEntityEffectJar jarEntity) {
|
||||
this.jarEntity = jarEntity;
|
||||
}
|
||||
public JarBeeHousingInventory(TileEntityEffectJar jarEntity) {
|
||||
this.jarEntity = jarEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getQueen() {
|
||||
return jarEntity.getStackInSlot(TileEntityEffectJar.QUEEN_SLOT);
|
||||
}
|
||||
@Override
|
||||
public ItemStack getQueen() {
|
||||
return jarEntity.getStackInSlot(TileEntityEffectJar.QUEEN_SLOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDrone() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getDrone() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQueen(ItemStack itemStack) {
|
||||
jarEntity.setInventorySlotContents(TileEntityEffectJar.QUEEN_SLOT, itemStack);
|
||||
}
|
||||
@Override
|
||||
public void setQueen(ItemStack itemStack) {
|
||||
jarEntity.setInventorySlotContents(TileEntityEffectJar.QUEEN_SLOT, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDrone(ItemStack itemstack) {
|
||||
}
|
||||
@Override
|
||||
public void setDrone(ItemStack itemstack) {}
|
||||
|
||||
@Override
|
||||
public boolean addProduct(ItemStack product, boolean all) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean addProduct(ItemStack product, boolean all) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static class JarErrorLogic implements IErrorLogic {
|
||||
private static class JarErrorLogic implements IErrorLogic {
|
||||
|
||||
@Override
|
||||
public boolean setCondition(boolean condition, IErrorState errorState) {
|
||||
return condition;
|
||||
}
|
||||
@Override
|
||||
public boolean setCondition(boolean condition, IErrorState errorState) {
|
||||
return condition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(IErrorState state) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean contains(IErrorState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasErrors() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean hasErrors() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearErrors() {
|
||||
@Override
|
||||
public void clearErrors() {}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {}
|
||||
|
||||
}
|
||||
@Override
|
||||
public ImmutableSet<IErrorState> getErrorStates() {
|
||||
return ImmutableSet.of();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
private static class JarHousingModifier implements IBeeModifier {
|
||||
@Override
|
||||
public float getTerritoryModifier(IBeeGenome genome, float currentModifier) {
|
||||
return 0.9f;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableSet<IErrorState> getErrorStates() {
|
||||
return ImmutableSet.of();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
private static class JarHousingModifier implements IBeeModifier {
|
||||
@Override
|
||||
public float getTerritoryModifier(IBeeGenome genome, float currentModifier) {
|
||||
return 0.9f;
|
||||
}
|
||||
@Override
|
||||
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
||||
return 0f;
|
||||
}
|
||||
@Override
|
||||
public float getFloweringModifier(IBeeGenome genome, float currentModifier) {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
||||
return 0f;
|
||||
}
|
||||
@Override
|
||||
public float getGeneticDecay(IBeeGenome genome, float currentModifier) {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
|
||||
return 0f;
|
||||
}
|
||||
@Override
|
||||
public boolean isSealed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloweringModifier(IBeeGenome genome, float currentModifier) {
|
||||
return 0f;
|
||||
}
|
||||
@Override
|
||||
public boolean isSelfLighted() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGeneticDecay(IBeeGenome genome, float currentModifier) {
|
||||
return 0f;
|
||||
}
|
||||
@Override
|
||||
public boolean isSunlightSimulated() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSealed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelfLighted() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSunlightSimulated() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHellish() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean isHellish() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
package magicbees.tileentity;
|
||||
|
||||
public interface ITileEntityAuraCharged {
|
||||
AuraCharges getAuraCharges();
|
||||
AuraCharges getAuraCharges();
|
||||
}
|
||||
@@ -2,5 +2,5 @@ package magicbees.tileentity;
|
||||
|
||||
public interface ITileEntityFlags {
|
||||
|
||||
public void setFlags(int[] flags);
|
||||
public void setFlags(int[] flags);
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package magicbees.tileentity;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import magicbees.main.CommonProxy;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -9,235 +11,219 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
|
||||
|
||||
public class TileEntityEffectJar extends TileEntity implements IInventory {
|
||||
public static final String tileEntityName = CommonProxy.DOMAIN + ".effectJar";
|
||||
private static final int SLOT_COUNT = 2;
|
||||
public static final int DRONE_SLOT = 0;
|
||||
public static final int QUEEN_SLOT = SLOT_COUNT - 1;
|
||||
public static final String tileEntityName = CommonProxy.DOMAIN + ".effectJar";
|
||||
private static final int SLOT_COUNT = 2;
|
||||
public static final int DRONE_SLOT = 0;
|
||||
public static final int QUEEN_SLOT = SLOT_COUNT - 1;
|
||||
|
||||
private GameProfile ownerName;
|
||||
private ItemStack[] beeSlots;
|
||||
private IEffectData[] effectData = new IEffectData[2];
|
||||
private int throttle;
|
||||
public int currentBeeHealth;
|
||||
public int currentBeeColour;
|
||||
|
||||
public TileEntityEffectJar() {
|
||||
super();
|
||||
this.beeSlots = new ItemStack[SLOT_COUNT];
|
||||
}
|
||||
|
||||
public void setOwner(EntityPlayer player) {
|
||||
this.ownerName = player.getGameProfile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderInPass(int pass) {
|
||||
return pass == 1;
|
||||
}
|
||||
private GameProfile ownerName;
|
||||
private ItemStack[] beeSlots;
|
||||
private IEffectData[] effectData = new IEffectData[2];
|
||||
private int throttle;
|
||||
public int currentBeeHealth;
|
||||
public int currentBeeColour;
|
||||
|
||||
public GameProfile getOwner() {
|
||||
return this.ownerName;
|
||||
}
|
||||
public TileEntityEffectJar() {
|
||||
super();
|
||||
this.beeSlots = new ItemStack[SLOT_COUNT];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
// Last slot reserved for "queen"
|
||||
return this.beeSlots.length - 1;
|
||||
}
|
||||
public void setOwner(EntityPlayer player) {
|
||||
this.ownerName = player.getGameProfile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return beeSlots[slot];
|
||||
}
|
||||
@Override
|
||||
public boolean shouldRenderInPass(int pass) {
|
||||
return pass == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (hasQueen()) {
|
||||
tickQueen();
|
||||
}
|
||||
else if (hasDrone()) {
|
||||
createQueenFromDrone();
|
||||
}
|
||||
}
|
||||
public GameProfile getOwner() {
|
||||
return this.ownerName;
|
||||
}
|
||||
|
||||
private void createQueenFromDrone() {
|
||||
ItemStack droneStack = this.beeSlots[DRONE_SLOT];
|
||||
if (magicbees.bees.BeeManager.beeRoot.isDrone(droneStack))
|
||||
{
|
||||
IBee bee = magicbees.bees.BeeManager.beeRoot.getMember(droneStack);
|
||||
if (droneStack.stackSize == 1)
|
||||
{
|
||||
this.beeSlots[DRONE_SLOT] = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
droneStack.stackSize--;
|
||||
}
|
||||
|
||||
this.beeSlots[QUEEN_SLOT] = droneStack.copy();
|
||||
this.beeSlots[QUEEN_SLOT].stackSize = 1;
|
||||
|
||||
int current = bee.getHealth();
|
||||
int max = bee.getMaxHealth();
|
||||
currentBeeHealth = (current * 100) / max;
|
||||
currentBeeColour = bee.getGenome().getPrimary().getIconColour(0);
|
||||
}
|
||||
this.markDirty();
|
||||
}
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
// Last slot reserved for "queen"
|
||||
return this.beeSlots.length - 1;
|
||||
}
|
||||
|
||||
private boolean hasDrone() {
|
||||
return this.beeSlots[DRONE_SLOT] != null;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return beeSlots[slot];
|
||||
}
|
||||
|
||||
private void tickQueen() {
|
||||
IBee queen = magicbees.bees.BeeManager.beeRoot.getMember(this.beeSlots[QUEEN_SLOT]);
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (hasQueen()) {
|
||||
tickQueen();
|
||||
} else if (hasDrone()) {
|
||||
createQueenFromDrone();
|
||||
}
|
||||
}
|
||||
|
||||
currentBeeHealth = (queen.getHealth() * 100) / queen.getMaxHealth();
|
||||
currentBeeColour = queen.getGenome().getPrimary().getIconColour(0);
|
||||
|
||||
EffectJarHousing housingLogic = new EffectJarHousing(this);
|
||||
this.effectData = queen.doEffect(this.effectData, housingLogic);
|
||||
if (this.worldObj.getWorldTime() % 5 == 0)
|
||||
{
|
||||
this.effectData = queen.doFX(this.effectData, housingLogic);
|
||||
}
|
||||
|
||||
// run the queen
|
||||
if (throttle > 550)
|
||||
{
|
||||
throttle = 0;
|
||||
queen.age(this.worldObj, 0.26f);
|
||||
|
||||
if (queen.getHealth() == 0)
|
||||
{
|
||||
this.beeSlots[QUEEN_SLOT] = null;
|
||||
currentBeeHealth = 0;
|
||||
currentBeeColour = 0x0ffffff;
|
||||
}
|
||||
else
|
||||
{
|
||||
queen.writeToNBT(this.beeSlots[QUEEN_SLOT].stackTagCompound);
|
||||
}
|
||||
this.markDirty();
|
||||
}
|
||||
else
|
||||
{
|
||||
throttle++;
|
||||
}
|
||||
}
|
||||
private void createQueenFromDrone() {
|
||||
ItemStack droneStack = this.beeSlots[DRONE_SLOT];
|
||||
if (magicbees.bees.BeeManager.beeRoot.isDrone(droneStack)) {
|
||||
IBee bee = magicbees.bees.BeeManager.beeRoot.getMember(droneStack);
|
||||
if (droneStack.stackSize == 1) {
|
||||
this.beeSlots[DRONE_SLOT] = null;
|
||||
} else {
|
||||
droneStack.stackSize--;
|
||||
}
|
||||
|
||||
private boolean hasQueen() {
|
||||
return this.beeSlots[QUEEN_SLOT] != null;
|
||||
}
|
||||
this.beeSlots[QUEEN_SLOT] = droneStack.copy();
|
||||
this.beeSlots[QUEEN_SLOT].stackSize = 1;
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int count) {
|
||||
ItemStack value = null;
|
||||
if (this.beeSlots[slot] != null) {
|
||||
value = this.beeSlots[slot].copy();
|
||||
value.stackSize = Math.min(count, this.beeSlots[slot].stackSize);
|
||||
this.beeSlots[slot].stackSize -= value.stackSize;
|
||||
if (this.beeSlots[slot].stackSize == 0) {
|
||||
this.beeSlots[slot] = null;
|
||||
}
|
||||
}
|
||||
markDirty();
|
||||
return value;
|
||||
}
|
||||
int current = bee.getHealth();
|
||||
int max = bee.getMaxHealth();
|
||||
currentBeeHealth = (current * 100) / max;
|
||||
currentBeeColour = bee.getGenome().getPrimary().getIconColour(0);
|
||||
}
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
ItemStack value = null;
|
||||
if (this.beeSlots[slot] != null) {
|
||||
value = this.beeSlots[slot];
|
||||
this.beeSlots[slot] = null;
|
||||
}
|
||||
markDirty();
|
||||
return value;
|
||||
}
|
||||
private boolean hasDrone() {
|
||||
return this.beeSlots[DRONE_SLOT] != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagRoot) {
|
||||
super.readFromNBT(tagRoot);
|
||||
|
||||
NBTTagList nbttaglist = tagRoot.getTagList("Items", Constants.NBT.TAG_COMPOUND);
|
||||
this.beeSlots = new ItemStack[SLOT_COUNT];
|
||||
private void tickQueen() {
|
||||
IBee queen = magicbees.bees.BeeManager.beeRoot.getMember(this.beeSlots[QUEEN_SLOT]);
|
||||
|
||||
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
|
||||
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
|
||||
byte b0 = nbttagcompound1.getByte("Slot");
|
||||
currentBeeHealth = (queen.getHealth() * 100) / queen.getMaxHealth();
|
||||
currentBeeColour = queen.getGenome().getPrimary().getIconColour(0);
|
||||
|
||||
if (b0 >= 0 && b0 < this.beeSlots.length) {
|
||||
this.beeSlots[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
this.currentBeeHealth = tagRoot.getInteger("currentBeeHealth");
|
||||
this.throttle = tagRoot.getInteger("throttle");
|
||||
}
|
||||
EffectJarHousing housingLogic = new EffectJarHousing(this);
|
||||
this.effectData = queen.doEffect(this.effectData, housingLogic);
|
||||
if (this.worldObj.getWorldTime() % 5 == 0) {
|
||||
this.effectData = queen.doFX(this.effectData, housingLogic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tagRoot) {
|
||||
super.writeToNBT(tagRoot);
|
||||
// run the queen
|
||||
if (throttle > 550) {
|
||||
throttle = 0;
|
||||
queen.age(this.worldObj, 0.26f);
|
||||
|
||||
NBTTagList inventory = new NBTTagList();
|
||||
for (int i = 0; i < this.beeSlots.length; ++i) {
|
||||
if (this.beeSlots[i] != null) {
|
||||
NBTTagCompound itemTag = new NBTTagCompound();
|
||||
itemTag.setByte("Slot", (byte)i);
|
||||
this.beeSlots[i].writeToNBT(itemTag);
|
||||
inventory.appendTag(itemTag);
|
||||
}
|
||||
}
|
||||
tagRoot.setTag("Items", inventory);
|
||||
tagRoot.setInteger("currentBeeHealth", this.currentBeeHealth);
|
||||
tagRoot.setInteger("throttle", this.throttle);
|
||||
}
|
||||
if (queen.getHealth() == 0) {
|
||||
this.beeSlots[QUEEN_SLOT] = null;
|
||||
currentBeeHealth = 0;
|
||||
currentBeeColour = 0x0ffffff;
|
||||
} else {
|
||||
queen.writeToNBT(this.beeSlots[QUEEN_SLOT].stackTagCompound);
|
||||
}
|
||||
this.markDirty();
|
||||
} else {
|
||||
throttle++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack itemStack) {
|
||||
this.beeSlots[slot] = itemStack;
|
||||
if (this.beeSlots[slot] != null) {
|
||||
this.beeSlots[slot].stackSize = Math.min(this.beeSlots[slot].stackSize,
|
||||
this.beeSlots[slot].getItem().getItemStackLimit(this.beeSlots[slot]));
|
||||
}
|
||||
this.markDirty();
|
||||
}
|
||||
private boolean hasQueen() {
|
||||
return this.beeSlots[QUEEN_SLOT] != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "container.effectJar";
|
||||
}
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int count) {
|
||||
ItemStack value = null;
|
||||
if (this.beeSlots[slot] != null) {
|
||||
value = this.beeSlots[slot].copy();
|
||||
value.stackSize = Math.min(count, this.beeSlots[slot].stackSize);
|
||||
this.beeSlots[slot].stackSize -= value.stackSize;
|
||||
if (this.beeSlots[slot].stackSize == 0) {
|
||||
this.beeSlots[slot] = null;
|
||||
}
|
||||
}
|
||||
markDirty();
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
ItemStack value = null;
|
||||
if (this.beeSlots[slot] != null) {
|
||||
value = this.beeSlots[slot];
|
||||
this.beeSlots[slot] = null;
|
||||
}
|
||||
markDirty();
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagRoot) {
|
||||
super.readFromNBT(tagRoot);
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
NBTTagList nbttaglist = tagRoot.getTagList("Items", Constants.NBT.TAG_COMPOUND);
|
||||
this.beeSlots = new ItemStack[SLOT_COUNT];
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemStack) {
|
||||
return true;
|
||||
}
|
||||
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
|
||||
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
|
||||
byte b0 = nbttagcompound1.getByte("Slot");
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
if (b0 >= 0 && b0 < this.beeSlots.length) {
|
||||
this.beeSlots[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
this.currentBeeHealth = tagRoot.getInteger("currentBeeHealth");
|
||||
this.throttle = tagRoot.getInteger("throttle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tagRoot) {
|
||||
super.writeToNBT(tagRoot);
|
||||
|
||||
NBTTagList inventory = new NBTTagList();
|
||||
for (int i = 0; i < this.beeSlots.length; ++i) {
|
||||
if (this.beeSlots[i] != null) {
|
||||
NBTTagCompound itemTag = new NBTTagCompound();
|
||||
itemTag.setByte("Slot", (byte) i);
|
||||
this.beeSlots[i].writeToNBT(itemTag);
|
||||
inventory.appendTag(itemTag);
|
||||
}
|
||||
}
|
||||
tagRoot.setTag("Items", inventory);
|
||||
tagRoot.setInteger("currentBeeHealth", this.currentBeeHealth);
|
||||
tagRoot.setInteger("throttle", this.throttle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack itemStack) {
|
||||
this.beeSlots[slot] = itemStack;
|
||||
if (this.beeSlots[slot] != null) {
|
||||
this.beeSlots[slot].stackSize = Math.min(
|
||||
this.beeSlots[slot].stackSize,
|
||||
this.beeSlots[slot].getItem().getItemStackLimit(this.beeSlots[slot]));
|
||||
}
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "container.effectJar";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemStack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {}
|
||||
}
|
||||
@@ -1,11 +1,26 @@
|
||||
package magicbees.tileentity;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.apiculture.DefaultBeeListener;
|
||||
import forestry.api.apiculture.DefaultBeeModifier;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeHousingInventory;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.apiculture.IBeekeepingMode;
|
||||
import forestry.api.apiculture.IHiveFrame;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import magicbees.api.bees.IMagicApiaryAuraProvider;
|
||||
import magicbees.bees.AuraCharge;
|
||||
import magicbees.bees.BeeManager;
|
||||
@@ -32,24 +47,6 @@ import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.apiculture.DefaultBeeListener;
|
||||
import forestry.api.apiculture.DefaultBeeModifier;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeHousingInventory;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.apiculture.IBeekeepingMode;
|
||||
import forestry.api.apiculture.IHiveFrame;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
|
||||
public class TileEntityMagicApiary extends TileEntity implements ISidedInventory, IBeeHousing, ITileEntityAuraCharged {
|
||||
|
||||
// Constants
|
||||
@@ -69,7 +66,7 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
private final MagicApiaryInventory inventory;
|
||||
private final AuraCharges auraCharges = new AuraCharges();
|
||||
|
||||
public TileEntityMagicApiary(){
|
||||
public TileEntityMagicApiary() {
|
||||
beeLogic = BeeManager.beeRoot.createBeekeepingLogic(this);
|
||||
beeModifier = new MagicApiaryBeeModifier(this);
|
||||
beeListener = new MagicApiaryBeeListener(this);
|
||||
@@ -106,7 +103,7 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
}
|
||||
|
||||
public void setOwner(EntityPlayer player) {
|
||||
this.ownerProfile = player.getGameProfile();
|
||||
this.ownerProfile = player.getGameProfile();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -179,7 +176,7 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
if (itemStack != null) {
|
||||
if (itemStack.stackSize <= j) {
|
||||
setInventorySlotContents(i, null);
|
||||
}else{
|
||||
} else {
|
||||
itemStack = itemStack.splitStack(j);
|
||||
markDirty();
|
||||
}
|
||||
@@ -222,14 +219,10 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
|
||||
}
|
||||
public void openInventory() {}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
|
||||
}
|
||||
public void closeInventory() {}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemStack) {
|
||||
@@ -288,9 +281,8 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
public void updateEntity() {
|
||||
if (worldObj.isRemote) {
|
||||
updateClientSide();
|
||||
}
|
||||
else {
|
||||
updateServerSide();
|
||||
} else {
|
||||
updateServerSide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,13 +293,12 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
}
|
||||
|
||||
public void updateServerSide() {
|
||||
if (this.auraProvider == null) {
|
||||
findAuraProvider();
|
||||
}
|
||||
else {
|
||||
updateAuraProvider();
|
||||
}
|
||||
tickCharges();
|
||||
if (this.auraProvider == null) {
|
||||
findAuraProvider();
|
||||
} else {
|
||||
updateAuraProvider();
|
||||
}
|
||||
tickCharges();
|
||||
|
||||
if (beeLogic.canWork()) {
|
||||
beeLogic.doWork();
|
||||
@@ -325,61 +316,63 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
iCrafting.sendProgressBarUpdate(container, 0, beeLogic.getBeeProgressPercent());
|
||||
}
|
||||
|
||||
|
||||
public boolean isProductionBoosted() {
|
||||
return auraCharges.isActive(AuraCharge.PRODUCTION);
|
||||
}
|
||||
|
||||
|
||||
public boolean isDeathRateBoosted() {
|
||||
return auraCharges.isActive(AuraCharge.DEATH);
|
||||
}
|
||||
|
||||
|
||||
public boolean isMutationBoosted() {
|
||||
return auraCharges.isActive(AuraCharge.MUTATION);
|
||||
}
|
||||
|
||||
|
||||
private void updateAuraProvider() {
|
||||
if (worldObj.getTotalWorldTime() % 10 != 0) {
|
||||
return;
|
||||
}
|
||||
if (getAuraProvider(auraProviderPosition) == null) {
|
||||
this.auraProvider = null;
|
||||
this.auraProviderPosition = null;
|
||||
return;
|
||||
}
|
||||
|
||||
boolean auraChargesChanged = false;
|
||||
if (worldObj.getTotalWorldTime() % 10 != 0) {
|
||||
return;
|
||||
}
|
||||
if (getAuraProvider(auraProviderPosition) == null) {
|
||||
this.auraProvider = null;
|
||||
this.auraProviderPosition = null;
|
||||
return;
|
||||
}
|
||||
|
||||
boolean auraChargesChanged = false;
|
||||
for (AuraCharge charge : AuraCharge.values()) {
|
||||
if (!auraCharges.isActive(charge) && auraProvider.getCharge(charge.type)) {
|
||||
auraCharges.start(charge, worldObj);
|
||||
auraChargesChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (auraChargesChanged) {
|
||||
|
||||
if (auraChargesChanged) {
|
||||
NetworkEventHandler.getInstance().sendAuraChargeUpdate(this, auraCharges);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void tickCharges() {
|
||||
boolean auraChargesChanged = false;
|
||||
|
||||
for (AuraCharge charge : AuraCharge.values()) {
|
||||
if (auraCharges.isActive(charge) && auraCharges.isExpired(charge, worldObj) && (auraProvider == null || !auraProvider.getCharge(charge.type))) {
|
||||
if (auraCharges.isActive(charge)
|
||||
&& auraCharges.isExpired(charge, worldObj)
|
||||
&& (auraProvider == null || !auraProvider.getCharge(charge.type))) {
|
||||
auraCharges.stop(charge);
|
||||
auraChargesChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (auraChargesChanged) {
|
||||
NetworkEventHandler.getInstance().sendAuraChargeUpdate(this, auraCharges);
|
||||
}
|
||||
if (auraChargesChanged) {
|
||||
NetworkEventHandler.getInstance().sendAuraChargeUpdate(this, auraCharges);
|
||||
}
|
||||
}
|
||||
|
||||
private void findAuraProvider() {
|
||||
if (worldObj.getTotalWorldTime() % 5 != 0) {
|
||||
return;
|
||||
}
|
||||
if (worldObj.getTotalWorldTime() % 5 != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.auraProviderPosition == null) {
|
||||
List<Chunk> chunks = getChunksInSearchRange();
|
||||
@@ -395,67 +388,72 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<Chunk> getChunksInSearchRange() {
|
||||
List<Chunk> chunks = new ArrayList<Chunk>(4);
|
||||
chunks.add(worldObj.getChunkFromBlockCoords(xCoord - AURAPROVIDER_SEARCH_RADIUS, zCoord - AURAPROVIDER_SEARCH_RADIUS));
|
||||
Chunk chunk = worldObj.getChunkFromBlockCoords(xCoord + AURAPROVIDER_SEARCH_RADIUS, zCoord - AURAPROVIDER_SEARCH_RADIUS);
|
||||
if (!chunks.contains(chunk)) {
|
||||
chunks.add(chunk);
|
||||
}
|
||||
chunk = worldObj.getChunkFromBlockCoords(xCoord - AURAPROVIDER_SEARCH_RADIUS, zCoord + AURAPROVIDER_SEARCH_RADIUS);
|
||||
if (!chunks.contains(chunk)) {
|
||||
chunks.add(chunk);
|
||||
}
|
||||
chunk = worldObj.getChunkFromBlockCoords(xCoord + AURAPROVIDER_SEARCH_RADIUS, zCoord + AURAPROVIDER_SEARCH_RADIUS);
|
||||
if (!chunks.contains(chunk)) {
|
||||
chunks.add(chunk);
|
||||
}
|
||||
return chunks;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private boolean searchChunkForBooster(Chunk chunk) {
|
||||
Vec3 apiaryPos = Vec3.createVectorHelper(xCoord, yCoord, zCoord);
|
||||
for (Map.Entry<ChunkPosition, TileEntity> entry : ((Map<ChunkPosition, TileEntity>)chunk.chunkTileEntityMap).entrySet()) {
|
||||
TileEntity entity = entry.getValue();
|
||||
if (entity instanceof IMagicApiaryAuraProvider) {
|
||||
Vec3 tePos = Vec3.createVectorHelper(entity.xCoord, entity.yCoord, entity.zCoord);
|
||||
Vec3 result = apiaryPos.subtract(tePos);
|
||||
if (result.lengthVector() <= AURAPROVIDER_SEARCH_RADIUS) {
|
||||
saveAuraProviderPosition(entity.xCoord, entity.yCoord, entity.zCoord);
|
||||
this.auraProvider = (IMagicApiaryAuraProvider)entity;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void saveAuraProviderPosition(int x, int y, int z) {
|
||||
auraProviderPosition = new ChunkCoords(worldObj.provider.dimensionId, x, y, z);
|
||||
}
|
||||
|
||||
private List<Chunk> getChunksInSearchRange() {
|
||||
List<Chunk> chunks = new ArrayList<Chunk>(4);
|
||||
chunks.add(worldObj.getChunkFromBlockCoords(
|
||||
xCoord - AURAPROVIDER_SEARCH_RADIUS, zCoord - AURAPROVIDER_SEARCH_RADIUS));
|
||||
Chunk chunk = worldObj.getChunkFromBlockCoords(
|
||||
xCoord + AURAPROVIDER_SEARCH_RADIUS, zCoord - AURAPROVIDER_SEARCH_RADIUS);
|
||||
if (!chunks.contains(chunk)) {
|
||||
chunks.add(chunk);
|
||||
}
|
||||
chunk = worldObj.getChunkFromBlockCoords(
|
||||
xCoord - AURAPROVIDER_SEARCH_RADIUS, zCoord + AURAPROVIDER_SEARCH_RADIUS);
|
||||
if (!chunks.contains(chunk)) {
|
||||
chunks.add(chunk);
|
||||
}
|
||||
chunk = worldObj.getChunkFromBlockCoords(
|
||||
xCoord + AURAPROVIDER_SEARCH_RADIUS, zCoord + AURAPROVIDER_SEARCH_RADIUS);
|
||||
if (!chunks.contains(chunk)) {
|
||||
chunks.add(chunk);
|
||||
}
|
||||
return chunks;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private boolean searchChunkForBooster(Chunk chunk) {
|
||||
Vec3 apiaryPos = Vec3.createVectorHelper(xCoord, yCoord, zCoord);
|
||||
for (Map.Entry<ChunkPosition, TileEntity> entry :
|
||||
((Map<ChunkPosition, TileEntity>) chunk.chunkTileEntityMap).entrySet()) {
|
||||
TileEntity entity = entry.getValue();
|
||||
if (entity instanceof IMagicApiaryAuraProvider) {
|
||||
Vec3 tePos = Vec3.createVectorHelper(entity.xCoord, entity.yCoord, entity.zCoord);
|
||||
Vec3 result = apiaryPos.subtract(tePos);
|
||||
if (result.lengthVector() <= AURAPROVIDER_SEARCH_RADIUS) {
|
||||
saveAuraProviderPosition(entity.xCoord, entity.yCoord, entity.zCoord);
|
||||
this.auraProvider = (IMagicApiaryAuraProvider) entity;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void saveAuraProviderPosition(int x, int y, int z) {
|
||||
auraProviderPosition = new ChunkCoords(worldObj.provider.dimensionId, x, y, z);
|
||||
}
|
||||
|
||||
private IMagicApiaryAuraProvider getAuraProvider(ChunkCoords coords) {
|
||||
return getAuraProvider(coords.x, coords.y, coords.z);
|
||||
}
|
||||
|
||||
private IMagicApiaryAuraProvider getAuraProvider(int x, int y, int z) {
|
||||
Chunk chunk = worldObj.getChunkFromBlockCoords(x, z);
|
||||
x %= 16;
|
||||
z %= 16;
|
||||
if (x < 0) {
|
||||
x += 16;
|
||||
}
|
||||
if (z < 0) {
|
||||
z += 16;
|
||||
}
|
||||
ChunkPosition cPos = new ChunkPosition(x, y, z);
|
||||
TileEntity entity = (TileEntity)chunk.chunkTileEntityMap.get(cPos);
|
||||
return getAuraProvider(coords.x, coords.y, coords.z);
|
||||
}
|
||||
|
||||
private IMagicApiaryAuraProvider getAuraProvider(int x, int y, int z) {
|
||||
Chunk chunk = worldObj.getChunkFromBlockCoords(x, z);
|
||||
x %= 16;
|
||||
z %= 16;
|
||||
if (x < 0) {
|
||||
x += 16;
|
||||
}
|
||||
if (z < 0) {
|
||||
z += 16;
|
||||
}
|
||||
ChunkPosition cPos = new ChunkPosition(x, y, z);
|
||||
TileEntity entity = (TileEntity) chunk.chunkTileEntityMap.get(cPos);
|
||||
if (!(entity instanceof IMagicApiaryAuraProvider)) {
|
||||
return null;
|
||||
}
|
||||
return (IMagicApiaryAuraProvider)entity;
|
||||
return (IMagicApiaryAuraProvider) entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -516,12 +514,12 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
|
||||
@Override
|
||||
public boolean addProduct(ItemStack product, boolean all) {
|
||||
int countAdded = ItemStackUtils.addItemToInventory(magicApiary, product, SLOT_PRODUCTS_START, SLOT_PRODUCTS_COUNT);
|
||||
int countAdded =
|
||||
ItemStackUtils.addItemToInventory(magicApiary, product, SLOT_PRODUCTS_START, SLOT_PRODUCTS_COUNT);
|
||||
|
||||
if (all) {
|
||||
return countAdded == product.stackSize;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return countAdded > 0;
|
||||
}
|
||||
}
|
||||
@@ -537,16 +535,15 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
public void setInventorySlotContents(int i, ItemStack itemStack) {
|
||||
items[i] = itemStack;
|
||||
|
||||
if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()){
|
||||
if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) {
|
||||
itemStack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
}
|
||||
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
if (side == 0 || side == 1) {
|
||||
return new int[] { SLOT_QUEEN, SLOT_DRONE };
|
||||
}
|
||||
else {
|
||||
return new int[] {SLOT_QUEEN, SLOT_DRONE};
|
||||
} else {
|
||||
int[] slots = new int[SLOT_PRODUCTS_COUNT];
|
||||
for (int i = 0, slot = SLOT_PRODUCTS_START; i < SLOT_PRODUCTS_COUNT; ++i, ++slot) {
|
||||
slots[i] = slot;
|
||||
@@ -556,18 +553,18 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
}
|
||||
|
||||
public boolean canInsertItem(int slot, ItemStack itemStack, int side) {
|
||||
if(slot == SLOT_QUEEN && BeeManager.beeRoot.isMember(itemStack)
|
||||
if (slot == SLOT_QUEEN
|
||||
&& BeeManager.beeRoot.isMember(itemStack)
|
||||
&& !BeeManager.beeRoot.isDrone(itemStack)) {
|
||||
return true;
|
||||
}
|
||||
else if (slot == SLOT_DRONE && BeeManager.beeRoot.isDrone(itemStack)) {
|
||||
} else if (slot == SLOT_DRONE && BeeManager.beeRoot.isDrone(itemStack)) {
|
||||
return true;
|
||||
}
|
||||
return slot == SLOT_DRONE && BeeManager.beeRoot.isDrone(itemStack);
|
||||
}
|
||||
|
||||
public boolean canExtractItem(int slot, ItemStack itemStack, int side) {
|
||||
switch (slot){
|
||||
switch (slot) {
|
||||
case SLOT_FRAME_START:
|
||||
case SLOT_FRAME_START + 1:
|
||||
case SLOT_FRAME_START + 2:
|
||||
@@ -607,7 +604,7 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
|
||||
if (itemStack != null) {
|
||||
NBTTagCompound item = new NBTTagCompound();
|
||||
item.setByte("Slot", (byte)i);
|
||||
item.setByte("Slot", (byte) i);
|
||||
itemStack.writeToNBT(item);
|
||||
itemsNBT.appendTag(item);
|
||||
}
|
||||
@@ -683,7 +680,9 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
IBeekeepingMode beekeepingMode = BeeManager.beeRoot.getBeekeepingMode(magicApiary.getWorldObj());
|
||||
int wear = Math.round(amount * beekeepingMode.getWearModifier());
|
||||
|
||||
for (int i = MagicApiaryInventory.SLOT_FRAME_START; i < MagicApiaryInventory.SLOT_FRAME_START + MagicApiaryInventory.SLOT_FRAME_COUNT; i++) {
|
||||
for (int i = MagicApiaryInventory.SLOT_FRAME_START;
|
||||
i < MagicApiaryInventory.SLOT_FRAME_START + MagicApiaryInventory.SLOT_FRAME_COUNT;
|
||||
i++) {
|
||||
ItemStack hiveFrameStack = magicApiary.getStackInSlot(i);
|
||||
if (hiveFrameStack == null) {
|
||||
continue;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package magicbees.tileentity;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import magicbees.api.bees.AuraChargeType;
|
||||
import magicbees.api.bees.IMagicApiaryAuraProvider;
|
||||
import magicbees.bees.AuraCharge;
|
||||
@@ -13,149 +13,147 @@ 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)
|
||||
@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 static final String tileEntityName = CommonProxy.DOMAIN + ".manaAuraProvider";
|
||||
|
||||
public int[] toArray() {
|
||||
return new int[]{charges, mana};
|
||||
}
|
||||
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;
|
||||
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private static class ManaAuraCharge {
|
||||
int charges;
|
||||
int mana;
|
||||
|
||||
@Override
|
||||
public boolean getMutationCharge() {
|
||||
return getCharge(AuraChargeType.MUTATION);
|
||||
}
|
||||
public int[] toArray() {
|
||||
return new int[] {charges, mana};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getDeathRateCharge() {
|
||||
return getCharge(AuraChargeType.DEATH);
|
||||
}
|
||||
public void fromArray(int[] array) {
|
||||
if (array.length == 2) {
|
||||
charges = array[0];
|
||||
mana = array[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getProductionCharge() {
|
||||
return getCharge(AuraChargeType.PRODUCTION);
|
||||
}
|
||||
private final Map<AuraCharge, ManaAuraCharge> currentCharges;
|
||||
private int currentMana;
|
||||
|
||||
@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;
|
||||
}
|
||||
public TileEntityManaAuraProvider() {
|
||||
super();
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = BotaniaHelper.Name)
|
||||
public int getCurrentMana() {
|
||||
return currentMana;
|
||||
}
|
||||
AuraCharge[] auraChargeTypes = AuraCharge.values();
|
||||
currentCharges = new HashMap<AuraCharge, ManaAuraCharge>(auraChargeTypes.length);
|
||||
for (AuraCharge auraChargeType : auraChargeTypes) {
|
||||
currentCharges.put(auraChargeType, new ManaAuraCharge());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = BotaniaHelper.Name)
|
||||
public boolean canRecieveManaFromBursts() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
long tick = worldObj.getTotalWorldTime();
|
||||
int manaForCharge = currentMana / 5;
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = BotaniaHelper.Name)
|
||||
public boolean isFull() {
|
||||
return currentMana == MAX_MANA;
|
||||
}
|
||||
if (manaForCharge > 0) {
|
||||
for (Map.Entry<AuraCharge, ManaAuraCharge> currentCharge : currentCharges.entrySet()) {
|
||||
AuraCharge type = currentCharge.getKey();
|
||||
ManaAuraCharge auraCharge = currentCharge.getValue();
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = BotaniaHelper.Name)
|
||||
public void recieveMana(int amount) {
|
||||
currentMana = (currentMana + amount > MAX_MANA) ? MAX_MANA : currentMana + amount;
|
||||
}
|
||||
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 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 boolean getMutationCharge() {
|
||||
return getCharge(AuraChargeType.MUTATION);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
@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);
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,9 @@ package magicbees.tileentity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import magicbees.api.bees.AuraChargeType;
|
||||
import magicbees.bees.AuraCharge;
|
||||
import magicbees.api.bees.IMagicApiaryAuraProvider;
|
||||
import magicbees.bees.AuraCharge;
|
||||
import magicbees.main.CommonProxy;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -14,120 +13,120 @@ import thaumcraft.api.visnet.VisNetHandler;
|
||||
|
||||
public class TileEntityVisAuraProvider extends TileEntity implements IMagicApiaryAuraProvider {
|
||||
|
||||
public static final String tileEntityName = CommonProxy.DOMAIN + ".visAuraProvider";
|
||||
|
||||
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);
|
||||
}
|
||||
public static final String tileEntityName = CommonProxy.DOMAIN + ".visAuraProvider";
|
||||
|
||||
private static class VisAuraCharge {
|
||||
int charges;
|
||||
int vis;
|
||||
private static final int MAX_CHARGES = 10;
|
||||
private static final int VIS_PER_CHARGE = 8;
|
||||
private static Map<AuraChargeType, Aspect> aspectMap;
|
||||
|
||||
public int[] toArray() {
|
||||
return new int[]{charges, vis};
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
public void fromArray(int[] array) {
|
||||
if (array.length == 2) {
|
||||
charges = array[0];
|
||||
vis = array[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
private static class VisAuraCharge {
|
||||
int charges;
|
||||
int vis;
|
||||
|
||||
private final Map<AuraCharge, VisAuraCharge> currentCharges;
|
||||
public int[] toArray() {
|
||||
return new int[] {charges, vis};
|
||||
}
|
||||
|
||||
public TileEntityVisAuraProvider() {
|
||||
super();
|
||||
public void fromArray(int[] array) {
|
||||
if (array.length == 2) {
|
||||
charges = array[0];
|
||||
vis = array[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AuraCharge[] auraChargeTypes = AuraCharge.values();
|
||||
currentCharges = new HashMap<AuraCharge, VisAuraCharge>(auraChargeTypes.length);
|
||||
for (AuraCharge auraChargeType : auraChargeTypes) {
|
||||
currentCharges.put(auraChargeType, new VisAuraCharge());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
long tick = worldObj.getTotalWorldTime();
|
||||
private final Map<AuraCharge, VisAuraCharge> currentCharges;
|
||||
|
||||
for (Map.Entry<AuraCharge, VisAuraCharge> currentCharge : currentCharges.entrySet()) {
|
||||
AuraCharge type = currentCharge.getKey();
|
||||
VisAuraCharge auraCharge = currentCharge.getValue();
|
||||
public TileEntityVisAuraProvider() {
|
||||
super();
|
||||
|
||||
if (auraCharge.charges < MAX_CHARGES && (tick % type.tickRate) == 0) {
|
||||
auraCharge.vis += getVisFromNet(aspectMap.get(type.type));
|
||||
if (auraCharge.vis >= VIS_PER_CHARGE) {
|
||||
auraCharge.vis -= VIS_PER_CHARGE;
|
||||
auraCharge.charges++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getVisFromNet(Aspect aspect) {
|
||||
return VisNetHandler.drainVis(worldObj, xCoord, yCoord, zCoord, aspect, 1);
|
||||
}
|
||||
AuraCharge[] auraChargeTypes = AuraCharge.values();
|
||||
currentCharges = new HashMap<AuraCharge, VisAuraCharge>(auraChargeTypes.length);
|
||||
for (AuraCharge auraChargeType : auraChargeTypes) {
|
||||
currentCharges.put(auraChargeType, new VisAuraCharge());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getMutationCharge() {
|
||||
return getCharge(AuraChargeType.MUTATION);
|
||||
}
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
@Override
|
||||
public boolean getDeathRateCharge() {
|
||||
return getCharge(AuraChargeType.DEATH);
|
||||
}
|
||||
long tick = worldObj.getTotalWorldTime();
|
||||
|
||||
@Override
|
||||
public boolean getProductionCharge() {
|
||||
return getCharge(AuraChargeType.PRODUCTION);
|
||||
}
|
||||
for (Map.Entry<AuraCharge, VisAuraCharge> currentCharge : currentCharges.entrySet()) {
|
||||
AuraCharge type = currentCharge.getKey();
|
||||
VisAuraCharge auraCharge = currentCharge.getValue();
|
||||
|
||||
@Override
|
||||
public boolean getCharge(AuraChargeType auraChargeType) {
|
||||
VisAuraCharge auraCharge = currentCharges.get(AuraCharge.fromChargeType(auraChargeType));
|
||||
if (auraCharge == null) {
|
||||
return false;
|
||||
}
|
||||
if (auraCharge.charges > 0) {
|
||||
auraCharge.charges--;
|
||||
return true;
|
||||
}
|
||||
if (auraCharge.charges < MAX_CHARGES && (tick % type.tickRate) == 0) {
|
||||
auraCharge.vis += getVisFromNet(aspectMap.get(type.type));
|
||||
if (auraCharge.vis >= VIS_PER_CHARGE) {
|
||||
auraCharge.vis -= VIS_PER_CHARGE;
|
||||
auraCharge.charges++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
private int getVisFromNet(Aspect aspect) {
|
||||
return VisNetHandler.drainVis(worldObj, xCoord, yCoord, zCoord, aspect, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
@Override
|
||||
public boolean getMutationCharge() {
|
||||
return getCharge(AuraChargeType.MUTATION);
|
||||
}
|
||||
|
||||
for (Map.Entry<AuraCharge, VisAuraCharge> charge : currentCharges.entrySet()) {
|
||||
String auraName = charge.getKey().toString();
|
||||
int[] array = tag.getIntArray(auraName);
|
||||
VisAuraCharge auraCharge = charge.getValue();
|
||||
auraCharge.fromArray(array);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean getDeathRateCharge() {
|
||||
return getCharge(AuraChargeType.DEATH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
@Override
|
||||
public boolean getProductionCharge() {
|
||||
return getCharge(AuraChargeType.PRODUCTION);
|
||||
}
|
||||
|
||||
for (Map.Entry<AuraCharge, VisAuraCharge> charge : currentCharges.entrySet()) {
|
||||
String auraName = charge.getKey().toString();
|
||||
VisAuraCharge auraCharge = charge.getValue();
|
||||
int[] array = auraCharge.toArray();
|
||||
tag.setIntArray(auraName, array);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean getCharge(AuraChargeType auraChargeType) {
|
||||
VisAuraCharge auraCharge = currentCharges.get(AuraCharge.fromChargeType(auraChargeType));
|
||||
if (auraCharge == null) {
|
||||
return false;
|
||||
}
|
||||
if (auraCharge.charges > 0) {
|
||||
auraCharge.charges--;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
|
||||
for (Map.Entry<AuraCharge, VisAuraCharge> charge : currentCharges.entrySet()) {
|
||||
String auraName = charge.getKey().toString();
|
||||
int[] array = tag.getIntArray(auraName);
|
||||
VisAuraCharge auraCharge = charge.getValue();
|
||||
auraCharge.fromArray(array);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
|
||||
for (Map.Entry<AuraCharge, VisAuraCharge> charge : currentCharges.entrySet()) {
|
||||
String auraName = charge.getKey().toString();
|
||||
VisAuraCharge auraCharge = charge.getValue();
|
||||
int[] array = auraCharge.toArray();
|
||||
tag.setIntArray(auraName, array);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user