Skip to content

Conversation

@Iaiao
Copy link
Contributor

@Iaiao Iaiao commented Jan 17, 2022

Add an ability to change gamemode from plugins

Status

  • Ready
  • Development
  • Hold

Description

Adds GamemodeEvent, InstabreakChangeEvent, FlyingAbilityChangeEvent, BuildingAbilityChangeEvent, and InvulnerabilityChangeEvent. This code was taken from #487 (I had to implement this for /gamemode command), but I think this change deserves a separate PR.

Related issues

Checklist

  • Ran cargo fmt, cargo clippy --all-targets, cargo build --release and cargo test and fixed any generated errors!
  • Removed unnecessary commented out code
  • Used specific traces (if you trace actions please specify the cause i.e. the player)

Note: if you locally don't get any errors, but GitHub Actions fails (especially at clippy) you might want to check your rust toolchain version. You can then feel free to fix these warnings/errors in your PR.

pub fn change_gamemode(&self, gamemode: Gamemode) {
self.send_packet(ChangeGameState {
reason: StateReason::ChangeGameMode,
value: gamemode as u8 as f32,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change the protocol to take Gamemode and implement write on game mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ChangeGameState requires it to be f64, so I did it in a different way.

});
}
for (entity, flying) in fly_changes {
if flying {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if statement is redundant, just create CreativeFlyingEvent with the value of flying?

@Defman Defman merged commit 77f1ace into feather-rs:main Jan 19, 2022
@Iaiao Iaiao mentioned this pull request Jan 20, 2022
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants