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


Java BooleanTraits类代码示例

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


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

示例1: resetLevers

import org.spongepowered.api.block.trait.BooleanTraits; //导入依赖的package包/类
private void resetLevers() {
  leversTriggered = false;
  checkingLevers = true;

  for (Location<World> entry : leverBlocks.keySet()) {
    BlockState state = entry.getBlock();

    entry.getExtent().setBlock(
        entry.getBlockPosition(),
        state.withTrait(BooleanTraits.LEVER_POWERED, false).orElse(state),
        Cause.source(SkreePlugin.container()).build()
    );

    leverBlocks.put(entry, !Probability.getChance(3));
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:17,代码来源:GoldRushInstance.java

示例2: findLeversAndFloodBlocks

import org.spongepowered.api.block.trait.BooleanTraits; //导入依赖的package包/类
private void findLeversAndFloodBlocks() {

    Vector3i min = flashMemoryRoom.getMinimumPoint();
    Vector3i max = flashMemoryRoom.getMaximumPoint();

    int minX = min.getX();
    int minZ = min.getZ();
    int minY = min.getY();
    int maxX = max.getX();
    int maxZ = max.getZ();
    int maxY = max.getY();

    for (int x = minX; x <= maxX; x++) {
      for (int z = minZ; z <= maxZ; z++) {
        for (int y = maxY; y >= minY; --y) {
          BlockState state = getRegion().getExtent().getBlock(x, y, z);
          if (state.getType() == BlockTypes.LEVER) {
            Location<World> loc = new Location<>(getRegion().getExtent(), x, y, z);
            loc.getExtent().setBlock(
                loc.getBlockPosition(),
                state.withTrait(BooleanTraits.LEVER_POWERED, false).orElse(state),
                Cause.source(SkreePlugin.container()).build()
            );

            leverBlocks.put(loc, !Probability.getChance(3));
            for (int i = y; i < maxY; i++) {
              BlockType type = getRegion().getExtent().getBlockType(x, i, z);
              if (type == BlockTypes.AIR) {
                floodBlocks.add(new Location<>(getRegion().getExtent(), x, i, z));
                break;
              }
            }
            break; // One lever a column only
          }
        }
      }
    }
  }
 
开发者ID:Skelril,项目名称:Skree,代码行数:39,代码来源:GoldRushInstance.java

示例3: checkLevers

import org.spongepowered.api.block.trait.BooleanTraits; //导入依赖的package包/类
public boolean checkLevers() {
  if (!checkingLevers) {
    return leversTriggered;
  }

  for (Map.Entry<Location<World>, Boolean> lever : leverBlocks.entrySet()) {
    boolean leverState = lever.getKey().getBlock().getTraitValue(BooleanTraits.LEVER_POWERED).orElse(false);
    if (leverState != lever.getValue()) {
      return false;
    }
  }
  return true;
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:14,代码来源:GoldRushInstance.java

示例4: isRedstoneChange

import org.spongepowered.api.block.trait.BooleanTraits; //导入依赖的package包/类
private static boolean isRedstoneChange(BlockState origState, BlockState finalState)
{
    if (origState.getType().equals(finalState.getType()) && origState.getType().equals(BlockTypes.REDSTONE_WIRE))
    {
        return true;
    }

    return isChangeFromOrTo(origState, finalState, BlockTypes.POWERED_REPEATER, BlockTypes.UNPOWERED_REPEATER)
        || isChangeFromOrTo(origState, finalState, BlockTypes.POWERED_COMPARATOR, BlockTypes.UNPOWERED_COMPARATOR)
        || isChangeFromOrTo(origState, finalState, BlockTypes.REDSTONE_TORCH, BlockTypes.UNLIT_REDSTONE_TORCH)
        || isChangeTrait(origState, finalState, BlockTypes.DROPPER, BooleanTraits.DROPPER_TRIGGERED, false)
        || isChangeTrait(origState, finalState, BlockTypes.DISPENSER, BooleanTraits.DISPENSER_TRIGGERED, false)
        || isChangeTrait(origState, finalState, BlockTypes.HOPPER, BooleanTraits.HOPPER_ENABLED, true);
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:15,代码来源:BlockReport.java

示例5: isBedOccupied

import org.spongepowered.api.block.trait.BooleanTraits; //导入依赖的package包/类
/**
 * Is this an occupied bed?
 *
 * @param blockLoc Block
 * @return Whether or not this block is an occupied bed
 */
public static boolean isBedOccupied(Location<World> blockLoc) {
    return isBed(blockLoc) ? blockLoc.getBlock().getTraitValue(BooleanTraits.BED_OCCUPIED).orElse(false) : false;
}
 
开发者ID:mmonkey,项目名称:Destinations,代码行数:10,代码来源:BlockUtil.java


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