Unicopia/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java

41 lines
1.4 KiB
Java
Raw Normal View History

package com.minelittlepony.unicopia.client;
2019-01-31 16:21:14 +01:00
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.network.Channel;
import com.minelittlepony.unicopia.network.MsgRequestCapabilities;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
2020-01-16 12:35:46 +01:00
import net.minecraft.entity.player.PlayerEntity;
2020-04-25 13:32:33 +02:00
public class UnicopiaClient implements ClientModInitializer {
2020-04-15 15:55:18 +02:00
private final KeyBindingsHandler keyboard = new KeyBindingsHandler();
2020-04-25 13:32:33 +02:00
private Race lastPreferredRace = InteractionManager.instance().getPreferredRace();
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();
ClientTickEvents.END_CLIENT_TICK.register(client -> {
PlayerEntity player = client.player;
2020-04-22 16:28:20 +02:00
if (player != null && !player.removed) {
Race newRace = InteractionManager.instance().getPreferredRace();
2020-04-22 16:28:20 +02:00
if (newRace != lastPreferredRace) {
lastPreferredRace = newRace;
2020-04-22 16:28:20 +02:00
Channel.REQUEST_CAPABILITIES.send(new MsgRequestCapabilities(lastPreferredRace));
}
2020-04-22 16:28:20 +02:00
}
keyboard.tick(client);
});
2020-04-22 16:28:20 +02:00
}
}