本文整理汇总了Java中org.bukkit.event.entity.EntityTeleportEvent.isCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java EntityTeleportEvent.isCancelled方法的具体用法?Java EntityTeleportEvent.isCancelled怎么用?Java EntityTeleportEvent.isCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.EntityTeleportEvent
的用法示例。
在下文中一共展示了EntityTeleportEvent.isCancelled方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: teleport
import org.bukkit.event.entity.EntityTeleportEvent; //导入方法依赖的package包/类
/**
* Teleport an entity and the vehicle it is inside of, or vice versa.
*
* @param entity The entity/vehicle to be teleported.
* @param to The destination.
*/
public static void teleport(final Entity entity, final Location to) {
EntityTeleportEvent event = new EntityTeleportEvent(entity, entity.getLocation(), to);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) return;
if (entity.isInsideVehicle()) {
Entity vehicle = entity.getVehicle();
vehicle.eject();
vehicle.teleport(to);
entity.teleport(to);
vehicle.setPassenger(entity);
} else if (entity.getPassenger() != null) {
Entity passenger = entity.getPassenger();
entity.eject();
entity.teleport(to);
passenger.teleport(to);
entity.setPassenger(passenger);
} else entity.teleport(to);
}
示例2: teleport
import org.bukkit.event.entity.EntityTeleportEvent; //导入方法依赖的package包/类
/**
* Teleport an entity and the vehicle it is inside of, or vice versa.
*
* @param entity The entity/vehicle to be teleported.
* @param to The destination.
*/
public static void teleport(final Entity entity, final Location to) {
EntityTeleportEvent event = new EntityTeleportEvent(entity, entity.getLocation(), to);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) return;
if (entity.isInsideVehicle()) {
Entity vehicle = entity.getVehicle();
vehicle.eject();
vehicle.teleport(to);
entity.teleport(to);
vehicle.setPassenger(entity);
} else if (entity.getPassenger() != null) {
Entity passenger = entity.getPassenger();
entity.eject();
entity.teleport(to);
passenger.teleport(to);
entity.setPassenger(passenger);
} else { entity.teleport(to); }
}
示例3: 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;
}
示例4: 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;
}
}