mirror of
https://github.com/GTNewHorizons/MagicBees.git
synced 2026-11-20 20:22:21 +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");
|
||||
|
||||
Reference in new issue
Block a user