Skip to content

Commit

Permalink
Additional network cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko committed Jan 17, 2025
1 parent 5c5268a commit b35846b
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/main/java/fi/dy/masa/minihud/config/Configs.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static class Generic
public static final ConfigBoolean DONT_RESET_SEED_ON_DIMENSION_CHANGE = new ConfigBoolean("dontClearStoredSeedOnDimensionChange", true).apply(GENERIC_KEY);
public static final ConfigBooleanHotkeyed ENTITY_DATA_SYNC = new ConfigBooleanHotkeyed("entityDataSync", false, "").apply(GENERIC_KEY);
public static final ConfigBoolean ENTITY_DATA_SYNC_BACKUP = new ConfigBoolean("entityDataSyncBackup", false).apply(GENERIC_KEY);
public static final ConfigFloat ENTITY_DATA_SYNC_CACHE_TIMEOUT = new ConfigFloat("entityDataSyncCacheTimeout", 1.0f, 0.25f, 5.0f).apply(GENERIC_KEY);
public static final ConfigFloat ENTITY_DATA_SYNC_CACHE_TIMEOUT = new ConfigFloat("entityDataSyncCacheTimeout", 0.75f, 0.25f, 5.0f).apply(GENERIC_KEY);
public static final ConfigBoolean ENTITY_DATA_LOAD_NBT = new ConfigBoolean("entityDataSyncLoadNbt", false).apply(GENERIC_KEY);
//public static final ConfigBoolean FIX_VANILLA_DEBUG_RENDERERS = new ConfigBoolean("enableVanillaDebugRendererFix", true).apply(GENERIC_KEY);
public static final ConfigDouble FONT_SCALE = new ConfigDouble("fontScale", 0.5, 0.01, 100.0).apply(GENERIC_KEY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public <P extends IClientPayloadData> void encodeClientData(P data)
{
if (this.failures > MAX_FAILURES)
{
MiniHUD.printDebug("encodeClientData(): encountered [{}] sendPayload failures, cancelling any Servux join attempt(s)", MAX_FAILURES);
MiniHUD.printDebug("ServuxDebugHandler#encodeClientData(): encountered [{}] sendPayload failures, cancelling any Servux join attempt(s)", MAX_FAILURES);
this.servuxRegistered = false;
ServuxDebugHandler.INSTANCE.unregisterPlayReceiver();
DebugDataManager.getInstance().onPacketFailure();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static ServuxDebugPacket ResponseS2CStart(@Nonnull NbtCompound nbt)
public static ServuxDebugPacket ResponseS2CData(@Nonnull PacketByteBuf buffer)
{
var packet = new ServuxDebugPacket(Type.PACKET_S2C_NBT_RESPONSE_DATA);
packet.buffer = buffer;
packet.buffer = new PacketByteBuf(buffer.copy());
packet.nbt = new NbtCompound();
return packet;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ else if (!ServuxEntitiesHandler.INSTANCE.sendPlayPayload(new ServuxEntitiesPacke
{
if (this.failures > MAX_FAILURES)
{
MiniHUD.printDebug("encodeClientData(): encountered [{}] sendPayload failures, cancelling any Servux join attempt(s)", MAX_FAILURES);
MiniHUD.printDebug("ServuxEntitiesHandler#encodeClientData(): encountered [{}] sendPayload failures, cancelling any Servux join attempt(s)", MAX_FAILURES);
this.servuxRegistered = false;
ServuxEntitiesHandler.INSTANCE.unregisterPlayReceiver();
EntitiesDataManager.getInstance().onPacketFailure();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static ServuxEntitiesPacket ResponseS2CStart(@Nonnull NbtCompound nbt)
public static ServuxEntitiesPacket ResponseS2CData(@Nonnull PacketByteBuf buffer)
{
var packet = new ServuxEntitiesPacket(Type.PACKET_S2C_NBT_RESPONSE_DATA);
packet.buffer = buffer;
packet.buffer = new PacketByteBuf(buffer.copy());
packet.nbt = new NbtCompound();
return packet;
}
Expand All @@ -116,7 +116,7 @@ public static ServuxEntitiesPacket ResponseC2SStart(@Nonnull NbtCompound nbt)
public static ServuxEntitiesPacket ResponseC2SData(@Nonnull PacketByteBuf buffer)
{
var packet = new ServuxEntitiesPacket(Type.PACKET_C2S_NBT_RESPONSE_DATA);
packet.buffer = buffer;
packet.buffer = new PacketByteBuf(buffer.copy());
packet.nbt = new NbtCompound();
return packet;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public <P extends IClientPayloadData> void encodeClientData(P data)
{
if (this.failures > MAX_FAILURES)
{
MiniHUD.printDebug("encodeClientData(): encountered [{}] sendPayload failures, cancelling any Servux join attempt(s)", MAX_FAILURES);
MiniHUD.printDebug("ServuxHudHandler#encodeClientData(): encountered [{}] sendPayload failures, cancelling any Servux join attempt(s)", MAX_FAILURES);
this.servuxRegistered = false;
ServuxHudHandler.INSTANCE.unregisterPlayReceiver();
HudDataManager.getInstance().onPacketFailure();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static ServuxHudPacket ResponseS2CStart(@Nonnull NbtCompound nbt)
public static ServuxHudPacket ResponseS2CData(@Nonnull PacketByteBuf buffer)
{
var packet = new ServuxHudPacket(Type.PACKET_S2C_NBT_RESPONSE_DATA);
packet.buffer = buffer;
packet.buffer = new PacketByteBuf(buffer.copy());
packet.nbt = new NbtCompound();
return packet;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void decodeStructuresPacket(Identifier channel, ServuxStructuresPacket pa
this.servuxRegistered = true;
}
}
// For backwards compat, only if hud_data isn't connected
// For backwards compat, only if hud_data isn't connected, or if Servux is too old
case PACKET_S2C_SPAWN_METADATA ->
{
if (HudDataManager.getInstance().hasServuxServer() == false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public ServuxStructuresPacket(Type type, @Nonnull PacketByteBuf packet)
{
this.packetType = type;
this.nbt = new NbtCompound();
this.buffer = packet;
this.buffer = new PacketByteBuf(packet.copy());
}

@Override
Expand Down

0 comments on commit b35846b

Please sign in to comment.