mirror of
https://github.com/GTNewHorizons/MagicBees.git
synced 2026-11-17 11:05:02 +00:00
Update for Forestry 4.0
This commit is contained in:
1 parent
2503c94b83
commit
f1086f3095
24 files changed
+778
-983
No files matched your search
@@ -5,6 +5,8 @@ import java.util.List;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
|
||||
import forestry.api.apiculture.IAlleleBeeEffect;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
@@ -70,18 +72,19 @@ public abstract class AlleleEffect extends Allele implements IAlleleBeeEffect
|
||||
{
|
||||
// Get the size of the affected area
|
||||
int[] area = genome.getTerritory();
|
||||
ChunkCoordinates coords = housing.getCoordinates();
|
||||
|
||||
// Calculate offset
|
||||
int[] min = new int[3];
|
||||
int[] max = new int[3];
|
||||
min[0] = housing.getXCoord() - area[0] / 2;
|
||||
max[0] = housing.getXCoord() + area[0] / 2;
|
||||
min[0] = coords.posX - area[0] / 2;
|
||||
max[0] = coords.posX + area[0] / 2;
|
||||
|
||||
min[1] = housing.getYCoord() - area[1] / 2;
|
||||
max[1] = housing.getYCoord() + area[1] / 2;
|
||||
min[1] = coords.posY - area[1] / 2;
|
||||
max[1] = coords.posY + area[1] / 2;
|
||||
|
||||
min[2] = housing.getZCoord() - area[2] / 2;
|
||||
max[2] = housing.getZCoord() + area[2] / 2;
|
||||
min[2] = coords.posZ - area[2] / 2;
|
||||
max[2] = coords.posZ + area[2] / 2;
|
||||
|
||||
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(min[0], min[1], min[2], max[0], max[1], max[2]);
|
||||
return (List<Entity>)housing.getWorld().getEntitiesWithinAABB(EntityPlayer.class, bounds);
|
||||
|
||||
@@ -19,16 +19,19 @@ import magicbees.main.utils.compat.ThermalModsHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.common.BiomeDictionary.Type;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IBeeMutation;
|
||||
import forestry.api.apiculture.IBeeRoot;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
|
||||
public class BeeMutation implements IBeeMutation {
|
||||
|
||||
@@ -390,9 +393,8 @@ public class BeeMutation implements IBeeMutation {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private IAllele parent1;
|
||||
private IAllele parent2;
|
||||
private IAlleleSpecies parent1;
|
||||
private IAlleleSpecies parent2;
|
||||
private IAllele mutationTemplate[];
|
||||
private int baseChance;
|
||||
private boolean isSecret;
|
||||
@@ -430,19 +432,11 @@ public class BeeMutation implements IBeeMutation {
|
||||
BeeManager.beeRoot.registerMutation(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public float getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
|
||||
if (allele0 instanceof IAlleleBeeSpecies && allele1 instanceof IAlleleBeeSpecies && genome0 instanceof IBeeGenome && genome1 instanceof IBeeGenome) {
|
||||
return getChance(housing, (IAlleleBeeSpecies)allele0, (IAlleleBeeSpecies)allele1, (IBeeGenome)genome0, (IBeeGenome)genome1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getChance(IBeeHousing housing, IAlleleBeeSpecies allele0, IAlleleBeeSpecies allele1, IBeeGenome genome0, IBeeGenome genome1) {
|
||||
float finalChance = 0f;
|
||||
float chance = this.baseChance * 1f;
|
||||
ChunkCoordinates housingCoords = housing.getCoordinates();
|
||||
|
||||
if (this.arePartners(allele0, allele1)) {
|
||||
// This mutation applies. Continue calculation.
|
||||
@@ -464,9 +458,8 @@ public class BeeMutation implements IBeeMutation {
|
||||
int blockMeta;
|
||||
int i = 1;
|
||||
do {
|
||||
blockBelow = housing.getWorld().getBlock(housing.getXCoord(), housing.getYCoord() - i,
|
||||
housing.getZCoord());
|
||||
blockMeta = housing.getWorld().getBlockMetadata(housing.getXCoord(), housing.getYCoord() - i, housing.getZCoord());
|
||||
blockBelow = housing.getWorld().getBlock(housingCoords.posX, housingCoords.posY - i, housingCoords.posZ);
|
||||
blockMeta = housing.getWorld().getBlockMetadata(housingCoords.posX, housingCoords.posY - i, housingCoords.posZ);
|
||||
++i;
|
||||
}
|
||||
while (blockBelow != null && (blockBelow instanceof IBeeHousing || blockBelow == ForestryHelper.alvearyBlock));
|
||||
@@ -489,10 +482,10 @@ public class BeeMutation implements IBeeMutation {
|
||||
}
|
||||
|
||||
if (this.requiredBiomeType != null) {
|
||||
BiomeDictionary.Type[] types = BiomeDictionary.getTypesForBiome(housing.getWorld().getBiomeGenForCoords(housing.getXCoord(), housing.getZCoord()));
|
||||
BiomeDictionary.Type[] types = BiomeDictionary.getTypesForBiome(housing.getWorld().getBiomeGenForCoords(housingCoords.posX, housingCoords.posZ));
|
||||
boolean found = false;
|
||||
for (int i = 0; i < types.length; ++i) {
|
||||
if (this.requiredBiomeType == types[i]) {
|
||||
for (Type type : types) {
|
||||
if (this.requiredBiomeType == type) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@@ -507,25 +500,25 @@ public class BeeMutation implements IBeeMutation {
|
||||
chance = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IBeeModifier housingBeeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
IBeeModifier modeBeeModifier = BeeManager.beeRoot.getBeekeepingMode(housing.getWorld()).getBeeModifier();
|
||||
|
||||
finalChance = Math.round(chance
|
||||
* housing.getMutationModifier((IBeeGenome)genome0,
|
||||
(IBeeGenome)genome1, chance)
|
||||
* BeeManager.beeRoot.getBeekeepingMode(housing.getWorld())
|
||||
.getMutationModifier((IBeeGenome)genome0,
|
||||
(IBeeGenome)genome1, chance));
|
||||
* housingBeeModifier.getMutationModifier(genome0, genome1, chance)
|
||||
* modeBeeModifier.getMutationModifier(genome0, genome1, chance));
|
||||
}
|
||||
|
||||
return finalChance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAllele getAllele0() {
|
||||
public IAlleleSpecies getAllele0() {
|
||||
return parent1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAllele getAllele1() {
|
||||
public IAlleleSpecies getAllele1() {
|
||||
return parent2;
|
||||
}
|
||||
|
||||
|
||||
@@ -588,11 +588,7 @@ public enum BeeSpecies implements IAlleleBeeSpecies, IIconProvider
|
||||
private boolean isNocturnal;
|
||||
private IClassification branch;
|
||||
private HashMap<ItemStack, Float> products;
|
||||
@Deprecated
|
||||
private HashMap<ItemStack, Integer> oldProducts;
|
||||
private HashMap<ItemStack, Float> specialties;
|
||||
@Deprecated
|
||||
private HashMap<ItemStack, Integer> oldSpecialties;
|
||||
private IAllele genomeTemplate[];
|
||||
private String uid;
|
||||
private boolean dominant;
|
||||
@@ -640,9 +636,7 @@ public enum BeeSpecies implements IAlleleBeeSpecies, IIconProvider
|
||||
isSecret = isSpeciesSecret;
|
||||
isCounted = isSpeciesCounted;
|
||||
products = new HashMap<ItemStack, Float>();
|
||||
oldProducts = new HashMap<ItemStack, Integer>();
|
||||
specialties = new HashMap<ItemStack, Float>();
|
||||
oldSpecialties = new HashMap<ItemStack, Integer>();
|
||||
this.branch = classification;
|
||||
this.branch.addMemberSpecies(this);
|
||||
this.isNocturnal = isSpeciesNocturnal;
|
||||
@@ -652,28 +646,14 @@ public enum BeeSpecies implements IAlleleBeeSpecies, IIconProvider
|
||||
public IAllele[] getGenome() {
|
||||
return genomeTemplate;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public BeeSpecies addProduct(ItemStack produce, int percentChance) {
|
||||
// Don't use this plz.
|
||||
return null;
|
||||
}
|
||||
|
||||
public BeeSpecies addProduct(ItemStack produce, float chance) {
|
||||
products.put(produce, chance);
|
||||
oldProducts.put(produce, (int)(chance * 100));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public BeeSpecies addSpecialty(ItemStack produce, int percentChance) {
|
||||
// Don't use this plz.
|
||||
return null;
|
||||
}
|
||||
|
||||
public BeeSpecies addSpecialty(ItemStack produce, float chance) {
|
||||
specialties.put(produce, chance);
|
||||
oldSpecialties.put(produce, (int)(chance * 100));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -756,18 +736,6 @@ public enum BeeSpecies implements IAlleleBeeSpecies, IIconProvider
|
||||
return specialties;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public HashMap<ItemStack, Integer> getProducts() {
|
||||
return oldProducts;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public HashMap<ItemStack, Integer> getSpecialty() {
|
||||
return oldSpecialties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUID() {
|
||||
return this.uid;
|
||||
|
||||
@@ -3,13 +3,17 @@ package magicbees.bees.allele.effect;
|
||||
import java.util.HashMap;
|
||||
|
||||
import magicbees.bees.AlleleEffect;
|
||||
import magicbees.bees.BeeManager;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
|
||||
public class AlleleEffectCrumbling extends AlleleEffect {
|
||||
@@ -50,14 +54,17 @@ public class AlleleEffectCrumbling extends AlleleEffect {
|
||||
@Override
|
||||
protected IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
World world = housing.getWorld();
|
||||
// Get random coords within territory
|
||||
int xRange = (int) (housing.getTerritoryModifier(genome, 1f) * genome.getTerritory()[0]);
|
||||
int yRange = (int) (housing.getTerritoryModifier(genome, 1f) * genome.getTerritory()[1]);
|
||||
int zRange = (int) (housing.getTerritoryModifier(genome, 1f) * genome.getTerritory()[2]);
|
||||
ChunkCoordinates coords = housing.getCoordinates();
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
|
||||
int xCoord = housing.getXCoord() + world.rand.nextInt(xRange) - xRange / 2;
|
||||
int yCoord = housing.getYCoord() + world.rand.nextInt(yRange) - yRange / 2;
|
||||
int zCoord = housing.getZCoord() + world.rand.nextInt(zRange) - zRange / 2;
|
||||
// Get random coords within territory
|
||||
int xRange = (int) (beeModifier.getTerritoryModifier(genome, 1f) * genome.getTerritory()[0]);
|
||||
int yRange = (int) (beeModifier.getTerritoryModifier(genome, 1f) * genome.getTerritory()[1]);
|
||||
int zRange = (int) (beeModifier.getTerritoryModifier(genome, 1f) * genome.getTerritory()[2]);
|
||||
|
||||
int xCoord = coords.posX + world.rand.nextInt(xRange) - xRange / 2;
|
||||
int yCoord = coords.posY + world.rand.nextInt(yRange) - yRange / 2;
|
||||
int zCoord = coords.posZ + world.rand.nextInt(zRange) - zRange / 2;
|
||||
|
||||
Block block = world.getBlock(xCoord, yCoord, zCoord);
|
||||
if (block != null) {
|
||||
|
||||
@@ -3,12 +3,16 @@ package magicbees.bees.allele.effect;
|
||||
import java.util.List;
|
||||
|
||||
import magicbees.bees.AlleleEffect;
|
||||
import magicbees.bees.BeeManager;
|
||||
import magicbees.main.utils.BlockUtil;
|
||||
import magicbees.main.utils.compat.thaumcraft.NodeHelper;
|
||||
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
|
||||
public class AlleleEffectEmpowering extends AlleleEffect {
|
||||
@@ -29,13 +33,12 @@ public class AlleleEffectEmpowering extends AlleleEffect {
|
||||
@Override
|
||||
protected IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
World world = housing.getWorld();
|
||||
int xCoord = housing.getXCoord();
|
||||
int yCoord = housing.getYCoord();
|
||||
int zCoord = housing.getZCoord();
|
||||
int range = (int)Math.ceil(genome.getTerritory()[0] * housing.getTerritoryModifier(genome, 1f));
|
||||
List<Chunk> chunks = BlockUtil.getChunksInSearchRange(world, xCoord, zCoord, range);
|
||||
ChunkCoordinates coords = housing.getCoordinates();
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
int range = (int)Math.ceil(genome.getTerritory()[0] * beeModifier.getTerritoryModifier(genome, 1f));
|
||||
List<Chunk> chunks = BlockUtil.getChunksInSearchRange(world, coords.posX, coords.posZ, range);
|
||||
|
||||
if (NodeHelper.growNodeInRange(chunks, world, xCoord, yCoord, zCoord, range)) {
|
||||
if (NodeHelper.growNodeInRange(chunks, world, coords.posX, coords.posY, coords.posZ, range)) {
|
||||
storedData.setInteger(0, storedData.getInteger(0) - throttle);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,13 +3,16 @@ package magicbees.bees.allele.effect;
|
||||
import java.util.List;
|
||||
|
||||
import magicbees.bees.AlleleEffect;
|
||||
import magicbees.bees.BeeManager;
|
||||
import magicbees.main.utils.BlockUtil;
|
||||
import magicbees.main.utils.compat.thaumcraft.NodeHelper;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import thaumcraft.api.nodes.NodeType;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
|
||||
public class AlleleEffectNodeConversion extends AlleleEffect {
|
||||
@@ -32,13 +35,12 @@ public class AlleleEffectNodeConversion extends AlleleEffect {
|
||||
@Override
|
||||
protected IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
World world = housing.getWorld();
|
||||
int xCoord = housing.getXCoord();
|
||||
int yCoord = housing.getYCoord();
|
||||
int zCoord = housing.getZCoord();
|
||||
int range = (int)Math.ceil(genome.getTerritory()[0] * housing.getTerritoryModifier(genome, 1f));
|
||||
List<Chunk> chunks = BlockUtil.getChunksInSearchRange(world, xCoord, zCoord, range);
|
||||
ChunkCoordinates coords = housing.getCoordinates();
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
int range = (int)Math.ceil(genome.getTerritory()[0] * beeModifier.getTerritoryModifier(genome, 1f));
|
||||
List<Chunk> chunks = BlockUtil.getChunksInSearchRange(world, coords.posX, coords.posZ, range);
|
||||
|
||||
if (NodeHelper.convertNodeInRangeToType(chunks, world, xCoord, yCoord, zCoord, range, targetType)) {
|
||||
if (NodeHelper.convertNodeInRangeToType(chunks, world, coords.posX, coords.posY, coords.posZ, range, targetType)) {
|
||||
storedData.setInteger(0, storedData.getInteger(0) - throttle);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,15 @@ package magicbees.bees.allele.effect;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import magicbees.bees.AlleleEffect;
|
||||
import magicbees.bees.BeeManager;
|
||||
import magicbees.main.utils.BlockUtil;
|
||||
import magicbees.main.utils.compat.thaumcraft.NodeHelper;
|
||||
|
||||
@@ -28,13 +31,12 @@ public class AlleleEffectNodeRepair extends AlleleEffect {
|
||||
@Override
|
||||
protected IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
World world = housing.getWorld();
|
||||
int xCoord = housing.getXCoord();
|
||||
int yCoord = housing.getYCoord();
|
||||
int zCoord = housing.getZCoord();
|
||||
int range = (int)Math.ceil(genome.getTerritory()[0] * housing.getTerritoryModifier(genome, 1f));
|
||||
List<Chunk> chunks = BlockUtil.getChunksInSearchRange(world, xCoord, zCoord, range);
|
||||
ChunkCoordinates coords = housing.getCoordinates();
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
int range = (int)Math.ceil(genome.getTerritory()[0] * beeModifier.getTerritoryModifier(genome, 1f));
|
||||
List<Chunk> chunks = BlockUtil.getChunksInSearchRange(world, coords.posX, coords.posZ, range);
|
||||
|
||||
if (NodeHelper.repairNodeInRange(chunks, world, xCoord, yCoord, zCoord, range)) {
|
||||
if (NodeHelper.repairNodeInRange(chunks, world, coords.posX, coords.posY, coords.posZ, range)) {
|
||||
storedData.setInteger(0, storedData.getInteger(0) - throttle);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,16 @@ package magicbees.bees.allele.effect;
|
||||
import java.util.List;
|
||||
|
||||
import magicbees.bees.AlleleEffect;
|
||||
import magicbees.bees.BeeManager;
|
||||
import magicbees.main.utils.BlockUtil;
|
||||
import magicbees.main.utils.compat.thaumcraft.NodeHelper;
|
||||
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
|
||||
public class AlleleEffectRecharge extends AlleleEffect {
|
||||
@@ -29,13 +33,12 @@ public class AlleleEffectRecharge extends AlleleEffect {
|
||||
@Override
|
||||
protected IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
World world = housing.getWorld();
|
||||
int xCoord = housing.getXCoord();
|
||||
int yCoord = housing.getYCoord();
|
||||
int zCoord = housing.getZCoord();
|
||||
int range = (int)Math.ceil(genome.getTerritory()[0] * housing.getTerritoryModifier(genome, 1f));
|
||||
List<Chunk> chunks = BlockUtil.getChunksInSearchRange(world, xCoord, zCoord, range);
|
||||
ChunkCoordinates coords = housing.getCoordinates();
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
int range = (int)Math.ceil(genome.getTerritory()[0] * beeModifier.getTerritoryModifier(genome, 1f));
|
||||
List<Chunk> chunks = BlockUtil.getChunksInSearchRange(world, coords.posX, coords.posZ, range);
|
||||
|
||||
if (NodeHelper.rechargeNodeInRange(chunks, world, xCoord, yCoord, zCoord, range)) {
|
||||
if (NodeHelper.rechargeNodeInRange(chunks, world, coords.posX, coords.posY, coords.posZ, range)) {
|
||||
storedData.setInteger(0, storedData.getInteger(0) - throttle);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,15 +3,18 @@ package magicbees.bees.allele.effect;
|
||||
import java.util.List;
|
||||
|
||||
import magicbees.bees.AlleleEffect;
|
||||
import magicbees.bees.BeeManager;
|
||||
import magicbees.item.ItemArmorApiarist;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
|
||||
public class AlleleEffectSpawnMob extends AlleleEffect {
|
||||
@@ -86,12 +89,14 @@ public class AlleleEffectSpawnMob extends AlleleEffect {
|
||||
|
||||
private void playMobLiveSound(IBeeGenome genome, IBeeHousing housing, World w) {
|
||||
if (mobSound != null && w.rand.nextInt(100) < 35) {
|
||||
ChunkCoordinates coords = housing.getCoordinates();
|
||||
|
||||
int range = genome.getTerritory()[0];
|
||||
double x = housing.getXCoord() + w.rand.nextDouble() * (range * 2) - range;
|
||||
double x = coords.posX + w.rand.nextDouble() * (range * 2) - range;
|
||||
range = genome.getTerritory()[1];
|
||||
double y = housing.getYCoord() + w.rand.nextDouble() * (range * 2) - range;
|
||||
double y = coords.posY + w.rand.nextDouble() * (range * 2) - range;
|
||||
range = genome.getTerritory()[2];
|
||||
double z = housing.getZCoord() + w.rand.nextDouble() * (range * 2) - range;
|
||||
double z = coords.posZ + w.rand.nextDouble() * (range * 2) - range;
|
||||
w.playSoundEffect(x, y, z, this.mobSound, 0.5f, (w.rand.nextFloat() - w.rand.nextFloat()) * 0.2f + 1.0f);
|
||||
}
|
||||
}
|
||||
@@ -175,10 +180,13 @@ public class AlleleEffectSpawnMob extends AlleleEffect {
|
||||
}
|
||||
|
||||
protected double[] randomMobSpawnCoords(World world, IBeeGenome bee, IBeeHousing housing) {
|
||||
ChunkCoordinates coords = housing.getCoordinates();
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
|
||||
double pos[] = new double[3];
|
||||
pos[0] = housing.getXCoord() + (world.rand.nextDouble() * (bee.getTerritory()[0] * housing.getTerritoryModifier(bee, 1f)) - bee.getTerritory()[0] / 2);
|
||||
pos[1] = housing.getYCoord() + world.rand.nextInt(3) - 1;
|
||||
pos[2] = housing.getZCoord() + (world.rand.nextDouble() * (bee.getTerritory()[2] * housing.getTerritoryModifier(bee, 1f)) - bee.getTerritory()[2] / 2);
|
||||
pos[0] = coords.posX + (world.rand.nextDouble() * (bee.getTerritory()[0] * beeModifier.getTerritoryModifier(bee, 1f)) - bee.getTerritory()[0] / 2);
|
||||
pos[1] = coords.posY + world.rand.nextInt(3) - 1;
|
||||
pos[2] = coords.posZ + (world.rand.nextDouble() * (bee.getTerritory()[2] * beeModifier.getTerritoryModifier(bee, 1f)) - bee.getTerritory()[2] / 2);
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,17 @@
|
||||
package magicbees.bees.allele.effect;
|
||||
|
||||
import magicbees.bees.AlleleEffect;
|
||||
import magicbees.bees.BeeManager;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
|
||||
public class AlleleEffectSpawnMobWeighted extends AlleleEffect {
|
||||
@@ -69,10 +74,13 @@ public class AlleleEffectSpawnMobWeighted extends AlleleEffect {
|
||||
}
|
||||
|
||||
protected double[] randomMobSpawnCoords(World world, IBeeGenome bee, IBeeHousing housing) {
|
||||
ChunkCoordinates coords = housing.getCoordinates();
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
|
||||
double pos[] = new double[3];
|
||||
pos[0] = housing.getXCoord() + world.rand.nextDouble() * (bee.getTerritory()[0] * housing.getTerritoryModifier(bee, 1f)) - bee.getTerritory()[0] / 2;
|
||||
pos[1] = housing.getYCoord() + world.rand.nextDouble() * (bee.getTerritory()[1] * housing.getTerritoryModifier(bee, 1f)) - bee.getTerritory()[1] / 2;
|
||||
pos[2] = housing.getZCoord() + world.rand.nextDouble() * (bee.getTerritory()[2] * housing.getTerritoryModifier(bee, 1f)) - bee.getTerritory()[2] / 2;
|
||||
pos[0] = coords.posX + world.rand.nextDouble() * (bee.getTerritory()[0] * beeModifier.getTerritoryModifier(bee, 1f)) - bee.getTerritory()[0] / 2;
|
||||
pos[1] = coords.posY + world.rand.nextDouble() * (bee.getTerritory()[1] * beeModifier.getTerritoryModifier(bee, 1f)) - bee.getTerritory()[1] / 2;
|
||||
pos[2] = coords.posZ + world.rand.nextDouble() * (bee.getTerritory()[2] * beeModifier.getTerritoryModifier(bee, 1f)) - bee.getTerritory()[2] / 2;
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package magicbees.bees.allele.effect;
|
||||
|
||||
import magicbees.bees.AlleleEffect;
|
||||
import magicbees.bees.BeeManager;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
|
||||
public class AlleleEffectTransmuting extends AlleleEffect {
|
||||
@@ -28,14 +32,17 @@ public class AlleleEffectTransmuting extends AlleleEffect {
|
||||
@Override
|
||||
protected IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
World world = housing.getWorld();
|
||||
// Get random coords within territory
|
||||
int xRange = (int) (housing.getTerritoryModifier(genome, 1f) * genome.getTerritory()[0]);
|
||||
int yRange = (int) (housing.getTerritoryModifier(genome, 1f) * genome.getTerritory()[1]);
|
||||
int zRange = (int) (housing.getTerritoryModifier(genome, 1f) * genome.getTerritory()[2]);
|
||||
ChunkCoordinates coords = housing.getCoordinates();
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
|
||||
int xCoord = housing.getXCoord() + world.rand.nextInt(xRange) - xRange / 2;
|
||||
int yCoord = housing.getYCoord() + world.rand.nextInt(yRange) - yRange / 2;
|
||||
int zCoord = housing.getZCoord() + world.rand.nextInt(zRange) - zRange / 2;
|
||||
// Get random coords within territory
|
||||
int xRange = (int) (beeModifier.getTerritoryModifier(genome, 1f) * genome.getTerritory()[0]);
|
||||
int yRange = (int) (beeModifier.getTerritoryModifier(genome, 1f) * genome.getTerritory()[1]);
|
||||
int zRange = (int) (beeModifier.getTerritoryModifier(genome, 1f) * genome.getTerritory()[2]);
|
||||
|
||||
int xCoord = coords.posX + world.rand.nextInt(xRange) - xRange / 2;
|
||||
int yCoord = coords.posY + world.rand.nextInt(yRange) - yRange / 2;
|
||||
int zCoord = coords.posZ + world.rand.nextInt(zRange) - zRange / 2;
|
||||
|
||||
BiomeGenBase biome = world.getBiomeGenForCoords(xCoord, zCoord);
|
||||
transmutationController.attemptTransmutations(world, biome,
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
package magicbees.bees.allele.flowerProvider;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import forestry.api.genetics.IFlower;
|
||||
|
||||
public class FlowerImpl implements IFlower {
|
||||
|
||||
private Block flowerBlock;
|
||||
private int meta;
|
||||
private double weight;
|
||||
private boolean plantable;
|
||||
|
||||
public FlowerImpl(Block flower, int blockMeta, double flowerWeight, boolean isPlantable) {
|
||||
flowerBlock = flower;
|
||||
meta = blockMeta;
|
||||
weight = flowerWeight;
|
||||
plantable = isPlantable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock() {
|
||||
return flowerBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWeight(double value) {
|
||||
weight = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlantable() {
|
||||
return plantable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(IFlower other) {
|
||||
return (int)(weight - other.getWeight());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +1,25 @@
|
||||
package magicbees.bees.allele.flowerProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.FlowerManager;
|
||||
import forestry.api.genetics.IFlower;
|
||||
import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
|
||||
public abstract class FlowerProvider implements IFlowerProvider {
|
||||
|
||||
protected List<IFlower> flowers;
|
||||
|
||||
public FlowerProvider(int size) {
|
||||
flowers = new ArrayList<IFlower>(size);
|
||||
@Override
|
||||
public Set<IFlower> getFlowers() {
|
||||
return FlowerManager.flowerRegistry.getAcceptableFlowers(getFlowerType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(World world, IIndividual genome, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
for (IFlower flower : flowers) {
|
||||
if (flower.getBlock() == block) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
protected void registerPlantableFlower(Block block, int meta, int weight) {
|
||||
FlowerManager.flowerRegistry.registerPlantableFlower(block, meta, weight, getFlowerType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IFlower> getFlowers() {
|
||||
return flowers;
|
||||
protected void registerAcceptableFlower(Block block, int meta) {
|
||||
FlowerManager.flowerRegistry.registerAcceptableFlower(block, meta, getFlowerType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract boolean isAcceptedPollinatable(World world, IPollinatable pollinatable);
|
||||
|
||||
@Override
|
||||
public abstract boolean growFlower(World world, IIndividual individual, int x, int y, int z);
|
||||
|
||||
@Override
|
||||
public abstract String getDescription();
|
||||
|
||||
@Override
|
||||
public abstract ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products);
|
||||
|
||||
}
|
||||
+11
-6
@@ -6,18 +6,18 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
|
||||
public class FlowerProviderArsMagicaFlower extends FlowerProvider {
|
||||
|
||||
public FlowerProviderArsMagicaFlower() {
|
||||
super(5);
|
||||
flowers.add(new FlowerImpl(ArsMagicaHelper.blackOrchid, 0, 1, true));
|
||||
flowers.add(new FlowerImpl(ArsMagicaHelper.desertNova, 0, 1, true));
|
||||
flowers.add(new FlowerImpl(ArsMagicaHelper.aum, 0, 1, true));
|
||||
flowers.add(new FlowerImpl(ArsMagicaHelper.wakebloom, 0, 1, true));
|
||||
flowers.add(new FlowerImpl(ArsMagicaHelper.tarmaRoot, 0, 1, true));
|
||||
registerPlantableFlower(ArsMagicaHelper.blackOrchid, 0, 1);
|
||||
registerPlantableFlower(ArsMagicaHelper.desertNova, 0, 1);
|
||||
registerPlantableFlower(ArsMagicaHelper.aum, 0, 1);
|
||||
registerPlantableFlower(ArsMagicaHelper.wakebloom, 0, 1);
|
||||
registerPlantableFlower(ArsMagicaHelper.tarmaRoot, 0, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,6 +51,11 @@ public class FlowerProviderArsMagicaFlower extends FlowerProvider {
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFlowerType() {
|
||||
return "flowersArsMagica";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return LocalizationManager.getLocalizedString("flowerProvider.arsmagica");
|
||||
|
||||
@@ -1,38 +1,18 @@
|
||||
package magicbees.bees.allele.flowerProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import magicbees.main.utils.LocalizationManager;
|
||||
import magicbees.main.utils.compat.ThaumcraftHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.api.nodes.INode;
|
||||
import forestry.api.genetics.IFlower;
|
||||
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
|
||||
public class FlowerProviderAuraNode extends FlowerProvider {
|
||||
|
||||
public FlowerProviderAuraNode() {
|
||||
super(2);
|
||||
flowers.add(new FlowerImpl(ThaumcraftHelper.airy, ThaumcraftHelper.AiryBlockType.NODE.ordinal(), 1, false));
|
||||
flowers.add(new FlowerImpl(ThaumcraftHelper.airy, ThaumcraftHelper.AiryBlockType.ENERGIZED_NODE.ordinal(), 1, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(World world, IIndividual genome, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (block.hasTileEntity(meta)) {
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
if (tileEntity instanceof INode) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
registerAcceptableFlower(ThaumcraftHelper.airy, ThaumcraftHelper.AiryBlockType.NODE.ordinal());
|
||||
registerAcceptableFlower(ThaumcraftHelper.airy, ThaumcraftHelper.AiryBlockType.ENERGIZED_NODE.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,6 +25,11 @@ public class FlowerProviderAuraNode extends FlowerProvider {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFlowerType() {
|
||||
return "flowersThaumcraftAuraNode";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return LocalizationManager.getLocalizedString("flowerProvider.node");
|
||||
@@ -52,9 +37,6 @@ public class FlowerProviderAuraNode extends FlowerProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack[] affectProducts(World world, IIndividual genome, int x, int y, int z, ItemStack[] products) {
|
||||
if (isAcceptedFlower(world, genome, x, y, z)) {
|
||||
|
||||
}
|
||||
return products;
|
||||
}
|
||||
|
||||
@@ -80,9 +62,4 @@ public class FlowerProviderAuraNode extends FlowerProvider {
|
||||
return products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IFlower> getFlowers() {
|
||||
return new ArrayList<IFlower>();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,16 +14,7 @@ import forestry.api.genetics.IPollinatable;
|
||||
public class FlowerProviderBookshelf extends FlowerProvider {
|
||||
|
||||
public FlowerProviderBookshelf() {
|
||||
super(1);
|
||||
flowers.add(new FlowerImpl(Blocks.bookshelf, OreDictionary.WILDCARD_VALUE, 1, false));
|
||||
}
|
||||
|
||||
public boolean isAcceptedFlower(World world, IIndividual genome, int x, int i, int j) {
|
||||
boolean flag = false;
|
||||
if (world.getBlock(x, i, j) == Blocks.bookshelf) {
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
registerAcceptableFlower(Blocks.bookshelf, OreDictionary.WILDCARD_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -31,6 +22,11 @@ public class FlowerProviderBookshelf extends FlowerProvider {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFlowerType() {
|
||||
return "flowersBookshelf";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] affectProducts(World world, IIndividual genome, int x, int i, int j, ItemStack products[]) {
|
||||
return products;
|
||||
|
||||
@@ -11,8 +11,7 @@ import forestry.api.genetics.IPollinatable;
|
||||
public class FlowerProviderBotania extends FlowerProvider {
|
||||
|
||||
public FlowerProviderBotania() {
|
||||
super(1);
|
||||
flowers.add(new FlowerImpl(BotaniaHelper.blockMysticalFlower, OreDictionary.WILDCARD_VALUE, 1, true));
|
||||
registerPlantableFlower(BotaniaHelper.blockMysticalFlower, OreDictionary.WILDCARD_VALUE, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -35,8 +34,8 @@ public class FlowerProviderBotania extends FlowerProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
return world.getBlock(x, y, z) == BotaniaHelper.blockMysticalFlower;
|
||||
public String getFlowerType() {
|
||||
return "flowersBotania";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+7
-15
@@ -12,21 +12,8 @@ import forestry.api.genetics.IPollinatable;
|
||||
public class FlowerProviderThaumcraftFlower extends FlowerProvider {
|
||||
|
||||
public FlowerProviderThaumcraftFlower() {
|
||||
super(2);
|
||||
flowers.add(new FlowerImpl(ThaumcraftHelper.plant, ThaumcraftHelper.BlockPlant.SHIMMERLEAF.ordinal(), 1, true));
|
||||
flowers.add(new FlowerImpl(ThaumcraftHelper.plant, ThaumcraftHelper.BlockPlant.CINDERPEARL.ordinal(), 1, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(World world, IIndividual genome, int x, int y, int z) {
|
||||
if (world.getBlock(x, y, z) == ThaumcraftHelper.plant) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == ThaumcraftHelper.BlockPlant.SHIMMERLEAF.ordinal()
|
||||
|| meta == ThaumcraftHelper.BlockPlant.CINDERPEARL.ordinal()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
registerPlantableFlower(ThaumcraftHelper.plant, ThaumcraftHelper.BlockPlant.SHIMMERLEAF.ordinal(), 1);
|
||||
registerPlantableFlower(ThaumcraftHelper.plant, ThaumcraftHelper.BlockPlant.CINDERPEARL.ordinal(), 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,6 +32,11 @@ public class FlowerProviderThaumcraftFlower extends FlowerProvider {
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFlowerType() {
|
||||
return "flowersThaumcraft";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return LocalizationManager.getLocalizedString("flowerProvider.magic");
|
||||
|
||||
@@ -9,10 +9,10 @@ import magicbees.main.utils.TabMagicBees;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IHiveFrame;
|
||||
|
||||
public class ItemMagicHiveFrame extends Item implements IHiveFrame
|
||||
@@ -39,91 +39,26 @@ public class ItemMagicHiveFrame extends Item implements IHiveFrame
|
||||
// --------- IHiveFrame functions -----------------------------------------
|
||||
|
||||
@Override
|
||||
public ItemStack frameUsed(IBeeHousing housing, ItemStack frame, IBee queen, int wear)
|
||||
{
|
||||
return this.doWear(housing.getWorld(), housing.getXCoord(), housing.getYCoord(), housing.getZCoord(), frame, wear);
|
||||
}
|
||||
|
||||
private ItemStack doWear(World w, int x, int y, int z, ItemStack frame, int wear)
|
||||
{
|
||||
int damage = wear;
|
||||
|
||||
frame.setItemDamage(frame.getItemDamage() + damage);
|
||||
|
||||
if (frame.getItemDamage() >= frame.getMaxDamage())
|
||||
{
|
||||
public ItemStack frameUsed(IBeeHousing housing, ItemStack frame, IBee queen, int wear) {
|
||||
frame.setItemDamage(frame.getItemDamage() + wear);
|
||||
|
||||
if (frame.getItemDamage() >= frame.getMaxDamage()) {
|
||||
// Break the frame.
|
||||
frame = null;
|
||||
}
|
||||
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBeeModifier getBeeModifier() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTerritoryModifier(IBeeGenome genome, float currentModifier)
|
||||
{
|
||||
return this.type.territoryMod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier)
|
||||
{
|
||||
return this.type.mutationMod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier)
|
||||
{
|
||||
return this.type.lifespanMod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProductionModifier(IBeeGenome genome, float currentModifier)
|
||||
{
|
||||
return this.type.productionMod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloweringModifier(IBeeGenome genome, float currentModifier)
|
||||
{
|
||||
return this.type.floweringMod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSealed()
|
||||
{
|
||||
return this.type.isSealed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelfLighted()
|
||||
{
|
||||
return this.type.isLit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSunlightSimulated()
|
||||
{
|
||||
return this.type.isSunlit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHellish()
|
||||
{
|
||||
return this.type.isHellish;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGeneticDecay(IBeeGenome genome, float currentModifier)
|
||||
{
|
||||
return this.type.geneticDecayMod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBookEnchantable(ItemStack itemstack1, ItemStack itemstack2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
package magicbees.item.types;
|
||||
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
|
||||
import magicbees.main.utils.LocalizationManager;
|
||||
|
||||
public enum HiveFrameType
|
||||
public enum HiveFrameType implements IBeeModifier
|
||||
{
|
||||
MAGIC("Magic", 240, 1f, 1f, 1f, 2f, 0.6f),
|
||||
RESILIENT("Resilient", 800, 1f, 1f, 1f, 2f, 0.5f),
|
||||
@@ -12,14 +15,26 @@ public enum HiveFrameType
|
||||
TEMPORAL("Temporal", 300, 1f, 1f, 2.5f, 1f, 0.8f),
|
||||
OBLIVION("Oblivion", 50, 1f, 1f, 0.0001f, 0f, 1f),
|
||||
;
|
||||
|
||||
private final String frameName;
|
||||
public final int maxDamage;
|
||||
|
||||
private final float territoryMod;
|
||||
private final float mutationMod;
|
||||
private final float lifespanMod;
|
||||
private final float productionMod;
|
||||
private final float floweringMod;
|
||||
private final float geneticDecayMod;
|
||||
private final boolean isSealed;
|
||||
private final boolean isLit;
|
||||
private final boolean isSunlit;
|
||||
private final boolean isHellish;
|
||||
|
||||
private HiveFrameType(String name, int damage,
|
||||
float territory, float mutation, float lifespan, float production, float geneticDecay)
|
||||
{
|
||||
HiveFrameType(String name, int damage, float territory, float mutation, float lifespan, float production, float geneticDecay) {
|
||||
this(name, damage, territory, mutation, lifespan, production, 1f, geneticDecay, false, false, false, false);
|
||||
}
|
||||
|
||||
private HiveFrameType(String name, int damage,
|
||||
HiveFrameType(String name, int damage,
|
||||
float territory, float mutation, float lifespan, float production, float flowering, float geneticDecay,
|
||||
boolean sealed, boolean lit, boolean sunlit, boolean hellish)
|
||||
{
|
||||
@@ -37,21 +52,7 @@ public enum HiveFrameType
|
||||
this.isSunlit = sunlit;
|
||||
this.isHellish = hellish;
|
||||
}
|
||||
|
||||
private String frameName;
|
||||
public int maxDamage;
|
||||
|
||||
public float territoryMod;
|
||||
public float mutationMod;
|
||||
public float lifespanMod;
|
||||
public float productionMod;
|
||||
public float floweringMod;
|
||||
public float geneticDecayMod;
|
||||
public boolean isSealed;
|
||||
public boolean isLit;
|
||||
public boolean isSunlit;
|
||||
public boolean isHellish;
|
||||
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.frameName;
|
||||
@@ -61,4 +62,54 @@ public enum HiveFrameType
|
||||
{
|
||||
return LocalizationManager.getLocalizedString("frame." + this.frameName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTerritoryModifier(IBeeGenome genome, float currentModifier) {
|
||||
return territoryMod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
||||
return mutationMod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
||||
return lifespanMod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
|
||||
return productionMod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloweringModifier(IBeeGenome genome, float currentModifier) {
|
||||
return floweringMod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGeneticDecay(IBeeGenome genome, float currentModifier) {
|
||||
return geneticDecayMod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSealed() {
|
||||
return isSealed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelfLighted() {
|
||||
return isLit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSunlightSimulated() {
|
||||
return isSunlit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHellish() {
|
||||
return isHellish;
|
||||
}
|
||||
}
|
||||
@@ -1,245 +1,240 @@
|
||||
package magicbees.tileentity;
|
||||
|
||||
import java.util.Set;
|
||||
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.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.DefaultBeeListener;
|
||||
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.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ErrorStateRegistry;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
import magicbees.bees.BeeManager;
|
||||
|
||||
|
||||
/**
|
||||
* Singleton object to simulate enough of a bee house to fire the bee effects. =D
|
||||
* Simulates enough of a bee house to fire the bee effects. =D
|
||||
*
|
||||
* @author MysteriousAges
|
||||
* @author MysteriousAges, mezz
|
||||
*/
|
||||
public class EffectJarHousing implements IBeeHousing
|
||||
{
|
||||
private static EffectJarHousing instance = new EffectJarHousing();
|
||||
public class EffectJarHousing implements IBeeHousing {
|
||||
|
||||
TileEntityEffectJar jarEntity;
|
||||
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());
|
||||
|
||||
public static EffectJarHousing getFor(TileEntityEffectJar entity)
|
||||
{
|
||||
instance.jarEntity = entity;
|
||||
return instance;
|
||||
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);
|
||||
}
|
||||
|
||||
@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 float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier)
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProductionModifier(IBeeGenome genome, float currentModifier)
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloweringModifier(IBeeGenome genome, float currentModifier)
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getXCoord()
|
||||
{
|
||||
return this.jarEntity.xCoord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getYCoord()
|
||||
{
|
||||
return this.jarEntity.yCoord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZCoord()
|
||||
{
|
||||
return this.jarEntity.zCoord;
|
||||
}
|
||||
|
||||
@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 void onQueenChange(ItemStack queen)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wearOutEquipment(int amount)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQueenDeath(IBee queen)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostQueenDeath(IBee queen)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getQueen()
|
||||
{
|
||||
return this.jarEntity.getStackInSlot(TileEntityEffectJar.QUEEN_SLOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDrone()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQueen(ItemStack itemStack)
|
||||
{
|
||||
this.jarEntity.setInventorySlotContents(TileEntityEffectJar.QUEEN_SLOT, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDrone(ItemStack itemstack)
|
||||
{
|
||||
public ChunkCoordinates getCoordinates() {
|
||||
return new ChunkCoordinates(jarEntity.xCoord, jarEntity.yCoord, jarEntity.zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeGenBase getBiome() {
|
||||
return this.jarEntity.getWorldObj().getBiomeGenForCoords(getXCoord(), getYCoord());
|
||||
return biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature()
|
||||
{
|
||||
EnumTemperature temp = EnumTemperature.NORMAL;
|
||||
ItemStack stack = this.jarEntity.getStackInSlot(TileEntityEffectJar.QUEEN_SLOT);
|
||||
if (stack != null)
|
||||
{
|
||||
IBee queen = magicbees.bees.BeeManager.beeRoot.getMember(stack);
|
||||
temp = queen.getGenome().getPrimary().getTemperature();
|
||||
public EnumTemperature getTemperature() {
|
||||
return EnumTemperature.getFromBiome(biome, jarEntity.xCoord, jarEntity.yCoord, jarEntity.zCoord);
|
||||
}
|
||||
|
||||
@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 boolean canBlockSeeTheSky() {
|
||||
return jarEntity.getWorldObj().canBlockSeeTheSky(jarEntity.xCoord, jarEntity.yCoord + 1, jarEntity.zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return jarEntity.getWorldObj();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfile getOwner() {
|
||||
return jarEntity.getOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IErrorLogic getErrorLogic() {
|
||||
return errorLogic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBeeHousingInventory getBeeInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBeekeepingLogic getBeekeepingLogic() {
|
||||
return beekeepingLogic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IBeeModifier> getBeeModifiers() {
|
||||
return beeModifiers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IBeeListener> getBeeListeners() {
|
||||
return beeListeners;
|
||||
}
|
||||
|
||||
private static class JarBeeHousingInventory implements IBeeHousingInventory {
|
||||
private final TileEntityEffectJar jarEntity;
|
||||
|
||||
public JarBeeHousingInventory(TileEntityEffectJar jarEntity) {
|
||||
this.jarEntity = jarEntity;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity()
|
||||
{
|
||||
EnumHumidity humid = EnumHumidity.NORMAL;
|
||||
ItemStack stack = this.jarEntity.getStackInSlot(TileEntityEffectJar.QUEEN_SLOT);
|
||||
if (stack != null)
|
||||
{
|
||||
IBee queen = magicbees.bees.BeeManager.beeRoot.getMember(stack);
|
||||
humid = queen.getGenome().getPrimary().getHumidity();
|
||||
@Override
|
||||
public ItemStack getQueen() {
|
||||
return jarEntity.getStackInSlot(TileEntityEffectJar.QUEEN_SLOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDrone() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQueen(ItemStack itemStack) {
|
||||
jarEntity.setInventorySlotContents(TileEntityEffectJar.QUEEN_SLOT, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDrone(ItemStack itemstack) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addProduct(ItemStack product, boolean all) {
|
||||
return false;
|
||||
}
|
||||
return humid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
return this.jarEntity.getWorldObj();
|
||||
private static class JarErrorLogic implements IErrorLogic {
|
||||
|
||||
@Override
|
||||
public boolean setCondition(boolean condition, IErrorState errorState) {
|
||||
return condition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(IErrorState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasErrors() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearErrors() {
|
||||
|
||||
}
|
||||
|
||||
@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 GameProfile getOwnerName()
|
||||
{
|
||||
return this.jarEntity.getOwner();
|
||||
}
|
||||
private static class JarHousingModifier implements IBeeModifier {
|
||||
@Override
|
||||
public float getTerritoryModifier(IBeeGenome genome, float currentModifier) {
|
||||
return 0.9f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setErrorState(IErrorState enumErrorCode)
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<IErrorState> getErrorStates() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setErrorCondition(boolean condition, IErrorState errorState) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public float getFloweringModifier(IBeeGenome genome, float currentModifier) {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IErrorState getErrorState()
|
||||
{
|
||||
return ErrorStateRegistry.getErrorState("ok");
|
||||
}
|
||||
@Override
|
||||
public float getGeneticDecay(IBeeGenome genome, float currentModifier) {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBreed()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isSealed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addProduct(ItemStack product, boolean all)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isSelfLighted() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isSunlightSimulated() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onEggLaid(IBee queen)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGeneticDecay(IBeeGenome genome, float currentModifier)
|
||||
{
|
||||
return 0f;
|
||||
@Override
|
||||
public boolean isHellish() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,23 +9,19 @@ 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.IAlleleBeeSpecies;
|
||||
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 GameProfile ownerName;
|
||||
|
||||
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;
|
||||
@@ -89,7 +85,7 @@ public class TileEntityEffectJar extends TileEntity implements IInventory {
|
||||
int current = bee.getHealth();
|
||||
int max = bee.getMaxHealth();
|
||||
currentBeeHealth = (current * 100) / max;
|
||||
currentBeeColour = ((IAlleleBeeSpecies)bee.getGenome().getPrimary()).getIconColour(0);
|
||||
currentBeeColour = bee.getGenome().getPrimary().getIconColour(0);
|
||||
}
|
||||
this.markDirty();
|
||||
}
|
||||
@@ -102,9 +98,9 @@ public class TileEntityEffectJar extends TileEntity implements IInventory {
|
||||
IBee queen = magicbees.bees.BeeManager.beeRoot.getMember(this.beeSlots[QUEEN_SLOT]);
|
||||
|
||||
currentBeeHealth = (queen.getHealth() * 100) / queen.getMaxHealth();
|
||||
currentBeeColour = ((IAlleleBeeSpecies)queen.getGenome().getPrimary()).getIconColour(0);
|
||||
currentBeeColour = queen.getGenome().getPrimary().getIconColour(0);
|
||||
|
||||
EffectJarHousing housingLogic = EffectJarHousing.getFor(this);
|
||||
EffectJarHousing housingLogic = new EffectJarHousing(this);
|
||||
this.effectData = queen.doEffect(this.effectData, housingLogic);
|
||||
if (this.worldObj.getWorldTime() % 5 == 0)
|
||||
{
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package magicbees.tileentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import magicbees.api.bees.IMagicApiaryAuraProvider;
|
||||
import magicbees.bees.AuraCharge;
|
||||
import magicbees.bees.BeeManager;
|
||||
import magicbees.main.CommonProxy;
|
||||
import magicbees.main.MagicBees;
|
||||
import magicbees.main.utils.ChunkCoords;
|
||||
import magicbees.main.utils.ItemStackUtils;
|
||||
import magicbees.main.utils.net.EventAuraChargeUpdate;
|
||||
@@ -19,11 +18,13 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.World;
|
||||
@@ -33,50 +34,75 @@ 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.ErrorStateRegistry;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
|
||||
public class TileEntityMagicApiary extends TileEntity implements ISidedInventory, IBeeHousing, ITileEntityAuraCharged {
|
||||
|
||||
public static final String tileEntityName = CommonProxy.DOMAIN + ".magicApiary";
|
||||
private GameProfile ownerProfile;
|
||||
|
||||
// Constants
|
||||
private static final int SLOT_QUEEN = 0;
|
||||
private static final int SLOT_DRONE = 1;
|
||||
private static final int SLOT_FRAME_START = 2;
|
||||
private static final int SLOT_FRAME_COUNT = 3;
|
||||
private static final int SLOT_PRODUCTS_START = 5;
|
||||
private static final int SLOT_PRODUCTS_COUNT = 7;
|
||||
|
||||
private static final int AURAPROVIDER_SEARCH_RADIUS = 6;
|
||||
|
||||
private IBeekeepingLogic logic;
|
||||
public static final String tileEntityName = CommonProxy.DOMAIN + ".magicApiary";
|
||||
|
||||
private GameProfile ownerProfile;
|
||||
private IMagicApiaryAuraProvider auraProvider;
|
||||
private ChunkCoords auraProviderPosition;
|
||||
private BiomeGenBase biome;
|
||||
private int displayHealthMax = 0;
|
||||
private int displayHealth = 0;
|
||||
private boolean init = false;
|
||||
private int breedingProgressPercent = 0;
|
||||
|
||||
private final IBeekeepingLogic beeLogic;
|
||||
private final IErrorLogic errorLogic;
|
||||
private final IBeeListener beeListener;
|
||||
private final IBeeModifier beeModifier;
|
||||
private final MagicApiaryInventory inventory;
|
||||
private final AuraCharges auraCharges = new AuraCharges();
|
||||
|
||||
private IErrorState errorState = ErrorStateRegistry.getErrorState("ok");
|
||||
private Set<IErrorState> errors = new HashSet<IErrorState>();
|
||||
|
||||
private ItemStack[] items;
|
||||
|
||||
public TileEntityMagicApiary(){
|
||||
items = new ItemStack[12];
|
||||
logic = BeeManager.beeRoot.createBeekeepingLogic(this);
|
||||
beeLogic = BeeManager.beeRoot.createBeekeepingLogic(this);
|
||||
beeModifier = new MagicApiaryBeeModifier(this);
|
||||
beeListener = new MagicApiaryBeeListener(this);
|
||||
inventory = new MagicApiaryInventory(this);
|
||||
errorLogic = ForestryAPI.errorStateRegistry.createErrorLogic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IBeeModifier> getBeeModifiers() {
|
||||
List<IBeeModifier> beeModifiers = new ArrayList<IBeeModifier>();
|
||||
|
||||
beeModifiers.add(beeModifier);
|
||||
|
||||
for (IHiveFrame frame : inventory.getFrames()) {
|
||||
beeModifiers.add(frame.getBeeModifier());
|
||||
}
|
||||
|
||||
return beeModifiers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IBeeListener> getBeeListeners() {
|
||||
return Collections.singleton(beeListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBeeHousingInventory getBeeInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBeekeepingLogic getBeekeepingLogic() {
|
||||
return beeLogic;
|
||||
}
|
||||
|
||||
public void setOwner(EntityPlayer player) {
|
||||
@@ -84,175 +110,12 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getQueen() {
|
||||
return getStackInSlot(SLOT_QUEEN);
|
||||
public IErrorLogic getErrorLogic() {
|
||||
return errorLogic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDrone() {
|
||||
return getStackInSlot(SLOT_DRONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQueen(ItemStack itemstack) {
|
||||
setInventorySlotContents(SLOT_QUEEN, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDrone(ItemStack itemstack) {
|
||||
setInventorySlotContents(SLOT_DRONE, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBreed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQueenChange(ItemStack queenStack) {
|
||||
if (!worldObj.isRemote) {
|
||||
MagicBees.object.netHandler.sendInventoryUpdate(this, SLOT_QUEEN, queenStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wearOutEquipment(int amount) {
|
||||
int wear = Math.round(amount * BeeManager.beeRoot.getBeekeepingMode(worldObj).getWearModifier());
|
||||
|
||||
for (int i = SLOT_FRAME_START; i < SLOT_FRAME_START + SLOT_FRAME_COUNT; i++) {
|
||||
if (getStackInSlot(i) == null) {
|
||||
continue;
|
||||
}
|
||||
if (!(getStackInSlot(i).getItem() instanceof IHiveFrame)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
setInventorySlotContents(i, ((IHiveFrame) getStackInSlot(i).getItem()).frameUsed(this, getStackInSlot(i),
|
||||
BeeManager.beeRoot.getMember(getStackInSlot(SLOT_QUEEN)), wear));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQueenDeath(IBee queen) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostQueenDeath(IBee queen) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onEggLaid(IBee queen) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isItemStackFrame(int i) {
|
||||
return getStackInSlot(i) != null && getStackInSlot(i).getItem() instanceof IHiveFrame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTerritoryModifier(IBeeGenome genome, float currentModifier) {
|
||||
float mod = 1.0f;
|
||||
for (int slotIndex = SLOT_FRAME_START; slotIndex < SLOT_FRAME_START + SLOT_FRAME_COUNT; slotIndex++) {
|
||||
if (isItemStackFrame(slotIndex)) {
|
||||
mod *= ((IHiveFrame) getStackInSlot(slotIndex).getItem()).getTerritoryModifier(genome, mod);
|
||||
}
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
||||
float mod = 1.0f;
|
||||
for (int slotIndex = SLOT_FRAME_START; slotIndex < SLOT_FRAME_START + SLOT_FRAME_COUNT; slotIndex++) {
|
||||
if (isItemStackFrame(slotIndex)) {
|
||||
mod *= ((IHiveFrame) getStackInSlot(slotIndex).getItem()).getMutationModifier(genome, mate, mod);
|
||||
}
|
||||
}
|
||||
if (this.isMutationBoosted()) {
|
||||
mod = mod * 2f;
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
||||
float mod = 1.0f;
|
||||
for (int slotIndex = SLOT_FRAME_START; slotIndex < SLOT_FRAME_START + SLOT_FRAME_COUNT; slotIndex++) {
|
||||
if (isItemStackFrame(slotIndex)) {
|
||||
mod *= ((IHiveFrame) getStackInSlot(slotIndex).getItem()).getLifespanModifier(genome, mate, mod);
|
||||
}
|
||||
}
|
||||
if (this.isDeathRateBoosted()) {
|
||||
mod = mod / 2f;
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
|
||||
float mod = 0.9f;
|
||||
for (int slotIndex = SLOT_FRAME_START; slotIndex < SLOT_FRAME_START + SLOT_FRAME_COUNT; slotIndex++){
|
||||
if (isItemStackFrame(slotIndex)) {
|
||||
mod *= ((IHiveFrame) getStackInSlot(slotIndex).getItem()).getProductionModifier(genome, mod);
|
||||
}
|
||||
}
|
||||
if (this.isProductionBoosted()) {
|
||||
mod = mod * 2f;
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloweringModifier(IBeeGenome genome, float currentModifier) {
|
||||
float mod = 1.0f;
|
||||
for (int slotIndex = SLOT_FRAME_START; slotIndex < SLOT_FRAME_START + SLOT_FRAME_COUNT; slotIndex++) {
|
||||
if (isItemStackFrame(slotIndex)) {
|
||||
mod *= ((IHiveFrame) getStackInSlot(slotIndex).getItem()).getFloweringModifier(genome, mod);
|
||||
}
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGeneticDecay(IBeeGenome genome, float currentModifier) {
|
||||
float mod = 0.8f;
|
||||
for (int slotIndex = SLOT_FRAME_START; slotIndex < SLOT_FRAME_START + SLOT_FRAME_COUNT; slotIndex++) {
|
||||
if (isItemStackFrame(slotIndex)) {
|
||||
mod *= ((IHiveFrame) getStackInSlot(slotIndex).getItem()).getGeneticDecay(genome, mod);
|
||||
}
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSealed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelfLighted() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSunlightSimulated() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHellish() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfile getOwnerName() {
|
||||
public GameProfile getOwner() {
|
||||
return this.ownerProfile;
|
||||
}
|
||||
|
||||
@@ -262,28 +125,21 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getXCoord() {
|
||||
return xCoord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getYCoord() {
|
||||
return yCoord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZCoord() {
|
||||
return zCoord;
|
||||
public ChunkCoordinates getCoordinates() {
|
||||
return new ChunkCoordinates(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeGenBase getBiome() {
|
||||
if (biome == null) {
|
||||
biome = worldObj.getBiomeGenForCoordsBody(xCoord, zCoord);
|
||||
}
|
||||
return biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
return EnumTemperature.getFromValue(getExactTemperature());
|
||||
return EnumTemperature.getFromBiome(getBiome(), xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -292,51 +148,23 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setErrorState(IErrorState state) {
|
||||
this.errorState = state;
|
||||
public int getBlockLightValue() {
|
||||
return worldObj.getBlockLightValue(xCoord, yCoord + 1, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IErrorState getErrorState() {
|
||||
return this.errorState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setErrorCondition(boolean condition, IErrorState errorState) {
|
||||
if (!condition) {
|
||||
errors.add(errorState);
|
||||
}
|
||||
else {
|
||||
errors.remove(errorState);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<IErrorState> getErrorStates() {
|
||||
return errors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addProduct(ItemStack product, boolean all) {
|
||||
int countAdded = ItemStackUtils.addItemToInventory(this, product, SLOT_PRODUCTS_START, SLOT_PRODUCTS_COUNT);
|
||||
|
||||
if (all) {
|
||||
return countAdded == product.stackSize;
|
||||
}
|
||||
else {
|
||||
return countAdded > 0;
|
||||
}
|
||||
public boolean canBlockSeeTheSky() {
|
||||
return worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return items.length;
|
||||
return inventory.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return items[i];
|
||||
return inventory.getStackInSlot(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -364,12 +192,7 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemStack) {
|
||||
items[i] = itemStack;
|
||||
|
||||
if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()){
|
||||
itemStack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
|
||||
inventory.setInventorySlotContents(i, itemStack);
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@@ -385,7 +208,7 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
return inventory.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -408,82 +231,8 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
if (side == 0 || side == 1) {
|
||||
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;
|
||||
}
|
||||
return slots;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack itemStack, int side) {
|
||||
if(slot == SLOT_QUEEN && BeeManager.beeRoot.isMember(itemStack)
|
||||
&& !BeeManager.beeRoot.isDrone(itemStack)) {
|
||||
return true;
|
||||
}
|
||||
else if (slot == SLOT_DRONE && BeeManager.beeRoot.isDrone(itemStack)) {
|
||||
return true;
|
||||
}
|
||||
return slot == SLOT_DRONE && BeeManager.beeRoot.isDrone(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack itemStack, int side) {
|
||||
switch (slot){
|
||||
case SLOT_FRAME_START:
|
||||
case SLOT_FRAME_START + 1:
|
||||
case SLOT_FRAME_START + 2:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private int getHealthDisplay() {
|
||||
if (getStackInSlot(SLOT_QUEEN) == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (BeeManager.beeRoot.isMated(getStackInSlot(SLOT_QUEEN))) {
|
||||
return BeeManager.beeRoot.getMember(getStackInSlot(SLOT_QUEEN)).getHealth();
|
||||
}
|
||||
else if (!BeeManager.beeRoot.isDrone(getStackInSlot(SLOT_QUEEN))) {
|
||||
return displayHealth;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private int getMaxHealthDisplay() {
|
||||
if (getStackInSlot(SLOT_QUEEN) == null) {
|
||||
return 0;
|
||||
}
|
||||
if (BeeManager.beeRoot.isMated(getStackInSlot(SLOT_QUEEN))) {
|
||||
return BeeManager.beeRoot.getMember(getStackInSlot(SLOT_QUEEN)).getMaxHealth();
|
||||
}
|
||||
else if (!BeeManager.beeRoot.isDrone(getStackInSlot(SLOT_QUEEN))) {
|
||||
return displayHealthMax;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int getHealthScaled(int i) {
|
||||
if (getMaxHealthDisplay() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (getHealthDisplay() * i) / getMaxHealthDisplay();
|
||||
return (breedingProgressPercent * i) / 100;
|
||||
}
|
||||
|
||||
public int getTemperatureScaled(int i) {
|
||||
@@ -499,27 +248,9 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
public void writeToNBT(NBTTagCompound compound) {
|
||||
super.writeToNBT(compound);
|
||||
|
||||
NBTTagList items = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < getSizeInventory(); i++) {
|
||||
ItemStack itemStack = getStackInSlot(i);
|
||||
|
||||
if (itemStack != null) {
|
||||
NBTTagCompound item = new NBTTagCompound();
|
||||
item.setByte("Slot", (byte)i);
|
||||
itemStack.writeToNBT(item);
|
||||
items.appendTag(item);
|
||||
}
|
||||
}
|
||||
compound.setTag("Items", items);
|
||||
|
||||
compound.setInteger("BiomeId", biome.biomeID);
|
||||
if (logic != null) {
|
||||
logic.writeToNBT(compound);
|
||||
}
|
||||
|
||||
ChunkCoords.writeToNBT(this.auraProviderPosition, compound);
|
||||
|
||||
inventory.writeToNBT(compound);
|
||||
beeLogic.writeToNBT(compound);
|
||||
ChunkCoords.writeToNBT(auraProviderPosition, compound);
|
||||
auraCharges.writeToNBT(compound);
|
||||
}
|
||||
|
||||
@@ -527,47 +258,29 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
super.readFromNBT(compound);
|
||||
|
||||
NBTTagList items = compound.getTagList("Items", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < items.tagCount(); i++) {
|
||||
NBTTagCompound item = items.getCompoundTagAt(i);
|
||||
int slot = item.getByte("Slot");
|
||||
|
||||
if (slot >= 0 && slot < getSizeInventory()) {
|
||||
setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(item));
|
||||
}
|
||||
}
|
||||
|
||||
int biomeId = compound.getInteger("BiomeId");
|
||||
biome = BiomeGenBase.getBiome(biomeId);
|
||||
logic.readFromNBT(compound);
|
||||
|
||||
this.auraProviderPosition = ChunkCoords.readFromNBT(compound);
|
||||
|
||||
inventory.readFromNBT(compound);
|
||||
beeLogic.readFromNBT(compound);
|
||||
auraProviderPosition = ChunkCoords.readFromNBT(compound);
|
||||
auraCharges.readFromNBT(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
beeLogic.syncToClient();
|
||||
EventAuraChargeUpdate event = new EventAuraChargeUpdate(new ChunkCoords(this), auraCharges);
|
||||
return event.getPacket();
|
||||
}
|
||||
|
||||
public float getExactTemperature() {
|
||||
return biome.temperature;
|
||||
return getBiome().getFloatTemperature(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
public float getExactHumidity() {
|
||||
return biome.rainfall;
|
||||
return getBiome().rainfall;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (!init) {
|
||||
init = true;
|
||||
updateBiome();
|
||||
}
|
||||
|
||||
if (worldObj.isRemote) {
|
||||
updateClientSide();
|
||||
}
|
||||
@@ -576,24 +289,9 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
}
|
||||
}
|
||||
|
||||
public void updateBiome() {
|
||||
if (worldObj != null) {
|
||||
if (biome == null) {
|
||||
BiomeGenBase biome = worldObj.getBiomeGenForCoordsBody(xCoord, zCoord);
|
||||
if (biome != null) {
|
||||
this.biome = biome;
|
||||
setErrorState(ErrorStateRegistry.getErrorState("OK"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateClientSide() {
|
||||
if (BeeManager.beeRoot.isMated(getStackInSlot(SLOT_QUEEN))) {
|
||||
if (getErrorState() == ErrorStateRegistry.getErrorState("OK") && worldObj.getTotalWorldTime() % 10 == 0) {
|
||||
IBee displayQueen = BeeManager.beeRoot.getMember(getStackInSlot(SLOT_QUEEN));
|
||||
displayQueen.doFX(logic.getEffectData(), this);
|
||||
}
|
||||
if (beeLogic.canDoBeeFX() && worldObj.getTotalWorldTime() % 10 == 0) {
|
||||
beeLogic.doBeeFX();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -605,42 +303,22 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
updateAuraProvider();
|
||||
}
|
||||
tickCharges();
|
||||
|
||||
if (logic.canWork()) {
|
||||
logic.doWork();
|
||||
}
|
||||
|
||||
IBee queen = logic.getQueen();
|
||||
if (queen == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (worldObj.getTotalWorldTime() % 5 == 0) {
|
||||
onQueenChange(getStackInSlot(SLOT_QUEEN));
|
||||
if (beeLogic.canWork()) {
|
||||
beeLogic.doWork();
|
||||
}
|
||||
}
|
||||
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
if (logic == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch(i) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
displayHealth = j;
|
||||
break;
|
||||
case 1: displayHealthMax = j;
|
||||
breedingProgressPercent = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
if (logic == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
iCrafting.sendProgressBarUpdate(container, 0, logic.getBreedingTime());
|
||||
iCrafting.sendProgressBarUpdate(container, 1, logic.getTotalBreedingTime());
|
||||
iCrafting.sendProgressBarUpdate(container, 0, beeLogic.getBeeProgressPercent());
|
||||
}
|
||||
|
||||
public boolean isProductionBoosted() {
|
||||
@@ -779,4 +457,246 @@ public class TileEntityMagicApiary extends TileEntity implements ISidedInventory
|
||||
public AuraCharges getAuraCharges() {
|
||||
return auraCharges;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int i) {
|
||||
return inventory.getAccessibleSlotsFromSide(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int i, ItemStack itemStack, int i1) {
|
||||
return inventory.canInsertItem(i, itemStack, i1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int i, ItemStack itemStack, int i1) {
|
||||
return inventory.canExtractItem(i, itemStack, i1);
|
||||
}
|
||||
|
||||
private static class MagicApiaryInventory implements IBeeHousingInventory {
|
||||
public static final int SLOT_QUEEN = 0;
|
||||
public static final int SLOT_DRONE = 1;
|
||||
public static final int SLOT_FRAME_START = 2;
|
||||
public static final int SLOT_FRAME_COUNT = 3;
|
||||
public static final int SLOT_PRODUCTS_START = 5;
|
||||
public static final int SLOT_PRODUCTS_COUNT = 7;
|
||||
|
||||
private final TileEntityMagicApiary magicApiary;
|
||||
private ItemStack[] items;
|
||||
|
||||
public MagicApiaryInventory(TileEntityMagicApiary magicApiary) {
|
||||
this.magicApiary = magicApiary;
|
||||
this.items = new ItemStack[12];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getQueen() {
|
||||
return magicApiary.getStackInSlot(SLOT_QUEEN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDrone() {
|
||||
return magicApiary.getStackInSlot(SLOT_DRONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQueen(ItemStack itemstack) {
|
||||
magicApiary.setInventorySlotContents(SLOT_QUEEN, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDrone(ItemStack itemstack) {
|
||||
magicApiary.setInventorySlotContents(SLOT_DRONE, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addProduct(ItemStack product, boolean all) {
|
||||
int countAdded = ItemStackUtils.addItemToInventory(magicApiary, product, SLOT_PRODUCTS_START, SLOT_PRODUCTS_COUNT);
|
||||
|
||||
if (all) {
|
||||
return countAdded == product.stackSize;
|
||||
}
|
||||
else {
|
||||
return countAdded > 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int getSizeInventory() {
|
||||
return items.length;
|
||||
}
|
||||
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return items[i];
|
||||
}
|
||||
|
||||
public void setInventorySlotContents(int i, ItemStack itemStack) {
|
||||
items[i] = itemStack;
|
||||
|
||||
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 {
|
||||
int[] slots = new int[SLOT_PRODUCTS_COUNT];
|
||||
for (int i = 0, slot = SLOT_PRODUCTS_START; i < SLOT_PRODUCTS_COUNT; ++i, ++slot) {
|
||||
slots[i] = slot;
|
||||
}
|
||||
return slots;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canInsertItem(int slot, ItemStack itemStack, int side) {
|
||||
if(slot == SLOT_QUEEN && BeeManager.beeRoot.isMember(itemStack)
|
||||
&& !BeeManager.beeRoot.isDrone(itemStack)) {
|
||||
return true;
|
||||
}
|
||||
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){
|
||||
case SLOT_FRAME_START:
|
||||
case SLOT_FRAME_START + 1:
|
||||
case SLOT_FRAME_START + 2:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
public Collection<IHiveFrame> getFrames() {
|
||||
Collection<IHiveFrame> hiveFrames = new ArrayList<IHiveFrame>(SLOT_FRAME_COUNT);
|
||||
|
||||
for (int i = SLOT_FRAME_START; i < SLOT_FRAME_START + SLOT_FRAME_COUNT; i++) {
|
||||
ItemStack stackInSlot = magicApiary.getStackInSlot(i);
|
||||
if (stackInSlot == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Item itemInSlot = stackInSlot.getItem();
|
||||
if (itemInSlot instanceof IHiveFrame) {
|
||||
hiveFrames.add((IHiveFrame) itemInSlot);
|
||||
}
|
||||
}
|
||||
|
||||
return hiveFrames;
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound compound) {
|
||||
NBTTagList itemsNBT = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
ItemStack itemStack = items[i];
|
||||
|
||||
if (itemStack != null) {
|
||||
NBTTagCompound item = new NBTTagCompound();
|
||||
item.setByte("Slot", (byte)i);
|
||||
itemStack.writeToNBT(item);
|
||||
itemsNBT.appendTag(item);
|
||||
}
|
||||
}
|
||||
compound.setTag("Items", itemsNBT);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
NBTTagList items = compound.getTagList("Items", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < items.tagCount(); i++) {
|
||||
NBTTagCompound item = items.getCompoundTagAt(i);
|
||||
int slot = item.getByte("Slot");
|
||||
|
||||
if (slot >= 0 && slot < getSizeInventory()) {
|
||||
setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(item));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class MagicApiaryBeeModifier extends DefaultBeeModifier {
|
||||
|
||||
private final TileEntityMagicApiary magicApiary;
|
||||
|
||||
public MagicApiaryBeeModifier(TileEntityMagicApiary magicApiary) {
|
||||
this.magicApiary = magicApiary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
||||
float mod = 1.0f;
|
||||
if (magicApiary.isMutationBoosted()) {
|
||||
mod = mod * 2f;
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
||||
float mod = 1.0f;
|
||||
if (magicApiary.isDeathRateBoosted()) {
|
||||
mod = mod / 2f;
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
|
||||
float mod = 0.9f;
|
||||
if (magicApiary.isProductionBoosted()) {
|
||||
mod = mod * 2f;
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGeneticDecay(IBeeGenome genome, float currentModifier) {
|
||||
return 0.8f;
|
||||
}
|
||||
}
|
||||
|
||||
private static class MagicApiaryBeeListener extends DefaultBeeListener {
|
||||
|
||||
private final TileEntityMagicApiary magicApiary;
|
||||
|
||||
public MagicApiaryBeeListener(TileEntityMagicApiary magicApiary) {
|
||||
this.magicApiary = magicApiary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wearOutEquipment(int amount) {
|
||||
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++) {
|
||||
ItemStack hiveFrameStack = magicApiary.getStackInSlot(i);
|
||||
if (hiveFrameStack == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Item hiveFrameItem = hiveFrameStack.getItem();
|
||||
if (!(hiveFrameItem instanceof IHiveFrame)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
IHiveFrame hiveFrame = (IHiveFrame) hiveFrameItem;
|
||||
|
||||
ItemStack queenStack = magicApiary.getBeeInventory().getQueen();
|
||||
IBee queen = BeeManager.beeRoot.getMember(queenStack);
|
||||
ItemStack usedFrame = hiveFrame.frameUsed(magicApiary, hiveFrameStack, queen, wear);
|
||||
|
||||
magicApiary.setInventorySlotContents(i, usedFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user