当前位置: 首页>>代码示例>>Java>>正文


Java EditSession.setBlock方法代码示例

本文整理汇总了Java中com.sk89q.worldedit.EditSession.setBlock方法的典型用法代码示例。如果您正苦于以下问题:Java EditSession.setBlock方法的具体用法?Java EditSession.setBlock怎么用?Java EditSession.setBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sk89q.worldedit.EditSession的用法示例。


在下文中一共展示了EditSession.setBlock方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: actPrimary

import com.sk89q.worldedit.EditSession; //导入方法依赖的package包/类
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
    World world = (World) clicked.getExtent();
    final int blockType = world.getBlockType(clicked.toVector());
    if (blockType == BlockID.BEDROCK
            && !player.canDestroyBedrock()) {
        return true;
    }

    EditSession editSession = session.createEditSession(player);
    editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop);

    try {
        if (editSession.setBlock(clicked.getBlockX(), clicked.getBlockY(), clicked.getBlockZ(), EditSession.nullBlock)) {
            world.playEffect(clicked.toVector(), 2001, blockType);
        }
    } finally {
        editSession.flushQueue();
        session.remember(editSession);
    }

    return true;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:24,代码来源:SinglePickaxe.java

示例2: apply

import com.sk89q.worldedit.EditSession; //导入方法依赖的package包/类
@Override
public void apply(EditSession editSession, LocalBlockVectorSet placed, Vector pt, Pattern p, double size) throws MaxChangedBlocksException {
    int x = pt.getBlockX();
    int y = pt.getBlockY();
    int z = pt.getBlockZ();
    Vector dir = getDirection(pt);
    dir.setComponents(x + dir.getBlockX(), y + dir.getBlockY(), z + dir.getBlockZ());
    editSession.setBlock(dir, p);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:10,代码来源:ScatterOverlayBrush.java

示例3: build

import com.sk89q.worldedit.EditSession; //导入方法依赖的package包/类
@Override
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
    SurfaceMask surface = new SurfaceMask(editSession);
    final SolidBlockMask solid = new SolidBlockMask(editSession);
    final RadiusMask radius = new RadiusMask(0, (int) size);
    RecursiveVisitor visitor = new RecursiveVisitor(vector -> surface.test(vector) && radius.test(vector), vector -> editSession.setBlock(vector, pattern));
    visitor.visit(position);
    visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
    Operations.completeBlindly(visitor);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:11,代码来源:SurfaceSphereBrush.java

示例4: build

import com.sk89q.worldedit.EditSession; //导入方法依赖的package包/类
@Override
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
    double seedX = ThreadLocalRandom.current().nextDouble();
    double seedY = ThreadLocalRandom.current().nextDouble();
    double seedZ = ThreadLocalRandom.current().nextDouble();

    int px = position.getBlockX();
    int py = position.getBlockY();
    int pz = position.getBlockZ();

    double distort = this.frequency / size;

    double modX = 1d/radius.getX();
    double modY = 1d/radius.getY();
    double modZ = 1d/radius.getZ();

    int radiusSqr = (int) (size * size);
    int sizeInt = (int) size * 2;
    for (int x = -sizeInt; x <= sizeInt; x++) {
        double nx = seedX + x * distort;
        double d1 = x * x * modX;
        for (int y = -sizeInt; y <= sizeInt; y++) {
            double d2 = d1 + y * y * modY;
            double ny = seedY + y * distort;
            for (int z = -sizeInt; z <= sizeInt; z++) {
                double nz = seedZ + z * distort;
                double distance = d2 + z * z * modZ;
                double noise = this.amplitude * SimplexNoise.noise(nx, ny, nz);
                if (distance + distance * noise < radiusSqr) {
                    editSession.setBlock(px + x, py + y, pz + z, pattern);
                }
            }
        }
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:36,代码来源:RockBrush.java

示例5: recurse

import com.sk89q.worldedit.EditSession; //导入方法依赖的package包/类
private void recurse(Platform server, EditSession editSession, World world, BlockVector pos, Vector origin, int size, int initialType,
                     Set<BlockVector> visited) throws WorldEditException {

    if (origin.distance(pos) > size || visited.contains(pos)) {
        return;
    }

    visited.add(pos);

    if (editSession.getBlock(pos).getType() == initialType) {
        editSession.setBlock(pos, pattern);
    } else {
        return;
    }

    recurse(server, editSession, world, pos.add(1, 0, 0).toBlockVector(),
            origin, size, initialType, visited);
    recurse(server, editSession, world, pos.add(-1, 0, 0).toBlockVector(),
            origin, size, initialType, visited);
    recurse(server, editSession, world, pos.add(0, 0, 1).toBlockVector(),
            origin, size, initialType, visited);
    recurse(server, editSession, world, pos.add(0, 0, -1).toBlockVector(),
            origin, size, initialType, visited);
    recurse(server, editSession, world, pos.add(0, 1, 0).toBlockVector(),
            origin, size, initialType, visited);
    recurse(server, editSession, world, pos.add(0, -1, 0).toBlockVector(),
            origin, size, initialType, visited);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:29,代码来源:FloodFillTool.java

示例6: build

import com.sk89q.worldedit.EditSession; //导入方法依赖的package包/类
@Override
public void build(EditSession editSession, Vector position, Pattern pattern, double sizeDouble) throws MaxChangedBlocksException {
    Mask mask = editSession.getMask();
    if (mask == Masks.alwaysTrue() || mask == Masks.alwaysTrue2D()) {
        mask = null;
    }
    int size = (int) sizeDouble;
    int endY = position.getBlockY() + size;
    int startPerformY = Math.max(0, position.getBlockY() - size);
    int startCheckY = fullHeight ? 0 : startPerformY;
    Vector mutablePos = new Vector(0, 0, 0);
    for (int x = position.getBlockX() + size; x > position.getBlockX() - size; --x) {
        for (int z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) {
            int freeSpot = startCheckY;
            for (int y = startCheckY; y <= endY; y++) {
                BaseBlock block = editSession.getLazyBlock(x, y, z);
                if (block.getId() != 0) {
                    if (y != freeSpot) {
                        editSession.setBlock(x, y, z, EditSession.nullBlock);
                        editSession.setBlock(x, freeSpot, z, block);
                    }
                    freeSpot = y + 1;
                }
            }
        }
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:28,代码来源:GravityBrush.java

示例7: actPrimary

import com.sk89q.worldedit.EditSession; //导入方法依赖的package包/类
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
    int ox = clicked.getBlockX();
    int oy = clicked.getBlockY();
    int oz = clicked.getBlockZ();
    int initialType = ((World) clicked.getExtent()).getBlockType(clicked.toVector());

    if (initialType == 0) {
        return true;
    }

    if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) {
        return true;
    }

    EditSession editSession = session.createEditSession(player);
    editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);

    for (int x = ox - range; x <= ox + range; ++x) {
        for (int y = oy - range; y <= oy + range; ++y) {
            for (int z = oz - range; z <= oz + range; ++z) {
                if (editSession.getLazyBlock(x, y, z).getId() != initialType) {
                    continue;
                }
                editSession.setBlock(x, y, z, air);
            }
        }
    }
    editSession.flushQueue();
    session.remember(editSession);

    return true;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:34,代码来源:AreaPickaxe.java

示例8: build

import com.sk89q.worldedit.EditSession; //导入方法依赖的package包/类
@Override
public void build(EditSession editSession, Vector pos, Pattern pattern, double radius) throws MaxChangedBlocksException {
    int maxY = editSession.getMaxY();
    boolean vis = editSession.getExtent() instanceof VisualExtent;
    if (path.isEmpty() || !pos.equals(path.get(path.size() - 1))) {
        int max = editSession.getNearestSurfaceTerrainBlock(pos.getBlockX(), pos.getBlockZ(), pos.getBlockY(), 0, editSession.getMaxY());
        if (max == -1) return;
        pos.mutY(max);
        path.add(pos);
        editSession.getPlayer().sendMessage(BBC.getPrefix() + BBC.BRUSH_SPLINE_PRIMARY_2.s());
        if (!vis) return;
    }
    LocalBlockVectorSet vset = new LocalBlockVectorSet();
    final List<Node> nodes = new ArrayList<>(path.size());
    final KochanekBartelsInterpolation interpol = new KochanekBartelsInterpolation();

    for (final Vector nodevector : path) {
        final Node n = new Node(nodevector);
        n.setTension(tension);
        n.setBias(bias);
        n.setContinuity(continuity);
        nodes.add(n);
    }
    interpol.setNodes(nodes);
    final double splinelength = interpol.arcLength(0, 1);
    for (double loop = 0; loop <= 1; loop += 1D / splinelength / quality) {
        final Vector tipv = interpol.getPosition(loop);
        final int tipx = MathMan.roundInt(tipv.getX());
        final int tipz = (int) tipv.getZ();
        int tipy = MathMan.roundInt(tipv.getY());
        tipy = editSession.getNearestSurfaceTerrainBlock(tipx, tipz, tipy, 0, maxY);
        if (tipy == -1) continue;
        if (radius == 0) {
            editSession.setBlock(tipx, tipy, tipz, pattern.next(tipx, tipy, tipz));
        } else {
            vset.add(tipx, tipy, tipz);
        }
    }
    if (radius != 0) {
        double radius2 = (radius * radius);
        LocalBlockVectorSet newSet = new LocalBlockVectorSet();
        final int ceilrad = (int) Math.ceil(radius);
        for (final Vector v : vset) {
            final int tipx = v.getBlockX(), tipy = v.getBlockY(), tipz = v.getBlockZ();
            for (int loopx = tipx - ceilrad; loopx <= (tipx + ceilrad); loopx++) {
                for (int loopz = tipz - ceilrad; loopz <= (tipz + ceilrad); loopz++) {
                    if (MathMan.hypot2(loopx - tipx, 0, loopz - tipz) <= radius2) {
                        int y = editSession.getNearestSurfaceTerrainBlock(loopx, loopz, v.getBlockY(), 0, maxY);
                        if (y == -1) continue;
                        newSet.add(loopx, y, loopz);
                    }
                }
            }
        }
        editSession.setBlocks(newSet, pattern);
        if (!vis) path.clear();
    }
    editSession.getPlayer().sendMessage(BBC.getPrefix() + BBC.BRUSH_SPLINE_SECONDARY.s());
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:60,代码来源:SurfaceSpline.java

示例9: build

import com.sk89q.worldedit.EditSession; //导入方法依赖的package包/类
@Override
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
    final int outsetSize = (int) (size + 1);
    double brushSizeSquared = size * size;

    int tx = position.getBlockX();
    int ty = position.getBlockY();
    int tz = position.getBlockZ();

    Map<BaseBlock, Integer> frequency = Maps.newHashMap();

    int maxY = editSession.getMaximumPoint().getBlockY();

    for (int x = -outsetSize; x <= outsetSize; x++) {
        int x0 = x + tx;
        for (int y = -outsetSize; y <= outsetSize; y++) {
            int y0 = y + ty;
            for (int z = -outsetSize; z <= outsetSize; z++) {
                if (x * x + y * y + z * z >= brushSizeSquared) {
                    continue;
                }
                int z0 = z + tz;
                int highest = 1;
                BaseBlock currentState = editSession.getBlock(x0, y0, z0);
                BaseBlock highestState = currentState;
                frequency.clear();
                boolean tie = false;
                for (int ox = -1; ox <= 1; ox++) {
                    for (int oz = -1; oz <= 1; oz++) {
                        for (int oy = -1; oy <= 1; oy++) {
                            if (oy + y0 < 0 || oy + y0 > maxY) {
                                continue;
                            }
                            BaseBlock state = editSession.getBlock(x0 + ox, y0 + oy, z0 + oz);
                            Integer count = frequency.get(state);
                            if (count == null) {
                                count = 1;
                            } else {
                                count++;
                            }
                            if (count > highest) {
                                highest = count;
                                highestState = state;
                                tie = false;
                            } else if (count == highest) {
                                tie = true;
                            }
                            frequency.put(state, count);
                        }
                    }
                }
                if (!tie && currentState != highestState) {
                    editSession.setBlock(x0, y0, z0, highestState);
                }
            }
        }
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:59,代码来源:BlendBall.java

示例10: apply

import com.sk89q.worldedit.EditSession; //导入方法依赖的package包/类
public void apply(EditSession editSession, LocalBlockVectorSet placed, Vector pt, Pattern p, double size) throws MaxChangedBlocksException {
    editSession.setBlock(pt, p);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:4,代码来源:ScatterBrush.java


注:本文中的com.sk89q.worldedit.EditSession.setBlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。