Advertisement
Guest User

Untitled

a guest
May 25th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. package com.sonniccub.racismmod.entity.ai;
  2. import com.sonniccub.racismmod.init.ModEntityTypes;
  3. import java.util.Random;
  4. import com.sonniccub.racismmod.client.entity.render.MissileRender;
  5. import com.sonniccub.racismmod.racismmod;
  6. import com.sonniccub.racismmod.entities.Missile;
  7. import net.minecraft.entity.CreatureEntity;
  8. import net.minecraft.entity.Entity;
  9. import net.minecraft.entity.EntityType;
  10. import net.minecraft.entity.LivingEntity;
  11. import net.minecraft.entity.ai.goal.Goal;
  12. import net.minecraft.entity.monster.MonsterEntity;
  13. import net.minecraft.entity.player.PlayerEntity;
  14. import net.minecraft.world.World;
  15. import net.minecraftforge.fml.RegistryObject;
  16.  
  17. public class BossBamaSummonGoal<T extends LivingEntity> extends Goal {
  18. protected final CreatureEntity attacker;
  19. private World world;
  20. public BossBamaSummonGoal(CreatureEntity creature, World worldIn) {
  21. this.attacker = creature;
  22.  
  23. }
  24.  
  25. @Override
  26. public boolean shouldExecute() {
  27. LivingEntity livingentity = this.attacker.getAttackTarget();
  28. if (livingentity == null) {
  29. return false;
  30. } else if (!livingentity.isAlive()) {
  31. return false;
  32. }
  33. else {
  34. return true;
  35. }
  36. }
  37. public boolean shouldContinueExecuting() {
  38. LivingEntity livingentity = this.attacker.getAttackTarget();
  39. if (livingentity == null) {
  40. return false;
  41. } else {
  42. return !(livingentity instanceof PlayerEntity) || !livingentity.isSpectator() && !((PlayerEntity)livingentity).isCreative();
  43. }
  44. }
  45. Random rd = new Random();
  46. public void startExecuting() {
  47. LivingEntity livingentity = this.attacker.getAttackTarget();
  48. this.attacker.setAggroed(true);
  49. for(int i = 0; i < rd.nextInt(10)+5; i++) {
  50. int rdZ = (int) ((livingentity.getPosZ())+rd.nextInt(7));
  51. int rdX = (int) ((livingentity.getPosX())+rd.nextInt(7));
  52. boolean negposX = rd.nextBoolean();
  53. boolean negposZ = rd.nextBoolean();
  54. if (negposX == true) {
  55. rdX = rdX-rdX*2;
  56. }
  57. if (negposZ == true) {
  58. rdZ = rdZ-rdZ*2;
  59. }
  60. spawnMissile(rdX, livingentity.getPosY()+7, rdZ);
  61.  
  62.  
  63.  
  64. }
  65. }
  66. public void spawnMissile(double x, double y, double z) {
  67. Missile m1 = new Missile(ModEntityTypes.MISSILE_ENTITY.get(), world);
  68. world.addEntity(m1);
  69. m1.setPosition(x, y, z);
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement