From 38c2c39e5252fbf6e0ce69bdbd0c7039b3c4d291 Mon Sep 17 00:00:00 2001 From: deirn Date: Thu, 1 Sep 2022 18:21:02 +0700 Subject: [PATCH] update to 1.19.2, fix ae2 mixin --- build.gradle.kts | 2 +- buildSrc/src/main/kotlin/Dependencies.kt | 63 ++++++++++--------- .../main/kotlin/FetchLatestVersionsTask.kt | 28 ++++----- .../block/FluidComponentProvider.java | 17 +---- .../mixin/MixinBlockEntityDataProvider.java | 32 ---------- .../mixin/MixinPowerStorageDataProvider.java | 35 +++++++++++ .../megane-applied-energistics-2.mixins.json | 2 +- .../industrial-revolution/build.gradle.kts | 7 --- settings.gradle.kts | 2 +- 9 files changed, 86 insertions(+), 102 deletions(-) delete mode 100644 module-compat/applied-energistics-2/src/main/java/lol/bai/megane/module/ae2/mixin/MixinBlockEntityDataProvider.java create mode 100644 module-compat/applied-energistics-2/src/main/java/lol/bai/megane/module/ae2/mixin/MixinPowerStorageDataProvider.java diff --git a/build.gradle.kts b/build.gradle.kts index 14f8c45..e3d0b1b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -191,7 +191,7 @@ afterEvaluate { // addOptional(cfSlugs.create) // addOptional(cfSlugs.dmlSim) addOptional(cfSlugs.extraGen) -// addOptional(cfSlugs.indrev) + addOptional(cfSlugs.indrev) addOptional(cfSlugs.kibe) // addOptional(cfSlugs.lba) addOptional(cfSlugs.luggage) diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 0ac65fa..f272f80 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -2,51 +2,54 @@ import org.gradle.kotlin.dsl.DependencyHandlerScope import org.gradle.kotlin.dsl.exclude object versions { - val minecraft = "1.19" + val minecraft = "1.19.2" } object deps { val minecraft = "com.mojang:minecraft:${versions.minecraft}" - val yarn = "net.fabricmc:yarn:1.19+build.4:v2" - val fabricLoader = "net.fabricmc:fabric-loader:0.14.8" - - val wthit = "mcp.mobius.waila:wthit:fabric-5.6.1" - val fabricApi = "net.fabricmc.fabric-api:fabric-api:0.57.0+1.19" - val modmenu = "com.terraformersmc:modmenu:4.0.0" - - val ae2 = "appeng:appliedenergistics2-fabric:12.0.1-alpha" - val dmlSim = "curse.maven:deep-mob-learning-simulacrum-508931:3785658" - val clothConfig = "me.shedaniel.cloth:cloth-config-fabric:6.2.62" - val extraGen = "curse.maven:extra-generators-475623:3856206" - val flk = "net.fabricmc:fabric-language-kotlin:1.8.0+kotlin.1.7.0" - val trEnergy = "teamreborn:energy:2.2.0" - val indrev = "curse.maven:industrial-revolution-391708:3759591" - val libgui = "io.github.cottonmc:LibGui:6.0.0+1.19" - val patchouli = "vazkii.patchouli:Patchouli:1.18.2-70-FABRIC" - val magna = "com.github.Draylar:magna:1.7.1-1.18" - val stepAttr = "com.github.emilyploszaj:step-height-entity-attribute:v1.0.1" - val fakePlayer = "dev.cafeteria:fake-player-api:0.3.0" - val noIndium = "me.luligabi:NoIndium:1.0.2+1.18.2" - val kibe = "curse.maven:kibe-388832:3842006" - val pal = "io.github.ladysnake:PlayerAbilityLib:1.6.0" - val rebornCore = "RebornCore:RebornCore-1.19:5.3.2" - val techReborn = "TechReborn:TechReborn-1.19:5.3.2" - val wirelessNet = "curse.maven:wireless-networks-461316:3876132" - val alloyForgery = "curse.maven:alloy-forgery-438718:3860382" + val yarn = "net.fabricmc:yarn:1.19.2+build.8:v2" + val fabricLoader = "net.fabricmc:fabric-loader:0.14.9" + + val wthit = "mcp.mobius.waila:wthit:fabric-5.11.3" + + val ae2 = "appeng:appliedenergistics2-fabric:12.1.2-beta" + val alloyForge = "maven.modrinth:jhl28YkY:2.0.16+1.19" + val create = "com.simibubi:Create:0.5.0c-708" + val clothConfig = "me.shedaniel.cloth:cloth-config-fabric:8.0.75+fabric" + val extraGen = "maven.modrinth:VXtwLg17:1.2.1-BETA+1.19" + val fabricApi = "net.fabricmc.fabric-api:fabric-api:0.60.0+1.19.2" + val flk = "net.fabricmc:fabric-language-kotlin:1.8.3+kotlin.1.7.10" + val kibe = "maven.modrinth:OvlwmUdC:1.9.9-BETA+1.19" + val modernDynamics = "maven.modrinth:fMpvLrnF:0.3.2-beta" + val modmenu = "com.terraformersmc:modmenu:4.0.6" + val noIndium = "me.luligabi:NoIndium:1.1.0+1.19" val owo = "io.wispforest:owo-lib:0.7.3+1.19" - val create = "com.simibubi:Create:mc1.18.2_v0.4.1+628" - val modernDynamics = "curse.maven:modern-dynamics-552758:3875277" - val luggage = "curse.maven:luggage-594709:3870828" + val patchouli = "vazkii.patchouli:Patchouli:1.19.2-76-FABRIC" + + val dmlSim = "curse.maven:cursemod-508931:3785658" + val indrev = "curse.maven:cursemod-391708:3940035" + val luggage = "curse.maven:cursemod-594709:3901069" + val pal = "io.github.ladysnake:PlayerAbilityLib:1.6.0" + val rebornCore = "RebornCore:RebornCore-1.19:5.3.4" + val techReborn = "TechReborn:TechReborn-1.19:5.3.4" + val wirelessNet = "curse.maven:cursemod-461316:3876132" object lba { val core = "alexiil.mc.lib:libblockattributes-core:0.10.2" val fluids = "alexiil.mc.lib:libblockattributes-fluids:0.10.2" val items = "alexiil.mc.lib:libblockattributes-items:0.10.2" } + + val trEnergy = "teamreborn:energy:2.2.0" + val libgui = "io.github.cottonmc:LibGui:6.0.1+1.19" + val magna = "com.github.GabrielOlvH:magna:0.5.2" + val stepAttr = "com.github.emilyploszaj:step-height-entity-attribute:v1.0.1" + val fakePlayer = "dev.cafeteria:fake-player-api:0.5.0" } fun DependencyHandlerScope.modImpl(dep: String) { "modImplementation"(dep) { if (!dep.startsWith("net.fabricmc.fabric-api")) exclude(group = "net.fabricmc.fabric-api") + exclude(group = "mezz.jei") } } diff --git a/buildSrc/src/main/kotlin/FetchLatestVersionsTask.kt b/buildSrc/src/main/kotlin/FetchLatestVersionsTask.kt index 30d2980..21b8798 100644 --- a/buildSrc/src/main/kotlin/FetchLatestVersionsTask.kt +++ b/buildSrc/src/main/kotlin/FetchLatestVersionsTask.kt @@ -17,8 +17,8 @@ abstract class FetchLatestVersionsTask : DefaultTask() { class VersionFetcherDsl( val versionFetcher: VersionFetcher ) { - fun fetch(name: KProperty<*>, project: String, parser: (T) -> String) { - val res = versionFetcher.getLatestVersionFor(http, project, versions.minecraft) + fun fetch(name: KProperty<*>, project: String, mc: String = versions.minecraft, parser: (T) -> String) { + val res = versionFetcher.getLatestVersionFor(http, project, mc) if (res != null) { println("val ${name.name} = \"${parser(res)}\"") } else { @@ -35,36 +35,36 @@ abstract class FetchLatestVersionsTask : DefaultTask() { fetch(deps::wthit, mrIds.wthit) { "mcp.mobius.waila:wthit:${it.version_number}" } println() - fetch(deps::ae2, mrIds.ae2) { "appeng:appliedenergistics2-fabric:${it.version_number.removePrefix("fabric-")}" } - fetch(deps::alloyForge, mrIds.alloyForge) { it.maven } - fetch(deps::create, mrIds.create) { "com.simibubi:Create:${it.version_number.removePrefix("create-1.18.2-")}" } + fetch(deps::ae2, mrIds.ae2, "1.19.1") { "appeng:appliedenergistics2-fabric:${it.version_number.removePrefix("fabric-")}" } + fetch(deps::alloyForge, mrIds.alloyForge, "1.19") { it.maven } + fetch(deps::create, mrIds.create, "1.18.2") { "com.simibubi:Create:${it.version_number.removePrefix("create-1.18.2-")}" } fetch(deps::clothConfig, mrIds.clothConfig) { "me.shedaniel.cloth:cloth-config-fabric:${it.version_number}" } - fetch(deps::extraGen, mrIds.extraGen) { it.maven } + fetch(deps::extraGen, mrIds.extraGen, "1.19") { it.maven } fetch(deps::fabricApi, mrIds.fabricApi) { "net.fabricmc.fabric-api:fabric-api:${it.version_number}" } fetch(deps::flk, mrIds.flk) { "net.fabricmc:fabric-language-kotlin:${it.version_number}" } - fetch(deps::kibe, mrIds.kibe) { it.maven } + fetch(deps::kibe, mrIds.kibe, "1.19") { it.maven } fetch(deps::modernDynamics, mrIds.modernDynamics) { it.maven } fetch(deps::modmenu, mrIds.modmenu) { "com.terraformersmc:modmenu:${it.version_number}" } - fetch(deps::noIndium, mrIds.noIndium) { "me.luligabi:NoIndium:${it.version_number}" } - fetch(deps::owo, mrIds.owo) { "io.wispforest:owo-lib:${it.version_number}" } + fetch(deps::noIndium, mrIds.noIndium, "1.19") { "me.luligabi:NoIndium:${it.version_number}" } + fetch(deps::owo, mrIds.owo, "1.19") { "io.wispforest:owo-lib:${it.version_number}" } fetch(deps::patchouli, mrIds.patchouli) { "vazkii.patchouli:Patchouli:${it.version_number.toUpperCase(Locale.ROOT)}" } } println() fetcher(CurseForgeVersionFetcher) { - fetch(deps::dmlSim, cfIds.dmlSim) { it.maven } + fetch(deps::dmlSim, cfIds.dmlSim, "1.18.2") { it.maven } fetch(deps::indrev, cfIds.indrev) { it.maven } fetch(deps::luggage, cfIds.luggage) { it.maven } fetch(deps::pal, cfIds.pal) { "io.github.ladysnake:PlayerAbilityLib:${it.download.fileName.removePrefix("pal-")}" } - fetch(deps::rebornCore, cfIds.rebornCore) { "RebornCore:RebornCore-1.18:${it.download.fileName.removePrefix("RebornCore-")}" } - fetch(deps::techReborn, cfIds.techReborn) { "TechReborn:TechReborn-1.18:${it.download.fileName.removePrefix("TechReborn-")}" } - fetch(deps::wirelessNet, cfIds.wirelessNet) { it.maven } + fetch(deps::rebornCore, cfIds.rebornCore) { "RebornCore:RebornCore-1.19:${it.download.fileName.removePrefix("RebornCore-")}" } + fetch(deps::techReborn, cfIds.techReborn) { "TechReborn:TechReborn-1.19:${it.download.fileName.removePrefix("TechReborn-")}" } + fetch(deps::wirelessNet, cfIds.wirelessNet, "1.19") { it.maven } println("\nobject lba {") deps.lba::class.memberProperties.forEach { module -> @Suppress("UNCHECKED_CAST") - fetch(module as KProperty, cfIds.lba) { + fetch(module as KProperty, cfIds.lba, "1.18.2") { "alexiil.mc.lib:libblockattributes-${module.name}:${it.download.fileName.removePrefix("libblockattributes-all-")}" } } diff --git a/module-base/runtime/src/main/java/lol/bai/megane/runtime/provider/block/FluidComponentProvider.java b/module-base/runtime/src/main/java/lol/bai/megane/runtime/provider/block/FluidComponentProvider.java index cbfa4ba..6fbedcf 100644 --- a/module-base/runtime/src/main/java/lol/bai/megane/runtime/provider/block/FluidComponentProvider.java +++ b/module-base/runtime/src/main/java/lol/bai/megane/runtime/provider/block/FluidComponentProvider.java @@ -1,7 +1,6 @@ package lol.bai.megane.runtime.provider.block; import java.util.List; -import java.util.Map; import lol.bai.megane.api.provider.FluidInfoProvider; import lol.bai.megane.api.util.BarFormat; @@ -25,7 +24,6 @@ import static lol.bai.megane.runtime.util.Keys.F_NBT; import static lol.bai.megane.runtime.util.Keys.F_SIZE; import static lol.bai.megane.runtime.util.Keys.F_STORED; -import static lol.bai.megane.runtime.util.MeganeUtils.CONFIG; import static lol.bai.megane.runtime.util.MeganeUtils.config; import static lol.bai.megane.runtime.util.MeganeUtils.fluidName; import static lol.bai.megane.runtime.util.MeganeUtils.id; @@ -43,10 +41,8 @@ protected void addFluid(ITooltip tooltip, IBlockAccessor accessor, Fluid fluid, BlockPos pos = accessor.getPosition(); World world = accessor.getWorld(); - Map colors = config().fluid.getColors(); boolean expand = accessor.getPlayer().isSneaking() && config().fluid.isExpandWhenSneak(); - Identifier id = Registry.FLUID.getId(fluid); List providers = Registrar.FLUID_INFO.get(fluid); FluidInfoProvider provider = null; @@ -59,18 +55,7 @@ protected void addFluid(ITooltip tooltip, IBlockAccessor accessor, Fluid fluid, } } - int color; - if (nbt != null && provider != null) { - color = provider.getColor() & 0xFFFFFF; - } else if (colors.containsKey(id)) { - color = colors.get(id); - } else { - color = provider == null - ? colors.computeIfAbsent(DEFAULT, s -> 0x0D0D59) - : provider.getColor() & 0xFFFFFF; - colors.put(id, color); - CONFIG.save(); - } + int color = provider != null ? provider.getColor() : 0x0D0D59; tooltip.addLine(new PairComponent( new WrappedComponent(provider == null ? fluidName(fluid) : provider.getName()), diff --git a/module-compat/applied-energistics-2/src/main/java/lol/bai/megane/module/ae2/mixin/MixinBlockEntityDataProvider.java b/module-compat/applied-energistics-2/src/main/java/lol/bai/megane/module/ae2/mixin/MixinBlockEntityDataProvider.java deleted file mode 100644 index 12406f0..0000000 --- a/module-compat/applied-energistics-2/src/main/java/lol/bai/megane/module/ae2/mixin/MixinBlockEntityDataProvider.java +++ /dev/null @@ -1,32 +0,0 @@ -package lol.bai.megane.module.ae2.mixin; - -import java.util.List; - -import appeng.integration.modules.waila.BaseDataProvider; -import appeng.integration.modules.waila.BlockEntityDataProvider; -import appeng.integration.modules.waila.tile.PowerStorageDataProvider; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(BlockEntityDataProvider.class) -public class MixinBlockEntityDataProvider { - - @Mutable - @Final - @Shadow - private List providers; - - /** - * Remove AE2's own energy tooltip, since megane provides it - */ - @Inject(method = "", at = @At("TAIL"), remap = false) - private void removeEnergyTooltip(CallbackInfo ci) { - providers = providers.stream().filter(it -> !(it instanceof PowerStorageDataProvider)).toList(); - } - -} diff --git a/module-compat/applied-energistics-2/src/main/java/lol/bai/megane/module/ae2/mixin/MixinPowerStorageDataProvider.java b/module-compat/applied-energistics-2/src/main/java/lol/bai/megane/module/ae2/mixin/MixinPowerStorageDataProvider.java new file mode 100644 index 0000000..58d71e0 --- /dev/null +++ b/module-compat/applied-energistics-2/src/main/java/lol/bai/megane/module/ae2/mixin/MixinPowerStorageDataProvider.java @@ -0,0 +1,35 @@ +package lol.bai.megane.module.ae2.mixin; + +import appeng.api.integrations.igtooltip.TooltipBuilder; +import appeng.api.integrations.igtooltip.TooltipContext; +import appeng.integration.modules.igtooltip.blocks.PowerStorageDataProvider; +import net.minecraft.block.entity.BlockEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Unique; + +@SuppressWarnings("UnstableApiUsage") +@Mixin(PowerStorageDataProvider.class) +public class MixinPowerStorageDataProvider { + + @Unique + private static final Logger LOGGER = LoggerFactory.getLogger("MixinPowerStorageDataProvider"); + + @Unique + private static boolean firstCall = true; + + /** + * @author deirn + * @reason Remove AE2's own energy tooltip, since megane provides it + */ + @Overwrite + public void buildTooltip(BlockEntity object, TooltipContext context, TooltipBuilder tooltip) { + if (firstCall) { + firstCall = false; + LOGGER.info("[Megane] Replaced AE2's own energy tooltip with Megane's"); + } + } + +} diff --git a/module-compat/applied-energistics-2/src/main/resources/megane-applied-energistics-2.mixins.json b/module-compat/applied-energistics-2/src/main/resources/megane-applied-energistics-2.mixins.json index d629010..db1a4dd 100644 --- a/module-compat/applied-energistics-2/src/main/resources/megane-applied-energistics-2.mixins.json +++ b/module-compat/applied-energistics-2/src/main/resources/megane-applied-energistics-2.mixins.json @@ -7,6 +7,6 @@ "defaultRequire": 1 }, "mixins" : [ - "MixinBlockEntityDataProvider" + "MixinPowerStorageDataProvider" ] } diff --git a/module-compat/industrial-revolution/build.gradle.kts b/module-compat/industrial-revolution/build.gradle.kts index 8c542e4..b9ac153 100644 --- a/module-compat/industrial-revolution/build.gradle.kts +++ b/module-compat/industrial-revolution/build.gradle.kts @@ -7,19 +7,12 @@ repositories { } dependencies { - runtimeOnly(namedProject("reborn-energy")) - runtimeOnly(namedProject("fabric-transfer")) - runtimeOnly(namedProject("lib-block-attributes")) - modImpl(deps.indrev) modImpl(deps.fabricApi) modImpl(deps.flk) modImpl(deps.trEnergy) modImpl(deps.libgui) modImpl(deps.patchouli) - modImpl(deps.lba.core) - modImpl(deps.lba.fluids) - modImpl(deps.lba.items) modImpl(deps.magna) modImpl(deps.stepAttr) modImpl(deps.fakePlayer) diff --git a/settings.gradle.kts b/settings.gradle.kts index d269632..95e71e7 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -20,7 +20,7 @@ compat("applied-energistics-2") //compat("deep-mob-learning-simulacrum") compat("extra-generators") compat("fabric-transfer") -//compat("industrial-revolution") +compat("industrial-revolution") compat("kibe") //compat("lib-block-attributes") compat("luggage")