Guest User

CustomSitGoal

a guest
Jan 12th, 2021
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. package com.example.examplemod.custom;
  2.  
  3. import com.example.examplemod.entity.TestEntity;
  4. import net.minecraft.entity.ai.goal.Goal;
  5. import java.util.EnumSet;
  6.  
  7. public class CustomSitGoal extends Goal {
  8.  
  9. private final TestEntity tameable;
  10.  
  11. public CustomSitGoal(TestEntity entityIn) {
  12. this.tameable = entityIn;
  13. this.setMutexFlags(EnumSet.of(Goal.Flag.JUMP, Goal.Flag.MOVE));
  14. }
  15.  
  16. /**
  17. * Returns whether an in-progress EntityAIBase should continue executing
  18. */
  19. public boolean shouldContinueExecuting() {
  20. return this.tameable.flag;
  21. }
  22.  
  23. /**
  24. * Returns whether execution should begin. You can also read and cache any state necessary for execution in this
  25. * method as well.
  26. */
  27. public boolean shouldExecute() {
  28. return this.tameable.flag;
  29. }
  30.  
  31. /**
  32. * Execute a one shot task or start executing a continuous task
  33. */
  34. public void startExecuting() {
  35. System.out.println("Executed");
  36. this.tameable.getNavigator().clearPath();
  37. this.tameable.setSleeping(true);
  38. }
  39.  
  40. /**
  41. * Reset the task's internal state. Called when this task is interrupted by another one
  42. */
  43. public void resetTask() {
  44. this.tameable.setSleeping(false);
  45. }
  46. }
  47.  
  48.  
Advertisement
Add Comment
Please, Sign In to add comment