Skip to content

Commit

Permalink
Rebrand & Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Desoroxxx committed Sep 19, 2023
1 parent 9bec3fd commit 0eed169
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 171 deletions.
141 changes: 60 additions & 81 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import org.jetbrains.gradle.ext.Gradle

plugins {
id("java")
id("java-library")
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.7"
id("com.gtnewhorizons.retrofuturagradle") version "1.+"
id("com.matthewprenger.cursegradle") version "1.4.0"
id("io.freefair.lombok") version "8.3"
id 'java'
id 'java-library'
id 'io.freefair.lombok' version '8.+'
id 'com.github.gmazzo.buildconfig' version '4.+'
id 'com.gtnewhorizons.retrofuturagradle' version '1.+'
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.+'
}

// Add version to the jar name
version project.version
version = project.version

// Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod
java {
Expand All @@ -23,111 +23,90 @@ java {
}

tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
options.encoding = 'UTF-8'
options.fork = true
}

minecraft {
mcVersion = "1.12.2"

username = "Desoroxxx"

extraRunJvmArguments.addAll("-Xmx6G", "-Xms4G", "-Dforge.logging.console.level=debug", "-Dfml.coreMods.load=io.redstudioragnarok.redcore.asm.RedCorePlugin")

injectedTags.put("ID", project.id)
injectedTags.put("VERSION", project.version)
}

// Generate a my.project.Tags class with the version number as a field
tasks.injectTags.configure {
outputClassName.set("io.redstudioragnarok.${project.id}.Tags")
mcVersion = '1.12.2'
username = 'Desoroxxx'
extraRunJvmArguments.addAll('-Xmx6G', '-Xms4G', '-Dforge.logging.console.level=debug', '-Dfml.coreMods.load=dev.redstudio.redcore.RedCore')
}

// Create configuration to include embedded dependencies into the jar
configurations {
implementation
compile.extendsFrom(embed)
}

dependencies {
implementation "net.jafama:jafama:2.3.2"
embed "net.jafama:jafama:2.3.2"
implementation 'net.jafama:jafama:2.3.2'
embed 'net.jafama:jafama:2.3.2'
}

processResources {
inputs.property "id", project.id
inputs.property "version", project.version
filesMatching("mcmod.info") { fcd ->
include "mcmod.info"
fcd.expand (
"id": project.id,
"version": project.version
)
}
dependsOn "compileJava"
buildConfig {
buildConfigField("String", "ID", "\"${project.id}\"")
buildConfigField("String", "VERSION", "\"${project.version}\"")
}

jar {
manifest.attributes([
"ModSide": "BOTH",
"FMLCorePlugin": "io.redstudioragnarok.redcore.asm.RedCorePlugin",
"FMLCorePluginContainsFMLMod": true,
"ForceLoadAsMod": true
'ModSide': 'BOTH',
'FMLCorePlugin': 'dev.redstudio.redcore.RedCore',
'FMLCorePluginContainsFMLMod': true,
'ForceLoadAsMod': true
])

// Add all embedded dependencies into the jar
from(provider{ configurations.embed.collect {it.isDirectory() ? it : zipTree(it)} })

// Add ! to the name of the jar to make sure we get loaded first
jar.archiveBaseName.set("!Red-Core")
from(provider { configurations.embed.collect { it.isDirectory() ? it : zipTree(it) } })
archiveBaseName.set('!Red-Core')
}

idea {
module {
inheritOutputDirs = true
excludeDirs = [
file(".settings"),
file(".github"),
file(".gradle"),
file("gradle"),
file(".idea"),
file("build"),
file("run"),
file("bin")
file('.settings'),
file('.github'),
file('.gradle'),
file('gradle'),
file('.idea'),
file('build'),
file('run'),
file('bin')
]
}

project { settings {
runConfigurations {
"Client"(Gradle) {
taskNames = ["runClient"]
}
"Server"(Gradle) {
taskNames = ["runServer"]
project {
jdkName = '1.8'
languageLevel = '1.8'

settings {
runConfigurations {
'Client'(Gradle) {
taskNames = ['runClient']
}
'Server'(Gradle) {
taskNames = ['runServer']
}
'Obfuscated Client'(Gradle) {
taskNames = ['runObfClient']
}
'Obfuscated Server'(Gradle) {
taskNames = ['runObfServer']
}
'Vanilla Client'(Gradle) {
taskNames = ['runVanillaClient']
}
'Vanilla Server'(Gradle) {
taskNames = ['runVanillaServer']
}
}
"Obfuscated Client"(Gradle) {
taskNames = ["runObfClient"]
}
"Obfuscated Server"(Gradle) {
taskNames = ["runObfServer"]
}
"Vanilla Client"(Gradle) {
taskNames = ["runVanillaClient"]
}
"Vanilla Server"(Gradle) {
taskNames = ["runVanillaServer"]
}
}

compiler.javac {
afterEvaluate {
javacAdditionalOptions = "-encoding utf8"
moduleJavacAdditionalOptions = [ (project.id + ".main"): tasks.compileJava.options.compilerArgs.collect { """ + it + """ }.join(" ") ]
compiler.javac {
afterEvaluate {
javacAdditionalOptions = '-encoding utf8'
moduleJavacAdditionalOptions = [(project.id + '.main'): tasks.compileJava.options.compilerArgs.collect { " $it " }.join(' ')]
}
}
}
}}
}

tasks.named("processIdeaSettings").configure {
dependsOn("injectTags")
}
}
100 changes: 62 additions & 38 deletions src/main/java/dev/redstudio/redcore/RedCore.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package dev.redstudio.redcore;

import dev.redstudio.redcore.ticking.RedClientTickEvent;
import dev.redstudio.redcore.ticking.RedClientTicker;
import dev.redstudio.redcore.utils.ModReference;
import dev.redstudio.redcore.utils.OptiNotFine;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import com.google.common.eventbus.EventBus;
import net.minecraftforge.fml.common.DummyModContainer;
import net.minecraftforge.fml.common.LoadController;
import net.minecraftforge.fml.common.ModMetadata;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;

import javax.annotation.Nullable;
import java.util.Map;

import static dev.redstudio.redcore.utils.ModReference.ID;
import static dev.redstudio.redcore.utils.ModReference.NAME;
import static dev.redstudio.redcore.utils.ModReference.VERSION;

// /$$$$$$$ /$$ /$$$$$$
// | $$__ $$ | $$ /$$__ $$
Expand All @@ -17,39 +21,59 @@
// | $$ \ $$| $$_____/| $$ | $$ | $$ $$| $$ | $$| $$ | $$_____/
// | $$ | $$| $$$$$$$| $$$$$$$ | $$$$$$/| $$$$$$/| $$ | $$$$$$$
// |__/ |__/ \_______/ \_______/ \______/ \______/ |__/ \_______/
@Mod(modid = ModReference.ID, name = ModReference.NAME, version = ModReference.VERSION, updateJSON = "https://raw.githubusercontent.com/Red-Studio-Ragnarok/Red-Core/main/update.json")
public final class RedCore {

private static boolean clientTickerStarted = false;
private static boolean forceOptiFineFastRenderOff = false;

/**
* Starts the client ticker.
* <p>
* This method registers {@link RedClientTicker} in the {@link MinecraftForge} event bus if the client ticker has not already been started.
* <p>
* The client ticker is responsible for ticking and thus sending the {@link RedClientTickEvent}.
*
* @author Desoroxxx
* @since 0.3
*/
@SideOnly(Side.CLIENT)
public static void startClientTicker() {
if (clientTickerStarted)
return;

MinecraftForge.EVENT_BUS.register(RedClientTicker.class);
clientTickerStarted = true;
@IFMLLoadingPlugin.Name(NAME)
@IFMLLoadingPlugin.MCVersion("1.12.2")
@IFMLLoadingPlugin.SortingIndex(Integer.MIN_VALUE + 2)
public final class RedCore implements IFMLLoadingPlugin {

@Override
public String[] getASMTransformerClass() {
return new String[0];
}

@Override
public String getModContainerClass() {
return "dev.redstudio.redcore.RedCore$Container";
}

@Nullable
@Override
public String getSetupClass() {
return null;
}

@SideOnly(Side.CLIENT)
public static void forceOptiFineFastRenderOff() {
if (forceOptiFineFastRenderOff)
return;
@Override
public void injectData(final Map<String, Object> data) {

}

@Override
public String getAccessTransformerClass() {
return null;
}

public static class Container extends DummyModContainer {

public Container() {
super(new ModMetadata());

final ModMetadata modMetadata = this.getMetadata();

startClientTicker();
modMetadata.modId = ID;
modMetadata.name = "Red Core";
modMetadata.description = "§lRed-Core§r\n\nRed-Core is the foundational framework for Red Studio projects and associated projects. It features robust development utilities, streamlined error logging, and a high-speed, clean vectors' suite.\n\n§lFeatures§r\n\n- §lRedLogger:§r This robust error logger elevates error tracking, offering a clean, user-friendly experience that demystifies complex error data.\n- §lVectors:§r Introducing a comprehensive vector suite that is sleek and speedy, continuously evolving with new features as per necessity.\n- §lMathUtil:§r A purpose-built class providing an array of mathematical methods, engineered with a steadfast focus on rapid processing and calculations.\n- §lStopwatch:§r Tailored for precise profiling, this stopwatch sets itself apart in the burgeoning roster of Java-based stopwatch solutions, by its simplicity and easy of use.\n- §lRedClientTicker:§r A useful ticker that allows you to have ticks every 2, 5 or 10 normal ticks, for things that shouldn't run 20 times a second.\n- §lOptiNotFine:§r A must-have when working with OptiFine compatibility, it allows you to know if OptiFine is installed, whether shaders are loaded, and to force fast render off.\n- §lNetworkUtil:§r Designed to streamline network coding practices, this utility makes writing cleaner, safer, and more efficient networking code effortless.\n- §lJafama:§r Red Core embeds Jafama allowing you to use it in your mods\n\n§lWhy Red-Core?§r\n\nRed-Core sits at the heart of Red Studio's Minecraft 1.12 mods, aiming to make your mod development process more efficient. By providing a set of tailored tools and libraries, we allow you to focus more on designing exciting mods and less on the intricacies of development.\n\nWhat sets us apart is our comprehensive Javadoc documentation. We believe good documentation is the cornerstone of effective development. Every method in Red-Core comes with detailed Javadoc comments, making the technical information and guidance you need just a ctrl-click away.\n\nJoin us in enhancing Red-Core! We believe in constant evolution and the power of community-driven development. Whether you're a contributor or a user in the Minecraft modding community, your experience matters. We're here to ensure it's the best it can be.";
modMetadata.url = "https://www.curseforge.com/minecraft/mc-mods/red-core";
modMetadata.updateJSON = "https://raw.githubusercontent.com/Red-Studio-Ragnarok/Red-Core/main/update.json";
modMetadata.logoFile = "/logo.png";
modMetadata.version = VERSION;
modMetadata.authorList.add("Red Studio");
modMetadata.credits = "Desoroxxx";
}

MinecraftForge.EVENT_BUS.register(OptiNotFine.class);
forceOptiFineFastRenderOff = true;
@Override
public boolean registerBus(final EventBus eventBus, final LoadController loadController) {
eventBus.register(this);
return true;
}
}
}
41 changes: 0 additions & 41 deletions src/main/java/dev/redstudio/redcore/asm/RedCorePlugin.java

This file was deleted.

19 changes: 19 additions & 0 deletions src/main/java/dev/redstudio/redcore/ticking/RedClientTicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
@SideOnly(Side.CLIENT)
public class RedClientTicker {

private static boolean clientTickerStarted = false;

private static int biTickCount, pentaTickCount, decaTickCount;

@SubscribeEvent(priority = EventPriority.HIGHEST)
Expand All @@ -41,4 +43,21 @@ public static void onClientTickEvent(TickEvent.ClientTickEvent clientTickEvent)
}
}
}

/**
* Starts the client ticker.
* <p>
* This method registers {@link RedClientTicker} in the {@link MinecraftForge} event bus if the client ticker has not already been started.
* <p>
* The client ticker is responsible for ticking and thus sending the {@link RedClientTickEvent}.
* <p>
* For performance reasons, this should be called on any of the init methods in your mod.
*
* @author Desoroxxx
* @since 0.3
*/
@SideOnly(Side.CLIENT)
public static void startClientTicker() {
MinecraftForge.EVENT_BUS.register(RedClientTicker.class);
}
}
Loading

0 comments on commit 0eed169

Please sign in to comment.