#Timer lag
1 messages · Page 1 of 1 (latest)
It's the first block placed. The rest of the block place events gets fired immediately after I turn off NetLimiter
hmm, interesting
@EventHandler
public void onPlace(BlockPlaceEvent event) {
Player player = event.getPlayer();
if (BridgeSession.this.player != event.getPlayer()) { return; }
Location location = event.getBlock().getLocation();
placedBlocks.add(location);
boolean inRangeX = ((xMax == xMin || location.getBlockX() > xMin + 2) && location.getBlockX() < xMax - 2);
boolean inRangeY = (location.getBlockY() < yMax);
boolean inRangeZ = (location.getBlockZ() > zMin + 2 && location.getBlockZ() < zMax - 2);
if (!inRangeX || !inRangeY || !inRangeZ) {
event.setCancelled(true);
} else {
BridgeSession.this.blockLoc = location;
if (!count) {
BridgeSession.this.time = BigDecimal.ZERO;
start = Instant.now();
count = true;
replayID = player.getUniqueId() + "_" + Instant.now().toEpochMilli();
ReplayAPI.getInstance().recordReplay(replayID, player, location, player);
}
blocks ++;
if (player.getItemInHand().getAmount() <= 15) {
refill();
}
}
}```
posting so i can see
haha
But I understand the issue now, you're not starting the timer until the player has already moved across all those blocks, thus the advantage
no, I'm helping bestem
o ohk
time to think of a solution to this
isn't it really easy?
-
On place block
| - Check if the player is already bridging
| | - Yes? Do nothing
| | - No? Set the player as bridging, and store their time -
On step on pressure plate
| - Check if the player is already bridging
| | - Yes? Stop the timer and get the difference from the start from now and teleport them to the start
| | - No? Do nothing
bam
its that easy
that's already what they do
the issue is they have laggy players that can freeze up at the start, placing blocks on their client, then it catches up on server-side, but they're already halfway across the map when the timer starts
too easy to cheat and will still be affected by freezing up issue
lagback seems to be the only easy solution tbh
calculate the ping serverside tbh
I want to say you could use transaction packets
but that's getting really hacky for something so simple
I wrote this part of the code over a year ago if that helps... 😅
It works though, since the stored player object has the same memory address as the player object from the event
Here's a video demonstrating the issue @solid rapids
lag them back
That might be solution. What I wish I could do, is to somehow get the time the packet was sent. And then use that time instead of when the packet was received
yeah if you want an easy solution, lag them back
if you want the hard solution, transaction packets (probably?)
yes
indeed
that is possible
Any idea how?
Updated code btw (without debug messages):
@EventHandler
public void onPlace(BlockPlaceEvent event) {
Player player = event.getPlayer();
if (this.player == null || !this.player.getUniqueId().equals(player.getUniqueId())) { return; }
Location location = event.getBlock().getLocation().clone();
placedBlocks.add(location);
boolean inRangeX = ((xMax == xMin || location.getBlockX() > xMin + 2) && location.getBlockX() < xMax - 2);
boolean inRangeY = (location.getBlockY() < yMax);
boolean inRangeZ = (location.getBlockZ() > zMin + 2 && location.getBlockZ() < zMax - 2);
if (!inRangeX || !inRangeY || !inRangeZ) {
event.setCancelled(true);
} else {
this.blockLoc = location;
if (!count) {
this.time = BigDecimal.ZERO;
start = Instant.now();
count = true;
replayID = player.getUniqueId() + "_" + Instant.now().toEpochMilli();
ReplayAPI.getInstance().recordReplay(replayID, player, location, player);
}
blocks ++;
if (player.getItemInHand().getAmount() <= 15) {
refill();
}
}
}
@odd ermine @solid rapids
one moment
well, you could send a transaction packet every tick and when the player starts a lagspike, you'll be waiting for a response from the client for one, so when that returns you can calculate the time between sending it and receiving it, but that's very hacky and idk if there's a better way