net.minecraft.network.play.server.SPacketTimeUpdate Java Examples
The following examples show how to use
net.minecraft.network.play.server.SPacketTimeUpdate.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TickRateManager.java From seppuku with GNU General Public License v3.0 | 5 votes |
@Listener public void receivePacket(EventReceivePacket event) { if (event.getStage() == EventStageable.EventStage.PRE) { if (event.getPacket() instanceof SPacketTimeUpdate) { if (this.prevTime != -1) { this.ticks[this.currentTick % this.ticks.length] = MathHelper.clamp((20.0f / ((float) (System.currentTimeMillis() - this.prevTime) / 1000.0f)), 0.0f, 20.0f); this.currentTick++; } this.prevTime = System.currentTimeMillis(); } } }
Example #2
Source File: CraftWorld.java From Kettle with GNU General Public License v3.0 | 5 votes |
public void setFullTime(long time) { world.setWorldTime(time); // Forces the client to update to the new time immediately for (Player p : getPlayers()) { CraftPlayer cp = (CraftPlayer) p; if (cp.getHandle().connection == null) { continue; } cp.getHandle().connection.sendPacket(new SPacketTimeUpdate(cp.getHandle().world.getTotalWorldTime(), cp.getHandle().getPlayerTime(), cp.getHandle().world.getGameRules().getBoolean("doDaylightCycle"))); } }
Example #3
Source File: TickRateService.java From ForgeHax with MIT License | 5 votes |
@SubscribeEvent public void onPacketPreceived(PacketEvent.Incoming.Pre event) { if (event.getPacket() instanceof SPacketTimeUpdate) { long currentTimeMillis = System.currentTimeMillis(); if (timeLastTimeUpdate != -1) { TICK_DATA.onTimePacketIncoming(currentTimeMillis - timeLastTimeUpdate); } timeLastTimeUpdate = currentTimeMillis; INSTANCE.timeLastTimeUpdate = timeLastTimeUpdate; } }
Example #4
Source File: TimerMod.java From ForgeHax with MIT License | 5 votes |
@SubscribeEvent public void onPacketPreceived(PacketEvent.Incoming.Pre event) { if (event.getPacket() instanceof SPacketTimeUpdate && tpsSync.getAsBoolean()) { TickRateService.TickRateData data = TickRateService.getTickData(); if (data.getSampleSize() > 0) { TickRateService.TickRateData.CalculationData point = data.getPoint(); setSpeed((float) (DEFAULT_SPEED / (point.getAverage() / 20))); } } else { updateTimer(); } }