Skip to content

Commit

Permalink
Port to Liteloader
Browse files Browse the repository at this point in the history
  • Loading branch information
maruohon committed Feb 26, 2018
1 parent ad2336e commit 32cb5ae
Show file tree
Hide file tree
Showing 36 changed files with 2,365 additions and 1,157 deletions.
116 changes: 66 additions & 50 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@

buildscript {
repositories {
jcenter()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = 'sponge'
url = 'http://repo.spongepowered.org/maven'
}
}

dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath "net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT"
classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
}
}

apply plugin: 'net.minecraftforge.gradle.forge'

sourceCompatibility = 1.8
targetCompatibility = 1.8
apply plugin: 'net.minecraftforge.gradle.liteloader'
apply plugin: 'org.spongepowered.mixin'

ext.configFile = file "build.properties"

Expand All @@ -24,22 +29,13 @@ configFile.withReader {
project.ext.config = new ConfigSlurper().parse prop
}

group = config.group + config.mod_id // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = config.mod_id + '-' + config.minecraft_version_out

minecraft {
version = config.minecraft_version + "-" + config.forge_version
runDir = "../minecraft"
version = config.minecraft_version
mappings = config.mappings_version
runDir = 'minecraft'
makeObfSourceJar = false

// the mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not allways work.
// simply re-run your setup task after changing the mappings to update your workspace.
mappings = config.mappings_version
makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

ext.mod_version = "${config.mod_version}"
ext.mod_version = config.mod_version

if (mod_version.endsWith('-dev')) {
mod_version = mod_version + "." + new Date().format('yyyyMMdd.HHmmss')
Expand All @@ -49,27 +45,62 @@ minecraft {
replace "@MOD_VERSION@", mod_version
}

dependencies {
// you may put jars on which you depend on in ./libs
// or you may define them like so..
//compile "some.group:artifact:version:classifier"
//compile "some.group:artifact:version"

// for more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
sourceSets {
main {
ext.refMap = 'mixins.' + config.mod_id + '.refmap.json'
}
}

group = config.group + config.mod_id // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = config.mod_id + '-' + config.minecraft_version_out
version = project.minecraft.mod_version

processResources
{
// Exclude the GIMP image files
exclude '**/*.xcf'
/**
* This section allows you to customise the generated litemod.json file
*/
litemod {
json {
name = config.mod_id
displayName = config.mod_name
mcversion = config.minecraft_version
version = config.mod_version
author = config.author

// Uncomment any of the following lines and fill in your own details as required
//dependsOn = [ 'modid', 'othermod' ]
//requiredAPIs = [ 'someapi' ]
//tweakClass = 'name.of.tweaker.here'
mixinConfigs = [ 'mixins.' + config.mod_id + '.json' ]
}
}

// Exclude the Cubik model files
exclude '**/*.bdc3D'
/**
* This section allows you to customise your generated jar (litemod) file. By
* default it includes the generated litemod.json file, however if you prefer to
* include your own file from resources, simply remove the line below.
*/
jar {
from litemod.outputs

/*
manifest.mainAttributes (
'Built-By': System.properties['user.name'],
'Created-By': System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")",
'Implementation-Title': config.mod_id,
'Implementation-Version': project.version
)
*/
}

mixin {
defaultObfuscationEnv notch
}

// Don't append a 'mod-' filename prefix >_>
tasks.withType(Jar)*.baseName = archivesBaseName

processResources
{
// this will ensure that this task is redone when the versions change.
inputs.property "mod_version", project.minecraft.mod_version
inputs.property "minecraft_version", project.config.minecraft_version
Expand All @@ -81,24 +112,9 @@ processResources
// replace version and mcversion
expand 'mod_version': project.minecraft.mod_version, 'minecraft_version': project.config.minecraft_version
}

// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}

// Move access transformers to META-INF
// rename '(' + config.mod_id + '_at.cfg)', 'META-INF/$1'
}

task signJar(type: SignJar, dependsOn: reobfJar) {
inputFile = jar.archivePath
outputFile = jar.archivePath

keyStore = config.keyStore
alias = config.alias
storePass = config.storePass
keyPass = config.keyPass
}

build.dependsOn signJar
14 changes: 4 additions & 10 deletions build.properties
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
# Thu Jan 14 08:33:00 EET 2016
group = fi.dy.masa
mod_id = minihud
mod_version = 0.12.0
mod_name = MiniHUD
mod_version = 0.12.0-dev
author = masa

# Minecraft, Forge and MCP mappings versions
minecraft_version_out = 1.12.0
minecraft_version = 1.12
forge_version = 14.21.1.2404
mappings_version = snapshot_20170708

# JAR signing related stuff
#keyStore = "C:\Users\masa\Desktop\minecraft_modding\keystore_masas_mods.jks"
keyStore = "../../../keystore_masas_mods.jks"
alias = signMinecraftModFiles
storePass = masaFooBar
keyPass = masaFooBar
mappings_version = snapshot_20170609
73 changes: 73 additions & 0 deletions src/main/java/fi/dy/masa/minihud/LiteModMiniHud.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package fi.dy.masa.minihud;

import java.io.File;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Keyboard;
import com.mojang.realmsclient.dto.RealmsServer;
import com.mumfrey.liteloader.Configurable;
import com.mumfrey.liteloader.InitCompleteListener;
import com.mumfrey.liteloader.JoinGameListener;
import com.mumfrey.liteloader.LiteMod;
import com.mumfrey.liteloader.core.LiteLoader;
import com.mumfrey.liteloader.modconfig.ConfigPanel;
import fi.dy.masa.minihud.config.Configs;
import fi.dy.masa.minihud.config.gui.MiniHudConfigPanel;
import fi.dy.masa.minihud.event.RenderEventHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.network.INetHandler;
import net.minecraft.network.play.server.SPacketJoinGame;

public class LiteModMiniHud implements LiteMod, Configurable, InitCompleteListener, JoinGameListener
{
public static final KeyBinding KEY_TOGGLE_MODE = new KeyBinding("minihud.key.togglemode", Keyboard.KEY_H, "category.minihud");
public static final Logger logger = LogManager.getLogger(Reference.MOD_ID);

public LiteModMiniHud()
{
}

@Override
public String getName()
{
return Reference.MOD_NAME;
}

@Override
public String getVersion()
{
return Reference.MOD_VERSION;
}

@Override
public Class<? extends ConfigPanel> getConfigPanelClass()
{
return MiniHudConfigPanel.class;
}

@Override
public void init(File configPath)
{
Configs.load();
RenderEventHandler.getInstance().setEnabled(Configs.Generic.ENABLE_BY_DEFAULT.getBooleanValue());
}

@Override
public void upgradeSettings(String version, File configPath, File oldConfigPath)
{
}

@Override
public void onInitCompleted(Minecraft minecraft, LiteLoader loader)
{
LiteLoader.getInput().registerKeyBinding(KEY_TOGGLE_MODE);
}

@Override
public void onJoinGame(INetHandler netHandler, SPacketJoinGame joinGamePacket, ServerData serverData, RealmsServer realmsServer)
{
RenderEventHandler.getInstance().onWorldLoad();
}
}
57 changes: 0 additions & 57 deletions src/main/java/fi/dy/masa/minihud/MiniHud.java

This file was deleted.

7 changes: 0 additions & 7 deletions src/main/java/fi/dy/masa/minihud/Reference.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
package fi.dy.masa.minihud;

import org.lwjgl.input.Keyboard;

public class Reference
{
public static final String MOD_ID = "minihud";
public static final String MOD_NAME = "Mini HUD";
public static final String MOD_VERSION = "@MOD_VERSION@";
public static final String FINGERPRINT = "2b03e1423915a189b8094816baa18f239d576dff";

public static final String KEYBIND_CATEGORY_MINIHUD = "category." + Reference.MOD_ID;
public static final String KEYBIND_NAME_TOGGLE_MODE = Reference.MOD_ID + ".key.togglemode";
public static final int DEFAULT_KEYBIND_TOGGLE_MODE = Keyboard.KEY_H;
}
Loading

0 comments on commit 32cb5ae

Please sign in to comment.