Fix #1071 Butterflies spread out of control

This commit is contained in:
Nedelosk committed 2016-10-18 15:42:12 +02:00
1 parent 2b40762934
commit 3f07e68952
5 files changed
+36 -2

No files matched your search

@@ -79,6 +79,7 @@ public class PluginLepidopterology extends BlankForestryPlugin {
private static final String CONFIG_CATEGORY = "lepidopterology";
public static int spawnConstraint = 100;
public static int entityConstraint = 1000;
public static int maxDistance = 1600;
private static boolean allowPollination = true;
public static final Map<String, Float> spawnRaritys = Maps.newHashMap();
private static boolean spawnButterflysFromLeaves = true;
@@ -172,6 +173,7 @@ public class PluginLepidopterology extends BlankForestryPlugin {
spawnConstraint = config.getIntLocalized("butterfly.entities", "spawn.limit", spawnConstraint, 0, 500);
entityConstraint = config.getIntLocalized("butterfly.entities", "maximum", entityConstraint, 0, 5000);
maxDistance = config.getIntLocalized("butterfly.entities", "maxDistance", maxDistance, 0, 1600);
allowPollination = config.getBooleanLocalized("butterfly.entities", "pollination", allowPollination);
spawnButterflysFromLeaves = config.getBooleanLocalized("butterfly.entities", "spawn.leaves", spawnButterflysFromLeaves);
@@ -0,0 +1,32 @@
package forestry.lepidopterology.entities;
import forestry.lepidopterology.PluginLepidopterology;
import net.minecraft.util.math.Vec3d;
public class AIButterflyGoHome extends AIButterflyMovement {
public AIButterflyGoHome(EntityButterfly entity) {
super(entity);
setMutexBits(1);
}
@Override
public boolean shouldExecute() {
if (PluginLepidopterology.maxDistance > entity.getDistanceSqToCenter(entity.getHomePosition())) {
return false;
}
flightTarget = new Vec3d(entity.getHomePosition());
if (flightTarget == null) {
if (entity.getState().doesMovement) {
entity.setState(EnumButterflyState.HOVER);
}
return false;
}
entity.setDestination(flightTarget);
entity.setState(EnumButterflyState.FLYING);
return true;
}
}
@@ -19,7 +19,6 @@ public class AIButterflyWander extends AIButterflyMovement {
@Override
public boolean shouldExecute() {
if (entity.getDestination() != null) {
return false;
}
@@ -119,6 +119,7 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly
tasks.addTask(11, new AIButterflyRest(this));
tasks.addTask(12, new AIButterflyRise(this));
tasks.addTask(12, new AIButterflyWander(this));
tasks.addTask(13, new AIButterflyGoHome(this));
}
@Override