java containsany_Java World.containsAnyLiquid方法代码示例

import net.minecraft.world.World; //导入方法依赖的package包/类

/**

* Teleports the entity to the specified location. Used for Enderman and Chorus Fruit teleportation

*/

public boolean attemptTeleport(double x, double y, double z)

{

double d0 = this.posX;

double d1 = this.posY;

double d2 = this.posZ;

this.posX = x;

this.posY = y;

this.posZ = z;

boolean flag = false;

BlockPos blockpos = new BlockPos(this);

World world = this.worldObj;

Random random = this.getRNG();

if (world.isBlockLoaded(blockpos))

{

boolean flag1 = false;

while (!flag1 && blockpos.getY() > 0)

{

BlockPos blockpos1 = blockpos.down();

IBlockState iblockstate = world.getBlockState(blockpos1);

if (iblockstate.getMaterial().blocksMovement())

{

flag1 = true;

}

else

{

--this.posY;

blockpos = blockpos1;

}

}

if (flag1)

{

this.setPositionAndUpdate(this.posX, this.posY, this.posZ);

if (world.getCollisionBoxes(this, this.getEntityBoundingBox()).isEmpty() && !world.containsAnyLiquid(this.getEntityBoundingBox()))

{

flag = true;

}

}

}

if (!flag)

{

this.setPositionAndUpdate(d0, d1, d2);

return false;

}

else

{

int i = 128;

for (int j = 0; j < 128; ++j)

{

double d6 = (double)j / 127.0D;

float f = (random.nextFloat() - 0.5F) * 0.2F;

float f1 = (random.nextFloat() - 0.5F) * 0.2F;

float f2 = (random.nextFloat() - 0.5F) * 0.2F;

double d3 = d0 + (this.posX - d0) * d6 + (random.nextDouble() - 0.5D) * (double)this.width * 2.0D;

double d4 = d1 + (this.posY - d1) * d6 + random.nextDouble() * (double)this.height;

double d5 = d2 + (this.posZ - d2) * d6 + (random.nextDouble() - 0.5D) * (double)this.width * 2.0D;

world.spawnParticle(EnumParticleTypes.PORTAL, d3, d4, d5, (double)f, (double)f1, (double)f2, new int[0]);

}

if (this instanceof EntityCreature)

{

((EntityCreature)this).getNavigator().clearPathEntity();

}

return true;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值