本文整理汇总了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));
}
}
示例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
}
}
}
}
}
示例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;
}
示例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);
}
示例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;
}