Search in sources :

Example 1 with Location

use of com.sk89q.worldedit.util.Location in project FastAsyncWorldEdit by IntellectualSites.

the class MaskedTargetBlock method getMaskedTargetBlock.

public Location getMaskedTargetBlock(boolean useLastBlock) {
    boolean searchForLastBlock = true;
    Location lastBlock = null;
    while (getNextBlock() != null) {
        Location current = getCurrentBlock();
        if (!mask.test(current.toBlockPoint())) {
            if (searchForLastBlock) {
                lastBlock = current;
                if (lastBlock.getBlockY() <= world.getMinY() || lastBlock.getBlockY() >= world.getMaxY()) {
                    searchForLastBlock = false;
                }
            } else if (current.getBlockY() <= world.getMinY()) {
                break;
            }
        } else {
            break;
        }
    }
    Location currentBlock = getCurrentBlock();
    return currentBlock != null || !useLastBlock ? currentBlock : lastBlock;
}
Also used : Location(com.sk89q.worldedit.util.Location)

Example 2 with Location

use of com.sk89q.worldedit.util.Location in project FastAsyncWorldEdit by IntellectualSites.

the class MutableEntityChange method create.

public void create(UndoContext context) {
    Map<String, Tag> map = tag.getValue();
    Tag posTag = map.get("Pos");
    if (posTag == null) {
        LOGGER.warn("Missing pos tag: {}", tag);
        return;
    }
    List<DoubleTag> pos = (List<DoubleTag>) posTag.getValue();
    double x = pos.get(0).getValue();
    double y = pos.get(1).getValue();
    double z = pos.get(2).getValue();
    Extent extent = context.getExtent();
    Location location = new Location(extent, x, y, z, 0, 0);
    String id = tag.getString("Id");
    EntityType type = EntityTypes.parse(id);
    BaseEntity entity = new BaseEntity(type, tag);
    context.getExtent().createEntity(location, entity);
}
Also used : EntityType(com.sk89q.worldedit.world.entity.EntityType) Extent(com.sk89q.worldedit.extent.Extent) BaseEntity(com.sk89q.worldedit.entity.BaseEntity) List(java.util.List) DoubleTag(com.sk89q.jnbt.DoubleTag) CompoundTag(com.sk89q.jnbt.CompoundTag) Tag(com.sk89q.jnbt.Tag) LongTag(com.sk89q.jnbt.LongTag) DoubleTag(com.sk89q.jnbt.DoubleTag) Location(com.sk89q.worldedit.util.Location)

Example 3 with Location

use of com.sk89q.worldedit.util.Location in project FastAsyncWorldEdit by IntellectualSites.

the class HistorySubCommands method list.

@Command(name = "list", desc = "List your history")
@CommandPermissions("worldedit.history.list")
public void list(Player player, LocalSession session, RollbackDatabase database, Arguments arguments, @Arg(desc = "Player uuid/name") UUID other, @ArgFlag(name = 'p', desc = "Page to view.", def = "") Integer page) {
    int index = session.getHistoryIndex();
    List<Supplier<? extends ChangeSet>> history = Lists.transform(session.getHistory(), (Function<ChangeSet, Supplier<ChangeSet>>) input -> () -> input);
    Location origin = player.getLocation();
    String pageCommand = "/" + arguments.get().replaceAll("-p [0-9]+", "").trim();
    Reference<PaginationBox> cached = player.getMeta(pageCommand);
    PaginationBox pages = cached == null ? null : cached.get();
    if (page == null || pages == null) {
        pages = list(database, pageCommand, history, origin.toBlockPoint());
        page = 1;
    }
    player.print(pages.create(page));
}
Also used : BlockVector2(com.sk89q.worldedit.math.BlockVector2) BlockVector3(com.sk89q.worldedit.math.BlockVector3) RollbackDatabase(com.fastasyncworldedit.core.database.RollbackDatabase) Player(com.sk89q.worldedit.entity.Player) World(com.sk89q.worldedit.world.World) Fawe(com.fastasyncworldedit.core.Fawe) Caption(com.fastasyncworldedit.core.configuration.Caption) Arg(org.enginehub.piston.annotation.param.Arg) Time(com.sk89q.worldedit.command.util.annotation.Time) Component(com.sk89q.worldedit.util.formatting.text.Component) AllowedRegion(com.sk89q.worldedit.command.util.annotation.AllowedRegion) CommandContainer(org.enginehub.piston.annotation.CommandContainer) Location(com.sk89q.worldedit.util.Location) Function(com.google.common.base.Function) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions) Identifiable(com.sk89q.worldedit.util.Identifiable) UUID(java.util.UUID) Settings(com.fastasyncworldedit.core.configuration.Settings) Confirm(com.sk89q.worldedit.command.util.annotation.Confirm) ArgFlag(org.enginehub.piston.annotation.param.ArgFlag) Reference(java.lang.ref.Reference) Objects(java.util.Objects) TextComponentProducer(com.sk89q.worldedit.util.formatting.component.TextComponentProducer) List(java.util.List) SimpleChangeSetSummary(com.fastasyncworldedit.core.history.changeset.SimpleChangeSetSummary) CommandPermissionsConditionGenerator(com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator) PaginationBox(com.sk89q.worldedit.util.formatting.component.PaginationBox) Countable(com.sk89q.worldedit.util.Countable) RollbackOptimizedHistory(com.fastasyncworldedit.core.history.RollbackOptimizedHistory) MainUtil(com.fastasyncworldedit.core.util.MainUtil) ChangeSet(com.sk89q.worldedit.history.changeset.ChangeSet) Switch(org.enginehub.piston.annotation.param.Switch) HoverEvent(com.sk89q.worldedit.util.formatting.text.event.HoverEvent) Supplier(java.util.function.Supplier) TranslatableComponent(com.sk89q.worldedit.util.formatting.text.TranslatableComponent) StringMan(com.fastasyncworldedit.core.util.StringMan) Lists(com.google.common.collect.Lists) WorldEditException(com.sk89q.worldedit.WorldEditException) ClickEvent(com.sk89q.worldedit.util.formatting.text.event.ClickEvent) Direction(com.sk89q.worldedit.util.Direction) SoftReference(java.lang.ref.SoftReference) RegionWrapper(com.fastasyncworldedit.core.regions.RegionWrapper) Nonnull(javax.annotation.Nonnull) Region(com.sk89q.worldedit.regions.Region) Nullable(javax.annotation.Nullable) Range(org.jetbrains.annotations.Range) TextComponent(com.sk89q.worldedit.util.formatting.text.TextComponent) CommandUtil.checkCommandArgument(com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument) File(java.io.File) Actor(com.sk89q.worldedit.extension.platform.Actor) ExecutionException(java.util.concurrent.ExecutionException) Command(org.enginehub.piston.annotation.Command) DBHandler(com.fastasyncworldedit.core.database.DBHandler) Arguments(com.sk89q.worldedit.command.argument.Arguments) FaweAPI(com.fastasyncworldedit.core.FaweAPI) LocalSession(com.sk89q.worldedit.LocalSession) BlockState(com.sk89q.worldedit.world.block.BlockState) Supplier(java.util.function.Supplier) PaginationBox(com.sk89q.worldedit.util.formatting.component.PaginationBox) ChangeSet(com.sk89q.worldedit.history.changeset.ChangeSet) Location(com.sk89q.worldedit.util.Location) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 4 with Location

