Advertisement
Guest User

entityturret

a guest
Feb 25th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.50 KB | None | 0 0
  1. package me.creepinson.meepar.entity;
  2.  
  3. import net.minecraft.entity.EntityCreature;
  4. import net.minecraft.entity.EntityLivingBase;
  5. import net.minecraft.entity.IRangedAttackMob;
  6. import net.minecraft.entity.ai.EntityAIAttackRanged;
  7. import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
  8. import net.minecraft.entity.monster.EntityZombie;
  9. import net.minecraft.util.math.AxisAlignedBB;
  10. import net.minecraft.util.math.Vec3d;
  11. import net.minecraft.world.World;
  12.  
  13. import java.util.ArrayList;
  14. import java.util.List;
  15. import java.util.UUID;
  16.  
  17. /**
  18.  * Created by theo on 7/28/17.
  19.  */
  20. public class EntityTurret extends EntityCreature implements IRangedAttackMob {
  21.     private int tier;
  22.     private static final AxisAlignedBB ENTITY_BOUNDING_BOX = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.5D, 3.5D, 1.5D);
  23.     public int getTier() {
  24.         return tier;
  25.     }
  26.  
  27.     public int attackMode;
  28.     public int range;
  29.     public List<UUID> owners = new ArrayList<UUID>();
  30.  
  31.  
  32.     @Override
  33.     public AxisAlignedBB getEntityBoundingBox() {
  34.         return ENTITY_BOUNDING_BOX;
  35.     }
  36.  
  37.     public EntityTurret(World worldIn, UUID startingOwner, int range, int tier) {
  38.         super(worldIn);
  39.         this.owners.add(startingOwner);
  40.         this.range = range;
  41.         this.tier = tier;
  42.     }
  43.  
  44.     public EntityTurret(World worldIn){
  45.         super(worldIn);
  46.     }
  47.  
  48.     @Override
  49.     protected void initEntityAI() {
  50.         super.initEntityAI();
  51.         this.targetTasks.addTask(3, new EntityAIAttackRanged(this, 0, 5, range));
  52.  
  53. //        switch(attackMode){
  54. //
  55. //             case 0:
  56. //                 this.targetTasks.addTask(2, new EntityAINearestAttackableTarget<EntityPlayer>(this, 0, 5, range));
  57. //
  58. //
  59. //        }
  60.  
  61.         this.targetTasks.addTask(2, new EntityAINearestAttackableTarget<EntityZombie>(this, EntityZombie.class, true, true));
  62.  
  63.  
  64.     }
  65.  
  66.  
  67.  
  68.     @Override
  69.     public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) {
  70.  
  71.         EntityArrowCustom arrow = null;
  72.         switch (tier) {
  73.             case 0:
  74.                 arrow = new EntityArrowCustom(getEntityWorld(), this, false);
  75.             case 1:
  76.                 arrow = new EntityArrowCustom(getEntityWorld(), this, true);
  77.  
  78.         }
  79.         Vec3d looking = this.getLookVec();
  80.         if (looking != null) {
  81.             arrow.motionX = looking.x;
  82.             arrow.motionY = looking.y;
  83.             arrow.motionZ = looking.z;
  84.         }
  85.  
  86.         getEntityWorld().spawnEntity(arrow);
  87.  
  88.  
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement