
Lv.1
半退……
签名:目标: 赞460/500 收藏168/200 再创作170/200 浏览6584/1w 粉丝792/1k 首页3/1 ✔ 称号潜力新星/进阶高手
在 【岛3教程】SQL时间排行榜注释版! 中回复
改正建议:1.何必在onPlayerJoin里面套个onPlayerLeave呢?而且还不cancle,就等于每进一个人都要加一个检测 2.计时过于复杂,使用onTick更容易造成卡顿,建议改为进入时设置玩家变量startTime=newDate().valueOf()作为开始时间,结束后用newDate().valueOf()与开始时间做差即可,单位ms
2022-03-14T17:09:06 点赞:0
在 【喵】地图方块压缩代码+解码 中回复
world.say('开始保存');
let blocks = [];
function append(item) {
if (blocks.length > 0 && blocks[blocks.length - 1][0] === item) {
blocks[blocks.length - 1][1] += 1;
}else {
blocks.push([item, 1]);
};
};
function forEach(fun) {
for (let l of blocks) {
for (let x = 0; x < l[1]; x++) {
fun(l[0]);
};
};
};
let index = 0;
(async () => {
for (y = 0; y < 128; y++) {
for (x = 0; x < 128; x++) {
for (z = 0; z < 128; z++) {
append(voxels.getVoxel(x, y, z));
index++;
if (index % 20000 == 0) {
world.say(`保存中${index / 128 ** 3 * 100}%`);
};
};
};
};
world.say('保存完毕');
})();
let t = [];
blocks.forEach((i) => {
t.push([i[0], i[1]]);
});
global.saveBlocks = t;
world.say('开始解码');
let index = 0;
let bolckIndex = 0;
let block = saveBlocks[0][0];
let lastIndex = saveBlocks[0][1];
(async () => {
for (y = 0; y < 128; y++) {
for (x = 0; x < 128; x++) {
for (z = 0; z < 128; z++) {
voxels.setVoxel(x, y, z, block);
index++;
if (index == lastIndex) {
bolckIndex++;
lastIndex += saveBlocks[bolckIndex][1];
block = saveBlocks[bolckIndex][0];
};
if (index % 200000 == 0){
world.say(`解码中${index / 128 ** 3 * 100}%`);
}
};
};
}
})();
world.say('解码完成');2022-03-15T16:45:05 点赞:2
在 【神岛JS萌新教程】BoxJS 从入门到实战 第七期——另一种条件判断! 中回复
比如是
switch(a){
case 1:
world.say(1)
case 2:
world.say(2)
case 3:
world.say(3)
}
这个代码,都没有用break,当a=1时,会同时广播123,同理,为2时会广播23
也就是当表达式 case n相等时会一直运行到case n后面第一个break结束,不会继续判断
可以试试,这是个很好的例子
2022-03-21T17:16:50 点赞:1
在 【神岛JS萌新教程】BoxJS 从入门到实战 第九期——无所不能的函数(二) 中回复
注:箭头函数的格式如果是 leti=(a,b,c)=>a+b+c 不加return不会有bug 但是如果有{} leti=(a,b,c)=>{a+b+c} 不加return有时会出现解析错误(这东西我之前研究了半天,害的老惨了
2022-04-03T21:11:18 点赞:1
在 学习代码岛3.0 3D创作,台式电脑配置最低要怎么样的? 中回复
1.能上网
2.有Google浏览器(edge也不是不行
其他关系不大(体验感好不好的问题
2022-04-04T20:59:27 点赞:0
在 求助:在文件里修改了模型后,如何应用????? 中回复
模型点开的界面的左边的最下面的那个点一下就是地图里的所有模型,也可以搜索(虽然有bug但往下还是找得到的
2022-04-14T16:56:43 点赞:0
在 [BOX3]Kick体验号优解 中回复
world.onPlayerJoin(({entity})=>{
if(/^[code]+\d+\d+\d+\d+$/.test(entity.player.boxId)){ // 如果boxId格式为codexxxx(xxxx为数字)就代表是体验号
entity.player.kick() // 再也不见
}
})2022-04-20T20:35:21 点赞:0
在 【神岛教程】如何做出高空摔落 中回复
voxels.isFluid = (voxel) => { return ['water', 364, 'strawberry_juice', 412, 'lime_juice', 414, 'blueberry_juice', 416, 'lemon_juice', 418, 'grape_juice', 420, voxels.name(422), 422, voxels.name(424), 424, voxels.name(426), 426, voxels.name(428), 428, voxels.name(430), 430].includes(voxel) }
var xzCo = 0.44921875
var yCo = 1.6
world.onPlayerJoin(async ({ entity }) => {
entity.enableDamage = true
entity.maxHp = 100
entity.hp = 100
const g = voxels.getVoxel
entity.fallHigh = 0
entity.highY = entity.position.y
entity.contactList = () => {
return [
g(entity.position.x + xzCo, entity.position.y - yCo, entity.position.z + xzCo),
g(entity.position.x + xzCo, entity.position.y - yCo, entity.position.z - xzCo),
g(entity.position.x - xzCo, entity.position.y - yCo, entity.position.z + xzCo),
g(entity.position.x - xzCo, entity.position.y - yCo, entity.position.z - xzCo),
g(entity.position.x + xzCo, entity.position.y - yCo, entity.position.z),
g(entity.position.x - xzCo, entity.position.y - yCo, entity.position.z),
g(entity.position.x, entity.position.y - yCo, entity.position.z + xzCo),
g(entity.position.x, entity.position.y - yCo, entity.position.z - xzCo),
g(entity.position.x, entity.position.y - yCo, entity.position.z)]
}
entity.ifContact = function () {
for (const count of entity.
contactList()) {
if (count != 0) {
if (voxels.isFluid(count)) {
this.fallHigh = 0
return false
} return true
}
} return false
}
while (entity) {
await sleep(64)
if (entity.ifContact()) {
if (voxels.isFluid(g(entity.position.x, entity.position.y - 1, entity.position.z))) continue
if (entity.fallHigh > 6) {
const hurt = entity.fallHigh / 3 * 18 * ~(world.gravity * 100) / 100
entity.hurt(hurt)
entity.player.directMessage(`你受到${hurt}点高空伤害`)
entity.fallHigh = 0
} else {
entity.fallHigh = 0
}
} if (entity.highY > Math.floor(entity.position.y)) {
entity.fallHigh += 1
entity.highY = Math.floor(entity.position.y)
} else {
entity.highY = Math.floor(entity.position.y)
}
}
})
world.onFluidEnter(({ entity }) => {
if (entity.isPlayer) entity.fallHigh = 0
})
修改了以下几点:
1.优化了格式,看起来更方便了
2.调高阈值,不然正常力度一个二段跳都能有接近10点伤害
3.稍微优化了代码
2022-05-02T20:58:11 点赞:5