本文整理汇总了Java中net.minecraft.entity.ai.RandomPositionGenerator.findRandomTargetBlockAwayFrom方法的典型用法代码示例。如果您正苦于以下问题:Java RandomPositionGenerator.findRandomTargetBlockAwayFrom方法的具体用法?Java RandomPositionGenerator.findRandomTargetBlockAwayFrom怎么用?Java RandomPositionGenerator.findRandomTargetBlockAwayFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.ai.RandomPositionGenerator
的用法示例。
在下文中一共展示了RandomPositionGenerator.findRandomTargetBlockAwayFrom方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateTask
import net.minecraft.entity.ai.RandomPositionGenerator; //导入方法依赖的package包/类
@Override
public void updateTask() {
if ((target = getClosestEntity()) != null) {
pathFinderTarget = target.getNavigator();
pathFinderSelf.tryMoveToEntityLiving(target, entity.getAIMoveSpeed());
if (entity.getDistanceToEntity(target) < scaringRange) {
Vec3 var2 = RandomPositionGenerator.findRandomTargetBlockAwayFrom((EntityCreature) target, 16, 7, entity.worldObj.getWorldVec3Pool().getVecFromPool(entity.posX, entity.posY, entity.posZ));
if (var2 != null && entity.getDistanceSq(var2.xCoord, var2.yCoord, var2.zCoord) >= entity.getDistanceSqToEntity(target)) {
pathEntity = pathFinderTarget.getPathToXYZ(var2.xCoord, var2.yCoord, var2.zCoord);
if (pathEntity != null) {
pathFinderTarget.setPath(pathEntity, 0.4F);
}
}
}
}
}
示例2: shouldExecute
import net.minecraft.entity.ai.RandomPositionGenerator; //导入方法依赖的package包/类
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
if (this.targetEntityClass == EntityCreeperDragon.class)
{
List<?> list = this.theEntity.worldObj.selectEntitiesWithinAABB(this.targetEntityClass, this.theEntity.boundingBox.expand(this.distanceFromEntity, 3.0D, this.distanceFromEntity), this.field_98218_a);
if (list.isEmpty()) {
return false;
}
for (Object dragon : list) {
if (dragon instanceof EntityCreeperDragon && ((EntityCreeperDragon) dragon).isTamed())
this.closestLivingEntity = (Entity) dragon;
}
if (this.closestLivingEntity == null) {
return false;
}
Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.theEntity, 16, 7, Vec3.createVectorHelper(this.closestLivingEntity.posX, this.closestLivingEntity.posY, this.closestLivingEntity.posZ));
if (vec3 == null) {
return false;
} else if (this.closestLivingEntity.getDistanceSq(vec3.xCoord, vec3.yCoord, vec3.zCoord) < this.closestLivingEntity.getDistanceSqToEntity(this.theEntity)) {
return false;
} else {
this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(vec3.xCoord, vec3.yCoord, vec3.zCoord);
return this.entityPathEntity != null && this.entityPathEntity.isDestinationSame(vec3);
}
}
return false;
}
示例3: moveAway
import net.minecraft.entity.ai.RandomPositionGenerator; //导入方法依赖的package包/类
protected boolean moveAway(int xz, int y) {
Vec3d vec3d = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.entity, xz, y, new Vec3d(this.creeper.posX, this.creeper.posY, this.creeper.posZ));
if (vec3d != null) {
if (this.creeper.getDistanceSq(vec3d.x, vec3d.y, vec3d.z) > this.creeper.getDistanceSq(this.entity)) {
this.pathEntity = this.entityPathNavigate.getPathToXYZ(vec3d.x, vec3d.y, vec3d.z);
return this.pathEntity != null;
}
}
return false;
}
示例4: shouldExecute
import net.minecraft.entity.ai.RandomPositionGenerator; //导入方法依赖的package包/类
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute() {
if (this.creature.getAITarget() == null && !this.creature.isBurning()) {
return false;
} else {
Vec3d vec3;
if (this.creature.getAITarget() == null)
vec3 = RandomPositionGenerator.findRandomTarget(this.creature,
5, 4);
else
vec3 = RandomPositionGenerator.findRandomTargetBlockAwayFrom(
this.creature, 5, 4, new Vec3d(
this.creature.getAITarget().posX,
this.creature.getAITarget().posY,
this.creature.getAITarget().posZ));
if (vec3 == null) {
return false;
} else {
this.randPosX = vec3.xCoord;
this.randPosY = vec3.yCoord;
this.randPosZ = vec3.zCoord;
return true;
}
}
}
示例5: tick
import net.minecraft.entity.ai.RandomPositionGenerator; //导入方法依赖的package包/类
@Override
public void tick() {
if (getParent().worldObj.getWorldTime() % 22L == 0) {
@SuppressWarnings("unchecked")
List<Entity> entityList = ((EntityPlayer) getParent()).getEntityWorld().getEntitiesWithinAABBExcludingEntity(getParent(), getParent().boundingBox.expand(radius, radius, radius));
if (!entityList.isEmpty()) {
for (Entity entity : entityList) {
if (entity instanceof EntityCreature) {
EntityCreature creature = (EntityCreature) entity;
for(Class clz : classList)
{
if(clz.isInstance(creature))
{
boolean canRun = false;
Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockAwayFrom(creature, 16, 7, Vec3.createVectorHelper(getParent().posX, getParent().posY, getParent().posZ));
if(vec3 != null && !(getParent().getDistanceSq(vec3.xCoord, vec3.yCoord, vec3.zCoord) < getParent().getDistanceSqToEntity(creature)))
{
PathEntity newPath = new PathEntity(new PathPoint[] { new PathPoint((int)vec3.xCoord, (int)vec3.yCoord, (int)vec3.zCoord) });
creature.getNavigator().setPath(newPath, 1D);
canRun = true;
}
if(canRun)
creature.getNavigator().setSpeed(runSpeed);
}
}
}
}
}
}
}
示例6: shouldExecute
import net.minecraft.entity.ai.RandomPositionGenerator; //导入方法依赖的package包/类
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
if (this.targetEntityClass == EntityPlayer.class)
{
if (this.theEntity instanceof EntityTameable && ((EntityTameable)this.theEntity).isTamed())
{
return false;
}
this.closestLivingEntity = this.theEntity.worldObj.getClosestPlayerToEntity(this.theEntity, (double)this.distanceFromEntity);
if (this.closestLivingEntity == null)
{
return false;
}
}
else
{
List list = this.theEntity.worldObj.selectEntitiesWithinAABB(this.targetEntityClass, this.theEntity.boundingBox.expand((double)this.distanceFromEntity, 3.0D, (double)this.distanceFromEntity), this.entityFilter);
if (list.isEmpty())
{
return false;
}
this.closestLivingEntity = (Entity)list.get(0);
}
Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.theEntity, fleeRange, 7, Vec3.createVectorHelper(this.closestLivingEntity.posX, this.closestLivingEntity.posY, this.closestLivingEntity.posZ));
if (vec3 == null)
{
return false;
}
else if (this.closestLivingEntity.getDistanceSq(vec3.xCoord, vec3.yCoord, vec3.zCoord) < this.closestLivingEntity.getDistanceSqToEntity(this.theEntity))
{
return false;
}
else
{
this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(vec3.xCoord, vec3.yCoord, vec3.zCoord);
return this.entityPathEntity == null ? false : this.entityPathEntity.isDestinationSame(vec3);
}
}
示例7: shouldExecute
import net.minecraft.entity.ai.RandomPositionGenerator; //导入方法依赖的package包/类
@Override
public boolean shouldExecute()
{
{
List list = this.theEntity.worldObj.selectEntitiesWithinAABB(this.targetEntityClass, this.theEntity.boundingBox.expand((double)this.distanceFromEntity, 3.0D, (double)this.distanceFromEntity), this.field_98218_a);
if (list.isEmpty())
{
return false;
}
closestLivingEntity = null;
for ( int i = 0; i < list.size(); ++i )
{
PetEntity pet = ( PetEntity ) list.get( i );
if ( theEntity.getDistanceToEntity( pet ) <= getRangeOf( pet ) && canChaseMe( pet ) )
{
closestLivingEntity = pet;
break;
}
}
if ( closestLivingEntity == null )
{
return false;
}
}
Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.theEntity, 16, 7, Vec3.createVectorHelper(this.closestLivingEntity.posX, this.closestLivingEntity.posY, this.closestLivingEntity.posZ));
if (vec3 == null)
{
return false;
}
else if (this.closestLivingEntity.getDistanceSq(vec3.xCoord, vec3.yCoord, vec3.zCoord) < this.closestLivingEntity.getDistanceSqToEntity(this.theEntity))
{
return false;
}
else
{
this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(vec3.xCoord, vec3.yCoord, vec3.zCoord);
return this.entityPathEntity == null ? false : this.entityPathEntity.isDestinationSame(vec3);
}
}
示例8: shouldExecute
import net.minecraft.entity.ai.RandomPositionGenerator; //导入方法依赖的package包/类
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
if (this.targetEntityClass == EntityPlayer.class)
{
if (this.theEntity instanceof EntityTameable && ((EntityTameable) this.theEntity).isTamed())
{
return false;
}
List<?> list = this.theEntity.worldObj.selectEntitiesWithinAABB(this.targetEntityClass, this.theEntity.boundingBox.expand(this.distanceFromEntity, 3.0D, this.distanceFromEntity), this.field_98218_a);
if (list.isEmpty())
{
return false;
}
for (Object player : list)
{
if (BackpackNames.getBackpackColorName(Wearing.getWearingBackpack((EntityPlayer) player)).equals(backpackName))
{
this.closestLivingEntity = (Entity) player;
}
}
if (this.closestLivingEntity == null)
{
return false;
}
Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.theEntity, 16, 7, Vec3.createVectorHelper(this.closestLivingEntity.posX, this.closestLivingEntity.posY, this.closestLivingEntity.posZ));
if (vec3 == null)
{
return false;
} else if (this.closestLivingEntity.getDistanceSq(vec3.xCoord, vec3.yCoord, vec3.zCoord) < this.closestLivingEntity.getDistanceSqToEntity(this.theEntity))
{
return false;
} else
{
this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(vec3.xCoord, vec3.yCoord, vec3.zCoord);
return this.entityPathEntity != null && this.entityPathEntity.isDestinationSame(vec3);
}
}
return false;
}
示例9: shouldExecute
import net.minecraft.entity.ai.RandomPositionGenerator; //导入方法依赖的package包/类
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute() {
if (this.targetEntityClass == EntityPlayer.class) {
this.closestLivingEntity = this.theEntity.worldObj
.getClosestPlayerToEntity(this.theEntity,
(double) this.distanceFromEntity);
if (this.closestLivingEntity == null
|| this.closestLivingEntity
.getDistanceSqToEntity(theEntity) > 49) {
return false;
}
} else {
List<Entity> list = this.theEntity.worldObj
.selectEntitiesWithinAABB(this.targetEntityClass,
this.theEntity.boundingBox.expand(
(double) this.distanceFromEntity, 3.0D,
(double) this.distanceFromEntity),
this.selector);
if (list.isEmpty()) {
return false;
}
this.closestLivingEntity = (Entity) list.get(0);
}
Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockAwayFrom(
this.theEntity, 6, 4, Vec3.createVectorHelper(
this.closestLivingEntity.posX,
this.closestLivingEntity.posY,
this.closestLivingEntity.posZ));
if (vec3 == null) {
return false;
} else if (this.closestLivingEntity.getDistanceSq(vec3.xCoord,
vec3.yCoord, vec3.zCoord) < this.closestLivingEntity
.getDistanceSqToEntity(this.theEntity)) {
return false;
} else {
this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(
vec3.xCoord, vec3.yCoord, vec3.zCoord);
return this.entityPathEntity == null ? false
: this.entityPathEntity.isDestinationSame(vec3);
}
}
示例10: shouldExecute
import net.minecraft.entity.ai.RandomPositionGenerator; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public boolean shouldExecute() {
if (targetEntityClass != EntityMob.class) {
if (theEntity instanceof EntityTameable && ((EntityTameable) theEntity).isTamed()) {
return false;
}
closestLivingEntity = theEntity.worldObj.getClosestPlayerToEntity(theEntity, distanceFromEntity);
if (closestLivingEntity == null) {
return false;
}
} else {
List list = theEntity.worldObj.getEntitiesWithinAABB(targetEntityClass,
theEntity.boundingBox.expand(distanceFromEntity, 3.0D, distanceFromEntity));
if (list.isEmpty()) {
return false;
}
closestLivingEntity = (Entity) list.get(0);
}
if (!theEntity.getEntitySenses().canSee(closestLivingEntity)) {
return false;
} else {
Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockAwayFrom(theEntity,
16, 7, Vec3.createVectorHelper(
closestLivingEntity.posX,
closestLivingEntity.posY,
closestLivingEntity.posZ)
);
if (vec3 == null) {
return false;
} else if (closestLivingEntity.getDistanceSq(vec3.xCoord, vec3.yCoord, vec3.zCoord) < closestLivingEntity.getDistanceSqToEntity(theEntity)) {
return false;
} else {
entityPathEntity = entityPathNavigate.getPathToXYZ(
vec3.xCoord, vec3.yCoord, vec3.zCoord);
return entityPathEntity != null && entityPathEntity.isDestinationSame(vec3);
}
}
}