mirror of
https://github.com/danbulant/flying-squid
synced 2026-07-07 04:00:46 +00:00
add _worldSync to implement modpe api
This commit is contained in:
parent
32c1368107
commit
316ed6b49b
3 changed files with 6 additions and 4 deletions
|
|
@ -37,7 +37,8 @@
|
||||||
"vec3": "0.1.3",
|
"vec3": "0.1.3",
|
||||||
"spiralloop": "1.0.2",
|
"spiralloop": "1.0.2",
|
||||||
"node-dir": "~0.1.9",
|
"node-dir": "~0.1.9",
|
||||||
"uuid-1345": "~0.99.6"
|
"uuid-1345": "~0.99.6",
|
||||||
|
"prismarine-world-sync": "0.1.0"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ function modpeApi() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTile(x, y, z) {
|
function getTile(x, y, z) {
|
||||||
server.world.getBlockType(new vec3(x, y, z));
|
return server._worldSync.getBlockType(new vec3(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
function preventDefault() {
|
function preventDefault() {
|
||||||
|
|
@ -161,7 +161,6 @@ function inject(serv,settings)
|
||||||
|
|
||||||
player._client.on("block_dig", function (packet) {
|
player._client.on("block_dig", function (packet) {
|
||||||
var pos = new vec3(packet.location);
|
var pos = new vec3(packet.location);
|
||||||
var currentlyDugBlock = serv.world.getBlock(pos);
|
|
||||||
if (packet.status == 0 && player.gameMode != 1)
|
if (packet.status == 0 && player.gameMode != 1)
|
||||||
startDestroyBlock(pos.x, pos.y, pos.z, 0);
|
startDestroyBlock(pos.x, pos.y, pos.z, 0);
|
||||||
else if (packet.status == 2)
|
else if (packet.status == 2)
|
||||||
|
|
@ -180,7 +179,7 @@ function inject(serv,settings)
|
||||||
if (packet.location.y < 0) return;
|
if (packet.location.y < 0) return;
|
||||||
useItem(packet.location.x, packet.location.y, packet.location.z,
|
useItem(packet.location.x, packet.location.y, packet.location.z,
|
||||||
packet.heldItem.blockId,
|
packet.heldItem.blockId,
|
||||||
serv.world.getBlockType(new vec3(packet.location.x, packet.location.y, packet.location.z)));
|
serv._worldSync.getBlockType(new vec3(packet.location.x, packet.location.y, packet.location.z)));
|
||||||
});
|
});
|
||||||
|
|
||||||
player.on('modpe', function (command) {
|
player.on('modpe', function (command) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
var Chunk = require('prismarine-chunk')(require("../version"));
|
var Chunk = require('prismarine-chunk')(require("../version"));
|
||||||
var World = require('prismarine-world');
|
var World = require('prismarine-world');
|
||||||
var Vec3 = require('vec3');
|
var Vec3 = require('vec3');
|
||||||
|
var WorldSync = require("prismarine-world-sync");
|
||||||
|
|
||||||
var generations={
|
var generations={
|
||||||
'grass_field':require("../worldGenerations/grass_field"),
|
'grass_field':require("../worldGenerations/grass_field"),
|
||||||
|
|
@ -15,4 +16,5 @@ function inject(serv,options) {
|
||||||
options["generation"].options.seed=options["generation"].options.seed || Math.random()*Math.pow(2, 32);
|
options["generation"].options.seed=options["generation"].options.seed || Math.random()*Math.pow(2, 32);
|
||||||
serv.emit("seed",options["generation"].options.seed);
|
serv.emit("seed",options["generation"].options.seed);
|
||||||
serv.world = new World(generations[options["generation"].name](options["generation"].options));
|
serv.world = new World(generations[options["generation"].name](options["generation"].options));
|
||||||
|
serv._worldSync=new WorldSync(serv.world);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue