Skip to content
This repository was archived by the owner on Feb 9, 2020. It is now read-only.

Commit 4b2e63f

Browse files
committed
fix up some gameruless
1 parent dbdceeb commit 4b2e63f

File tree

2 files changed

+35
-15
lines changed

2 files changed

+35
-15
lines changed

src/pocketnode/network/minecraft/protocol/DataPacket.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -150,21 +150,17 @@ class DataPacket extends BinaryStream {
150150

151151
writeGameRules(rules){
152152
this.writeUnsignedVarInt(rules.length);
153-
rules.forEach((rule, name) => {
154-
this.writeString(name);
155-
this.writeUnsignedVarInt(rule[0]);
156-
switch(rule[0]){
157-
case 1:
158-
this.writeBool(rule[1]);
159-
break;
160-
161-
case 2:
162-
this.writeUnsignedVarInt(rule[1]);
163-
break;
164-
165-
case 3:
166-
this.writeLFloat(rule[1]);
167-
break;
153+
rules.forEach(rule => {
154+
this.writeString(rule.getName());
155+
if(typeof rule.getValue() === "boolean") {
156+
this.writeByte(1);
157+
this.writeBool(rule.getValue());
158+
}else if(Number.isInteger(rule.getValue())){
159+
this.writeByte(2);
160+
this.writeUnsignedVarInt(rule.getValue());
161+
}else if(typeof rule.getValue() === "number" && !Number.isInteger(rule.getValue())){
162+
this.writeByte(3);
163+
this.writeLFloat(rule.getValue());
168164
}
169165
});
170166

src/pocketnode/player/Player.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const ChunkRadiusUpdatedPacket = pocketnode("network/minecraft/protocol/ChunkRad
1313
const TextPacket = pocketnode("network/minecraft/protocol/TextPacket");
1414
const FullChunkDataPacket = pocketnode("network/minecraft/protocol/FullChunkDataPacket");
1515

16+
const GameRule = pocketnode("level/GameRule");
17+
1618
const Vector3 = pocketnode("math/Vector3");
1719

1820
const Skin = pocketnode("entity/Skin");
@@ -488,6 +490,28 @@ class Player extends CommandSender {
488490
pk.enchantmentSeed = 123456;
489491
pk.time = 0;
490492
pk.hasAchievementsDisabled = true;
493+
//pk.gameRules = this.getServer().getDefaultLevel().getGameRules();
494+
pk.gameRules = [
495+
new GameRule(GameRule.COMMAND_BLOCK_OUTPUT, true),
496+
new GameRule(GameRule.DO_DAYLIGHT_CYCLE, true),
497+
new GameRule(GameRule.DO_ENTITY_DROPS, true),
498+
new GameRule(GameRule.DO_FIRE_TICK, true),
499+
new GameRule(GameRule.DO_MOB_LOOT, true),
500+
new GameRule(GameRule.DO_MOB_SPAWNING, true),
501+
new GameRule(GameRule.DO_TILE_DROPS, true),
502+
new GameRule(GameRule.DO_WEATHER_CYCLE, true),
503+
new GameRule(GameRule.DROWNING_DAMAGE, true),
504+
new GameRule(GameRule.FALL_DAMAGE, true),
505+
new GameRule(GameRule.FIRE_DAMAGE, true),
506+
new GameRule(GameRule.KEEP_INVENTORY, false),
507+
new GameRule(GameRule.MOB_GRIEFING, true),
508+
new GameRule(GameRule.NATURAL_REGENERATION, true),
509+
new GameRule(GameRule.PVP, true),
510+
new GameRule(GameRule.SEND_COMMAND_FEEDBACK, true),
511+
new GameRule(GameRule.SHOW_COORDINATES, true),
512+
new GameRule(GameRule.RANDOM_TICK_SPEED, 3),
513+
new GameRule(GameRule.TNT_EXPLODES, true)
514+
];
491515
this.dataPacket(pk);
492516

493517
this.server.addOnlinePlayer(this);

0 commit comments

Comments
 (0)