use of com.sk89q.worldedit.util.Location in project FastAsyncWorldEdit by IntellectualSites.

the class SelectionCommands method pos1.

@Command(name = "/pos1", aliases = "/1", desc = "Set position 1")
@Logging(POSITION)
@CommandPermissions("worldedit.selection.pos")
public void pos1(Actor actor, World world, LocalSession session, @Arg(desc = "Coordinates to set position 1 to", def = "") BlockVector3 coordinates) throws WorldEditException {
    Location pos;
    // FAWE start - clamp
    if (coordinates != null) {
        pos = new Location(world, coordinates.toVector3().clampY(world.getMinY(), world.getMaxY()));
    } else if (actor instanceof Locatable) {
        pos = ((Locatable) actor).getBlockLocation().clampY(world.getMinY(), world.getMaxY());
    // FAWE end
    } else {
        actor.print(Caption.of("worldedit.pos.console-require-coords"));
        return;
    }
    if (!session.getRegionSelector(world).selectPrimary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(actor))) {
        actor.print(Caption.of("worldedit.pos.already-set"));
        return;
    }
    session.getRegionSelector(world).explainPrimarySelection(actor, session, pos.toVector().toBlockPoint());
}
Also used : Location(com.sk89q.worldedit.util.Location) Locatable(com.sk89q.worldedit.extension.platform.Locatable) Logging(com.sk89q.worldedit.command.util.Logging) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 5 with Location

use of com.sk89q.worldedit.util.Location in project FastAsyncWorldEdit by IntellectualSites.

the class RegionCommands method nbtinfo.

@Command(name = "/nbtinfo", aliases = "/nbt", desc = "View nbt info for a block")
@CommandPermissions("worldedit.nbtinfo")
public void nbtinfo(Player player, EditSession editSession) {
    Location pos = player.getBlockTrace(128);
    if (pos == null) {
        player.print(Caption.of("fawe.navigation.no.block"));
        return;
    }
    CompoundTag nbt = editSession.getFullBlock(pos.toBlockPoint()).getNbtData();
    if (nbt != null) {
        player.print(TextComponent.of(nbt.getValue().toString()));
    } else {
        player.print(Caption.of("fawe.navigation.no.block"));
    }
}
Also used : CompoundTag(com.sk89q.jnbt.CompoundTag) Location(com.sk89q.worldedit.util.Location) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Aggregations

Location (com.sk89q.worldedit.util.Location)65 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)26 BaseEntity (com.sk89q.worldedit.entity.BaseEntity)12 CompoundTag (com.sk89q.jnbt.CompoundTag)11 World (com.sk89q.worldedit.world.World)11 Region (com.sk89q.worldedit.regions.Region)10 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)9 Command (org.enginehub.piston.annotation.Command)9 MutableBlockVector3 (com.fastasyncworldedit.core.math.MutableBlockVector3)8 Tag (com.sk89q.jnbt.Tag)8 List (java.util.List)8 ListTag (com.sk89q.jnbt.ListTag)7 Vector3 (com.sk89q.worldedit.math.Vector3)7 CuboidRegion (com.sk89q.worldedit.regions.CuboidRegion)7 BaseBlock (com.sk89q.worldedit.world.block.BaseBlock)7 StringTag (com.sk89q.jnbt.StringTag)6 Player (com.sk89q.worldedit.entity.Player)6 BlockVector2 (com.sk89q.worldedit.math.BlockVector2)6 BlockState (com.sk89q.worldedit.world.block.BlockState)6 IntTag (com.sk89q.jnbt.IntTag)5