mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-20 20:12:19 +00:00
Fix #1504 [1.10.2] [5.2.15.296] Butterflies gravitating towards 0,0 where huge swarms are found
This commit is contained in:
1 parent
1775e59880
commit
91ec6cff9b
4 files changed
+15
-5
No files matched your search
@@ -1,6 +1,8 @@
|
||||
package forestry.lepidopterology.entities;
|
||||
|
||||
import forestry.lepidopterology.PluginLepidopterology;
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class AIButterflyGoHome extends AIButterflyMovement {
|
||||
@@ -12,12 +14,12 @@ public class AIButterflyGoHome extends AIButterflyMovement {
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute() {
|
||||
if (PluginLepidopterology.maxDistance > entity.getDistanceSqToCenter(entity.getHomePosition())) {
|
||||
if (entity.isWithinHomeDistanceCurrentPosition()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
flightTarget = new Vec3d(entity.getHomePosition());
|
||||
if (flightTarget == null) {
|
||||
if (flightTarget == null || flightTarget.equals(BlockPos.ORIGIN)) {
|
||||
if (entity.getState().doesMovement) {
|
||||
entity.setState(EnumButterflyState.HOVER);
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ import forestry.api.lepidopterology.IButterflyRoot;
|
||||
import forestry.api.lepidopterology.IEntityButterfly;
|
||||
import forestry.api.lepidopterology.ILepidopteristTracker;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.lepidopterology.PluginLepidopterology;
|
||||
import forestry.lepidopterology.genetics.Butterfly;
|
||||
|
||||
public class EntityButterfly extends EntityCreature implements IEntityButterfly {
|
||||
@@ -96,10 +97,11 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly
|
||||
setDefaults();
|
||||
}
|
||||
|
||||
public EntityButterfly(World world, IButterfly butterfly) {
|
||||
public EntityButterfly(World world, IButterfly butterfly, BlockPos homePos) {
|
||||
super(world);
|
||||
setDefaults();
|
||||
setIndividual(butterfly);
|
||||
setHomePosAndDistance(homePos, PluginLepidopterology.maxDistance);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -145,6 +147,10 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly
|
||||
|
||||
nbttagcompound.setByte("STATE", (byte) getState().ordinal());
|
||||
nbttagcompound.setInteger("EXH", exhaustion);
|
||||
|
||||
nbttagcompound.setInteger("homeX", getHomePosition().getX());
|
||||
nbttagcompound.setInteger("homeY", getHomePosition().getY());
|
||||
nbttagcompound.setInteger("homeZ", getHomePosition().getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -164,6 +170,8 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly
|
||||
EnumButterflyState state = EnumButterflyState.VALUES[nbttagcompound.getByte("STATE")];
|
||||
setState(state);
|
||||
exhaustion = nbttagcompound.getInteger("EXH");
|
||||
BlockPos home = new BlockPos(nbttagcompound.getInteger("homeX"), nbttagcompound.getInteger("homeY"), nbttagcompound.getInteger("homeZ"));
|
||||
setHomePosAndDistance(home, PluginLepidopterology.maxDistance);
|
||||
}
|
||||
|
||||
public float getWingFlap(float partialTicktime) {
|
||||
|
||||
@@ -171,7 +171,7 @@ public class ButterflyRoot extends SpeciesRoot implements IButterflyRoot {
|
||||
|
||||
@Override
|
||||
public EntityButterfly spawnButterflyInWorld(World world, IButterfly butterfly, double x, double y, double z) {
|
||||
return EntityUtil.spawnEntity(world, new EntityButterfly(world, butterfly), x, y, z);
|
||||
return EntityUtil.spawnEntity(world, new EntityButterfly(world, butterfly, new BlockPos(x, y, z)), x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -143,7 +143,7 @@ public class ItemButterflyGE extends ItemGE implements ISpriteRegister, IColored
|
||||
return false;
|
||||
}
|
||||
|
||||
if (EntityUtil.spawnEntity(entityItem.worldObj, new EntityButterfly(entityItem.worldObj, butterfly), entityItem.posX, entityItem.posY, entityItem.posZ) != null) {
|
||||
if (EntityUtil.spawnEntity(entityItem.worldObj, new EntityButterfly(entityItem.worldObj, butterfly, entityItem.getPosition()), entityItem.posX, entityItem.posY, entityItem.posZ) != null) {
|
||||
if (entityItem.getEntityItem().stackSize > 1) {
|
||||
entityItem.getEntityItem().stackSize--;
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user