Skip to content
This repository has been archived by the owner on Nov 7, 2022. It is now read-only.

Commit

Permalink
Remove unused class, make installer place mod in the corresponding mi…
Browse files Browse the repository at this point in the history
…necraft mods directory. #4
  • Loading branch information
boomboompower committed Mar 25, 2020
1 parent c4e0c11 commit f2b81df
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 95 deletions.
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ buildscript {
apply plugin: "net.minecraftforge.gradle.forge"
apply plugin: 'org.spongepowered.mixin'

version = "2.0.0-SNAPSHOT"
group = "me.boomboompower.skinchanger"
version = '3.0.0'
group = "me.do_you_like.skinchanger"
archivesBaseName = "SkinChangerMod"

sourceCompatibility = 1.8
Expand All @@ -65,7 +65,7 @@ repositories {

maven {
name = 'sponge'
url = 'http://repo.spongepowered.org/maven'
url = 'https://repo.spongepowered.org/maven'
}

maven {
Expand All @@ -82,7 +82,6 @@ dependencies {
exclude module: 'gson'
exclude module: 'commons-io'
exclude module: 'log4j-core'

}

compile 'org.projectlombok:lombok:1.16.20'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import me.do_you_like.mods.skinchanger.utils.backend.CacheRetriever;

import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.ModMetadata;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
Expand Down Expand Up @@ -59,10 +58,6 @@ public void preInit(FMLPreInitializationEvent event) {

this.cacheRetriever = new CacheRetriever(this);
this.configurationHandler = new ConfigurationHandler(this);

for (int i = 0; i < 20; i++) {
System.out.println((i * 'X') + " PreInit!");
}
}

@Mod.EventHandler
Expand All @@ -76,10 +71,6 @@ public void postInit(FMLPostInitializationEvent event) {
this.configurationHandler.load();

this.mojangHooker = new MojangHooker();

for (int i = 0; i < 20; i++) {
System.out.println((i * 'Z') + " PostInit!");
}
}

public File getModConfigDirectory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public class InstallerCore {

private static final String MOD_NAME = "SkinChanger";

private static final String BUILT_FOR = "1.8.9"; // TODO Update this across versions.
private static final String MOD_VERSION = "3.0.0"; // TODO Update this on releases

public static void main(String[] args) {
if (!GraphicsEnvironment.isHeadless()) {
try {
Expand All @@ -42,7 +45,7 @@ public static void main(String[] args) {
OSType osType = OperatingSystem.getOSType();

if (osType == OSType.UNKNOWN) {
onInstallationFailed("Your operating system is not supported by the installer.");
onInstallationFailed("Your operating system is not supported by the installer.\nPlease place the mod file in your mods folder manually.");

return;
}
Expand All @@ -69,8 +72,10 @@ public static void main(String[] args) {
return;
}

File installLocation = new File(mcModDir, BUILT_FOR);

try {
Files.copy(currentPath.toPath(), new File(mcModDir, MOD_NAME + ".jar").toPath(), StandardCopyOption.REPLACE_EXISTING);
Files.copy(currentPath.toPath(), new File(installLocation, MOD_NAME + " v" + MOD_VERSION + ".jar").toPath(), StandardCopyOption.REPLACE_EXISTING);
} catch (IOException ex) {
onInstallationFailed("The mod was unable to be written to the installation directory.");

Expand All @@ -92,7 +97,7 @@ public static void main(String[] args) {
// Had no permission to delete the file.
}

JOptionPane.showMessageDialog(null, MOD_NAME + " has been installed at: \n " + mcModDir.getAbsolutePath() + "\n\nFrom: \n" + currentPath.getAbsolutePath(), "Installation Successful", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, MOD_NAME + " (v" + MOD_VERSION + ") has been installed at: \n " + installLocation.getAbsolutePath() + "\n\nFrom: \n" + currentPath.getAbsolutePath() + "\n\nYou may delete this file now!", "Installation Successful", JOptionPane.INFORMATION_MESSAGE);
}
}

Expand All @@ -115,5 +120,4 @@ private static void onInstallationFailed(String additional) {

JOptionPane.showMessageDialog(null, message, "Installation Failed", JOptionPane.ERROR_MESSAGE);
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
* Copyright (C) 2020 boomboompower
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package me.do_you_like.mods.skinchanger.utils.gui.impl;

import com.google.common.collect.Lists;

import java.awt.Color;
import java.util.List;

import lombok.Getter;

import me.do_you_like.mods.skinchanger.utils.gui.InteractiveDrawable;
import me.do_you_like.mods.skinchanger.utils.gui.ModernDrawable;
import me.do_you_like.mods.skinchanger.utils.gui.ModernGui;

/**
* Similar to a {@link ModernHeader}
*/
public class ModernScroller implements InteractiveDrawable {

@Getter
private int x;

@Getter
private int y;

@Getter
private int width;

@Getter
private int height;

// Each node will be rendered with a height of 20px
private List<ScrollableNode> nodes = Lists.newArrayList();


public ModernScroller(int x, int y, int width) {
this.x = x;
this.y = y;

this.width = width;

// Default height.
this.height = 10;
}

@Override
public void render(int mouseX, int mouseY, float yTranslation) {
Color transparentBlue = new Color(255, 255, 255, 120);

ModernGui.drawRectangleOutlineF(this.x, this.y, this.x + this.width, this.y + this.height, transparentBlue.getRGB());

for (int i = 0; i < this.nodes.size(); i++) {
ScrollableNode node = this.nodes.get(i);

int top = this.y;

// Padding
top += 2;

// Position
top += (i * 20);

ModernGui.drawRect(this.x + 2, top, this.x + this.width - 2, top + 30, transparentBlue.getRGB());
}
}

@Override
public boolean isInside(int mouseX, int mouseY, float yTranslation) {
return false;
}

@Override
public void onLeftClick(int mouseX, int mouseY, float yTranslation) {

}

@Override
public boolean isEnabled() {
return true;
}

@Override
public ModernDrawable setAsPartOfHeader(ModernHeader parent) {
throw new UnsupportedOperationException("ModernScrollbar's cannot be added to a header.");
}

public void insertNode(ScrollableNode node) {
if (node == null) {
System.err.println("A null node was registered. Ignoring.");
return;
} else if (this.nodes.contains(node)) {
// Don't want duplicates.
return;
}

this.height += 30;

this.nodes.add(node);
}

public class ScrollableNode {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

import java.util.HashMap;

import me.do_you_like.mods.skinchanger.utils.backend.ReflectionUtils;
import me.do_you_like.mods.skinchanger.utils.backend.ThreadFactory;
import me.do_you_like.mods.skinchanger.utils.general.ReflectUtils;
import me.do_you_like.mods.skinchanger.utils.resources.CapeBuffer;
import me.do_you_like.mods.skinchanger.utils.resources.LocalFileData;
import me.do_you_like.mods.skinchanger.utils.resources.SkinBuffer;
Expand Down Expand Up @@ -88,7 +88,7 @@ public void setSkin(AbstractClientPlayer player, ResourceLocation newLocation, O
return;
}

ReflectUtils.setPrivateValue(NetworkPlayerInfo.class, playerInfo, newLocation, "locationSkin", "field_178865_e");
ReflectionUtils.setPrivateValue(NetworkPlayerInfo.class, playerInfo, newLocation, "locationSkin", "field_178865_e");

if (response != null) {
response.run(null);
Expand All @@ -103,7 +103,7 @@ public void setCape(AbstractClientPlayer player, ResourceLocation newLocation, O
return;
}

ReflectUtils.setPrivateValue(NetworkPlayerInfo.class, playerInfo, newLocation, "locationCape", "field_178862_f");
ReflectionUtils.setPrivateValue(NetworkPlayerInfo.class, playerInfo, newLocation, "locationCape", "field_178862_f");

if (response != null) {
response.run(null);
Expand All @@ -116,8 +116,7 @@ private NetworkPlayerInfo getPlayerInfo(AbstractClientPlayer player, OptionRespo
}

try {
NetworkPlayerInfo playerInfo = (NetworkPlayerInfo) ReflectUtils.findMethod(
AbstractClientPlayer.class, new String[] {"getPlayerInfo", "func_175155_b"}).invoke(player);
NetworkPlayerInfo playerInfo = (NetworkPlayerInfo) ReflectionUtils.findMethod(AbstractClientPlayer.class, new String[] {"getPlayerInfo", "func_175155_b"}).invoke(player);

this.cachedPlayerInfo.put(player, playerInfo);

Expand Down

0 comments on commit f2b81df

Please sign in to comment.