mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 05:19:41 +00:00
Proper Reformating
This commit is contained in:
1 parent
ce75880aba
commit
180d257024
1179 files changed
+59847
-61583
No files matched your search
@@ -6,8 +6,7 @@ import net.minecraft.util.Vec3;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class RandomPositionGeneratorAlt
|
||||
{
|
||||
public class RandomPositionGeneratorAlt {
|
||||
/**
|
||||
* used to store a driection when the user passes a point to move towards or away from. WARNING: NEVER THREAD SAFE.
|
||||
* MULTIPLE findTowards and findAway calls, will share this var
|
||||
@@ -17,20 +16,18 @@ public class RandomPositionGeneratorAlt
|
||||
/**
|
||||
* finds a random target within par1(x,z) and par2 (y) blocks
|
||||
*/
|
||||
public static Vec3 findRandomTarget(EntityCreature par0EntityCreature, int par1, int par2)
|
||||
{
|
||||
public static Vec3 findRandomTarget(EntityCreature par0EntityCreature, int par1, int par2) {
|
||||
/**
|
||||
* searches 10 blocks at random in a within par1(x,z) and par2 (y) distance, ignores those not in the direction
|
||||
* of par3Vec3, then points to the tile for which creature.getBlockPathWeight returns the highest number
|
||||
*/
|
||||
return findRandomTargetBlock(par0EntityCreature, par1, par2, (Vec3)null);
|
||||
return findRandomTargetBlock(par0EntityCreature, par1, par2, (Vec3) null);
|
||||
}
|
||||
|
||||
/**
|
||||
* finds a random target within par1(x,z) and par2 (y) blocks in the direction of the point par3
|
||||
*/
|
||||
public static Vec3 findRandomTargetBlockTowards(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3)
|
||||
{
|
||||
public static Vec3 findRandomTargetBlockTowards(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3) {
|
||||
staticVector.xCoord = par3Vec3.xCoord - par0EntityCreature.posX;
|
||||
staticVector.yCoord = par3Vec3.yCoord - par0EntityCreature.posY;
|
||||
staticVector.zCoord = par3Vec3.zCoord - par0EntityCreature.posZ;
|
||||
@@ -44,8 +41,7 @@ public class RandomPositionGeneratorAlt
|
||||
/**
|
||||
* finds a random target within par1(x,z) and par2 (y) blocks in the reverse direction of the point par3
|
||||
*/
|
||||
public static Vec3 findRandomTargetBlockAwayFrom(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3)
|
||||
{
|
||||
public static Vec3 findRandomTargetBlockAwayFrom(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3) {
|
||||
staticVector.xCoord = par0EntityCreature.posX - par3Vec3.xCoord;
|
||||
staticVector.yCoord = par0EntityCreature.posY - par3Vec3.yCoord;
|
||||
staticVector.zCoord = par0EntityCreature.posZ - par3Vec3.zCoord;
|
||||
@@ -60,12 +56,11 @@ public class RandomPositionGeneratorAlt
|
||||
* searches 10 blocks at random in a within par1(x,z) and par2 (y) distance, ignores those not in the direction of
|
||||
* par3Vec3, then points to the tile for which creature.getBlockPathWeight returns the highest number
|
||||
*/
|
||||
private static Vec3 findRandomTargetBlock(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3)
|
||||
{
|
||||
if(par1 <= 0)
|
||||
par1 = 1;
|
||||
if(par2 <= 0)
|
||||
par2 = 1;
|
||||
private static Vec3 findRandomTargetBlock(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3) {
|
||||
if (par1 <= 0)
|
||||
par1 = 1;
|
||||
if (par2 <= 0)
|
||||
par2 = 1;
|
||||
Random random = par0EntityCreature.getRNG();
|
||||
boolean flag = false;
|
||||
int k = 0;
|
||||
@@ -74,41 +69,33 @@ public class RandomPositionGeneratorAlt
|
||||
float f = -99999.0F;
|
||||
boolean flag1;
|
||||
|
||||
if (par0EntityCreature.hasHome())
|
||||
{
|
||||
double d0 = (double)(par0EntityCreature.getHomePosition().getDistanceSquared(MathHelper.floor_double(par0EntityCreature.posX), MathHelper.floor_double(par0EntityCreature.posY), MathHelper.floor_double(par0EntityCreature.posZ)) + 4.0F);
|
||||
double d1 = (double)(par0EntityCreature.func_110174_bM() + (float)par1);
|
||||
if (par0EntityCreature.hasHome()) {
|
||||
double d0 = (double) (par0EntityCreature.getHomePosition().getDistanceSquared(MathHelper.floor_double(par0EntityCreature.posX), MathHelper.floor_double(par0EntityCreature.posY), MathHelper.floor_double(par0EntityCreature.posZ)) + 4.0F);
|
||||
double d1 = (double) (par0EntityCreature.func_110174_bM() + (float) par1);
|
||||
flag1 = d0 < d1 * d1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
flag1 = false;
|
||||
}
|
||||
|
||||
for (int l1 = 0; l1 < 10; ++l1)
|
||||
{
|
||||
for (int l1 = 0; l1 < 10; ++l1) {
|
||||
int j1 = random.nextInt(2 * par1) - par1;
|
||||
int i2 = random.nextInt(2 * par2) - par2;
|
||||
int k1 = random.nextInt(2 * par1) - par1;
|
||||
|
||||
if (par3Vec3 == null || (double)j1 * par3Vec3.xCoord + (double)k1 * par3Vec3.zCoord >= 0.0D)
|
||||
{
|
||||
if(random.nextBoolean()){
|
||||
j1 += MathHelper.floor_double(par0EntityCreature.posX);
|
||||
i2 += MathHelper.floor_double(par0EntityCreature.posY);
|
||||
k1 += MathHelper.floor_double(par0EntityCreature.posZ);
|
||||
}
|
||||
else{
|
||||
j1 += MathHelper.ceiling_double_int(par0EntityCreature.posX);
|
||||
i2 += MathHelper.ceiling_double_int(par0EntityCreature.posY);
|
||||
k1 += MathHelper.ceiling_double_int(par0EntityCreature.posZ);
|
||||
}
|
||||
if (!flag1 || par0EntityCreature.isWithinHomeDistance(j1, i2, k1))
|
||||
{
|
||||
if (par3Vec3 == null || (double) j1 * par3Vec3.xCoord + (double) k1 * par3Vec3.zCoord >= 0.0D) {
|
||||
if (random.nextBoolean()) {
|
||||
j1 += MathHelper.floor_double(par0EntityCreature.posX);
|
||||
i2 += MathHelper.floor_double(par0EntityCreature.posY);
|
||||
k1 += MathHelper.floor_double(par0EntityCreature.posZ);
|
||||
} else {
|
||||
j1 += MathHelper.ceiling_double_int(par0EntityCreature.posX);
|
||||
i2 += MathHelper.ceiling_double_int(par0EntityCreature.posY);
|
||||
k1 += MathHelper.ceiling_double_int(par0EntityCreature.posZ);
|
||||
}
|
||||
if (!flag1 || par0EntityCreature.isWithinHomeDistance(j1, i2, k1)) {
|
||||
float f1 = par0EntityCreature.getBlockPathWeight(j1, i2, k1);
|
||||
|
||||
if (f1 > f)
|
||||
{
|
||||
if (f1 > f) {
|
||||
f = f1;
|
||||
k = j1;
|
||||
l = i2;
|
||||
@@ -119,13 +106,10 @@ public class RandomPositionGeneratorAlt
|
||||
}
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
return Vec3.createVectorHelper((double)k, (double)l, (double)i1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (flag) {
|
||||
return Vec3.createVectorHelper((double) k, (double) l, (double) i1);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user