本文整理汇总了Java中org.spongepowered.api.world.weather.Weathers.CLEAR属性的典型用法代码示例。如果您正苦于以下问题:Java Weathers.CLEAR属性的具体用法?Java Weathers.CLEAR怎么用?Java Weathers.CLEAR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.spongepowered.api.world.weather.Weathers
的用法示例。
在下文中一共展示了Weathers.CLEAR属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cast
@Override
public SkillResult cast(IActiveCharacter character, ExtendedSkillInfo info, SkillModifier modifier) {
Player character1 = character.getEntity();
if (character1.getWorld().getWeather() == Weathers.CLEAR) {
Vector3d position = character1.getLocation().getPosition();
if (character1.getWorld().getHighestYAt(position.getFloorX(), position.getFloorZ()) > position.getFloorY()) {
character1.sendMessage(ChatTypes.ACTION_BAR, Text.builder(SkillLocalization.ASTRONOMY_CANNOT_SEE_THE_SKY)
.color(TextColors.RED).build());
return SkillResult.CANCELLED;
}
ItemStack is = Utils.createTeleportationScroll(character.getLocation());
character.getEntity().getInventory().offer(is);
return SkillResult.OK;
}
character1.sendMessage(ChatTypes.ACTION_BAR, Text.builder(SkillLocalization.ASTRONOMY_CANNOT_SEE_THE_SKY)
.color(TextColors.RED).build());
return SkillResult.CANCELLED;
}
示例2: parseValue
@Nullable
@Override
public Weather parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException {
String value = args.next();
switch (value) {
case "sun":
case "clear":
return Weathers.CLEAR;
case "rain":
case "snow":
case "downfall":
return Weathers.RAIN;
case "thunder":
case "thunderstorm":
case "thunder_storm":
case "storm":
return Weathers.THUNDER_STORM;
default:
throw args.createError(Messages.getFormatted(source, "weather.command.weather.invalidweathertype", "%weather%", value));
}
}
示例3: getWeather
private Optional<Weather> getWeather(final String weather_name) {
Weather weather = null;
if (weather_name.equalsIgnoreCase("sun")) {
weather = Weathers.CLEAR;
} else if (weather_name.equalsIgnoreCase("rain")) {
weather = Weathers.RAIN;
} else if (weather_name.equalsIgnoreCase("storm")) {
weather = Weathers.THUNDER_STORM;
}
return Optional.ofNullable(weather);
}
示例4: calculateInitialWeather
@Overwrite
protected void calculateInitialWeather() {
final IMixinWorldInfo info = (IMixinWorldInfo) this.worldInfo;
info.setWorld(this);
if (info.getWeather() == null) {
final Weather weather;
int duration;
int rainTime = this.worldInfo.raining ? this.worldInfo.getRainTime() : 0;
int thunderTime = this.worldInfo.thundering ? this.worldInfo.thunderTime : 0;
this.worldInfo.thunderTime = thunderTime;
this.worldInfo.rainTime = rainTime;
if (rainTime <= 0) {
weather = Weathers.CLEAR;
duration = this.worldInfo.getCleanWeatherTime();
} else if (thunderTime > 0) {
weather = Weathers.THUNDER_STORM;
duration = Math.min(rainTime, thunderTime);
} else {
weather = Weathers.RAIN;
duration = rainTime;
}
info.setWeather((WeatherType) weather);
info.setWeatherDuration(duration);
info.setElapsedWeatherDuration(0);
}
this.initWeatherVolume();
}
示例5: setRaining
@Override
public void setRaining(boolean state) {
LanternWeather weather = this.weatherData.getWeather();
final boolean raining = weather.getOptions().getOrDefault(WeatherOptions.RAIN_STRENGTH).get() > 0;
if (raining != state) {
weather = (LanternWeather) (state ? Weathers.RAIN : Weathers.CLEAR);
this.weatherData.setWeather(weather);
this.weatherData.setRemainingDuration(weather.getRandomTicksDuration());
this.weatherData.setRunningDuration(0);
}
}
示例6: setThundering
@Override
public void setThundering(boolean state) {
LanternWeather weather = this.weatherData.getWeather();
final boolean thunderStorm = weather == Weathers.THUNDER_STORM;
if (thunderStorm != state) {
weather = (LanternWeather) (state ? Weathers.THUNDER_STORM : Weathers.CLEAR);
this.weatherData.setWeather(weather);
this.weatherData.setRemainingDuration(weather.getRandomTicksDuration());
this.weatherData.setRunningDuration(0);
}
}
示例7: getWeather
@Override
public LanternWeather getWeather() {
if (this.weatherUniverse != null) {
return this.weatherUniverse.getWeather();
}
return (LanternWeather) Weathers.CLEAR;
}
示例8: execute
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException
{
String weatherString = ctx.<String> getOne("weather").get();
Optional<Integer> duration = ctx.<Integer> getOne("duration");
if (src instanceof Player)
{
Player player = (Player) src;
Weather weather;
if (weatherString.toLowerCase().equals("clear") || weatherString.toLowerCase().equals("sun"))
{
weather = Weathers.CLEAR;
player.sendMessage(Text.of(TextColors.GOLD, "Changing weather to ", TextColors.GRAY, "sunny."));
}
else if (weatherString.toLowerCase().equals("rain"))
{
weather = Weathers.RAIN;
player.sendMessage(Text.of(TextColors.GOLD, "Changing weather to ", TextColors.GRAY, "rain."));
}
else if (weatherString.toLowerCase().equals("storm") || weatherString.toLowerCase().equals("thunderstorm"))
{
weather = Weathers.THUNDER_STORM;
player.sendMessage(Text.of(TextColors.GOLD, "Changing weather to ", TextColors.GRAY, "storm."));
}
else
{
src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Input invalid: " + weatherString));
return CommandResult.success();
}
if (duration.isPresent())
{
player.getWorld().setWeather(weather, duration.get());
}
else
{
player.getWorld().setWeather(weather);
}
return CommandResult.success();
}
else
{
src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You must be a in-game player to do /weather!"));
return CommandResult.success();
}
}