mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-26 14:53:05 +00:00
52 lines
1.8 KiB
Java
Executable File
52 lines
1.8 KiB
Java
Executable File
/*******************************************************************************
|
|
* Copyright (c) 2011-2014 SirSengir.
|
|
* All rights reserved. This program and the accompanying materials
|
|
* are made available under the terms of the GNU Lesser Public License v3
|
|
* which accompanies this distribution, and is available at
|
|
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
|
*
|
|
* Various Contributors including, but not limited to:
|
|
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
|
******************************************************************************/
|
|
package forestry.apiculture.genetics;
|
|
|
|
import java.util.List;
|
|
|
|
import net.minecraft.entity.EntityLiving;
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
import net.minecraft.util.ChunkCoordinates;
|
|
|
|
import forestry.api.apiculture.IAlleleBeeSpecies;
|
|
import forestry.api.apiculture.IBeeGenome;
|
|
import forestry.api.apiculture.IBeeHousing;
|
|
import forestry.core.vect.Vect;
|
|
|
|
/**
|
|
* Hermits will not produce if there are any other living creatures nearby.
|
|
*/
|
|
public class JubilanceProviderHermit extends JubilanceDefault {
|
|
|
|
@Override
|
|
public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) {
|
|
AxisAlignedBB bounding = getBounding(genome, housing, 1.0f);
|
|
|
|
@SuppressWarnings("rawtypes")
|
|
List list = housing.getWorld().getEntitiesWithinAABB(EntityLiving.class, bounding);
|
|
return list.size() <= 0;
|
|
}
|
|
|
|
private static AxisAlignedBB getBounding(IBeeGenome genome, IBeeHousing housing, float modifier) {
|
|
int[] areaAr = genome.getTerritory();
|
|
Vect area = new Vect(areaAr).multiply(modifier);
|
|
Vect offset = area.multiply(-1 / 2.0f);
|
|
|
|
ChunkCoordinates housingCoordinates = housing.getCoordinates();
|
|
|
|
Vect min = new Vect(housingCoordinates).add(offset);
|
|
Vect max = min.add(area);
|
|
|
|
return AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
|
|
}
|
|
|
|
}
|