2020-04-15 14:22:03 +02:00
|
|
|
package com.minelittlepony.unicopia.client;
|
2019-01-31 16:21:14 +01:00
|
|
|
|
2020-04-15 14:22:03 +02:00
|
|
|
import com.minelittlepony.unicopia.InteractionManager;
|
|
|
|
import com.minelittlepony.unicopia.Race;
|
2020-04-23 23:44:31 +02:00
|
|
|
import com.minelittlepony.unicopia.network.Channel;
|
2020-04-15 14:22:03 +02:00
|
|
|
import com.minelittlepony.unicopia.network.MsgRequestCapabilities;
|
2020-01-27 17:37:22 +01:00
|
|
|
import net.fabricmc.api.ClientModInitializer;
|
2020-09-22 15:11:20 +02:00
|
|
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
2020-01-16 12:35:46 +01:00
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
2019-02-02 21:34:27 +01:00
|
|
|
|
2020-04-25 13:32:33 +02:00
|
|
|
public class UnicopiaClient implements ClientModInitializer {
|
2020-01-27 17:37:22 +01:00
|
|
|
|
2020-04-15 15:55:18 +02:00
|
|
|
private final KeyBindingsHandler keyboard = new KeyBindingsHandler();
|
2019-01-30 11:26:00 +01:00
|
|
|
|
2020-04-25 13:32:33 +02:00
|
|
|
private Race lastPreferredRace = InteractionManager.instance().getPreferredRace();
|
2019-01-30 11:26:00 +01:00
|
|
|
|
2020-04-22 16:28:20 +02:00
|
|
|
@Override
|
|
|
|
public void onInitializeClient() {
|
2020-04-25 13:32:33 +02:00
|
|
|
lastPreferredRace = InteractionManager.instance().getPreferredRace();
|
|
|
|
InteractionManager.INSTANCE = new ClientInteractionManager();
|
2020-04-22 16:28:20 +02:00
|
|
|
|
2020-04-24 16:10:00 +02:00
|
|
|
URenderers.bootstrap();
|
|
|
|
|
2020-09-22 15:11:20 +02:00
|
|
|
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
|
|
|
PlayerEntity player = client.player;
|
2020-04-22 16:28:20 +02:00
|
|
|
|
2020-09-22 15:11:20 +02:00
|
|
|
if (player != null && !player.removed) {
|
|
|
|
Race newRace = InteractionManager.instance().getPreferredRace();
|
2020-04-22 16:28:20 +02:00
|
|
|
|
2020-09-22 15:11:20 +02:00
|
|
|
if (newRace != lastPreferredRace) {
|
|
|
|
lastPreferredRace = newRace;
|
2020-04-22 16:28:20 +02:00
|
|
|
|
2020-09-22 15:11:20 +02:00
|
|
|
Channel.REQUEST_CAPABILITIES.send(new MsgRequestCapabilities(lastPreferredRace));
|
|
|
|
}
|
2020-04-22 16:28:20 +02:00
|
|
|
}
|
|
|
|
|
2020-09-22 15:11:20 +02:00
|
|
|
keyboard.tick(client);
|
|
|
|
});
|
2020-04-22 16:28:20 +02:00
|
|
|
}
|
2019-01-30 11:26:00 +01:00
|
|
|
}
|