mirror of
https://github.com/danbulant/flying-squid
synced 2026-07-05 19:20:54 +00:00
serv.setBlock -> player.setBlock
This commit is contained in:
parent
e3b7ad569b
commit
c2b1424743
7 changed files with 21 additions and 25 deletions
|
|
@ -186,10 +186,6 @@ logs a `message`
|
||||||
|
|
||||||
broadcasts `message` to all the players with the optional `color`.
|
broadcasts `message` to all the players with the optional `color`.
|
||||||
|
|
||||||
#### serv.setBlock(position,blockType)
|
|
||||||
|
|
||||||
Saves block in world and sends block update to all players.
|
|
||||||
|
|
||||||
#### serv.getPlayer(username)
|
#### serv.getPlayer(username)
|
||||||
|
|
||||||
Returns player object with that username or, if no such player is on the server, null.
|
Returns player object with that username or, if no such player is on the server, null.
|
||||||
|
|
@ -349,6 +345,10 @@ set player gameMode to `gameMode`
|
||||||
|
|
||||||
handle `command`
|
handle `command`
|
||||||
|
|
||||||
|
#### player.setBlock(position,blockType)
|
||||||
|
|
||||||
|
Saves block in world and sends block update to all players of the same world.
|
||||||
|
|
||||||
#### player.updateHealth(health)
|
#### player.updateHealth(health)
|
||||||
|
|
||||||
update the player health.
|
update the player health.
|
||||||
|
|
|
||||||
|
|
@ -4,19 +4,29 @@ function inject(serv,player)
|
||||||
{
|
{
|
||||||
async function changeBlock(position,blockType)
|
async function changeBlock(position,blockType)
|
||||||
{
|
{
|
||||||
player.getNearby().forEach(function(p) {
|
serv.players.filter(p => p.world==player.world).forEach(function(p) {
|
||||||
p.sendBlock(position, blockType);
|
p.sendBlock(position, blockType);
|
||||||
});
|
});
|
||||||
return await player.world.setBlockType(position,blockType);
|
return await player.world.setBlockType(position,blockType);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendBlock(position, blockType) { // Call from serv.setBlock unless you want "local" fake blocks
|
function sendBlock(position, blockType) { // Call from player.setBlock unless you want "local" fake blocks
|
||||||
player._client.write("block_change",{
|
player._client.write("block_change",{
|
||||||
location:position,
|
location:position,
|
||||||
type:blockType<<4
|
type:blockType<<4
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setBlock(position,blockType)
|
||||||
|
{
|
||||||
|
player.getNearby().forEach(function(player){
|
||||||
|
player.sendBlock(position, blockType);
|
||||||
|
});
|
||||||
|
return player.world.setBlockType(position,blockType);
|
||||||
|
}
|
||||||
|
|
||||||
|
player.setBlock = setBlock;
|
||||||
|
|
||||||
player.changeBlock=changeBlock;
|
player.changeBlock=changeBlock;
|
||||||
player.sendBlock=sendBlock;
|
player.sendBlock=sendBlock;
|
||||||
}
|
}
|
||||||
|
|
@ -73,7 +73,7 @@ function inject(serv, player) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
serv.setBlock(new Vec3(res[1], res[2], res[3]), res[4]);
|
player.setBlock(new Vec3(res[1], res[2], res[3]), res[4]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,12 @@ function inject(serv,player)
|
||||||
if(packet.heldItem.blockId!=323){
|
if(packet.heldItem.blockId!=323){
|
||||||
player.changeBlock(placedPosition,packet.heldItem.blockId);
|
player.changeBlock(placedPosition,packet.heldItem.blockId);
|
||||||
}else if(packet.direction==1){
|
}else if(packet.direction==1){
|
||||||
serv.setBlock(placedPosition, 63);
|
player.setBlock(placedPosition, 63);
|
||||||
player._client.write('open_sign_entity', {
|
player._client.write('open_sign_entity', {
|
||||||
location:placedPosition
|
location:placedPosition
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
serv.setBlock(placedPosition, 68);
|
player.setBlock(placedPosition, 68);
|
||||||
player._client.write('open_sign_entity', {
|
player._client.write('open_sign_entity', {
|
||||||
location:placedPosition
|
location:placedPosition
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
module.exports=inject;
|
|
||||||
|
|
||||||
function inject(serv)
|
|
||||||
{
|
|
||||||
function setBlock(position,blockType)
|
|
||||||
{
|
|
||||||
serv.players.forEach(function(player){
|
|
||||||
player.sendBlock(position, blockType);
|
|
||||||
});
|
|
||||||
return serv.world.setBlockType(position,blockType);
|
|
||||||
}
|
|
||||||
|
|
||||||
serv.setBlock = setBlock;
|
|
||||||
}
|
|
||||||
|
|
@ -22,5 +22,5 @@ function inject(serv,settings)
|
||||||
return serv.players.filter(function(player) {
|
return serv.players.filter(function(player) {
|
||||||
return player.world == loc.world && player.entity.position.distanceTo(loc.position) <= loc.radius;
|
return player.world == loc.world && player.entity.position.distanceTo(loc.position) <= loc.radius;
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -52,7 +52,7 @@ function modpeApi() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setTile(x, y, z, id, damage) {
|
function setTile(x, y, z, id, damage) {
|
||||||
server.setBlock(new vec3(x, y, z), id);
|
player.setBlock(new vec3(x, y, z), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTile(x, y, z) {
|
function getTile(x, y, z) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue