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


Java BlockID类代码示例

本文整理汇总了Java中com.sk89q.worldedit.blocks.BlockID的典型用法代码示例。如果您正苦于以下问题:Java BlockID类的具体用法?Java BlockID怎么用?Java BlockID使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: simulateBlockMine

import com.sk89q.worldedit.blocks.BlockID; //导入依赖的package包/类
@Override
default void simulateBlockMine(Vector pt) {
    BaseBlock block = getLazyBlock(pt);
    BaseItemStack stack = BlockType.getBlockDrop(block.getId(), (short) block.getData());

    if (stack != null) {
        final int amount = stack.getAmount();
        if (amount > 1) {
            dropItem(pt, new BaseItemStack(stack.getType(), 1, stack.getData()), amount);
        } else {
            dropItem(pt, stack, amount);
        }
    }

    try {
        setBlock(pt, new BaseBlock(BlockID.AIR));
    } catch (WorldEditException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:21,代码来源:SimpleWorld.java

示例2: getAnyTargetBlock

import com.sk89q.worldedit.blocks.BlockID; //导入依赖的package包/类
/**
 * Returns any block at the sight. Returns null if out of range or if no
 * viable target was found. Will try to return the last valid air block it finds.
 *
 * @return Block
 */
public BlockWorldVector getAnyTargetBlock() {
    boolean searchForLastBlock = true;
    BlockWorldVector lastBlock = null;
    while (getNextBlock() != null) {
        if (world.getBlockType(getCurrentBlock()) == BlockID.AIR) {
            if (searchForLastBlock) {
                lastBlock = getCurrentBlock();
                if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= world.getMaxY()) {
                    searchForLastBlock = false;
                }
            }
        } else {
            break;
        }
    }
    BlockWorldVector currentBlock = getCurrentBlock();
    return (currentBlock != null ? currentBlock : lastBlock);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:25,代码来源:TargetBlock.java

示例3: extinguishBrush

import com.sk89q.worldedit.blocks.BlockID; //导入依赖的package包/类
@Command(
        aliases = {"ex", "extinguish"},
        usage = "[radius=5]",
        desc = "Shortcut fire extinguisher brush",
        min = 0,
        max = 1
)
@CommandPermissions("worldedit.brush.ex")
public BrushSettings extinguishBrush(Player player, LocalSession session, EditSession editSession, @Optional("5") double radius, CommandContext context) throws WorldEditException {
    worldEdit.checkMaxBrushRadius(radius);

    Pattern fill = (new BaseBlock(0));
    return get(context)
            .setBrush(new SphereBrush())
            .setSize(radius)
            .setFill(fill)
            .setMask(new BlockMask(editSession, new BaseBlock(BlockID.FIRE)));
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:19,代码来源:BrushCommands.java

示例4: actPrimary

import com.sk89q.worldedit.blocks.BlockID; //导入依赖的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

示例5: actPrimary

import com.sk89q.worldedit.blocks.BlockID; //导入依赖的package包/类
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
    World world = (World) clicked.getExtent();

    int initialType = world.getBlockType(clicked.toVector());

    if (initialType == BlockID.AIR) {
        return true;
    }

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

    EditSession editSession = session.createEditSession(player);

    try {
        recurse(server, editSession, world, clicked.toVector().toBlockVector(),
                clicked.toVector(), range, initialType, new HashSet<BlockVector>());
    } catch (WorldEditException e) {
        throw new RuntimeException(e);
    }
    editSession.flushQueue();
    session.remember(editSession);
    return true;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:27,代码来源:FloodFillTool.java

示例6: showStartingPlatform

import com.sk89q.worldedit.blocks.BlockID; //导入依赖的package包/类
private void showStartingPlatform(boolean present) {
  Location<World> platformLocation = startingLocation.add(0, -1, 0);

  EditSession editor = WorldEdit.getInstance().getEditSessionFactory().getEditSession(
      new WorldResolver(getRegion().getExtent()).getWorldEditWorld(),
      -1
  );
  com.sk89q.worldedit.Vector origin = new com.sk89q.worldedit.Vector(
      platformLocation.getX(), platformLocation.getY(), platformLocation.getZ()
  );

  BaseBlock targetBlock;

  if (present) {
    targetBlock = WorldEdit.getInstance().getBaseBlockFactory().getBaseBlock(BlockID.STAINED_GLASS, 15);
  } else {
    targetBlock = WorldEdit.getInstance().getBaseBlockFactory().getBaseBlock(BlockID.AIR);
  }

  try {
    editor.makeCylinder(origin, new SingleBlockPattern(targetBlock), 12, 1, true);
  } catch (MaxChangedBlocksException e) {
    e.printStackTrace();
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:26,代码来源:SkyWarsInstance.java

示例7: clearOldRegions

import com.sk89q.worldedit.blocks.BlockID; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private void clearOldRegions() {
	for (String planetName : centreCoordinates.keySet()){
		ProtectedRegion wgRegion = rgMgr.getRegion(planetName);
		if(wgRegion == null){
			print("No WG region forund for planet '"+planetName+"', skipping region deletion.");
			continue;
		}
		com.sk89q.worldedit.LocalWorld weWorld = BukkitUtil.getLocalWorld(world);
		EditSession es = WorldEdit.getInstance().getEditSessionFactory().getEditSession(weWorld, -1);
		Region weRegion = new Polygonal2DRegion(weWorld,
				wgRegion.getPoints(), 
				wgRegion.getMinimumPoint().getBlockY(),
				wgRegion.getMaximumPoint().getBlockY());
		try {
			es.setBlocks(weRegion, new BaseBlock(BlockID.AIR));
		} catch (MaxChangedBlocksException e) {
			// should never happen as limit is -1
			print("Error deleting blocks with WE for planet '"+planetName+"', max block limit reached.");
		}
		rgMgr.removeRegion(planetName);
	}	
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:24,代码来源:SQOrbitsPlanetMover.java

示例8: getState

import com.sk89q.worldedit.blocks.BlockID; //导入依赖的package包/类
@Override
public BlockState getState() {
    int combined = queue.getCombinedId4Data(x, y, z, 0);
    switch (FaweCache.getId(combined)) {
        case BlockID.SIGN_POST:
        case BlockID.WALL_SIGN:
            return new AsyncSign(this, combined);
    }
    return new AsyncBlockState(this);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:11,代码来源:AsyncBlock.java

示例9: getBlockInHand

import com.sk89q.worldedit.blocks.BlockID; //导入依赖的package包/类
@Override
public BaseBlock getBlockInHand() throws WorldEditException {
    ItemStack itemStack = player.getItemInHand();
    if (itemStack == null) {
        return EditSession.nullBlock;
    }
    final int typeId = itemStack.getTypeId();
    switch (typeId) {
        case 0:
            return EditSession.nullBlock;
        case ItemID.INK_SACK:
            final Dye materialData = (Dye) itemStack.getData();
            if (materialData.getColor() == DyeColor.BROWN) {
                return FaweCache.getBlock(BlockID.COCOA_PLANT, 0);
            }
            break;
        case ItemID.HEAD:
            return new SkullBlock(0, (byte) itemStack.getDurability());

        default:
            final BaseBlock baseBlock = BlockType.getBlockForItem(typeId, itemStack.getDurability());
            if (baseBlock != null) {
                return baseBlock;
            }
            break;
    }
    BaseBlock block = FaweCache.getBlock(typeId, itemStack.getType().getMaxDurability() != 0 ? 0 : Math.max(0, itemStack.getDurability()));
    if (Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES && Fawe.<FaweBukkit>imp().getItemUtil() != null) {
        return new BrushBoundBaseBlock(this, WorldEdit.getInstance().getSession(this), itemStack);
    }
    return block;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:33,代码来源:BukkitPlayer.java

示例10: ascendLevel

import com.sk89q.worldedit.blocks.BlockID; //导入依赖的package包/类
@Override
public boolean ascendLevel() {
    final WorldVector pos = getBlockIn();
    final int x = pos.getBlockX();
    int y = Math.max(0, pos.getBlockY());
    final int z = pos.getBlockZ();
    final World world = pos.getWorld();

    byte free = 0;
    byte spots = 0;

    while (y <= world.getMaxY() + 2) {
        if (BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
            ++free;
        } else {
            free = 0;
        }

        if (free == 2) {
            ++spots;
            if (spots == 2) {
                final Vector platform = new Vector(x, y - 2, z);
                final BaseBlock block = world.getBlock(platform);
                final int type = block.getId();

                // Don't get put in lava!
                if (type == BlockID.LAVA || type == BlockID.STATIONARY_LAVA) {
                    return false;
                }

                setPosition(platform.add(0.5, BlockType.centralTopLimit(block), 0.5));
                return true;
            }
        }

        ++y;
    }

    return false;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:41,代码来源:AbstractPlayerActor.java

示例11: createLiquidMask

import com.sk89q.worldedit.blocks.BlockID; //导入依赖的package包/类
@Override
default Mask createLiquidMask() {
    return new BlockMask(this,
            new BaseBlock(BlockID.STATIONARY_LAVA, -1),
            new BaseBlock(BlockID.LAVA, -1),
            new BaseBlock(BlockID.STATIONARY_WATER, -1),
            new BaseBlock(BlockID.WATER, -1));
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:9,代码来源:SimpleWorld.java

示例12: removeAbove

import com.sk89q.worldedit.blocks.BlockID; //导入依赖的package包/类
/**
 * Remove a cuboid above the given position with a given apothem and a given height.
 *
 * @param position base position
 * @param apothem  an apothem of the cuboid (on the XZ plane), where the minimum is 1
 * @param height   the height of the cuboid, where the minimum is 1
 * @return number of blocks affected
 * @throws MaxChangedBlocksException thrown if too many blocks are changed
 */
@SuppressWarnings("deprecation")
public int removeAbove(final Vector position, final int apothem, final int height) {
    checkNotNull(position);
    checkArgument(apothem >= 1, "apothem >= 1");
    checkArgument(height >= 1, "height >= 1");

    final Region region = new CuboidRegion(this.getWorld(), // Causes clamping of Y range
            position.add(-apothem + 1, 0, -apothem + 1), position.add(apothem - 1, height - 1, apothem - 1));
    final Pattern pattern = (new BaseBlock(BlockID.AIR));
    return this.setBlocks(region, pattern);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:21,代码来源:EditSession.java

示例13: removeBelow

import com.sk89q.worldedit.blocks.BlockID; //导入依赖的package包/类
/**
 * Remove a cuboid below the given position with a given apothem and a given height.
 *
 * @param position base position
 * @param apothem  an apothem of the cuboid (on the XZ plane), where the minimum is 1
 * @param height   the height of the cuboid, where the minimum is 1
 * @return number of blocks affected
 * @throws MaxChangedBlocksException thrown if too many blocks are changed
 */
@SuppressWarnings("deprecation")
public int removeBelow(final Vector position, final int apothem, final int height) {
    checkNotNull(position);
    checkArgument(apothem >= 1, "apothem >= 1");
    checkArgument(height >= 1, "height >= 1");

    final Region region = new CuboidRegion(this.getWorld(), // Causes clamping of Y range
            position.add(-apothem + 1, 0, -apothem + 1), position.add(apothem - 1, -height + 1, apothem - 1));
    final Pattern pattern = (new BaseBlock(BlockID.AIR));
    return this.setBlocks(region, pattern);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:21,代码来源:EditSession.java

示例14: removeNear

import com.sk89q.worldedit.blocks.BlockID; //导入依赖的package包/类
/**
 * Remove blocks of a certain type nearby a given position.
 *
 * @param position  center position of cuboid
 * @param blockType the block type to match
 * @param apothem   an apothem of the cuboid, where the minimum is 1
 * @return number of blocks affected
 * @throws MaxChangedBlocksException thrown if too many blocks are changed
 */
@SuppressWarnings("deprecation")
public int removeNear(final Vector position, final int blockType, final int apothem) {
    checkNotNull(position);
    checkArgument(apothem >= 1, "apothem >= 1");

    final Mask mask = new FuzzyBlockMask(this, new BaseBlock(blockType, -1));
    final Vector adjustment = new Vector(1, 1, 1).multiply(apothem - 1);
    final Region region = new CuboidRegion(this.getWorld(), // Causes clamping of Y range
            position.add(adjustment.multiply(-1)), position.add(adjustment));
    final Pattern pattern = (new BaseBlock(BlockID.AIR));
    return this.replaceBlocks(region, mask, pattern);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:22,代码来源:EditSession.java

示例15: drainArea

import com.sk89q.worldedit.blocks.BlockID; //导入依赖的package包/类
/**
     * Drain nearby pools of water or lava.
     *
     * @param origin the origin to drain from, which will search a 3x3 area
     * @param radius the radius of the removal, where a value should be 0 or greater
     * @return number of blocks affected
     * @throws MaxChangedBlocksException thrown if too many blocks are changed
     */
    public int drainArea(final Vector origin, final double radius) {
        checkNotNull(origin);
        checkArgument(radius >= 0, "radius >= 0 required");
        Mask liquidMask;
        // Not thread safe, use hardcoded liquidmask
//        if (getWorld() != null) {
//            liquidMask = getWorld().createLiquidMask();
//        } else {
        liquidMask = new BlockMask(this,
                new BaseBlock(BlockID.STATIONARY_LAVA, -1),
                new BaseBlock(BlockID.LAVA, -1),
                new BaseBlock(BlockID.STATIONARY_WATER, -1),
                new BaseBlock(BlockID.WATER, -1));
//        }
        final MaskIntersection mask = new MaskIntersection(
                new BoundedHeightMask(0, EditSession.this.getMaximumPoint().getBlockY()),
                new RegionMask(
                        new EllipsoidRegion(null, origin,
                                new Vector(radius, radius, radius))), liquidMask);

        final BlockReplace replace = new BlockReplace(EditSession.this, new BaseBlock(BlockID.AIR));
        final RecursiveVisitor visitor = new RecursiveVisitor(mask, replace, (int) (radius * 2 + 1), this);

        // Around the origin in a 3x3 block
        for (final BlockVector position : CuboidRegion.fromCenter(origin, 1)) {
            if (mask.test(position)) {
                visitor.visit(position);
            }
        }

        Operations.completeBlindly(visitor);
        return this.changes = visitor.getAffected();
    }
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:42,代码来源:EditSession.java


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