#MinecraftClient breaks building my mod

35 messages · Page 1 of 1 (latest)

whole tinsel
#

As soon as I try to use the net.minecraft.client.MinecraftClient in my code, it breaks and IntelliJ asks me if it should add „net.minecraft:minecraft-clientOnly-56a904…“ to the classpath and when I accept it, it works somehow. I can run the mod via IntelliJ but as soon as I try to build it, it gives me the error „error: package net.minecraft.client does not exist“at the import an firther down in the code it then tells me „error: cannot find symbol“. Does anyone have an idea on what I could/should do so can build and export my mod as a .jar?

sage tusk
#

are you using split sources and are you using MinecraftClient in your main sourceset ?

whole tinsel
#

what do you mean? and how/where can I check?

sage tusk
#

!!splitsources

weary anchorBOT
#
Split Sources

Split Sources provide a compile-time guarantee against calling client only Minecraft code or client only API on the server.

Client-only code can be placed in client, and code that is common to client and server can be placed in main. Client-only code can refer code in main, but not the other way.

Read more: Split Client and Common code - Fabric Loom

whole tinsel
#

ooh

#

yeah

#

i think yes

#

I tested it like this

#

because I followed a tutorial where there weren't a "client" and a "main" src

#

so I decided to go with the main

#

because main is main and sounds better for a beginner

#

lol

#

oh well

#

it works in the src.client

#

how can I "switch" easily from the src.main to the src.client?

#

or can I edit the settings/configurations to make the src.main act the same as the src.client?

sage tusk
#

the source sets are split for a reason. you must not use client-only classes in your common code since doing so will crash dedicated server

#

keep your client-only code in the client source set

#

split sources was added to help beginners

whole tinsel
#

alright so I I should just move all my code to the client split

#

that would be the easiest way?

#

(I'm making a client side mod btw.)

whole tinsel
sage tusk
#

if your mod is client-only you don't need split sources. just use the client source sets or re-create your template

#

it's enabled in your build gradle but I don't use it so I don't know if just removing the settings in your build.gradle file is enough

#

I would re-create the project personally

#

(without split sources enabled)

whole tinsel
#

and how would I disable split sources?

#

... when rebuilding?

whole tinsel
sage tusk
#

Something like that, yes

whole tinsel
sage tusk
#

It's an option in the template generator