Add a new simplified and modularized config manager

This commit is contained in:
Matthew Messinger 2019-07-12 21:39:14 -04:00
parent 3c477745e4
commit ee19181089
19 changed files with 152 additions and 143 deletions

View file

@ -1,5 +1,6 @@
package com.minelittlepony.client;
import com.minelittlepony.settings.PonyConfig;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.hit.HitResult;
@ -13,7 +14,7 @@ public class HorseCam {
*/
public static float transformCameraAngle(float pitch) {
if (!MineLittlePony.getInstance().getConfig().fillycam.get()) {
if (!PonyConfig.INSTANCE.fillycam.get()) {
return pitch;
}

View file

@ -4,15 +4,13 @@ import com.minelittlepony.client.gui.GuiPonySettings;
import com.minelittlepony.client.hdskins.IndirectHDSkins;
import com.minelittlepony.client.pony.PonyManager;
import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer;
import com.minelittlepony.client.settings.ClientPonyConfig;
import com.minelittlepony.common.client.gui.VisibilityMode;
import com.minelittlepony.common.client.gui.element.Button;
import com.minelittlepony.common.client.gui.sprite.TextureSprite;
import com.minelittlepony.common.config.ConfigManager;
import com.minelittlepony.common.event.ClientReadyCallback;
import com.minelittlepony.common.event.ScreenInitCallback;
import com.minelittlepony.common.event.SkinFilterCallback;
import com.minelittlepony.common.util.GamePaths;
import com.minelittlepony.common.util.settings.JsonConfig;
import com.minelittlepony.pony.IPonyManager;
import com.minelittlepony.settings.PonyConfig;
@ -53,7 +51,6 @@ public class MineLittlePony implements ClientModInitializer {
private final PonyRenderManager renderManager = PonyRenderManager.getInstance();
private ClientPonyConfig config;
private PonyManager ponyManager;
private FabricKeyBinding keyBinding;
@ -63,6 +60,7 @@ public class MineLittlePony implements ClientModInitializer {
public MineLittlePony() {
instance = this;
ConfigManager.register("minelp.json", PonyConfig.INSTANCE);
}
/**
@ -77,8 +75,8 @@ public class MineLittlePony implements ClientModInitializer {
hasHdSkins = FabricLoader.getInstance().isModLoaded("hdskins");
hasModMenu = FabricLoader.getInstance().isModLoaded("modmenu");
config = JsonConfig.of(GamePaths.getConfigDirectory().resolve("minelp.json"), ClientPonyConfig::new);
ponyManager = new PonyManager(config);
ponyManager = new PonyManager();
keyBinding = FabricKeyBinding.Builder.create(new Identifier("minelittlepony", "settings"), InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_F9, "key.categories.misc").build();
KeyBindingRegistry.INSTANCE.register(keyBinding);
@ -141,7 +139,7 @@ public class MineLittlePony implements ClientModInitializer {
private void onScreenInit(Screen screen, ScreenInitCallback.ButtonList buttons) {
if (screen instanceof TitleScreen) {
VisibilityMode mode = config.horseButton.get();
VisibilityMode mode = PonyConfig.INSTANCE.horseButton.get();
boolean show = mode == VisibilityMode.ON || (mode == VisibilityMode.AUTO
&& !(hasHdSkins || hasModMenu
));
@ -161,13 +159,6 @@ public class MineLittlePony implements ClientModInitializer {
}
}
/**
* Gets the global MineLP client configuration.
*/
public PonyConfig getConfig() {
return config;
}
public IPonyManager getManager() {
return ponyManager;
}

View file

@ -1,12 +1,16 @@
package com.minelittlepony.client.gui;
import com.minelittlepony.common.config.ConfigManager;
import com.minelittlepony.common.config.Value;
import com.minelittlepony.common.config.ValueSignature;
import com.minelittlepony.settings.PonyConfig;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.LiteralText;
import com.minelittlepony.client.MineLittlePony;
import com.minelittlepony.client.render.entities.MobRenderers;
import com.minelittlepony.client.settings.ClientPonyConfig;
import com.minelittlepony.common.client.gui.GameGui;
import com.minelittlepony.common.client.gui.ScrollContainer;
import com.minelittlepony.common.client.gui.element.Button;
@ -16,10 +20,13 @@ import com.minelittlepony.common.client.gui.element.Slider;
import com.minelittlepony.common.client.gui.element.Toggle;
import com.minelittlepony.common.util.settings.Setting;
import com.minelittlepony.settings.PonyLevel;
import org.apache.logging.log4j.LogManager;
import java.io.IOException;
import java.util.Map;
/**
* In-Game options menu.
*
*/
public class GuiPonySettings extends GameGui {
@ -29,8 +36,6 @@ public class GuiPonySettings extends GameGui {
private static final String MOB_PREFIX = "minelp.mobs.";
private ClientPonyConfig config;
private final ScrollContainer content = new ScrollContainer();
private final boolean hiddenOptions;
@ -38,8 +43,6 @@ public class GuiPonySettings extends GameGui {
public GuiPonySettings() {
super(new LiteralText(OPTIONS_PREFIX + "title"));
config = (ClientPonyConfig)MineLittlePony.getInstance().getConfig();
content.margin.top = 30;
content.margin.bottom = 30;
content.padding.top = 10;
@ -77,37 +80,49 @@ public class GuiPonySettings extends GameGui {
.setText("gui.done");
content.addButton(new Label(LEFT, row)).getStyle().setText(PONY_LEVEL);
content.addButton(new Slider(LEFT, row += 20, 0, 2, config.ponyLevel.get().ordinal())
content.addButton(new Slider(LEFT, row += 20, 0, 2, PonyConfig.INSTANCE.ponyLevel.get().ordinal())
.onChange(v -> {
PonyLevel level = PonyLevel.valueFor(v);
config.ponyLevel.set(level);
return (float)level.ordinal();
PonyConfig.INSTANCE.ponyLevel.set(level);
return (float) level.ordinal();
})
.setFormatter(value -> I18n.translate(PONY_LEVEL + "." + PonyLevel.valueFor(value).name().toLowerCase())));
if (hiddenOptions) {
content.addButton(new Label(LEFT, row += 30)).getStyle().setText("minelp.debug.scale");
content.addButton(new Slider(LEFT, row += 15, 0.1F, 3, config.getGlobalScaleFactor())
.onChange(config::setGlobalScaleFactor)
content.addButton(new Slider(LEFT, row += 15, 0.1F, 3, PonyConfig.INSTANCE.getGlobalScaleFactor())
.onChange(PonyConfig.INSTANCE::setGlobalScaleFactor)
.setFormatter(value -> I18n.translate("minelp.debug.scale.value", I18n.translate(describeCurrentScale(value)))));
content.addButton(new Label(LEFT, row += 30)).getStyle().setText("minelp.debug.size");
content.addButton(new EnumSlider<>(LEFT, row += 15, config.sizeOverride.get())
.onChange(config.sizeOverride::set));
content.addButton(new EnumSlider<>(LEFT, row += 15, PonyConfig.INSTANCE.sizeOverride.get())
.onChange(i -> {
PonyConfig.INSTANCE.sizeOverride.set(i);
return i;
}));
}
row += 20;
content.addButton(new Label(LEFT, row)).getStyle().setText(OPTIONS_PREFIX + "options");
for (Setting<?> i : MineLittlePony.getInstance().getConfig().getByCategory("settings")) {
content.addButton(new Toggle(LEFT, row += 20, ((Setting<Boolean>)i).get()))
.onChange((Setting<Boolean>)i)
.getStyle().setText(OPTIONS_PREFIX + i.name().toLowerCase());
for (Map.Entry<String, ValueSignature<?>> i : ConfigManager.getCatagory(PonyConfig.INSTANCE, "settings").entrySet()) {
if (i.getValue().type == Boolean.class) {
Value<Boolean> v = (Value<Boolean>) i.getValue().value;
content.addButton(new Toggle(LEFT, row += 20, v.get()))
.onChange(b -> {
v.set(b);
return b;
})
.getStyle().setText(OPTIONS_PREFIX + i.getKey().toLowerCase());
}
}
content.addButton(new Label(LEFT, row += 20)).getStyle().setText(OPTIONS_PREFIX + "button");
content.addButton(new EnumSlider<>(LEFT, row += 20, config.horseButton.get())
.onChange(config.horseButton::set));
content.addButton(new EnumSlider<>(LEFT, row += 20, PonyConfig.INSTANCE.horseButton.get())
.onChange(value -> {
PonyConfig.INSTANCE.horseButton.set(value);
return value;
}));
if (RIGHT != LEFT) {
row = 0;
@ -152,6 +167,14 @@ public class GuiPonySettings extends GameGui {
@Override
public void onClose() {
super.onClose();
config.save();
try {
ConfigManager.save(PonyConfig.INSTANCE);
PlayerEntity player = MinecraftClient.getInstance().player;
if (player != null) {
player.calculateDimensions();
}
} catch (IOException e) {
LogManager.getLogger().warn("Unable to save config", e);
}
}
}

View file

@ -3,6 +3,7 @@ package com.minelittlepony.client.mixin;
import com.minelittlepony.client.MineLittlePony;
import com.minelittlepony.client.model.races.PlayerModels;
import com.minelittlepony.pony.IPonyManager;
import com.minelittlepony.settings.PonyConfig;
import com.minelittlepony.settings.PonyLevel;
import net.minecraft.client.util.DefaultSkinHelper;
@ -21,7 +22,7 @@ public abstract class MixinDefaultPlayerSkin {
at = @At("HEAD"),
cancellable = true)
private static void legacySkin(CallbackInfoReturnable<Identifier> cir) {
if (MineLittlePony.getInstance().getConfig().ponyLevel.get() == PonyLevel.PONIES) {
if (PonyConfig.INSTANCE.ponyLevel.get() == PonyLevel.PONIES) {
cir.setReturnValue(IPonyManager.STEVE);
}
}
@ -30,7 +31,7 @@ public abstract class MixinDefaultPlayerSkin {
at = @At("HEAD"),
cancellable = true)
private static void defaultSkin(UUID uuid, CallbackInfoReturnable<Identifier> cir) {
if (MineLittlePony.getInstance().getConfig().ponyLevel.get() == PonyLevel.PONIES) {
if (PonyConfig.INSTANCE.ponyLevel.get() == PonyLevel.PONIES) {
cir.setReturnValue(IPonyManager.getDefaultSkin(uuid));
}
}
@ -39,7 +40,7 @@ public abstract class MixinDefaultPlayerSkin {
at = @At("HEAD"),
cancellable = true)
private static void skinType(UUID uuid, CallbackInfoReturnable<String> cir) {
if (MineLittlePony.getInstance().getConfig().ponyLevel.get() == PonyLevel.PONIES) {
if (PonyConfig.INSTANCE.ponyLevel.get() == PonyLevel.PONIES) {
cir.setReturnValue(PlayerModels.forRace(MineLittlePony.getInstance().getManager()
.getPony(IPonyManager.getDefaultSkin(uuid), uuid)

View file

@ -1,9 +1,9 @@
package com.minelittlepony.client.model.components;
import com.minelittlepony.settings.PonyConfig;
import net.minecraft.client.model.Cuboid;
import net.minecraft.client.model.Model;
import com.minelittlepony.client.MineLittlePony;
import com.minelittlepony.client.util.render.plane.PlaneRenderer;
import com.minelittlepony.model.ICapitated;
import com.minelittlepony.pony.meta.Gender;
@ -59,7 +59,7 @@ public class PonySnout {
}
public void setGender(Gender gender) {
boolean show = !head.hasHeadGear() && !isHidden && MineLittlePony.getInstance().getConfig().snuzzles.get();
boolean show = !head.hasHeadGear() && !isHidden && PonyConfig.INSTANCE.snuzzles.get();
mare.field_3664 = !(show && gender.isMare());
stallion.field_3664 = !(show && gender.isStallion());

View file

@ -54,16 +54,10 @@ public class PonyManager implements IPonyManager, IdentifiableResourceReloadList
*/
private List<Identifier> backgroundPonyList = Lists.newArrayList();
private final PonyConfig config;
private final LoadingCache<Identifier, IPony> poniesCache = CacheBuilder.newBuilder()
.expireAfterAccess(30, TimeUnit.SECONDS)
.build(CacheLoader.from(Pony::new));
public PonyManager(PonyConfig config) {
this.config = config;
}
@Override
public IPony getPony(Identifier resource) {
return poniesCache.getUnchecked(resource);
@ -109,7 +103,7 @@ public class PonyManager implements IPonyManager, IdentifiableResourceReloadList
public IPony getPony(Identifier resource, UUID uuid) {
IPony pony = getPony(resource);
if (config.ponyLevel.get() == PonyLevel.PONIES && pony.getMetadata().getRace().isHuman()) {
if (PonyConfig.INSTANCE.ponyLevel.get() == PonyLevel.PONIES && pony.getMetadata().getRace().isHuman()) {
return getBackgroundPony(uuid);
}
@ -118,7 +112,7 @@ public class PonyManager implements IPonyManager, IdentifiableResourceReloadList
@Override
public IPony getDefaultPony(UUID uuid) {
if (config.ponyLevel.get() != PonyLevel.PONIES) {
if (PonyConfig.INSTANCE.ponyLevel.get() != PonyLevel.PONIES) {
return getPony(DefaultSkinHelper.getTexture(uuid));
}

View file

@ -1,5 +1,6 @@
package com.minelittlepony.client.render;
import com.minelittlepony.settings.PonyConfig;
import org.lwjgl.opengl.GL14;
import com.minelittlepony.client.MineLittlePony;
@ -79,7 +80,7 @@ public class LevitatingItemRenderer {
pushMatrix();
boolean doMagic = MineLittlePony.getInstance().getConfig().fpsmagic.get() && pony.getMetadata().hasMagic();
boolean doMagic = PonyConfig.INSTANCE.fpsmagic.get() && pony.getMetadata().hasMagic();
ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();

View file

@ -1,11 +1,11 @@
package com.minelittlepony.client.render;
import com.minelittlepony.client.MineLittlePony;
import com.minelittlepony.client.PonyRenderManager;
import com.minelittlepony.client.model.IPonyModel;
import com.minelittlepony.client.model.ModelWrapper;
import com.minelittlepony.client.transform.PonyPosture;
import com.minelittlepony.pony.IPony;
import com.minelittlepony.settings.PonyConfig;
import com.minelittlepony.util.math.MathUtil;
import com.mojang.blaze3d.platform.GlStateManager;
@ -41,7 +41,7 @@ public class RenderPony<T extends LivingEntity, M extends EntityModel<T> & IPony
}
public VisibleRegion getFrustrum(T entity, VisibleRegion vanilla) {
if (entity.isSleeping() || !MineLittlePony.getInstance().getConfig().frustrum.get()) {
if (entity.isSleeping() || !PonyConfig.INSTANCE.frustrum.get()) {
return vanilla;
}
return frustrum.withCamera(entity, vanilla);

View file

@ -2,12 +2,14 @@ package com.minelittlepony.client.render.entities;
import com.minelittlepony.client.MineLittlePony;
import com.minelittlepony.client.PonyRenderManager;
import com.minelittlepony.common.config.Value;
import com.minelittlepony.common.util.settings.Setting;
import java.util.Arrays;
import java.util.List;
import java.util.function.BiConsumer;
import com.minelittlepony.settings.PonyConfig;
import net.minecraft.entity.mob.*;
import net.minecraft.entity.passive.*;
@ -15,61 +17,59 @@ import net.minecraft.entity.passive.*;
* Central location where new entity renderers are registered and applied.
*/
public enum MobRenderers {
VILLAGERS((state, pony) -> {
VILLAGERS(PonyConfig.INSTANCE.villagers, (state, pony) -> {
pony.switchRenderer(state, VillagerEntity.class, RenderPonyVillager::new);
pony.switchRenderer(state, WitchEntity.class, RenderPonyWitch::new);
pony.switchRenderer(state, ZombieVillagerEntity.class, RenderPonyZombieVillager::new);
pony.switchRenderer(state, WanderingTraderEntity.class, RenderPonyTrader::new);
pony.switchRenderer(state, PillagerEntity.class, RenderPonyPillager::new);
}),
ZOMBIES((state, pony) -> {
ZOMBIES(PonyConfig.INSTANCE.zombies, (state, pony) -> {
pony.switchRenderer(state, ZombieEntity.class, RenderPonyZombie::new);
pony.switchRenderer(state, HuskEntity.class, RenderPonyZombie.Husk::new);
pony.switchRenderer(state, GiantEntity.class, RenderPonyZombie.Giant::new);
pony.switchRenderer(state, DrownedEntity.class, RenderPonyZombie.Drowned::new);
}),
PIGZOMBIES((state, pony) -> {
PIGZOMBIES(PonyConfig.INSTANCE.pigzombies, (state, pony) -> {
pony.switchRenderer(state, ZombiePigmanEntity.class, RenderPonyZombie.Pigman::new);
}),
SKELETONS((state, pony) -> {
SKELETONS(PonyConfig.INSTANCE.skeletons, (state, pony) -> {
pony.switchRenderer(state, SkeletonEntity.class, RenderPonySkeleton::new);
pony.switchRenderer(state, StrayEntity.class, RenderPonySkeleton.Stray::new);
pony.switchRenderer(state, WitherSkeletonEntity.class, RenderPonySkeleton.Wither::new);
}),
ILLAGERS((state, pony) -> {
ILLAGERS(PonyConfig.INSTANCE.illagers, (state, pony) -> {
pony.switchRenderer(state, VexEntity.class, RenderPonyVex::new);
pony.switchRenderer(state, EvokerEntity.class, RenderPonyIllager.Evoker::new);
pony.switchRenderer(state, VindicatorEntity.class, RenderPonyIllager.Vindicator::new);
pony.switchRenderer(state, IllusionerEntity.class, RenderPonyIllager.Illusionist::new);
}),
GUARDIANS((state, pony) -> {
GUARDIANS(PonyConfig.INSTANCE.guardians, (state, pony) -> {
pony.switchRenderer(state, GuardianEntity.class, RenderPonyGuardian::new);
pony.switchRenderer(state, ElderGuardianEntity.class, RenderPonyGuardian.Elder::new);
}),
ENDERMEN((state, pony) -> {
ENDERMEN(PonyConfig.INSTANCE.endermen, (state, pony) -> {
pony.switchRenderer(state, EndermanEntity.class, RenderEnderStallion::new);
});
public static final List<MobRenderers> registry = Arrays.asList(values());
private final Value<Boolean> config;
private final BiConsumer<Boolean, PonyRenderManager> changer;
MobRenderers(BiConsumer<Boolean, PonyRenderManager> changer) {
MobRenderers(Value<Boolean> config, BiConsumer<Boolean, PonyRenderManager> changer) {
this.config = config;
this.changer = changer;
}
public Setting<Boolean> option() {
return MineLittlePony.getInstance().getConfig().<Boolean>get(name().toLowerCase());
}
public boolean set(boolean value) {
value = option().set(value);
config.set(value);
apply(PonyRenderManager.getInstance());
return value;
return config.get();
}
public boolean get() {
return option().get();
return config.get();
}
public void apply(PonyRenderManager pony) {

View file

@ -19,8 +19,8 @@ public class PlayerSkullRenderer extends PonySkull {
private final ModelDeadMau5Ears deadMau5 = new ModelDeadMau5Ears();
@Override
public boolean canRender(PonyConfig config) {
return config.ponyLevel.get() != PonyLevel.HUMANS;
public boolean canRender() {
return PonyConfig.INSTANCE.ponyLevel.get() != PonyLevel.HUMANS;
}
@Override

View file

@ -44,7 +44,7 @@ public class PonySkullRenderer extends SkullBlockEntityRenderer {
* Original/Existing renderer is stored to a backup variable as a fallback in case of mods.
*/
public static SkullBlockEntityRenderer resolve() {
if (MineLittlePony.getInstance().getConfig().ponyskulls.get()) {
if (PonyConfig.INSTANCE.ponyskulls.get()) {
if (!(INSTANCE instanceof PonySkullRenderer)) {
backup = INSTANCE;
BlockEntityRendererRegistry.INSTANCE.register(SkullBlockEntity.class, ponyInstance);
@ -69,7 +69,7 @@ public class PonySkullRenderer extends SkullBlockEntityRenderer {
ISkull skull = skullMap.get(skullType);
if (skull == null || !skull.canRender(MineLittlePony.getInstance().getConfig())) {
if (skull == null || !skull.canRender()) {
if (backup != null) {
backup.render(x, y, z, facing, rotation, skullType, profile, destroyStage, animateTicks);
} else {
@ -154,7 +154,7 @@ public class PonySkullRenderer extends SkullBlockEntityRenderer {
void render(float animateTicks, float rotation, float scale);
boolean canRender(PonyConfig config);
boolean canRender();
Identifier getSkinResource(@Nullable GameProfile profile);

View file

@ -1,6 +1,5 @@
package com.minelittlepony.client.render.tileentities.skull;
import com.minelittlepony.client.render.entities.MobRenderers;
import com.minelittlepony.client.render.entities.RenderPonySkeleton;
import com.minelittlepony.settings.PonyConfig;
import com.mojang.authlib.GameProfile;
@ -11,8 +10,8 @@ import javax.annotation.Nullable;
public class SkeletonSkullRenderer extends PonySkull {
@Override
public boolean canRender(PonyConfig config) {
return MobRenderers.SKELETONS.get();
public boolean canRender() {
return PonyConfig.INSTANCE.skeletons.get();
}
@Override

View file

@ -1,6 +1,5 @@
package com.minelittlepony.client.render.tileentities.skull;
import com.minelittlepony.client.render.entities.MobRenderers;
import com.minelittlepony.client.render.entities.RenderPonySkeleton;
import com.minelittlepony.settings.PonyConfig;
import com.mojang.authlib.GameProfile;
@ -11,8 +10,8 @@ import javax.annotation.Nullable;
public class WitherSkullRenderer extends PonySkull {
@Override
public boolean canRender(PonyConfig config) {
return MobRenderers.SKELETONS.get();
public boolean canRender() {
return PonyConfig.INSTANCE.skeletons.get();
}
@Override

View file

@ -1,6 +1,5 @@
package com.minelittlepony.client.render.tileentities.skull;
import com.minelittlepony.client.render.entities.MobRenderers;
import com.minelittlepony.client.render.entities.RenderPonyZombie;
import com.minelittlepony.settings.PonyConfig;
import com.mojang.authlib.GameProfile;
@ -11,8 +10,8 @@ import javax.annotation.Nullable;
public class ZombieSkullRenderer extends PonySkull {
@Override
public boolean canRender(PonyConfig config) {
return MobRenderers.ZOMBIES.get();
public boolean canRender() {
return PonyConfig.INSTANCE.zombies.get();
}
@Override

View file

@ -1,30 +0,0 @@
package com.minelittlepony.client.settings;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.player.PlayerEntity;
import com.minelittlepony.client.render.entities.MobRenderers;
import com.minelittlepony.common.client.gui.VisibilityMode;
import com.minelittlepony.common.util.settings.Setting;
import com.minelittlepony.settings.PonyConfig;
public class ClientPonyConfig extends PonyConfig {
/**
* Visibility mode for the horse button.
*/
public final Setting<VisibilityMode> horseButton = value("horseButton", VisibilityMode.AUTO);
public ClientPonyConfig() {
MobRenderers.registry.forEach(r -> value(r.name().toLowerCase(), true));
}
@Override
public void save() {
super.save();
PlayerEntity player = MinecraftClient.getInstance().player;
if (player != null) {
player.calculateDimensions();
}
}
}

View file

@ -1,4 +0,0 @@
@ParametersAreNonnullByDefault
package com.minelittlepony.client.settings;
import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -1,7 +1,7 @@
package com.minelittlepony.pony.meta;
import com.minelittlepony.client.MineLittlePony;
import com.minelittlepony.pony.ITriggerPixelMapped;
import com.minelittlepony.settings.PonyConfig;
import com.minelittlepony.settings.PonyLevel;
import javax.annotation.Nonnull;
@ -94,7 +94,7 @@ public enum Race implements ITriggerPixelMapped<Race> {
* PonyLevel.PONIES (should) return a pony if this is a human. Don't be fooled, though. It doesn't.
*/
public Race getEffectiveRace(boolean ignorePony) {
if (MineLittlePony.getInstance().getConfig().getEffectivePonyLevel(ignorePony) == PonyLevel.HUMANS) {
if (PonyConfig.INSTANCE.getEffectivePonyLevel(ignorePony) == PonyLevel.HUMANS) {
return HUMAN;
}

View file

@ -1,7 +1,7 @@
package com.minelittlepony.pony.meta;
import com.minelittlepony.client.MineLittlePony;
import com.minelittlepony.pony.ITriggerPixelMapped;
import com.minelittlepony.settings.PonyConfig;
public enum Size implements ITriggerPixelMapped<Size> {
TALL (0x764b53, 0.45f, 1.1F, 1.15F),
@ -28,25 +28,25 @@ public enum Size implements ITriggerPixelMapped<Size> {
}
public float getShadowSize() {
return shadowSize * MineLittlePony.getInstance().getConfig().getGlobalScaleFactor();
return shadowSize * PonyConfig.INSTANCE.getGlobalScaleFactor();
}
public float getScaleFactor() {
return scale * MineLittlePony.getInstance().getConfig().getGlobalScaleFactor();
return scale * PonyConfig.INSTANCE.getGlobalScaleFactor();
}
public float getEyeHeightFactor() {
if (!MineLittlePony.getInstance().getConfig().fillycam.get()) {
if (!PonyConfig.INSTANCE.fillycam.get()) {
return 1;
}
return camera * MineLittlePony.getInstance().getConfig().getGlobalScaleFactor();
return camera * PonyConfig.INSTANCE.getGlobalScaleFactor();
}
public float getEyeDistanceFactor() {
if (!MineLittlePony.getInstance().getConfig().fillycam.get()) {
if (!PonyConfig.INSTANCE.fillycam.get()) {
return 1;
}
return camera * MineLittlePony.getInstance().getConfig().getGlobalScaleFactor();
return camera * PonyConfig.INSTANCE.getGlobalScaleFactor();
}
@Override
@ -55,13 +55,13 @@ public enum Size implements ITriggerPixelMapped<Size> {
}
public Size getEffectiveSize() {
Size sz = MineLittlePony.getInstance().getConfig().sizeOverride.get();
Size sz = PonyConfig.INSTANCE.sizeOverride.get();
if (sz != UNSET) {
return sz;
}
if (this == UNSET || !MineLittlePony.getInstance().getConfig().sizes.get()) {
if (this == UNSET || !PonyConfig.INSTANCE.sizes.get()) {
return NORMAL;
}

View file

@ -1,34 +1,69 @@
package com.minelittlepony.settings;
import com.minelittlepony.common.client.gui.VisibilityMode;
import com.minelittlepony.common.config.JsonConfig;
import com.minelittlepony.common.config.Setting;
import com.minelittlepony.common.config.Value;
import net.minecraft.util.math.MathHelper;
import com.minelittlepony.common.util.settings.JsonConfig;
import com.minelittlepony.common.util.settings.Setting;
import com.minelittlepony.pony.meta.Size;
/**
* Storage container for MineLP client settings.
*/
public class PonyConfig extends JsonConfig {
public class PonyConfig implements JsonConfig {
public static final PonyConfig INSTANCE = new PonyConfig();
private PonyConfig() {
}
/**
* Sets the pony level. Want MOAR PONEHS? Well here you go.
*/
public final Setting<PonyLevel> ponyLevel = value("ponylevel", PonyLevel.PONIES);
private final Setting<Float> scaleFactor = value("globalScaleFactor", 0.9F);
public final Value<PonyLevel> ponyLevel = new Value<>(PonyLevel.PONIES);
@Setting(name = "globalScaleFactor")
private final Value<Float> scaleFactor = new Value<>(0.9F);
public final Setting<Boolean> sizes = value("settings", "sizes", false);
public final Setting<Boolean> snuzzles = value("settings", "snuzzles", false);
public final Setting<Boolean> fillycam = value("settings", "fillycam", false);
private final Setting<Boolean> showscale = value("settings", "showscale", false);
public final Setting<Boolean> fpsmagic = value("settings", "fpsmagic", false);
public final Setting<Boolean> ponyskulls = value("settings", "ponyskulls", false);
public final Setting<Boolean> frustrum = value("settings", "frustrum", false);
@Setting(category = "settings")
public final Value<Boolean> sizes = new Value<>(false);
@Setting(category = "settings")
public final Value<Boolean> snuzzles = new Value<>(false);
@Setting(category = "settings")
public final Value<Boolean> fillycam = new Value<>(false);
@Setting(category = "settings")
private final Value<Boolean> showscale = new Value<>(false);
@Setting(category = "settings")
public final Value<Boolean> fpsmagic = new Value<>(false);
@Setting(category = "settings")
public final Value<Boolean> ponyskulls = new Value<>(false);
@Setting(category = "settings")
public final Value<Boolean> frustrum = new Value<>(false);
/**
* Debug override for pony sizes.
*/
public final Setting<Size> sizeOverride = value("sizeOverride", Size.UNSET);
public final Value<Size> sizeOverride = new Value<>(Size.UNSET);
/**
* Visibility mode for the horse button.
*/
public final Value<VisibilityMode> horseButton = new Value<>(VisibilityMode.AUTO);
@Setting(category = "entities")
public final Value<Boolean> villagers = new Value<>(true);
@Setting(category = "entities")
public final Value<Boolean> zombies = new Value<>(true);
@Setting(category = "entities")
public final Value<Boolean> pigzombies = new Value<>(true);
@Setting(category = "entities")
public final Value<Boolean> skeletons = new Value<>(true);
@Setting(category = "entities")
public final Value<Boolean> illagers = new Value<>(true);
@Setting(category = "entities")
public final Value<Boolean> guardians = new Value<>(true);
@Setting(category = "entities")
public final Value<Boolean> endermen = new Value<>(true);
/**
* Gets the current PonyLevel. That is the level of ponies you would like to see.