mirror of
https://github.com/YouHaveTrouble/Enchantio.git
synced 2026-10-26 12:25:28 +00:00
fix tunnelling breaking visualisation when gamerule advance_time is set to false
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<java.version>21</java.version>
|
<java.version>21</java.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<revision>1.16.0</revision>
|
<revision>1.16.1</revision>
|
||||||
</properties>
|
</properties>
|
||||||
<url>https://youhavetrouble.me</url>
|
<url>https://youhavetrouble.me</url>
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,8 @@ public class TunnellingListener implements Listener {
|
|||||||
}
|
}
|
||||||
BlockBreakData data = blockBreakData.get(uuid);
|
BlockBreakData data = blockBreakData.get(uuid);
|
||||||
if (data == null) return;
|
if (data == null) return;
|
||||||
long elapsedTicks = player.getWorld().getFullTime() - data.startedBreakingAtTick();
|
long elapsed = System.currentTimeMillis() - data.startedBreakingAt();
|
||||||
|
long elapsedTicks = elapsed / 50;
|
||||||
float breakSpeed = data.block.getBreakSpeed(player);
|
float breakSpeed = data.block.getBreakSpeed(player);
|
||||||
float ticksNeeded = 1.0f / breakSpeed;
|
float ticksNeeded = 1.0f / breakSpeed;
|
||||||
float progress = Math.min(elapsedTicks / ticksNeeded, 1.0f);
|
float progress = Math.min(elapsedTicks / ticksNeeded, 1.0f);
|
||||||
@@ -74,7 +75,7 @@ public class TunnellingListener implements Listener {
|
|||||||
if (blockBreakData.containsKey(player.getUniqueId())) return;
|
if (blockBreakData.containsKey(player.getUniqueId())) return;
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Set<Block> blocksToBreak = getSquare(block, event.getBlockFace(), tunnellingEnchant.getBlocksPerLevel() * enchantLevel);
|
Set<Block> blocksToBreak = getSquare(block, event.getBlockFace(), tunnellingEnchant.getBlocksPerLevel() * enchantLevel);
|
||||||
blockBreakData.put(player.getUniqueId(), new BlockBreakData(block, block.getWorld().getFullTime(), event.getBlockFace(), blocksToBreak));
|
blockBreakData.put(player.getUniqueId(), new BlockBreakData(block, System.currentTimeMillis(), event.getBlockFace(), blocksToBreak));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
@@ -173,6 +174,6 @@ public class TunnellingListener implements Listener {
|
|||||||
return blocks;
|
return blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
private record BlockBreakData(Block block, long startedBreakingAtTick, BlockFace blockFace, Set<Block> blocksToSyncDamage) {}
|
private record BlockBreakData(Block block, long startedBreakingAt, BlockFace blockFace, Set<Block> blocksToSyncDamage) {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user