Skip to content

Commit

Permalink
3.0.0
Browse files Browse the repository at this point in the history
Initial release.
  • Loading branch information
Wyvest committed Oct 5, 2021
1 parent a32eb21 commit a7348c7
Show file tree
Hide file tree
Showing 12 changed files with 228 additions and 66 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div align="center">

# Template
# Damage Tint

</div>

## About
Placeholder.
A mod which changes the color of entities that are hurt.

## How to install
Placeholder
## Examples
TODO: add images here lol
29 changes: 23 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id "java"
id "com.github.johnrengelman.shadow" version "6.1.0"
id "net.minecraftforge.gradle.forge" version "ddb1eb0"
id 'org.spongepowered.mixin' version "d5f9873"
}

version = mod_ver
Expand All @@ -19,7 +20,8 @@ minecraft {
replace('@ID@', mod_id)
mappings = "stable_22"
makeObfSourceJar = false
clientRunArgs += '--tweakClass xyz.matthewtgm.requisite.launchwrapper.RequisiteLaunchwrapper'
clientRunArgs += '--mixin mixins.damagetint.json'
clientRunArgs += '--tweakClass gg.essential.loader.stage0.EssentialSetupTweaker'
}

configurations {
Expand All @@ -30,20 +32,22 @@ configurations {

repositories {
mavenCentral()
maven { url 'https://repo.sk1er.club/repository/maven-releases/' }
maven { url 'https://jitpack.io/' }
maven { url 'https://repo.spongepowered.org/repository/maven-public/' }
maven { url 'https://repo.sk1er.club/repository/maven-releases/' }
}

dependencies {
// How to normally add a dependency (If you don't want it to be added to the jar)
// implementation "com.example:example:1.0.0"
// If you would like to include it (have the library inside your jar) instead use
// include "com.example:example:1.0.0"
implementation 'xyz.matthewtgm:Requisite:1.1.1'
include ('xyz.matthewtgm:RequisiteLaunchwrapper:1.1') {
include ('gg.essential:loader-launchwrapper:1.1.1') {
transitive = false
}
implementation 'gg.essential:essential-1.8.9-forge:1495+release-launch'
annotationProcessor 'org.spongepowered:mixin:0.7.11-SNAPSHOT'

}

processResources {
Expand All @@ -68,7 +72,8 @@ jar {
manifest.attributes(
'ModSide': 'CLIENT',
'ForceLoadAsMod': true,
'TweakClass': 'xyz.matthewtgm.requisite.launchwrapper.RequisiteLaunchwrapper',
'MixinConfigs': 'mixins.damagetint.json',
'TweakClass': 'gg.essential.loader.stage0.EssentialSetupTweaker',
)
enabled = false
}
Expand Down Expand Up @@ -109,9 +114,21 @@ shadowJar {

exclude 'fabric.mod.json'
}

mixin {
disableRefMapWarning = true
defaultObfuscationEnv searge
add sourceSets.main, "mixins.damagetint.refmap.json"
}

reobf {
shadowJar {
classpath = sourceSets.main.compileClasspath
}
}
tasks.reobfJar.dependsOn tasks.shadowJar
tasks.reobfJar.dependsOn tasks.shadowJar
sourceSets {
main {
ext.refMap = "mixins.damagetint.refmap.json"
}
}
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
org.gradle.jvmargs=-Xmx4G

mod_name=ForgeTemplate
mod_id=forgetemplate
mod_ver=1.0.0
mod_name=DamageTint
mod_id=damagetint
mod_ver=3.0.0
9 changes: 8 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ pluginManagement {
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == "net.minecraftforge.gradle.forge") useModule("com.github.asbyth:ForgeGradle:${requested.version}")
switch (requested.id.id) {
case 'net.minecraftforge.gradle.forge':
useModule "com.github.asbyth:ForgeGradle:${requested.version}"
break
case 'org.spongepowered.mixin':
useModule "com.github.Skytils:MixinGradle:${requested.version}"
break
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
package xyz.qalcyo.template;
package xyz.qalcyo.damagetint;

import gg.essential.api.EssentialAPI;
import net.minecraft.client.Minecraft;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import xyz.matthewtgm.requisite.util.ChatHelper;
import xyz.qalcyo.template.utils.Updater;
import xyz.qalcyo.damagetint.command.DamageTintCommand;
import xyz.qalcyo.damagetint.config.Config;
import xyz.qalcyo.damagetint.utils.Updater;

import java.io.File;

@Mod(name = ForgeTemplate.NAME, version = ForgeTemplate.VER, modid = ForgeTemplate.ID)
public class ForgeTemplate {
@Mod(name = DamageTint.NAME, version = DamageTint.VER, modid = DamageTint.ID)
public class DamageTint {
public static final String NAME = "@NAME@", VER = "@VER@", ID = "@ID@";
public static File jarFile;
public static File modDir = new File(new File(new File(Minecraft.getMinecraft().mcDataDir, "config"), "Qalcyo"), NAME);
public static void sendMessage(String message) {
ChatHelper.sendMessage(EnumChatFormatting.DARK_PURPLE + "[" + NAME + "]", message);
EssentialAPI.getMinecraftUtil().sendMessage(EnumChatFormatting.DARK_PURPLE + "[" + NAME + "] ", message);
}
public static Config config;
public static DamageTintCommand command;

@Mod.EventHandler
protected void onFMLPreInitialization(FMLPreInitializationEvent event) {
Expand All @@ -27,7 +31,10 @@ protected void onFMLPreInitialization(FMLPreInitializationEvent event) {

@Mod.EventHandler
protected void onInitialization(FMLInitializationEvent event) {
System.out.println("Hello.");
config = new Config();
config.preload();
command = new DamageTintCommand();
command.register();
Updater.update();
}

Expand Down
17 changes: 17 additions & 0 deletions src/main/java/xyz/qalcyo/damagetint/command/DamageTintCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package xyz.qalcyo.damagetint.command;

import gg.essential.api.EssentialAPI;
import gg.essential.api.commands.Command;
import gg.essential.api.commands.DefaultHandler;
import xyz.qalcyo.damagetint.DamageTint;

public class DamageTintCommand extends Command {
public DamageTintCommand() {
super("damagetint", true);
}

@DefaultHandler
public void handle() {
EssentialAPI.getGuiUtil().openScreen(DamageTint.config.gui());
}
}
56 changes: 56 additions & 0 deletions src/main/java/xyz/qalcyo/damagetint/config/Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package xyz.qalcyo.damagetint.config;

import gg.essential.api.EssentialAPI;
import gg.essential.vigilance.Vigilant;
import gg.essential.vigilance.data.Property;
import gg.essential.vigilance.data.PropertyType;
import net.minecraft.client.Minecraft;
import xyz.qalcyo.damagetint.DamageTint;
import xyz.qalcyo.damagetint.gui.DownloadConfirmGui;
import xyz.qalcyo.damagetint.utils.Updater;

import java.awt.*;
import java.io.File;

public class Config extends Vigilant {
@Property(
type = PropertyType.SWITCH,
name = "Toggle Mod",
description = "Toggle the mod's functionality.",
category = "General"
)
public static boolean toggle = true;

@Property(
type = PropertyType.COLOR,
name = "Damage Tint Colour",
description = "Modify the damage tint when mobs take damage.",
category = "General",
allowAlpha = false
)
public static Color color = Color.RED;

@Property(
type = PropertyType.SWITCH,
name = "Show Update Notification",
description = "Show a notification when you start Minecraft informing you of new updates.",
category = "Updater"
)
public static boolean showUpdate = true;

@Property(
type = PropertyType.BUTTON,
name = "Update Now",
description = "Update by clicking the button.",
category = "Updater"
)
public void update() {
if (Updater.shouldUpdate) EssentialAPI.getGuiUtil()
.openScreen(new DownloadConfirmGui(Minecraft.getMinecraft().currentScreen)); else EssentialAPI.getNotifications()
.push("Damage Tint", "No update had been detected at startup, and thus the update GUI has not been shown.");
}

public Config() {
super(new File(DamageTint.modDir, "damagetint.toml"), "Damage Tint");
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package xyz.qalcyo.template.gui;
package xyz.qalcyo.damagetint.gui;

import gg.essential.api.EssentialAPI;
import gg.essential.api.utils.Multithreading;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.EnumChatFormatting;
import org.apache.commons.lang3.StringUtils;
import xyz.matthewtgm.requisite.util.GuiHelper;
import xyz.matthewtgm.requisite.util.Multithreading;
import xyz.matthewtgm.requisite.util.Notifications;
import xyz.qalcyo.template.ForgeTemplate;
import xyz.qalcyo.template.utils.Updater;
import xyz.qalcyo.damagetint.DamageTint;
import xyz.qalcyo.damagetint.utils.Updater;

import java.io.File;

public class DownloadConfirmGui extends GuiScreen {
private final GuiScreen parent;

public DownloadConfirmGui(GuiScreen parent) {
this.parent = parent;
}
Expand All @@ -29,31 +29,31 @@ public void initGui() {
@Override
public void actionPerformed(GuiButton button) {
switch (button.id) {
case 1:
GuiHelper.open(null);
case 0:
EssentialAPI.getGuiUtil().openScreen(parent);
Multithreading.runAsync(() -> {
if (Updater.download(
Updater.updateUrl,
new File("mods/" + ForgeTemplate.NAME + "-" + StringUtils.substringAfter(Updater.latestTag, "v") + ".jar")
new File("mods/" + DamageTint.NAME + "-" + StringUtils.substringAfter(Updater.latestTag, "v") + ".jar")
) && Updater.download(
"https://github.com/Qalcyo/Deleter/releases/download/v1.2/Deleter-1.2.jar",
new File(ForgeTemplate.modDir.getParentFile(), "Deleter-1.2.jar")
new File(DamageTint.modDir.getParentFile(), "Deleter-1.2.jar")
)
) {
Notifications
.push(ForgeTemplate.NAME, "The ingame updater has successfully installed the newest version.");
EssentialAPI.getNotifications()
.push(DamageTint.NAME, "The ingame updater has successfully installed the newest version.");
Updater.addShutdownHook();
Updater.shouldUpdate = false;
} else {
Notifications.push(
ForgeTemplate.NAME,
EssentialAPI.getNotifications().push(
DamageTint.NAME,
"The ingame updater has NOT installed the newest version as something went wrong."
);
}
});
break;
case 2:
GuiHelper.open(parent);
case 1:
EssentialAPI.getGuiUtil().openScreen(parent);
}
}

Expand All @@ -64,7 +64,7 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
GlStateManager.scale(2f, 2f, 0f);
drawCenteredString(
fontRendererObj,
EnumChatFormatting.DARK_PURPLE + ForgeTemplate.NAME,
EnumChatFormatting.DARK_PURPLE + DamageTint.NAME,
width / 4,
3,
-1
Expand All @@ -75,7 +75,7 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
String[] lines = new String[]{
"Are you sure you want to update?",
"You can download it ingame at any time via the configuration screen.",
"(This will update from v" + ForgeTemplate.VER + " to " + Updater.latestTag + ")"
"(This will update from v" + DamageTint.VER + " to " + Updater.latestTag + ")"
};
int offset = Math.max(85 - lines.length * 10, 10);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package xyz.qalcyo.damagetint.mixin;

import net.minecraft.client.renderer.entity.RendererLivingEntity;
import net.minecraft.entity.EntityLivingBase;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
import xyz.qalcyo.damagetint.config.Config;

@Mixin(RendererLivingEntity.class)
public class RendererLivingEntityMixin {
private boolean flag = false;
private int count;
@Inject(method = "setBrightness", at = @At("HEAD"))
private void set(EntityLivingBase entitylivingbaseIn, float partialTicks, boolean combineTextures, CallbackInfoReturnable<Boolean> cir) {
flag = (entitylivingbaseIn.hurtTime > 0 || entitylivingbaseIn.deathTime > 0) && Config.toggle;
count = 0;
}
@ModifyArgs(method = "setBrightness", at = @At(value = "INVOKE", target = "Ljava/nio/FloatBuffer;put(F)Ljava/nio/FloatBuffer;"))
private void returnColor(Args args) {
if (flag) {
float arg = args.get(0);
if (arg == 1.0F) {
//red
args.set(0, ((float) Config.color.getRed()) / 255);
} else if (arg == 0.0F) {
//blue / green
++count;
if (count == 1) {
args.set(0, ((float) Config.color.getGreen()) / 255);
} else {
args.set(0, ((float) Config.color.getBlue()) / 255);
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xyz.qalcyo.template.utils;
package xyz.qalcyo.damagetint.utils;

import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
Expand All @@ -13,7 +13,7 @@
import org.apache.http.impl.client.HttpClients;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
import xyz.qalcyo.template.ForgeTemplate;
import xyz.qalcyo.damagetint.DamageTint;

import java.net.URI;
import java.util.Scanner;
Expand All @@ -26,7 +26,7 @@ public class APIUtil {

private static final JsonParser parser = new JsonParser();

public static final HttpClientBuilder builder = HttpClients.custom().setUserAgent(ForgeTemplate.ID + "/" + ForgeTemplate.VER)
public static final HttpClientBuilder builder = HttpClients.custom().setUserAgent(DamageTint.ID + "/" + DamageTint.VER)
.addInterceptorFirst(((HttpRequest request, HttpContext context) -> {
if (!request.containsHeader("Pragma")) request.addHeader("Pragma", "no-cache");
if (!request.containsHeader("Cache-Control")) request.addHeader("Cache-Control", "no-cache");
Expand Down
Loading

0 comments on commit a7348c7

Please sign in to comment.