Skip to content

Commit

Permalink
Merge branch 'feature-multi' into nyan-work/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Hendrix-Shen committed Aug 22, 2023
2 parents 56ccc7d + f96855c commit 96ddf95
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 19 deletions.
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
plugins {
id("maven-publish")
id("fabric-loom").version("1.3-SNAPSHOT").apply(false)
// https://github.com/Juuxel/LoomQuiltflower
id("io.github.juuxel.loom-quiltflower").version("1.10.0").apply(false)
id("net.kyori.blossom").version("1.3.1").apply(false)
// https://github.com/Juuxel/loom-vineflower
id("io.github.juuxel.loom-vineflower").version("1.11.0").apply(false)
id("org.ajoberstar.grgit").version("5.2.0")
id("com.replaymod.preprocess").version("SNAPSHOT")
}
Expand All @@ -18,6 +17,7 @@ preprocess {
def mc1193 = createNode("1.19.3", 1_19_03, "mojang")
def mc1194 = createNode("1.19.4", 1_19_04, "mojang")
def mc1201 = createNode("1.20.1", 1_20_01, "mojang")
def mc1202 = createNode("1.20.2", 1_20_02, "mojang")

mc1144.link(mc1152, null)
mc1152.link(mc1165, null)
Expand All @@ -27,6 +27,7 @@ preprocess {
mc1192.link(mc1193, null)
mc1193.link(mc1194, null)
mc1194.link(mc1201, null)
mc1201.link(mc1202, null)
}

ext {
Expand Down
86 changes: 76 additions & 10 deletions common.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import com.google.common.collect.ImmutableList
import com.google.common.collect.ImmutableMap
import org.objectweb.asm.ClassReader
import org.objectweb.asm.ClassWriter
import org.objectweb.asm.tree.ClassNode
import org.objectweb.asm.tree.LdcInsnNode

apply(plugin: "maven-publish")
apply(plugin: "fabric-loom")
apply(plugin: "io.github.juuxel.loom-quiltflower")
apply(plugin: "net.kyori.blossom")
apply(plugin: "io.github.juuxel.loom-vineflower")
apply(plugin: "com.replaymod.preprocess")

int mcVersion = 1
Expand Down Expand Up @@ -33,8 +39,13 @@ repositories {
}

maven {
name("Nyan Maven")
url("https://maven.hendrixshen.top")
name("Masa Maven")
url("https://masa.dy.fi/maven")
}

maven {
name("JitPack")
url("https://www.jitpack.io")
}

mavenCentral()
Expand Down Expand Up @@ -184,12 +195,6 @@ processResources {
from("${project.mod_id}.accesswidener")
}

blossom {
replaceToken("@MOD_IDENTIFIER@" , project.mod_id)
replaceToken("@MOD_NAME@" , project.mod_name)
replaceToken("@MINECRAFT_VERSION_IDENTIFY@", project.minecraft_version.replace(".", "_"))
}

java {
sourceCompatibility(JavaVersion.VERSION_1_8)
targetCompatibility(JavaVersion.VERSION_1_8)
Expand Down Expand Up @@ -217,3 +222,64 @@ publishing {
}
}
}

ImmutableMap<Object, Object> replaceTokenMap = ImmutableMap.builder()
.put("@MOD_IDENTIFIER@" , project.mod_id)
.put("@MOD_NAME@" , project.mod_name)
.put("@MINECRAFT_VERSION_IDENTIFY@", project.minecraft_version.replace(".", "_"))
.build()
ImmutableList<Object> replaceTokenFile = ImmutableList.builder()
.add("PluslsCarpetAdditionReference")
.build()

tasks.classes {
doLast {
File dir = file("build/classes/java")

dir.eachFileRecurse {
String path = it.path.replace(file("build/classes/java").path, "")

if (path.endsWith(".class") && replaceTokenFile.stream().anyMatch { path.contains(it as String) }) {
ClassReader cr = new ClassReader(it.newInputStream().bytes)
ClassNode cn = new ClassNode()
cr.accept(cn, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG)

// ReplaceToken in fields
cn.fields.each {
if (it.desc == "Ljava/lang/String;" && it.value instanceof String) {
String value = it.value as String

replaceTokenMap.each {
value = value.replace(it.key as String, it.value as String)
}

it.value = value
}
}

// ReplaceToken in methods
cn.methods.each {
it.instructions.each {
if (it instanceof LdcInsnNode) {
LdcInsnNode ldc = it as LdcInsnNode

if (ldc.cst instanceof String) {
String value = ldc.cst as String

replaceTokenMap.each {
value = value.replace(it.key as String, it.value as String)
}

ldc.cst = value
}
}
}
}

ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES)
cn.accept(cw)
new FileOutputStream(it).write(cw.toByteArray())
}
}
}
}
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ mod_sources=https://github.com/plusls/plusls-carpet-addition
mod_version=0.3

# Required Libraries
# MagicLib - 0.7.345
magiclib_dependency=0.7.345
magiclib_version=0.7.345
# MagicLib - 0.7.376+bce84f9-beta
magiclib_dependency=0.7.376+bce84f9-beta
magiclib_version=0.7.376+bce84f9-beta

# Annotation processor
lombok_version=1.18.28
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3 changes: 2 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def versions = Arrays.asList(
"1.19.3",
"1.19.4",
"1.20.1",
"1.20.2",
)

for (String version : versions) {
Expand Down
2 changes: 1 addition & 1 deletion versions/1.20.1/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Development Environment
minecraft_version=1.20.1
minecraft_dependency=1.20.x
minecraft_dependency=>1.20 <=1.20.1
3 changes: 3 additions & 0 deletions versions/1.20.2/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Development Environment
minecraft_version=23w33a
minecraft_dependency=1.20.2-alpha.23.33.a
5 changes: 5 additions & 0 deletions versions/1.20.2/pca.accesswidener
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
accessWidener v2 named
accessible class net/minecraft/world/level/block/entity/BeehiveBlockEntity$BeeData
accessible field net/minecraft/world/entity/ExperienceOrb count I
accessible field net/minecraft/world/level/block/DispenserBlock DISPENSER_REGISTRY Ljava/util/Map;
accessible method net/minecraft/world/entity/player/Player destroyVanishingCursedItems ()V

0 comments on commit 96ddf95

Please sign in to comment.