Skip to content

Commit

Permalink
✨ Fabric support!
Browse files Browse the repository at this point in the history
Signed-off-by: 秋雨落 <[email protected]>
  • Loading branch information
qyl27 committed Apr 26, 2023
1 parent e1dc8e9 commit eda0d90
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 42 deletions.
2 changes: 1 addition & 1 deletion common/src/main/resources/assets/nbtedit/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"gui.narration.button.special_character": "插入特殊符号",
"gui.narration.sub_window.value_editor": "数值编辑子窗口",
"gui.title.nbtedit_block_entity": "正在编辑位于 {0} {1} {2} 的方块实体",
"gui.title.nbtedit_entity": "正在编辑实体 ID: {0}",
"gui.title.nbtedit_entity": "正在编辑实体 ID:{0}",
"gui.title.nbtedit_item_stack": "正在编辑名为 {0} 的物品",
"key.category.nbtedit": "游戏内 NBT 修改器 (重制版)",
"key.nbtedit.shortcut": "修改所指向内容的 NBT",
Expand Down
34 changes: 19 additions & 15 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
id 'com.github.johnrengelman.shadow' version '7.1.2'
}

architectury {
Expand All @@ -8,7 +8,7 @@ architectury {
}

loom {
accessWidenerPath = project(":common").loom.accessWidenerPath
accessWidenerPath = project(':common').loom.accessWidenerPath
}

configurations {
Expand All @@ -21,34 +21,34 @@ configurations {

repositories {
maven {
name = "Mod Menu"
url = "https://maven.terraformersmc.com/releases"
name = 'Mod Menu'
url = 'https://maven.terraformersmc.com/releases'
}
}

dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"

modRuntimeOnly "com.terraformersmc:modmenu:6.2.1"
modRuntimeOnly 'com.terraformersmc:modmenu:6.2.1'

common(project(path: ":common", configuration: "namedElements")) { transitive = false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive = false }
common(project(path: ':common', configuration: 'namedElements')) { transitive = false }
shadowCommon(project(path: ':common', configuration: 'transformProductionFabric')) { transitive = false }
}

processResources {
inputs.property "version", project.version
inputs.property 'version', project.version

filesMatching("fabric.mod.json") {
expand "version": project.version
filesMatching('fabric.mod.json') {
expand 'version': project.version
}
}

shadowJar {
exclude "architectury.common.json"
exclude 'architectury.common.json'

configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"
classifier 'dev-shadow'
}

remapJar {
Expand All @@ -59,15 +59,19 @@ remapJar {
}

jar {
classifier "dev"
classifier 'dev'
}

sourcesJar {
def commonSources = project(":common").sourcesJar
def commonSources = project(':common').sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
}

remapJar {
classifier 'fabric'
}

components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
Expand All @@ -77,7 +81,7 @@ components.java {
publishing {
publications {
mavenFabric(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
artifactId = rootProject.archives_base_name + '-' + project.name
from components.java
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void serverOpenClientGui(ServerPlayer player) {
NBTEdit.getInstance().getLogger().info("Player " + player.getName().getString() + " is editing itself.");
player.getServer().execute(() -> {
var tag = new CompoundTag();
player.save(tag);
player.saveWithoutId(tag);
ServerPlayNetworking.send(player, new S2COpenEntityEditingGuiPacket(player.getUUID(), player.getId(), tag, true));
});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public static void clientHandle(Minecraft client, ClientPacketListener handler,

NBTEdit.getInstance().getLogger().info("Editing BlockEntity at XYZ " +
blockPos.getX() + " " + blockPos.getY() + " " + blockPos.getZ() + ".");
ScreenHelper.showNBTEditScreen(blockPos, compoundTag);
client.execute(() -> {
ScreenHelper.showNBTEditScreen(blockPos, compoundTag);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public static void clientHandle(Minecraft client, ClientPacketListener handler,
var isSelf = buf.readBoolean();

NBTEdit.getInstance().getLogger().info("Editing entity with UUID " + entityUuid + ".");
ScreenHelper.showNBTEditScreen(entityUuid, entityId, compoundTag, isSelf);
client.execute(() -> {
ScreenHelper.showNBTEditScreen(entityUuid, entityId, compoundTag, isSelf);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public static void clientHandle(Minecraft client, ClientPacketListener handler,

NBTEdit.getInstance().getLogger().info("Editing ItemStack "
+ itemStack.getDisplayName().getString() + "in hand.");
ScreenHelper.showNBTEditScreen(itemStack, compoundTag);
client.execute(() -> {
ScreenHelper.showNBTEditScreen(itemStack, compoundTag);
});
}
}
34 changes: 17 additions & 17 deletions forge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
id 'com.github.johnrengelman.shadow' version '7.1.2'
}

architectury {
Expand All @@ -8,7 +8,7 @@ architectury {
}

loom {
accessWidenerPath = project(":common").loom.accessWidenerPath
accessWidenerPath = project(':common').loom.accessWidenerPath

forge {
convertAccessWideners = true
Expand All @@ -26,10 +26,10 @@ configurations {

repositories {
maven {
name = "Curse maven"
url = "https://cursemaven.com"
name = 'Curse maven'
url = 'https://cursemaven.com'
content {
includeGroup "curse.maven"
includeGroup 'curse.maven'
}
}

Expand All @@ -39,38 +39,38 @@ repositories {
dependencies {
forge "net.minecraftforge:forge:${rootProject.forge_version}"

common(project(path: ":common", configuration: "namedElements")) { transitive = false }
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }
common(project(path: ':common', configuration: 'namedElements')) { transitive = false }
shadowCommon(project(path: ':common', configuration: 'transformProductionForge')) { transitive = false }
}

processResources {
inputs.property "version", project.version
inputs.property 'version', project.version

filesMatching("META-INF/mods.toml") {
expand "version": project.version
filesMatching('META-INF/mods.toml') {
expand 'version': project.version
}
}

shadowJar {
exclude "fabric.mod.json"
exclude "architectury.common.json"
exclude 'fabric.mod.json'
exclude 'architectury.common.json'

configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"
classifier 'dev-shadow'
}

remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
classifier null
classifier 'forge'
}

jar {
classifier "dev"
classifier 'dev'
}

sourcesJar {
def commonSources = project(":common").sourcesJar
def commonSources = project(':common').sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
}
Expand All @@ -84,7 +84,7 @@ components.java {
publishing {
publications {
mavenForge(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
artifactId = rootProject.archives_base_name + '-' + project.name
from components.java
}
}
Expand Down
5 changes: 0 additions & 5 deletions forge/src/main/resources/META-INF/accesstransformer.cfg

This file was deleted.

0 comments on commit eda0d90

Please sign in to comment.