Bon !
Après plusieurs heures de bataille acharnées, j’ai réussi, du moins ça fonctionne.
J’ai procédé comme tel.
@SubscribeEvent
public static void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent event) {
System.out.println("PLAYER LOGGED");
AmyNetwork.sendPacketToDimension(DimensionType.OVERWORLD, new PacketDayCounter(DayCounterWorldSavedData.get(event.getPlayer().world).getAgeInDays()));
System.out.println("PACKET SEND");
}
@Override
public void handle(PacketDayCounter packet, Supplier<NetworkEvent.Context> ctxProvider) {
System.out.println("CHECK SENDER");
ctxProvider.get().enqueueWork(() -> handleClient(packet));
ctxProvider.get().setPacketHandled(true);
}
@OnlyIn(Dist.CLIENT)
private static void handleClient(PacketDayCounter packet) {
EntityPlayerSP player = Minecraft.getInstance().player;
World world = player.world;
System.out.println("WORLD TIME AGE "+packet.worldTime);
DayCounterWorldSavedData.get(world).setAgeInDays(packet.worldTime);
IRenderHandler renderer = world.getDimension().getSkyRenderer();
if(world != null) {
if(world.getDimension().isSurfaceWorld()) {
if (renderer == null) {
IceAgeMod.getLogger().info("Setting sky renderer for dimension {}", world.getDimension().getType());
world.getDimension().setSkyRenderer(new IceAgeSkyRenderer());
} else {
IceAgeMod.getLogger().info("Not hooking sky renderer for dimension {} {}", world.getDimension().getType(), renderer.getClass());
}
}
}
}