本文整理汇总了Java中org.spongepowered.api.block.trait.EnumTraits类的典型用法代码示例。如果您正苦于以下问题:Java EnumTraits类的具体用法?Java EnumTraits怎么用?Java EnumTraits使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EnumTraits类属于org.spongepowered.api.block.trait包,在下文中一共展示了EnumTraits类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reduceLogs
import org.spongepowered.api.block.trait.EnumTraits; //导入依赖的package包/类
private void reduceLogs() {
if (this.seaLevel < 1) {
return;
}
boolean jungleBiome = this.biome == BiomeTypes.JUNGLE || this.biome == BiomeTypes.JUNGLE_HILLS;
// scan all blocks above sea level
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++) {
BlockSnapshot block = snapshots[x][y][z];
// skip non-logs
if (block.getState().getType() != BlockTypes.LOG) {
continue;
}
if (block.getState().getType() != BlockTypes.LOG2) {
continue;
}
// if in jungle biome, skip jungle logs
Optional<? extends Enum<?>> enumProperty = block.getState().getTraitValue(EnumTraits.LOG_VARIANT);
if (jungleBiome && enumProperty.isPresent() && enumProperty.get().name().equalsIgnoreCase("jungle")) {
continue;
}
// examine adjacent blocks for logs
BlockSnapshot leftBlock = this.snapshots[x + 1][y][z];
BlockSnapshot rightBlock = this.snapshots[x - 1][y][z];
BlockSnapshot upBlock = this.snapshots[x][y][z + 1];
BlockSnapshot downBlock = this.snapshots[x][y][z - 1];
// if any, remove the log
if (leftBlock.getState().getType() == BlockTypes.LOG || rightBlock.getState().getType() == BlockTypes.LOG
|| upBlock.getState().getType() == BlockTypes.LOG || downBlock.getState().getType() == BlockTypes.LOG) {
this.snapshots[x][y][z] = this.snapshots[x][y][z].withState(BlockTypes.AIR.getDefaultState());
}
}
}
}
}
示例2: smartStart
import org.spongepowered.api.block.trait.EnumTraits; //导入依赖的package包/类
public void smartStart() {
List<Player> ffaList = new ArrayList<>();
List<Player> redList = new ArrayList<>();
List<Player> blueList = new ArrayList<>();
Collection<Player> containedPlayers = getPlayers(PARTICIPANT);
if (containedPlayers.size() <= 1) {
return;
}
for (Player player : containedPlayers) {
BlockState state = player.getLocation().add(0, -1, 0).getBlock();
if (state.getType() != BlockTypes.WOOL) {
return;
}
Optional<?> optColor = state.getTraitValue(EnumTraits.WOOL_COLOR);
if (optColor.isPresent()) {
DyeColor color = (DyeColor) optColor.get();
if (color == DyeColors.RED) {
redList.add(player);
} else if (color == DyeColors.BLUE) {
blueList.add(player);
} else if (color == DyeColors.WHITE) {
ffaList.add(player);
} else {
return;
}
}
}
if (getWinner(ffaList, blueList, redList).isPresent()) {
getPlayerMessageChannel(SPECTATOR).send(Text.of(TextColors.RED, "All players are on one team, the game will not start."));
return;
}
ffaList.stream().forEach(p -> addFFAPlayer(p, classMap.getOrDefault(p, JungleRaidClass.BALANCED)));
redList.stream().forEach(p -> addRedPlayer(p, classMap.getOrDefault(p, JungleRaidClass.BALANCED)));
blueList.stream().forEach(p -> addBluePlayer(p, classMap.getOrDefault(p, JungleRaidClass.BALANCED)));
state = JungleRaidState.INITIALIZE;
startTime = System.currentTimeMillis();
}