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


Java BlockSnapshot.withState方法代码示例

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


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

示例1: removePlayerLeaves

import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
private void removePlayerLeaves() {
    if (this.seaLevel < 1) {
        return;
    }

    for (int x = 1; x < snapshots.length - 1; x++) {
        for (int z = 1; z < snapshots[0][0].length - 1; z++) {
            for (int y = this.seaLevel - 1; y < snapshots[0].length; y++) {
                // note: see minecraft wiki data values for leaves
                BlockSnapshot block = snapshots[x][y][z];
                if (block.getState().getType() == BlockTypes.LEAVES && (BlockUtils.getBlockStateMeta(block.getState()) & 0x4) != 0) {
                    snapshots[x][y][z] = block.withState(BlockTypes.AIR.getDefaultState());
                }
            }
        }
    }
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:18,代码来源:RestoreNatureProcessingTask.java

示例2: removePlayerBlocks

import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
private void removePlayerBlocks() {
    int miny = this.miny;
    if (miny < 1) {
        miny = 1;
    }

    // remove all player blocks
    for (int x = 1; x < snapshots.length - 1; x++) {
        for (int z = 1; z < snapshots[0][0].length - 1; z++) {
            for (int y = miny; y < snapshots[0].length - 1; y++) {
                BlockSnapshot block = snapshots[x][y][z];
                if (this.playerBlocks.contains(block.getState().getType())) {
                    snapshots[x][y][z] = block.withState(BlockTypes.AIR.getDefaultState());
                }
            }
        }
    }
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:19,代码来源:RestoreNatureProcessingTask.java

示例3: removeHanging

import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
private void removeHanging() {
    int miny = this.miny;
    if (miny < 1) {
        miny = 1;
    }

    for (int x = 1; x < snapshots.length - 1; x++) {
        for (int z = 1; z < snapshots[0][0].length - 1; z++) {
            for (int y = miny; y < snapshots[0].length - 1; y++) {
                BlockSnapshot block = snapshots[x][y][z];
                BlockSnapshot underBlock = snapshots[x][y - 1][z];

                if (underBlock.getState().getType() == BlockTypes.AIR || underBlock.getState().getType() == BlockTypes.WATER
                        || underBlock.getState().getType() == BlockTypes.LAVA || underBlock.getState().getType() == BlockTypes.LEAVES) {
                    if (this.notAllowedToHang.contains(block.getState().getType())) {
                        snapshots[x][y][z] = block.withState(BlockTypes.AIR.getDefaultState());
                    }
                }
            }
        }
    }
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:23,代码来源:RestoreNatureProcessingTask.java

示例4: removeDumpedFluids

import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
private void removeDumpedFluids() {
    if (this.seaLevel < 1) {
        return;
    }

    // remove any surface water or lava above sea level, presumed to be
    // placed by players
    // sometimes, this is naturally generated. but replacing it is very easy
    // with a bucket, so overall this is a good plan
    if (this.environment.equals(DimensionTypes.NETHER)) {
        return;
    }
    for (int x = 1; x < snapshots.length - 1; x++) {
        for (int z = 1; z < snapshots[0][0].length - 1; z++) {
            for (int y = this.seaLevel - 1; y < snapshots[0].length - 1; y++) {
                BlockSnapshot block = snapshots[x][y][z];
                if (block.getState().getType() == BlockTypes.WATER || block.getState().getType() == BlockTypes.LAVA ||
                        block.getState().getType() == BlockTypes.WATER || block.getState().getType() == BlockTypes.LAVA) {
                    snapshots[x][y][z] = block.withState(BlockTypes.AIR.getDefaultState());
                }
            }
        }
    }
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:25,代码来源:RestoreNatureProcessingTask.java

示例5: onBlockHit

import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
@Override
public boolean onBlockHit(CustomWorld world, Vector3i pos, Player player, HandType currHand, Direction side,
        Vector3d clickPoint) {
    Cause breakCause = Cause.builder()
            .named("plugin", Industrialization.toContainer())
            .named(NamedCause.SOURCE, player)
            .build();
    world.getWorld().setBlockType(pos, BlockTypes.AIR, BlockChangeFlag.ALL, breakCause);
    // Sponge broke and doesn't fire the event (SpongeCommon#998)
    BlockSnapshot from = world.getWorld().createSnapshot(pos);
    BlockSnapshot to = from.withState(BlockTypes.AIR.getDefaultState());
    List<Transaction<BlockSnapshot>> tr = Lists.newArrayList(new Transaction<>(from, to));
    Sponge.getEventManager().post(SpongeEventFactory.createChangeBlockEventBreak(breakCause, tr));
    return false;
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:16,代码来源:PipeBlock.java

示例6: onBlockPlacedByPlayer

import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
@Override
public BlockSnapshot onBlockPlacedByPlayer(CustomWorld world, Vector3i pos, BlockSnapshot blockSnapshot,
        Player player, ItemBlockWrapper item, ItemStack itemStack) {
    this.entityStruct.initialize(world, pos);
    return blockSnapshot.withState(BlockTypes.BARRIER.getDefaultState());
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:7,代码来源:PipeBlock.java

示例7: fillHolesAndTrenches

import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
private void fillHolesAndTrenches() {
    ArrayList<BlockType> fillableBlocks = new ArrayList<BlockType>();
    fillableBlocks.add(BlockTypes.AIR);
    fillableBlocks.add(BlockTypes.WATER);
    fillableBlocks.add(BlockTypes.LAVA);
    fillableBlocks.add(BlockTypes.TALLGRASS);

    ArrayList<BlockType> notSuitableForFillBlocks = new ArrayList<BlockType>();
    notSuitableForFillBlocks.add(BlockTypes.TALLGRASS);
    notSuitableForFillBlocks.add(BlockTypes.CACTUS);
    notSuitableForFillBlocks.add(BlockTypes.WATER);
    notSuitableForFillBlocks.add(BlockTypes.LAVA);
    notSuitableForFillBlocks.add(BlockTypes.LOG);
    notSuitableForFillBlocks.add(BlockTypes.LOG2);

    boolean changed;
    do {
        changed = false;
        for (int x = 1; x < snapshots.length - 1; x++) {
            for (int z = 1; z < snapshots[0][0].length - 1; z++) {
                for (int y = 0; y < snapshots[0].length - 1; y++) {
                    BlockSnapshot block = this.snapshots[x][y][z];
                    if (!fillableBlocks.contains(block.getState().getType())) {
                        continue;
                    }

                    BlockSnapshot leftBlock = this.snapshots[x + 1][y][z];
                    BlockSnapshot rightBlock = this.snapshots[x - 1][y][z];

                    if (!fillableBlocks.contains(leftBlock.getState().getType()) && !fillableBlocks.contains(rightBlock.getState().getType())) {
                        if (!notSuitableForFillBlocks.contains(rightBlock.getState().getType())) {
                            this.snapshots[x][y][z] = block.withState(rightBlock.getState().getType().getDefaultState());
                            changed = true;
                        }
                    }

                    BlockSnapshot upBlock = this.snapshots[x][y][z + 1];
                    BlockSnapshot downBlock = this.snapshots[x][y][z - 1];

                    if (!fillableBlocks.contains(upBlock.getState().getType()) && !fillableBlocks.contains(downBlock.getState().getType())) {
                        if (!notSuitableForFillBlocks.contains(downBlock.getState().getType())) {
                            this.snapshots[x][y][z] = block.withState(downBlock.getState().getType().getDefaultState());
                            changed = true;
                        }
                    }
                }
            }
        }
    } while (changed);
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:51,代码来源:RestoreNatureProcessingTask.java


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