All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.minecraft.server.PathfinderGoalFleeSun Maven / Gradle / Ivy

package net.minecraft.server;

import java.util.Random;

public class PathfinderGoalFleeSun extends PathfinderGoal {
	
	private final EntityCreature a;
	private double b;
	private double c;
	private double d;
	private final double e;
	private final World f;
	
	public PathfinderGoalFleeSun(EntityCreature entitycreature, double d0) {
		this.a = entitycreature;
		this.e = d0;
		this.f = entitycreature.world;
		this.setMutexBits(1);
	}
	
	public boolean a() {
		if (!this.f.w()) {
			return false;
		} else if (!this.a.isBurning()) {
			return false;
		} else if (!this.f.i(new BlockPosition(this.a.locX, this.a.getBoundingBox().b, this.a.locZ))) {
			return false;
		} else {
			Vec3D vec3d = this.f();
			
			if (vec3d == null) {
				return false;
			} else {
				this.b = vec3d.a;
				this.c = vec3d.b;
				this.d = vec3d.c;
				return true;
			}
		}
	}
	
	public boolean b() {
		return !this.a.getNavigation().noPath();
	}
	
	public void c() {
		this.a.getNavigation().tryMoveToXYZ(this.b, this.c, this.d, this.e);
	}
	
	private Vec3D f() {
		Random random = this.a.getRandom();
		BlockPosition blockposition = new BlockPosition(this.a.locX, this.a.getBoundingBox().b, this.a.locZ);
		
		for (int i = 0; i < 10; ++i) {
			BlockPosition blockposition1 = blockposition.a(random.nextInt(20) - 10, random.nextInt(6) - 3, random.nextInt(20) - 10);
			
			if (!this.f.i(blockposition1) && this.a.a(blockposition1) < 0.0F) {
				return new Vec3D(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ());
			}
		}
		
		return null;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy