diff --git a/src/main/java/com/minelittlepony/api/pony/IPony.java b/src/main/java/com/minelittlepony/api/pony/IPony.java index 525b89f6..e87940a4 100644 --- a/src/main/java/com/minelittlepony/api/pony/IPony.java +++ b/src/main/java/com/minelittlepony/api/pony/IPony.java @@ -11,12 +11,22 @@ import com.minelittlepony.client.MineLittlePony; public interface IPony { + /** + * Gets the global pony manager instance. + */ + static IPonyManager getManager() { + return MineLittlePony.getInstance().getManager(); + } + /** * Gets or creates a new pony associated with the provided resource location. * The results of this method should not be cached. + * + * @deprecated User IPony.getManager().getPony(texture) instead */ + @Deprecated static IPony forResource(Identifier texture) { - return MineLittlePony.getInstance().getManager().getPony(texture); + return getManager().getPony(texture); } /** @@ -24,18 +34,6 @@ public interface IPony { */ void updateForEntity(Entity entity); - /** - * Returns true if this pony has wings and the will to use them. - */ - default boolean canFly() { - return getRace().hasWings(); - } - - /** - * Checks the required conditions for whether the given entity can perform a sonic rainboom. - */ - boolean isPerformingRainboom(LivingEntity entity); - /** * Returns whether this is one of the default ponies assigned to a player without a custom skin. */ @@ -65,21 +63,11 @@ public interface IPony { */ boolean isSwimming(LivingEntity entity); - /** - * Returns true if the provided entity is fully submerged with water reaching the entity's eyeheight or above. - */ - boolean isFullySubmerged(LivingEntity entity); - /** * Returns true if the provided entity is partially submerged. That is if any part of it is in contact with water. */ boolean isPartiallySubmerged(LivingEntity entity); - @Deprecated - default Race getRace(boolean ignorePony) { - return com.minelittlepony.client.pony.Pony.getEffectiveRace(getMetadata().getRace(), ignorePony); - } - /** * Gets the race associated with this pony. */ diff --git a/src/main/java/com/minelittlepony/client/pony/NativePonyData.java b/src/main/java/com/minelittlepony/client/pony/NativePonyData.java index 481d1cd7..a4ed0498 100644 --- a/src/main/java/com/minelittlepony/client/pony/NativePonyData.java +++ b/src/main/java/com/minelittlepony/client/pony/NativePonyData.java @@ -16,6 +16,7 @@ import com.minelittlepony.api.pony.meta.TriggerPixel; import com.minelittlepony.api.pony.meta.Wearable; import com.minelittlepony.client.MineLittlePony; import com.minelittlepony.common.util.animation.Interpolator; +import com.minelittlepony.settings.PonyConfig; import java.util.Map; import java.util.TreeMap; @@ -91,7 +92,7 @@ class NativePonyData implements IPonyData { @Override public boolean hasHorn() { - return getRace() != null && Pony.getEffectiveRace(getRace(), false).hasHorn(); + return getRace() != null && PonyConfig.getEffectiveRace(getRace()).hasHorn(); } @Override diff --git a/src/main/java/com/minelittlepony/client/pony/Pony.java b/src/main/java/com/minelittlepony/client/pony/Pony.java index 16402ac5..860122c2 100644 --- a/src/main/java/com/minelittlepony/client/pony/Pony.java +++ b/src/main/java/com/minelittlepony/client/pony/Pony.java @@ -9,11 +9,10 @@ import com.minelittlepony.api.pony.meta.Sizes; import com.minelittlepony.api.pony.network.MsgPonyData; import com.minelittlepony.api.pony.network.fabric.Channel; import com.minelittlepony.api.pony.network.fabric.PonyDataCallback; -import com.minelittlepony.client.MineLittlePony; import com.minelittlepony.client.render.IPonyRenderContext; import com.minelittlepony.client.render.PonyRenderDispatcher; import com.minelittlepony.client.transform.PonyTransformation; -import com.minelittlepony.settings.PonyLevel; +import com.minelittlepony.settings.PonyConfig; import java.util.Objects; @@ -79,14 +78,6 @@ public class Pony implements IPony { } } - @Override - public boolean isPerformingRainboom(LivingEntity entity) { - Vec3d motion = entity.getVelocity(); - double zMotion = Math.sqrt(motion.x * motion.x + motion.z * motion.z); - - return (isFlying(entity) && canFly()) || entity.isFallFlying() & zMotion > 0.4F; - } - @Override public boolean isCrouching(LivingEntity entity) { @@ -97,6 +88,13 @@ public class Pony implements IPony { return !isPerformingRainboom(entity) && !isSwimming && isSneak && !isFlying; } + private boolean isPerformingRainboom(LivingEntity entity) { + Vec3d motion = entity.getVelocity(); + double zMotion = Math.sqrt(motion.x * motion.x + motion.z * motion.z); + + return (isFlying(entity) && getRace().hasWings()) || entity.isFallFlying() & zMotion > 0.4F; + } + @Override public boolean isFlying(LivingEntity entity) { return !(isOnGround(entity) @@ -141,12 +139,6 @@ public class Pony implements IPony { || entity.getEntityWorld().getBlockState(entity.getBlockPos()).getMaterial() == Material.WATER; } - @Override - public boolean isFullySubmerged(LivingEntity entity) { - return entity.isSubmergedInWater() - && entity.getEntityWorld().getBlockState(new BlockPos(getVisualEyePosition(entity))).getMaterial() == Material.WATER; - } - protected Vec3d getVisualEyePosition(LivingEntity entity) { Size size = entity.isBaby() ? Sizes.FOAL : getMetadata().getSize(); @@ -159,7 +151,7 @@ public class Pony implements IPony { @Override public Race getRace() { - return getEffectiveRace(getMetadata().getRace(), true); + return PonyConfig.getEffectiveRace(getMetadata().getRace()); } @Override @@ -246,26 +238,6 @@ public class Pony implements IPony { .toString(); } - /** - * Gets the actual race determined by the given pony level. - * PonyLevel.HUMANS would force all races to be humans. - * PonyLevel.BOTH is no change. - * PonyLevel.PONIES (should) return a pony if this is a human. Don't be fooled, though. It doesn't. - */ - public static Race getEffectiveRace(Race race, boolean ignorePony) { - - Race override = MineLittlePony.getInstance().getConfig().raceOverride.get(); - if (override != Race.HUMAN) { - return override; - } - - if (MineLittlePony.getInstance().getConfig().getEffectivePonyLevel(ignorePony) == PonyLevel.HUMANS) { - return Race.HUMAN; - } - - return race; - } - public interface RegistrationHandler { boolean shouldUpdateRegistration(Pony pony); } diff --git a/src/main/java/com/minelittlepony/client/pony/PonyData.java b/src/main/java/com/minelittlepony/client/pony/PonyData.java index 25223053..27d9cf4c 100644 --- a/src/main/java/com/minelittlepony/client/pony/PonyData.java +++ b/src/main/java/com/minelittlepony/client/pony/PonyData.java @@ -133,7 +133,7 @@ public class PonyData implements IPonyData { @Override public boolean hasHorn() { - return getRace() != null && Pony.getEffectiveRace(getRace(), false).hasHorn(); + return getRace() != null && getRace().hasHorn(); } @Override diff --git a/src/main/java/com/minelittlepony/settings/PonyConfig.java b/src/main/java/com/minelittlepony/settings/PonyConfig.java index ed52cf92..b4fce360 100644 --- a/src/main/java/com/minelittlepony/settings/PonyConfig.java +++ b/src/main/java/com/minelittlepony/settings/PonyConfig.java @@ -4,6 +4,7 @@ import net.minecraft.util.math.MathHelper; import com.minelittlepony.api.pony.meta.Race; import com.minelittlepony.api.pony.meta.Sizes; +import com.minelittlepony.client.MineLittlePony; import com.minelittlepony.common.util.settings.*; import java.nio.file.Path; @@ -60,15 +61,6 @@ public class PonyConfig extends Config { super(HEIRARCHICAL_JSON_ADAPTER, path); } - /** - * Gets the current PonyLevel. That is the level of ponies you would like to see. - * - * @param ignorePony true to ignore whatever value the setting has. - */ - public PonyLevel getEffectivePonyLevel(boolean ignorePony) { - return ignorePony ? PonyLevel.BOTH : ponyLevel.get(); - } - public float setGlobalScaleFactor(float f) { if (f < 0.15F) { @@ -101,4 +93,25 @@ public class PonyConfig extends Config { public float getGlobalScaleFactor() { return showscale.get() ? scaleFactor.get() : 1; } + + + /** + * Gets the actual race determined by the given pony level. + * PonyLevel.HUMANS would force all races to be humans. + * PonyLevel.BOTH is no change. + * PonyLevel.PONIES (should) return a pony if this is a human. Don't be fooled, though. It doesn't. + */ + public static Race getEffectiveRace(Race race) { + + Race override = MineLittlePony.getInstance().getConfig().raceOverride.get(); + if (override != Race.HUMAN) { + return override; + } + + if (MineLittlePony.getInstance().getConfig().ponyLevel.get() == PonyLevel.HUMANS) { + return Race.HUMAN; + } + + return race; + } }