下面列出了org.bukkit.Material#SNOW 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@EventHandler
public void onForm(BlockFormEvent event) {
if (event.isCancelled()) {
return;
}
if (event.getNewState().getType() == Material.SNOW) {
return;
}
for (String s : Main.getGameNames()) {
Game game = Main.getGame(s);
if (game.getStatus() == GameStatus.RUNNING || game.getStatus() == GameStatus.GAME_END_CELEBRATING) {
if (GameCreator.isInArea(event.getBlock().getLocation(), game.getPos1(), game.getPos2())) {
if (!game.isBlockAddedDuringGame(event.getBlock().getLocation())) {
event.setCancelled(true);
}
return;
}
}
}
}
@EventHandler
public void onForm(BlockFormEvent event) {
if (event.isCancelled()) {
return;
}
if (event.getNewState().getType() == Material.SNOW) {
return;
}
for (String s : Main.getGameNames()) {
Game game = Main.getGame(s);
if (game.getStatus() == GameStatus.RUNNING || game.getStatus() == GameStatus.GAME_END_CELEBRATING) {
if (GameCreator.isInArea(event.getBlock().getLocation(), game.getPos1(), game.getPos2())) {
if (!game.isBlockAddedDuringGame(event.getBlock().getLocation())) {
event.setCancelled(true);
}
return;
}
}
}
}
@Override
public void makeStepSound(int i, int j, int k, Material block) {
BlockSoundData soundData = INMS.getInstance().getBlockSoundData(block);
if (getBukkitEntity().getWorld().getBlockAt(i, j + 1, k).getType() == Material.SNOW) {
soundData = INMS.getInstance().getBlockSoundData(Material.SNOW);
}
if (!INMS.getInstance().isLiquid(block)) {
if (!getEntity().getPassengers().isEmpty() && getHorseType() != HorseType.NORMAL && getHorseType() != HorseType.MULE) {
++this.stepSoundCount;
if (this.stepSoundCount > 5 && this.stepSoundCount % 3 == 0) {
getEntity().playSound(SafeSound.HORSE_GALLOP, soundData.getVolume() * 0.15F, soundData.getPitch());
if (getHorseType() == HorseType.NORMAL && this.random() .nextInt(10) == 0) {
getEntity().playSound(SafeSound.HORSE_BREATHE, soundData.getVolume() * 0.6F, soundData.getPitch());
}
} else if (this.stepSoundCount <= 5) {
getEntity().playSound(SafeSound.HORSE_STEP_WOOD, soundData.getVolume() * 0.15F, soundData.getPitch());
}
} else if (soundData.equals(BlockSoundData.WOOD)) {
getEntity().playSound(SafeSound.HORSE_STEP_WOOD, soundData.getVolume() * 0.15F, soundData.getPitch());
} else {
getEntity().playSound(SafeSound.HORSE_STEP, soundData.getVolume() * 0.15F, soundData.getPitch());
}
}
}
@EventHandler(ignoreCancelled = true)
public void onForm(BlockFormEvent form) {
if (form.getNewState().getType() != Material.SNOW) {
return;
}
Game game =
BedwarsRel.getInstance().getGameManager().getGameByLocation(form.getBlock().getLocation());
if (game == null) {
return;
}
if (game.getState() == GameState.STOPPED) {
return;
}
form.setCancelled(true);
}
@EventHandler
public void blockFormEvent(BlockFormEvent event) {
if (event.getNewState().getType() == Material.SNOW) {
WorldClimateEngine climateEngine = ClimateEngine.getInstance().getClimateEngine(event.getBlock().getWorld().getUID());
if (climateEngine != null && climateEngine.isEffectEnabled(ClimateEffectType.SNOW_FORMATION)) {
double temperature = climateEngine.getTemperature();
if (event.getBlock().getY() < heightMap.getValue(temperature)) {
event.setCancelled(true);
}
}
}
}
private boolean isReallySolid(Block b) {
boolean reallySolid = block.getMaterial().isSolid();
MaterialData matData = b.getState().getData();
if (matData instanceof Sign || matData instanceof Banner)
reallySolid = false;
else if (matData instanceof FlowerPot || matData instanceof Diode || matData instanceof Skull ||
b.getType() == Material.CARPET || matData instanceof Ladder ||
b.getType() == Material.REDSTONE_COMPARATOR || b.getType() == Material.REDSTONE_COMPARATOR_ON ||
b.getType() == Material.REDSTONE_COMPARATOR_OFF || b.getType() == Material.SOIL ||
b.getType() == Material.WATER_LILY || b.getType() == Material.SNOW || b.getType() == Material.COCOA) {
reallySolid = true;
}
return reallySolid;
}