mirror of
https://github.com/AlmostReliable/almostunified.git
synced 2024-11-14 19:25:13 -05:00
1.19.2 backports
- remove unnecessary gradle tasks - don't publish common module in dependencies - move REI plugin to common - use JEI tooltip renderer for recipe indicator
This commit is contained in:
parent
b72fda2756
commit
944ce27ac9
8 changed files with 25 additions and 144 deletions
|
@ -3,6 +3,7 @@
|
||||||
val junitVersion: String by project
|
val junitVersion: String by project
|
||||||
val minecraftVersion: String by project
|
val minecraftVersion: String by project
|
||||||
val fabricLoaderVersion: String by project
|
val fabricLoaderVersion: String by project
|
||||||
|
val reiVersion: String by project
|
||||||
val jeiVersion: String by project
|
val jeiVersion: String by project
|
||||||
val kubejsVersion: String by project
|
val kubejsVersion: String by project
|
||||||
val mappingsChannel: String by project
|
val mappingsChannel: String by project
|
||||||
|
@ -22,15 +23,11 @@ base {
|
||||||
}
|
}
|
||||||
|
|
||||||
loom {
|
loom {
|
||||||
shareCaches()
|
|
||||||
remapArchives.set(false)
|
remapArchives.set(false)
|
||||||
setupRemappedVariants.set(false);
|
setupRemappedVariants.set(false)
|
||||||
runConfigs.configureEach {
|
runConfigs.configureEach {
|
||||||
ideConfigGenerated(false)
|
ideConfigGenerated(false)
|
||||||
}
|
}
|
||||||
mixin {
|
|
||||||
useLegacyMixinAp.set(false)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -42,6 +39,7 @@ dependencies {
|
||||||
parchment("org.parchmentmc.data:$mappingsChannel-$minecraftVersion.2:$mappingsVersion@zip")
|
parchment("org.parchmentmc.data:$mappingsChannel-$minecraftVersion.2:$mappingsVersion@zip")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api:$reiVersion") // required for common rei plugin
|
||||||
modCompileOnly("mezz.jei:jei-$minecraftVersion-common:$jeiVersion") // required for common jei plugin and mixin
|
modCompileOnly("mezz.jei:jei-$minecraftVersion-common:$jeiVersion") // required for common jei plugin and mixin
|
||||||
modCompileOnly("dev.latvian.mods:kubejs:$kubejsVersion") // required for common kubejs plugin
|
modCompileOnly("dev.latvian.mods:kubejs:$kubejsVersion") // required for common kubejs plugin
|
||||||
|
|
||||||
|
@ -51,14 +49,6 @@ dependencies {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
// TODO: test if this is necessary
|
|
||||||
processResources {
|
|
||||||
val buildProps = project.properties
|
|
||||||
|
|
||||||
filesMatching("pack.mcmeta") {
|
|
||||||
expand(buildProps)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
withType<Test> {
|
withType<Test> {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.almostreliable.unified.compat;
|
package com.almostreliable.unified.compat;
|
||||||
|
|
||||||
|
import com.almostreliable.unified.AlmostUnifiedPlatform;
|
||||||
|
import com.almostreliable.unified.Platform;
|
||||||
import com.almostreliable.unified.config.Config;
|
import com.almostreliable.unified.config.Config;
|
||||||
import com.almostreliable.unified.config.UnifyConfig;
|
import com.almostreliable.unified.config.UnifyConfig;
|
||||||
import com.almostreliable.unified.recipe.CRTLookup;
|
import com.almostreliable.unified.recipe.CRTLookup;
|
||||||
|
@ -30,6 +32,9 @@ public class AlmostREI implements REIClientPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerEntries(EntryRegistry registry) {
|
public void registerEntries(EntryRegistry registry) {
|
||||||
|
// REI compat layer will automatically hide entries for Forge through JEI
|
||||||
|
if (AlmostUnifiedPlatform.INSTANCE.getPlatform() == Platform.FORGE) return;
|
||||||
|
|
||||||
UnifyConfig config = Config.load(UnifyConfig.NAME, new UnifyConfig.Serializer());
|
UnifyConfig config = Config.load(UnifyConfig.NAME, new UnifyConfig.Serializer());
|
||||||
if (config.reiOrJeiDisabled()) return;
|
if (config.reiOrJeiDisabled()) return;
|
||||||
|
|
|
@ -5,7 +5,6 @@ import com.almostreliable.unified.utils.Utils;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiComponent;
|
import net.minecraft.client.gui.GuiComponent;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.client.renderer.Rect2i;
|
import net.minecraft.client.renderer.Rect2i;
|
||||||
|
@ -52,13 +51,4 @@ public final class RecipeIndicator {
|
||||||
GuiComponent.blit(poseStack, 0, 0, 0, 0, SIZE, SIZE, SIZE, SIZE);
|
GuiComponent.blit(poseStack, 0, 0, 0, 0, SIZE, SIZE, SIZE, SIZE);
|
||||||
poseStack.popPose();
|
poseStack.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renderTooltip(PoseStack poseStack, Rect2i area, int mX, int mY, ClientRecipeLink link) {
|
|
||||||
var screen = Minecraft.getInstance().screen;
|
|
||||||
if (screen == null) return;
|
|
||||||
if (mX >= area.getX() && mX <= area.getX() + area.getWidth() &&
|
|
||||||
mY >= area.getY() && mY <= area.getY() + area.getHeight()) {
|
|
||||||
screen.renderComponentTooltip(poseStack, constructTooltip(link), mX, mY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.almostreliable.unified.recipe.CRTLookup;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import mezz.jei.api.gui.drawable.IDrawable;
|
import mezz.jei.api.gui.drawable.IDrawable;
|
||||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||||
|
import mezz.jei.common.gui.TooltipRenderer;
|
||||||
import mezz.jei.common.gui.recipes.layout.RecipeLayout;
|
import mezz.jei.common.gui.recipes.layout.RecipeLayout;
|
||||||
import net.minecraft.client.renderer.Rect2i;
|
import net.minecraft.client.renderer.Rect2i;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
@ -37,6 +38,9 @@ public abstract class JeiRecipeLayoutMixin<R> {
|
||||||
var posY = y - RecipeIndicator.SIZE / 2 - RECIPE_BORDER_PADDING + 1;
|
var posY = y - RecipeIndicator.SIZE / 2 - RECIPE_BORDER_PADDING + 1;
|
||||||
var area = new Rect2i(posX, posY, 10, 10);
|
var area = new Rect2i(posX, posY, 10, 10);
|
||||||
RecipeIndicator.renderIndicator(stack, area);
|
RecipeIndicator.renderIndicator(stack, area);
|
||||||
RecipeIndicator.renderTooltip(stack, area, mX, mY, link);
|
if (mX >= area.getX() && mX <= area.getX() + area.getWidth() &&
|
||||||
|
mY >= area.getY() && mY <= area.getY() + area.getHeight()) {
|
||||||
|
TooltipRenderer.drawHoveringText(stack, RecipeIndicator.constructTooltip(link), mX, mY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,6 @@ base {
|
||||||
}
|
}
|
||||||
|
|
||||||
loom {
|
loom {
|
||||||
shareCaches()
|
|
||||||
|
|
||||||
runs {
|
runs {
|
||||||
named("client") {
|
named("client") {
|
||||||
client()
|
client()
|
||||||
|
@ -49,7 +47,7 @@ loom {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":Common", "namedElements")) { isTransitive = false }
|
compileOnly(project(":Common", "namedElements")) { isTransitive = false }
|
||||||
|
|
||||||
minecraft("com.mojang:minecraft:$minecraftVersion")
|
minecraft("com.mojang:minecraft:$minecraftVersion")
|
||||||
modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion")
|
modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion")
|
||||||
|
@ -60,7 +58,7 @@ dependencies {
|
||||||
parchment("org.parchmentmc.data:$mappingsChannel-$minecraftVersion.2:$mappingsVersion@zip")
|
parchment("org.parchmentmc.data:$mappingsChannel-$minecraftVersion.2:$mappingsVersion@zip")
|
||||||
})
|
})
|
||||||
|
|
||||||
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:$reiVersion") // required for fabric rei plugin
|
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:$reiVersion") // required for common rei plugin
|
||||||
modCompileOnly("mezz.jei:jei-$minecraftVersion-fabric:$jeiVersion") // required for common jei plugin and mixin
|
modCompileOnly("mezz.jei:jei-$minecraftVersion-fabric:$jeiVersion") // required for common jei plugin and mixin
|
||||||
// runtime only
|
// runtime only
|
||||||
when (fabricRecipeViewer) {
|
when (fabricRecipeViewer) {
|
||||||
|
@ -90,20 +88,8 @@ dependencies {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
// TODO: test if this is necessary
|
|
||||||
jar {
|
|
||||||
from("LICENSE") {
|
|
||||||
rename { "${it}_${modName}" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO: test if this is necessary
|
|
||||||
processResources {
|
processResources {
|
||||||
from(project(":Common").sourceSets.main.get().resources)
|
from(project(":Common").sourceSets.main.get().resources)
|
||||||
inputs.property("version", project.version)
|
|
||||||
|
|
||||||
filesMatching("fabric.mod.json") {
|
|
||||||
expand("version" to project.version)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
withType<JavaCompile> {
|
withType<JavaCompile> {
|
||||||
source(project(":Common").sourceSets.main.get().allSource)
|
source(project(":Common").sourceSets.main.get().allSource)
|
||||||
|
|
|
@ -25,7 +25,6 @@ base {
|
||||||
}
|
}
|
||||||
|
|
||||||
loom {
|
loom {
|
||||||
shareCaches()
|
|
||||||
silentMojangMappingsLicense()
|
silentMojangMappingsLicense()
|
||||||
|
|
||||||
runs {
|
runs {
|
||||||
|
@ -55,7 +54,7 @@ loom {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":Common", "namedElements")) { isTransitive = false }
|
compileOnly(project(":Common", "namedElements")) { isTransitive = false }
|
||||||
|
|
||||||
minecraft("com.mojang:minecraft:$minecraftVersion")
|
minecraft("com.mojang:minecraft:$minecraftVersion")
|
||||||
forge("net.minecraftforge:forge:$minecraftVersion-$forgeVersion")
|
forge("net.minecraftforge:forge:$minecraftVersion-$forgeVersion")
|
||||||
|
@ -65,7 +64,7 @@ dependencies {
|
||||||
parchment("org.parchmentmc.data:$mappingsChannel-$minecraftVersion.2:$mappingsVersion@zip")
|
parchment("org.parchmentmc.data:$mappingsChannel-$minecraftVersion.2:$mappingsVersion@zip")
|
||||||
})
|
})
|
||||||
|
|
||||||
modCompileOnly("me.shedaniel:RoughlyEnoughItems-forge:$reiVersion") // required for forge rei plugin | api does not work here!
|
modCompileOnly("me.shedaniel:RoughlyEnoughItems-forge:$reiVersion") // required for common rei plugin | api does not work here!
|
||||||
modCompileOnly("mezz.jei:jei-$minecraftVersion-forge:$jeiVersion") // required for common jei plugin and mixin
|
modCompileOnly("mezz.jei:jei-$minecraftVersion-forge:$jeiVersion") // required for common jei plugin and mixin
|
||||||
// runtime only
|
// runtime only
|
||||||
when (forgeRecipeViewer) {
|
when (forgeRecipeViewer) {
|
||||||
|
@ -97,20 +96,8 @@ dependencies {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
// TODO: test if this is necessary
|
|
||||||
jar {
|
|
||||||
from("LICENSE") {
|
|
||||||
rename { "${it}_${modName}" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO: test if this is necessary
|
|
||||||
processResources {
|
processResources {
|
||||||
from(project(":Common").sourceSets.main.get().resources)
|
from(project(":Common").sourceSets.main.get().resources)
|
||||||
inputs.property("version", project.version)
|
|
||||||
|
|
||||||
filesMatching("META-INF/mods.toml") {
|
|
||||||
expand("version" to project.version)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
withType<JavaCompile> {
|
withType<JavaCompile> {
|
||||||
source(project(":Common").sourceSets.main.get().allSource)
|
source(project(":Common").sourceSets.main.get().allSource)
|
||||||
|
|
|
@ -1,89 +0,0 @@
|
||||||
package com.almostreliable.unified.compat;
|
|
||||||
|
|
||||||
import com.almostreliable.unified.recipe.CRTLookup;
|
|
||||||
import com.almostreliable.unified.recipe.ClientRecipeTracker;
|
|
||||||
import com.almostreliable.unified.utils.Utils;
|
|
||||||
import me.shedaniel.math.Rectangle;
|
|
||||||
import me.shedaniel.rei.api.client.gui.DisplayRenderer;
|
|
||||||
import me.shedaniel.rei.api.client.gui.widgets.Widget;
|
|
||||||
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
|
|
||||||
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
|
|
||||||
import me.shedaniel.rei.api.client.registry.category.ButtonArea;
|
|
||||||
import me.shedaniel.rei.api.client.registry.category.CategoryRegistry;
|
|
||||||
import me.shedaniel.rei.api.client.registry.category.extension.CategoryExtensionProvider;
|
|
||||||
import me.shedaniel.rei.api.client.registry.display.DisplayCategory;
|
|
||||||
import me.shedaniel.rei.api.client.registry.display.DisplayCategoryView;
|
|
||||||
import me.shedaniel.rei.api.common.display.Display;
|
|
||||||
import me.shedaniel.rei.api.common.plugins.PluginManager;
|
|
||||||
import me.shedaniel.rei.api.common.registry.ReloadStage;
|
|
||||||
import me.shedaniel.rei.forge.REIPlugin;
|
|
||||||
import net.minecraft.client.renderer.Rect2i;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@REIPlugin(Dist.CLIENT)
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
|
||||||
public class AlmostREI implements REIClientPlugin {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postStage(PluginManager<REIClientPlugin> manager, ReloadStage stage) {
|
|
||||||
if (stage != ReloadStage.END || !manager.equals(PluginManager.getClientInstance())) return;
|
|
||||||
CategoryRegistry.getInstance().forEach(category -> {
|
|
||||||
IndicatorExtension extension = new IndicatorExtension(category.getPlusButtonArea().orElse(null));
|
|
||||||
category.registerExtension(Utils.cast(extension));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("OverrideOnly")
|
|
||||||
private record IndicatorExtension(@Nullable ButtonArea plusButtonArea)
|
|
||||||
implements CategoryExtensionProvider<Display> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DisplayCategoryView<Display> provide(Display display, DisplayCategory<Display> category, DisplayCategoryView<Display> lastView) {
|
|
||||||
return display
|
|
||||||
.getDisplayLocation()
|
|
||||||
.map(CRTLookup::getLink)
|
|
||||||
.map(link -> (DisplayCategoryView<Display>) new IndicatorView(lastView, link))
|
|
||||||
.orElse(lastView);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final class IndicatorView implements DisplayCategoryView<Display> {
|
|
||||||
|
|
||||||
private final DisplayCategoryView<Display> lastView;
|
|
||||||
private final ClientRecipeTracker.ClientRecipeLink link;
|
|
||||||
|
|
||||||
private IndicatorView(DisplayCategoryView<Display> lastView, ClientRecipeTracker.ClientRecipeLink link) {
|
|
||||||
this.lastView = lastView;
|
|
||||||
this.link = link;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DisplayRenderer getDisplayRenderer(Display display) {
|
|
||||||
return lastView.getDisplayRenderer(display);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Widget> setupDisplay(Display display, Rectangle bounds) {
|
|
||||||
var widgets = lastView.setupDisplay(display, bounds);
|
|
||||||
var area = calculateArea(bounds);
|
|
||||||
widgets.add(Widgets.createDrawableWidget((helper, stack, mX, mY, delta) ->
|
|
||||||
RecipeIndicator.renderIndicator(stack, area)));
|
|
||||||
var tooltipArea = new Rectangle(area.getX(), area.getY(), area.getWidth(), area.getHeight());
|
|
||||||
widgets.add(Widgets.createTooltip(tooltipArea, RecipeIndicator.constructTooltip(link)));
|
|
||||||
return widgets;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Rect2i calculateArea(Rectangle bounds) {
|
|
||||||
if (plusButtonArea != null) {
|
|
||||||
var area = plusButtonArea.get(bounds);
|
|
||||||
return new Rect2i(area.x, area.y - area.height - 2, area.width, area.height);
|
|
||||||
}
|
|
||||||
return new Rect2i(bounds.x, bounds.y, bounds.width, bounds.height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.almostreliable.unified.compat;
|
||||||
|
|
||||||
|
import me.shedaniel.rei.forge.REIPluginClient;
|
||||||
|
|
||||||
|
@REIPluginClient
|
||||||
|
public class AlmostREIForge extends AlmostREI {
|
||||||
|
// dummy class to activate the plugin on Forge
|
||||||
|
}
|
Loading…
Reference in a new issue