9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2026-01-04 15:41:38 +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 // can break now
if (this.miningProgress >= 1f) { if (this.miningProgress >= 1f) {
boolean breakResult = false;
// for simplified adventure break, switch mayBuild temporarily // for simplified adventure break, switch mayBuild temporarily
if (isAdventureMode() && Config.simplifyAdventureBreakCheck()) { if (isAdventureMode() && Config.simplifyAdventureBreakCheck()) {
// check the appearance state // check the appearance state
@@ -777,20 +778,24 @@ public class BukkitServerPlayer extends Player {
// Error might occur so we use try here // Error might occur so we use try here
try { try {
FastNMS.INSTANCE.field$Player$mayBuild(serverPlayer, true); FastNMS.INSTANCE.field$Player$mayBuild(serverPlayer, true);
CoreReflections.method$ServerPlayerGameMode$destroyBlock.invoke(gameMode, blockPos); breakResult = (boolean) CoreReflections.method$ServerPlayerGameMode$destroyBlock.invoke(gameMode, blockPos);
} finally { } finally {
FastNMS.INSTANCE.field$Player$mayBuild(serverPlayer, false); FastNMS.INSTANCE.field$Player$mayBuild(serverPlayer, false);
} }
} }
} else { } else {
// normal break check // normal break check
CoreReflections.method$ServerPlayerGameMode$destroyBlock.invoke(gameMode, blockPos); breakResult = (boolean) CoreReflections.method$ServerPlayerGameMode$destroyBlock.invoke(gameMode, blockPos);
} }
// send break particle + (removed sounds) // send break particle + (removed sounds)
sendPacket(FastNMS.INSTANCE.constructor$ClientboundLevelEventPacket(WorldEvents.BLOCK_BREAK_EFFECT, blockPos, customState.customBlockState().registryId(), false), false); if (breakResult) {
this.lastSuccessfulBreak = currentTick; sendPacket(FastNMS.INSTANCE.constructor$ClientboundLevelEventPacket(WorldEvents.BLOCK_BREAK_EFFECT, blockPos, customState.customBlockState().registryId(), false), false);
this.destroyPos = null; this.lastSuccessfulBreak = currentTick;
this.setIsDestroyingBlock(false, false); this.destroyPos = null;
this.setIsDestroyingBlock(false, false);
} else {
this.setIsDestroyingBlock(true, true);
}
} }
} }
} }

View File

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

View File

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