Skip to content

Commit

Permalink
Added compatibility layer for mods using older versions
Browse files Browse the repository at this point in the history
At least I do not need to face transition hell anymore
  • Loading branch information
Desoroxxx committed Oct 6, 2023
1 parent 0088ed6 commit 3768ce2
Show file tree
Hide file tree
Showing 19 changed files with 1,264 additions and 10 deletions.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ Red Core and its Minecraft parts have been separated into two, this allows for g
- `MathUtil` is now under `utils.math`
- Separated `MathUtil` clamping methods into their own class `ClampUtil`
- Changed GroupId from `io.redstudioragnarok` to `dev.redstudio`
- Made `RedLogger#RANDOM` private

### Removed

- Removed `Stopwatch` :sob: it wasn't that good or useful but was fun to make

### Fixed

- Fixed inconsistent argument naming in `MathUtil#lerp`

### Internal

- Switched to [gradle-buildconfig-plugin](https://github.com/gmazzo/gradle-buildconfig-plugin) entirely for project constants
Expand Down
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ allprojects {
// Azul covers the most platforms for Java 8 toolchains, crucially including macOS arm64
vendor.set(JvmVendorSpec.AZUL)
}
withJavadocJar()
// Generate sources jar when building
withSourcesJar()
}

tasks.withType<JavaCompile>().configureEach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
public class RedLogger {

public static final Random RANDOM = new Random();
private static final Random RANDOM = new Random();

/**
* A list of recomfort messages to be displayed when an error occurs.
Expand Down Expand Up @@ -86,7 +86,7 @@ public RedLogger(final String modName, final String newIssueLink, final Logger l
*
* @deprecated Use a String instead of an URI for the newIssueLink parameter. To be removed in 0.4
*/
@Deprecated // Use a String instead of an URI for the newIssueLink parameter. To be removed in 0.4
@Deprecated // Use a String instead of an URI for the newIssueLink parameter. Todo: Removed in 0.4
public RedLogger(final String modName, final URI newIssueLink, final Logger logger, final String... customRecomfortMessages) {
this.modName = modName;
this.newIssueLink = newIssueLink.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @author Desoroxxx
* @since 0.2
*/
@SuppressWarnings({"unused"})
@SuppressWarnings("unused")
public final class MathUtil {

/**
Expand Down Expand Up @@ -176,13 +176,13 @@ public static float lerp(final float startValue, final float partialTicks, final
/**
* Performs a linear interpolation between two values.
*
* @param input The starting value.
* @param startValue The starting value.
* @param partialTicks The fraction of the tick that has passed.
* @param target The target value.
* @param targetValue The target value.
* @return The interpolated value.
*/
public static double lerp(final double input, final double partialTicks, final double target) {
return input + (target - input) * partialTicks;
public static double lerp(final double startValue, final double partialTicks, final double targetValue) {
return startValue + (targetValue - startValue) * partialTicks;
}

/**
Expand Down
7 changes: 6 additions & 1 deletion mc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ tasks.named<Jar>("jar") {
)
}

archiveBaseName = "!Red-Core-1.12"
archiveBaseName = "!Red-Core-1.12.2"
}

tasks.named<Jar>("sourcesJar") {
archiveBaseName.set("!Red-Core-1.12.2")
}


publishing.publications.register("redCoreMc", MavenPublication::class) {
from(components["java"])

Expand Down
3 changes: 2 additions & 1 deletion mc/src/main/java/dev/redstudio/redcore/RedCorePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import javax.annotation.Nullable;
import java.util.Map;

import static dev.redstudio.redcore.ProjectConstants.*;
import static dev.redstudio.redcore.ProjectConstants.NAME;
import static dev.redstudio.redcore.ProjectConstants.VERSION;

// /$$$$$$$ /$$ /$$$$$$ /$$ /$$ /$$$$$$
// | $$__ $$ | $$ /$$__ $$ | $$$ /$$$ /$$__ $$
Expand Down
33 changes: 33 additions & 0 deletions mc/src/main/java/io/redstudioragnarok/redcore/RedCore.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.redstudioragnarok.redcore;

import dev.redstudio.redcore.utils.OptiNotFine;
import io.redstudioragnarok.redcore.ticking.RedClientTicker;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

/**
* @author Luna Lage (Desoroxxx)
* @deprecated See methods for details.
*/
@Deprecated
public final class RedCore {

/**
* @deprecated Use {@link dev.redstudio.redcore.ticking.RedClientTicker#startClientTicker}
*/
@Deprecated
@SideOnly(Side.CLIENT)
public static void startClientTicker() {
MinecraftForge.EVENT_BUS.register(RedClientTicker.class);
}

/**
* @deprecated Use {@link OptiNotFine#forceOptiFineFastRenderOff}
*/
@Deprecated
@SideOnly(Side.CLIENT)
public static void forceOptiFineFastRenderOff() {
OptiNotFine.forceOptiFineFastRenderOff();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package io.redstudioragnarok.redcore.logging;

import org.apache.logging.log4j.Logger;

import java.net.URI;
import java.util.Random;

/**
* @author Luna Lage (Desoroxxx)
* @deprecated See methods for details.
*/
@Deprecated
public final class RedLogger extends dev.redstudio.redcore.logging.RedLogger {

/**
* @deprecated Use your own random
*/
@Deprecated
public static final Random RANDOM = new Random();

/**
* @deprecated Use {@link dev.redstudio.redcore.logging.RedLogger#RedLogger(String, String, Logger, String...)}
*/
@Deprecated
public RedLogger(final String modName, final String newIssueLink, final Logger logger, final String... customRecomfortMessages) {
super(modName, newIssueLink, logger, customRecomfortMessages);
}

/**
* @deprecated Use {@link dev.redstudio.redcore.logging.RedLogger#RedLogger(String, URI, Logger, String...)}
*/
@Deprecated
public RedLogger(final String modName, final URI newIssueLink, final Logger logger, final String... customRecomfortMessages) {
super(modName, newIssueLink, logger, customRecomfortMessages);
}

/**
* @deprecated Use {@link dev.redstudio.redcore.logging.RedLogger#printFramedError}
*/
@Override
@Deprecated
public void printFramedError(final String category, final String whatHappened, final String whatNow, final String... additionalInformation) {
super.printFramedError(category, whatHappened, whatNow, additionalInformation);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package io.redstudioragnarok.redcore.ticking;

import net.minecraftforge.fml.common.eventhandler.Event;

/**
* @author Luna Lage (Desoroxxx)
* @deprecated See methods for details.
*/
@Deprecated
public class RedClientTickEvent extends Event {

/**
* @deprecated Use {@link dev.redstudio.redcore.ticking.RedClientTickEvent.BiTickEvent}
*/
@Deprecated
public static class BiTickEvent extends RedClientTickEvent {

/**
* @deprecated Use {@link dev.redstudio.redcore.ticking.RedClientTickEvent.BiTickEvent#BiTickEvent()}
*/
@Deprecated
public BiTickEvent() {
}
}

/**
* @deprecated Use {@link dev.redstudio.redcore.ticking.RedClientTickEvent.PentaTickEvent}
*/
@Deprecated
public static class PentaTickEvent extends RedClientTickEvent {

/**
* @deprecated Use {@link dev.redstudio.redcore.ticking.RedClientTickEvent.PentaTickEvent#PentaTickEvent()}
*/
@Deprecated
public PentaTickEvent() {
}
}

/**
* @deprecated Use {@link dev.redstudio.redcore.ticking.RedClientTickEvent.DecaTickEvent}
*/
@Deprecated
public static class DecaTickEvent extends RedClientTickEvent {

/**
* @deprecated Use {@link dev.redstudio.redcore.ticking.RedClientTickEvent.DecaTickEvent#DecaTickEvent()}
*/
@Deprecated
public DecaTickEvent() {
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package io.redstudioragnarok.redcore.ticking;

import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;

/**
* @author Luna Lage (Desoroxxx)
* @deprecated See methods for details.
*/
@Deprecated
public class RedClientTicker {

private static int biTickCount, pentaTickCount, decaTickCount;

/**
* @deprecated Use {@link dev.redstudio.redcore.ticking.RedClientTicker#onClientTickEvent}
*/
@Deprecated
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void onClientTickEvent(TickEvent.ClientTickEvent clientTickEvent) {
if (clientTickEvent.phase == TickEvent.Phase.START) {

biTickCount++;
if (biTickCount == 2) {
MinecraftForge.EVENT_BUS.post(new RedClientTickEvent.BiTickEvent());
biTickCount = 0;
}

pentaTickCount++;
if (pentaTickCount == 5) {
MinecraftForge.EVENT_BUS.post(new RedClientTickEvent.PentaTickEvent());
pentaTickCount = 0;
}

decaTickCount++;
if (decaTickCount == 10) {
MinecraftForge.EVENT_BUS.post(new RedClientTickEvent.DecaTickEvent());
decaTickCount = 0;
}
}
}
}
Loading

0 comments on commit 3768ce2

Please sign in to comment.