Java Code Examples for org.bukkit.entity.Entity#teleport()
The following examples show how to use
org.bukkit.entity.Entity#teleport() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Scout.java From AnnihilationPro with MIT License | 6 votes |
private void pullEntityToLocation(Entity e, Location loc) { Location entityLoc = e.getLocation(); entityLoc.setY(entityLoc.getY() + 0.5D); e.teleport(entityLoc); double g = -0.08D; double d = loc.distance(entityLoc); double t = d; double v_x = (1.0D + 0.07000000000000001D * t) * (loc.getX() - entityLoc.getX()) / t; double v_y = (1.0D + 0.03D * t) * (loc.getY() - entityLoc.getY()) / t - 0.5D * g * t; double v_z = (1.0D + 0.07000000000000001D * t) * (loc.getZ() - entityLoc.getZ()) / t; Vector v = e.getVelocity(); v.setX(v_x); v.setY(v_y); v.setZ(v_z); e.setVelocity(v); //addNoFall(e, 100); }
Example 2
Source File: DebugCommand.java From civcraft with GNU General Public License v2.0 | 6 votes |
public void moveframes_cmd() throws CivException { Player player = getPlayer(); Chunk chunk = player.getLocation().getChunk(); // int x = this.getNamedInteger(1); // int y = this.getNamedInteger(2); // int z = this.getNamedInteger(3); // Location loc = new Location(player.getWorld(), x, y, z); for (Entity entity : chunk.getEntities()) { if (entity instanceof ItemFrame) { CivMessage.send(sender, "Teleported..."); entity.teleport(entity.getLocation()); } } }
Example 3
Source File: TelepositionScroll.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
@Override public ItemUseHandler getItemHandler() { return e -> { int range = radius.getValue(); for (Entity n : e.getPlayer().getNearbyEntities(range, range, range)) { if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !n.getUniqueId().equals(e.getPlayer().getUniqueId())) { float yaw = n.getLocation().getYaw() + 180F; if (yaw > 360F) { yaw = yaw - 360F; } n.teleport(new Location(n.getWorld(), n.getLocation().getX(), n.getLocation().getY(), n.getLocation().getZ(), yaw, n.getLocation().getPitch())); } } }; }
Example 4
Source File: SpigotWrapper.java From QuickShop-Reremake with GNU General Public License v3.0 | 5 votes |
@Override public void teleportEntity( @NotNull Entity entity, @NotNull Location location, @Nullable PlayerTeleportEvent.TeleportCause cause) { if (cause == null) { entity.teleport(location); } else { entity.teleport(location, cause); } }
Example 5
Source File: EffTeleport.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override protected void execute(final Event e) { Location to = location.getSingle(e); if (to == null) return; if (Math.abs(to.getX() - to.getBlockX() - 0.5) < Skript.EPSILON && Math.abs(to.getZ() - to.getBlockZ() - 0.5) < Skript.EPSILON) { final Block on = to.getBlock().getRelative(BlockFace.DOWN); if (on.getType() != Material.AIR) { to = to.clone(); // TODO 1.13 block height stuff //to.setY(on.getY() + Utils.getBlockHeight(on.getTypeId(), on.getData())); } } for (final Entity entity : entities.getArray(e)) { final Location loc; if (ignoreDirection(to.getYaw(), to.getPitch())) { loc = to.clone(); loc.setPitch(entity.getLocation().getPitch()); loc.setYaw(entity.getLocation().getYaw()); } else { loc = to; } loc.getChunk().load(); if (e instanceof PlayerRespawnEvent && entity.equals(((PlayerRespawnEvent) e).getPlayer()) && !Delay.isDelayed(e)) { ((PlayerRespawnEvent) e).setRespawnLocation(loc); } else { entity.teleport(loc); } } }
Example 6
Source File: InfusedHopper.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@Override public BlockTicker getItemHandler() { return new BlockTicker() { @Override public void tick(Block b, SlimefunItem sfItem, Config data) { if (b.getType() != Material.HOPPER) { // we're no longer a hopper, we were probably destroyed. skipping this tick. BlockStorage.clearBlockInfo(b); return; } Location l = b.getLocation().add(0.5, 1.2, 0.5); boolean sound = false; double range = radius.getValue(); for (Entity item : b.getWorld().getNearbyEntities(l, range, range, range, n -> isValidItem(l, n))) { item.setVelocity(new Vector(0, 0.1, 0)); item.teleport(l); sound = true; } if (sound && !silent.getValue().booleanValue()) { b.getWorld().playSound(b.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1F, 2F); } } @Override public boolean isSynchronized() { return true; } }; }
Example 7
Source File: Shuffle.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void effect(Event e, ItemStack item, final int level) { if(e instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; Entity target = event.getEntity(); Player p = (Player) ((Projectile) event.getDamager()).getShooter(); if(target.getEntityId() == p.getEntityId()) return; Location pLoc = p.getLocation(); Location tLoc = target.getLocation(); target.teleport(pLoc); p.teleport(tLoc); EffectManager.playSound(tLoc, "ENTITY_ENDERMAN_TELEPORT", 0.4f, 2f); EffectManager.playSound(pLoc, "ENTITY_ENDERMAN_TELEPORT", 0.4f, 2f); for(int i = 10; i>0; i--) { p.getWorld().playEffect(tLoc, Effect.ENDER_SIGNAL, 10); p.getWorld().playEffect(pLoc, Effect.ENDER_SIGNAL, 10); } if(target instanceof Player) { p.sendMessage(ChatColor.DARK_PURPLE + "You have switched positions with " + target.getName() + "!"); target.sendMessage(ChatColor.DARK_PURPLE + "You have switched positions with " + p.getName() + "!"); } } }
Example 8
Source File: TurnEffect.java From EffectLib with MIT License | 5 votes |
@Override public void onRun() { Entity entity = getEntity(); if (entity == null) { cancel(); return; } Location loc = entity.getLocation(); loc.setYaw(loc.getYaw() + step); entity.teleport(loc); }