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

Commit

Permalink
fix up some gameruless
Browse files Browse the repository at this point in the history
  • Loading branch information
hcortezr committed Mar 3, 2018
1 parent dbdceeb commit 4b2e63f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
26 changes: 11 additions & 15 deletions src/pocketnode/network/minecraft/protocol/DataPacket.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,21 +150,17 @@ class DataPacket extends BinaryStream {

writeGameRules(rules){
this.writeUnsignedVarInt(rules.length);
rules.forEach((rule, name) => {
this.writeString(name);
this.writeUnsignedVarInt(rule[0]);
switch(rule[0]){
case 1:
this.writeBool(rule[1]);
break;

case 2:
this.writeUnsignedVarInt(rule[1]);
break;

case 3:
this.writeLFloat(rule[1]);
break;
rules.forEach(rule => {
this.writeString(rule.getName());
if(typeof rule.getValue() === "boolean") {
this.writeByte(1);
this.writeBool(rule.getValue());
}else if(Number.isInteger(rule.getValue())){
this.writeByte(2);
this.writeUnsignedVarInt(rule.getValue());
}else if(typeof rule.getValue() === "number" && !Number.isInteger(rule.getValue())){
this.writeByte(3);
this.writeLFloat(rule.getValue());
}
});

Expand Down
24 changes: 24 additions & 0 deletions src/pocketnode/player/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const ChunkRadiusUpdatedPacket = pocketnode("network/minecraft/protocol/ChunkRad
const TextPacket = pocketnode("network/minecraft/protocol/TextPacket");
const FullChunkDataPacket = pocketnode("network/minecraft/protocol/FullChunkDataPacket");

const GameRule = pocketnode("level/GameRule");

const Vector3 = pocketnode("math/Vector3");

const Skin = pocketnode("entity/Skin");
Expand Down Expand Up @@ -488,6 +490,28 @@ class Player extends CommandSender {
pk.enchantmentSeed = 123456;
pk.time = 0;
pk.hasAchievementsDisabled = true;
//pk.gameRules = this.getServer().getDefaultLevel().getGameRules();
pk.gameRules = [
new GameRule(GameRule.COMMAND_BLOCK_OUTPUT, true),
new GameRule(GameRule.DO_DAYLIGHT_CYCLE, true),
new GameRule(GameRule.DO_ENTITY_DROPS, true),
new GameRule(GameRule.DO_FIRE_TICK, true),
new GameRule(GameRule.DO_MOB_LOOT, true),
new GameRule(GameRule.DO_MOB_SPAWNING, true),
new GameRule(GameRule.DO_TILE_DROPS, true),
new GameRule(GameRule.DO_WEATHER_CYCLE, true),
new GameRule(GameRule.DROWNING_DAMAGE, true),
new GameRule(GameRule.FALL_DAMAGE, true),
new GameRule(GameRule.FIRE_DAMAGE, true),
new GameRule(GameRule.KEEP_INVENTORY, false),
new GameRule(GameRule.MOB_GRIEFING, true),
new GameRule(GameRule.NATURAL_REGENERATION, true),
new GameRule(GameRule.PVP, true),
new GameRule(GameRule.SEND_COMMAND_FEEDBACK, true),
new GameRule(GameRule.SHOW_COORDINATES, true),
new GameRule(GameRule.RANDOM_TICK_SPEED, 3),
new GameRule(GameRule.TNT_EXPLODES, true)
];
this.dataPacket(pk);

this.server.addOnlinePlayer(this);
Expand Down

0 comments on commit 4b2e63f

Please sign in to comment.