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


Java EntityTeleportEvent.getTo方法代码示例

本文整理汇总了Java中org.bukkit.event.entity.EntityTeleportEvent.getTo方法的典型用法代码示例。如果您正苦于以下问题:Java EntityTeleportEvent.getTo方法的具体用法?Java EntityTeleportEvent.getTo怎么用?Java EntityTeleportEvent.getTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.entity.EntityTeleportEvent的用法示例。


在下文中一共展示了EntityTeleportEvent.getTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: attemptEnderTeleport

import org.bukkit.event.entity.EntityTeleportEvent; //导入方法依赖的package包/类
private boolean attemptEnderTeleport(EntityHuman entity, final double x, final double y, final double z) {
    final double prevX = entity.locX;
    final double prevY = entity.locY;
    final double prevZ = entity.locZ;
    entity.locX = x;
    entity.locY = y;
    entity.locZ = z;
    boolean success = false;
    BlockPosition blockposition = new BlockPosition(entity.locX, entity.locY, entity.locZ);
    if (entity.world.isLoaded(blockposition)) {
        boolean foundPos = false;
        while (!foundPos && (blockposition.getY() > 0)) {
            final BlockPosition blockposition2 = blockposition.down();
            final Block block = entity.world.getType(blockposition2).getBlock();
            if (block.getMaterial().isSolid()) {
                foundPos = true;
            } else {
                --entity.locY;
                blockposition = blockposition2;
            }
        }
        if (foundPos) {
            final EntityTeleportEvent teleport = new EntityTeleportEvent(entity.getBukkitEntity(), new Location(entity.world.getWorld(), prevX, prevY, prevZ), new Location(entity.world.getWorld(), entity.locX, entity.locY, entity.locZ));
            entity.world.getServer().getPluginManager().callEvent(teleport);
            if (teleport.isCancelled()) {
                return false;
            }
            final Location to = teleport.getTo();
            entity.enderTeleportTo(to.getX(), to.getY(), to.getZ());
            if (entity.world.getCubes(entity, entity.getBoundingBox()).isEmpty() && !entity.world.containsLiquid(entity.getBoundingBox())) {
                success = true;
            }
        }
    }
    if (!success) {
        entity.setPosition(prevX, prevY, prevZ);
        return false;
    }
    final short count = 128;
    for (int i = 0; i < count; ++i) {
        final double d6 = i / (count - 1.0);
        final float spreadX = (entity.bc().nextFloat() - 0.5f) * 0.2f;
        final float spreadY = (entity.bc().nextFloat() - 0.5f) * 0.2f;
        final float spreadZ = (entity.bc().nextFloat() - 0.5f) * 0.2f;
        final double pX = prevX + ((entity.locX - prevX) * d6) + ((entity.bc().nextDouble() - 0.5) * entity.width * 2.0);
        final double pY = prevY + ((entity.locY - prevY) * d6) + (entity.bc().nextDouble() * entity.length);
        final double pZ = prevZ + ((entity.locZ - prevZ) * d6) + ((entity.bc().nextDouble() - 0.5) * entity.width * 2.0);
        entity.world.addParticle(EnumParticle.PORTAL, pX, pY, pZ, spreadX, spreadY, spreadZ);
    }
    entity.world.makeSound(prevX, prevY, prevZ, "mob.endermen.portal", 1.0f, 1.0f);
    entity.makeSound("mob.endermen.portal", 1.0f, 1.0f);
    return true;
}
 
开发者ID:MCCarbon,项目名称:Carbon-2,代码行数:54,代码来源:ItemChorusFruit.java

示例2: k

import org.bukkit.event.entity.EntityTeleportEvent; //导入方法依赖的package包/类
public boolean k(double d0, double d1, double d2) {
    double d3 = this.locX;
    double d4 = this.locY;
    double d5 = this.locZ;

    this.locX = d0;
    this.locY = d1;
    this.locZ = d2;
    boolean flag = false;
    BlockPosition blockposition = new BlockPosition(this);
    World world = this.world;
    Random random = this.getRandom();

    if (world.isLoaded(blockposition)) {
        boolean flag1 = false;

        while (!flag1 && blockposition.getY() > 0) {
            BlockPosition blockposition1 = blockposition.down();
            IBlockData iblockdata = world.getType(blockposition1);

            if (iblockdata.getMaterial().isSolid()) {
                flag1 = true;
            } else {
                --this.locY;
                blockposition = blockposition1;
            }
        }

        if (flag1) {
            // CraftBukkit start - Teleport event
            // this.enderTeleportTo(this.locX, this.locY, this.locZ);
            EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), new Location(this.world.getWorld(), d3, d4, d5), new Location(this.world.getWorld(), this.locX, this.locY, this.locZ));
            this.world.getServer().getPluginManager().callEvent(teleport);
            if (teleport.isCancelled()) {
                return false;
            }

            Location to = teleport.getTo();
            this.enderTeleportTo(to.getX(), to.getY(), to.getZ());
            // CraftBukkit end
            if (world.getCubes(this, this.getBoundingBox()).isEmpty() && !world.containsLiquid(this.getBoundingBox())) {
                flag = true;
            }
        }
    }

    if (!flag) {
        this.enderTeleportTo(d3, d4, d5);
        return false;
    } else {
        short short0 = 128;

        for (int i = 0; i < short0; ++i) {
            double d6 = (double) i / ((double) short0 - 1.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 d7 = d3 + (this.locX - d3) * d6 + (random.nextDouble() - 0.5D) * (double) this.width * 2.0D;
            double d8 = d4 + (this.locY - d4) * d6 + random.nextDouble() * (double) this.length;
            double d9 = d5 + (this.locZ - d5) * d6 + (random.nextDouble() - 0.5D) * (double) this.width * 2.0D;

            world.addParticle(EnumParticle.PORTAL, d7, d8, d9, (double) f, (double) f1, (double) f2, new int[0]);
        }

        if (this instanceof EntityCreature) {
            ((EntityCreature) this).getNavigation().o();
        }

        return true;
    }
}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:72,代码来源:EntityLiving.java

示例3: onEntityTeleport

import org.bukkit.event.entity.EntityTeleportEvent; //导入方法依赖的package包/类
@EventHandler (ignoreCancelled = true)
public void onEntityTeleport(EntityTeleportEvent event) {
	Location loc = event.getTo();
	if (Util.getQuadtree(loc).contains(loc))
		event.setCancelled(true);
}
 
开发者ID:catageek,项目名称:BCProtect,代码行数:7,代码来源:MobListener.java


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