From 5495d7526043b3c458de2ce61fc1554fb22d692b Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 2 Feb 2019 13:23:22 +0200 Subject: [PATCH] Move the minelp code into one location --- .../com/minelittlepony/unicopia/MineLP.java | 34 ++++++++++++++++++- .../com/minelittlepony/unicopia/Race.java | 28 --------------- .../unicopia/UnicopiaClient.java | 6 ++-- 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/MineLP.java b/src/main/java/com/minelittlepony/unicopia/MineLP.java index c8791272..e1997a32 100644 --- a/src/main/java/com/minelittlepony/unicopia/MineLP.java +++ b/src/main/java/com/minelittlepony/unicopia/MineLP.java @@ -1,8 +1,11 @@ package com.minelittlepony.unicopia; import com.minelittlepony.MineLittlePony; +import com.minelittlepony.pony.data.IPony; import com.minelittlepony.pony.data.PonyRace; +import net.minecraft.client.Minecraft; + public final class MineLP { private static boolean checkComplete; private static boolean modIsActive; @@ -10,7 +13,7 @@ public final class MineLP { /** * Returns true if mine little pony is present. That's all we need. */ - public static boolean modIsActive() { + static boolean modIsActive() { if (!checkComplete) { try { MineLittlePony.getInstance(); @@ -23,4 +26,33 @@ public final class MineLP { } return modIsActive; } + + public static Race getPlayerPonyRace() { + + if (!modIsActive()) { + return Race.HUMAN; + } + + switch (IPony.forPlayer(Minecraft.getMinecraft().player).getRace(false)) { + case ALICORN: + return Race.ALICORN; + case CHANGELING: + case REFORMED_CHANGELING: + return Race.CHANGELING; + case ZEBRA: + case EARTH: + return Race.EARTH; + case GRIFFIN: + case HIPPOGRIFF: + case PEGASUS: + case BATPONY: + return Race.PEGASUS; + case SEAPONY: + case UNICORN: + return Race.UNICORN; + default: + return Race.EARTH; + + } + } } \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/unicopia/Race.java b/src/main/java/com/minelittlepony/unicopia/Race.java index 944e8ada..4cf901eb 100644 --- a/src/main/java/com/minelittlepony/unicopia/Race.java +++ b/src/main/java/com/minelittlepony/unicopia/Race.java @@ -4,8 +4,6 @@ import java.util.HashMap; import java.util.Map; import com.google.common.base.Strings; -import com.minelittlepony.pony.data.PonyRace; -import com.minelittlepony.unicopia.forgebullshit.FUF; public enum Race { /** @@ -79,32 +77,6 @@ public enum Race { return def; } - // Commented so we don't alert overlord forge - @FUF(reason = "@SideOnly(Side.CLIENT)") - public static Race fromPonyRace(PonyRace ponyRace) { - switch (ponyRace) { - case ALICORN: - return ALICORN; - case CHANGELING: - case REFORMED_CHANGELING: - return CHANGELING; - case ZEBRA: - case EARTH: - return EARTH; - case GRIFFIN: - case HIPPOGRIFF: - case PEGASUS: - case BATPONY: - return PEGASUS; - case SEAPONY: - case UNICORN: - return UNICORN; - default: - return EARTH; - - } - } - public static Race fromName(String name) { return fromName(name, EARTH); } diff --git a/src/main/java/com/minelittlepony/unicopia/UnicopiaClient.java b/src/main/java/com/minelittlepony/unicopia/UnicopiaClient.java index 569f2085..58cf072d 100644 --- a/src/main/java/com/minelittlepony/unicopia/UnicopiaClient.java +++ b/src/main/java/com/minelittlepony/unicopia/UnicopiaClient.java @@ -5,7 +5,6 @@ import java.util.UUID; import javax.annotation.Nullable; import com.minelittlepony.jumpingcastle.api.Target; -import com.minelittlepony.pony.data.IPony; import com.minelittlepony.unicopia.hud.UHud; import com.minelittlepony.unicopia.input.Keyboard; import com.minelittlepony.unicopia.inventory.gui.GuiOfHolding; @@ -47,9 +46,8 @@ public class UnicopiaClient extends UClient { private static Race getclientPlayerRace() { if (!UConfig.getInstance().ignoresMineLittlePony() - && Minecraft.getMinecraft().player != null - && MineLP.modIsActive()) { - Race race = Race.fromPonyRace(IPony.forPlayer(Minecraft.getMinecraft().player).getRace(false)); + && Minecraft.getMinecraft().player != null) { + Race race = MineLP.getPlayerPonyRace(); if (!race.isDefault()) { return race;