Fixes for spaces and documentation

This commit is contained in:
Ethan 2024-07-24 16:37:10 +08:00
parent b2a5cd5c4b
commit b8b05177b8
2 changed files with 20 additions and 4 deletions

View file

@ -29,7 +29,17 @@ package org.geysermc.geyser.entity.type;
* Implemented onto anything that should have code ran every Minecraft tick - 50 milliseconds. * Implemented onto anything that should have code ran every Minecraft tick - 50 milliseconds.
*/ */
public interface Tickable { public interface Tickable {
default void drawTick() {}; /*
void tick(); * This function gets called every tick at all times, even when the server requests that the
* game should be frozen. This should be used for updating things that are always
* client side updated on Java, regardless of if the server is frozen or not.
*/
default void drawTick() {
}
/*
* This function gets called every game tick as long as the
* game tick loop isn't frozen.
*/
void tick();
} }

View file

@ -561,6 +561,10 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
private MinecraftProtocol protocol; private MinecraftProtocol protocol;
private boolean tickingFrozen = false; private boolean tickingFrozen = false;
/*
* The amount of ticks requested by the server that the
* game should proceed with, even if game ticking is frozen.
*/
@Setter @Setter
private int stepTicks = 0; private int stepTicks = 0;
private boolean gameShouldUpdate = true; private boolean gameShouldUpdate = true;
@ -1208,6 +1212,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
camera().removeFog("minecraft:fog_crimson_forest"); camera().removeFog("minecraft:fog_crimson_forest");
isInWorldBorderWarningArea = false; isInWorldBorderWarningArea = false;
} }
gameShouldUpdate = !tickingFrozen || stepTicks > 0; gameShouldUpdate = !tickingFrozen || stepTicks > 0;
if (stepTicks > 0) { if (stepTicks > 0) {
--stepTicks; --stepTicks;
@ -1218,6 +1223,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
entity.tick(); entity.tick();
} }
} }
if (armAnimationTicks >= 0) { if (armAnimationTicks >= 0) {
// As of 1.18.2 Java Edition, it appears that the swing time is dynamically updated depending on the // As of 1.18.2 Java Edition, it appears that the swing time is dynamically updated depending on the
// player's effect status, but the animation can cut short if the duration suddenly decreases // player's effect status, but the animation can cut short if the duration suddenly decreases
@ -1643,7 +1649,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
/** /**
* Send a packet to the remote server if in the specified state. * Send a packet to the remote server if in the specified state.
* *
* @param packet the java edition packet from MCProtocolLib * @param packet the java edition packet from MCProtocolLib
* @param intendedState the state the client should be in * @param intendedState the state the client should be in
*/ */
public void sendDownstreamPacket(Packet packet, ProtocolState intendedState) { public void sendDownstreamPacket(Packet packet, ProtocolState intendedState) {
@ -1727,7 +1733,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
* Send a gamerule value to the client * Send a gamerule value to the client
* *
* @param gameRule The gamerule to send * @param gameRule The gamerule to send
* @param value The value of the gamerule * @param value The value of the gamerule
*/ */
public void sendGameRule(String gameRule, Object value) { public void sendGameRule(String gameRule, Object value) {
GameRulesChangedPacket gameRulesChangedPacket = new GameRulesChangedPacket(); GameRulesChangedPacket gameRulesChangedPacket = new GameRulesChangedPacket();