Closed tobiazsh closed 1 month ago
Still looks like you didn't setup Fabric correctly.
First of all, thanks for the reply! I mean, I think I did set it up correctly. I copied all the in my opinion necessary things from build.gradle and fabric.mod.json into mine. I must've missed a few things then...
That's my build.gradle:
plugins {
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
}
version = project.mod_version
group = project.maven_group
project.ext.imgui_version = "1.87.5";
base {
archivesName = project.archives_base_name
}
repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
maven {
name = "deftuRepoSnapshots"
url = uri("https://maven.deftu.dev/snapshots")
}
mavenCentral()
}
loom {
splitEnvironmentSourceSets()
mods {
"myworld_traffic_addition" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}
accessWidenerPath = file("src/main/resources/myworld_traffic_addition.accesswidener")
}
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Dear ImGui Implementation
include implementation("io.github.spair:imgui-java-binding:${project.imgui_version}")
include implementation("io.github.spair:imgui-java-lwjgl3:${project.imgui_version}")
include implementation("io.github.spair:imgui-java-natives-windows:${project.imgui_version}")
include implementation("io.github.spair:imgui-java-natives-linux:${project.imgui_version}")
include implementation("io.github.spair:imgui-java-natives-macos:${project.imgui_version}")
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
tasks.withType(JavaCompile).configureEach {
it.options.release = 21
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}"}
}
}
// configure the maven publication
publishing {
publications {
create("mavenJava", MavenPublication) {
artifactId = project.archives_base_name
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
and that's my fabric.mod.json:
{
"schemaVersion": 1,
"id": "myworld_traffic_addition",
"version": "${version}",
"name": "MyWorld Traffic Addition",
"description": "A Minecraft Mod that adds so much more than just stupid, lousy, pre-defined traffic signs! Create your own signs, make directional signs, turn them at any angle to create your perfect roads and highways!",
"authors": [
"Tobiazsh"
],
"contact": {
"homepage": "https://fabricmc.net/",
"sources": "https://github.com/FabricMC/fabric-example-mod"
},
"license": "CC0-1.0",
"icon": "assets/myworld_traffic_addition/icon.png",
"environment": "*",
"entrypoints": {
"main": [
"at.tobiazsh.myworld.traffic_addition.MyWorldTrafficAddition"
],
"client": [
"at.tobiazsh.myworld.traffic_addition.MyWorldTrafficAdditionClient"
]
},
"mixins": [
"myworld_traffic_addition.mixins.json",
{
"config": "myworld_traffic_addition.client.mixins.json",
"environment": "client"
}
],
"depends": {
"fabricloader": ">=0.15.11",
"minecraft": "~1.21",
"java": ">=21",
"fabric-api": "*"
},
"suggests": {
"another-mod": "*"
},
"accessWidener" : "myworld_traffic_addition.accesswidener"
}
That's not really what I meant, the errors you provided are indicating that you haven't setup the environment in your IDE correctly. I at least can't see any issues in my example mod / the code you provided.
Hmmm... I followed the Fabric Docs 1:1. If I run it from the command line, I get these errors:
@Inject(method = "<init>", at = @At("RETURN"))
^
D:\Development\Fabric\MyWorld Traffic Addition\src\client\java\at\tobiazsh\myworld\traffic_addition\mixin\client\ImGui\MinecraftClientMixin.java:34: Warnung: Unable to determine descriptor for @Inject target method
@Inject(method = "close", at = @At("RETURN"))
^
D:\Development\Fabric\MyWorld Traffic Addition\src\client\java\at\tobiazsh\myworld\traffic_addition\mixin\client\ImGui\MinecraftClientMixin.java:25: Warnung: Cannot find target for @Shadow field in com.mojang.authlib.minecraft.client.MinecraftClient
@Shadow
^
I really don't know what's wrong here...
Are you sure you used the 1.21 branch and not the 1.21.1 branch?
Okay, yeah. That was one error. But the errors unfortunately still stay the same:
Warnung: Unable to locate obfuscation mapping for @Inject target <init>
@Inject(method = "<init>", at = @At("RETURN"))
@Shadow field window was not located in the target class com.mojang.authlib.minecraft.client.MinecraftClient. No refMap loaded.
I think you imported the wrong MinecraftClient class, it should be in net.minecraft package
YES Thank you so much. That fixed the mixin errors.... And there are new one's again. java.lang.NoSuchMethodError: 'boolean imgui.gl3.ImGuiImplGl3.init()'
public static void create(final long handle) {
ImGui.createContext();
ImPlot.createContext();
final ImGuiIO data = ImGui.getIO();
data.setIniFilename(MyWorldTrafficAddition.MOD_ID + ".ini");
data.setFontGlobalScale(1F);
/*final ImFontAtlas fonts = data.getFonts();
final ImFontGlyphRangesBuilder rangesBuilder = new ImFontGlyphRangesBuilder();
rangesBuilder.addRanges(data.getFonts().getGlyphRangesDefault());
rangesBuilder.addRanges(data.getFonts().getGlyphRangesCyrillic());
rangesBuilder.addRanges(data.getFonts().getGlyphRangesJapanese());
final short[] glyphRanges = rangesBuilder.buildRanges();
final ImFontConfig basicConfig = new ImFontConfig();
basicConfig.setGlyphRanges(glyphRanges);
final List<ImFont> generatedFonts = new ArrayList<>();
for (int i = 5; i < 50; i++) {
basicConfig.setName("DejaVuSans " + i + "px");
generatedFonts.add(fonts.addFontFromMemoryTTF(IOUtils.toByteArray(ImGuiImpl.class.getResourceAsStream("DejaVuSans.ttf")), i, basicConfig, glyphRanges));
}
fonts.build();
basicConfig.destroy();*/
data.setConfigFlags(ImGuiConfigFlags.DockingEnable);
imGuiImplGlfw.init(handle, true);
imGuiImplGl3.init();
}```
Removed imGuiImplGl3.init()
But it's in your example. Won't that mess up things if I remove it?
The 1.21.0 branch doesn't have this line
I'm on 1.21 but I see it
Change the ImGui version to 1.86.4
Yes that fixed. Everything. Thank you so much!
👍
Hi! I just tried the full version of the example mod implemented in my project. I came across multiple Mixin errors and I don't know what any of them mean since I honestly have never even touched Mixins and I just want to get ImGui working so I can move on. The error it's throwing me, is:
(FabricLoader/Mixin) Mixin apply for mod myworld_traffic_addition failed myworld_traffic_addition.client.mixins.json:ImGui.MinecraftClientMixin from mod myworld_traffic_addition -> com.mojang.authlib.minecraft.client.MinecraftClient: org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException @Shadow field window was not located in the target class com.mojang.authlib.minecraft.client.MinecraftClient. No refMap loaded.
And in the MinecraftClientMixin file, my IDE (IntelliJ) shows the the following error messages:
private Window window
):Unresolved field window in target class
method = close
):Cannot resolve any target instructions in target class; Cannot resolve method 'close' in target class
Here's my
MinecraftClientMixin
:and here's my
ExampleClientMixin
:Thanks or any help in advance!