Skip to content

Commit

Permalink
Reapply resource pack after config state
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrygames committed Oct 7, 2023
1 parent c076f04 commit fadf839
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public class ConfigSessionHandler implements MinecraftSessionHandler {
private final VelocityServerConnection serverConn;
private final CompletableFuture<Impl> resultFuture;

private ResourcePackInfo resourcePackToApply;

private State state;

/**
Expand All @@ -77,7 +79,9 @@ public class ConfigSessionHandler implements MinecraftSessionHandler {
}

@Override
public void deactivated() {
public void activated() {
resourcePackToApply = serverConn.getPlayer().getAppliedResourcePack();
serverConn.getPlayer().clearAppliedResourcePack();
}

@Override
Expand Down Expand Up @@ -126,6 +130,7 @@ public boolean handle(ResourcePackRequest packet) {
ResourcePackInfo.Origin.DOWNSTREAM_SERVER);
}

resourcePackToApply = null;
serverConn.getPlayer().queueResourcePack(toSend);
} else if (serverConn.getConnection() != null) {
serverConn.getConnection().write(new ResourcePackResponse(packet.getHash(),
Expand Down Expand Up @@ -158,6 +163,9 @@ public boolean handle(FinishedUpdate packet) {
smc.setActiveSessionHandler(StateRegistry.PLAY,
new TransitionSessionHandler(server, serverConn, resultFuture));
}
if (serverConn.getPlayer().getAppliedResourcePack() == null && resourcePackToApply != null) {
serverConn.getPlayer().queueResourcePack(resourcePackToApply);
}
smc.setAutoReading(true);
}, smc.eventLoop());
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,13 @@ && getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_17) >= 0) {
return pendingResourcePack;
}

/**
* Clears the applied resource pack field.
*/
public void clearAppliedResourcePack() {
appliedResourcePack = null;
}

/**
* Processes a client response to a sent resource-pack.
*/
Expand Down

0 comments on commit fadf839

Please sign in to comment.