mirror of
https://github.com/danbulant/flying-squid
synced 2026-07-07 04:00:46 +00:00
use prismarine-world : flying-squid has now 9 chunk columns
This commit is contained in:
parent
6cd8ad0013
commit
37e74ae52c
6 changed files with 35 additions and 22 deletions
|
|
@ -4,5 +4,5 @@
|
||||||
"maxPlayers": 10,
|
"maxPlayers": 10,
|
||||||
"onlineMode": true,
|
"onlineMode": true,
|
||||||
"logging": true,
|
"logging": true,
|
||||||
"gameMode": 0
|
"gameMode": 1
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ function inject(serv,player)
|
||||||
location:position,
|
location:position,
|
||||||
type:blockType<<4
|
type:blockType<<4
|
||||||
});
|
});
|
||||||
serv.world.setBlockType(position.x,position.y,position.z,blockType);
|
serv.world.setBlockType(position,blockType);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.changeBlock=changeBlock;
|
player.changeBlock=changeBlock;
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
var Block=require("prismarine-block")(require("../version"));
|
var Vec3 = require("vec3");
|
||||||
|
|
||||||
module.exports=inject;
|
module.exports=inject;
|
||||||
|
|
||||||
function inject(serv,player)
|
function inject(serv,player)
|
||||||
{
|
{
|
||||||
player._client.on("block_dig",function(packet){
|
player._client.on("block_dig",function(packet){
|
||||||
var b=serv.world.getBlock(packet.location.x,packet.location.y,packet.location.z);
|
var pos=new Vec3(packet.location);
|
||||||
currentlyDugBlock=new Block(b.id, b.biome, b.data);
|
currentlyDugBlock=serv.world.getBlock(pos);
|
||||||
if(currentlyDugBlock.type==0) return;
|
if(currentlyDugBlock.type==0) return;
|
||||||
if(packet.status==0 && player.gameMode!=1)
|
if(packet.status==0 && player.gameMode!=1)
|
||||||
startDigging(packet.location);
|
startDigging(pos);
|
||||||
else if(packet.status==2)
|
else if(packet.status==2)
|
||||||
completeDigging(packet.location);
|
completeDigging(pos);
|
||||||
else if(packet.status==1)
|
else if(packet.status==1)
|
||||||
cancelDigging(packet.location);
|
cancelDigging(pos);
|
||||||
else if(packet.status==0 && player.gameMode==1)
|
else if(packet.status==0 && player.gameMode==1)
|
||||||
creativeDigging(packet.location);
|
creativeDigging(pos);
|
||||||
});
|
});
|
||||||
|
|
||||||
function diggingTime(location)
|
function diggingTime(location)
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,14 @@ function inject(serv,player)
|
||||||
}
|
}
|
||||||
function sendMap()
|
function sendMap()
|
||||||
{
|
{
|
||||||
player._client.write('map_chunk', {
|
serv.world.getColumns().forEach(function(column){
|
||||||
x: 0,
|
player._client.write('map_chunk', {
|
||||||
z: 0,
|
x: column.chunkX,
|
||||||
groundUp: true,
|
z: column.chunkZ,
|
||||||
bitMap: 0xffff,
|
groundUp: true,
|
||||||
chunkData: serv.world.dump()
|
bitMap: 0xffff,
|
||||||
|
chunkData: column.column.dump()
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
var World = require('prismarine-chunk');
|
var Chunk = require('prismarine-chunk')(require("../version"));
|
||||||
|
var World = require('prismarine-world');
|
||||||
|
var Vec3 = require('vec3');
|
||||||
|
|
||||||
module.exports=inject;
|
module.exports=inject;
|
||||||
|
|
||||||
|
|
@ -6,12 +8,20 @@ function inject(serv) {
|
||||||
|
|
||||||
serv.world=new World();
|
serv.world=new World();
|
||||||
|
|
||||||
for (var x = 0; x < 16;x++) {
|
for(var chunkX=-1;chunkX<2;chunkX++)
|
||||||
for (var z = 0; z < 16; z++) {
|
{
|
||||||
serv.world.setBlockType(x, 50, z, 2);
|
for(var chunkZ=-1;chunkZ<2;chunkZ++)
|
||||||
for (var y = 0; y < 256; y++) {
|
{
|
||||||
serv.world.setSkyLight(x, y, z, 15);
|
var chunk=new Chunk();
|
||||||
|
for (var x = 0; x < 16;x++) {
|
||||||
|
for (var z = 0; z < 16; z++) {
|
||||||
|
chunk.setBlockType(new Vec3(x, 50, z), 2);
|
||||||
|
for (var y = 0; y < 256; y++) {
|
||||||
|
chunk.setSkyLight(new Vec3(x, y, z), 15);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
serv.world.setColumn(chunkX,chunkZ,chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -25,7 +25,8 @@
|
||||||
"buffers": "0.1.1",
|
"buffers": "0.1.1",
|
||||||
"mocha": "~2.2.5",
|
"mocha": "~2.2.5",
|
||||||
"chai": "~3.2.0",
|
"chai": "~3.2.0",
|
||||||
"prismarine-chunk": "~0.1.0",
|
"prismarine-chunk": "git://github.com/rom1504/prismarine-chunk.git#use-prismarine-block",
|
||||||
|
"prismarine-world": "git://github.com/rom1504/prismarine-world.git#implementation",
|
||||||
"vec3": "0.1.3",
|
"vec3": "0.1.3",
|
||||||
"requireindex": "~1.0.0",
|
"requireindex": "~1.0.0",
|
||||||
"prismarine-block": "0.1.0",
|
"prismarine-block": "0.1.0",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue