chore: codebase cleanup & rebrand

This commit is contained in:
Timo Ley 2023-01-22 14:21:28 +01:00
parent a36693537c
commit c34d2b0544
16 changed files with 55 additions and 1220 deletions

View file

@ -4,18 +4,3 @@ Licenses are not really my friend -- strict closed source software really drives
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright © 2016 Aidan Brady
## Note that modifications made by Thorfusion, Terralization, maggi373 and others contributing to this fork goes under:
# Mekanism 1.7.10 Community Edition License
## “Commons Clause” License Condition v1.0
The Software is provided to you by the Licensor under the License, as defined below, subject to the following condition.
Without limiting other conditions in the License, the grant of rights under the License will not include, and the License does not grant to you, right to Sell the Software.
For purposes of the foregoing, “Sell” means practicing any or all of the rights granted to you under the License to provide to third parties, for a fee or other consideration (including without limitation fees for hosting or consulting/ support services related to the Software), a product or service whose value derives, entirely or substantially, from the functionality of the Software. Any license notice or attribution required by the License must also include this Commons Cause License Condition notice.
### Software: [Mekanism 1.7.10 Community Edition]
### License: [EUPL-1.2]
### Artwork, logos and other stuff that the license [EUPL-1.2] does not cover is under [CC BY-NC-SA 4.0]
### Licensor: [Thorfusion]

View file

@ -1,83 +1,14 @@
# Mekanism 1.7.10 Community Edition
Originally made for Terralization Modpack with fixes from several different mods. Now with new features, bugfixes and performance enhancement.
# Mekanism tilera Edition
#### Download at [curseforge](https://www.curseforge.com/minecraft/mc-mods/mekanism-ce)
#### Builds at our [maven](https://maven.thorfusion.com/ui/repos/tree/General/thorfusion/mekanism/Mekanism-1.7.10-Community-Edition)
### Building Mekanism 1.7.10 Community Edition
### Building Mekanism tilera Edition
```bash
./gradlew fullBuild
```
You will find the files inside ./output/
## For modpacks
You need to include the [LICENSE](https://raw.githubusercontent.com/Thorfusion/Mekanism-1.7.10-Community-Edition/1.7.10/LICENSE.md) for Mekanism 1.7.10 Community Edition and Aidanbrady as author, if your system supports it indicate that this is an custom version and give appreciable credits
## Required Dependencies:
Mekanism CE has continued the use of the update notifier but changed the config name to v2. This is to notify people making the switch to CE of this feature. It is recommended for modpacks to disable this.
## Required Dependencies
Mekanism CE also has two dependencies that it requires, as a modpack creator DO NOT USE the automatic downloader to get those file. It puts alot of strain to my server network.
### Dependency list
+ [ForgeMultipart](https://files.thorfusion.com/mekanism/ForgeMultipart-1.7.10-1.2.0.347-universal.jar)
+ [CodeChickenLib](https://files.thorfusion.com/mekanism/CodeChickenLib-1.7.10-1.1.3.141-universal.jar)
## Modifications by
#### Clienthax :
+ dupe bug with chemical washer and fluidtank, fixes issue with railcraft
#### draksterau :
+ personal chest bug and a server crash bug
#### iKEVAREZ :
+ and the turbine bug involving each fluid being sucked in.
#### kmecpp :
+ dupe bug with factories
#### awesomely2002 :
+ improvment for Entangloporters need to transport more
#### q1051278389 :
+ Turbine and matrix bug
+ fix industrialTrubine can input Water or some liquid with another mod's pipe(now only accept water)
+ fix EnergyMatrix use IC2 cable(EnergyNetBug) connecting valve as a loop to fully charge the Matrix(now IC2Cable can't connect the MatrixValve which in "Input Mode")
#### [maggi373](https://github.com/maggi373) - Mekanism CE Team
+ fix for bin dupe bug, removed the ability to stack bins, quick solution but it works
+ added api.jar, mdk is now depricated
+ oredict switcher for osmium: you can chose either or both of osmium/platinum
+ fixed minetweaker not working problerly with mekanism
+ fixed osmium compressor taking incorrect amount of osmium Thorfusion#32
+ making enriched alloy now uses steel ingots instead of iron ingots
+ updated libraries and removed unused metallurgy compat
+ voiceserver is now disabled by default
+ oredict recipes for poor ores from railcraft (1x ingot from using purification chamber) Thorfusion#30
+ oredict recipe for dustQuartz to be enriched(mekanism) to quartz Thorfusion#30
+ oredict recipe for dustQuartz to be enriched(mekanism) from quartz ore Thorfusion#30
+ oredict recipe for gemDiamond to be enriched(mekanism) to compresseddiamonds Thorfusion#30
+ cleaned and upgraded gradle building
+ added autodownload for dependencies and missing dependency warning
#### [Pokemonplatin](https://github.com/Pokemonplatin) - Mekanism CE Team
+ Teleporter and Quantum Entangloporter now have a trusted channel for smp Thorfusion#22
#### [DrParadox7](https://github.com/DrParadox7) - Mekanism CE Team
+ fixed missing lang for teleporter Thorfusion#36
+ cardboxes are now single use Thorfusion#36
+ added methane gas Thorfusion#36
+ nerfed fusion reactor Thorfusion#36
+ added config for reducing particles for completed multiblocks Thorfusion#36
+ sawmill now outputs raw rubber instead of rubber Thorfusion#36
+ added methane to gas burner fuel list Thorfusion#36
## All contributors get capes
# License
[LICENSE](https://raw.githubusercontent.com/Thorfusion/Mekanism-1.7.10-Community-Edition/1.7.10/LICENSE.md)
[ORIGINAL MOD](https://github.com/mekanism/Mekanism)
- ForgeMultipart
- CodeChickenLib
- [Universal Electricity](https://git.tilera.org/Anvilcraft/universal-electricity)

View file

@ -1,29 +1,25 @@
buildscript {
repositories {
mavenCentral()
maven {
name = "central"
url = "https://maven.thorfusion.com/artifactory/central/"
}
mavenCentral()
maven {
name = "forge"
url = "https://maven.minecraftforge.net/"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath ('com.anatawa12.forge:ForgeGradle:1.2-1.0.+') {
changing = true
}
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:latest.release"
}
}
plugins {
id 'java-library'
}
apply plugin: 'forge'
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: "com.jfrog.artifactory"
apply plugin: "maven-publish"
apply plugin: "maven"
defaultTasks 'fullBuild'
@ -80,7 +76,6 @@ minecraft {
replaceIn "mekanism/generators/common/MekanismGenerators.java"
replaceIn "mekanism/tools/common/MekanismTools.java"
replace "GRADLE_MODVERSION", config.mod_version
replace "GRADLE_VERSIONMOD", config.alt_version
}
processResources
@ -156,18 +151,16 @@ task deobfJar(type: Jar) {
classifier = 'deobf'
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
coreJar.dependsOn('reobf')
toolsJar.dependsOn('reobf')
generatorsJar.dependsOn('reobf')
alltJar.dependsOn('reobf')
task MDKZip(type: Zip) {
classifier = 'MDK'
from sourceSets.main.java.srcDirs
include 'mekanism/api/**'
}
task apiJar(type: Jar) {
classifier = 'API'
dependsOn processResources
@ -180,61 +173,32 @@ task fullBuild(type: Delete) {
delete jar
}
fullBuild.dependsOn('toolsJar', 'coreJar', 'generatorsJar', 'MDKZip', 'alltJar', 'apiJar')
artifactory {
contextUrl = System.getenv("MAVEN_URL")
publish {
repository {
repoKey = 'thorfusion'
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
maven = true
}
defaults {
publications('mavenJava')
}
publishBuildInfo = false
publishArtifacts = true
publishPom = true
}
resolve {
repository {
repoKey = 'central'
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
maven = true
}
}
}
fullBuild.dependsOn('toolsJar', 'coreJar', 'generatorsJar', 'sourcesJar', 'alltJar', 'apiJar')
publishing {
tasks.publish.dependsOn 'build'
publications {
mavenJava(MavenPublication) {
artifactId = rootProject.name
groupId = project.group
version = project.version
artifacts = [toolsJar, coreJar, generatorsJar, MDKZip, alltJar, apiJar]
components.java.withVariantsFromConfiguration(configurations.runtimeElements) {
skip()
}
pom {
name.set("Mekanism 1.7.10 Community Edition")
description.set('Mekanism is a Minecraft add-on featuring high-tech machinery that can be used to create powerful tools, armor, and weapons.')
url.set('https://aidancbrady.com/mekanism/')
issueManagement {
system.set('github')
url.set('https://github.com/Thorfusion/Mekanism-1.7.10-Community-Edition/issues')
}
licenses {
license {
name.set('EUPL-1.2')
distribution.set('repo')
}
}
}
artifactId = project.archivesBaseName
artifact deobfJar
artifact sourcesJar
artifact jar
}
}
}
repositories {
if (project.hasProperty('mvnURL')) {
maven {
credentials {
username findProperty("mvnUsername")
password findProperty("mvnPassword")
}
url = findProperty("mvnURL")
}
}
else {
mavenLocal()
}
}
}

View file

@ -5,4 +5,3 @@ CCLIB_version=1.1.3.141
NEI_version=1.0.5.120
CCC_version=1.0.7.48
mod_version=9.11.1
alt_version=9, 10, 16

View file

@ -1,14 +0,0 @@
[
{
"repo": "https://files.thorfusion.com/mekanism",
"file": "ForgeMultipart-${mc_version}-${fmp_version}-universal.jar",
"dev": "ForgeMultipart-${mc_version}-${fmp_version}-dev.jar",
"class": "codechicken.multipart.MultipartMod"
},
{
"repo": "https://files.thorfusion.com/mekanism",
"file": "CodeChickenLib-1.7.10-1.1.3.141-universal.jar",
"dev": "CodeChickenLib-1.7.10-1.1.3.141-dev.jar",
"class": "codechicken.lib.asm.ASMHelper"
}
]

View file

@ -1,14 +0,0 @@
[
{
"repo": "https://files.thorfusion.com/mekanism",
"file": "ForgeMultipart-${mc_version}-${fmp_version}-universal.jar",
"dev": "ForgeMultipart-${mc_version}-${fmp_version}-dev.jar",
"class": "codechicken.multipart.MultipartMod"
},
{
"repo": "https://files.thorfusion.com/mekanism",
"file": "CodeChickenLib-1.7.10-1.1.3.141-universal.jar",
"dev": "CodeChickenLib-1.7.10-1.1.3.141-dev.jar",
"class": "codechicken.lib.asm.ASMHelper"
}
]

View file

@ -1,618 +0,0 @@
package codechicken.core.launch;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import cpw.mods.fml.common.versioning.ComparableVersion;
import cpw.mods.fml.relauncher.FMLInjectionData;
import cpw.mods.fml.relauncher.FMLLaunchHandler;
import cpw.mods.fml.relauncher.IFMLCallHook;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
import net.minecraft.launchwrapper.LaunchClassLoader;
import sun.misc.URLClassPath;
import sun.net.util.URLUtil;
import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import java.awt.*;
import java.awt.Dialog.ModalityType;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.*;
import java.lang.reflect.Field;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLConnection;
import java.nio.ByteBuffer;
import java.util.*;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
/**
* For autodownloading stuff.
* This is really unoriginal, mostly ripped off FML, credits to cpw.
*/
public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
private static ByteBuffer downloadBuffer = ByteBuffer.allocateDirect(1 << 23);
private static final String owner = "CB's DepLoader";
private static DepLoadInst inst;
public interface IDownloadDisplay {
void resetProgress(int sizeGuess);
void setPokeThread(Thread currentThread);
void updateProgress(int fullLength);
boolean shouldStopIt();
void updateProgressString(String string, Object... data);
Object makeDialog();
void showErrorDialog(String name, String url);
}
@SuppressWarnings("serial")
public static class Downloader extends JOptionPane implements IDownloadDisplay {
private JDialog container;
private JLabel currentActivity;
private JProgressBar progress;
boolean stopIt;
Thread pokeThread;
private Box makeProgressPanel() {
Box box = Box.createVerticalBox();
box.add(Box.createRigidArea(new Dimension(0, 10)));
JLabel welcomeLabel = new JLabel("<html><b><font size='+1'>" + owner + " is setting up your minecraft environment</font></b></html>");
box.add(welcomeLabel);
welcomeLabel.setAlignmentY(LEFT_ALIGNMENT);
welcomeLabel = new JLabel("<html>Please wait, " + owner + " has some tasks to do before you can play</html>");
welcomeLabel.setAlignmentY(LEFT_ALIGNMENT);
box.add(welcomeLabel);
box.add(Box.createRigidArea(new Dimension(0, 10)));
currentActivity = new JLabel("Currently doing ...");
box.add(currentActivity);
box.add(Box.createRigidArea(new Dimension(0, 10)));
progress = new JProgressBar(0, 100);
progress.setStringPainted(true);
box.add(progress);
box.add(Box.createRigidArea(new Dimension(0, 30)));
return box;
}
@Override
public JDialog makeDialog() {
if (container != null)
return container;
setMessageType(JOptionPane.INFORMATION_MESSAGE);
setMessage(makeProgressPanel());
setOptions(new Object[]{"Stop"});
addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getSource() == Downloader.this && evt.getPropertyName() == VALUE_PROPERTY) {
requestClose("This will stop minecraft from launching\nAre you sure you want to do this?");
}
}
});
container = new JDialog(null, "Hello", ModalityType.MODELESS);
container.setResizable(false);
container.setLocationRelativeTo(null);
container.add(this);
this.updateUI();
container.pack();
container.setMinimumSize(container.getPreferredSize());
container.setVisible(true);
container.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
container.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
requestClose("Closing this window will stop minecraft from launching\nAre you sure you wish to do this?");
}
});
return container;
}
protected void requestClose(String message) {
int shouldClose = JOptionPane.showConfirmDialog(container, message, "Are you sure you want to stop?", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
if (shouldClose == JOptionPane.YES_OPTION)
container.dispose();
stopIt = true;
if (pokeThread != null)
pokeThread.interrupt();
}
@Override
public void updateProgressString(String progressUpdate, Object... data) {
//FMLLog.finest(progressUpdate, data);
if (currentActivity != null)
currentActivity.setText(String.format(progressUpdate, data));
}
@Override
public void resetProgress(int sizeGuess) {
if (progress != null)
progress.getModel().setRangeProperties(0, 0, 0, sizeGuess, false);
}
@Override
public void updateProgress(int fullLength) {
if (progress != null)
progress.getModel().setValue(fullLength);
}
@Override
public void setPokeThread(Thread currentThread) {
this.pokeThread = currentThread;
}
@Override
public boolean shouldStopIt() {
return stopIt;
}
@Override
public void showErrorDialog(String name, String url) {
JEditorPane ep = new JEditorPane("text/html",
"<html>" +
owner + " was unable to download required library " + name +
"<br>Check your internet connection and try restarting or download it manually from" +
"<br><a href=\"" + url + "\">" + url + "</a> and put it in your mods folder" +
"</html>");
ep.setEditable(false);
ep.setOpaque(false);
ep.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent event) {
try {
if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
Desktop.getDesktop().browse(event.getURL().toURI());
} catch (Exception e) {
}
}
});
JOptionPane.showMessageDialog(null, ep, "A download error has occured", JOptionPane.ERROR_MESSAGE);
}
}
public static class DummyDownloader implements IDownloadDisplay {
@Override
public void resetProgress(int sizeGuess) {
}
@Override
public void setPokeThread(Thread currentThread) {
}
@Override
public void updateProgress(int fullLength) {
}
@Override
public boolean shouldStopIt() {
return false;
}
@Override
public void updateProgressString(String string, Object... data) {
}
@Override
public Object makeDialog() {
return null;
}
@Override
public void showErrorDialog(String name, String url) {
}
}
public static class VersionedFile
{
public final Pattern pattern;
public final String filename;
public final ComparableVersion version;
public final String name;
public VersionedFile(String filename, Pattern pattern) {
this.pattern = pattern;
this.filename = filename;
Matcher m = pattern.matcher(filename);
if(m.matches()) {
name = m.group(1);
version = new ComparableVersion(m.group(2));
}
else {
name = null;
version = null;
}
}
public boolean matches() {
return name != null;
}
}
public static class Dependency
{
public String url;
public VersionedFile file;
public String existing;
/**
* Flag set to add this dep to the classpath immediately because it is required for a coremod.
*/
public boolean coreLib;
public Dependency(String url, VersionedFile file, boolean coreLib) {
this.url = url;
this.file = file;
this.coreLib = coreLib;
}
}
public static class DepLoadInst {
private File modsDir;
private File v_modsDir;
private IDownloadDisplay downloadMonitor;
private JDialog popupWindow;
private Map<String, Dependency> depMap = new HashMap<String, Dependency>();
private HashSet<String> depSet = new HashSet<String>();
public DepLoadInst() {
String mcVer = (String) FMLInjectionData.data()[4];
File mcDir = (File) FMLInjectionData.data()[6];
modsDir = new File(mcDir, "mods");
v_modsDir = new File(mcDir, "mods/" + mcVer);
if (!v_modsDir.exists())
v_modsDir.mkdirs();
}
private void addClasspath(String name) {
try {
((LaunchClassLoader) DepLoader.class.getClassLoader()).addURL(new File(v_modsDir, name).toURI().toURL());
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
private void deleteMod(File mod) {
if (mod.delete())
return;
try {
ClassLoader cl = DepLoader.class.getClassLoader();
URL url = mod.toURI().toURL();
Field f_ucp = URLClassLoader.class.getDeclaredField("ucp");
Field f_loaders = URLClassPath.class.getDeclaredField("loaders");
Field f_lmap = URLClassPath.class.getDeclaredField("lmap");
f_ucp.setAccessible(true);
f_loaders.setAccessible(true);
f_lmap.setAccessible(true);
URLClassPath ucp = (URLClassPath) f_ucp.get(cl);
Closeable loader = ((Map<String, Closeable>) f_lmap.get(ucp)).remove(URLUtil.urlNoFragString(url));
if (loader != null) {
loader.close();
((List<?>) f_loaders.get(ucp)).remove(loader);
}
} catch (Exception e) {
e.printStackTrace();
}
if (!mod.delete()) {
mod.deleteOnExit();
String msg = owner + " was unable to delete file " + mod.getPath() + " the game will now try to delete it on exit. If this dialog appears again, delete it manually.";
System.err.println(msg);
if (!GraphicsEnvironment.isHeadless())
JOptionPane.showMessageDialog(null, msg, "An update error has occured", JOptionPane.ERROR_MESSAGE);
System.exit(1);
}
}
private void download(Dependency dep) {
popupWindow = (JDialog) downloadMonitor.makeDialog();
File libFile = new File(v_modsDir, dep.file.filename);
try {
URL libDownload = new URL(dep.url + '/' + dep.file.filename);
downloadMonitor.updateProgressString("Downloading file %s", libDownload.toString());
System.out.format("Downloading file %s\n", libDownload.toString());
URLConnection connection = libDownload.openConnection();
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);
connection.setRequestProperty("User-Agent", "" + owner + " Downloader");
int sizeGuess = connection.getContentLength();
download(connection.getInputStream(), sizeGuess, libFile);
downloadMonitor.updateProgressString("Download complete");
System.out.println("Download complete");
scanDepInfo(libFile);
} catch (Exception e) {
libFile.delete();
if (downloadMonitor.shouldStopIt()) {
System.err.println("You have stopped the downloading operation before it could complete");
System.exit(1);
return;
}
downloadMonitor.showErrorDialog(dep.file.filename, dep.url + '/' + dep.file.filename);
throw new RuntimeException("A download error occured", e);
}
}
private void download(InputStream is, int sizeGuess, File target) throws Exception {
if (sizeGuess > downloadBuffer.capacity())
throw new Exception(String.format("The file %s is too large to be downloaded by " + owner + " - the download is invalid", target.getName()));
downloadBuffer.clear();
int bytesRead, fullLength = 0;
downloadMonitor.resetProgress(sizeGuess);
try {
downloadMonitor.setPokeThread(Thread.currentThread());
byte[] smallBuffer = new byte[1024];
while ((bytesRead = is.read(smallBuffer)) >= 0) {
downloadBuffer.put(smallBuffer, 0, bytesRead);
fullLength += bytesRead;
if (downloadMonitor.shouldStopIt()) {
break;
}
downloadMonitor.updateProgress(fullLength);
}
is.close();
downloadMonitor.setPokeThread(null);
downloadBuffer.limit(fullLength);
downloadBuffer.position(0);
} catch (InterruptedIOException e) {
// We were interrupted by the stop button. We're stopping now.. clear interruption flag.
Thread.interrupted();
throw new Exception("Stop");
} catch (IOException e) {
throw e;
}
try {
/*String cksum = generateChecksum(downloadBuffer);
if (cksum.equals(validationHash))
{*/
if (!target.exists())
target.createNewFile();
downloadBuffer.position(0);
FileOutputStream fos = new FileOutputStream(target);
fos.getChannel().write(downloadBuffer);
fos.close();
/*}
else
{
throw new RuntimeException(String.format("The downloaded file %s has an invalid checksum %s (expecting %s). The download did not succeed correctly and the file has been deleted. Please try launching again.", target.getName(), cksum, validationHash));
}*/
} catch (Exception e) {
throw e;
}
}
private String checkExisting(Dependency dep) {
for (File f : modsDir.listFiles()) {
VersionedFile vfile = new VersionedFile(f.getName(), dep.file.pattern);
if (!vfile.matches() || !vfile.name.equals(dep.file.name))
continue;
if (f.renameTo(new File(v_modsDir, f.getName())))
continue;
deleteMod(f);
}
for (File f : v_modsDir.listFiles()) {
VersionedFile vfile = new VersionedFile(f.getName(), dep.file.pattern);
if (!vfile.matches() || !vfile.name.equals(dep.file.name))
continue;
int cmp = vfile.version.compareTo(dep.file.version);
if (cmp < 0) {
System.out.println("Deleted old version " + f.getName());
deleteMod(f);
return null;
}
if (cmp > 0) {
System.err.println("Warning: version of " + dep.file.name + ", " + vfile.version + " is newer than request " + dep.file.version);
return f.getName();
}
return f.getName();//found dependency
}
return null;
}
public void load() {
scanDepInfos();
if (depMap.isEmpty())
return;
loadDeps();
activateDeps();
}
private void activateDeps() {
for (Dependency dep : depMap.values())
if (dep.coreLib)
addClasspath(dep.existing);
}
private void loadDeps() {
downloadMonitor = FMLLaunchHandler.side().isClient() ? new Downloader() : new DummyDownloader();
try {
while (!depSet.isEmpty()) {
Iterator<String> it = depSet.iterator();
Dependency dep = depMap.get(it.next());
it.remove();
load(dep);
}
} finally {
if (popupWindow != null) {
popupWindow.setVisible(false);
popupWindow.dispose();
}
}
}
private void load(Dependency dep) {
dep.existing = checkExisting(dep);
if (dep.existing == null)//download dep
{
download(dep);
dep.existing = dep.file.filename;
}
}
private List<File> modFiles() {
List<File> list = new LinkedList<File>();
list.addAll(Arrays.asList(modsDir.listFiles()));
list.addAll(Arrays.asList(v_modsDir.listFiles()));
return list;
}
private void scanDepInfos() {
for (File file : modFiles()) {
if (!file.getName().endsWith(".jar") && !file.getName().endsWith(".zip"))
continue;
scanDepInfo(file);
}
}
private void scanDepInfo(File file) {
try {
ZipFile zip = new ZipFile(file);
ZipEntry e = zip.getEntry("dependancies.info");
if (e == null) e = zip.getEntry("dependencies.info");
if (e != null)
loadJSon(zip.getInputStream(e));
zip.close();
} catch (Exception e) {
System.err.println("Failed to load dependencies.info from " + file.getName() + " as JSON");
e.printStackTrace();
}
}
private void loadJSon(InputStream input) throws IOException {
InputStreamReader reader = new InputStreamReader(input);
JsonElement root = new JsonParser().parse(reader);
if (root.isJsonArray())
loadJSonArr(root);
else
loadJson(root.getAsJsonObject());
reader.close();
}
private void loadJSonArr(JsonElement root) throws IOException {
for (JsonElement node : root.getAsJsonArray())
loadJson(node.getAsJsonObject());
}
private void loadJson(JsonObject node) throws IOException {
boolean obfuscated = ((LaunchClassLoader) DepLoader.class.getClassLoader())
.getClassBytes("net.minecraft.world.World") == null;
String testClass = node.get("class").getAsString();
if (DepLoader.class.getResource("/" + testClass.replace('.', '/') + ".class") != null)
return;
String repo = node.get("repo").getAsString();
String filename = node.get("file").getAsString();
if (!obfuscated && node.has("dev"))
filename = node.get("dev").getAsString();
boolean coreLib = node.has("coreLib") && node.get("coreLib").getAsBoolean();
Pattern pattern = null;
try {
if(node.has("pattern"))
pattern = Pattern.compile(node.get("pattern").getAsString());
} catch (PatternSyntaxException e) {
System.err.println("Invalid filename pattern: "+node.get("pattern"));
e.printStackTrace();
}
if(pattern == null)
pattern = Pattern.compile("(\\w+).*?([\\d\\.]+)[-\\w]*\\.[^\\d]+");
VersionedFile file = new VersionedFile(filename, pattern);
if (!file.matches())
throw new RuntimeException("Invalid filename format for dependency: " + filename);
addDep(new Dependency(repo, file, coreLib));
}
private void addDep(Dependency newDep) {
if (mergeNew(depMap.get(newDep.file.name), newDep)) {
depMap.put(newDep.file.name, newDep);
depSet.add(newDep.file.name);
}
}
private boolean mergeNew(Dependency oldDep, Dependency newDep) {
if (oldDep == null)
return true;
Dependency newest = newDep.file.version.compareTo(oldDep.file.version) > 0 ? newDep : oldDep;
newest.coreLib = newDep.coreLib || oldDep.coreLib;
return newest == newDep;
}
}
public static void load() {
if (inst == null) {
inst = new DepLoadInst();
inst.load();
}
}
@Override
public String[] getASMTransformerClass() {
return null;
}
@Override
public String getModContainerClass() {
return null;
}
@Override
public String getSetupClass() {
return getClass().getName();
}
@Override
public void injectData(Map<String, Object> data) {
}
@Override
public Void call() {
load();
return null;
}
@Override
public String getAccessTransformerClass() {
return null;
}
}

View file

@ -1,210 +0,0 @@
package mekanism.client;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import mekanism.api.EnumColor;
import mekanism.client.gui.GuiCredits;
import mekanism.common.Mekanism;
import mekanism.common.Version;
import mekanism.common.base.IModule;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* Thread that downloads the latest release of Mekanism. The older file is deleted and the newly downloaded file takes it's place.
* @author AidanBrady
*
*/
@SideOnly(Side.CLIENT)
public class ThreadClientUpdate extends Thread
{
private int bytesDownloaded;
private int lastBytesDownloaded;
private byte[] buffer = new byte[10240];
private static File modsDir = new File(Mekanism.proxy.getMinecraftDir(), "mods");
private static File tempDir = new File(modsDir, "temp");
private static URL zipUrl = createURL();
public static boolean hasUpdated;
public ThreadClientUpdate()
{
setDaemon(false);
start();
}
@Override
public void run()
{
try {
deleteTemp();
createTemp();
File download = new File(tempDir, "builds.zip");
prepareForDownload();
download.createNewFile();
GuiCredits.updateInfo("Downloading...");
FileOutputStream outputStream = new FileOutputStream(download.getAbsolutePath());
InputStream stream = zipUrl.openStream();
while((lastBytesDownloaded = stream.read(buffer)) > 0)
{
outputStream.write(buffer, 0, lastBytesDownloaded);
buffer = new byte[10240];
bytesDownloaded += lastBytesDownloaded;
}
outputStream.close();
stream.close();
if(Mekanism.versionNumber.comparedState(Version.get(Mekanism.latestVersionNumber)) == -1)
{
ZipInputStream zip = new ZipInputStream(new FileInputStream(download));
deployEntry(zip, "Mekanism-");
zip.close();
}
for(IModule module : Mekanism.modulesLoaded)
{
if(module.getVersion().comparedState(Version.get(Mekanism.latestVersionNumber)) == -1)
{
ZipInputStream zip = new ZipInputStream(new FileInputStream(download));
deployEntry(zip, "Mekanism" + module.getName());
zip.close();
}
}
deleteTemp();
hasUpdated = true;
GuiCredits.updateInfo("Update installed, reboot Minecraft for changes.");
Mekanism.logger.info("Successfully updated to latest version (" + Mekanism.latestVersionNumber + ").");
finalize();
} catch(Throwable t) {
GuiCredits.updateInfo(EnumColor.DARK_RED + "Error updating.");
hasUpdated = true;
Mekanism.logger.error("Error while finishing update thread: " + t.getMessage());
t.printStackTrace();
}
}
private void deployEntry(ZipInputStream zip, String filePrefix) throws IOException
{
byte[] zipBuffer = new byte[1024];
ZipEntry entry = zip.getNextEntry();
while(entry != null)
{
if(entry.isDirectory())
{
continue;
}
if(entry.getName().contains(filePrefix))
{
File modFile = new File(modsDir, entry.getName().replace("output/", ""));
if(modFile.exists())
{
modFile.delete();
}
modFile.createNewFile();
FileOutputStream outStream = new FileOutputStream(modFile);
int len;
while((len = zip.read(zipBuffer)) > 0)
{
outStream.write(zipBuffer, 0, len);
}
zip.closeEntry();
outStream.close();
break;
}
entry = zip.getNextEntry();
}
}
private void createTemp() throws IOException
{
if(!tempDir.exists())
{
tempDir.mkdir();
}
}
private void deleteTemp() throws IOException
{
if(tempDir.exists())
{
clearFiles(tempDir);
}
}
private void clearFiles(File file)
{
if(file.isDirectory())
{
for(File sub : file.listFiles())
{
clearFiles(sub);
}
}
file.delete();
}
private void prepareForDownload()
{
File[] modsList = new File(new StringBuilder().append(Mekanism.proxy.getMinecraftDir()).append(File.separator + "mods").toString()).listFiles();
if(Mekanism.versionNumber.comparedState(Version.get(Mekanism.latestVersionNumber)) == -1)
{
for(File file : modsList)
{
if(file.getName().startsWith("Mekanism-") && file.getName().endsWith(".jar") && !file.getName().contains(Mekanism.latestVersionNumber))
{
file.delete();
}
}
}
for(IModule module : Mekanism.modulesLoaded)
{
for(File file : modsList)
{
if(file.getName().startsWith("Mekanism" + module.getName()) && file.getName().endsWith(".jar") && !file.getName().contains(Mekanism.latestVersionNumber))
{
file.delete();
}
}
}
Mekanism.logger.info("Preparing to update...");
}
private static URL createURL()
{
try {
return new URL("http://technic-solder.eu-central-1.linodeobjects.com/mekanism/latestmekanism.zip");
} catch(Exception e) {}
return null;
}
}

View file

@ -1,9 +1,7 @@
package mekanism.client.gui;
import mekanism.api.EnumColor;
import mekanism.client.ThreadClientUpdate;
import mekanism.common.Mekanism;
import mekanism.common.Version;
import mekanism.common.base.IModule;
import mekanism.common.util.MekanismUtils;
import net.minecraft.client.gui.GuiButton;
@ -59,31 +57,16 @@ public class GuiCredits extends GuiScreen
drawDefaultBackground();
drawCenteredString(fontRendererObj, EnumColor.DARK_BLUE + "Mekanism" + EnumColor.GREY + " by aidancbrady", width / 2, (height / 4 - 60) + 20, 0xffffff);
if(Mekanism.latestVersionNumber != null && !Mekanism.latestVersionNumber.equals("null"))
{
writeText(EnumColor.INDIGO + "Mekanism " + (Mekanism.versionNumber.comparedState(Version.get(Mekanism.latestVersionNumber)) == -1 ? EnumColor.DARK_RED : EnumColor.GREY) + Mekanism.versionNumber, 36);
}
else {
writeText(EnumColor.INDIGO + "Mekanism " + EnumColor.GREY + Mekanism.versionNumber, 36);
}
writeText(EnumColor.INDIGO + "Mekanism " + EnumColor.GREY + Mekanism.versionNumber, 36);
int size = 36;
for(IModule module : Mekanism.modulesLoaded)
{
size += 9;
if(Mekanism.latestVersionNumber != null && !Mekanism.latestVersionNumber.equals("null"))
{
writeText(EnumColor.INDIGO + "Mekanism" + module.getName() + (module.getVersion().comparedState(Version.get(Mekanism.latestVersionNumber)) == -1 ? EnumColor.DARK_RED : EnumColor.GREY) + " " + module.getVersion(), size);
}
else {
writeText(EnumColor.INDIGO + "Mekanism" + module.getName() + EnumColor.GREY + " " + module.getVersion(), size);
}
writeText(EnumColor.INDIGO + "Mekanism" + module.getName() + EnumColor.GREY + " " + module.getVersion(), size);
}
writeText(EnumColor.GREY + "Newest version: " + Mekanism.latestVersionNumber, size+9);
writeText(EnumColor.GREY + "*Developed on Mac OS X 10.8 Mountain Lion", size+18);
writeText(EnumColor.GREY + "*Code, textures, and ideas by aidancbrady", size+27);
writeText(EnumColor.GREY + "Recent news: " + EnumColor.DARK_BLUE + (!Mekanism.recentNews.contains("null") ? Mekanism.recentNews : "couldn't access."), size+36);
writeText(EnumColor.GREY + updateProgress, size+45);

View file

@ -5,14 +5,11 @@ import java.util.List;
import mekanism.api.EnumColor;
import mekanism.api.MekanismAPI;
import mekanism.api.MekanismConfig.general;
import mekanism.common.frequency.Frequency;
import mekanism.common.frequency.FrequencyManager;
import mekanism.common.tile.TileEntityTeleporter;
import mekanism.common.util.MekanismUtils;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ChatComponentText;
@ -49,7 +46,6 @@ public class CommandMekanism extends CommandBase
{
sender.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------"));
sender.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Version: " + EnumColor.DARK_GREY + Mekanism.versionNumber));
sender.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Latest Version: " + EnumColor.DARK_GREY + Mekanism.latestVersionNumber));
sender.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Code, textures, and ideas by aidancbrady"));
sender.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Recent News: " + EnumColor.INDIGO + Mekanism.recentNews));
sender.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------"));
@ -89,10 +85,6 @@ public class CommandMekanism extends CommandBase
{
sender.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Most recent news: " + EnumColor.INDIGO + Mekanism.recentNews));
}
else if(params[0].equalsIgnoreCase("latest"))
{
sender.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " The latest version for mekanism is " + EnumColor.DARK_GREY + Mekanism.latestVersionNumber + EnumColor.GREY + "."));
}
else if(params[0].equalsIgnoreCase("teleporter"))
{
if(params.length == 2)

View file

@ -137,8 +137,8 @@ import cpw.mods.fml.common.registry.GameRegistry;
* @author AidanBrady
*
*/
@Mod(modid = "Mekanism", name = "Mekanism", version = "GRADLE_MODVERSION", guiFactory = "mekanism.client.gui.ConfigGuiFactory",
dependencies = "after:universalelectricity;after:ForgeMultipart;after:BuildCraft;after:BuildCraftAPI;after:IC2;after:CoFHCore;" +
@Mod(modid = "Mekanism", name = "Mekanism tilera Edition", version = "GRADLE_MODVERSION", guiFactory = "mekanism.client.gui.ConfigGuiFactory",
dependencies = "required-after:universalelectricity;required-after:ForgeMultipart;after:BuildCraft;after:BuildCraftAPI;after:IC2;after:CoFHCore;" +
"after:ComputerCraft;after:Galacticraft;after:MineTweaker3")
public class Mekanism
{
@ -163,7 +163,8 @@ public class Mekanism
public static Configuration configuration;
/** Mekanism version number */
public static Version versionNumber = new Version(GRADLE_VERSIONMOD);
//public static Version versionNumber = new Version(GRADLE_VERSIONMOD);
public static String versionNumber = "GRADLE_MODVERSION";
/** MultiblockManagers for various structrures */
public static MultiblockManager<SynchronizedTankData> tankManager = new MultiblockManager<SynchronizedTankData>("dynamicTank");
@ -187,9 +188,6 @@ public class Mekanism
/** List of Mekanism modules loaded */
public static List<IModule> modulesLoaded = new ArrayList<IModule>();
/** The latest version number which is received from the Mekanism server */
public static String latestVersionNumber;
/** The recent news which is received from the Mekanism server */
public static String recentNews;
@ -1188,10 +1186,8 @@ public class Mekanism
OreGas clean = (OreGas)GasRegistry.register(new OreGas("clean" + name, "oregas." + name.toLowerCase()).setVisible(false));
GasRegistry.register(new OreGas(name.toLowerCase(), "oregas." + name.toLowerCase()).setCleanGas(clean).setVisible(false));
}
if (Loader.isModLoaded("universalelectricity")) {
CompatibilityModule.register(new UECompatModule());
}
CompatibilityModule.register(new UECompatModule());
Mekanism.proxy.preInit();

View file

@ -1,155 +0,0 @@
package mekanism.common;
/**
* Version v2.0.0. Simple version handling for Mekanism.
* @author AidanBrady
*
*/
public class Version
{
/** Major number for version */
public int major;
/** Minor number for version */
public int minor;
/** Build number for version */
public int build;
/**
* Creates a version number with 3 digits.
* @param majorNum - major version
* @param minorNum - minor version
* @param buildNum - build version
*/
public Version(int majorNum, int minorNum, int buildNum)
{
major = majorNum;
minor = minorNum;
build = buildNum;
}
/**
* Resets the version number to "0.0.0."
*/
public void reset()
{
major = 0;
minor = 0;
build = 0;
}
/**
* 1: greater than
* 0: equal to
* -1: less than
* @param version
* @return
*/
public byte comparedState(Version version)
{
if(version.major > major)
{
return -1;
}
else if(version.major == major)
{
if(version.minor > minor)
{
return -1;
}
else if(version.minor == minor)
{
if(version.build > build)
{
return -1;
}
else if(version.build == build)
{
return 0;
}
else {
return 1;
}
}
else {
return 1;
}
}
else {
return 1;
}
}
/**
* Gets a version object from a string.
* @param s - string object
* @return version if applicable, otherwise null
*/
public static Version get(String s)
{
String[] split = s.replace('.', ':').split(":");
if(split.length != 3)
{
return null;
}
for(String i : split)
{
for(Character c : i.toCharArray())
{
if(!Character.isDigit(c))
{
return null;
}
}
}
int[] digits = new int[3];
for(int i = 0; i < 3; i++)
{
digits[i] = Integer.parseInt(split[i]);
}
return new Version(digits[0], digits[1], digits[2]);
}
@Override
public String toString()
{
if(major == 0 && minor == 0 && build == 0)
{
return "";
}
else {
return major + "." + minor + "." + build;
}
}
@Override
public int hashCode()
{
int result = 1;
result = 31 * result + build;
result = 31 * result + major;
result = 31 * result + minor;
return result;
}
@Override
public boolean equals(Object obj)
{
if(obj == null || getClass() != obj.getClass())
{
return false;
}
Version other = (Version)obj;
return build == other.build && major == other.major && minor == other.minor;
}
}

View file

@ -4,7 +4,6 @@ import io.netty.buffer.ByteBuf;
import java.io.IOException;
import mekanism.common.Version;
/**
* Implement in your main class if your mod happens to be completely reliant on Mekanism, or in other words, is a Mekanism module.
@ -17,7 +16,7 @@ public interface IModule
* Gets the version of the module.
* @return the module's version
*/
public Version getVersion();
public String getVersion();
/**
* Gets the name of the module. Note that this doesn't include "Mekanism" like the actual module's name does, just the

View file

@ -40,7 +40,6 @@ import mekanism.common.Tier.GasTankTier;
import mekanism.common.Tier.InductionCellTier;
import mekanism.common.Tier.InductionProviderTier;
import mekanism.common.Upgrade;
import mekanism.common.Version;
import mekanism.common.base.IActiveState;
import mekanism.common.base.IFactory;
import mekanism.common.base.IFactory.RecipeType;

View file

@ -15,7 +15,6 @@ import mekanism.common.MekanismBlocks;
import mekanism.common.MekanismItems;
import mekanism.common.Tier.BaseTier;
import mekanism.common.Tier.GasTankTier;
import mekanism.common.Version;
import mekanism.common.base.IModule;
import mekanism.common.multiblock.MultiblockManager;
import mekanism.common.network.PacketSimpleGui;
@ -54,7 +53,7 @@ public class MekanismGenerators implements IModule
public static MekanismGenerators instance;
/** MekanismGenerators version number */
public static Version versionNumber = new Version(GRADLE_VERSIONMOD);
public static String versionNumber = "GRADLE_MODVERSION";
public static MultiblockManager<SynchronizedTurbineData> turbineManager = new MultiblockManager<SynchronizedTurbineData>("industrialTurbine");
@ -185,7 +184,7 @@ public class MekanismGenerators implements IModule
}
@Override
public Version getVersion()
public String getVersion()
{
return versionNumber;
}

View file

@ -6,7 +6,6 @@ import java.io.IOException;
import mekanism.api.MekanismConfig.tools;
import mekanism.common.Mekanism;
import mekanism.common.Version;
import mekanism.common.base.IModule;
import mekanism.common.recipe.ShapedMekanismRecipe;
import net.minecraft.entity.monster.EntitySkeleton;
@ -39,7 +38,7 @@ public class MekanismTools implements IModule
public static MekanismTools instance;
/** MekanismTools version number */
public static Version versionNumber = new Version(GRADLE_VERSIONMOD);
public static String versionNumber = "GRADLE_MODVERSION";
//Enums: Tools
public static ToolMaterial toolOBSIDIAN;
@ -528,7 +527,7 @@ public class MekanismTools implements IModule
}
@Override
public Version getVersion()
public String getVersion()
{
return versionNumber;
}