mirror of
https://github.com/GTNewHorizons/MagicBees.git
synced 2026-11-23 21:50:06 +00:00
Breaking effect alleles and flower providers into their own namespace.
Cleaned up effect & flower provider alleles. Added basic genome template for Botanical, Blossoming, Floral bees. Added FlowerProviderBotania to grow Mystical Flowers.
This commit is contained in:
1 parent
eeb6cb356d
commit
7afda32063
23 files changed
+604
-690
No files matched your search
@@ -0,0 +1,80 @@
|
||||
package magicbees.bees.allele.effect;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import magicbees.bees.AlleleEffect;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
|
||||
public class AlleleEffectCrumbling extends AlleleEffect {
|
||||
private static HashMap<ItemStack, ItemStack> crumbleMap = new HashMap<ItemStack, ItemStack>();
|
||||
|
||||
public static void addPairToMap(ItemStack source, ItemStack target) {
|
||||
boolean add = true;
|
||||
for (ItemStack i : crumbleMap.keySet()) {
|
||||
if (OreDictionary.itemMatches(i, source, false)) {
|
||||
add = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (add) {
|
||||
crumbleMap.put(source, target);
|
||||
}
|
||||
}
|
||||
|
||||
public AlleleEffectCrumbling(String id, boolean isDominant) {
|
||||
super(id, isDominant, 600);
|
||||
|
||||
addPairToMap(new ItemStack(Blocks.stone), new ItemStack(Blocks.cobblestone));
|
||||
addPairToMap(new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.mossy_cobblestone));
|
||||
addPairToMap(new ItemStack(Blocks.stonebrick, 1, 0), new ItemStack(Blocks.stonebrick, 1, 2));
|
||||
addPairToMap(new ItemStack(Blocks.stonebrick, 1, 2), new ItemStack(Blocks.stonebrick, 1, 1));
|
||||
addPairToMap(new ItemStack(Blocks.cobblestone_wall), new ItemStack(Blocks.cobblestone_wall, 1, 1));
|
||||
addPairToMap(new ItemStack(Blocks.gravel), new ItemStack(Blocks.sand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEffectData validateStorage(IEffectData storedData) {
|
||||
if (storedData == null || !(storedData instanceof magicbees.bees.EffectData)) {
|
||||
storedData = new magicbees.bees.EffectData(1, 0, 0);
|
||||
}
|
||||
return storedData;
|
||||
}
|
||||
|
||||
@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]);
|
||||
|
||||
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;
|
||||
|
||||
Block block = world.getBlock(xCoord, yCoord, zCoord);
|
||||
if (block != null) {
|
||||
ItemStack source = new ItemStack(block, 1, world.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||
for (ItemStack key : crumbleMap.keySet()) {
|
||||
if (OreDictionary.itemMatches(source, key, false)) {
|
||||
ItemStack target = crumbleMap.get(key);
|
||||
world.setBlock(xCoord, yCoord, zCoord, Block.getBlockFromItem(target.getItem()), target.getItemDamage(), 2);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
storedData.setInteger(0, 0);
|
||||
|
||||
return storedData;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package magicbees.bees.allele.effect;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import magicbees.bees.AlleleEffect;
|
||||
import magicbees.bees.EffectData;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
|
||||
public class AlleleEffectCure extends AlleleEffect {
|
||||
|
||||
public AlleleEffectCure(String id, boolean isDominant) {
|
||||
super(id, isDominant, 200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEffectData validateStorage(IEffectData storedData) {
|
||||
if (storedData == null) {
|
||||
storedData = new EffectData(1, 0, 0);
|
||||
}
|
||||
return storedData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
List<Entity> entityList = this.getEntitiesWithinRange(genome, housing);
|
||||
|
||||
for (Entity e : entityList) {
|
||||
if (e instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) e;
|
||||
player.curePotionEffects(new ItemStack(Items.milk_bucket));
|
||||
}
|
||||
}
|
||||
storedData.setInteger(0, 0);
|
||||
|
||||
return storedData;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package magicbees.bees.allele.effect;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import magicbees.bees.AlleleEffect;
|
||||
import magicbees.bees.EffectData;
|
||||
import magicbees.item.ItemArmorApiarist;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
|
||||
public class AlleleEffectPotion extends AlleleEffect {
|
||||
private int potionId;
|
||||
private int duration;
|
||||
private boolean isMalicious;
|
||||
|
||||
public AlleleEffectPotion(String name, Potion potionApplied, int effectDuration, boolean isDominant) {
|
||||
super(name, isDominant, 200);
|
||||
this.potionId = potionApplied.id;
|
||||
this.duration = 20 * effectDuration;
|
||||
this.isMalicious = false;
|
||||
}
|
||||
|
||||
public AlleleEffectPotion setMalicious() {
|
||||
this.isMalicious = true;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEffectData validateStorage(IEffectData storedData) {
|
||||
if (storedData == null) {
|
||||
storedData = new EffectData(1, 0, 0);
|
||||
}
|
||||
return storedData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
List<Entity> entityList = this.getEntitiesWithinRange(genome, housing);
|
||||
|
||||
for (Entity e : entityList) {
|
||||
if (e instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) e;
|
||||
if (this.isMalicious) {
|
||||
int armorPieces = ItemArmorApiarist.getNumberPiecesWorn(player);
|
||||
int finalDuration = this.duration / 4 * (4 - armorPieces);
|
||||
if (finalDuration > 0) {
|
||||
player.addPotionEffect(new PotionEffect(this.potionId, finalDuration, 0));
|
||||
}
|
||||
} else {
|
||||
player.addPotionEffect(new PotionEffect(this.potionId, this.duration, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
storedData.setInteger(0, 0);
|
||||
|
||||
return storedData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
package magicbees.bees.allele.effect;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import magicbees.bees.AlleleEffect;
|
||||
import magicbees.bees.EffectData;
|
||||
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.world.World;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
|
||||
public class AlleleEffectSpawnMob extends AlleleEffect {
|
||||
protected boolean aggosOnPlayer;
|
||||
protected boolean spawnsWhilePlayerNear;
|
||||
protected String alternateMob;
|
||||
protected String mobName;
|
||||
protected String mobSound;
|
||||
protected int chanceToSpawn;
|
||||
protected int maxMobsInArea;
|
||||
|
||||
public AlleleEffectSpawnMob(String id, boolean isDominant, String mobToSpawn) {
|
||||
this(id, isDominant, mobToSpawn, null);
|
||||
}
|
||||
|
||||
public AlleleEffectSpawnMob(String id, boolean isDominant, String mobToSpawn, String mobSoundFx) {
|
||||
super(id, isDominant, 200);
|
||||
this.aggosOnPlayer = false;
|
||||
this.mobName = mobToSpawn;
|
||||
this.chanceToSpawn = 100;
|
||||
this.maxMobsInArea = 6;
|
||||
this.mobSound = mobSoundFx;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEffectData validateStorage(IEffectData storedData) {
|
||||
if (storedData == null || !(storedData instanceof magicbees.bees.EffectData)) {
|
||||
// Throttle; Ready to spawn
|
||||
storedData = new EffectData(1, 1, 0);
|
||||
}
|
||||
return storedData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
// Check if we're ready to spawn the mob.
|
||||
if (storedData.getBoolean(0)) {
|
||||
World w = housing.getWorld();
|
||||
|
||||
int roll = w.rand.nextInt(100);
|
||||
|
||||
if (roll <= this.chanceToSpawn) {
|
||||
if (this.spawnsWhilePlayerNear) {
|
||||
List<Entity> entities = this.getEntitiesWithinRange(genome, housing);
|
||||
EntityPlayer target = null;
|
||||
for (Entity e : entities) {
|
||||
if (e instanceof EntityPlayer) {
|
||||
target = (EntityPlayer) e;
|
||||
// Check for wearing armor & cancel
|
||||
if (ItemArmorApiarist.getNumberPiecesWorn(target) >= 4) {
|
||||
// Full armor suit is treated as "invisible."
|
||||
target = null;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Let's spawn a mob. =D
|
||||
if (target != null) {
|
||||
storedData.setBoolean(0, !this.spawnMob(genome, target, w, housing, false));
|
||||
} else if (this.alternateMob != null) {
|
||||
storedData.setBoolean(0, !this.spawnMob(genome, null, w, housing, true));
|
||||
}
|
||||
} else {
|
||||
storedData.setBoolean(0, !this.spawnMob(genome, null, w, housing, true));
|
||||
}
|
||||
} else {
|
||||
if (this.mobSound != null && w.rand.nextInt(100) < 35) {
|
||||
int range = genome.getTerritory()[0];
|
||||
double x = housing.getXCoord() + w.rand.nextDouble() * (range * 2) - range;
|
||||
range = genome.getTerritory()[1];
|
||||
double y = housing.getYCoord() + w.rand.nextDouble() * (range * 2) - range;
|
||||
range = genome.getTerritory()[2];
|
||||
double z = housing.getZCoord() + 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);
|
||||
}
|
||||
storedData.setBoolean(0, true);
|
||||
}
|
||||
}
|
||||
|
||||
return storedData;
|
||||
}
|
||||
|
||||
protected boolean spawnMob(IBeeGenome bee, EntityPlayer player, World world, IBeeHousing housing, boolean spawnAlternate) {
|
||||
boolean spawnedFlag = false;
|
||||
|
||||
EntityLiving mob;
|
||||
if (spawnAlternate && this.alternateMob != null) {
|
||||
mob = (EntityLiving) EntityList.createEntityByName(this.alternateMob, world);
|
||||
} else {
|
||||
mob = (EntityLiving) EntityList.createEntityByName(this.mobName, world);
|
||||
}
|
||||
|
||||
if (mob != null) {
|
||||
double pos[] = this.randomMobSpawnCoords(world, bee, housing);
|
||||
|
||||
int entitiesCount = world.getEntitiesWithinAABB(
|
||||
mob.getClass(),
|
||||
AxisAlignedBB.getBoundingBox((int) pos[0], (int) pos[1], (int) pos[2], (int) pos[0] + 1, (int) pos[1] + 1, (int) pos[2] + 1).expand(8.0D,
|
||||
4.0D, 8.0D)).size();
|
||||
|
||||
mob.setPositionAndRotation(pos[0], pos[1], pos[2], world.rand.nextFloat() * 360f, 0f);
|
||||
|
||||
if (entitiesCount < this.maxMobsInArea && mob.getCanSpawnHere()) {
|
||||
spawnedFlag = world.spawnEntityInWorld(mob);
|
||||
if (this.aggosOnPlayer && player != null) {
|
||||
if (ItemArmorApiarist.getNumberPiecesWorn(player) < 4) {
|
||||
// Protect fully suited player from initial murder
|
||||
// intent.
|
||||
mob.setAttackTarget(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return spawnedFlag;
|
||||
}
|
||||
|
||||
public AlleleEffectSpawnMob setSpawnsOnPlayerNear(String alternateMobToSpawn) {
|
||||
this.spawnsWhilePlayerNear = true;
|
||||
this.alternateMob = alternateMobToSpawn;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public AlleleEffectSpawnMob setAggrosPlayerOnSpawn() {
|
||||
this.aggosOnPlayer = true;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public AlleleEffectSpawnMob setThrottle(int val) {
|
||||
this.throttle = val;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public AlleleEffectSpawnMob setChanceToSpawn(int value) {
|
||||
this.chanceToSpawn = value;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public AlleleEffectSpawnMob setMaxMobsInSpawnZone(int value) {
|
||||
this.maxMobsInArea = value;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
protected double[] randomMobSpawnCoords(World world, IBeeGenome bee, IBeeHousing 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);
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package magicbees.bees.allele.effect;
|
||||
|
||||
import magicbees.bees.AlleleEffect;
|
||||
import magicbees.bees.EffectData;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.world.World;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
|
||||
public class AlleleEffectSpawnMobWeighted extends AlleleEffect {
|
||||
private String[] entityNames;
|
||||
private int[] spawnChance;
|
||||
|
||||
public AlleleEffectSpawnMobWeighted(String id, boolean isDominant, int throttle, String[] mobs, int[] chance) {
|
||||
super(id, isDominant, throttle);
|
||||
if (mobs.length != chance.length) {
|
||||
throw new IllegalArgumentException("Array lengths must be equal!");
|
||||
}
|
||||
this.entityNames = mobs;
|
||||
this.spawnChance = chance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEffectData validateStorage(IEffectData storedData) {
|
||||
if (storedData == null || !(storedData instanceof magicbees.bees.EffectData)) {
|
||||
storedData = new EffectData(1, 0, 0);
|
||||
}
|
||||
return storedData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
if (this.spawnMob(genome, housing)) {
|
||||
storedData.setInteger(0, 0);
|
||||
}
|
||||
|
||||
return storedData;
|
||||
}
|
||||
|
||||
protected boolean spawnMob(IBeeGenome genome, IBeeHousing housing) {
|
||||
boolean flag = false;
|
||||
|
||||
World w = housing.getWorld();
|
||||
int roll = 0;
|
||||
|
||||
for (int i = 0; i < this.spawnChance.length && !flag; ++i) {
|
||||
roll = 100 - w.rand.nextInt(100) + 1;
|
||||
if (roll < this.spawnChance[i]) {
|
||||
flag = true;
|
||||
Entity mob = EntityList.createEntityByName(this.entityNames[i], w);
|
||||
double[] coords = this.randomMobSpawnCoords(w, genome, housing);
|
||||
|
||||
mob.setPositionAndRotation(coords[0], coords[1], coords[2], w.rand.nextFloat() * 360f, 0f);
|
||||
if (mob instanceof EntityLiving) {
|
||||
if (((EntityLiving) mob).getCanSpawnHere()) {
|
||||
w.spawnEntityInWorld(mob);
|
||||
}
|
||||
} else {
|
||||
w.spawnEntityInWorld(mob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
protected double[] randomMobSpawnCoords(World world, IBeeGenome bee, IBeeHousing 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;
|
||||
return pos;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package magicbees.bees.allele.effect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import magicbees.item.ItemArmorApiarist;
|
||||
import magicbees.main.utils.compat.ThaumcraftHelper;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
|
||||
public class AlleleEffectSpawnWisp extends AlleleEffectSpawnMob {
|
||||
|
||||
private byte[] wispTypes = {
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
||||
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
|
||||
21, 23, 24, 25, 26, 27, 28, 29, 30,
|
||||
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
||||
41, 42, 43, 44, 45, 46, 47
|
||||
};
|
||||
|
||||
public AlleleEffectSpawnWisp(String id, boolean isDominant, String mobToSpawn, String soundToPlay) {
|
||||
super(id, isDominant, mobToSpawn, soundToPlay);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean spawnMob(IBeeGenome bee, EntityPlayer player, World world, IBeeHousing housing, boolean spawnAlternate) {
|
||||
boolean spawnedFlag = false;
|
||||
|
||||
EntityLiving mob;
|
||||
if (spawnAlternate && this.alternateMob != null) {
|
||||
mob = (EntityLiving) EntityList.createEntityByName(this.alternateMob, world);
|
||||
} else {
|
||||
mob = (EntityLiving) EntityList.createEntityByName(this.mobName, world);
|
||||
}
|
||||
|
||||
if (mob != null) {
|
||||
double pos[] = this.randomMobSpawnCoords(world, bee, housing);
|
||||
|
||||
int entitiesCount = world.getEntitiesWithinAABB(
|
||||
mob.getClass(),
|
||||
AxisAlignedBB.getBoundingBox((int) pos[0], (int) pos[1], (int) pos[2], (int) pos[0] + 1, (int) pos[1] + 1, (int) pos[2] + 1).expand(8.0D,
|
||||
4.0D, 8.0D)).size();
|
||||
|
||||
mob.setPositionAndRotation(pos[0], pos[1], pos[2], world.rand.nextFloat() * 360f, 0f);
|
||||
|
||||
if (entitiesCount < this.maxMobsInArea && mob.getCanSpawnHere()) {
|
||||
// Try some Reflection on TC code. This could be dangerous.
|
||||
try {
|
||||
Class<?> wispEntity = Class.forName(ThaumcraftHelper.Entity.WISP.getClassName());
|
||||
Field type = wispEntity.getDeclaredField("type");
|
||||
type.setByte(mob, wispTypes[world.rand.nextInt(wispTypes.length)]);
|
||||
} catch (Exception e) { /*
|
||||
* Last time I had a request to post
|
||||
* error messages, I regretted it.
|
||||
*/
|
||||
}
|
||||
|
||||
spawnedFlag = world.spawnEntityInWorld(mob);
|
||||
if (this.aggosOnPlayer && player != null) {
|
||||
if (ItemArmorApiarist.getNumberPiecesWorn(player) < 4) {
|
||||
// Protect fully suited player from initial murder
|
||||
// intent.
|
||||
mob.setAttackTarget(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return spawnedFlag;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package magicbees.bees.allele.effect;
|
||||
|
||||
import magicbees.bees.AlleleEffect;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
|
||||
public class AlleleEffectTransmuting extends AlleleEffect {
|
||||
public AlleleEffectTransmuting(String id, boolean isDominant) {
|
||||
super(id, isDominant, 200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEffectData validateStorage(IEffectData storedData) {
|
||||
if (storedData == null || !(storedData instanceof magicbees.bees.EffectData)) {
|
||||
storedData = new magicbees.bees.EffectData(1, 0, 0);
|
||||
}
|
||||
return storedData;
|
||||
}
|
||||
|
||||
@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]);
|
||||
|
||||
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;
|
||||
|
||||
BiomeGenBase biome = world.getBiomeGenForCoords(xCoord, zCoord);
|
||||
TransmutationEffectController.instance.attemptTransmutations(world, biome,
|
||||
new ItemStack(world.getBlock(xCoord, yCoord, zCoord), 1, world.getBlockMetadata(xCoord, yCoord, zCoord)), xCoord, yCoord, zCoord);
|
||||
|
||||
storedData.setInteger(0, 0);
|
||||
|
||||
return storedData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package magicbees.bees.allele.effect;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import magicbees.api.MagicBeesAPI;
|
||||
import magicbees.api.bees.ITransmutationEffectController;
|
||||
import magicbees.api.bees.ITransmutationEffectLogic;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
public class TransmutationEffectController implements ITransmutationEffectController {
|
||||
private ArrayList<ITransmutationEffectLogic> logicObjects;
|
||||
static TransmutationEffectController instance;
|
||||
|
||||
public TransmutationEffectController() {
|
||||
logicObjects = new ArrayList<ITransmutationEffectLogic>();
|
||||
logicObjects.add(new TransmutationEffectRailcraft());
|
||||
logicObjects.add(new TransmutationEffectVanilla());
|
||||
MagicBeesAPI.transmutationEffectController = instance = this;
|
||||
}
|
||||
|
||||
public void attemptTransmutations(World world, BiomeGenBase biome, ItemStack sourceBlock, int x, int y, int z) {
|
||||
boolean done;
|
||||
ITransmutationEffectLogic logic;
|
||||
for (int i = 0; i < logicObjects.size(); i++) {
|
||||
logic = logicObjects.get(i);
|
||||
try {
|
||||
done = logic.tryTransmutation(world, biome, sourceBlock, x, y, z);
|
||||
} catch (Exception e) {
|
||||
done = false;
|
||||
FMLLog.warning("Magic Bees encountered an issue with an ITransmutationEffectLogic provider %s. Debug information follows.", logic.getClass()
|
||||
.getName());
|
||||
FMLLog.info(e.getMessage());
|
||||
}
|
||||
|
||||
if (done) {
|
||||
logicObjects.remove(i);
|
||||
logicObjects.add(logic);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEffectLogic(ITransmutationEffectLogic logic) {
|
||||
if (logic != null && !logicObjects.contains(logic)) {
|
||||
logicObjects.add(logic);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package magicbees.bees.allele.effect;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import magicbees.api.bees.ITransmutationEffectLogic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class TransmutationEffectRailcraft implements ITransmutationEffectLogic {
|
||||
@Override
|
||||
public boolean tryTransmutation(World world, BiomeGenBase biome, ItemStack sourceBlock, int x, int y, int z) {
|
||||
boolean flag = false;
|
||||
if (OreDictionary.itemMatches(new ItemStack(Blocks.stone), sourceBlock, false)
|
||||
|| OreDictionary.itemMatches(new ItemStack(Blocks.cobblestone), sourceBlock, false)) {
|
||||
flag = trySpawnQuarriedStone(world, biome, sourceBlock, x, y, z) || trySpawnAbyssalStone(world, biome, sourceBlock, x, y, z);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
private boolean trySpawnQuarriedStone(World world, BiomeGenBase biome, ItemStack sourceBlock, int x, int y, int z) {
|
||||
boolean flag = false;
|
||||
if (BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.FOREST) && !BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.SNOWY)) {
|
||||
ItemStack item = GameRegistry.findItemStack("Railcraft", "cube.stone.quarried", 1);
|
||||
if (item != null) {
|
||||
world.setBlock(x, y, z, Block.getBlockFromItem(item.getItem()), item.getItemDamage(), 2);
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
private boolean trySpawnAbyssalStone(World world, BiomeGenBase biome, ItemStack sourceBlock, int x, int y, int z) {
|
||||
boolean flag = false;
|
||||
if (BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.WATER) && !biome.biomeName.toLowerCase(Locale.ENGLISH).contains("river")) {
|
||||
ItemStack item = GameRegistry.findItemStack("Railcraft", "cube.stone.abyssal", 1);
|
||||
if (item != null) {
|
||||
world.setBlock(x, y, z, Block.getBlockFromItem(item.getItem()), item.getItemDamage(), 2);
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package magicbees.bees.allele.effect;
|
||||
|
||||
import magicbees.api.bees.ITransmutationEffectLogic;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class TransmutationEffectVanilla implements ITransmutationEffectLogic {
|
||||
@Override
|
||||
public boolean tryTransmutation(World world, BiomeGenBase biome, ItemStack sourceBlock, int x, int y, int z) {
|
||||
return trySpawnSandstone(world, biome, sourceBlock, x, y, z);
|
||||
}
|
||||
|
||||
private boolean trySpawnSandstone(World world, BiomeGenBase biome, ItemStack sourceBlock, int x, int y, int z) {
|
||||
boolean flag = false;
|
||||
if (BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.SANDY) && OreDictionary.itemMatches(new ItemStack(Blocks.sand), sourceBlock, false)) {
|
||||
world.setBlock(x, y, z, Blocks.sandstone);
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user