Skip to content

Commit

Permalink
Backport from 1.20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dima-dencep committed Jan 31, 2024
1 parent 1aeb549 commit db968eb
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 65 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ jobs:

github-token: ${{ secrets.GITHUB_TOKEN }}

name: "[NeoForge ${{ steps.read_property.outputs.minecraft_version }}] v${{ steps.read_property.outputs.mod_version }}"
name: "[(Neo)Forge ${{ steps.read_property.outputs.minecraft_version }}] v${{ steps.read_property.outputs.mod_version }}"

changelog: ${{steps.build_changelog.outputs.changelog}}

version-type: release

loaders: |
forge
neoforge
game-versions: |
Expand Down
22 changes: 16 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ group = project.maven_group

loom {
accessWidenerPath = file("src/main/resources/sodium-extra.accesswidener")

forge {
convertAccessWideners = true

mixinConfigs = [
"sodium-extra.mixins.json"
]
}
}

repositories {
Expand All @@ -38,12 +46,18 @@ dependencies {
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
neoForge "net.neoforged:neoforge:${project.loader_version}"
forge "net.minecraftforge:forge:${project.loader_version}"

modImplementation "org.embeddedt:embeddium-${project.minecraft_version}:${project.embeddium_version}"
modCompileOnly "maven.modrinth:oculus:${project.oculus_version}"

implementation include("com.github.dima_dencep.mods:NanoLiveConfig:${project.nanoliveconfig_version}")
implementation(annotationProcessor("io.github.llamalad7:mixinextras-common:${project.mixinextras_version}"))
implementation(include("io.github.llamalad7:mixinextras-forge:${project.mixinextras_version}"))

implementation(forgeRuntimeLibrary(include("com.github.dima_dencep.mods:NanoLiveConfig:${project.nanoliveconfig_version}") {
exclude(group: "dev.su5ed.sinytra.fabric-api")
exclude(group: "dev.su5ed.sinytra")
}))
}

processResources {
Expand All @@ -66,10 +80,6 @@ java {
withSourcesJar()
}

remapJar {
atAccessWideners.add(loom.accessWidenerPath.get().asFile.name)
}

jar {
from "LICENSE.txt"
}
Expand Down
13 changes: 7 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ org.gradle.jvmargs=-Xmx1G
# this will enable us to use the "forge" dependency.
# using archloom without this is possible and will give you a
# "standard" loom installation with some extra features.
loom.platform = neoforge
loom.platform = forge

# Forge Properties
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=20.4.146-beta
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=1.20.1-47.1.3

# Mod Properties
mod_version=0.5.4
maven_group=com.github.dima_dencep.mods
archives_base_name=rubidium-extra

# Dependencies
nanoliveconfig_version=2.2.0
nanoliveconfig_version=1.2.0
oculus_version=1.20.1-1.6.9
embeddium_version=0.3.0-git.759ddab+mc1.20.4
embeddium_version=0.3.0-git.abf0fe6+mc1.20.1
mixinextras_version=0.3.5
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package me.flashyreese.mods.sodiumextra;

import net.neoforged.fml.common.Mod;
import net.minecraftforge.fml.common.Mod;

@Mod(EmbeddiumExtraMod.MOD_ID)
public final class EmbeddiumExtraMod {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import me.flashyreese.mods.sodiumextra.EmbeddiumExtraMod;
import com.google.common.collect.EvictingQueue;
import me.flashyreese.mods.sodiumextra.mixin.gui.MinecraftClientAccessor;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.neoforge.event.TickEvent;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import java.util.Queue;
import java.util.stream.IntStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import me.flashyreese.mods.sodiumextra.client.gui.SodiumExtraGameOptions;
import net.caffeinemc.caffeineconfig.CaffeineConfig;
import net.neoforged.fml.loading.FMLPaths;
import net.minecraftforge.fml.loading.FMLPaths;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;

Expand All @@ -21,7 +21,7 @@ public static SodiumExtraGameOptions options() {

public static CaffeineConfig mixinConfig() {
if (MIXIN_CONFIG == null) {
MIXIN_CONFIG = CaffeineConfig.builder("Sodium Extra").withSettingsKey("embeddium_extra", "sodium-extra:options")
MIXIN_CONFIG = CaffeineConfig.builder("Sodium Extra").withSettingsKey("sodium-extra:options")
.addMixinOption("adaptive_sync", true)
.addMixinOption("animation", true)
.addMixinOption("biome_colors", true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import net.minecraft.client.gui.DrawContext;
import net.minecraft.text.Text;
import net.minecraft.util.math.Vec3d;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.neoforge.client.event.RenderGuiEvent;
import net.neoforged.neoforge.event.TickEvent;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.RenderGuiEvent;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import java.util.List;

Expand Down Expand Up @@ -58,7 +58,7 @@ public static void onStartTick(TickEvent.ClientTickEvent client) {
}
@SubscribeEvent
public static void onHudRender(RenderGuiEvent.Post event) {
if (!CLIENT.getDebugHud().shouldShowDebugHud()) {
if (!CLIENT.hasReducedDebugInfo()) {
SodiumExtraGameOptions.OverlayCorner overlayCorner = SodiumExtraClientMod.options().extraSettings.overlayCorner;
// Calculate starting position based on the overlay corner
int x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ public boolean mouseReleased(double mouseX, double mouseY, int button) {
}

@Override
public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount) {
if (super.mouseScrolled(mouseX, mouseY, horizontalAmount, verticalAmount)) {
public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
if (super.mouseScrolled(mouseX, mouseY, amount)) {
return true;
}
if (this.canScroll) {
return this.scrollBar.mouseScrolled(mouseX, mouseY, horizontalAmount, verticalAmount);
return this.scrollBar.mouseScrolled(mouseX, mouseY, amount);
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double del
}

@Override
public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount) {
public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
if (this.dim.containsCursor(mouseX, mouseY) || this.extendedScrollArea != null && this.extendedScrollArea.containsCursor(mouseX, mouseY)) {
if (this.offset <= this.maxScrollBarOffset && this.offset >= 0) {
int value = (int) (this.offset - verticalAmount * 6); // todo: horizontalAmount
int value = (int) (this.offset - amount * 6); // todo: horizontalAmount
this.setOffset(value);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import net.coderbot.iris.vertices.IrisVertexFormats;
import net.irisshaders.iris.api.v0.IrisApi;
import net.minecraft.client.render.VertexFormat;
import net.neoforged.fml.loading.LoadingModList;
import net.minecraftforge.fml.loading.LoadingModList;

public class IrisCompat {
private static final boolean irisPresent = LoadingModList.get().getModFileById("oculus") != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod;
import me.flashyreese.mods.sodiumextra.client.gui.SodiumExtraGameOptions;
import net.neoforged.neoforge.client.ClientHooks;
import net.minecraftforge.client.ForgeHooksClient;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(value = ClientHooks.class, remap = false)
@Mixin(value = ForgeHooksClient.class, remap = false)
public class ForgeHooksClientMixin {
@ModifyExpressionValue(
method = "onFogRender",
at = @At(
value = "INVOKE",
target = "Lnet/neoforged/neoforge/client/event/ViewportEvent$RenderFog;isCanceled()Z"
target = "Lnet/minecraftforge/eventbus/api/IEventBus;post(Lnet/minecraftforge/eventbus/api/Event;)Z"
)
)
private static boolean rubidiumextra$cancel(boolean original) { // If the rubidium-extra were to work the event normally, it would canceling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public abstract class MixinBackgroundRenderer {
method = "applyFog",
at = @At(
value = "INVOKE",
target = "Lnet/neoforged/neoforge/client/ClientHooks;onFogRender(Lnet/minecraft/client/render/BackgroundRenderer$FogType;Lnet/minecraft/client/render/CameraSubmersionType;Lnet/minecraft/client/render/Camera;FFFFLnet/minecraft/client/render/FogShape;)V",
target = "Lnet/minecraftforge/client/ForgeHooksClient;onFogRender(Lnet/minecraft/client/render/BackgroundRenderer$FogType;Lnet/minecraft/client/render/CameraSubmersionType;Lnet/minecraft/client/render/Camera;FFFFLnet/minecraft/client/render/FogShape;)V",
shift = At.Shift.BY
)
)
Expand Down Expand Up @@ -61,7 +61,7 @@ private static void applyFogBase(Camera camera, BackgroundRenderer.FogType fogTy
method = "applyFog",
at = @At(
value = "INVOKE",
target = "Lnet/neoforged/neoforge/client/ClientHooks;onFogRender(Lnet/minecraft/client/render/BackgroundRenderer$FogType;Lnet/minecraft/client/render/CameraSubmersionType;Lnet/minecraft/client/render/Camera;FFFFLnet/minecraft/client/render/FogShape;)V"
target = "Lnet/minecraftforge/client/ForgeHooksClient;onFogRender(Lnet/minecraft/client/render/BackgroundRenderer$FogType;Lnet/minecraft/client/render/CameraSubmersionType;Lnet/minecraft/client/render/Camera;FFFFLnet/minecraft/client/render/FogShape;)V"
),
index = 5
)
Expand All @@ -77,7 +77,7 @@ private static float applyFogModCompatStart(float fogStart, @Share("rbSetFog") L
method = "applyFog",
at = @At(
value = "INVOKE",
target = "Lnet/neoforged/neoforge/client/ClientHooks;onFogRender(Lnet/minecraft/client/render/BackgroundRenderer$FogType;Lnet/minecraft/client/render/CameraSubmersionType;Lnet/minecraft/client/render/Camera;FFFFLnet/minecraft/client/render/FogShape;)V"
target = "Lnet/minecraftforge/client/ForgeHooksClient;onFogRender(Lnet/minecraft/client/render/BackgroundRenderer$FogType;Lnet/minecraft/client/render/CameraSubmersionType;Lnet/minecraft/client/render/Camera;FFFFLnet/minecraft/client/render/FogShape;)V"
),
index = 6
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package me.flashyreese.mods.sodiumextra.mixin.steady_debug_hud;

import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.DebugHud;
import net.minecraft.util.Util;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.ArrayList;
import java.util.List;

@Mixin(DebugHud.class)
@Mixin(targets = "net.minecraftforge.client.gui.overlay.ForgeGui$ForgeDebugScreenOverlay")
public abstract class MixinDebugHud {

@Unique
Expand All @@ -27,39 +24,51 @@ public abstract class MixinDebugHud {
@Unique
private boolean rebuild = true;

@Shadow
protected abstract void drawText(DrawContext context, List<String> text, boolean left);

@Inject(method = "render", at = @At(value = "HEAD"))
public void preRender(DrawContext context, CallbackInfo ci) {
@Inject(method = "update", remap = false, at = @At(value = "HEAD"), cancellable = true)
public void preRender(CallbackInfo ci) {
if (SodiumExtraClientMod.options().extraSettings.steadyDebugHud) {
final long currentTime = Util.getMeasuringTimeMs();
if (currentTime > this.nextTime) {
this.rebuild = true;
this.nextTime = currentTime + (SodiumExtraClientMod.options().extraSettings.steadyDebugHudRefreshInterval * 50L);
} else {
this.rebuild = false;
ci.cancel();
}
} else {
this.rebuild = true;
}
}

@Redirect(method = "drawGameInformation", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/DebugHud;drawText(Lnet/minecraft/client/gui/DrawContext;Ljava/util/List;Z)V"))
public void sodiumExtra$redirectDrawLeftText(DebugHud instance, DrawContext context, List<String> text, boolean left) {
@Inject(method = "getLeft", remap = false, at = @At(value = "HEAD"), cancellable = true)
public void sodiumExtra$getLeftText0(CallbackInfoReturnable<List<String>> cir) {
if (!this.rebuild) {
cir.setReturnValue(this.leftTextCache);
}
}

@Inject(method = "getLeft", remap = false, at = @At(value = "RETURN"))
public void sodiumExtra$getLeftText1(CallbackInfoReturnable<List<String>> cir) {
if (this.rebuild) {
this.leftTextCache.clear();
this.leftTextCache.addAll(text);
this.leftTextCache.addAll(cir.getReturnValue());
}
this.drawText(context, this.leftTextCache, left);
}

@Redirect(method = "drawSystemInformation", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/DebugHud;drawText(Lnet/minecraft/client/gui/DrawContext;Ljava/util/List;Z)V"))
public void sodiumExtra$redirectDrawRightText(DebugHud instance, DrawContext context, List<String> text, boolean left) {
@Inject(method = "getRight", remap = false, at = @At(value = "HEAD"), cancellable = true)
public void sodiumExtra$getRightText0(CallbackInfoReturnable<List<String>> cir) {
if (!this.rebuild) {
cir.setReturnValue(this.rightTextCache);
}

}

@Inject(method = "getRight", remap = false, at = @At(value = "RETURN"))
public void sodiumExtra$getRightText1(CallbackInfoReturnable<List<String>> cir) {
if (this.rebuild) {
this.rightTextCache.clear();
this.rightTextCache.addAll(text);
this.rightTextCache.addAll(cir.getReturnValue());
}
this.drawText(context, this.rightTextCache, left);

}
}
15 changes: 6 additions & 9 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,23 @@ displayURL = "https://curseforge.com/minecraft/mc-mods/rubidium-extra"
description = "Features that shouldn't be in Embeddium."
provides = ["sodium-extra", "sodium_extra"]

[[mixins]]
config = "sodium-extra.mixins.json"

[[dependencies.embeddium_extra]]
modId = "neoforge"
type = "required"
versionRange = "[20.4.114-beta,)"
modId = "forge"
mandatory = true
versionRange = "[47.1.3,)"
ordering = "NONE"
side = "BOTH"

[[dependencies.embeddium_extra]]
modId = "embeddium"
type = "required"
mandatory = true
versionRange = "*"
ordering = "NONE"
side = "CLIENT"

[[dependencies.embeddium_extra]]
modId = "minecraft"
type = "required"
versionRange = "[1.20.4,)"
mandatory = true
versionRange = "[1.20.1,)"
ordering = "NONE"
side = "CLIENT"

0 comments on commit db968eb

Please sign in to comment.