com.sk89q.worldedit.internal.LocalWorldAdapter Java Examples

The following examples show how to use com.sk89q.worldedit.internal.LocalWorldAdapter. 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: WorldEditListener.java    From FastAsyncWorldedit with GNU General Public License v3.0 7 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockBreak(BlockBreakEvent event) {
    final LocalPlayer player = plugin.wrapPlayer(event.getPlayer());
    final World world = player.getWorld();
    final WorldEdit we = WorldEdit.getInstance();
    final Block clickedBlock = event.getBlock();
    final WorldVector pos = new WorldVector(LocalWorldAdapter.adapt(world), clickedBlock.getX(), clickedBlock.getY(), clickedBlock.getZ());
    if (we.handleBlockLeftClick(player, pos)) {
        event.setCancelled(true);
    }
    if (we.handleArmSwing(player)) {
        event.setCancelled(true);
    }
}
 
Example #2
Source File: FaweForge.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public String getWorldName(World world) {
    if (world instanceof WorldWrapper) {
        return getWorldName(((WorldWrapper) world).getParent());
    }
    else if (world instanceof EditSession) {
        return getWorldName(((EditSession) world).getWorld());
    } else if (world.getClass().getName().equals("com.sk89q.worldedit.bukkit.BukkitWorld")) {
        try {
            Class<?> classBukkitWorld = world.getClass();
            Method methodGetWorld = classBukkitWorld.getDeclaredMethod("getWorld");
            methodGetWorld.setAccessible(true);
            Object craftWorld = methodGetWorld.invoke(world);
            Class<? extends Object> classCraftWorld = craftWorld.getClass();
            Method methodGetHandle = classCraftWorld.getDeclaredMethod("getHandle");
            methodGetHandle.setAccessible(true);
            Object nmsWorld = methodGetHandle.invoke(craftWorld);
            return getWorldName((net.minecraft.world.World) nmsWorld);
        } catch (Throwable e) {
            e.printStackTrace();
            return world.getName();
        }
    }else if (world instanceof LocalWorldAdapter){
        return world.getName();
    }
    return getWorldName(((ForgeWorld) world).getWorld());
}
 
Example #3
Source File: WorldWrapper.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public static World unwrap(World world) {
    if (world instanceof WorldWrapper) {
        return unwrap(((WorldWrapper) world).getParent());
    }
    if (world instanceof LocalWorldAdapter) {
        return unwrap(LocalWorldAdapter.unwrap(world));
    }
    else if (world instanceof EditSession) {
        return unwrap(((EditSession) world).getWorld());
    }
    return world;
}
 
Example #4
Source File: LocationMaskedPlayerWrapper.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public WorldVector getPosition() {
    LocalWorld world;
    if (position.getExtent() instanceof LocalWorld) {
        world = (LocalWorld) position.getExtent();
    } else {
        world = LocalWorldAdapter.adapt((World) position.getExtent());
    }
    return new WorldVector(world, position.toVector());
}
 
Example #5
Source File: GPActor.java    From GriefPrevention with MIT License 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public WorldVector getPosition() {
    return new WorldVector(LocalWorldAdapter.adapt(this.getWorld()), this.player.posX, this.player.posY, this.player.posZ);
}
 
Example #6
Source File: ForgePlayer.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public WorldVector getPosition() {
    return new WorldVector(LocalWorldAdapter.adapt(ForgeWorldEdit.inst.getWorld(this.player.worldObj)), this.player.posX, this.player.posY, this.player.posZ);
}
 
Example #7
Source File: SpongePlayer.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public WorldVector getPosition() {
    Vector3d pos = this.player.getLocation().getPosition();
    return new WorldVector(LocalWorldAdapter.adapt(SpongeWorldEdit.inst().getAdapter().getWorld(this.player.getWorld())), pos.getX(), pos.getY(), pos.getZ());
}
 
Example #8
Source File: ForgePlayer.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public WorldVector getPosition() {
    return new WorldVector(LocalWorldAdapter.adapt(ForgeWorldEdit.inst.getWorld(this.player.worldObj)), this.player.posX, this.player.posY, this.player.posZ);
}
 
Example #9
Source File: SpongePlayer.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public WorldVector getPosition() {
    Vector3d pos = this.player.getLocation().getPosition();
    return new WorldVector(LocalWorldAdapter.adapt(SpongeWorldEdit.inst().getAdapter().getWorld(this.player.getWorld())), pos.getX(), pos.getY(), pos.getZ());
}
 
Example #10
Source File: ForgePlayer.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public WorldVector getPosition() {
    return new WorldVector(LocalWorldAdapter.adapt(ForgeWorldEdit.inst.getWorld(this.player.world)), this.player.posX, this.player.posY, this.player.posZ);
}
 
Example #11
Source File: ForgePlayer.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public WorldVector getPosition() {
    return new WorldVector(LocalWorldAdapter.adapt(ForgeWorldEdit.inst.getWorld(this.player.worldObj)), this.player.posX, this.player.posY, this.player.posZ);
}
 
Example #12
Source File: ForgePlayer.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public WorldVector getPosition() {
    return new WorldVector(LocalWorldAdapter.adapt(ForgeWorldEdit.inst.getWorld(this.player.worldObj)), this.player.posX, this.player.posY, this.player.posZ);
}
 
Example #13
Source File: ForgePlayer.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public WorldVector getPosition() {
    return new WorldVector(LocalWorldAdapter.adapt(ForgeWorldEdit.inst.getWorld(this.player.world)), this.player.posX, this.player.posY, this.player.posZ);
}
 
Example #14
Source File: PlayerProxy.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public WorldVector getPosition() {
    WorldVector wv = this.basePlayer.getPosition();
    return new WorldVector(LocalWorldAdapter.wrap(world), wv.add(offset));
}
 
Example #15
Source File: TargetBlock.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor requiring a player, uses default values
 *
 * @param player player to work with
 */
public TargetBlock(LocalPlayer player) {
    this.world = LocalWorldAdapter.adapt(player.getWorld());
    this.setValues(player.getPosition(), player.getYaw(), player.getPitch(),
            300, 1.65, 0.2);
}
 
Example #16
Source File: TargetBlock.java    From FastAsyncWorldedit with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Constructor requiring a player, max distance and a checking distance
 *
 * @param player LocalPlayer to work with
 * @param maxDistance how far it checks for blocks
 * @param checkDistance how often to check for blocks, the smaller the more precise
 */
public TargetBlock(Player player, int maxDistance, double checkDistance) {
    this.world = LocalWorldAdapter.adapt(player.getWorld());
    this.setValues(player.getPosition(), player.getYaw(), player.getPitch(), maxDistance, 1.65, checkDistance);
}