9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-28 19:39:11 +00:00

修复事件取消声音被播放的问题

This commit is contained in:
XiaoMoMi
2025-10-25 17:32:58 +08:00
parent 83910b180e
commit b088134311
3 changed files with 15 additions and 9 deletions

View File

@@ -770,6 +770,7 @@ public class BukkitServerPlayer extends Player {
// can break now
if (this.miningProgress >= 1f) {
boolean breakResult = false;
// for simplified adventure break, switch mayBuild temporarily
if (isAdventureMode() && Config.simplifyAdventureBreakCheck()) {
// check the appearance state
@@ -777,20 +778,24 @@ public class BukkitServerPlayer extends Player {
// Error might occur so we use try here
try {
FastNMS.INSTANCE.field$Player$mayBuild(serverPlayer, true);
CoreReflections.method$ServerPlayerGameMode$destroyBlock.invoke(gameMode, blockPos);
breakResult = (boolean) CoreReflections.method$ServerPlayerGameMode$destroyBlock.invoke(gameMode, blockPos);
} finally {
FastNMS.INSTANCE.field$Player$mayBuild(serverPlayer, false);
}
}
} else {
// normal break check
CoreReflections.method$ServerPlayerGameMode$destroyBlock.invoke(gameMode, blockPos);
breakResult = (boolean) CoreReflections.method$ServerPlayerGameMode$destroyBlock.invoke(gameMode, blockPos);
}
// send break particle + (removed sounds)
sendPacket(FastNMS.INSTANCE.constructor$ClientboundLevelEventPacket(WorldEvents.BLOCK_BREAK_EFFECT, blockPos, customState.customBlockState().registryId(), false), false);
this.lastSuccessfulBreak = currentTick;
this.destroyPos = null;
this.setIsDestroyingBlock(false, false);
if (breakResult) {
sendPacket(FastNMS.INSTANCE.constructor$ClientboundLevelEventPacket(WorldEvents.BLOCK_BREAK_EFFECT, blockPos, customState.customBlockState().registryId(), false), false);
this.lastSuccessfulBreak = currentTick;
this.destroyPos = null;
this.setIsDestroyingBlock(false, false);
} else {
this.setIsDestroyingBlock(true, true);
}
}
}
}

View File

@@ -96,7 +96,8 @@ resource-pack:
# .png
texture:
enable: true
exclude: []
exclude:
- pack.png
# .json / .mcmeta
json:
enable: true

View File

@@ -965,7 +965,7 @@ public abstract class AbstractPackManager implements PackManager {
}
}
{
if (Config.optimizeJson()) {
this.plugin.logger().info("> Optimizing json files...");
AtomicLong previousBytes = new AtomicLong(0L);
AtomicLong afterBytes = new AtomicLong(0L);
@@ -1036,7 +1036,7 @@ public abstract class AbstractPackManager implements PackManager {
this.plugin.logger().info("□ Before/After/Ratio: " + formatSize(originalSize) + "/" + formatSize(optimizedSize) + "/" + String.format("%.2f%%", compressionRatio));
}
{
if (Config.optimizeTexture()) {
this.plugin.logger().info("> Optimizing textures...");
AtomicLong previousBytes = new AtomicLong(0L);
AtomicLong afterBytes = new AtomicLong(0L);