From b3c21cd47db2bb24fa258aa94618b70c56da753a Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 27 Mar 2019 09:24:23 +0200 Subject: [PATCH] Remove some leftover HDSkins code --- .../minelittlepony/hdskins/fml/Config.java | 73 ---------------- .../hdskins/fml/ForgeModHDSkins.java | 31 ------- .../hdskins/litemod/LiteModHDSkins.java | 85 ------------------- .../hdskins/litemod/package-info.java | 7 -- 4 files changed, 196 deletions(-) delete mode 100644 src/hdskinsfml/java/com/minelittlepony/hdskins/fml/Config.java delete mode 100644 src/hdskinsfml/java/com/minelittlepony/hdskins/fml/ForgeModHDSkins.java delete mode 100644 src/hdskinslitemod/java/com/minelittlepony/hdskins/litemod/LiteModHDSkins.java delete mode 100644 src/hdskinslitemod/java/com/minelittlepony/hdskins/litemod/package-info.java diff --git a/src/hdskinsfml/java/com/minelittlepony/hdskins/fml/Config.java b/src/hdskinsfml/java/com/minelittlepony/hdskins/fml/Config.java deleted file mode 100644 index fd6d8ad8..00000000 --- a/src/hdskinsfml/java/com/minelittlepony/hdskins/fml/Config.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.minelittlepony.hdskins.fml; - -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.entity.Entity; -import net.minecraftforge.fml.client.registry.RenderingRegistry; -import net.minecraftforge.fml.loading.FMLPaths; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.stream.JsonWriter; -import com.minelittlepony.hdskins.HDSkins; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.function.Function; - -public class Config extends HDSkins { - static final Gson gson = new GsonBuilder() - .setPrettyPrinting() - .excludeFieldsWithoutExposeAnnotation() - .create(); - - private final Path configFile; - - Config(Path file) { - configFile = file; - } - - @Override - public File getAssetsDirectory() { - return FMLPaths.CONFIGDIR.get().getParent().toAbsolutePath().toFile(); - } - - @Override - public void saveConfig() { - try (JsonWriter writer = new JsonWriter(Files.newBufferedWriter(configFile))) { - writer.setIndent(" "); - - gson.toJson(this, Config.class, writer); - } catch (IOException e) { - e.printStackTrace(); - } - } - - @Override - protected void addRenderer(Class type, Function> renderer) { - RenderingRegistry.registerEntityRenderingHandler(type, rm -> renderer.apply(rm)); - } - - static Config of(Path file) { - Config result = null; - - if (Files.exists(file)) { - try (BufferedReader s = Files.newBufferedReader(file)) { - result = gson.fromJson(s, Config.class); - } catch (IOException ignored) { - result = null; - } - } - - if (result == null) { - result = new Config(file); - } - - result.saveConfig(); - - return result; - } -} diff --git a/src/hdskinsfml/java/com/minelittlepony/hdskins/fml/ForgeModHDSkins.java b/src/hdskinsfml/java/com/minelittlepony/hdskins/fml/ForgeModHDSkins.java deleted file mode 100644 index 3c6b4c72..00000000 --- a/src/hdskinsfml/java/com/minelittlepony/hdskins/fml/ForgeModHDSkins.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.minelittlepony.hdskins.fml; - -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.fml.loading.FMLPaths; - -@Mod("hdskins") -public class ForgeModHDSkins { - - private Config hdskins; - - public ForgeModHDSkins() { - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::commonInit); - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientInit); - MinecraftForge.EVENT_BUS.register(this); - } - - private void commonInit(final FMLCommonSetupEvent event) { - - hdskins = Config.of(FMLPaths.CONFIGDIR.get().resolve("hdskins.json")); - - hdskins.init(); - } - - private void clientInit(FMLClientSetupEvent event) { - hdskins.initComplete(); - } -} diff --git a/src/hdskinslitemod/java/com/minelittlepony/hdskins/litemod/LiteModHDSkins.java b/src/hdskinslitemod/java/com/minelittlepony/hdskins/litemod/LiteModHDSkins.java deleted file mode 100644 index 38664b73..00000000 --- a/src/hdskinslitemod/java/com/minelittlepony/hdskins/litemod/LiteModHDSkins.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.minelittlepony.hdskins.litemod; - -import com.google.gson.GsonBuilder; -import com.minelittlepony.common.client.gui.GuiLiteHost; -import com.minelittlepony.hdskins.HDSkinManager; -import com.minelittlepony.hdskins.HDSkins; -import com.minelittlepony.hdskins.gui.HDSkinsConfigPanel; -import com.minelittlepony.hdskins.server.SkinServer; -import com.minelittlepony.hdskins.server.SkinServerSerializer; -import com.mumfrey.liteloader.Configurable; -import com.mumfrey.liteloader.InitCompleteListener; -import com.mumfrey.liteloader.ViewportListener; -import com.mumfrey.liteloader.core.LiteLoader; -import com.mumfrey.liteloader.modconfig.AdvancedExposable; -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 net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.entity.Entity; - -import java.io.File; -import java.util.function.Function; - -@ExposableOptions(strategy = ConfigStrategy.Unversioned, filename = "hdskins") -public class LiteModHDSkins extends HDSkins implements InitCompleteListener, AdvancedExposable { - - @Override - public String getName() { - return HDSkins.MOD_NAME; - } - - @Override - public String getVersion() { - return HDSkins.VERSION; - } - - @Override - public void saveConfig() { - LiteLoader.getInstance().writeConfig(this); - } - - @Override - public void init(File configPath) { - - // register config - LiteLoader.getInstance().registerExposable(this, null); - super.init(); - } - - @Override - public void upgradeSettings(String version, File configPath, File oldConfigPath) { - HDSkinManager.INSTANCE.clearSkinCache(); - } - - @Override - public void setupGsonSerialiser(GsonBuilder gsonBuilder) { - gsonBuilder.registerTypeAdapter(SkinServer.class, new SkinServerSerializer()); - } - - @Override - public File getConfigFile(File configFile, File configFileLocation, String defaultFileName) { - return null; - } - - @Override - public void onInitCompleted(Minecraft minecraft, LiteLoader loader) { - initComplete(); - } - - @Override - protected void addRenderer(Class type, Function> renderer) { - ModUtilities.addRenderer(type, renderer.apply(Minecraft.getInstance().getRenderManager())); - } - - @Override - public File getAssetsDirectory() { - return LiteLoader.getAssetsDirectory(); - } - -} diff --git a/src/hdskinslitemod/java/com/minelittlepony/hdskins/litemod/package-info.java b/src/hdskinslitemod/java/com/minelittlepony/hdskins/litemod/package-info.java deleted file mode 100644 index 167f1f93..00000000 --- a/src/hdskinslitemod/java/com/minelittlepony/hdskins/litemod/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@MethodsReturnNonnullByDefault -@ParametersAreNonnullByDefault -package com.minelittlepony.hdskins.litemod; - -import mcp.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault;