本文整理汇总了Java中org.spongepowered.api.world.weather.Weathers类的典型用法代码示例。如果您正苦于以下问题:Java Weathers类的具体用法?Java Weathers怎么用?Java Weathers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Weathers类属于org.spongepowered.api.world.weather包,在下文中一共展示了Weathers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setWeathers
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@Inject(method = "registerDefaults", at = @At("RETURN"), remap = false)
private void setWeathers(CallbackInfo ci) {
// The weathers
this.weathers = Maps.newHashMap();
// Sponge has only a lookup by the name of the weather,
// we will also add the by identifier
for (Weather weather : this.weatherMappings.values()) {
this.weathers.put(weather.getId().toLowerCase(), (WeatherType) weather);
this.weathers.put(weather.getName().toLowerCase(), (WeatherType) weather);
}
// Add some default aliases and command messages
((IMixinWeather) Weathers.THUNDER_STORM).setAliases(Lists.newArrayList("storm", "thunder"));
((IMixinWeather) Weathers.THUNDER_STORM).setCommandMessage("commands.weather.thunder");
((IMixinWeather) Weathers.THUNDER_STORM).setRainStrength(1f);
((IMixinWeather) Weathers.THUNDER_STORM).setDarkness(1f);
// The rate is the chance for every chunk, every tick
((IMixinWeather) Weathers.THUNDER_STORM).setLightningRate(0.00001f);
((IMixinWeather) Weathers.THUNDER_STORM).setThunderRate(1f);
((IMixinWeather) Weathers.CLEAR).setAliases(Lists.newArrayList("sunny"));
((IMixinWeather) Weathers.CLEAR).setCommandMessage("commands.weather.clear");
((IMixinWeather) Weathers.RAIN).setAliases(Lists.newArrayList("rainy"));
((IMixinWeather) Weathers.RAIN).setCommandMessage("commands.weather.rain");
((IMixinWeather) Weathers.RAIN).setRainStrength(1f);
this.addAliases(Weathers.THUNDER_STORM);
this.addAliases(Weathers.CLEAR);
}
示例2: cast
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@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;
}
示例3: aquireSpec
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
public static CommandSpec aquireSpec() {
Map<String, Weather> map = new HashMap<>();
map.put("clear", Weathers.CLEAR);
map.put("rain", Weathers.RAIN);
map.put("thunder", Weathers.THUNDER_STORM);
return CommandSpec.builder()
.description(Text.of("Change the weather"))
.permission("skree.weathercommand")
.arguments(
seq(
onlyOne(choices(Text.of("type"), map)),
// TODO should be onlyOne(catalogedElement(Text.of("type"), game, Weather.class)),
onlyOne(optionalWeak(integer(Text.of("duration")))),
onlyOne(optional(world(Text.of("world"))))
)
)
.executor(new WeatherCommand()).build();
}
示例4: parseValue
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@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));
}
}
示例5: getWeather
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
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);
}
示例6: getMessage
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
private EMessageSender getMessage(final Weather weather) {
if (weather.equals(Weathers.RAIN)) {
return EEMessages.WEATHER_RAIN.sender();
} else if (weather.equals(Weathers.THUNDER_STORM)) {
return EEMessages.WEATHER_STORM.sender();
}
return EEMessages.WEATHER_SUN.sender();
}
示例7: getMessageDuration
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
private EMessageSender getMessageDuration(final Weather weather) {
if (weather.equals(Weathers.RAIN)) {
return EEMessages.WEATHER_RAIN_DURATION.sender();
} else if (weather.equals(Weathers.THUNDER_STORM)) {
return EEMessages.WEATHER_STORM_DURATION.sender();
}
return EEMessages.WEATHER_SUN_DURATION.sender();
}
示例8: setCleanWeatherTime
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@Overwrite
public void setCleanWeatherTime(int time) {
if (this.world != null) {
if (time > 0) {
this.world.forecast(Weathers.CLEAR, time);
}
} else {
this.cleanWeatherTime = time;
}
}
示例9: setRainTime
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@Overwrite
public void setRainTime(int time) {
if (this.world != null) {
this.raining = time > 0;
if (this.thundering && this.thunderTime > 0 && this.raining) {
this.world.forecast(Weathers.THUNDER_STORM, time);
} else if (this.raining) {
this.world.forecast(Weathers.RAIN, time);
} else {
this.world.forecast(Weathers.CLEAR, this.cleanWeatherTime);
}
} else {
this.rainTime = time;
}
}
示例10: setThunderTime
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@Overwrite
public void setThunderTime(int time) {
if (this.world != null) {
this.thundering = time > 0;
if (this.thundering) {
this.world.forecast(Weathers.THUNDER_STORM, time);
} else if (this.raining && this.rainTime > 0) {
this.world.forecast(Weathers.RAIN, this.rainTime);
} else {
this.world.forecast(Weathers.CLEAR, this.cleanWeatherTime);
}
} else {
this.thunderTime = time;
}
}
示例11: setThundering
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@Overwrite
public void setThundering(boolean flag) {
if (this.world != null) {
if (!flag) {
if (this.raining && this.rainTime > 0) {
this.world.forecast(Weathers.RAIN, this.rainTime);
} else {
this.world.forecast(Weathers.CLEAR, this.cleanWeatherTime);
}
}
} else {
this.raining = flag;
}
}
示例12: setRaining
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@Overwrite
public void setRaining(boolean flag) {
if (this.world != null) {
if (!flag) {
this.world.forecast(Weathers.CLEAR, this.cleanWeatherTime);
}
} else {
this.raining = flag;
}
}
示例13: calculateInitialWeather
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@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();
}
示例14: setRaining
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@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);
}
}
示例15: setThundering
import org.spongepowered.api.world.weather.Weathers; //导入依赖的package包/类
@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);
}
}