mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-29 07:27:59 +01:00
Use the forge config system for minelp. It adds a magic gui.
This commit is contained in:
parent
b24af17ef2
commit
c841abe4dc
14 changed files with 115 additions and 147 deletions
|
@ -1,9 +1,9 @@
|
||||||
package com.minelittlepony;
|
package com.minelittlepony;
|
||||||
|
|
||||||
import com.minelittlepony.gui.GuiPonySettings;
|
|
||||||
import com.minelittlepony.hdskins.gui.GuiSkinsMineLP;
|
import com.minelittlepony.hdskins.gui.GuiSkinsMineLP;
|
||||||
import com.minelittlepony.pony.data.IPonyData;
|
import com.minelittlepony.pony.data.IPonyData;
|
||||||
import com.minelittlepony.pony.data.PonyDataSerialzier;
|
import com.minelittlepony.pony.data.PonyDataSerialzier;
|
||||||
|
import com.minelittlepony.render.ponies.MobRenderers;
|
||||||
import com.minelittlepony.settings.PonyConfig;
|
import com.minelittlepony.settings.PonyConfig;
|
||||||
import com.voxelmodpack.hdskins.HDSkinManager;
|
import com.voxelmodpack.hdskins.HDSkinManager;
|
||||||
import com.voxelmodpack.hdskins.gui.GuiSkins;
|
import com.voxelmodpack.hdskins.gui.GuiSkins;
|
||||||
|
@ -11,13 +11,16 @@ import com.voxelmodpack.hdskins.skins.SkinServer;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||||
import net.minecraft.client.resources.data.MetadataSerializer;
|
import net.minecraft.client.resources.data.MetadataSerializer;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.common.config.Config;
|
||||||
|
import net.minecraftforge.common.config.ConfigManager;
|
||||||
|
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent;
|
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.lwjgl.input.Keyboard;
|
|
||||||
|
|
||||||
|
|
||||||
@Mod(modid = "minelittlepony", name = MineLittlePony.MOD_NAME, version = MineLittlePony.MOD_VERSION, clientSideOnly = true)
|
@Mod(modid = "minelittlepony", name = MineLittlePony.MOD_NAME, version = MineLittlePony.MOD_VERSION, clientSideOnly = true)
|
||||||
public class MineLittlePony {
|
public class MineLittlePony {
|
||||||
|
@ -29,12 +32,8 @@ public class MineLittlePony {
|
||||||
|
|
||||||
private static final String MINELP_LEGACY_SERVER = "legacy:http://minelpskins.voxelmodpack.com;http://minelpskinmanager.voxelmodpack.com";
|
private static final String MINELP_LEGACY_SERVER = "legacy:http://minelpskins.voxelmodpack.com;http://minelpskinmanager.voxelmodpack.com";
|
||||||
|
|
||||||
// TODO Replace this with a config screen
|
|
||||||
private static final KeyBinding SETTINGS_GUI = new KeyBinding("Settings", Keyboard.KEY_F9, "Mine Little Pony");
|
|
||||||
|
|
||||||
private static MineLittlePony instance;
|
private static MineLittlePony instance;
|
||||||
|
|
||||||
private PonyConfig.Loader configLoader;
|
|
||||||
private PonyManager ponyManager;
|
private PonyManager ponyManager;
|
||||||
|
|
||||||
private PonyRenderManager renderManager;
|
private PonyRenderManager renderManager;
|
||||||
|
@ -44,9 +43,11 @@ public class MineLittlePony {
|
||||||
instance = this;
|
instance = this;
|
||||||
logger = event.getModLog();
|
logger = event.getModLog();
|
||||||
|
|
||||||
configLoader = new PonyConfig.Loader(event.getModConfigurationDirectory().toPath().resolve("minelittlepony.json"));
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
ponyManager = new PonyManager(configLoader.getConfig());
|
|
||||||
|
|
||||||
|
ConfigManager.sync("minelittlepony", Config.Type.INSTANCE);
|
||||||
|
|
||||||
|
ponyManager = new PonyManager();
|
||||||
|
|
||||||
IReloadableResourceManager irrm = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager();
|
IReloadableResourceManager irrm = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager();
|
||||||
irrm.registerReloadListener(ponyManager);
|
irrm.registerReloadListener(ponyManager);
|
||||||
|
@ -71,25 +72,32 @@ public class MineLittlePony {
|
||||||
manager.addClearListener(ponyManager);
|
manager.addClearListener(ponyManager);
|
||||||
|
|
||||||
renderManager.initialisePlayerRenderers();
|
renderManager.initialisePlayerRenderers();
|
||||||
renderManager.initializeMobRenderers(configLoader.getConfig());
|
renderManager.initializeMobRenderers();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called on every update tick
|
* Called on every update tick
|
||||||
*/
|
*/
|
||||||
void onTick(Minecraft minecraft, boolean inGame) {
|
@SubscribeEvent
|
||||||
|
public void onTick(GuiScreenEvent.InitGuiEvent.Pre event) {
|
||||||
|
|
||||||
if (inGame && minecraft.currentScreen == null && SETTINGS_GUI.isPressed()) {
|
if (event.getGui() instanceof GuiSkins && !(event.getGui() instanceof GuiSkinsMineLP)) {
|
||||||
minecraft.displayGuiScreen(new GuiPonySettings());
|
event.setCanceled(true);
|
||||||
|
Minecraft.getMinecraft().displayGuiScreen(new GuiSkinsMineLP(ponyManager));
|
||||||
|
}
|
||||||
|
HDSkinManager.INSTANCE.setEnabled(PonyConfig.hd);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean skins = minecraft.currentScreen instanceof GuiSkins
|
@SubscribeEvent
|
||||||
&& !(minecraft.currentScreen instanceof GuiSkinsMineLP);
|
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
|
||||||
if (skins) {
|
// System.out.println("Config " + event.getModID() + "." + event.getConfigID() + " Loaded");
|
||||||
minecraft.displayGuiScreen(new GuiSkinsMineLP(ponyManager));
|
if (event.getModID().equals("minelittlepony")) {
|
||||||
|
ConfigManager.sync("minelittlepony", Config.Type.INSTANCE);
|
||||||
|
for (MobRenderers mobRenderers : MobRenderers.values()) {
|
||||||
|
mobRenderers.set(mobRenderers.get());
|
||||||
|
}
|
||||||
|
renderManager.initializeMobRenderers();
|
||||||
}
|
}
|
||||||
HDSkinManager.INSTANCE.setEnabled(configLoader.getConfig().hd);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,11 +121,4 @@ public class MineLittlePony {
|
||||||
return renderManager;
|
return renderManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the global MineLP client configuration.
|
|
||||||
*/
|
|
||||||
public static PonyConfig.Loader getConfigLoader() {
|
|
||||||
return getInstance().configLoader;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,12 +45,9 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
||||||
*/
|
*/
|
||||||
private List<ResourceLocation> backgroundPonyList = Lists.newArrayList();
|
private List<ResourceLocation> backgroundPonyList = Lists.newArrayList();
|
||||||
|
|
||||||
private PonyConfig config;
|
|
||||||
|
|
||||||
private Map<ResourceLocation, Pony> poniesCache = Maps.newHashMap();
|
private Map<ResourceLocation, Pony> poniesCache = Maps.newHashMap();
|
||||||
|
|
||||||
public PonyManager(PonyConfig config) {
|
public PonyManager() {
|
||||||
this.config = config;
|
|
||||||
initmodels();
|
initmodels();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +106,7 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
||||||
public Pony getPony(ResourceLocation resource, UUID uuid) {
|
public Pony getPony(ResourceLocation resource, UUID uuid) {
|
||||||
Pony pony = getPony(resource, isSlimSkin(uuid));
|
Pony pony = getPony(resource, isSlimSkin(uuid));
|
||||||
|
|
||||||
if (config.getPonyLevel() == PonyLevel.PONIES && pony.getMetadata().getRace().isHuman()) {
|
if (PonyConfig.getPonyLevel() == PonyLevel.PONIES && pony.getMetadata().getRace().isHuman()) {
|
||||||
return getBackgroundPony(uuid);
|
return getBackgroundPony(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +119,7 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
||||||
* @param uuid id of a player or entity
|
* @param uuid id of a player or entity
|
||||||
*/
|
*/
|
||||||
public Pony getDefaultPony(UUID uuid) {
|
public Pony getDefaultPony(UUID uuid) {
|
||||||
if (config.getPonyLevel() != PonyLevel.PONIES) {
|
if (PonyConfig.getPonyLevel() != PonyLevel.PONIES) {
|
||||||
return getPony(DefaultPlayerSkin.getDefaultSkin(uuid), isSlimSkin(uuid));
|
return getPony(DefaultPlayerSkin.getDefaultSkin(uuid), isSlimSkin(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ import com.minelittlepony.model.player.PlayerModels;
|
||||||
import com.minelittlepony.render.LevitatingItemRenderer;
|
import com.minelittlepony.render.LevitatingItemRenderer;
|
||||||
import com.minelittlepony.render.player.RenderPonyPlayer;
|
import com.minelittlepony.render.player.RenderPonyPlayer;
|
||||||
import com.minelittlepony.render.ponies.MobRenderers;
|
import com.minelittlepony.render.ponies.MobRenderers;
|
||||||
import com.minelittlepony.settings.PonyConfig;
|
|
||||||
import net.minecraft.client.renderer.entity.Render;
|
import net.minecraft.client.renderer.entity.Render;
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||||
|
@ -66,9 +65,9 @@ public class PonyRenderManager {
|
||||||
/**
|
/**
|
||||||
* Registers all entity model replacements. (except for players).
|
* Registers all entity model replacements. (except for players).
|
||||||
*/
|
*/
|
||||||
public void initializeMobRenderers(PonyConfig config) {
|
public void initializeMobRenderers() {
|
||||||
for (MobRenderers i : MobRenderers.values()) {
|
for (MobRenderers i : MobRenderers.values()) {
|
||||||
boolean state = i.get(config);
|
boolean state = i.get();
|
||||||
i.register(state, this);
|
i.register(state, this);
|
||||||
if (state) {
|
if (state) {
|
||||||
MineLittlePony.logger.info(i.name() + " are now ponies.");
|
MineLittlePony.logger.info(i.name() + " are now ponies.");
|
||||||
|
@ -88,10 +87,11 @@ public class PonyRenderManager {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T extends Entity> void switchRenderer(boolean state, Class<T> type, IRenderFactory<T> renderer) {
|
public <T extends Entity> void switchRenderer(boolean state, Class<T> type, IRenderFactory<T> renderer) {
|
||||||
if (state) {
|
// always put the original, regardless of state
|
||||||
if (!renderMap.containsKey(type)) {
|
if (!renderMap.containsKey(type)) {
|
||||||
renderMap.put(type, manager.getEntityClassRenderObject(type));
|
renderMap.put(type, manager.getEntityClassRenderObject(type));
|
||||||
}
|
}
|
||||||
|
if (state) {
|
||||||
RenderingRegistry.registerEntityRenderingHandler(type, renderer);
|
RenderingRegistry.registerEntityRenderingHandler(type, renderer);
|
||||||
} else if (renderMap.containsKey(type)) {
|
} else if (renderMap.containsKey(type)) {
|
||||||
RenderingRegistry.registerEntityRenderingHandler(type, mngr -> (Render<T>) renderMap.get(type));
|
RenderingRegistry.registerEntityRenderingHandler(type, mngr -> (Render<T>) renderMap.get(type));
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.minelittlepony.gui;
|
package com.minelittlepony.gui;
|
||||||
|
|
||||||
import com.minelittlepony.MineLittlePony;
|
|
||||||
import com.minelittlepony.pony.data.PonyLevel;
|
import com.minelittlepony.pony.data.PonyLevel;
|
||||||
import com.minelittlepony.render.ponies.MobRenderers;
|
import com.minelittlepony.render.ponies.MobRenderers;
|
||||||
import com.minelittlepony.settings.PonyConfig;
|
import com.minelittlepony.settings.PonyConfig;
|
||||||
|
@ -21,13 +20,8 @@ public class GuiPonySettings extends GuiConfig {
|
||||||
|
|
||||||
private static final String MOB_PREFIX = "minelp.mobs.";
|
private static final String MOB_PREFIX = "minelp.mobs.";
|
||||||
|
|
||||||
private PonyConfig.Loader configLoader;
|
|
||||||
private PonyConfig config;
|
|
||||||
|
|
||||||
public GuiPonySettings() {
|
public GuiPonySettings() {
|
||||||
super(null, "minelittlepony", "Mine Little Pony");
|
super(null, "minelittlepony", "Mine Little Pony");
|
||||||
configLoader = MineLittlePony.getConfigLoader();
|
|
||||||
config = configLoader.getConfig();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,18 +36,18 @@ public class GuiPonySettings extends GuiConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
addButton(new Label(LEFT, row += 15, PONY_LEVEL, -1));
|
addButton(new Label(LEFT, row += 15, PONY_LEVEL, -1));
|
||||||
addButton(new Slider(LEFT, row += 15, 0, 2, config.getPonyLevel().ordinal(), (int id, String name, float value) -> {
|
addButton(new Slider(LEFT, row += 15, 0, 2, PonyConfig.getPonyLevel().ordinal(), (int id, String name, float value) -> {
|
||||||
return I18n.format(PONY_LEVEL + "." + PonyLevel.valueFor((int) value).name().toLowerCase());
|
return I18n.format(PONY_LEVEL + "." + PonyLevel.valueFor((int) value).name().toLowerCase());
|
||||||
}, v -> {
|
}, v -> {
|
||||||
PonyLevel level = PonyLevel.valueFor((int) v);
|
PonyLevel level = PonyLevel.valueFor((int) v);
|
||||||
config.setPonyLevel(level);
|
PonyConfig.setPonyLevel(level);
|
||||||
return (float)level.ordinal();
|
return (float)level.ordinal();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
row += 15;
|
row += 15;
|
||||||
addButton(new Label(LEFT, row += 15, OPTIONS_PREFIX + "options", -1));
|
addButton(new Label(LEFT, row += 15, OPTIONS_PREFIX + "options", -1));
|
||||||
for (Setting<PonyConfig> i : PonyConfig.PonySettings.values()) {
|
for (Setting i : PonyConfig.PonySettings.values()) {
|
||||||
addButton(new Checkbox(LEFT, row += 15, OPTIONS_PREFIX + i.name().toLowerCase(), i.get(config), b -> i.set(config, b)));
|
addButton(new Checkbox(LEFT, row += 15, OPTIONS_PREFIX + i.name().toLowerCase(), i.get(), i::set));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mustScroll()) {
|
if (mustScroll()) {
|
||||||
|
@ -64,7 +58,7 @@ public class GuiPonySettings extends GuiConfig {
|
||||||
|
|
||||||
addButton(new Label(RIGHT, row += 15, MOB_PREFIX + "title", -1));
|
addButton(new Label(RIGHT, row += 15, MOB_PREFIX + "title", -1));
|
||||||
for (MobRenderers i : MobRenderers.values()) {
|
for (MobRenderers i : MobRenderers.values()) {
|
||||||
addButton(new Checkbox(RIGHT, row += 15, MOB_PREFIX + i.name().toLowerCase(), i.get(config), v -> i.set(config, v)));
|
addButton(new Checkbox(RIGHT, row += 15, MOB_PREFIX + i.name().toLowerCase(), i.get(), i::set));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,10 +75,6 @@ public class GuiPonySettings extends GuiConfig {
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGuiClosed() {
|
|
||||||
configLoader.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getTitle() {
|
protected String getTitle() {
|
||||||
return OPTIONS_PREFIX + "title";
|
return OPTIONS_PREFIX + "title";
|
||||||
|
|
|
@ -2,10 +2,10 @@ package com.minelittlepony.model.components;
|
||||||
|
|
||||||
import static com.minelittlepony.model.PonyModelConstants.*;
|
import static com.minelittlepony.model.PonyModelConstants.*;
|
||||||
|
|
||||||
import com.minelittlepony.MineLittlePony;
|
|
||||||
import com.minelittlepony.model.AbstractPonyModel;
|
import com.minelittlepony.model.AbstractPonyModel;
|
||||||
import com.minelittlepony.pony.data.PonyGender;
|
import com.minelittlepony.pony.data.PonyGender;
|
||||||
import com.minelittlepony.render.plane.PlaneRenderer;
|
import com.minelittlepony.render.plane.PlaneRenderer;
|
||||||
|
import com.minelittlepony.settings.PonyConfig;
|
||||||
|
|
||||||
public class PonySnout {
|
public class PonySnout {
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class PonySnout {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGender(PonyGender gender) {
|
public void setGender(PonyGender gender) {
|
||||||
boolean show = !isHidden && MineLittlePony.getConfigLoader().getConfig().snuzzles;
|
boolean show = !isHidden && PonyConfig.snuzzles;
|
||||||
|
|
||||||
mare.isHidden = !show || gender == PonyGender.STALLION;
|
mare.isHidden = !show || gender == PonyGender.STALLION;
|
||||||
stallion.isHidden = !show || gender == PonyGender.MARE;
|
stallion.isHidden = !show || gender == PonyGender.MARE;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.google.common.base.MoreObjects;
|
||||||
import com.minelittlepony.MineLittlePony;
|
import com.minelittlepony.MineLittlePony;
|
||||||
import com.minelittlepony.mixin.MixinThreadDownloadImageData;
|
import com.minelittlepony.mixin.MixinThreadDownloadImageData;
|
||||||
import com.minelittlepony.model.ModelWrapper;
|
import com.minelittlepony.model.ModelWrapper;
|
||||||
|
import com.minelittlepony.settings.PonyConfig;
|
||||||
import com.voxelmodpack.hdskins.DynamicTextureImage;
|
import com.voxelmodpack.hdskins.DynamicTextureImage;
|
||||||
import com.voxelmodpack.hdskins.ThreadDownloadImageETag;
|
import com.voxelmodpack.hdskins.ThreadDownloadImageETag;
|
||||||
|
|
||||||
|
@ -117,7 +118,7 @@ public class Pony {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PonyRace getRace(boolean ignorePony) {
|
public PonyRace getRace(boolean ignorePony) {
|
||||||
return metadata.getRace().getEffectiveRace(MineLittlePony.getConfigLoader().getConfig().getEffectivePonyLevel(ignorePony));
|
return metadata.getRace().getEffectiveRace(PonyConfig.getEffectivePonyLevel(ignorePony));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceLocation getTexture() {
|
public ResourceLocation getTexture() {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.minelittlepony.pony.data;
|
package com.minelittlepony.pony.data;
|
||||||
|
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.minelittlepony.MineLittlePony;
|
import com.minelittlepony.settings.PonyConfig;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import javax.annotation.concurrent.Immutable;
|
import javax.annotation.concurrent.Immutable;
|
||||||
|
@ -58,7 +58,7 @@ public class PonyData implements IPonyData {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PonySize getSize() {
|
public PonySize getSize() {
|
||||||
return MineLittlePony.getConfigLoader().getConfig().sizes ? size : PonySize.NORMAL;
|
return PonyConfig.sizes ? size : PonySize.NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.pony.data;
|
package com.minelittlepony.pony.data;
|
||||||
|
|
||||||
import com.minelittlepony.MineLittlePony;
|
import com.minelittlepony.settings.PonyConfig;
|
||||||
|
|
||||||
public enum PonySize implements ITriggerPixelMapped<PonySize> {
|
public enum PonySize implements ITriggerPixelMapped<PonySize> {
|
||||||
NORMAL(0, 0.4f, 1f),
|
NORMAL(0, 0.4f, 1f),
|
||||||
|
@ -20,14 +20,14 @@ public enum PonySize implements ITriggerPixelMapped<PonySize> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getShadowSize() {
|
public float getShadowSize() {
|
||||||
if (MineLittlePony.getConfigLoader().getConfig().showscale) {
|
if (PonyConfig.showscale) {
|
||||||
return shadowSize * 0.9F;
|
return shadowSize * 0.9F;
|
||||||
}
|
}
|
||||||
return shadowSize;
|
return shadowSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getScaleFactor() {
|
public float getScaleFactor() {
|
||||||
if (MineLittlePony.getConfigLoader().getConfig().showscale) {
|
if (PonyConfig.showscale) {
|
||||||
return scale * 0.9F;
|
return scale * 0.9F;
|
||||||
}
|
}
|
||||||
return scale;
|
return scale;
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.minelittlepony.render.layer.LayerHeldPonyItemMagical;
|
||||||
import com.minelittlepony.render.layer.LayerPonyArmor;
|
import com.minelittlepony.render.layer.LayerPonyArmor;
|
||||||
import com.minelittlepony.render.layer.LayerPonyCustomHead;
|
import com.minelittlepony.render.layer.LayerPonyCustomHead;
|
||||||
import com.minelittlepony.render.layer.LayerPonyElytra;
|
import com.minelittlepony.render.layer.LayerPonyElytra;
|
||||||
|
import com.minelittlepony.settings.PonyConfig;
|
||||||
import com.voxelmodpack.hdskins.HDSkinManager;
|
import com.voxelmodpack.hdskins.HDSkinManager;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
|
@ -83,7 +84,7 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
|
||||||
public float getShadowScale() {
|
public float getShadowScale() {
|
||||||
if (mainModel.isChild) {
|
if (mainModel.isChild) {
|
||||||
return 0.25F;
|
return 0.25F;
|
||||||
} else if (MineLittlePony.getConfigLoader().getConfig().showscale) {
|
} else if (PonyConfig.showscale) {
|
||||||
return 0.4F;
|
return 0.4F;
|
||||||
}
|
}
|
||||||
return 0.5F;
|
return 0.5F;
|
||||||
|
@ -91,7 +92,7 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getScaleFactor() {
|
public float getScaleFactor() {
|
||||||
if (MineLittlePony.getConfigLoader().getConfig().showscale) return 0.9F;
|
if (PonyConfig.showscale) return 0.9F;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.minelittlepony.render.ponies;
|
||||||
|
|
||||||
import com.minelittlepony.MineLittlePony;
|
import com.minelittlepony.MineLittlePony;
|
||||||
import com.minelittlepony.PonyRenderManager;
|
import com.minelittlepony.PonyRenderManager;
|
||||||
import com.minelittlepony.settings.PonyConfig;
|
import com.minelittlepony.settings.MobConfig;
|
||||||
import com.minelittlepony.settings.Setting;
|
import com.minelittlepony.settings.Setting;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
|
@ -29,7 +29,7 @@ import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||||
*
|
*
|
||||||
* Due to the limitations in Mumfrey's framework, needs to be paired with a field in PonyConfig.
|
* Due to the limitations in Mumfrey's framework, needs to be paired with a field in PonyConfig.
|
||||||
*/
|
*/
|
||||||
public enum MobRenderers implements Setting<PonyConfig> {
|
public enum MobRenderers implements Setting {
|
||||||
VILLAGERS {
|
VILLAGERS {
|
||||||
@Override
|
@Override
|
||||||
public void register(boolean state, PonyRenderManager pony) {
|
public void register(boolean state, PonyRenderManager pony) {
|
||||||
|
@ -78,8 +78,13 @@ public enum MobRenderers implements Setting<PonyConfig> {
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(PonyConfig config, boolean value) {
|
public Class<?> getEnclosingClass() {
|
||||||
Setting.super.set(config, value);
|
return MobConfig.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(boolean value) {
|
||||||
|
Setting.super.set(value);
|
||||||
apply(value, MineLittlePony.getInstance().getRenderManager(), Minecraft.getMinecraft().getRenderManager());
|
apply(value, MineLittlePony.getInstance().getRenderManager(), Minecraft.getMinecraft().getRenderManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
src/main/java/com/minelittlepony/settings/MobConfig.java
Normal file
14
src/main/java/com/minelittlepony/settings/MobConfig.java
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
package com.minelittlepony.settings;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.config.Config;
|
||||||
|
|
||||||
|
@Config(modid = "minelittlepony", name = "mobs", category = "mobs")
|
||||||
|
public class MobConfig {
|
||||||
|
|
||||||
|
public static boolean villagers = true;
|
||||||
|
public static boolean zombies = true;
|
||||||
|
public static boolean pigzombies = true;
|
||||||
|
public static boolean skeletons = true;
|
||||||
|
public static boolean illagers = true;
|
||||||
|
public static boolean guardians = true;
|
||||||
|
}
|
|
@ -1,37 +1,26 @@
|
||||||
package com.minelittlepony.settings;
|
package com.minelittlepony.settings;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import com.minelittlepony.MineLittlePony;
|
|
||||||
import com.minelittlepony.pony.data.PonyLevel;
|
import com.minelittlepony.pony.data.PonyLevel;
|
||||||
|
import net.minecraftforge.common.config.Config;
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.NoSuchFileException;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Storage container for MineLP client settings.
|
* Storage container for MineLP client settings.
|
||||||
*/
|
*/
|
||||||
|
@Config(modid = "minelittlepony", name = "options")
|
||||||
|
@Config.LangKey("minelp.options.options")
|
||||||
public class PonyConfig {
|
public class PonyConfig {
|
||||||
|
|
||||||
private PonyLevel ponylevel = PonyLevel.PONIES;
|
@Config.LangKey("minelp.options.ponylevel")
|
||||||
|
public static PonyLevel ponylevel = PonyLevel.PONIES;
|
||||||
|
|
||||||
public boolean sizes = true;
|
@Config.LangKey("minelp.options.sizes")
|
||||||
public boolean snuzzles = true;
|
public static boolean sizes = true;
|
||||||
public boolean hd = true;
|
public static boolean snuzzles = true;
|
||||||
public boolean showscale = true;
|
public static boolean hd = true;
|
||||||
|
public static boolean showscale = true;
|
||||||
|
|
||||||
public boolean villagers = true;
|
|
||||||
public boolean zombies = true;
|
|
||||||
public boolean pigzombies = true;
|
|
||||||
public boolean skeletons = true;
|
|
||||||
public boolean illagers = true;
|
|
||||||
public boolean guardians = true;
|
|
||||||
|
|
||||||
public enum PonySettings implements Setting<PonyConfig> {
|
public enum PonySettings implements Setting {
|
||||||
SIZES,
|
SIZES,
|
||||||
SNUZZLES,
|
SNUZZLES,
|
||||||
HD,
|
HD,
|
||||||
|
@ -44,14 +33,14 @@ public class PonyConfig {
|
||||||
*
|
*
|
||||||
* @param ignorePony true to ignore whatever value the setting has.
|
* @param ignorePony true to ignore whatever value the setting has.
|
||||||
*/
|
*/
|
||||||
public PonyLevel getEffectivePonyLevel(boolean ignorePony) {
|
public static PonyLevel getEffectivePonyLevel(boolean ignorePony) {
|
||||||
return ignorePony ? PonyLevel.BOTH : getPonyLevel();
|
return ignorePony ? PonyLevel.BOTH : getPonyLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actually gets the pony level value. No option to ignore reality here.
|
* Actually gets the pony level value. No option to ignore reality here.
|
||||||
*/
|
*/
|
||||||
public PonyLevel getPonyLevel() {
|
public static PonyLevel getPonyLevel() {
|
||||||
if (ponylevel == null) {
|
if (ponylevel == null) {
|
||||||
ponylevel = PonyLevel.PONIES;
|
ponylevel = PonyLevel.PONIES;
|
||||||
}
|
}
|
||||||
|
@ -63,51 +52,8 @@ public class PonyConfig {
|
||||||
*
|
*
|
||||||
* @param ponylevel
|
* @param ponylevel
|
||||||
*/
|
*/
|
||||||
public void setPonyLevel(PonyLevel ponylevel) {
|
public static void setPonyLevel(PonyLevel ponylevel) {
|
||||||
this.ponylevel = ponylevel;
|
PonyConfig.ponylevel = ponylevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Loader {
|
|
||||||
|
|
||||||
private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
|
||||||
|
|
||||||
private final Path path;
|
|
||||||
|
|
||||||
private PonyConfig config;
|
|
||||||
|
|
||||||
public Loader(Path path) {
|
|
||||||
this.path = path;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PonyConfig getConfig() {
|
|
||||||
if (config == null) {
|
|
||||||
reload();
|
|
||||||
}
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reload() {
|
|
||||||
try (BufferedReader reader = Files.newBufferedReader(path)) {
|
|
||||||
config = gson.fromJson(reader, PonyConfig.class);
|
|
||||||
} catch (NoSuchFileException e) {
|
|
||||||
config = new PonyConfig();
|
|
||||||
} catch (IOException e) {
|
|
||||||
MineLittlePony.logger.warn("Error while loading config. Using defaults.", e);
|
|
||||||
config = new PonyConfig();
|
|
||||||
}
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save() {
|
|
||||||
try (BufferedWriter writer = Files.newBufferedWriter(path)) {
|
|
||||||
gson.toJson(getConfig(), writer);
|
|
||||||
} catch (IOException e) {
|
|
||||||
MineLittlePony.logger.warn("Unable to save config.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,33 +3,37 @@ package com.minelittlepony.settings;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public interface Setting<Config> {
|
public interface Setting {
|
||||||
|
|
||||||
String name();
|
String name();
|
||||||
|
|
||||||
default boolean get(Config config) {
|
default boolean get() {
|
||||||
try {
|
try {
|
||||||
Field field = getField(config.getClass());
|
Field field = getField();
|
||||||
return field.getBoolean(config);
|
return field.getBoolean(null);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
default void set(Config config, boolean value) {
|
default void set(boolean value) {
|
||||||
try {
|
try {
|
||||||
Field field = getField(config.getClass());
|
Field field = getField();
|
||||||
field.setBoolean(config, value);
|
field.setBoolean(null, value);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
default Field getField(Class<?> owner) {
|
default Class<?> getEnclosingClass() {
|
||||||
|
return getClass().getEnclosingClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
default Field getField() {
|
||||||
try {
|
try {
|
||||||
return owner.getField(name().toLowerCase());
|
return getEnclosingClass().getField(name().toLowerCase());
|
||||||
} catch (NoSuchFieldException e) {
|
} catch (NoSuchFieldException e) {
|
||||||
throw new IllegalArgumentException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
9
src/main/resources/mcmod.info
Normal file
9
src/main/resources/mcmod.info
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[{
|
||||||
|
"modid": "minelittlepony",
|
||||||
|
"name": "Mine Little Pony",
|
||||||
|
"description": "Mine Little Pony turns players and mobs into ponies",
|
||||||
|
"version": "1.0.0.0",
|
||||||
|
"url": "minecraftforge.net/",
|
||||||
|
"authorList": ["killjoy"],
|
||||||
|
"credits": "I'd like to thank my mother and father."
|
||||||
|
}]
|
Loading…
Reference in a new issue