Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.nosrick.minersgotchi.ai;
- import java.util.UUID;
- import net.minecraft.client.Minecraft;
- import net.minecraft.entity.EntityCreature;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.ai.EntityAIBase;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.pathfinding.PathNavigate;
- import net.minecraft.server.MinecraftServer;
- import net.minecraft.util.MathHelper;
- import net.minecraft.world.World;
- public class GotchiAIFollowOwner extends EntityAIBase
- {
- protected EntityCreature m_Gotchi;
- protected EntityPlayer m_Owner;
- protected World m_World;
- protected double m_Thing1;
- protected PathNavigate m_Navigator;
- protected int m_Thing2;
- protected float m_MinDistance;
- protected float m_MaxDistance;
- private boolean m_AvoidsWater;
- public GotchiAIFollowOwner(EntityCreature gotchiRef, UUID ownerIDRef, double ref1, float minDistRef, float maxDistRef)
- {
- m_Gotchi = gotchiRef;
- m_World = m_Gotchi.worldObj;
- if(ownerIDRef != null)
- {
- m_Owner = m_World.func_152378_a(ownerIDRef);
- }
- m_Thing1 = ref1;
- m_Navigator = m_Gotchi.getNavigator();
- m_MinDistance = minDistRef;
- m_MaxDistance = maxDistRef;
- this.setMutexBits(3);
- }
- public void SetOwner(UUID ownerRef, int dimensionRef)
- {
- World world = MinecraftServer.getServer().worldServerForDimension(dimensionRef);
- m_Owner = world.func_152378_a(ownerRef);
- if(m_Owner != null)
- {
- System.out.println("Owner is " + m_Owner.getUniqueID());
- }
- else
- {
- System.out.println("OWNER IS NULL");
- }
- }
- @Override
- public void startExecuting()
- {
- m_Thing2 = 0;
- m_AvoidsWater = m_Navigator.getAvoidsWater();
- m_Navigator.setAvoidsWater(false);
- }
- @Override
- public boolean shouldExecute()
- {
- if(m_Owner != null)
- {
- if(m_Gotchi.getDistanceSqToEntity(m_Owner) < (double)(m_MinDistance * m_MaxDistance))
- {
- return true;
- }
- }
- return false;
- }
- @Override
- public boolean continueExecuting()
- {
- if(m_Owner == null)
- {
- return false;
- }
- return !m_Navigator.noPath() && m_Gotchi.getDistanceSqToEntity(m_Owner) > (double)(this.m_MinDistance * this.m_MaxDistance);
- }
- @Override
- public void updateTask()
- {
- if(m_Owner != null)
- {
- m_Gotchi.getLookHelper().setLookPositionWithEntity(m_Owner, 10.0F, (float)m_Gotchi.getVerticalFaceSpeed());
- if(--m_Thing2 <= 0)
- {
- m_Thing2 = 10;
- if(!m_Navigator.tryMoveToEntityLiving(m_Owner, m_Thing1))
- {
- if(!m_Gotchi.getLeashed())
- {
- if(m_Gotchi.getDistanceSqToEntity(m_Owner) >= 144.0D)
- {
- int i = MathHelper.floor_double(m_Owner.posX);
- int k = MathHelper.floor_double(m_Owner.posZ);
- int j = MathHelper.floor_double(m_Owner.boundingBox.minY);
- //m_Gotchi.setLocationAndAngles((double)(i + 0.5F), (double)k, (double)(j + 0.5F), m_Gotchi.rotationYaw, m_Gotchi.rotationPitch);
- m_Gotchi.setLocationAndAngles(i, j, k, m_Gotchi.rotationYaw, m_Gotchi.rotationPitch);
- m_Navigator.clearPathEntity();
- return;
- /*
- for(int l = 0; l <= 4; ++l)
- {
- for(int m = 0; m <= 4; ++m)
- {
- if((l < 1 || m < 1 || l > 3 || m > 3) && World.doesBlockHaveSolidTopSurface(m_World, i + l, k - 1, j + m) &&
- m_World.getBlock(i + l, k, j + m).isNormalCube() && m_World.getBlock(i + l, k + 1, j + m).isNormalCube())
- {
- m_Gotchi.setLocationAndAngles((double)((float)(i + l) + 0.5F), (double)k, (double)((float)(j + m) + 0.5F), m_Gotchi.rotationYaw, m_Gotchi.rotationPitch);
- m_Navigator.clearPathEntity();
- return;
- }
- }
- }
- */
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement