use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class JubilanceDefault method getBounding.
protected AxisAlignedBB getBounding(IBeeGenome genome, IBeeHousing housing, float modifier) {
int[] areaAr = genome.getTerritory();
Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(modifier);
Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2));
Vect min = new Vect(housing.getXCoord() + offset.x, housing.getYCoord() + offset.y, housing.getZCoord() + offset.z);
Vect max = new Vect(housing.getXCoord() + offset.x + area.x, housing.getYCoord() + offset.y + area.y, housing.getZCoord() + offset.z + area.z);
return AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
}
use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class MutationEMC method getChance.
@Override
public float getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
float chance = super.getChance(housing, allele0, allele1, genome0, genome1);
// If we don't have any chance, return at once.
if (chance <= 0) {
return 0;
}
if (emcRequired <= 0) {
return chance;
}
World world = housing.getWorld();
Vect[] possibleTargets = new Vect[] { new Vect(housing.getXCoord() + 1, housing.getYCoord(), housing.getZCoord()), new Vect(housing.getXCoord() - 1, housing.getYCoord(), housing.getZCoord()), new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord() + 1), new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord() - 1) };
for (Vect target : possibleTargets) {
if (!world.blockExists(target.x, target.y, target.z)) {
continue;
}
TileEntity entity = world.getTileEntity(target.x, target.y, target.z);
if (entity == null) {
continue;
}
if (!condenserClass.isInstance(entity)) {
Proxies.log.warning("Did not find a relay at " + target.toString());
continue;
}
int emc = 0;
try {
emc = emcField.getInt(entity);
} catch (Exception ex) {
Proxies.log.warning("Failed to fetch EMC information.");
}
if (emc < emcRequired * 80) {
continue;
}
boolean removedEMC = false;
try {
emcField.set(entity, emc - (emcRequired * 80));
removedEMC = true;
} catch (Exception ex) {
Proxies.log.warning("Failed to set EMC information.");
}
if (removedEMC) {
return chance;
}
}
return 0;
}
use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class AlleleEffectRadioactive method doEffect.
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
World world = housing.getWorld();
if (isHalted(storedData, housing)) {
return storedData;
}
int[] areaAr = genome.getTerritory();
Vect area = new Vect(areaAr[0] * 2, areaAr[1] * 2, areaAr[2] * 2);
Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2));
// Radioactivity hurts players and mobs
Vect min = new Vect(housing.getXCoord() + offset.x, housing.getYCoord() + offset.y, housing.getZCoord() + offset.z);
Vect max = new Vect(housing.getXCoord() + offset.x + area.x, housing.getYCoord() + offset.y + area.y, housing.getZCoord() + offset.z + area.z);
AxisAlignedBB hurtBox = AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
@SuppressWarnings("rawtypes") List list = housing.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, hurtBox);
for (Object obj : list) {
EntityLivingBase entity = (EntityLivingBase) obj;
int damage = 8;
// armor.
if (entity instanceof EntityPlayer) {
int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true);
// Full set, no damage/effect
if (count > 3) {
continue;
} else if (count > 2) {
damage = 1;
} else if (count > 1) {
damage = 2;
} else if (count > 0) {
damage = 3;
}
}
entity.attackEntityFrom(damageSourceBeeRadioactive, damage);
}
Random rand = housing.getWorld().rand;
// Radioactivity destroys environment
for (int i = 0; i < 20; i++) {
Vect randomPos = new Vect(rand.nextInt(area.x), rand.nextInt(area.y), rand.nextInt(area.z));
Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()));
posBlock = posBlock.add(offset);
if (posBlock.y <= 1 || posBlock.y >= housing.getWorld().getActualHeight()) {
continue;
}
// Don't destroy ourself and blocks below us.
if (posBlock.x == housing.getXCoord() && posBlock.z == housing.getZCoord() && posBlock.y <= housing.getYCoord()) {
continue;
}
if (world.isAirBlock(posBlock.x, posBlock.y, posBlock.z)) {
continue;
}
Block block = world.getBlock(posBlock.x, posBlock.y, posBlock.z);
if (block instanceof BlockAlveary) {
continue;
}
TileEntity tile = world.getTileEntity(posBlock.x, posBlock.y, posBlock.z);
if (tile instanceof IBeeHousing) {
continue;
}
if (tile instanceof TileAlveary) {
continue;
}
if (block.getBlockHardness(world, posBlock.x, posBlock.y, posBlock.z) < 0) {
continue;
}
world.setBlockToAir(posBlock.x, posBlock.y, posBlock.z);
break;
}
return storedData;
}
use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class AlleleEffectThrottled method getBounding.
protected AxisAlignedBB getBounding(IBeeGenome genome, IBeeHousing housing, float modifier) {
int[] areaAr = genome.getTerritory();
Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(modifier);
Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2));
// Radioactivity hurts players and mobs
Vect min = new Vect(housing.getXCoord() + offset.x, housing.getYCoord() + offset.y, housing.getZCoord() + offset.z);
Vect max = new Vect(housing.getXCoord() + offset.x + area.x, housing.getYCoord() + offset.y + area.y, housing.getZCoord() + offset.z + area.z);
return AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
}
use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.
the class ItemHabitatLocator method onUpdate.
@Override
public void onUpdate(ItemStack p_77663_1_, World world, Entity player, int p_77663_4_, boolean p_77663_5_) {
if (!Proxies.common.isSimulating(world)) {
return;
}
if (this.searchCenter == null) {
this.searchCenter = new Vect((int) player.posX, (int) player.posY, (int) player.posZ);
BiomeGenBase currentBiome = world.getBiomeGenForCoords(searchCenter.x, searchCenter.z);
removeInvalidBiomes(currentBiome, biomesToSearch);
}
if (biomesToSearch.isEmpty()) {
return;
}
// once we've found the biome, slow down to conserve cpu and network data
if (biomeFound && world.getTotalWorldTime() % 20 != 0) {
return;
}
ChunkCoordinates target = findNearestBiome(player, biomesToSearch);
// send an update if we find the biome
if (target != null) {
Proxies.common.setHabitatLocatorCoordinates(player, target);
biomeFound = true;
}
}
Aggregations