mirror of
https://github.com/GTNewHorizons/MagicBees.git
synced 2026-11-19 11:59:19 +00:00
Adding node effect bees.
This commit is contained in:
1 parent
4c93eb6bf4
commit
354f2ef71b
12 files changed
+414
-92
No files matched your search
@@ -0,0 +1,44 @@
|
||||
package magicbees.bees.allele.effect;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import magicbees.bees.AlleleEffect;
|
||||
import magicbees.main.utils.BlockUtil;
|
||||
import magicbees.main.utils.compat.thaumcraft.NodeHelper;
|
||||
|
||||
public class AlleleEffectNodeRepair extends AlleleEffect {
|
||||
|
||||
public AlleleEffectNodeRepair(String id, boolean isDominant) {
|
||||
super(id, isDominant, 2);
|
||||
}
|
||||
|
||||
@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();
|
||||
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);
|
||||
|
||||
if (NodeHelper.repairNodeInRange(chunks, world, xCoord, yCoord, zCoord, range)) {
|
||||
storedData.setInteger(0, storedData.getInteger(0) - throttle);
|
||||
}
|
||||
|
||||
return storedData;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user