mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 12:37:59 +01:00
It runs on forge now. Probably has some bugs or unimplemented things.
This commit is contained in:
parent
af88f75de7
commit
8ddee9f65e
38 changed files with 511 additions and 804 deletions
|
@ -31,6 +31,8 @@ minecraft {
|
|||
mappings = 'snapshot_20180606'
|
||||
runDir = 'run'
|
||||
replace '@VERSION@', project.version
|
||||
|
||||
clientJvmArgs += '-Dfml.coreMod.load=com.minelittlepony.core.MLPLoadingPlugin'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
@ -70,6 +72,8 @@ dependencies {
|
|||
|
||||
jar {
|
||||
from sourceSets.hdskins.output
|
||||
manifest.attributes FMLCorePlugin: 'com.minelittlepony.core.MLPLoadingPlugin',
|
||||
FMLCorePluginContainsFMLMod: 'true'
|
||||
}
|
||||
sourceJar {
|
||||
// add hdskins sources
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
package mcp;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.meta.TypeQualifierDefault;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* This annotation can be applied to a package, class or method to indicate that
|
||||
* the method in that element are nonnull by default unless there is:
|
||||
* <ul>
|
||||
* <li>An explicit nullness annotation
|
||||
* <li>The method overrides a method in a superclass (in which case the
|
||||
* annotation of the corresponding method in the superclass applies)
|
||||
* <li> there is a default parameter annotation applied to a more tightly nested
|
||||
* element.
|
||||
* </ul>
|
||||
*
|
||||
*/
|
||||
@Documented
|
||||
@Nonnull
|
||||
@TypeQualifierDefault(ElementType.METHOD) // Note: This is a copy of javax.annotation.ParametersAreNonnullByDefault with target changed to METHOD
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface MethodsReturnNonnullByDefault {}
|
|
@ -1,20 +0,0 @@
|
|||
package net.minecraftforge.client;
|
||||
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
// stub
|
||||
public class ForgeHooksClient {
|
||||
|
||||
public static String getArmorTexture(Entity entity, ItemStack armor, String def, EntityEquipmentSlot slot, String type) {
|
||||
return def;
|
||||
}
|
||||
|
||||
public static ModelBiped getArmorModel(EntityLivingBase entity, ItemStack item, EntityEquipmentSlot slot, ModelBiped def) {
|
||||
return def;
|
||||
}
|
||||
|
||||
}
|
|
@ -16,8 +16,6 @@ import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
|||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.yggdrasil.response.MinecraftTexturesPayload;
|
||||
import com.mojang.util.UUIDTypeAdapter;
|
||||
import com.mumfrey.liteloader.core.LiteLoader;
|
||||
import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
|
||||
import com.voxelmodpack.hdskins.resource.SkinResourceManager;
|
||||
import com.voxelmodpack.hdskins.skins.AsyncCacheLoader;
|
||||
import com.voxelmodpack.hdskins.skins.SkinServer;
|
||||
|
@ -29,9 +27,12 @@ import net.minecraft.client.resources.DefaultPlayerSkin;
|
|||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
@ -47,12 +48,13 @@ import java.util.concurrent.ExecutorService;
|
|||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class HDSkinManager implements IResourceManagerReloadListener {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private static final ResourceLocation LOADING = new ResourceLocation("LOADING");
|
||||
private static final Gson GSON = new GsonBuilder()
|
||||
.registerTypeAdapter(UUID.class, new UUIDTypeAdapter())
|
||||
|
@ -139,7 +141,7 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
|
|||
|
||||
String skinDir = type.toString().toLowerCase() + "s/";
|
||||
final ResourceLocation skin = new ResourceLocation("hdskins", skinDir + texture.getHash());
|
||||
File file2 = new File(LiteLoader.getAssetsDirectory(), "hd/" + skinDir + texture.getHash().substring(0, 2) + "/" + texture.getHash());
|
||||
File file2 = new File(Launch.assetsDir, "hd/" + skinDir + texture.getHash().substring(0, 2) + "/" + texture.getHash());
|
||||
|
||||
final IImageBuffer imagebufferdownload = type == Type.SKIN ? new ImageBufferDownloadHD() : null;
|
||||
|
||||
|
@ -237,11 +239,11 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
|
|||
}
|
||||
|
||||
public static void clearSkinCache() {
|
||||
LiteLoaderLogger.info("Clearing local player skin cache");
|
||||
LOGGER.info("Clearing local player skin cache");
|
||||
|
||||
try {
|
||||
FileUtils.deleteDirectory(new File(LiteLoader.getAssetsDirectory(), "skins"));
|
||||
FileUtils.deleteDirectory(new File(LiteLoader.getAssetsDirectory(), "hd"));
|
||||
FileUtils.deleteDirectory(new File(Launch.assetsDir, "skins"));
|
||||
FileUtils.deleteDirectory(new File(Launch.assetsDir, "hd"));
|
||||
TextureManager textures = Minecraft.getMinecraft().getTextureManager();
|
||||
INSTANCE.skinCache.values().stream()
|
||||
.flatMap(m -> m.values().stream())
|
||||
|
@ -261,7 +263,7 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
|
|||
try {
|
||||
return callback.onSkinCacheCleared();
|
||||
} catch (Exception e) {
|
||||
LiteLoaderLogger.warning("Exception ancountered calling skin listener '{}'. It will be removed.", callback.getClass().getName());
|
||||
LOGGER.warn("Exception encountered calling skin listener '{}'. It will be removed.", callback.getClass().getName());
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
|
68
src/hdskins/java/com/voxelmodpack/hdskins/HDSkins.java
Normal file
68
src/hdskins/java/com/voxelmodpack/hdskins/HDSkins.java
Normal file
|
@ -0,0 +1,68 @@
|
|||
package com.voxelmodpack.hdskins;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
|
||||
import com.voxelmodpack.hdskins.gui.GLWindow;
|
||||
import com.voxelmodpack.hdskins.gui.RenderPlayerModel;
|
||||
import com.voxelmodpack.hdskins.skins.SkinServer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
@Mod(modid = "hdskins", name = "HD Skins", version = "4.0.0")
|
||||
@Mod.EventBusSubscriber
|
||||
public class HDSkins {
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLPreInitializationEvent event) {
|
||||
|
||||
Path json = event.getModConfigurationDirectory().toPath().resolve("skinservers.txt");
|
||||
List<String> list = SkinServer.defaultServers;
|
||||
try {
|
||||
list = Files.readAllLines(json);
|
||||
} catch (NoSuchFileException e) {
|
||||
// ignore this
|
||||
} catch (IOException e) {
|
||||
event.getModLog().warn("Error reading skin servers. Using defaults.", e);
|
||||
}
|
||||
|
||||
event.getModLog().info("Using skin servers:\n" + Joiner.on('\n').join(list));
|
||||
|
||||
IReloadableResourceManager irrm = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager();
|
||||
irrm.registerReloadListener(HDSkinManager.INSTANCE);
|
||||
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityPlayerModel.class, RenderPlayerModel::new);
|
||||
// register skin servers.
|
||||
for (String s : list) {
|
||||
try {
|
||||
HDSkinManager.INSTANCE.addSkinServer(SkinServer.from(s));
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// GLWindow.current();
|
||||
}
|
||||
|
||||
private static boolean fullscreen;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onFullScreenToggled(TickEvent.ClientTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.START) {
|
||||
fullscreen = Minecraft.getMinecraft().isFullScreen();
|
||||
} else if (Minecraft.getMinecraft().isFullScreen() != fullscreen) {
|
||||
// fullscreen has changed since beginning of tick.
|
||||
GLWindow.refresh(Minecraft.getMinecraft().isFullScreen());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package com.voxelmodpack.hdskins;
|
||||
|
||||
public final class Later extends Thread {
|
||||
|
||||
private final int delay;
|
||||
|
||||
protected Later(int delay, Runnable runnable) {
|
||||
super(runnable);
|
||||
this.delay = delay;
|
||||
setDaemon(true);
|
||||
setName("Later#" + getId());
|
||||
}
|
||||
|
||||
public static void performLater(int delay, Runnable callable) {
|
||||
new Later(delay, callable).start();
|
||||
}
|
||||
|
||||
public static void performNow(Runnable callable) {
|
||||
new Later(0, callable).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (delay > 0) sleep(delay);
|
||||
} catch (InterruptedException e) {}
|
||||
super.run();
|
||||
}
|
||||
}
|
|
@ -96,7 +96,7 @@ public class GLWindow extends DropTarget {
|
|||
|
||||
frame = new JFrame(Display.getTitle());
|
||||
frame.add(canvas);
|
||||
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
frame.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosed(WindowEvent windowEvent) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import com.google.common.util.concurrent.FutureCallback;
|
|||
import com.google.common.util.concurrent.Futures;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
|
||||
import com.voxelmodpack.hdskins.HDSkinManager;
|
||||
import com.voxelmodpack.hdskins.skins.SkinUploadResponse;
|
||||
import com.voxelmodpack.hdskins.upload.awt.ThreadOpenFilePNG;
|
||||
|
@ -33,6 +32,7 @@ import net.minecraft.util.math.MathHelper;
|
|||
import net.minecraft.util.text.TextFormatting;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.util.glu.GLU;
|
||||
|
@ -47,6 +47,9 @@ import javax.imageio.ImageIO;
|
|||
import javax.swing.*;
|
||||
|
||||
public class GuiSkins extends GuiScreen implements FutureCallback<SkinUploadResponse> {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private static final int MAX_SKIN_DIMENSION = 1024;
|
||||
private int updateCounter = 0;
|
||||
private ResourceLocation viewportTexture;
|
||||
|
@ -672,7 +675,7 @@ public class GuiSkins extends GuiScreen implements FutureCallback<SkinUploadResp
|
|||
}
|
||||
|
||||
private void onUploadComplete(SkinUploadResponse response) {
|
||||
LiteLoaderLogger.info("Upload completed with: %s", response);
|
||||
LOGGER.info("Upload completed with: %s", response);
|
||||
this.uploadingSkin = false;
|
||||
if (!"OK".equalsIgnoreCase(response.getMessage())) {
|
||||
this.setUploadError(response.getMessage());
|
||||
|
|
|
@ -1,64 +1,28 @@
|
|||
package com.voxelmodpack.hdskins.gui;
|
||||
|
||||
import com.mumfrey.liteloader.modconfig.ConfigPanel;
|
||||
import com.mumfrey.liteloader.modconfig.ConfigPanelHost;
|
||||
import com.voxelmodpack.hdskins.HDSkinManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraftforge.fml.client.config.GuiConfig;
|
||||
|
||||
public class HDSkinsConfigPanel implements ConfigPanel {
|
||||
public class HDSkinsConfigPanel extends GuiConfig {
|
||||
|
||||
private GuiButton button;
|
||||
|
||||
@Override
|
||||
public void onPanelShown(ConfigPanelHost host) {
|
||||
this.button = new GuiButton(0, 40, 10, 100, 20, "Clear Skin Cache");
|
||||
|
||||
public HDSkinsConfigPanel() {
|
||||
super(null, "hdskins", "HD Skins");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPanel(ConfigPanelHost host, int mouseX, int mouseY, float partialTicks) {
|
||||
this.button.drawButton(Minecraft.getMinecraft(), mouseX, mouseY, partialTicks);
|
||||
public void initGui() {
|
||||
this.addButton(new GuiButton(0, 40, 10, 100, 20, "Clear Skin Cache"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton) {
|
||||
if (button.mousePressed(Minecraft.getMinecraft(), mouseX, mouseY)) {
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
super.actionPerformed(button);
|
||||
|
||||
if (button.id == 0) {
|
||||
HDSkinManager.clearSkinCache();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPanelTitle() {
|
||||
return "HD Skins Settings";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContentHeight() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(ConfigPanelHost host, char keyChar, int keyCode) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(ConfigPanelHost host, int mouseX, int mouseY) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPanelHidden() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPanelResize(ConfigPanelHost host) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(ConfigPanelHost host) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
package com.voxelmodpack.hdskins.mod;
|
||||
|
||||
import com.mumfrey.liteloader.Configurable;
|
||||
import com.mumfrey.liteloader.InitCompleteListener;
|
||||
import com.mumfrey.liteloader.ViewportListener;
|
||||
|
||||
public interface HDSkinsMod extends InitCompleteListener, ViewportListener, Configurable {
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
package com.voxelmodpack.hdskins.mod;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.mumfrey.liteloader.core.LiteLoader;
|
||||
import com.mumfrey.liteloader.modconfig.ConfigPanel;
|
||||
import com.mumfrey.liteloader.modconfig.ConfigStrategy;
|
||||
import com.mumfrey.liteloader.modconfig.ExposableOptions;
|
||||
import com.mumfrey.liteloader.util.ModUtilities;
|
||||
import com.voxelmodpack.hdskins.HDSkinManager;
|
||||
import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
|
||||
import com.voxelmodpack.hdskins.gui.GLWindow;
|
||||
import com.voxelmodpack.hdskins.gui.GuiSkins;
|
||||
import com.voxelmodpack.hdskins.gui.HDSkinsConfigPanel;
|
||||
import com.voxelmodpack.hdskins.gui.RenderPlayerModel;
|
||||
import com.voxelmodpack.hdskins.skins.SkinServer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
@ExposableOptions(strategy = ConfigStrategy.Unversioned, filename = "hdskins")
|
||||
public class LiteModHDSkinsMod implements HDSkinsMod {
|
||||
|
||||
@Expose
|
||||
public List<String> skin_servers = SkinServer.defaultServers;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "HD Skins";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return "4.0.0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(File configPath) {
|
||||
|
||||
// register config
|
||||
LiteLoader.getInstance().registerExposable(this, null);
|
||||
|
||||
// try it initialize voxelmenu button
|
||||
try {
|
||||
Class<?> ex = Class.forName("com.thevoxelbox.voxelmenu.GuiMainMenuVoxelBox");
|
||||
Method mRegisterCustomScreen = ex.getDeclaredMethod("registerCustomScreen", Class.class, String.class);
|
||||
mRegisterCustomScreen.invoke(null, GuiSkins.class, "HD Skins Manager");
|
||||
} catch (ClassNotFoundException var4) {
|
||||
// voxelmenu's not here, man
|
||||
} catch (Exception var5) {
|
||||
var5.printStackTrace();
|
||||
}
|
||||
|
||||
IReloadableResourceManager irrm = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager();
|
||||
irrm.registerReloadListener(HDSkinManager.INSTANCE);
|
||||
|
||||
GLWindow.current();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradeSettings(String version, File configPath, File oldConfigPath) {
|
||||
HDSkinManager.clearSkinCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends ConfigPanel> getConfigPanelClass() {
|
||||
return HDSkinsConfigPanel.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitCompleted(Minecraft minecraft, LiteLoader loader) {
|
||||
ModUtilities.addRenderer(EntityPlayerModel.class, new RenderPlayerModel<>(minecraft.getRenderManager()));
|
||||
|
||||
// register skin servers.
|
||||
for (String s : skin_servers) {
|
||||
try {
|
||||
HDSkinManager.INSTANCE.addSkinServer(SkinServer.from(s));
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewportResized(ScaledResolution resolution, int displayWidth, int displayHeight) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFullScreenToggled(boolean fullScreen) {
|
||||
GLWindow.refresh(fullScreen);
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
@MethodsReturnNonnullByDefault
|
||||
@ParametersAreNonnullByDefault
|
||||
package com.voxelmodpack.hdskins.mod;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
|
@ -5,15 +5,14 @@ import com.google.gson.Gson;
|
|||
import com.google.gson.JsonParseException;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
@ -23,9 +22,12 @@ import java.util.concurrent.CompletableFuture;
|
|||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class SkinResourceManager implements IResourceManagerReloadListener {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
|
||||
private ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
|
||||
private Map<UUID, Skin> uuidSkins = Maps.newHashMap();
|
||||
|
@ -55,7 +57,7 @@ public class SkinResourceManager implements IResourceManagerReloadListener {
|
|||
}
|
||||
}
|
||||
} catch (JsonParseException je) {
|
||||
LiteLoaderLogger.warning(je, "Invalid skins.json in %s", res.getResourcePackName());
|
||||
logger.warn("Invalid skins.json in %s", res.getResourcePackName(), je);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -2,16 +2,8 @@ package com.voxelmodpack.hdskins.upload.awt;
|
|||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
import org.lwjgl.opengl.Display;
|
||||
|
||||
import com.voxelmodpack.hdskins.Later;
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.*;
|
||||
|
||||
/**
|
||||
* Base class for "open file" dialog threads
|
||||
|
@ -41,18 +33,6 @@ public abstract class ThreadOpenFile extends Thread {
|
|||
this.dialogTitle = dialogTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
Later.performLater(0, this);
|
||||
}
|
||||
|
||||
public ThreadOpenFile setParent(JFrame parent) {
|
||||
this.parent = parent;
|
||||
this.parent.setAlwaysOnTop(true);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (parent == null) {
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
package com.minelittlepony;
|
||||
|
||||
import com.mumfrey.liteloader.util.ModUtilities;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Proxy class for accessing forge fields and methods.
|
||||
*/
|
||||
public class ForgeProxy {
|
||||
|
||||
/**
|
||||
* True if forge is present.
|
||||
*/
|
||||
private static boolean forgeLoaded = ModUtilities.fmlIsPresent();
|
||||
|
||||
/**
|
||||
* Gets the mod armour texture for an associated item and slot.
|
||||
*
|
||||
* @param entity The entity to get armour for.
|
||||
* @param item The armour item
|
||||
* @param def Default return value if no mods present
|
||||
* @param slot The slot this armour piece is place in.
|
||||
* @param type unknown
|
||||
* @return
|
||||
*/
|
||||
public static String getArmorTexture(Entity entity, ItemStack item, String def, EntityEquipmentSlot slot, @Nullable String type) {
|
||||
if (forgeLoaded)
|
||||
return ForgeHooksClient.getArmorTexture(entity, item, def, slot, type);
|
||||
return def;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mod armour model for an associated item and slot.
|
||||
*
|
||||
* @param entity The entity to get armour for.
|
||||
* @param item The armour item
|
||||
* @param slot The slot this armour piece is place in.
|
||||
* @param def Default return value if no mods present
|
||||
*/
|
||||
public static ModelBiped getArmorModel(EntityLivingBase entity, ItemStack item, EntityEquipmentSlot slot, ModelBiped def) {
|
||||
if (forgeLoaded)
|
||||
return ForgeHooksClient.getArmorModel(entity, item, slot, def);
|
||||
return def;
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package com.minelittlepony;
|
||||
|
||||
import com.minelittlepony.gui.PonySettingsPanel;
|
||||
import com.mumfrey.liteloader.Configurable;
|
||||
import com.mumfrey.liteloader.InitCompleteListener;
|
||||
import com.mumfrey.liteloader.Tickable;
|
||||
import com.mumfrey.liteloader.core.LiteLoader;
|
||||
import com.mumfrey.liteloader.modconfig.ConfigPanel;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class LiteModMineLittlePony implements Tickable, InitCompleteListener, Configurable {
|
||||
|
||||
private MineLittlePony mlp;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MineLittlePony.MOD_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return MineLittlePony.MOD_VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradeSettings(String version, File configPath, File oldConfigPath) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(File configPath) {
|
||||
mlp = new MineLittlePony();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitCompleted(Minecraft minecraft, LiteLoader loader) {
|
||||
mlp.postInit(minecraft);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) {
|
||||
mlp.onTick(minecraft, inGame);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends ConfigPanel> getConfigPanelClass() {
|
||||
return PonySettingsPanel.class;
|
||||
}
|
||||
}
|
|
@ -4,53 +4,49 @@ import com.minelittlepony.gui.GuiPonySettings;
|
|||
import com.minelittlepony.hdskins.gui.GuiSkinsMineLP;
|
||||
import com.minelittlepony.pony.data.IPonyData;
|
||||
import com.minelittlepony.pony.data.PonyDataSerialzier;
|
||||
import com.mumfrey.liteloader.core.LiteLoader;
|
||||
import com.minelittlepony.settings.PonyConfig;
|
||||
import com.voxelmodpack.hdskins.HDSkinManager;
|
||||
import com.voxelmodpack.hdskins.gui.GuiSkins;
|
||||
import com.voxelmodpack.hdskins.skins.SkinServer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
import net.minecraft.client.resources.data.MetadataSerializer;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
/**
|
||||
* Static MineLittlePony singleton class. Everything's controlled from up here.
|
||||
*/
|
||||
|
||||
@Mod(modid = "minelittlepony", name = MineLittlePony.MOD_NAME, version = MineLittlePony.MOD_VERSION, clientSideOnly = true)
|
||||
public class MineLittlePony {
|
||||
|
||||
public static final Logger logger = LogManager.getLogger("MineLittlePony");
|
||||
public static Logger logger;
|
||||
|
||||
public static final String MOD_NAME = "Mine Little Pony";
|
||||
public static final String MOD_VERSION = "@VERSION@";
|
||||
|
||||
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 final PonyConfig config;
|
||||
private final PonyManager ponyManager;
|
||||
private PonyConfig.Loader configLoader;
|
||||
private PonyManager ponyManager;
|
||||
|
||||
private final PonyRenderManager renderManager;
|
||||
private PonyRenderManager renderManager;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
instance = this;
|
||||
logger = event.getModLog();
|
||||
|
||||
LiteLoader.getInput().registerKeyBinding(SETTINGS_GUI);
|
||||
configLoader = new PonyConfig.Loader(event.getModConfigurationDirectory().toPath().resolve("minelittlepony.json"));
|
||||
ponyManager = new PonyManager(configLoader.getConfig());
|
||||
|
||||
config = new PonyConfig();
|
||||
ponyManager = new PonyManager(config);
|
||||
|
||||
renderManager = new PonyRenderManager();
|
||||
|
||||
LiteLoader.getInstance().registerExposable(config, null);
|
||||
|
||||
IReloadableResourceManager irrm = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager();
|
||||
irrm.registerReloadListener(ponyManager);
|
||||
|
@ -63,7 +59,9 @@ public class MineLittlePony {
|
|||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
public void postInit(FMLLoadCompleteEvent event) {
|
||||
|
||||
renderManager = new PonyRenderManager(Minecraft.getMinecraft().getRenderManager());
|
||||
|
||||
HDSkinManager manager = HDSkinManager.INSTANCE;
|
||||
// manager.setSkinUrl(SKIN_SERVER_URL);
|
||||
|
@ -72,9 +70,8 @@ public class MineLittlePony {
|
|||
// logger.info("Set MineLP skin server URL.");
|
||||
manager.addClearListener(ponyManager);
|
||||
|
||||
RenderManager rm = minecraft.getRenderManager();
|
||||
renderManager.initialisePlayerRenderers(rm);
|
||||
renderManager.initializeMobRenderers(rm, config);
|
||||
renderManager.initialisePlayerRenderers();
|
||||
renderManager.initializeMobRenderers(configLoader.getConfig());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -91,7 +88,7 @@ public class MineLittlePony {
|
|||
if (skins) {
|
||||
minecraft.displayGuiScreen(new GuiSkinsMineLP(ponyManager));
|
||||
}
|
||||
HDSkinManager.INSTANCE.setEnabled(config.hd);
|
||||
HDSkinManager.INSTANCE.setEnabled(configLoader.getConfig().hd);
|
||||
|
||||
}
|
||||
|
||||
|
@ -119,8 +116,8 @@ public class MineLittlePony {
|
|||
/**
|
||||
* Gets the global MineLP client configuration.
|
||||
*/
|
||||
public static PonyConfig getConfig() {
|
||||
return getInstance().config;
|
||||
public static PonyConfig.Loader getConfigLoader() {
|
||||
return getInstance().configLoader;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
package com.minelittlepony;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.minelittlepony.pony.data.PonyLevel;
|
||||
import com.minelittlepony.settings.SensibleConfig;
|
||||
import com.mumfrey.liteloader.modconfig.ConfigStrategy;
|
||||
import com.mumfrey.liteloader.modconfig.Exposable;
|
||||
import com.mumfrey.liteloader.modconfig.ExposableOptions;
|
||||
|
||||
/**
|
||||
* Storage container for MineLP client settings.
|
||||
*
|
||||
*/
|
||||
@ExposableOptions(filename = "minelittlepony", strategy = ConfigStrategy.Unversioned)
|
||||
public class PonyConfig extends SensibleConfig implements Exposable {
|
||||
|
||||
@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;
|
||||
|
||||
public enum PonySettings implements Setting {
|
||||
SIZES,
|
||||
SNUZZLES,
|
||||
HD,
|
||||
SHOWSCALE;
|
||||
}
|
||||
|
||||
@Expose public boolean villagers = true;
|
||||
@Expose public boolean zombies = true;
|
||||
@Expose public boolean pigzombies = true;
|
||||
@Expose public boolean skeletons = true;
|
||||
@Expose public boolean illagers = true;
|
||||
@Expose public boolean guardians = 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually gets the pony level value. No option to ignore reality here.
|
||||
*/
|
||||
public PonyLevel getPonyLevel() {
|
||||
if (ponylevel == null) {
|
||||
ponylevel = PonyLevel.PONIES;
|
||||
}
|
||||
return ponylevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the pony level. Want MOAR PONEHS? Well here you go.
|
||||
* @param ponylevel
|
||||
*/
|
||||
public void setPonyLevel(PonyLevel ponylevel) {
|
||||
this.ponylevel = ponylevel;
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import com.google.gson.JsonParseException;
|
|||
import com.minelittlepony.model.PMAPI;
|
||||
import com.minelittlepony.pony.data.Pony;
|
||||
import com.minelittlepony.pony.data.PonyLevel;
|
||||
import com.minelittlepony.settings.PonyConfig;
|
||||
import com.voxelmodpack.hdskins.HDSkinManager;
|
||||
import com.voxelmodpack.hdskins.ISkinCacheClearListener;
|
||||
|
||||
|
|
|
@ -1,20 +1,22 @@
|
|||
package com.minelittlepony;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.minelittlepony.mixin.MixinRenderManager;
|
||||
import com.minelittlepony.hdskins.gui.EntityPonyModel;
|
||||
import com.minelittlepony.hdskins.gui.RenderPonyModel;
|
||||
import com.minelittlepony.model.player.PlayerModels;
|
||||
import com.minelittlepony.render.LevitatingItemRenderer;
|
||||
import com.minelittlepony.render.player.RenderPonyPlayer;
|
||||
import com.minelittlepony.render.ponies.MobRenderers;
|
||||
import com.mumfrey.liteloader.util.ModUtilities;
|
||||
|
||||
import com.minelittlepony.settings.PonyConfig;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraftforge.fml.client.registry.IRenderFactory;
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Render manager responsible for replacing and restoring entity renderers when the client settings change.
|
||||
|
@ -24,65 +26,77 @@ public class PonyRenderManager {
|
|||
|
||||
private LevitatingItemRenderer magicRenderer = new LevitatingItemRenderer();
|
||||
|
||||
|
||||
private final Map<Class<? extends Entity>, Render<?>> renderMap = Maps.newHashMap();
|
||||
|
||||
private final RenderManager manager;
|
||||
private final Map<String, RenderPlayer> skinMap;
|
||||
|
||||
public PonyRenderManager(RenderManager manager) {
|
||||
this.manager = manager;
|
||||
skinMap = ReflectionHelper.getPrivateValue(RenderManager.class, manager, "field_178636_l", "skinMap");
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers all new player skin types. (currently only pony and slimpony).
|
||||
*/
|
||||
public void initialisePlayerRenderers(RenderManager manager) {
|
||||
public void initialisePlayerRenderers() {
|
||||
// Preview on the select skin gui
|
||||
ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(manager));
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityPonyModel.class, RenderPonyModel::new);
|
||||
|
||||
for (PlayerModels i : PlayerModels.values()) {
|
||||
if (i != PlayerModels.HUMAN) {
|
||||
registerPlayerSkin(manager, i);
|
||||
registerPlayerSkin(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerPlayerSkin(RenderManager manager, PlayerModels playerModel) {
|
||||
addPlayerSkin(manager, false, playerModel);
|
||||
addPlayerSkin(manager, true, playerModel);
|
||||
private void registerPlayerSkin(PlayerModels playerModel) {
|
||||
addPlayerSkin(false, playerModel);
|
||||
addPlayerSkin(true, playerModel);
|
||||
}
|
||||
|
||||
private void addPlayerSkin(RenderManager manager, boolean slimArms, PlayerModels playerModel) {
|
||||
private void addPlayerSkin(boolean slimArms, PlayerModels playerModel) {
|
||||
RenderPonyPlayer renderer = new RenderPonyPlayer(manager, slimArms, playerModel.getModel(slimArms));
|
||||
|
||||
((MixinRenderManager)manager).getSkinMap().put(playerModel.getId(slimArms), renderer);
|
||||
Map<String, RenderPlayer> skinMap = ReflectionHelper.getPrivateValue(RenderManager.class, manager, "field_178636_l", "skinMap");
|
||||
|
||||
skinMap.put(playerModel.getId(slimArms), renderer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers all entity model replacements. (except for players).
|
||||
*/
|
||||
public void initializeMobRenderers(RenderManager manager, PonyConfig config) {
|
||||
public void initializeMobRenderers(PonyConfig config) {
|
||||
for (MobRenderers i : MobRenderers.values()) {
|
||||
i.apply(this, manager);
|
||||
boolean state = i.get(config);
|
||||
i.register(state, this);
|
||||
if (state) {
|
||||
MineLittlePony.logger.info(i.name() + " are now ponies.");
|
||||
}
|
||||
}
|
||||
|
||||
RenderingRegistry.loadEntityRenderers(manager, manager.entityRenderMap);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Replaces an entity renderer depending on whether we want ponies or not.
|
||||
*
|
||||
* @param state True if we want ponies (the original will be stored)
|
||||
* @param manager The render manager
|
||||
* @param type The type to replace
|
||||
* @param renderer The replacement value
|
||||
* @param <T> The entity type
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Entity, V extends T> void switchRenderer(boolean state, RenderManager manager, Class<V> type, Render<T> renderer) {
|
||||
public <T extends Entity> void switchRenderer(boolean state, Class<T> type, IRenderFactory<T> renderer) {
|
||||
if (state) {
|
||||
if (!renderMap.containsKey(type)) {
|
||||
renderMap.put(type, manager.getEntityClassRenderObject(type));
|
||||
}
|
||||
ModUtilities.addRenderer((Class<T>)type, renderer);
|
||||
} else {
|
||||
if (renderMap.containsKey(type)) {
|
||||
ModUtilities.addRenderer(type, (Render<V>)renderMap.get(type));
|
||||
}
|
||||
RenderingRegistry.registerEntityRenderingHandler(type, renderer);
|
||||
} else if (renderMap.containsKey(type)) {
|
||||
RenderingRegistry.registerEntityRenderingHandler(type, mngr -> (Render<T>) renderMap.get(type));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public LevitatingItemRenderer getMagicRenderer() {
|
||||
|
|
43
src/main/java/com/minelittlepony/core/MLPLoadingPlugin.java
Normal file
43
src/main/java/com/minelittlepony/core/MLPLoadingPlugin.java
Normal file
|
@ -0,0 +1,43 @@
|
|||
package com.minelittlepony.core;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
|
||||
import org.spongepowered.asm.launch.MixinBootstrap;
|
||||
import org.spongepowered.asm.mixin.Mixins;
|
||||
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@IFMLLoadingPlugin.MCVersion("1.12.2")
|
||||
public class MLPLoadingPlugin implements IFMLLoadingPlugin {
|
||||
|
||||
public MLPLoadingPlugin() {
|
||||
MixinBootstrap.init();
|
||||
Mixins.addConfigurations("minelp.mixin.json", "hdskins.mixin.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getASMTransformerClass() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModContainerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getSetupClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectData(Map<String, Object> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAccessTransformerClass() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,22 +1,22 @@
|
|||
package com.minelittlepony.gui;
|
||||
|
||||
import com.mumfrey.liteloader.client.gui.GuiCheckbox;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.client.config.GuiCheckBox;
|
||||
|
||||
public class Checkbox extends GuiCheckbox implements IActionable {
|
||||
import java.util.function.Consumer;
|
||||
|
||||
private final IGUIAction<Boolean> action;
|
||||
public class Checkbox extends GuiCheckBox implements IActionable {
|
||||
|
||||
public Checkbox(int x, int y, String displayString, boolean value, IGUIAction<Boolean> callback) {
|
||||
super(0, x, y, I18n.format(displayString));
|
||||
action = callback;
|
||||
checked = value;
|
||||
private final Consumer<Boolean> callback;
|
||||
|
||||
public Checkbox(int x, int y, String displayString, boolean value, Consumer<Boolean> callback) {
|
||||
super(0, x, y, I18n.format(displayString), value);
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
checked = action.perform(!checked);
|
||||
this.callback.accept(isChecked());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,23 +1,19 @@
|
|||
package com.minelittlepony.gui;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.PonyConfig;
|
||||
import com.minelittlepony.PonyConfig.PonySettings;
|
||||
import com.minelittlepony.pony.data.PonyLevel;
|
||||
import com.minelittlepony.render.ponies.MobRenderers;
|
||||
import com.mumfrey.liteloader.core.LiteLoader;
|
||||
|
||||
import com.minelittlepony.settings.PonyConfig;
|
||||
import com.minelittlepony.settings.Setting;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.client.config.GuiConfig;
|
||||
|
||||
/**
|
||||
* In-Game options menu.
|
||||
*
|
||||
*/
|
||||
public class GuiPonySettings extends GuiScreen {
|
||||
public class GuiPonySettings extends GuiConfig {
|
||||
|
||||
private static final String OPTIONS_PREFIX = "minelp.options.";
|
||||
|
||||
|
@ -25,10 +21,13 @@ public class GuiPonySettings extends GuiScreen {
|
|||
|
||||
private static final String MOB_PREFIX = "minelp.mobs.";
|
||||
|
||||
private PonyConfig.Loader configLoader;
|
||||
private PonyConfig config;
|
||||
|
||||
public GuiPonySettings() {
|
||||
config = MineLittlePony.getConfig();
|
||||
super(null, "minelittlepony", "Mine Little Pony");
|
||||
configLoader = MineLittlePony.getConfigLoader();
|
||||
config = configLoader.getConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -44,17 +43,17 @@ public class GuiPonySettings extends GuiScreen {
|
|||
|
||||
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) -> {
|
||||
return I18n.format(PONY_LEVEL + "." + PonyLevel.valueFor(value).name().toLowerCase());
|
||||
return I18n.format(PONY_LEVEL + "." + PonyLevel.valueFor((int) value).name().toLowerCase());
|
||||
}, v -> {
|
||||
PonyLevel level = PonyLevel.valueFor(v);
|
||||
PonyLevel level = PonyLevel.valueFor((int) v);
|
||||
config.setPonyLevel(level);
|
||||
return (float)level.ordinal();
|
||||
}));
|
||||
|
||||
row += 15;
|
||||
addButton(new Label(LEFT, row += 15, OPTIONS_PREFIX + "options", -1));
|
||||
for (PonySettings i : PonySettings.values()) {
|
||||
addButton(new Checkbox(LEFT, row += 15, OPTIONS_PREFIX + i.name().toLowerCase(), i.get(), i));
|
||||
for (Setting<PonyConfig> i : PonyConfig.PonySettings.values()) {
|
||||
addButton(new Checkbox(LEFT, row += 15, OPTIONS_PREFIX + i.name().toLowerCase(), i.get(config), b -> i.set(config, b)));
|
||||
}
|
||||
|
||||
if (mustScroll()) {
|
||||
|
@ -65,12 +64,12 @@ public class GuiPonySettings extends GuiScreen {
|
|||
|
||||
addButton(new Label(RIGHT, row += 15, MOB_PREFIX + "title", -1));
|
||||
for (MobRenderers i : MobRenderers.values()) {
|
||||
addButton(new Checkbox(RIGHT, row += 15, MOB_PREFIX + i.name().toLowerCase(), i.get(), i));
|
||||
addButton(new Checkbox(RIGHT, row += 15, MOB_PREFIX + i.name().toLowerCase(), i.get(config), v -> i.set(config, v)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
if (button instanceof IActionable) {
|
||||
((IActionable)button).perform();
|
||||
}
|
||||
|
@ -84,7 +83,7 @@ public class GuiPonySettings extends GuiScreen {
|
|||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
LiteLoader.getInstance().writeConfig(config);
|
||||
configLoader.save();
|
||||
}
|
||||
|
||||
protected String getTitle() {
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
package com.minelittlepony.gui;
|
||||
|
||||
/**
|
||||
* Response actions for UI events.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface IGUIAction<T> {
|
||||
/**
|
||||
* Performs this action now.
|
||||
*
|
||||
* @param value New Value of the field being changed
|
||||
* @return Adjusted value the field must take on
|
||||
*/
|
||||
T perform(T value);
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
package com.minelittlepony.gui;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.mumfrey.liteloader.modconfig.ConfigPanel;
|
||||
import com.mumfrey.liteloader.modconfig.ConfigPanelHost;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
/**
|
||||
* Boilerplate because LiteLoader has to be such a 'special flower' -_-
|
||||
*/
|
||||
public class PonySettingsPanel extends GuiPonySettings implements ConfigPanel {
|
||||
|
||||
private int contentHeight;
|
||||
|
||||
@Override
|
||||
public String getPanelTitle() {
|
||||
return I18n.format(getTitle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContentHeight() {
|
||||
return contentHeight + 40;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T extends GuiButton> T addButton(T button) {
|
||||
if (button.y > contentHeight) {
|
||||
contentHeight = button.y;
|
||||
}
|
||||
return super.addButton(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPanelShown(ConfigPanelHost host) {
|
||||
mc = Minecraft.getMinecraft();
|
||||
width = host.getWidth();
|
||||
buttonList.clear();
|
||||
initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPanelResize(ConfigPanelHost host) {
|
||||
width = host.getWidth();
|
||||
buttonList.clear();
|
||||
initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPanelHidden() {
|
||||
onGuiClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(ConfigPanelHost host) {
|
||||
updateScreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPanel(ConfigPanelHost host, int mouseX, int mouseY, float partialTicks) {
|
||||
drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton) {
|
||||
try {
|
||||
mouseClicked(mouseX, mouseY, mouseButton);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton) {
|
||||
mouseReleased(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(ConfigPanelHost host, int mouseX, int mouseY) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(ConfigPanelHost host, char keyChar, int keyCode) {
|
||||
try {
|
||||
keyTyped(keyChar, keyCode);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawWorldBackground(int tint) {
|
||||
|
||||
}
|
||||
|
||||
protected boolean mustScroll() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -3,11 +3,13 @@ package com.minelittlepony.gui;
|
|||
import net.minecraft.client.gui.GuiSlider;
|
||||
import net.minecraft.client.gui.GuiPageButtonList.GuiResponder;
|
||||
|
||||
import java.util.function.DoubleUnaryOperator;
|
||||
|
||||
public class Slider extends GuiSlider {
|
||||
|
||||
private static Responder callback;
|
||||
|
||||
public Slider(int x, int y, float minIn, float maxIn, float defaultValue, GuiSlider.FormatHelper formatter, IGUIAction<Float> action) {
|
||||
public Slider(int x, int y, float minIn, float maxIn, float defaultValue, GuiSlider.FormatHelper formatter, DoubleUnaryOperator action) {
|
||||
super(callback = new Responder(action), 0, x, y, "", minIn, maxIn, defaultValue, formatter);
|
||||
callback.owner = this;
|
||||
callback = null;
|
||||
|
@ -15,11 +17,11 @@ public class Slider extends GuiSlider {
|
|||
|
||||
private static final class Responder implements GuiResponder {
|
||||
|
||||
private final IGUIAction<Float> action;
|
||||
private final DoubleUnaryOperator action;
|
||||
|
||||
private Slider owner;
|
||||
|
||||
private Responder(IGUIAction<Float> callback) {
|
||||
private Responder(DoubleUnaryOperator callback) {
|
||||
action = callback;
|
||||
}
|
||||
|
||||
|
@ -28,7 +30,7 @@ public class Slider extends GuiSlider {
|
|||
|
||||
@Override
|
||||
public void setEntryValue(int id, float value) {
|
||||
owner.setSliderValue(action.perform(value), false);
|
||||
owner.setSliderValue((float) action.applyAsDouble(value), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package com.minelittlepony.model.components;
|
||||
|
||||
import com.minelittlepony.pony.data.PonyGender;
|
||||
import com.minelittlepony.render.plane.PlaneRenderer;
|
||||
|
||||
import static com.minelittlepony.model.PonyModelConstants.*;
|
||||
|
||||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.model.AbstractPonyModel;
|
||||
import com.minelittlepony.pony.data.PonyGender;
|
||||
import com.minelittlepony.render.plane.PlaneRenderer;
|
||||
|
||||
public class PonySnout {
|
||||
|
||||
|
@ -51,7 +50,7 @@ public class PonySnout {
|
|||
}
|
||||
|
||||
public void setGender(PonyGender gender) {
|
||||
boolean show = !isHidden && MineLittlePony.getConfig().snuzzles;
|
||||
boolean show = !isHidden && MineLittlePony.getConfigLoader().getConfig().snuzzles;
|
||||
|
||||
mare.isHidden = !show || gender == PonyGender.STALLION;
|
||||
stallion.isHidden = !show || gender == PonyGender.MARE;
|
||||
|
|
|
@ -117,7 +117,7 @@ public class Pony {
|
|||
}
|
||||
|
||||
public PonyRace getRace(boolean ignorePony) {
|
||||
return metadata.getRace().getEffectiveRace(MineLittlePony.getConfig().getEffectivePonyLevel(ignorePony));
|
||||
return metadata.getRace().getEffectiveRace(MineLittlePony.getConfigLoader().getConfig().getEffectivePonyLevel(ignorePony));
|
||||
}
|
||||
|
||||
public ResourceLocation getTexture() {
|
||||
|
|
|
@ -58,7 +58,7 @@ public class PonyData implements IPonyData {
|
|||
|
||||
@Override
|
||||
public PonySize getSize() {
|
||||
return MineLittlePony.getConfig().sizes ? size : PonySize.NORMAL;
|
||||
return MineLittlePony.getConfigLoader().getConfig().sizes ? size : PonySize.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,11 +5,11 @@ public enum PonyLevel {
|
|||
HUMANS,
|
||||
BOTH;
|
||||
|
||||
public static PonyLevel valueFor(float index) {
|
||||
public static PonyLevel valueFor(int index) {
|
||||
PonyLevel[] values = values();
|
||||
if (index < 0) {
|
||||
index = 0;
|
||||
}
|
||||
return values[(int)Math.round(index) % values.length];
|
||||
return values[Math.round(index) % values.length];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,14 +20,14 @@ public enum PonySize implements ITriggerPixelMapped<PonySize> {
|
|||
}
|
||||
|
||||
public float getShadowSize() {
|
||||
if (MineLittlePony.getConfig().showscale) {
|
||||
if (MineLittlePony.getConfigLoader().getConfig().showscale) {
|
||||
return shadowSize * 0.9F;
|
||||
}
|
||||
return shadowSize;
|
||||
}
|
||||
|
||||
public float getScaleFactor() {
|
||||
if (MineLittlePony.getConfig().showscale) {
|
||||
if (MineLittlePony.getConfigLoader().getConfig().showscale) {
|
||||
return scale * 0.9F;
|
||||
}
|
||||
return scale;
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
package com.minelittlepony.render;
|
||||
|
||||
import org.lwjgl.opengl.GL14;
|
||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||
|
||||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.ducks.IRenderItem;
|
||||
import com.minelittlepony.pony.data.Pony;
|
||||
import com.minelittlepony.util.coordinates.Color;
|
||||
import com.mumfrey.liteloader.client.overlays.IMinecraft;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
|
@ -17,7 +15,7 @@ import net.minecraft.entity.EntityLivingBase;
|
|||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHandSide;
|
||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||
import org.lwjgl.opengl.GL14;
|
||||
|
||||
public class LevitatingItemRenderer {
|
||||
|
||||
|
@ -112,7 +110,7 @@ public class LevitatingItemRenderer {
|
|||
boolean doBow = doNormal && stack.getItemUseAction() == EnumAction.BOW;
|
||||
|
||||
if (doNormal) { // eating, blocking, and drinking are not transformed. Only held items.
|
||||
float ticks = ((IMinecraft)Minecraft.getMinecraft()).getTimer().elapsedPartialTicks - entity.ticksExisted;
|
||||
float ticks = Minecraft.getMinecraft().getTickLength() - entity.ticksExisted;
|
||||
|
||||
float floatAmount = (float)Math.sin(ticks / 9) / 40;
|
||||
float driftAmount = (float)Math.cos(ticks / 10) / 40;
|
||||
|
|
|
@ -83,7 +83,7 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
|
|||
public float getShadowScale() {
|
||||
if (mainModel.isChild) {
|
||||
return 0.25F;
|
||||
} else if (MineLittlePony.getConfig().showscale) {
|
||||
} else if (MineLittlePony.getConfigLoader().getConfig().showscale) {
|
||||
return 0.4F;
|
||||
}
|
||||
return 0.5F;
|
||||
|
@ -91,7 +91,7 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
|
|||
|
||||
@Override
|
||||
public float getScaleFactor() {
|
||||
if (MineLittlePony.getConfig().showscale) return 0.9F;
|
||||
if (MineLittlePony.getConfigLoader().getConfig().showscale) return 0.9F;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package com.minelittlepony.render.layer;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.minelittlepony.ForgeProxy;
|
||||
import com.minelittlepony.ducks.IRenderPony;
|
||||
import com.minelittlepony.model.ModelWrapper;
|
||||
import com.minelittlepony.model.armour.ModelPonyArmor;
|
||||
import com.minelittlepony.util.coordinates.Color;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
@ -21,11 +19,11 @@ import net.minecraft.item.ItemArmor.ArmorMaterial;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Tuple;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class LayerPonyArmor<T extends EntityLivingBase> extends AbstractPonyLayer<T> {
|
||||
|
||||
|
@ -157,11 +155,11 @@ public class LayerPonyArmor<T extends EntityLivingBase> extends AbstractPonyLaye
|
|||
}
|
||||
|
||||
private static String getArmorTexture(EntityLivingBase entity, ItemStack item, String def, EntityEquipmentSlot slot, @Nullable String type) {
|
||||
return ForgeProxy.getArmorTexture(entity, item, def, slot, type);
|
||||
return ForgeHooksClient.getArmorTexture(entity, item, def, slot, type);
|
||||
}
|
||||
|
||||
private static ModelPonyArmor getArmorModel(EntityLivingBase entity, ItemStack itemstack, EntityEquipmentSlot slot, ModelPonyArmor def) {
|
||||
ModelBase model = ForgeProxy.getArmorModel(entity, itemstack, slot, def);
|
||||
ModelBase model = ForgeHooksClient.getArmorModel(entity, itemstack, slot, def);
|
||||
if (model instanceof ModelPonyArmor) {
|
||||
return (ModelPonyArmor) model;
|
||||
}
|
||||
|
|
|
@ -2,75 +2,92 @@ package com.minelittlepony.render.ponies;
|
|||
|
||||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.PonyRenderManager;
|
||||
import com.minelittlepony.settings.SensibleConfig.Setting;
|
||||
|
||||
import com.minelittlepony.settings.PonyConfig;
|
||||
import com.minelittlepony.settings.Setting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.monster.*;
|
||||
import net.minecraft.entity.passive.*;
|
||||
import net.minecraft.entity.monster.EntityElderGuardian;
|
||||
import net.minecraft.entity.monster.EntityEvoker;
|
||||
import net.minecraft.entity.monster.EntityGiantZombie;
|
||||
import net.minecraft.entity.monster.EntityGuardian;
|
||||
import net.minecraft.entity.monster.EntityHusk;
|
||||
import net.minecraft.entity.monster.EntityIllusionIllager;
|
||||
import net.minecraft.entity.monster.EntityPigZombie;
|
||||
import net.minecraft.entity.monster.EntitySkeleton;
|
||||
import net.minecraft.entity.monster.EntityStray;
|
||||
import net.minecraft.entity.monster.EntityVex;
|
||||
import net.minecraft.entity.monster.EntityVindicator;
|
||||
import net.minecraft.entity.monster.EntityWitch;
|
||||
import net.minecraft.entity.monster.EntityWitherSkeleton;
|
||||
import net.minecraft.entity.monster.EntityZombie;
|
||||
import net.minecraft.entity.monster.EntityZombieVillager;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
|
||||
/**
|
||||
* Central location where new entity renderers are registered and applied.
|
||||
*
|
||||
* Due to the limitations in Mumfrey's framework, needs to be paired with a field in PonyConfig.
|
||||
*/
|
||||
public enum MobRenderers implements Setting {
|
||||
public enum MobRenderers implements Setting<PonyConfig> {
|
||||
VILLAGERS {
|
||||
@Override
|
||||
public void register(boolean state, PonyRenderManager pony, RenderManager manager) {
|
||||
pony.switchRenderer(state, manager, EntityVillager.class, new RenderPonyVillager(manager));
|
||||
pony.switchRenderer(state, manager, EntityWitch.class, new RenderPonyWitch(manager));
|
||||
pony.switchRenderer(state, manager, EntityZombieVillager.class, new RenderPonyZombieVillager(manager));
|
||||
public void register(boolean state, PonyRenderManager pony) {
|
||||
pony.switchRenderer(state, EntityVillager.class, RenderPonyVillager::new);
|
||||
pony.switchRenderer(state, EntityWitch.class, RenderPonyWitch::new);
|
||||
pony.switchRenderer(state, EntityZombieVillager.class, RenderPonyZombieVillager::new);
|
||||
}
|
||||
},
|
||||
ZOMBIES {
|
||||
@Override
|
||||
public void register(boolean state, PonyRenderManager pony, RenderManager manager) {
|
||||
pony.switchRenderer(state, manager, EntityZombie.class, new RenderPonyZombie<>(manager));
|
||||
pony.switchRenderer(state, manager, EntityHusk.class, new RenderPonyZombie.Husk(manager));
|
||||
pony.switchRenderer(state, manager, EntityGiantZombie.class, new RenderPonyZombie.Giant(manager));
|
||||
public void register(boolean state, PonyRenderManager pony) {
|
||||
pony.switchRenderer(state, EntityZombie.class, RenderPonyZombie::new);
|
||||
pony.switchRenderer(state, EntityHusk.class, RenderPonyZombie.Husk::new);
|
||||
pony.switchRenderer(state, EntityGiantZombie.class, RenderPonyZombie.Giant::new);
|
||||
}
|
||||
},
|
||||
PIGZOMBIES {
|
||||
@Override
|
||||
public void register(boolean state, PonyRenderManager pony, RenderManager manager) {
|
||||
pony.switchRenderer(state, manager, EntityPigZombie.class, new RenderPonyPigman(manager));
|
||||
public void register(boolean state, PonyRenderManager pony) {
|
||||
pony.switchRenderer(state, EntityPigZombie.class, RenderPonyPigman::new);
|
||||
}
|
||||
},
|
||||
SKELETONS {
|
||||
@Override
|
||||
public void register(boolean state, PonyRenderManager pony, RenderManager manager) {
|
||||
pony.switchRenderer(state, manager, EntitySkeleton.class, new RenderPonySkeleton<>(manager));
|
||||
pony.switchRenderer(state, manager, EntityStray.class, new RenderPonySkeleton.Stray(manager));
|
||||
pony.switchRenderer(state, manager, EntityWitherSkeleton.class, new RenderPonySkeleton.Wither(manager));
|
||||
public void register(boolean state, PonyRenderManager pony) {
|
||||
pony.switchRenderer(state, EntitySkeleton.class, RenderPonySkeleton::new);
|
||||
pony.switchRenderer(state, EntityStray.class, RenderPonySkeleton.Stray::new);
|
||||
pony.switchRenderer(state, EntityWitherSkeleton.class, RenderPonySkeleton.Wither::new);
|
||||
}
|
||||
},
|
||||
ILLAGERS {
|
||||
@Override
|
||||
public void register(boolean state, PonyRenderManager pony, RenderManager manager) {
|
||||
pony.switchRenderer(state, manager, EntityVex.class, new RenderPonyVex(manager));
|
||||
pony.switchRenderer(state, manager, EntityEvoker.class, new RenderPonyIllager.Evoker(manager));
|
||||
pony.switchRenderer(state, manager, EntityVindicator.class, new RenderPonyIllager.Vindicator(manager));
|
||||
pony.switchRenderer(state, manager, EntityIllusionIllager.class, new RenderPonyIllager.Illusionist(manager));
|
||||
public void register(boolean state, PonyRenderManager pony) {
|
||||
pony.switchRenderer(state, EntityVex.class, RenderPonyVex::new);
|
||||
pony.switchRenderer(state, EntityEvoker.class, RenderPonyIllager.Evoker::new);
|
||||
pony.switchRenderer(state, EntityVindicator.class, RenderPonyIllager.Vindicator::new);
|
||||
pony.switchRenderer(state, EntityIllusionIllager.class, RenderPonyIllager.Illusionist::new);
|
||||
}
|
||||
},
|
||||
GUARDIANS {
|
||||
@Override
|
||||
public void register(boolean state, PonyRenderManager pony, RenderManager manager) {
|
||||
pony.switchRenderer(state, manager, EntityGuardian.class, new RenderPonyGuardian(manager));
|
||||
pony.switchRenderer(state, manager, EntityElderGuardian.class, new RenderPonyGuardian.Elder(manager));
|
||||
public void register(boolean state, PonyRenderManager pony) {
|
||||
pony.switchRenderer(state, EntityGuardian.class, RenderPonyGuardian::new);
|
||||
pony.switchRenderer(state, EntityElderGuardian.class, RenderPonyGuardian.Elder::new);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void set(boolean value) {
|
||||
Setting.super.set(value);
|
||||
apply(MineLittlePony.getInstance().getRenderManager(), Minecraft.getMinecraft().getRenderManager());
|
||||
public void set(PonyConfig config, boolean value) {
|
||||
Setting.super.set(config, value);
|
||||
apply(value, MineLittlePony.getInstance().getRenderManager(), Minecraft.getMinecraft().getRenderManager());
|
||||
}
|
||||
|
||||
public void apply(PonyRenderManager pony, RenderManager manager) {
|
||||
boolean state = get();
|
||||
register(state, pony, manager);
|
||||
public void apply(boolean state, PonyRenderManager pony, RenderManager manager) {
|
||||
register(state, pony);
|
||||
|
||||
RenderingRegistry.loadEntityRenderers(manager, manager.entityRenderMap);
|
||||
|
||||
if (state) {
|
||||
MineLittlePony.logger.info(name() + " are now ponies.");
|
||||
} else {
|
||||
|
@ -78,5 +95,5 @@ public enum MobRenderers implements Setting {
|
|||
}
|
||||
}
|
||||
|
||||
public abstract void register(boolean state, PonyRenderManager pony, RenderManager manager);
|
||||
public abstract void register(boolean state, PonyRenderManager pony);
|
||||
}
|
113
src/main/java/com/minelittlepony/settings/PonyConfig.java
Normal file
113
src/main/java/com/minelittlepony/settings/PonyConfig.java
Normal file
|
@ -0,0 +1,113 @@
|
|||
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 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.
|
||||
*/
|
||||
public class PonyConfig {
|
||||
|
||||
private PonyLevel ponylevel = PonyLevel.PONIES;
|
||||
|
||||
public boolean sizes = true;
|
||||
public boolean snuzzles = true;
|
||||
public boolean hd = true;
|
||||
public 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> {
|
||||
SIZES,
|
||||
SNUZZLES,
|
||||
HD,
|
||||
SHOWSCALE
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually gets the pony level value. No option to ignore reality here.
|
||||
*/
|
||||
public PonyLevel getPonyLevel() {
|
||||
if (ponylevel == null) {
|
||||
ponylevel = PonyLevel.PONIES;
|
||||
}
|
||||
return ponylevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the pony level. Want MOAR PONEHS? Well here you go.
|
||||
*
|
||||
* @param ponylevel
|
||||
*/
|
||||
public void setPonyLevel(PonyLevel ponylevel) {
|
||||
this.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
package com.minelittlepony.settings;
|
||||
|
||||
import com.minelittlepony.gui.IGUIAction;
|
||||
|
||||
/**
|
||||
* A sensible config container that actually lets us programatically index values by a key.
|
||||
*
|
||||
* Reflection because Mumfrey pls.
|
||||
*
|
||||
*/
|
||||
// Mumfrey pls.
|
||||
public abstract class SensibleConfig {
|
||||
|
||||
private static SensibleConfig instance;
|
||||
|
||||
public SensibleConfig() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public interface Setting extends IGUIAction<Boolean> {
|
||||
String name();
|
||||
|
||||
/**
|
||||
* Gets the config value associated with this entry.
|
||||
*/
|
||||
default boolean get() {
|
||||
return instance.getValue(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the config value associated with this entry.
|
||||
*/
|
||||
default void set(boolean value) {
|
||||
instance.setValue(this, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
default Boolean perform(Boolean v) {
|
||||
set(v);
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getValue(Setting key) {
|
||||
try {
|
||||
return this.getClass().getField(key.name().toLowerCase()).getBoolean(this);
|
||||
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException ignored) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setValue(Setting key, boolean value) {
|
||||
try {
|
||||
this.getClass().getField(key.name().toLowerCase()).setBoolean(this, value);
|
||||
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException ignored) {
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
35
src/main/java/com/minelittlepony/settings/Setting.java
Normal file
35
src/main/java/com/minelittlepony/settings/Setting.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
package com.minelittlepony.settings;
|
||||
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public interface Setting<Config> {
|
||||
|
||||
String name();
|
||||
|
||||
default boolean get(Config config) {
|
||||
try {
|
||||
Field field = getField(config.getClass());
|
||||
return field.getBoolean(config);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
default void set(Config config, boolean value) {
|
||||
try {
|
||||
Field field = getField(config.getClass());
|
||||
field.setBoolean(config, value);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
default Field getField(Class<?> owner) {
|
||||
try {
|
||||
return owner.getField(name().toLowerCase());
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue