Search in sources :

Example 6 with Entity

use of com.sk89q.worldedit.entity.Entity in project PixelsSkyblock by dudullle.

the class OnislandObjective method check.

@Override
public boolean check(Player p, Island i) {
    if (!type) {
        List<Countable<Integer>> blocks = WEManager.count(Bukkit.getWorld("world"), i.getEdges().get(0), i.getEdges().get(1));
        for (Countable<Integer> b : blocks) {
            if (b.getID() == mat_ID && b.getAmount() >= quantity) {
                return true;
            } else if (b.getID() == mat_ID) {
                calculated_nb = b.getAmount();
            }
        }
        return false;
    } else {
        try {
            List<Entity> es = (List<Entity>) WEManager.count_entities(Bukkit.getWorld("world"), i.getEdges().get(0), i.getEdges().get(1));
            int qte = 0;
            for (Entity e : es) {
                try {
                    if (e.getState().getTypeId().toString().equalsIgnoreCase(it_name)) {
                        qte += 1;
                    }
                } catch (Exception ex) {
                }
            }
            calculated_nb = qte;
            if (qte >= quantity) {
                return true;
            }
        } catch (Exception ex) {
        }
    }
    return false;
}
Also used : Countable(com.sk89q.worldedit.util.Countable) Entity(com.sk89q.worldedit.entity.Entity) List(java.util.List)

Example 7 with Entity

use of com.sk89q.worldedit.entity.Entity in project FastAsyncWorldEdit by IntellectualSites.

the class TracingExtent method createEntity.

@Nullable
@Override
public Entity createEntity(Location location, BaseEntity entity) {
    BlockVector3 blockVector3 = location.toVector().toBlockPoint();
    touchedLocations.add(blockVector3);
    Entity result = super.createEntity(location, entity);
    if (result == null) {
        failedActions.put(blockVector3, Action.CREATE_ENTITY);
    }
    return result;
}
Also used : Entity(com.sk89q.worldedit.entity.Entity) BaseEntity(com.sk89q.worldedit.entity.BaseEntity) BlockVector3(com.sk89q.worldedit.math.BlockVector3) Nullable(javax.annotation.Nullable)

Example 8 with Entity

use of com.sk89q.worldedit.entity.Entity in project FastAsyncWorldEdit by IntellectualSites.

the class ConsumeBindings method baseBlock.

@Binding
public BaseBlock baseBlock(Actor actor, String argument) {
    ParserContext parserContext = new ParserContext();
    parserContext.setActor(actor);
    if (actor instanceof Entity) {
        Extent extent = ((Entity) actor).getExtent();
        if (extent instanceof World) {
            parserContext.setWorld((World) extent);
        }
    }
    parserContext.setSession(getWorldEdit().getSessionManager().get(actor));
    try {
        return getWorldEdit().getBlockFactory().parseFromInput(argument, parserContext);
    } catch (NoMatchException e) {
        throw new InputParseException(TextComponent.of(e.getMessage()));
    }
}
Also used : Entity(com.sk89q.worldedit.entity.Entity) InputParseException(com.sk89q.worldedit.extension.input.InputParseException) Extent(com.sk89q.worldedit.extent.Extent) ParserContext(com.sk89q.worldedit.extension.input.ParserContext) World(com.sk89q.worldedit.world.World) NoMatchException(com.sk89q.worldedit.extension.input.NoMatchException)

Example 9 with Entity

use of com.sk89q.worldedit.entity.Entity in project bteConoSurCore by BTEConoSur.

the class Polywall method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (command.getName().equals("/polywalls")) {
        if (sender instanceof Player) {
            Player p = (Player) sender;
            // 
            // GET REGION
            Region region = null;
            try {
                region = getSelection(p);
            } catch (IncompleteRegionException e) {
                p.sendMessage(wePrefix + "Selecciona un área primero.");
                return true;
            }
            if (args.length > 0) {
                // PARSE PATTERN
                com.sk89q.worldedit.entity.Player actor = new BukkitPlayer((WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"), ((WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit")).getServerInterface(), p);
                LocalSession localSession = WorldEdit.getInstance().getSessionManager().get(actor);
                Mask mask = localSession.getMask();
                ParserContext parserContext = new ParserContext();
                parserContext.setActor(actor);
                Extent extent = ((Entity) actor).getExtent();
                if (extent instanceof World) {
                    parserContext.setWorld((World) extent);
                }
                parserContext.setSession(WorldEdit.getInstance().getSessionManager().get(actor));
                Pattern pattern;
                try {
                    pattern = WorldEdit.getInstance().getPatternFactory().parseFromInput(args[0], parserContext);
                } catch (InputParseException e) {
                    p.sendMessage(wePrefix + "Patrón inválido.");
                    return true;
                }
                // GET POINTS
                List<BlockVector2D> points = new ArrayList<>();
                int maxY;
                int minY;
                if (region instanceof CuboidRegion) {
                    CuboidRegion cuboidRegion = (CuboidRegion) region;
                    Vector first = cuboidRegion.getPos1();
                    Vector second = cuboidRegion.getPos2();
                    maxY = cuboidRegion.getMaximumY();
                    minY = cuboidRegion.getMinimumY();
                    points.add(new BlockVector2D(first.getX(), first.getZ()));
                    points.add(new BlockVector2D(second.getX(), first.getZ()));
                    points.add(new BlockVector2D(second.getX(), second.getZ()));
                    points.add(new BlockVector2D(first.getX(), second.getZ()));
                } else if (region instanceof Polygonal2DRegion) {
                    maxY = ((Polygonal2DRegion) region).getMaximumY();
                    minY = ((Polygonal2DRegion) region).getMinimumY();
                    points = ((Polygonal2DRegion) region).getPoints();
                } else {
                    p.sendMessage(wePrefix + "Debes seleccionar una region cúbica o poligonal.");
                    return true;
                }
                if (points.size() < 3) {
                    p.sendMessage(wePrefix + "Selecciona un área primero.");
                    return true;
                }
                List<BlockVector2D> pointsFinal = new ArrayList<>(points);
                pointsFinal.add(points.get(0));
                EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession((World) new BukkitWorld(mainWorld), WorldEdit.getInstance().getSessionManager().get(actor).getBlockChangeLimit());
                for (int i = minY; i <= maxY; i++) {
                    for (int j = 0; j < pointsFinal.size() - 1; j++) {
                        BlockVector2D v1 = pointsFinal.get(j);
                        BlockVector2D v2 = pointsFinal.get(j + 1);
                        setBlocksInLine(p, actor, editSession, pattern, mask, v1.toVector(i), v2.toVector(i));
                    }
                }
                p.sendMessage(wePrefix + "Paredes de la selección creadas.");
            } else {
                p.sendMessage(wePrefix + "Introduce un patrón de bloques.");
            }
        }
    }
    return true;
}
Also used : Entity(com.sk89q.worldedit.entity.Entity) Pattern(com.sk89q.worldedit.function.pattern.Pattern) BukkitPlayer(com.sk89q.worldedit.bukkit.BukkitPlayer) Player(org.bukkit.entity.Player) Extent(com.sk89q.worldedit.extent.Extent) Mask(com.sk89q.worldedit.function.mask.Mask) ArrayList(java.util.ArrayList) BukkitWorld(com.sk89q.worldedit.bukkit.BukkitWorld) CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) BteConoSur.mainWorld(pizzaaxx.bteconosur.BteConoSur.mainWorld) World(com.sk89q.worldedit.world.World) BukkitWorld(com.sk89q.worldedit.bukkit.BukkitWorld) BukkitPlayer(com.sk89q.worldedit.bukkit.BukkitPlayer) InputParseException(com.sk89q.worldedit.extension.input.InputParseException) Polygonal2DRegion(com.sk89q.worldedit.regions.Polygonal2DRegion) Polygonal2DRegion(com.sk89q.worldedit.regions.Polygonal2DRegion) CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) Region(com.sk89q.worldedit.regions.Region) ParserContext(com.sk89q.worldedit.extension.input.ParserContext)

Aggregations

Entity (com.sk89q.worldedit.entity.Entity)9 BaseEntity (com.sk89q.worldedit.entity.BaseEntity)4 Extent (com.sk89q.worldedit.extent.Extent)4 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)4 Region (com.sk89q.worldedit.regions.Region)4 World (com.sk89q.worldedit.world.World)4 CompoundTag (com.sk89q.jnbt.CompoundTag)3 Location (com.sk89q.worldedit.util.Location)3 BaseBlock (com.sk89q.worldedit.world.block.BaseBlock)3 BlockState (com.sk89q.worldedit.world.block.BlockState)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 ListTag (com.sk89q.jnbt.ListTag)2 StringTag (com.sk89q.jnbt.StringTag)2 Tag (com.sk89q.jnbt.Tag)2 InputParseException (com.sk89q.worldedit.extension.input.InputParseException)2 ParserContext (com.sk89q.worldedit.extension.input.ParserContext)2 CuboidRegion (com.sk89q.worldedit.regions.CuboidRegion)2 HashMap (java.util.HashMap)2 SimpleClipboard (com.fastasyncworldedit.core.extent.clipboard.SimpleClipboard)1