Skip to content

Commit

Permalink
修复工具无耐久度继续挖掘问题
Browse files Browse the repository at this point in the history
  • Loading branch information
QuanhuZeYu committed Jan 10, 2025
1 parent ec84669 commit bc7a4ae
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
19 changes: 13 additions & 6 deletions src/main/java/club/heiqi/qz_miner/minerModes/AbstractMode.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package club.heiqi.qz_miner.minerModes;

import club.heiqi.qz_miner.Config;
import club.heiqi.qz_miner.MY_LOG;
import club.heiqi.qz_miner.Mod_Main;
import club.heiqi.qz_miner.minerModes.breakBlock.BlockBreaker;
import club.heiqi.qz_miner.statueStorage.SelfStatue;
Expand Down Expand Up @@ -80,7 +81,6 @@ public void run() {
public void onTick(TickEvent.ServerTickEvent event) {
timer = System.currentTimeMillis();
updateTaskType();
// 每次循环只挖掘一个点
while (isRunning.get()) {
try {
Vector3i pos = null;
Expand Down Expand Up @@ -115,7 +115,7 @@ public boolean checkCanBreak(Vector3i pos) {
int meta = world.getBlockMetadata(pos.x, pos.y, pos.z);
EntityPlayerMP player = breaker.player;
ItemInWorldManager iwm = player.theItemInWorldManager;
ItemStack holdItem = iwm.thisPlayerMP.getCurrentEquippedItem();
ItemStack holdItem = player.inventory.getCurrentItem();
// 判断是否为创造模式
if (iwm.getGameType().isCreative()) {
return true;
Expand All @@ -137,14 +137,21 @@ public boolean checkCanBreak(Vector3i pos) {
return false;
}
// 判断工具能否挖掘
if (!checkToolCanBreak(pos)) {
return false;
}
return true;
}

public boolean checkToolCanBreak(Vector3i pos) {
EntityPlayerMP player = breaker.player;
ItemStack holdItem = player.inventory.getCurrentItem();
if (holdItem != null) {
// 检查工具耐久度
if (holdItem.getItemDamage() <= 1) {
if (holdItem.getMaxDamage() - holdItem.getItemDamage() <= 1) {
return false;
}
return block.canHarvestBlock(player, meta);
}
return true;
return breaker.world.getBlock(pos.x, pos.y, pos.z).canHarvestBlock(player, breaker.world.getBlockMetadata(pos.x, pos.y, pos.z));
}

public void register() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public boolean checkCanBreak(Vector3i pos) {
return false;
}
// 判断工具能否挖掘
if (holdItem != null) {
return block.canHarvestBlock(player, meta);
if (!checkToolCanBreak(pos)) {
return false;
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public boolean checkCanBreak(Vector3i pos) {
return false;
}
// 判断工具能否挖掘
if (holdItem != null) {
return block.canHarvestBlock(player, meta);
if (!checkToolCanBreak(pos)) {
return false;
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public boolean checkCanBreak(Vector3i pos) {
return false;
}
// 判断工具能否挖掘
if (holdItem != null) {
return block.canHarvestBlock(player, meta);
if (checkToolCanBreak(pos)) {
return false;
}
return true;
}
Expand Down

0 comments on commit bc7a4ae

Please sign in to comment.