Skip to content

Commit

Permalink
Fixed a synchronization issue
Browse files Browse the repository at this point in the history
  • Loading branch information
apace100 committed Aug 5, 2020
1 parent f03687c commit 46457c7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/io/github/apace100/origins/mixin/LoginMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@
import net.minecraft.server.PlayerManager;
import net.minecraft.server.network.ServerPlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.List;

@Mixin(PlayerManager.class)
public class LoginMixin {
public abstract class LoginMixin {

@Shadow public abstract List<ServerPlayerEntity> getPlayerList();

@Inject(at = @At("TAIL"), method = "Lnet/minecraft/server/PlayerManager;onPlayerConnect(Lnet/minecraft/network/ClientConnection;Lnet/minecraft/server/network/ServerPlayerEntity;)V")
private void openOriginsGui(ClientConnection connection, ServerPlayerEntity player, CallbackInfo info) {
Expand All @@ -43,5 +48,9 @@ private void openOriginsGui(ClientConnection connection, ServerPlayerEntity play
data.writeBoolean(true);
ServerSidePacketRegistry.INSTANCE.sendToPlayer(player, ModPackets.OPEN_ORIGIN_SCREEN, data);
}
List<ServerPlayerEntity> playerList = getPlayerList();
playerList.forEach(spe -> {
ModComponents.ORIGIN.get(spe).syncWith(player);
});
}
}

0 comments on commit 46457c7

Please sign in to comment.