Skip to content

Commit

Permalink
Merge branch '1.18'
Browse files Browse the repository at this point in the history
# Conflicts:
#	buildSrc/src/main/kotlin/Dependencies.kt
#	buildSrc/src/main/kotlin/FetchLatestVersionsTask.kt
#	module-compat/alloy-forgery/src/main/java/lol/bai/megane/module/alloyforgery/mixin/AccessorForgeControllerBlockEntity.java
#	module-compat/alloy-forgery/src/main/java/lol/bai/megane/module/alloyforgery/provider/ForgeControllerEnergyProvider.java
#	module-compat/applied-energistics-2/src/main/resources/megane-applied-energistics-2.mixins.json
  • Loading branch information
deirn committed Nov 12, 2022
2 parents 38c2c39 + 6739cc8 commit 7e6b561
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 11 deletions.
11 changes: 9 additions & 2 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.gradle.api.artifacts.ExternalModuleDependency
import org.gradle.kotlin.dsl.DependencyHandlerScope
import org.gradle.kotlin.dsl.exclude

Expand Down Expand Up @@ -45,11 +46,17 @@ object deps {
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"
val mixinExtras = "com.github.LlamaLad7:MixinExtras:0.1.1-rc.4"
}

fun DependencyHandlerScope.modImpl(dep: String) {
fun DependencyHandlerScope.modImpl(dep: String, dependencyConfiguration: ExternalModuleDependency.() -> Unit = {}) {
"modImplementation"(dep) {
if (!dep.startsWith("net.fabricmc.fabric-api")) exclude(group = "net.fabricmc.fabric-api")
exclude(group = "mezz.jei")
dependencyConfiguration()
}
}

fun ExternalModuleDependency.exclude(dep: String) {
val (group, module) = dep.split(':', limit = 2)
exclude(group, module)
}
26 changes: 20 additions & 6 deletions buildSrc/src/main/kotlin/FetchLatestVersionsTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import org.gradle.api.tasks.TaskAction
import version.CurseForgeVersionFetcher
import version.ModrinthVersionFetcher
import version.VersionFetcher
import java.awt.Toolkit
import java.awt.datatransfer.StringSelection
import java.net.http.HttpClient
import java.util.*
import kotlin.reflect.KProperty
Expand All @@ -12,15 +14,21 @@ import kotlin.reflect.full.memberProperties
abstract class FetchLatestVersionsTask : DefaultTask() {
@TaskAction
fun run() {
val output = StringBuilder()
val http = HttpClient.newHttpClient()

fun out(line: String = "") {
output.appendLine(line)
println(line)
}

class VersionFetcherDsl<T>(
val versionFetcher: VersionFetcher<T>
) {
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)}\"")
out("val ${name.name} = \"${parser(res)}\"")
} else {
throw GradleException("Failed to get version for ${name}")
}
Expand All @@ -33,11 +41,15 @@ abstract class FetchLatestVersionsTask : DefaultTask() {

fetcher(ModrinthVersionFetcher) {
fetch(deps::wthit, mrIds.wthit) { "mcp.mobius.waila:wthit:${it.version_number}" }
println()
out()

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::create, mrIds.create, "1.18.2") {
"com.simibubi.create:create-fabric-${
it.version_number.removePrefix("create-fabric-").replaceFirst('-', ':')
}"
}
fetch(deps::clothConfig, mrIds.clothConfig) { "me.shedaniel.cloth:cloth-config-fabric:${it.version_number}" }
fetch(deps::extraGen, mrIds.extraGen, "1.19") { it.maven }
fetch(deps::fabricApi, mrIds.fabricApi) { "net.fabricmc.fabric-api:fabric-api:${it.version_number}" }
Expand All @@ -50,7 +62,7 @@ abstract class FetchLatestVersionsTask : DefaultTask() {
fetch(deps::patchouli, mrIds.patchouli) { "vazkii.patchouli:Patchouli:${it.version_number.toUpperCase(Locale.ROOT)}" }
}

println()
out()

fetcher(CurseForgeVersionFetcher) {
fetch(deps::dmlSim, cfIds.dmlSim, "1.18.2") { it.maven }
Expand All @@ -61,15 +73,17 @@ abstract class FetchLatestVersionsTask : DefaultTask() {
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 {")
out("\nobject lba {")
deps.lba::class.memberProperties.forEach { module ->
@Suppress("UNCHECKED_CAST")
fetch(module as KProperty<String>, cfIds.lba, "1.18.2") {
"alexiil.mc.lib:libblockattributes-${module.name}:${it.download.fileName.removePrefix("libblockattributes-all-")}"
}
}
println("}")
out("}")
}

Toolkit.getDefaultToolkit().systemClipboard.setContents(StringSelection(output.toString()), null)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected void init() {

@Override
public long getStored() {
return (long) access.getFuel();
return Math.round(access.getFuel());
}

@Override
Expand Down
5 changes: 4 additions & 1 deletion module-compat/applied-energistics-2/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ dependencies {
runtimeOnly(namedProject("reborn-energy"))
runtimeOnly(namedProject("fabric-transfer"))

modImpl(deps.ae2)
modImpl(deps.ae2) {
exclude("curse.maven:jade-324717")
exclude("mezz.jei:jei-${deps.minecraft}-fabric")
}
modImpl(deps.fabricApi)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package lol.bai.megane.module.ae2.mixin;

import appeng.api.integrations.igtooltip.providers.ServerDataProvider;
import appeng.integration.modules.igtooltip.blocks.PowerStorageDataProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongepowered.asm.mixin.Mixin;
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.callback.CallbackInfo;

@Mixin(targets = "appeng.integration.modules.wthit.WthitModule$1")
public class MixinWthitModule1 {

@Unique
private static final Logger LOGGER = LoggerFactory.getLogger("MixinWthitModule1");

@Inject(method = "addBlockEntityData", at = @At("HEAD"), cancellable = true, remap = false)
private void megane_removePowerTooltip(Class<?> blockEntityClass, ServerDataProvider<?> provider, CallbackInfo ci) {
if (provider instanceof PowerStorageDataProvider) {
LOGGER.info("[megane-applied-energistics-2] Disabled AE2's builtin power tooltip in favor of Megane's");
ci.cancel();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"defaultRequire": 1
},
"mixins" : [
"MixinPowerStorageDataProvider"
"MixinWthitModule1"
]
}
2 changes: 2 additions & 0 deletions module-compat/create/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ repositories {
dependencies {
modImpl(deps.create) {
exclude("dev.emi:emi")
exclude("com.github.LlamaLad7:MixinExtras")
}
modImpl(deps.fabricApi)
modImpl(deps.mixinExtras)
}

0 comments on commit 7e6b561

Please sign in to comment.