-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added bird ai to hang around birdhouse if active (#9)
* added bird ai to hang around birdhouse if active * fixed styling errors * fixed small bug. Removed extraneous functions * rebased from main, restructured goal logic to fit new ticking structure * Styling changes, removed dead code in hangoutaroundbirdhousegoal class. Refactored goal class. Added comments * added bird ai to hang around birdhouse if active * fixed styling errors * fixed small bug. Removed extraneous functions
- Loading branch information
1 parent
ba69a83
commit 34913ab
Showing
2 changed files
with
125 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/com/ocelotslovebirds/birdhaus/mobai/HangAroundBirdhouseGoal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.ocelotslovebirds.birdhaus.mobai; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.entity.PathfinderMob; | ||
import net.minecraft.world.entity.ai.goal.RandomStrollGoal; | ||
import net.minecraft.world.phys.Vec3; | ||
|
||
|
||
public class HangAroundBirdhouseGoal extends RandomStrollGoal { | ||
|
||
private Vec3 bHousePosVec; | ||
|
||
/** | ||
* Constructor for the parrot goal. Makes parrots stay | ||
* around a birdhouse when it has seeds in its internal inventory. | ||
* @param pMob the mob getting this goal | ||
* @param pSpeedModifier modifies mob move speed | ||
* @param pInterval interval to check if the goal should be sought | ||
* @param pCheckNoActionTime boolean to check to see if the mob has not been performing an action | ||
* @param bHousePos position of the birdhouse passing the goal to the mob | ||
*/ | ||
public HangAroundBirdhouseGoal(PathfinderMob pMob, double pSpeedModifier, | ||
int pInterval, boolean pCheckNoActionTime, BlockPos bHousePos) { | ||
super(pMob, pSpeedModifier, pInterval, pCheckNoActionTime); | ||
this.bHousePosVec = new Vec3(bHousePos.getX(), bHousePos.getY(), bHousePos.getZ()); | ||
} | ||
|
||
/** | ||
* Returns the position for the parrot to move to. This will be the position of the birdhouse that gave it the goal. | ||
* If for some reason, the bird is left with this goal with no birdhouse in sight, it will default to behaving like | ||
* "RandomWanderGoal". | ||
*/ | ||
@Override | ||
protected Vec3 getPosition() { | ||
if (this.bHousePosVec != null) { | ||
return this.bHousePosVec; | ||
} else { | ||
return super.getPosition(); | ||
} | ||
} | ||
} |