Skip to content

Commit

Permalink
More bee progress. Still very broken. They also slide backwards for s…
Browse files Browse the repository at this point in the history
…ome reason
  • Loading branch information
Roadhog360 committed Aug 18, 2023
1 parent 429bdb3 commit a616c39
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 29 deletions.
31 changes: 12 additions & 19 deletions src/main/java/ganymedes01/etfuturum/entities/EntityBee.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.pathfinding.PathNavigate;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntity;
Expand All @@ -33,7 +32,7 @@
import java.util.*;
import java.util.function.Predicate;

public class EntityBee extends EntityAnimal implements IFlyingEntity {
public class EntityBee extends EntityAnimal implements INoGravityEntity {
private static final int DATA_FLAGS_ID = 13; //byte
private static final int ANGER_TIME = 14; //int
private UUID lastHurtBy;
Expand All @@ -52,7 +51,6 @@ public class EntityBee extends EntityAnimal implements IFlyingEntity {
private EntityBee.FindFlowerGoal findFlowerGoal;
private int underWaterTicks;

private final FlyingPathNavigator flyNavigator;
private int beeSoundTime = 0;

private boolean hasNoGravity;
Expand All @@ -62,7 +60,7 @@ public EntityBee(World worldIn) {
// this.lookController = new EntityBee.BeeLookController(this);
setSize(0.7F, 0.7F);

flyNavigator = new FlyingPathNavigator(this, worldIn) {
navigator = new FlyingPathNavigator(this, worldIn) {
@Override
public boolean isSafeToStandAt(int p_75483_1_, int p_75483_2_, int p_75483_3_, int p_75483_4_, int p_75483_5_, int p_75483_6_, Vec3 p_75483_7_, double p_75483_8_, double p_75483_10_) {
int k1 = p_75483_1_ - p_75483_4_ / 2;
Expand Down Expand Up @@ -94,9 +92,9 @@ public void onUpdateNavigation() {
};
moveHelper = new FlyMoveHelper(this);
registerGoals();
flyNavigator.setBreakDoors(false);
flyNavigator.setEnterDoors(true);
flyNavigator.setCanSwim(false);
getNavigator().setBreakDoors(false);
getNavigator().setEnterDoors(true);
getNavigator().setCanSwim(false);
}

protected void entityInit() {
Expand All @@ -116,11 +114,6 @@ private float getPathWeight(Block block) {
return 0.0F;
}

@Override
public PathNavigate getNavigator() {
return flyNavigator;
}

protected boolean isAIEnabled() {
return true;
}
Expand Down Expand Up @@ -417,6 +410,7 @@ public void setRevengeTarget(EntityLivingBase livingBase) {
}

protected void updateAITasks() {
super.updateAITasks();
if (this.isInWater()) {
++this.underWaterTicks;
} else {
Expand Down Expand Up @@ -446,7 +440,6 @@ protected void updateAITasks() {
if (!this.hasNectar()) {
++this.ticksWithoutNectarSinceExitingHive;
}
super.updateAITasks();
}

public void resetTicksWithoutNectar() {
Expand Down Expand Up @@ -801,7 +794,7 @@ private List<BlockPos> getBlocksInRange(Predicate<BlockPos> predicate, int range
for (int x1 = -range; x1 <= range; x1++) {
for (int y1 = -range; y1 <= range; y1++) {
for (int z1 = -range; z1 <= range; z1++) {
BlockPos pos = new BlockPos(x1, y1, z1);
BlockPos pos = beePos.add(x1, y1, z1);
if (predicate.test(pos)) {
posList.add(pos);
}
Expand Down Expand Up @@ -1015,7 +1008,7 @@ public boolean canBeeContinue() {
return this.canBeeStart();
}

public void updateTask() {
// public void updateTask() {
// if (EntityBee.this.rand.nextInt(30) == 0) {
// for(int i = 1; i <= 2; ++i) {
// BlockPos blockpos = (new BlockPos(EntityBee.this)).down(i);
Expand Down Expand Up @@ -1051,7 +1044,7 @@ public void updateTask() {
// }
// }
// }
}
// }
}

abstract class PassiveGoal extends EntityAIBase {
Expand Down Expand Up @@ -1178,8 +1171,6 @@ public void updateTask() {
} else {
flag1 = false;
}

// EntityBee.this.getLookController().setLookPosition(vec3d.getX(), vec3d.getY(), vec3d.getZ());
}

if (flag1) {
Expand Down Expand Up @@ -1272,7 +1263,9 @@ public boolean continueExecuting() {

public void startExecuting() {
Vec3 vec3d = this.getRandomLocation();
EntityBee.this.getNavigator().setPath(EntityBee.this.getNavigator().getPathToXYZ(vec3d.xCoord, vec3d.yCoord, vec3d.zCoord), 1.0D);
if (vec3d != null) {
EntityBee.this.getNavigator().setPath(EntityBee.this.getNavigator().getPathToXYZ(vec3d.xCoord, vec3d.yCoord, vec3d.zCoord), 1.0D);
}

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ganymedes01.etfuturum.entities;

public interface IFlyingEntity {
public interface INoGravityEntity {
void setNoGravity(boolean gravity);

boolean hasNoGravity();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
package ganymedes01.etfuturum.entities.ai;

import ganymedes01.etfuturum.core.utils.Utils;
import ganymedes01.etfuturum.entities.IFlyingEntity;
import ganymedes01.etfuturum.entities.INoGravityEntity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.util.MathHelper;

public class FlyMoveHelper extends ExtendedEntityMoveHelper {
/**
* Note: Since setNoGravity does not exist in 1.7.10 you must implement IFlyingEntity so this class can toggle gravity on the entity when it needs to.
* Note: Since setNoGravity does not exist in 1.7.10 you must implement INoGravityEntity so this class can toggle gravity on the entity when it needs to.
*/
public FlyMoveHelper(EntityLiving p_i47418_1_) {
super(p_i47418_1_);
if (!(p_i47418_1_ instanceof IFlyingEntity)) {
throw new IllegalArgumentException("Entity using " + getClass().getName() + " MUST implement " + IFlyingEntity.class.getName() + "! Got " + p_i47418_1_ + " instead...");
if (!(p_i47418_1_ instanceof INoGravityEntity)) {
throw new IllegalArgumentException("Entity using " + getClass().getName() + " MUST implement " + INoGravityEntity.class.getName() + "! Got " + p_i47418_1_ + " instead...");
}
}

public void onUpdateMoveHelper() {
if (action == ExtendedEntityMoveHelper.Action.MOVE_TO) {
action = ExtendedEntityMoveHelper.Action.WAIT;
((IFlyingEntity) entity).setNoGravity(true);
((INoGravityEntity) entity).setNoGravity(true);
double d0 = posX - entity.posX;
double d1 = posY - entity.posY;
double d2 = posZ - entity.posZ;
Expand Down Expand Up @@ -49,7 +49,7 @@ public void onUpdateMoveHelper() {
entity.rotationPitch = limitAngle(entity.rotationPitch, f2, 10.0F);
entity.setMoveForward(d1 > 0.0D ? f1 : -f1);
} else {
((IFlyingEntity) entity).setNoGravity(false);
((INoGravityEntity) entity).setNoGravity(false);
entity.setMoveForward(0.0F);
entity.moveStrafing = 0.0F;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ public FlyingPathNavigator(EntityLiving p_i1671_1_, World p_i1671_2_) {
public void updatePath() {
if (this.worldObj.getTotalWorldTime() - this.lastTimeUpdated > 20L) {
if (this.getPath() != null) {
this.currentPath = null;
this.currentPath = this.getPathToXYZ(getPath().getFinalPathPoint().xCoord, getPath().getFinalPathPoint().yCoord, getPath().getFinalPathPoint().zCoord);
int x = getPath().getFinalPathPoint().xCoord;
int y = getPath().getFinalPathPoint().yCoord;
int z = getPath().getFinalPathPoint().zCoord;
this.currentPath = this.getPathToXYZ(x, y, z);
this.lastTimeUpdated = this.worldObj.getTotalWorldTime();
this.tryUpdatePath = false;
}
Expand All @@ -43,7 +45,7 @@ protected Vec3 getEntityPosition() {
public void onUpdateNavigation() {
++this.totalTicks;

if (!this.noPath()) {
if (tryUpdatePath) {
this.updatePath();
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/META-INF/etfuturum_at.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ protected net.minecraft.block.BlockStairs field_150149_b
public net.minecraft.entity.EntityLiving field_82179_bU #persistenceRequired
public net.minecraft.entity.EntityLiving field_70767_i #jumpHelper
public net.minecraft.entity.EntityLiving field_70765_h #moveHelper
protected net.minecraft.entity.EntityLiving field_70699_by #navigator

public net.minecraft.entity.projectile.EntityArrow field_70254_i #inGround
public net.minecraft.entity.projectile.EntityArrow field_70252_j #ticksInGround
Expand Down

0 comments on commit a616c39

Please sign in to comment.