2020-04-15 14:22:03 +02:00
|
|
|
package com.minelittlepony.unicopia.client;
|
2019-01-31 16:21:14 +01:00
|
|
|
|
2020-09-23 21:56:57 +02:00
|
|
|
import com.minelittlepony.common.client.gui.element.Cycler;
|
|
|
|
import com.minelittlepony.common.event.ScreenInitCallback;
|
|
|
|
import com.minelittlepony.common.event.ScreenInitCallback.ButtonList;
|
2020-04-15 14:22:03 +02:00
|
|
|
import com.minelittlepony.unicopia.InteractionManager;
|
|
|
|
import com.minelittlepony.unicopia.Race;
|
2020-09-23 21:56:57 +02:00
|
|
|
import com.minelittlepony.unicopia.Unicopia;
|
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-09-23 21:56:57 +02:00
|
|
|
import net.minecraft.client.MinecraftClient;
|
|
|
|
import net.minecraft.client.gui.screen.Screen;
|
|
|
|
import net.minecraft.client.gui.screen.world.CreateWorldScreen;
|
|
|
|
import net.minecraft.client.util.math.MatrixStack;
|
|
|
|
import net.minecraft.util.math.MathHelper;
|
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-09-23 21:56:57 +02:00
|
|
|
public static Race getPreferredRace() {
|
|
|
|
if (!Unicopia.getConfig().ignoresMineLittlePony()
|
|
|
|
&& MinecraftClient.getInstance().player != null) {
|
|
|
|
Race race = MineLPConnector.getPlayerPonyRace();
|
|
|
|
|
|
|
|
if (!race.isDefault()) {
|
|
|
|
return race;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Unicopia.getConfig().getPrefferedRace();
|
|
|
|
}
|
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
|
|
|
InteractionManager.INSTANCE = new ClientInteractionManager();
|
2020-04-22 16:28:20 +02:00
|
|
|
|
2020-04-24 16:10:00 +02:00
|
|
|
URenderers.bootstrap();
|
|
|
|
|
2020-09-23 21:56:57 +02:00
|
|
|
ClientTickEvents.END_CLIENT_TICK.register(this::onTick);
|
|
|
|
ScreenInitCallback.EVENT.register(this::onScreenInit);
|
|
|
|
}
|
2020-04-22 16:28:20 +02:00
|
|
|
|
2020-09-23 21:56:57 +02:00
|
|
|
private void onTick(MinecraftClient client) {
|
|
|
|
KeyBindingsHandler.INSTANCE.tick(client);
|
|
|
|
}
|
2020-04-22 16:28:20 +02:00
|
|
|
|
2020-09-23 21:56:57 +02:00
|
|
|
private void onScreenInit(Screen screen, ButtonList buttons) {
|
|
|
|
if (screen instanceof CreateWorldScreen) {
|
|
|
|
buttons.add(new Cycler(screen.width / 2 + 110, 60, 20, 20) {
|
|
|
|
@Override
|
|
|
|
protected void renderForground(MatrixStack matrices, MinecraftClient mc, int mouseX, int mouseY, int foreColor) {
|
|
|
|
super.renderForground(matrices, mc, mouseX, mouseY, foreColor);
|
|
|
|
if (isMouseOver(mouseX, mouseY)) {
|
|
|
|
renderToolTip(matrices, screen, mouseX, mouseY);
|
|
|
|
}
|
2020-09-22 15:11:20 +02:00
|
|
|
}
|
2020-09-23 21:56:57 +02:00
|
|
|
}).setStyles(
|
|
|
|
Race.EARTH.getStyle(),
|
|
|
|
Race.UNICORN.getStyle(),
|
|
|
|
Race.PEGASUS.getStyle(),
|
|
|
|
Race.BAT.getStyle(),
|
|
|
|
Race.ALICORN.getStyle(),
|
|
|
|
Race.CHANGELING.getStyle()
|
|
|
|
).onChange(i -> {
|
|
|
|
Unicopia.getConfig().setPreferredRace(Race.fromId(i + 1));
|
2020-04-22 16:28:20 +02:00
|
|
|
|
2020-09-23 21:56:57 +02:00
|
|
|
return i;
|
|
|
|
}).setValue(MathHelper.clamp(Unicopia.getConfig().getPrefferedRace().ordinal() - 1, 0, 5));
|
|
|
|
}
|
2020-04-22 16:28:20 +02:00
|
|
|
}
|
2019-01-30 11:26:00 +01:00
|
|
|
}
|