GeyserSession: Always set Keep Inventory to true (#1213)

* GeyserSession: Always set Keep Inventory to true

This prevents the client from removing items on death in creative mode if Keep Inventory is true, but doesn't break existing behavior. Essentially, this assures full server-side behavior of the inventory during death.

* Small comment update

* OK, it was fine before the last commit, but make it better
This commit is contained in:
Camotoy 2020-09-02 00:37:24 -04:00 committed by GitHub
parent d717085c6b
commit 6f161a380f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -301,10 +301,13 @@ public class GeyserSession implements CommandSender {
attributesPacket.setAttributes(attributes);
upstream.sendPacket(attributesPacket);
GameRulesChangedPacket gamerulePacket = new GameRulesChangedPacket();
// Only allow the server to send health information
// Setting this to false allows natural regeneration to work false but doesn't break it being true
GameRulesChangedPacket gamerulePacket = new GameRulesChangedPacket();
gamerulePacket.getGameRules().add(new GameRuleData<>("naturalregeneration", false));
// Don't let the client modify the inventory on death
// Setting this to true allows keep inventory to work if enabled but doesn't break functionality being false
gamerulePacket.getGameRules().add(new GameRuleData<>("keepinventory", true));
upstream.sendPacket(gamerulePacket);
}