Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
0480f10a
Commit
0480f10a
authored
Apr 21, 2022
by
yarik0chka
Browse files
Add a changing weather id
parent
0e7976f9
Changes
4
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
0480f10a
...
@@ -66,7 +66,7 @@ There is a dummy user named "Server" in every player's friends list that you can
...
@@ -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.
`!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/).*
*More commands will be updated in the [wiki](https://github.com/Melledy/Grasscutter/wiki/).*
...
...
src/main/java/emu/grasscutter/command/commands/WeatherCommand.java
View file @
0480f10a
...
@@ -8,7 +8,7 @@ import emu.grasscutter.server.packet.send.PacketSceneAreaWeatherNotify;
...
@@ -8,7 +8,7 @@ import emu.grasscutter.server.packet.send.PacketSceneAreaWeatherNotify;
import
java.util.List
;
import
java.util.List
;
@Command
(
label
=
"weather"
,
usage
=
"weather <weatherId>"
,
@Command
(
label
=
"weather"
,
usage
=
"weather <weatherId>
[climateId]
"
,
description
=
"Changes the weather."
,
aliases
=
{
"w"
},
permission
=
"player.weather"
)
description
=
"Changes the weather."
,
aliases
=
{
"w"
},
permission
=
"player.weather"
)
public
final
class
WeatherCommand
implements
CommandHandler
{
public
final
class
WeatherCommand
implements
CommandHandler
{
...
@@ -20,20 +20,22 @@ public final class WeatherCommand implements CommandHandler {
...
@@ -20,20 +20,22 @@ public final class WeatherCommand implements CommandHandler {
}
}
if
(
args
.
size
()
<
1
)
{
if
(
args
.
size
()
<
1
)
{
CommandHandler
.
sendMessage
(
sender
,
"Usage: weather <weatherId>"
);
CommandHandler
.
sendMessage
(
sender
,
"Usage: weather <weatherId>
[climateId]
"
);
return
;
return
;
}
}
try
{
try
{
int
weatherId
=
Integer
.
parseInt
(
args
.
get
(
0
));
int
weatherId
=
Integer
.
parseInt
(
args
.
get
(
0
));
int
climateId
=
args
.
size
()
>
1
?
Integer
.
parseInt
(
args
.
get
(
1
))
:
1
;
ClimateType
climate
=
ClimateType
.
getTypeByValue
(
weather
Id
);
ClimateType
climate
=
ClimateType
.
getTypeByValue
(
climate
Id
);
sender
.
getScene
().
setWeather
(
weatherId
);
sender
.
getScene
().
setClimate
(
climate
);
sender
.
getScene
().
setClimate
(
climate
);
sender
.
getScene
().
broadcastPacket
(
new
PacketSceneAreaWeatherNotify
(
sender
));
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
)
{
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
"Invalid
weather
ID."
);
CommandHandler
.
sendMessage
(
sender
,
"Invalid ID."
);
}
}
}
}
}
}
src/main/java/emu/grasscutter/game/GenshinScene.java
View file @
0480f10a
...
@@ -34,7 +34,8 @@ public class GenshinScene {
...
@@ -34,7 +34,8 @@ public class GenshinScene {
private
int
time
;
private
int
time
;
private
ClimateType
climate
;
private
ClimateType
climate
;
private
int
weather
;
public
GenshinScene
(
World
world
,
SceneData
sceneData
)
{
public
GenshinScene
(
World
world
,
SceneData
sceneData
)
{
this
.
world
=
world
;
this
.
world
=
world
;
this
.
sceneData
=
sceneData
;
this
.
sceneData
=
sceneData
;
...
@@ -89,10 +90,18 @@ public class GenshinScene {
...
@@ -89,10 +90,18 @@ public class GenshinScene {
return
climate
;
return
climate
;
}
}
public
int
getWeather
()
{
return
weather
;
}
public
void
setClimate
(
ClimateType
climate
)
{
public
void
setClimate
(
ClimateType
climate
)
{
this
.
climate
=
climate
;
this
.
climate
=
climate
;
}
}
public
void
setWeather
(
int
weather
)
{
this
.
weather
=
weather
;
}
public
boolean
isInScene
(
GenshinEntity
entity
)
{
public
boolean
isInScene
(
GenshinEntity
entity
)
{
return
this
.
entities
.
containsKey
(
entity
.
getId
());
return
this
.
entities
.
containsKey
(
entity
.
getId
());
}
}
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketSceneAreaWeatherNotify.java
View file @
0480f10a
...
@@ -12,7 +12,7 @@ public class PacketSceneAreaWeatherNotify extends GenshinPacket {
...
@@ -12,7 +12,7 @@ public class PacketSceneAreaWeatherNotify extends GenshinPacket {
super
(
PacketOpcodes
.
SceneAreaWeatherNotify
);
super
(
PacketOpcodes
.
SceneAreaWeatherNotify
);
SceneAreaWeatherNotify
proto
=
SceneAreaWeatherNotify
.
newBuilder
()
SceneAreaWeatherNotify
proto
=
SceneAreaWeatherNotify
.
newBuilder
()
.
setWeatherAreaId
(
1
)
.
setWeatherAreaId
(
player
.
getScene
().
getWeather
()
)
.
setClimateType
(
player
.
getScene
().
getClimate
().
getValue
())
.
setClimateType
(
player
.
getScene
().
getClimate
().
getValue
())
.
build
();
.
build
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment