diff --git a/README.md b/README.md index 24269f6b9..1aef752c0 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ There is a dummy user named "Server" in every player's friends list that you can `!pos` - Gets your current coordinate. -`!weather [weather id]` - Changes the current weather. +`!weather [weather id] [climate id]` - Changes the current weather. *More commands will be updated in the [wiki](https://github.com/Melledy/Grasscutter/wiki/).* diff --git a/src/main/java/emu/grasscutter/command/commands/WeatherCommand.java b/src/main/java/emu/grasscutter/command/commands/WeatherCommand.java index 919432ed1..bb9ae4a42 100644 --- a/src/main/java/emu/grasscutter/command/commands/WeatherCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/WeatherCommand.java @@ -8,7 +8,7 @@ import emu.grasscutter.server.packet.send.PacketSceneAreaWeatherNotify; import java.util.List; -@Command(label = "weather", usage = "weather ", +@Command(label = "weather", usage = "weather [climateId]", description = "Changes the weather.", aliases = {"w"}, permission = "player.weather") public final class WeatherCommand implements CommandHandler { @@ -20,20 +20,22 @@ public final class WeatherCommand implements CommandHandler { } if (args.size() < 1) { - CommandHandler.sendMessage(sender, "Usage: weather "); + CommandHandler.sendMessage(sender, "Usage: weather [climateId]"); return; } try { int weatherId = Integer.parseInt(args.get(0)); + int climateId = args.size() > 1 ? Integer.parseInt(args.get(1)) : 1; - ClimateType climate = ClimateType.getTypeByValue(weatherId); + ClimateType climate = ClimateType.getTypeByValue(climateId); + sender.getScene().setWeather(weatherId); sender.getScene().setClimate(climate); sender.getScene().broadcastPacket(new PacketSceneAreaWeatherNotify(sender)); - CommandHandler.sendMessage(sender, "Changed weather to " + weatherId); + CommandHandler.sendMessage(sender, "Changed weather to " + weatherId + " with climate " + climateId); } catch (NumberFormatException ignored) { - CommandHandler.sendMessage(sender, "Invalid weather ID."); + CommandHandler.sendMessage(sender, "Invalid ID."); } } } diff --git a/src/main/java/emu/grasscutter/game/GenshinScene.java b/src/main/java/emu/grasscutter/game/GenshinScene.java index 668902d87..ea462fcdb 100644 --- a/src/main/java/emu/grasscutter/game/GenshinScene.java +++ b/src/main/java/emu/grasscutter/game/GenshinScene.java @@ -34,7 +34,8 @@ public class GenshinScene { private int time; private ClimateType climate; - + private int weather; + public GenshinScene(World world, SceneData sceneData) { this.world = world; this.sceneData = sceneData; @@ -89,10 +90,18 @@ public class GenshinScene { return climate; } + public int getWeather() { + return weather; + } + public void setClimate(ClimateType climate) { this.climate = climate; } + public void setWeather(int weather) { + this.weather = weather; + } + public boolean isInScene(GenshinEntity entity) { return this.entities.containsKey(entity.getId()); } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketSceneAreaWeatherNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketSceneAreaWeatherNotify.java index de26dd064..69c40dba0 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketSceneAreaWeatherNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketSceneAreaWeatherNotify.java @@ -12,7 +12,7 @@ public class PacketSceneAreaWeatherNotify extends GenshinPacket { super(PacketOpcodes.SceneAreaWeatherNotify); SceneAreaWeatherNotify proto = SceneAreaWeatherNotify.newBuilder() - .setWeatherAreaId(1) + .setWeatherAreaId(player.getScene().getWeather()) .setClimateType(player.getScene().getClimate().getValue()) .build();