当前位置: 首页>>代码示例>>Java>>正文


Java EntityLivingBase.attemptTeleport方法代码示例

本文整理汇总了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;
}
 
开发者ID:Maxwell-lt,项目名称:MobBlocker,代码行数:25,代码来源:TileEntityChunkProtector.java

示例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);
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:8,代码来源:SpellBlink.java

示例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;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:42,代码来源:ItemChorusFruit.java

示例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;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:43,代码来源:ItemChorusFruit.java


注:本文中的net.minecraft.entity.EntityLivingBase.attemptTeleport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。