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

Commit

Permalink
挖掘机不应在未开启的世界工作
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperIceCN committed Jul 9, 2021
1 parent 004a1ab commit 29657c5
Showing 1 changed file with 2 additions and 27 deletions.
29 changes: 2 additions & 27 deletions src/machine/TechDawn_miner.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export function placeMiner(pos, player, data){
let model = entity.buildModel(pos, "miner", 1, 1, 1, 1, F((self, tick) => {
//每32刻检测一次是否可以挖掘方块
if(!(tick & 31) && self.dataStorage.getItem("storage") >= 20){
//该世界没有开启科技黎明直接忽略
if(!TechDawnConfig.isLevelEnabled(self.getLevel().getName())) return;
/** @type {cn.nukkit.level.Position} */
let dVector = self.getPosition().clone();
let font = Math.floor((45 + self.getYaw()) / 90);
Expand Down Expand Up @@ -102,33 +104,6 @@ export function placeMiner(pos, player, data){
}
}

/**
* @description 处理投掷器/发射器自动冶炼
*/
function ItemSpawnEvent(/**@type {cn.nukkit.event.entity.ItemSpawnEvent}*/event){
//该世界没有开启科技黎明直接忽略
if(!TechDawnConfig.isLevelEnabled(event.getEntity().getLevel().getName())) return;
let itemEntity = event.getEntity();
let item = itemEntity.getItem();
for(let each of itemEntity.getChunk().getEntities()){
if(each.getName() == "BNModel" && each.dataStorage.getItem("techDawn") && each.dataStorage.getItem("name") == "miner" && each.getPosition().floor().equals(itemEntity.getPosition().floor())){
let storage = each.dataStorage.getItem("storage");
if(storage < 160){
return;
}
let recipe = server.getCraftingManager().matchFurnaceRecipe(item);
if(recipe != null){
itemEntity.close();
blockitem.makeDropItem(each.add(0,1,0), recipe.getResult());
particle.drawDot(each.add(0,1,0), 6);
blockitem.makeSound(each, "MOB_ENDERDRAGON_FLAP");
each.dataStorage.setItem("storage", storage - 160);
break;
}
}
}
}

function RightClickBlockEvent(/**@type {cn.nukkit.event.player.PlayerInteractEvent}*/event){
//玩家操作间隔太小直接忽略
if(playerTouchedTime[event.getPlayer().getName()] != null && mills() - playerTouchedTime[event.getPlayer().getName()] < 200) return;
Expand Down

0 comments on commit 29657c5

Please sign in to comment.