本文整理汇总了Java中net.minecraft.entity.EntityLivingBase.attemptTeleport方法的典型用法代码示例。如果您正苦于以下问题:Java EntityLivingBase.attemptTeleport方法的具体用法?Java EntityLivingBase.attemptTeleport怎么用?Java EntityLivingBase.attemptTeleport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.EntityLivingBase
的用法示例。
在下文中一共展示了EntityLivingBase.attemptTeleport方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: teleport
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
* Teleports entities randomly up to 16 blocks away
* Copy of code from Enderman class
* Tries 10 times to teleport the entity before giving for this tick cycle
* @param entity Entity to be teleported
*/
private void teleport(EntityLivingBase entity) {
boolean moved = false; // Stores the status of teleportation attempts.
int counter = 0; // Used to prevent infinite loops.
while (!moved) {
counter++;
if (counter > 10) break; // Breaks out of a possible infinite loop.
// Implementation of Enderman random teleport code:
double newX = entity.posX + (this.rand.nextDouble() - 0.5D) * 64.0D;
double newY = entity.posY + (double)(this.rand.nextInt(64) - 32);
double newZ = entity.posZ + (this.rand.nextDouble() - 0.5D) * 64.0D;
moved = entity.attemptTeleport(newX, world.getTopSolidOrLiquidBlock(new BlockPos(newX, newY, newZ)).getY(), newZ);
}
// Reset loop controllers:
counter = 0;
moved = false;
}
示例2: performEffect
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void performEffect(RayTraceResult rtrace, EntityLivingBase caster, World world) {
if (caster != null && rtrace.typeOfHit == Type.BLOCK) {
BlockPos dest = rtrace.getBlockPos().offset(EnumFacing.UP);
caster.attemptTeleport(dest.getX() + 0.5, dest.getY() + 0.5, dest.getZ() + 0.5);
}
}
示例3: onItemUseFinish
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
* Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
* the Item before the action is complete.
*/
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
{
ItemStack itemstack = super.onItemUseFinish(stack, worldIn, entityLiving);
if (!worldIn.isRemote)
{
double d0 = entityLiving.posX;
double d1 = entityLiving.posY;
double d2 = entityLiving.posZ;
for (int i = 0; i < 16; ++i)
{
double d3 = entityLiving.posX + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D;
double d4 = MathHelper.clamp(entityLiving.posY + (double)(entityLiving.getRNG().nextInt(16) - 8), 0.0D, (double)(worldIn.getActualHeight() - 1));
double d5 = entityLiving.posZ + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D;
if (entityLiving.isRiding())
{
entityLiving.dismountRidingEntity();
}
if (entityLiving.attemptTeleport(d3, d4, d5))
{
worldIn.playSound((EntityPlayer)null, d0, d1, d2, SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
entityLiving.playSound(SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, 1.0F, 1.0F);
break;
}
}
if (entityLiving instanceof EntityPlayer)
{
((EntityPlayer)entityLiving).getCooldownTracker().setCooldown(this, 20);
}
}
return itemstack;
}
示例4: onItemUseFinish
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
* Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
* the Item before the action is complete.
*/
@Nullable
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
{
ItemStack itemstack = super.onItemUseFinish(stack, worldIn, entityLiving);
if (!worldIn.isRemote)
{
double d0 = entityLiving.posX;
double d1 = entityLiving.posY;
double d2 = entityLiving.posZ;
for (int i = 0; i < 16; ++i)
{
double d3 = entityLiving.posX + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D;
double d4 = MathHelper.clamp_double(entityLiving.posY + (double)(entityLiving.getRNG().nextInt(16) - 8), 0.0D, (double)(worldIn.getActualHeight() - 1));
double d5 = entityLiving.posZ + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D;
if (entityLiving.isRiding())
{
entityLiving.dismountRidingEntity();
}
if (entityLiving.attemptTeleport(d3, d4, d5))
{
worldIn.playSound((EntityPlayer)null, d0, d1, d2, SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
entityLiving.playSound(SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, 1.0F, 1.0F);
break;
}
}
if (entityLiving instanceof EntityPlayer)
{
((EntityPlayer)entityLiving).getCooldownTracker().setCooldown(this, 20);
}
}
return itemstack;
}