Skip to content
This repository was archived by the owner on Jun 22, 2023. It is now read-only.

Commit 3d38752

Browse files
committed
修复太阳能发电机遮挡bug
1 parent 854fd5a commit 3d38752

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/machine/TechDawn_solarGenerator.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function place(pos, player, data) {
5656
}
5757
//每64tick计算一次是否能够工作
5858
if(!(tick & 63)){
59-
self.dataStorage.setItem("working", blockitem.isDay(self) && (self.getChunk().getHighestBlockAt(self.x, self.z, false) < self.y));
59+
self.dataStorage.setItem("working", blockitem.isDay(self) && (getHeighestBlockAt(self.level, self.x, self.z) <= self.y));
6060
}
6161
}), 1, F((self, damageEvent) => {
6262
//如果被奇奇怪怪的东西伤害就爆炸
@@ -106,6 +106,21 @@ export function place(pos, player, data) {
106106
}
107107
}
108108

109+
/**
110+
* @description 检测指定位置最高方块
111+
* @param {cn.nukkit.level.Level} level
112+
* @param {int} x
113+
* @param {int} z
114+
*/
115+
function getHeighestBlockAt(level, x, z){
116+
for(let i=255; i>=0; i--){
117+
if(level.getBlockIdAt(x, i, z) != 0){
118+
return i;
119+
}
120+
}
121+
return 0;
122+
}
123+
109124
/**
110125
* @description 销毁太阳能发电机
111126
* @param {com.blocklynukkit.loader.other.Entities.BNModel} model

0 commit comments

Comments
 (0)