net.minecraft.entity.ai.RandomPositionGenerator Java Examples

The following examples show how to use net.minecraft.entity.ai.RandomPositionGenerator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityGnomeWood.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public Job getNewJob()
{
	if (this.gnode != null)
	{
		return this.gnode.generateJob(this);
	}
	else if (this.panic)	// no home, panicking
	{
		Vec3d vec = null;
		while (vec == null)
		{
			vec = RandomPositionGenerator.findRandomTarget(this, 32,8);
		}
		return new JobPanicTo(this, vec, 1.5D);
	}
	else	// no home, not panicking
	{
		// return new JobCreateGnomeCache
		// TODO replace hovel creation with a Job class
		return null;
	}
}
 
Example #2
Source File: EntityAIMoveIntoArea.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
public boolean shouldExecute() {

		if (!enabled) {
			return false;
		}

		if (inCorrectPosition()) {
			return false;
		}

		Vec3d vec3d = RandomPositionGenerator.findRandomTargetBlockTowards(this.entity, 16, 7, new Vec3d((double) centerX, (double) entity.posY, (double) centerZ));

		if (vec3d == null) {
			return false;
		} else {
			this.movePosX = vec3d.x;
			this.movePosY = vec3d.y;
			this.movePosZ = vec3d.z;
			return true;
		}

	}
 
Example #3
Source File: EntityAIFlyingPanic.java    From EnderZoo with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
@Override
public boolean shouldExecute() {
  if (theEntityCreature.getRevengeTarget() == null && !theEntityCreature.isBurning()) {
    return false;
  }
  Vec3d vec3 = RandomPositionGenerator.findRandomTarget(theEntityCreature, 5, 4);
  if (vec3 == null) {
    return false;
  }
  double yOffset = 1 + theEntityCreature.getEntityWorld().rand.nextInt(3);
  //double yOffset = 0;
  randPosX = vec3.x;
  randPosY = vec3.y + yOffset;
  randPosZ = vec3.z;
  return true;
}
 
Example #4
Source File: EntityAIFlyingShortWander.java    From EnderZoo with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
@Override
public boolean shouldExecute() {
  int chance = executionChance;
  if (isOnLeaves()) {
    chance *= 2;
  }
  if (entity.getRNG().nextInt(chance) != 0) {
    return false;
  }
  
  Vec3d vec3 = RandomPositionGenerator.findRandomTarget(entity, 4, 2);    
  if (vec3 == null || entity.posY - vec3.y < -2) {
    return false;
  }    
  randPosX = vec3.x;
  randPosY = vec3.y;
  randPosZ = vec3.z;
  return true;
}
 
Example #5
Source File: EntityAIWanderSwim.java    From TofuCraftReload with MIT License 5 votes vote down vote up
@Nullable
protected Vec3d getPosition() {
    Vec3d vec3d = RandomPositionGenerator.findRandomTarget(this.entity, 10, 7);

    for(int i = 0; vec3d != null && i++ < 10; vec3d = RandomPositionGenerator.findRandomTarget(this.entity, 10, 7)) {
        ;
    }

    return vec3d;
}
 
Example #6
Source File: Job.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Vec3d getRandomSurfaceVec(EntityCreature ent, int xrad, int yrad)
{
	Vec3d vecRand = RandomPositionGenerator.findRandomTarget(ent, xrad, yrad);
	return Job.groundify(ent.world, vecRand);
}
 
Example #7
Source File: Job.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Vec3d getSurfaceVecToward(EntityCreature ent, Vec3d vec, int xrad, int yrad)
{
	Vec3d vecRand = RandomPositionGenerator.findRandomTargetBlockTowards(ent, xrad, yrad, vec);
	return Job.groundify(ent.world, vecRand);
}