@Override public Location getLocation() { org.spongepowered.api.world.Location<World> entityLoc = this.player.getLocation(); Vector3d entityRot = this.player.getRotation(); return SpongeWorldEdit.inst().getAdapter().adapt(entityLoc, entityRot); }
private static Vector3d getVelocity(Player player, double multiplier) { double yaw = ((player.getRotation().getY() + 90) % 360); double pitch = ((player.getRotation().getX()) * -1); double rotYCos = Math.cos(Math.toRadians(pitch)); double rotYSin = Math.sin(Math.toRadians(pitch)); double rotXCos = Math.cos(Math.toRadians(yaw)); double rotXSin = Math.sin(Math.toRadians(yaw)); double x = (multiplier * rotYCos) * rotXCos; double y = multiplier * rotYSin; double z = (multiplier * rotYCos) * rotXSin; return new Vector3d(x, y, z); }
public CachedPlayer(Player player) { super(player); this.uuid = UUID.fromString(player.getUniqueId().toString()); this.name = player.getName(); this.isOnline = true; this.location = new CachedLocation(player.getLocation()); this.rotation = player.getRotation().clone(); this.velocity = player.getVelocity().clone(); this.scale = player.getScale().clone(); this.address = player.getConnection().getAddress().toString(); this.latency = player.getConnection().getLatency(); // Collect unlocked advancements for (AdvancementTree tree : player.getUnlockedAdvancementTrees()) { addUnlockedAdvancements(player, tree.getRootAdvancement()); } // This will be moved to the other constructor once Sponge implements the offline inventory API this.helmet = player.getHelmet().map(ItemStack::copy).orElse(null); this.chestplate = player.getChestplate().map(ItemStack::copy).orElse(null); this.leggings = player.getLeggings().map(ItemStack::copy).orElse(null); this.boots = player.getBoots().map(ItemStack::copy).orElse(null); this.inventory = new CachedInventory(player.getInventory()); }
private void spawnFireball(Player player, boolean isLarge) { World world = player.getWorld(); Vector3d playerRot = player.getRotation(); Vector3d playerLoc = player.getLocation().getPosition(); Vector3d spawnLoc = playerLoc.add(Math.cos((playerRot.getY() - 90) % 360) * 0.2, 1.8,
private void sendUpdateSelf() { receiver.getTabList().removeEntry(receiver.getUniqueId()); receiver.getTabList().addEntry(TabListEntry.builder() .displayName(receiver.getDisplayNameData().displayName().get()) .latency(receiver.getConnection().getLatency()) .list(receiver.getTabList()) .gameMode(receiver.getGameModeData().type().get()) .profile(receiver.getProfile()) .build()); Location<World> oldLocation = receiver.getLocation(); Vector3d rotation = receiver.getRotation(); World receiverWorld = receiver.getWorld(); Sponge.getServer().getWorlds() .stream() .filter(world -> !world.equals(receiverWorld)) .findFirst() .ifPresent(world -> { receiver.setLocation(world.getSpawnLocation()); receiver.setLocationAndRotation(oldLocation, rotation); }); } }