mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-20 11:24:23 +01:00
Groundwork for rendering as library without LiteLoader
Added IPonyConfig to fake a config that doesn't use LiteLoader-based code, made config and rendermanager in mod class static so they exist without a LiteLoader-created instance of the mod, and modified appropriate calls.
This commit is contained in:
parent
d8913ed245
commit
927cbf1ce7
13 changed files with 89 additions and 42 deletions
27
src/main/java/com/minelittlepony/IPonyConfig.java
Normal file
27
src/main/java/com/minelittlepony/IPonyConfig.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
package com.minelittlepony;
|
||||
|
||||
import com.minelittlepony.pony.data.PonyLevel;
|
||||
|
||||
public interface IPonyConfig {
|
||||
default boolean getSizes() { return true; }
|
||||
default boolean getSnuzzles() { return true; }
|
||||
default boolean getHD() { return true; }
|
||||
default boolean getShowScale() { return true; }
|
||||
default boolean getFPSMagic() { return true; }
|
||||
default boolean getPonySkulls() { return true; }
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
default PonyLevel getEffectivePonyLevel(boolean ignorePony) {
|
||||
return ignorePony ? PonyLevel.BOTH : getPonyLevel();
|
||||
}
|
||||
/**
|
||||
* Actually gets the pony level value. No option to ignore reality here.
|
||||
*/
|
||||
PonyLevel getPonyLevel();
|
||||
default float getGlobalScaleFactor() {
|
||||
return getShowScale() ? 0.9F : 1;
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import com.minelittlepony.gui.GuiPonySettings;
|
|||
import com.minelittlepony.hdskins.gui.GuiSkinsMineLP;
|
||||
import com.minelittlepony.pony.data.IPonyData;
|
||||
import com.minelittlepony.pony.data.PonyDataSerialiser;
|
||||
import com.minelittlepony.pony.data.PonyLevel;
|
||||
import com.minelittlepony.render.PonySkullRenderer;
|
||||
import com.mumfrey.liteloader.core.LiteLoader;
|
||||
import com.voxelmodpack.hdskins.HDSkinManager;
|
||||
|
@ -37,22 +38,25 @@ public class MineLittlePony {
|
|||
|
||||
private static MineLittlePony instance;
|
||||
|
||||
private final PonyConfig config;
|
||||
private static PonyConfig pconfig;
|
||||
private static IPonyConfig config = new IPonyConfig() {
|
||||
@Override
|
||||
public PonyLevel getPonyLevel() {
|
||||
return PonyLevel.BOTH;
|
||||
}};
|
||||
private final PonyManager ponyManager;
|
||||
|
||||
private final PonyRenderManager renderManager;
|
||||
private static final PonyRenderManager renderManager = new PonyRenderManager();
|
||||
|
||||
MineLittlePony() {
|
||||
instance = this;
|
||||
|
||||
LiteLoader.getInput().registerKeyBinding(SETTINGS_GUI);
|
||||
|
||||
config = new PonyConfig();
|
||||
config = (IPonyConfig)(Object) (pconfig = new PonyConfig());
|
||||
ponyManager = new PonyManager(config);
|
||||
|
||||
renderManager = new PonyRenderManager();
|
||||
|
||||
LiteLoader.getInstance().registerExposable(config, null);
|
||||
LiteLoader.getInstance().registerExposable(pconfig, null);
|
||||
|
||||
IReloadableResourceManager irrm = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager();
|
||||
irrm.registerReloadListener(ponyManager);
|
||||
|
@ -110,15 +114,21 @@ public class MineLittlePony {
|
|||
/**
|
||||
* Gets the static pony render manager responsible for all entity renderers.
|
||||
*/
|
||||
public PonyRenderManager getRenderManager() {
|
||||
public static PonyRenderManager getRenderManager() {
|
||||
return renderManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the global MineLP client configuration.
|
||||
*/
|
||||
public static PonyConfig getConfig() {
|
||||
return getInstance().config;
|
||||
public static IPonyConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Exposable MineLP client config, which is only present if MineLP is loaded for LiteLoader
|
||||
*/
|
||||
public static PonyConfig getInstalledConfig() {
|
||||
return pconfig;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,16 +12,16 @@ import com.voxelmodpack.hdskins.HDSkinManager;
|
|||
* Storage container for MineLP client settings.
|
||||
*/
|
||||
@ExposableOptions(filename = "minelittlepony", strategy = ConfigStrategy.Unversioned)
|
||||
public class PonyConfig extends SensibleConfig implements Exposable {
|
||||
public class PonyConfig extends SensibleConfig implements Exposable, IPonyConfig {
|
||||
|
||||
@Expose private PonyLevel ponylevel = PonyLevel.PONIES;
|
||||
|
||||
@Expose public boolean sizes = true;
|
||||
@Expose public boolean snuzzles = true;
|
||||
@Expose public boolean hd = true;
|
||||
@Expose public boolean showscale = true;
|
||||
@Expose public boolean fpsmagic = true;
|
||||
@Expose public boolean ponyskulls = true;
|
||||
@Expose public boolean sizes = IPonyConfig.super.getSizes();
|
||||
@Expose public boolean snuzzles = IPonyConfig.super.getSnuzzles();
|
||||
@Expose public boolean hd = IPonyConfig.super.getHD();
|
||||
@Expose public boolean showscale = IPonyConfig.super.getShowScale();
|
||||
@Expose public boolean fpsmagic = IPonyConfig.super.getFPSMagic();
|
||||
@Expose public boolean ponyskulls = IPonyConfig.super.getPonySkulls();
|
||||
|
||||
public enum PonySettings implements Setting {
|
||||
SIZES,
|
||||
|
@ -40,18 +40,32 @@ public class PonyConfig extends SensibleConfig implements Exposable {
|
|||
@Expose public boolean guardians = true;
|
||||
@Expose public boolean endermen = true;
|
||||
|
||||
/**
|
||||
* 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 : getPonyLevel();
|
||||
@Override
|
||||
public boolean getSizes() {
|
||||
return sizes;
|
||||
}
|
||||
@Override
|
||||
public boolean getSnuzzles() {
|
||||
return snuzzles;
|
||||
}
|
||||
@Override
|
||||
public boolean getHD() {
|
||||
return hd;
|
||||
}
|
||||
@Override
|
||||
public boolean getShowScale() {
|
||||
return showscale;
|
||||
}
|
||||
@Override
|
||||
public boolean getFPSMagic() {
|
||||
return fpsmagic;
|
||||
}
|
||||
@Override
|
||||
public boolean getPonySkulls() {
|
||||
return ponyskulls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually gets the pony level value. No option to ignore reality here.
|
||||
*/
|
||||
@Override
|
||||
public PonyLevel getPonyLevel() {
|
||||
if (ponylevel == null) {
|
||||
ponylevel = PonyLevel.PONIES;
|
||||
|
@ -71,8 +85,4 @@ public class PonyConfig extends SensibleConfig implements Exposable {
|
|||
HDSkinManager.INSTANCE.parseSkins();
|
||||
}
|
||||
}
|
||||
|
||||
public float getGlobalScaleFactor() {
|
||||
return showscale ? 0.9F : 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,11 +42,11 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
|||
*/
|
||||
private List<ResourceLocation> backgroundPonyList = Lists.newArrayList();
|
||||
|
||||
private PonyConfig config;
|
||||
private IPonyConfig config;
|
||||
|
||||
private Map<ResourceLocation, IPony> poniesCache = Maps.newHashMap();
|
||||
|
||||
public PonyManager(PonyConfig config) {
|
||||
public PonyManager(IPonyConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public class PonyRenderManager {
|
|||
/**
|
||||
* Registers all entity model replacements. (except for players).
|
||||
*/
|
||||
public void initializeMobRenderers(RenderManager manager, PonyConfig config) {
|
||||
public void initializeMobRenderers(RenderManager manager, IPonyConfig config) {
|
||||
for (MobRenderers i : MobRenderers.values()) {
|
||||
i.apply(this, manager);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public class GuiPonySettings extends SettingsPanel {
|
|||
private PonyConfig config;
|
||||
|
||||
public GuiPonySettings() {
|
||||
config = MineLittlePony.getConfig();
|
||||
config = MineLittlePony.getInstalledConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,6 +27,6 @@ public class MixinItemRenderer {
|
|||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/renderer/ItemRenderer;renderItemSide(" + EntityLivingBase + ItemStack + TransformType + "Z)V"))
|
||||
private void redirectRenderItemSide(ItemRenderer self, EntityLivingBase entity, ItemStack stack, TransformType transform, boolean left) {
|
||||
MineLittlePony.getInstance().getRenderManager().getMagicRenderer().renderItemInFirstPerson(self, (AbstractClientPlayer)entity, stack, transform, left);
|
||||
MineLittlePony.getRenderManager().getMagicRenderer().renderItemInFirstPerson(self, (AbstractClientPlayer)entity, stack, transform, left);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public class PonySnout {
|
|||
}
|
||||
|
||||
public void setGender(PonyGender gender) {
|
||||
boolean show = !head.hasHeadGear() && !isHidden && MineLittlePony.getConfig().snuzzles;
|
||||
boolean show = !head.hasHeadGear() && !isHidden && MineLittlePony.getConfig().getSnuzzles();
|
||||
|
||||
mare.isHidden = !show || gender == PonyGender.STALLION;
|
||||
stallion.isHidden = !show || gender == PonyGender.MARE;
|
||||
|
|
|
@ -42,6 +42,6 @@ public enum PonySize implements ITriggerPixelMapped<PonySize> {
|
|||
}
|
||||
|
||||
public PonySize getEffectiveSize() {
|
||||
return MineLittlePony.getConfig().sizes ? this : PonySize.NORMAL;
|
||||
return MineLittlePony.getConfig().getSizes() ? this : PonySize.NORMAL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class LevitatingItemRenderer {
|
|||
|
||||
pushMatrix();
|
||||
|
||||
boolean doMagic = MineLittlePony.getConfig().fpsmagic && pony.getMetadata().hasMagic();
|
||||
boolean doMagic = MineLittlePony.getConfig().getFPSMagic() && pony.getMetadata().hasMagic();
|
||||
|
||||
if (doMagic) {
|
||||
setupPerspective(entity, stack, left);
|
||||
|
|
|
@ -52,7 +52,7 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende
|
|||
* Original/Existing renderer is stored to a backup variable as a fallback in case of mods.
|
||||
*/
|
||||
public static TileEntitySkullRenderer resolve() {
|
||||
if (MineLittlePony.getConfig().ponyskulls) {
|
||||
if (MineLittlePony.getConfig().getPonySkulls()) {
|
||||
if (!(instance instanceof PonySkullRenderer)) {
|
||||
backup = instance;
|
||||
ModUtilities.addRenderer(TileEntitySkull.class, ponyInstance);
|
||||
|
@ -79,7 +79,7 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende
|
|||
|
||||
ISkull skull = skullMap.get(skullType);
|
||||
|
||||
if (skull == null || !skull.canRender(MineLittlePony.getConfig())) {
|
||||
if (skull == null || !skull.canRender(MineLittlePony.getInstalledConfig())) {
|
||||
if (backup != null) {
|
||||
backup.renderSkull(x, y, z, facing, rotation, skullType, profile, destroyStage, animateTicks);
|
||||
} else {
|
||||
|
|
|
@ -31,7 +31,7 @@ public class LayerHeldPonyItemMagical<T extends EntityLivingBase> extends LayerH
|
|||
@Override
|
||||
protected void postItemRender(T entity, ItemStack drop, TransformType transform, EnumHandSide hand) {
|
||||
if (isUnicorn()) {
|
||||
MineLittlePony.getInstance().getRenderManager().getMagicRenderer().renderItemGlow(entity, drop, transform, hand, this.<IModelUnicorn>getPonyModel().getMagicColor());
|
||||
MineLittlePony.getRenderManager().getMagicRenderer().renderItemGlow(entity, drop, transform, hand, this.<IModelUnicorn>getPonyModel().getMagicColor());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ public enum MobRenderers implements Setting {
|
|||
@Override
|
||||
public void set(boolean value) {
|
||||
Setting.super.set(value);
|
||||
apply(MineLittlePony.getInstance().getRenderManager(), Minecraft.getMinecraft().getRenderManager());
|
||||
apply(MineLittlePony.getRenderManager(), Minecraft.getMinecraft().getRenderManager());
|
||||
}
|
||||
|
||||
public void apply(PonyRenderManager pony, RenderManager manager) {
|
||||
|
|
Loading…
Reference in a new issue