Advertisement
Guest User

Mob code

a guest
Nov 16th, 2018
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 23.39 KB | None | 0 0
  1. package net.minecraft.entity.monster;
  2.  
  3. import com.google.common.base.Predicate;
  4. import javax.annotation.Nullable;
  5. import net.minecraft.block.material.Material;
  6. import net.minecraft.entity.Entity;
  7. import net.minecraft.entity.EntityLiving;
  8. import net.minecraft.entity.EntityLivingBase;
  9. import net.minecraft.entity.MoverType;
  10. import net.minecraft.entity.SharedMonsterAttributes;
  11. import net.minecraft.entity.ai.EntityAIBase;
  12. import net.minecraft.entity.ai.EntityAILookIdle;
  13. import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;
  14. import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
  15. import net.minecraft.entity.ai.EntityAIWander;
  16. import net.minecraft.entity.ai.EntityAIWatchClosest;
  17. import net.minecraft.entity.ai.EntityLookHelper;
  18. import net.minecraft.entity.ai.EntityMoveHelper;
  19. import net.minecraft.entity.passive.EntitySquid;
  20. import net.minecraft.entity.player.EntityPlayer;
  21. import net.minecraft.init.SoundEvents;
  22. import net.minecraft.network.datasync.DataParameter;
  23. import net.minecraft.network.datasync.DataSerializers;
  24. import net.minecraft.network.datasync.EntityDataManager;
  25. import net.minecraft.pathfinding.PathNavigate;
  26. import net.minecraft.pathfinding.PathNavigateSwimmer;
  27. import net.minecraft.util.DamageSource;
  28. import net.minecraft.util.EnumParticleTypes;
  29. import net.minecraft.util.ResourceLocation;
  30. import net.minecraft.util.SoundEvent;
  31. import net.minecraft.util.datafix.DataFixer;
  32. import net.minecraft.util.math.BlockPos;
  33. import net.minecraft.util.math.MathHelper;
  34. import net.minecraft.util.math.Vec3d;
  35. import net.minecraft.world.EnumDifficulty;
  36. import net.minecraft.world.World;
  37. import net.minecraft.world.storage.loot.LootTableList;
  38. import net.minecraftforge.fml.relauncher.Side;
  39. import net.minecraftforge.fml.relauncher.SideOnly;
  40.  
  41. public class mcreator_test extends EntityMob
  42. {
  43.     private static final DataParameter<Boolean> MOVING = EntityDataManager.<Boolean>createKey(mcreator_test.class, DataSerializers.BOOLEAN);
  44.     private static final DataParameter<Integer> TARGET_ENTITY = EntityDataManager.<Integer>createKey(mcreator_test.class, DataSerializers.VARINT);
  45.     protected float clientSideTailAnimation;
  46.     protected float clientSideTailAnimationO;
  47.     protected float clientSideTailAnimationSpeed;
  48.     protected float clientSideSpikesAnimation;
  49.     protected float clientSideSpikesAnimationO;
  50.     private EntityLivingBase targetedEntity;
  51.     private int clientSideAttackTime;
  52.     private boolean clientSideTouchedGround;
  53.     protected EntityAIWander wander;
  54.  
  55.     public mcreator_test(World worldIn)
  56.     {
  57.         super(worldIn);
  58.         this.experienceValue = 10;
  59.         this.setSize(0.85F, 0.85F);
  60.         this.moveHelper = new mcreator_test.GuardianMoveHelper(this);
  61.         this.clientSideTailAnimation = this.rand.nextFloat();
  62.         this.clientSideTailAnimationO = this.clientSideTailAnimation;
  63.     }
  64.  
  65.     protected void initEntityAI()
  66.     {
  67.         EntityAIMoveTowardsRestriction entityaimovetowardsrestriction = new EntityAIMoveTowardsRestriction(this, 1.0D);
  68.         this.wander = new EntityAIWander(this, 1.0D, 80);
  69.         this.tasks.addTask(4, new mcreator_test.AIGuardianAttack(this));
  70.         this.tasks.addTask(5, entityaimovetowardsrestriction);
  71.         this.tasks.addTask(7, this.wander);
  72.         this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
  73.         this.tasks.addTask(8, new EntityAIWatchClosest(this, mcreator_test.class, 12.0F, 0.01F));
  74.         this.tasks.addTask(9, new EntityAILookIdle(this));
  75.         this.wander.setMutexBits(3);
  76.         entityaimovetowardsrestriction.setMutexBits(3);
  77.         this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, 10, true, false, new mcreator_test.GuardianTargetSelector(this)));
  78.     }
  79.  
  80.     protected void applyEntityAttributes()
  81.     {
  82.         super.applyEntityAttributes();
  83.         this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(6.0D);
  84.         this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.5D);
  85.         this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(16.0D);
  86.         this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(30.0D);
  87.     }
  88.  
  89.     public static void registerFixesGuardian(DataFixer fixer)
  90.     {
  91.         EntityLiving.registerFixesMob(fixer, mcreator_test.class);
  92.     }
  93.  
  94.     /**
  95.      * Returns new PathNavigateGround instance
  96.      */
  97.     protected PathNavigate createNavigator(World worldIn)
  98.     {
  99.         return new PathNavigateSwimmer(this, worldIn);
  100.     }
  101.  
  102.     protected void entityInit()
  103.     {
  104.         super.entityInit();
  105.         this.dataManager.register(MOVING, Boolean.valueOf(false));
  106.         this.dataManager.register(TARGET_ENTITY, Integer.valueOf(0));
  107.     }
  108.  
  109.     public boolean isMoving()
  110.     {
  111.         return ((Boolean)this.dataManager.get(MOVING)).booleanValue();
  112.     }
  113.  
  114.     private void setMoving(boolean moving)
  115.     {
  116.         this.dataManager.set(MOVING, Boolean.valueOf(moving));
  117.     }
  118.  
  119.     public int getAttackDuration()
  120.     {
  121.         return 80;
  122.     }
  123.  
  124.     private void setTargetedEntity(int entityId)
  125.     {
  126.         this.dataManager.set(TARGET_ENTITY, Integer.valueOf(entityId));
  127.     }
  128.  
  129.     public boolean hasTargetedEntity()
  130.     {
  131.         return ((Integer)this.dataManager.get(TARGET_ENTITY)).intValue() != 0;
  132.     }
  133.  
  134.     @Nullable
  135.     public EntityLivingBase getTargetedEntity()
  136.     {
  137.         if (!this.hasTargetedEntity())
  138.         {
  139.             return null;
  140.         }
  141.         else if (this.world.isRemote)
  142.         {
  143.             if (this.targetedEntity != null)
  144.             {
  145.                 return this.targetedEntity;
  146.             }
  147.             else
  148.             {
  149.                 Entity entity = this.world.getEntityByID(((Integer)this.dataManager.get(TARGET_ENTITY)).intValue());
  150.  
  151.                 if (entity instanceof EntityLivingBase)
  152.                 {
  153.                     this.targetedEntity = (EntityLivingBase)entity;
  154.                     return this.targetedEntity;
  155.                 }
  156.                 else
  157.                 {
  158.                     return null;
  159.                 }
  160.             }
  161.         }
  162.         else
  163.         {
  164.             return this.getAttackTarget();
  165.         }
  166.     }
  167.  
  168.     public void notifyDataManagerChange(DataParameter<?> key)
  169.     {
  170.         super.notifyDataManagerChange(key);
  171.  
  172.         if (TARGET_ENTITY.equals(key))
  173.         {
  174.             this.clientSideAttackTime = 0;
  175.             this.targetedEntity = null;
  176.         }
  177.     }
  178.  
  179.     /**
  180.      * Get number of ticks, at least during which the living entity will be silent.
  181.      */
  182.     public int getTalkInterval()
  183.     {
  184.         return 160;
  185.     }
  186.  
  187.     protected SoundEvent getAmbientSound()
  188.     {
  189.         return this.isInWater() ? SoundEvents.ENTITY_GUARDIAN_AMBIENT : SoundEvents.ENTITY_GUARDIAN_AMBIENT_LAND;
  190.     }
  191.  
  192.     protected SoundEvent getHurtSound(DamageSource damageSourceIn)
  193.     {
  194.         return this.isInWater() ? SoundEvents.ENTITY_GUARDIAN_HURT : SoundEvents.ENTITY_GUARDIAN_HURT_LAND;
  195.     }
  196.  
  197.     protected SoundEvent getDeathSound()
  198.     {
  199.         return this.isInWater() ? SoundEvents.ENTITY_GUARDIAN_DEATH : SoundEvents.ENTITY_GUARDIAN_DEATH_LAND;
  200.     }
  201.  
  202.     /**
  203.      * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
  204.      * prevent them from trampling crops
  205.      */
  206.     protected boolean canTriggerWalking()
  207.     {
  208.         return false;
  209.     }
  210.  
  211.     public float getEyeHeight()
  212.     {
  213.         return this.height * 0.5F;
  214.     }
  215.  
  216.     public float getBlockPathWeight(BlockPos pos)
  217.     {
  218.         return this.world.getBlockState(pos).getMaterial() == Material.WATER ? 10.0F + this.world.getLightBrightness(pos) - 0.5F : super.getBlockPathWeight(pos);
  219.     }
  220.  
  221.     /**
  222.      * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
  223.      * use this to react to sunlight and start to burn.
  224.      */
  225.     public void onLivingUpdate()
  226.     {
  227.         if (this.world.isRemote)
  228.         {
  229.             this.clientSideTailAnimationO = this.clientSideTailAnimation;
  230.  
  231.             if (!this.isInWater())
  232.             {
  233.                 this.clientSideTailAnimationSpeed = 2.0F;
  234.  
  235.                 if (this.motionY > 0.0D && this.clientSideTouchedGround && !this.isSilent())
  236.                 {
  237.                     this.world.playSound(this.posX, this.posY, this.posZ, this.getFlopSound(), this.getSoundCategory(), 1.0F, 1.0F, false);
  238.                 }
  239.  
  240.                 this.clientSideTouchedGround = this.motionY < 0.0D && this.world.isBlockNormalCube((new BlockPos(this)).down(), false);
  241.             }
  242.             else if (this.isMoving())
  243.             {
  244.                 if (this.clientSideTailAnimationSpeed < 0.5F)
  245.                 {
  246.                     this.clientSideTailAnimationSpeed = 4.0F;
  247.                 }
  248.                 else
  249.                 {
  250.                     this.clientSideTailAnimationSpeed += (0.5F - this.clientSideTailAnimationSpeed) * 0.1F;
  251.                 }
  252.             }
  253.             else
  254.             {
  255.                 this.clientSideTailAnimationSpeed += (0.125F - this.clientSideTailAnimationSpeed) * 0.2F;
  256.             }
  257.  
  258.             this.clientSideTailAnimation += this.clientSideTailAnimationSpeed;
  259.             this.clientSideSpikesAnimationO = this.clientSideSpikesAnimation;
  260.  
  261.             if (!this.isInWater())
  262.             {
  263.                 this.clientSideSpikesAnimation = this.rand.nextFloat();
  264.             }
  265.             else if (this.isMoving())
  266.             {
  267.                 this.clientSideSpikesAnimation += (0.0F - this.clientSideSpikesAnimation) * 0.25F;
  268.             }
  269.             else
  270.             {
  271.                 this.clientSideSpikesAnimation += (1.0F - this.clientSideSpikesAnimation) * 0.06F;
  272.             }
  273.  
  274.             if (this.isMoving() && this.isInWater())
  275.             {
  276.                 Vec3d vec3d = this.getLook(0.0F);
  277.  
  278.                 for (int i = 0; i < 2; ++i)
  279.                 {
  280.                     this.world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width - vec3d.x * 1.5D, this.posY + this.rand.nextDouble() * (double)this.height - vec3d.y * 1.5D, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width - vec3d.z * 1.5D, 0.0D, 0.0D, 0.0D);
  281.                 }
  282.             }
  283.  
  284.             if (this.hasTargetedEntity())
  285.             {
  286.                 if (this.clientSideAttackTime < this.getAttackDuration())
  287.                 {
  288.                     ++this.clientSideAttackTime;
  289.                 }
  290.  
  291.                 EntityLivingBase entitylivingbase = this.getTargetedEntity();
  292.  
  293.                 if (entitylivingbase != null)
  294.                 {
  295.                     this.getLookHelper().setLookPositionWithEntity(entitylivingbase, 90.0F, 90.0F);
  296.                     this.getLookHelper().onUpdateLook();
  297.                     double d5 = (double)this.getAttackAnimationScale(0.0F);
  298.                     double d0 = entitylivingbase.posX - this.posX;
  299.                     double d1 = entitylivingbase.posY + (double)(entitylivingbase.height * 0.5F) - (this.posY + (double)this.getEyeHeight());
  300.                     double d2 = entitylivingbase.posZ - this.posZ;
  301.                     double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
  302.                     d0 = d0 / d3;
  303.                     d1 = d1 / d3;
  304.                     d2 = d2 / d3;
  305.                     double d4 = this.rand.nextDouble();
  306.  
  307.                     while (d4 < d3)
  308.                     {
  309.                         d4 += 1.8D - d5 + this.rand.nextDouble() * (1.7D - d5);
  310.                         this.world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX + d0 * d4, this.posY + d1 * d4 + (double)this.getEyeHeight(), this.posZ + d2 * d4, 0.0D, 0.0D, 0.0D);
  311.                     }
  312.                 }
  313.             }
  314.         }
  315.  
  316.         if (this.inWater)
  317.         {
  318.             this.setAir(300);
  319.         }
  320.         else if (this.onGround)
  321.         {
  322.             this.motionY += 0.5D;
  323.             this.motionX += (double)((this.rand.nextFloat() * 2.0F - 1.0F) * 0.4F);
  324.             this.motionZ += (double)((this.rand.nextFloat() * 2.0F - 1.0F) * 0.4F);
  325.             this.rotationYaw = this.rand.nextFloat() * 360.0F;
  326.             this.onGround = false;
  327.             this.isAirBorne = true;
  328.         }
  329.  
  330.         if (this.hasTargetedEntity())
  331.         {
  332.             this.rotationYaw = this.rotationYawHead;
  333.         }
  334.  
  335.         super.onLivingUpdate();
  336.     }
  337.  
  338.     protected SoundEvent getFlopSound()
  339.     {
  340.         return SoundEvents.ENTITY_GUARDIAN_FLOP;
  341.     }
  342.  
  343.     @SideOnly(Side.CLIENT)
  344.     public float getTailAnimation(float p_175471_1_)
  345.     {
  346.         return this.clientSideTailAnimationO + (this.clientSideTailAnimation - this.clientSideTailAnimationO) * p_175471_1_;
  347.     }
  348.  
  349.     @SideOnly(Side.CLIENT)
  350.     public float getSpikesAnimation(float p_175469_1_)
  351.     {
  352.         return this.clientSideSpikesAnimationO + (this.clientSideSpikesAnimation - this.clientSideSpikesAnimationO) * p_175469_1_;
  353.     }
  354.  
  355.     public float getAttackAnimationScale(float p_175477_1_)
  356.     {
  357.         return ((float)this.clientSideAttackTime + p_175477_1_) / (float)this.getAttackDuration();
  358.     }
  359.  
  360.     @Nullable
  361.     protected ResourceLocation getLootTable()
  362.     {
  363.         return LootTableList.ENTITIES_GUARDIAN;
  364.     }
  365.  
  366.     /**
  367.      * Checks to make sure the light is not too bright where the mob is spawning
  368.      */
  369.     protected boolean isValidLightLevel()
  370.     {
  371.         return true;
  372.     }
  373.  
  374.     /**
  375.      * Checks that the entity is not colliding with any blocks / liquids
  376.      */
  377.     public boolean isNotColliding()
  378.     {
  379.         return this.world.checkNoEntityCollision(this.getEntityBoundingBox(), this) && this.world.getCollisionBoxes(this, this.getEntityBoundingBox()).isEmpty();
  380.     }
  381.  
  382.     /**
  383.      * Checks if the entity's current position is a valid location to spawn this entity.
  384.      */
  385.     public boolean getCanSpawnHere()
  386.     {
  387.         return (this.rand.nextInt(20) == 0 || !this.world.canBlockSeeSky(new BlockPos(this))) && super.getCanSpawnHere();
  388.     }
  389.  
  390.     /**
  391.      * Called when the entity is attacked.
  392.      */
  393.     public boolean attackEntityFrom(DamageSource source, float amount)
  394.     {
  395.         if (!this.isMoving() && !source.isMagicDamage() && source.getImmediateSource() instanceof EntityLivingBase)
  396.         {
  397.             EntityLivingBase entitylivingbase = (EntityLivingBase)source.getImmediateSource();
  398.  
  399.             if (!source.isExplosion())
  400.             {
  401.                 entitylivingbase.attackEntityFrom(DamageSource.causeThornsDamage(this), 2.0F);
  402.             }
  403.         }
  404.  
  405.         if (this.wander != null)
  406.         {
  407.             this.wander.makeUpdate();
  408.         }
  409.  
  410.         return super.attackEntityFrom(source, amount);
  411.     }
  412.  
  413.     /**
  414.      * The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
  415.      * use in wolves.
  416.      */
  417.     public int getVerticalFaceSpeed()
  418.     {
  419.         return 180;
  420.     }
  421.  
  422.     public void travel(float strafe, float vertical, float forward)
  423.     {
  424.         if (this.isServerWorld() && this.isInWater())
  425.         {
  426.             this.moveRelative(strafe, vertical, forward, 0.1F);
  427.             this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ);
  428.             this.motionX *= 0.8999999761581421D;
  429.             this.motionY *= 0.8999999761581421D;
  430.             this.motionZ *= 0.8999999761581421D;
  431.  
  432.             if (!this.isMoving() && this.getAttackTarget() == null)
  433.             {
  434.                 this.motionY -= 0.005D;
  435.             }
  436.         }
  437.         else
  438.         {
  439.             super.travel(strafe, vertical, forward);
  440.         }
  441.     }
  442.  
  443.     static class AIGuardianAttack extends EntityAIBase
  444.         {
  445.             private final mcreator_test guardian;
  446.             private int tickCounter;
  447.             private final boolean isElder;
  448.  
  449.             public AIGuardianAttack(mcreator_test guardian)
  450.             {
  451.                 this.guardian = guardian;
  452.                 this.isElder = guardian instanceof mcreator_test;
  453.                 this.setMutexBits(3);
  454.             }
  455.  
  456.             /**
  457.              * Returns whether the EntityAIBase should begin execution.
  458.              */
  459.             public boolean shouldExecute()
  460.             {
  461.                 EntityLivingBase entitylivingbase = this.guardian.getAttackTarget();
  462.                 return entitylivingbase != null && entitylivingbase.isEntityAlive();
  463.             }
  464.  
  465.             /**
  466.              * Returns whether an in-progress EntityAIBase should continue executing
  467.              */
  468.             public boolean shouldContinueExecuting()
  469.             {
  470.                 return super.shouldContinueExecuting() && (this.isElder || this.guardian.getDistanceSq(this.guardian.getAttackTarget()) > 9.0D);
  471.             }
  472.  
  473.             /**
  474.              * Execute a one shot task or start executing a continuous task
  475.              */
  476.             public void startExecuting()
  477.             {
  478.                 this.tickCounter = -10;
  479.                 this.guardian.getNavigator().clearPath();
  480.                 this.guardian.getLookHelper().setLookPositionWithEntity(this.guardian.getAttackTarget(), 90.0F, 90.0F);
  481.                 this.guardian.isAirBorne = true;
  482.             }
  483.  
  484.             /**
  485.              * Reset the task's internal state. Called when this task is interrupted by another one
  486.              */
  487.             public void resetTask()
  488.             {
  489.                 this.guardian.setTargetedEntity(0);
  490.                 this.guardian.setAttackTarget((EntityLivingBase)null);
  491.                 this.guardian.wander.makeUpdate();
  492.             }
  493.  
  494.             /**
  495.              * Keep ticking a continuous task that has already been started
  496.              */
  497.             public void updateTask()
  498.             {
  499.                 EntityLivingBase entitylivingbase = this.guardian.getAttackTarget();
  500.                 this.guardian.getNavigator().clearPath();
  501.                 this.guardian.getLookHelper().setLookPositionWithEntity(entitylivingbase, 90.0F, 90.0F);
  502.  
  503.                 if (!this.guardian.canEntityBeSeen(entitylivingbase))
  504.                 {
  505.                     this.guardian.setAttackTarget((EntityLivingBase)null);
  506.                 }
  507.                 else
  508.                 {
  509.                     ++this.tickCounter;
  510.  
  511.                     if (this.tickCounter == 0)
  512.                     {
  513.                         this.guardian.setTargetedEntity(this.guardian.getAttackTarget().getEntityId());
  514.                         this.guardian.world.setEntityState(this.guardian, (byte)21);
  515.                     }
  516.                     else if (this.tickCounter >= this.guardian.getAttackDuration())
  517.                     {
  518.                         float f = 1.0F;
  519.  
  520.                         if (this.guardian.world.getDifficulty() == EnumDifficulty.HARD)
  521.                         {
  522.                             f += 2.0F;
  523.                         }
  524.  
  525.                         if (this.isElder)
  526.                         {
  527.                             f += 2.0F;
  528.                         }
  529.  
  530.                         entitylivingbase.attackEntityFrom(DamageSource.causeIndirectMagicDamage(this.guardian, this.guardian), f);
  531.                         entitylivingbase.attackEntityFrom(DamageSource.causeMobDamage(this.guardian), (float)this.guardian.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue());
  532.                         this.guardian.setAttackTarget((EntityLivingBase)null);
  533.                     }
  534.  
  535.                     super.updateTask();
  536.                 }
  537.             }
  538.         }
  539.  
  540.     static class GuardianMoveHelper extends EntityMoveHelper
  541.         {
  542.             private final mcreator_test mcreator_test;
  543.  
  544.             public GuardianMoveHelper(mcreator_test guardian)
  545.             {
  546.                 super(guardian);
  547.                 this.mcreator_test = guardian;
  548.             }
  549.  
  550.             public void onUpdateMoveHelper()
  551.             {
  552.                 if (this.action == EntityMoveHelper.Action.MOVE_TO && !this.mcreator_test.getNavigator().noPath())
  553.                 {
  554.                     double d0 = this.posX - this.mcreator_test.posX;
  555.                     double d1 = this.posY - this.mcreator_test.posY;
  556.                     double d2 = this.posZ - this.mcreator_test.posZ;
  557.                     double d3 = (double)MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
  558.                     d1 = d1 / d3;
  559.                     float f = (float)(MathHelper.atan2(d2, d0) * (180D / Math.PI)) - 90.0F;
  560.                     this.mcreator_test.rotationYaw = this.limitAngle(this.mcreator_test.rotationYaw, f, 90.0F);
  561.                     this.mcreator_test.renderYawOffset = this.mcreator_test.rotationYaw;
  562.                     float f1 = (float)(this.speed * this.mcreator_test.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue());
  563.                     this.mcreator_test.setAIMoveSpeed(this.mcreator_test.getAIMoveSpeed() + (f1 - this.mcreator_test.getAIMoveSpeed()) * 0.125F);
  564.                     double d4 = Math.sin((double)(this.mcreator_test.ticksExisted + this.mcreator_test.getEntityId()) * 0.5D) * 0.05D;
  565.                     double d5 = Math.cos((double)(this.mcreator_test.rotationYaw * 0.017453292F));
  566.                     double d6 = Math.sin((double)(this.mcreator_test.rotationYaw * 0.017453292F));
  567.                     this.mcreator_test.motionX += d4 * d5;
  568.                     this.mcreator_test.motionZ += d4 * d6;
  569.                     d4 = Math.sin((double)(this.mcreator_test.ticksExisted + this.mcreator_test.getEntityId()) * 0.75D) * 0.05D;
  570.                     this.mcreator_test.motionY += d4 * (d6 + d5) * 0.25D;
  571.                     this.mcreator_test.motionY += (double)this.mcreator_test.getAIMoveSpeed() * d1 * 0.1D;
  572.                     EntityLookHelper entitylookhelper = this.mcreator_test.getLookHelper();
  573.                     double d7 = this.mcreator_test.posX + d0 / d3 * 2.0D;
  574.                     double d8 = (double)this.mcreator_test.getEyeHeight() + this.mcreator_test.posY + d1 / d3;
  575.                     double d9 = this.mcreator_test.posZ + d2 / d3 * 2.0D;
  576.                     double d10 = entitylookhelper.getLookPosX();
  577.                     double d11 = entitylookhelper.getLookPosY();
  578.                     double d12 = entitylookhelper.getLookPosZ();
  579.  
  580.                     if (!entitylookhelper.getIsLooking())
  581.                     {
  582.                         d10 = d7;
  583.                         d11 = d8;
  584.                         d12 = d9;
  585.                     }
  586.  
  587.                     this.mcreator_test.getLookHelper().setLookPosition(d10 + (d7 - d10) * 0.125D, d11 + (d8 - d11) * 0.125D, d12 + (d9 - d12) * 0.125D, 10.0F, 40.0F);
  588.                     this.mcreator_test.setMoving(true);
  589.                 }
  590.                 else
  591.                 {
  592.                     this.mcreator_test.setAIMoveSpeed(0.0F);
  593.                     this.mcreator_test.setMoving(false);
  594.                 }
  595.             }
  596.         }
  597.  
  598.     static class GuardianTargetSelector implements Predicate<EntityLivingBase>
  599.         {
  600.             private final mcreator_test parentEntity;
  601.  
  602.             public GuardianTargetSelector(mcreator_test guardian)
  603.             {
  604.                 this.parentEntity = guardian;
  605.             }
  606.  
  607.             public boolean apply(@Nullable EntityLivingBase p_apply_1_)
  608.             {
  609.                 return (p_apply_1_ instanceof EntityPlayer || p_apply_1_ instanceof EntitySquid) && p_apply_1_.getDistanceSq(this.parentEntity) > 9.0D;
  610.             }
  611.         }
  612. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement