#can someone help me with this 1.21.8 fabric server side mod

116 messages · Page 1 of 1 (latest)

supple sparrow
#

help plz:

package com.camum.headrevival;

import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;

public class MyItems {
public static final Item RESURRECTION_ITEM = new Item(new Item.Settings().maxCount(1));

public static void register() {
    Registry.register(Registries.ITEM, new Identifier(HeadRevivalMod.MOD_ID, "resurrection_item"), RESURRECTION_ITEM);
}

}

lean sable
#

Looks like a mod 👍

supple sparrow
lean sable
supple sparrow
lean sable
#

Ok, try restarting IntelliJ / syncing gradle

supple sparrow
#

ive done that too many times

lean sable
#

Including syncing gradle?

supple sparrow
#

yea

lean sable
#

Then try clearing Gradle cache I guess.

supple sparrow
#

matter of fact im doing it right now

supple sparrow
lean sable
#

C:\Users\<USERNAME>\.gradle\caches

#

Probably will need to stop IntelliJ first

supple sparrow
#

yea i figured

lean sable
#

Possibly even restart computer cuz windows something holds on to the locks sometimes.

supple sparrow
#

yea um u want me to delete the cache folder??

lean sable
#

Yeah

supple sparrow
#

@lean sable does the code look correct?

#

for 1.21.8

lean sable
#

No, but the imports look fine.

#

new Identifier doesn't work anymore, you need Identifier.of

supple sparrow
#

@lean sable i did every thing u asked but it didnt work

lean sable
#

Is syncing gradle erroring?

supple sparrow
#

nah its the building part

lean sable
supple sparrow
#

k

#

Starting a Gradle Daemon, 3 stopped Daemons could not be reused, use --status for details

Configure project :
Fabric Loom: 1.11.7

Task :compileJava FAILED
C:\Users\user\Desktop\headrevival-template-1.21.8\src\main\java\com\user\headrevival\MyItems.java:3: error: package net.minecraft.item does not exist
import net.minecraft.item.Item;
^
C:\Users\user\Desktop\headrevival-template-1.21.8\src\main\java\com\user\headrevival\MyItems.java:4: error: package net.minecraft.registry does not exist
import net.minecraft.registry.Registries;
^

                           ^
#

C:\Users\user\Desktop\headrevival-template-1.21.8\src\main\java\com\user\headrevival\MyItems.java:5: error: package net.minecraft.registry does not exist
import net.minecraft.registry.Registry;
^
C:\Users\user\Desktop\headrevival-template-1.21.8\src\main\java\com\user\headrevival\MyItems.java:6: error: cannot find symbol
import net.minecraft.util.Identifier;
^
symbol: class Identifier
location: package net.minecraft.util
C:\Users\user\Desktop\headrevival-template-1.21.8\src\main\java\com\user\headrevival\MyItems.java:9: error: cannot find symbol
public static final Item RESURRECTION_ITEM = new Item(new Item.Settings().maxCount(1));
^
symbol: class Item
location: class MyItems
5 errors

[Incubating] Problems report is available at: file:///C:/Users/user/Desktop/headrevival-template-1.21.8/build/reports/problems/problems-report.html

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':compileJava'.

Compilation failed; see the compiler output below.
C:\Users\user\Desktop\headrevival-template-1.21.8\src\main\java\com\user\headrevival\MyItems.java:6: error: cannot find symbol
import net.minecraft.util.Identifier;
^
symbol: class Identifier
location: package net.minecraft.util
C:\Users\user\Desktop\headrevival-template-1.21.8\src\main\java\com\user\headrevival\MyItems.java:9: error: cannot find symbol
public static final Item RESURRECTION_ITEM = new Item(new Item.Settings().maxCount(1));
^

#

symbol: class Item
location: class MyItems
C:\Users\user\Desktop\headrevival-template-1.21.8\src\main\java\com\user\headrevival\MyItems.java:3: error: package net.minecraft.item does not exist
import net.minecraft.item.Item;
^
C:\Users\user\Desktop\headrevival-template-1.21.8\src\main\java\com\user\headrevival\MyItems.java:4: error: package net.minecraft.registry does not exist
import net.minecraft.registry.Registries;
^
C:\Users\user\Desktop\headrevival-template-1.21.8\src\main\java\com\user\headrevival\MyItems.java:5: error: package net.minecraft.registry does not exist
import net.minecraft.registry.Registry;

lean sable
#

Are you using MojMaps? If you don't know, Ctrl+f build.gradle for Official.

supple sparrow
#

im not sure

lean sable
#

Does your build.gradle include yarn or Official?

#

If you can't find either, send it

supple sparrow
#

plugins {
id 'fabric-loom' version "${loom_version}"
id 'maven-publish'
id "org.jetbrains.kotlin.jvm" version "2.2.10"
}

version = project.mod_version
group = project.maven_group

base {
archivesName = project.archives_base_name
}

repositories {
// You usually don’t need extra repos — Loom handles Minecraft + Fabric automatically
}

loom {
splitEnvironmentSourceSets()

mods {
    "headrevival" {
        sourceSet sourceSets.main
        sourceSet sourceSets.client
    }
}

}

fabricApi {
configureDataGeneration {
client = true
}
}

dependencies {
// Core
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API (needed for registry, events, etc.)
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// Kotlin support
modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}"

}

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

filesMatching("fabric.mod.json") {
    expand "version": inputs.properties.version
}

}

tasks.withType(JavaCompile).configureEach {
it.options.release = 21
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "21"
}
}

java {
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

jar {
inputs.property "archivesName", project.base.archivesName

from("LICENSE") {
    rename { "${it}_${inputs.properties.archivesName}" }
}

}

#

publishing {
publications {
create("mavenJava", MavenPublication) {
artifactId = project.archives_base_name
from components.java
}
}
repositories {
// Add publishing repos if needed
}
}

#

thats what my .build looks like

lean sable
#

If you want to use yarn, you can change to use that

#

!!tut mappings

vestal rootBOT
supple sparrow
lean sable
#

You're using names from Yarn in a project that expects names from MojMap. To fix the errors, you can either change the project to expect yarn, or change the names to MojMap

supple sparrow
#

so just switch the dependences?

lean sable
#

If you want to use yarn, yes

#

I'd generate a new template and copy the build.gradle and gradle.properties

supple sparrow
#

why?

lean sable
#

Cuz that will fix it for sure. You could do it by hand by copying from other projects I guess. It's like two lines to change but I don't know what to change those lines to.

lean sable
supple sparrow
#

okay so just make a new template and then copy the scripts, build and properties

#

@lean sable

lean sable
#

Yep

supple sparrow
#

@lean sable

supple sparrow
#

tried that

#

@lean sable

lean sable
#

Please double check the same area. That is currently invalid Java.

supple sparrow
#

oops

#

this look right @lean sable

lean sable
supple sparrow
#

@lean sable

#

can u help me rq

lean sable
#

!!splitsources , you can't access client classes in the main source set (folder)

vestal rootBOT
#
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

supple sparrow
#

i already have split sources

#

@lean sable

lean sable
#

Yes, I know. That's the reason you can't access client classes from the main folder.

supple sparrow
#

so get rid of it

#

?

lean sable
#

No, move your client to the client folder

#

Split sources is the reason it's not compiling. If you removed split sources, you'd suddenly start crashing, but only on dedicated servers.

#

Annoying to deal with if you do that

supple sparrow
#

@lean sable i moved the thing to the client folder but what about the rest of the errors

lean sable
supple sparrow
#

@lean sable this is a server side mod tho

lean sable
#

Then you can't mixin MinecraftClient. It's not a thing on the server.

#

You also can't add items without polymer

#

!!Mr polymer

vestal rootBOT
supple sparrow
#

its not really an item though

#

i need a crafting recipe for things that are already in the game

lean sable
lean sable
supple sparrow
#

well the whole premise was for players when they get killed 2 times on the 3rd death there head drops (i alr have a mod for that) and then u use a crafting recipe (including diamonds, totem and player head) and then it gives you a enchanted player head which when placed on the ground unbanneds them

#

@lean sable

lean sable
#

You can manage that with custom components maybe, but polymer might make it easier

supple sparrow
#

so ur saying i can just do this whole thing with polymer

lean sable
#

It'll help making the item and giving it data

#

But you don't need it nessecarily

#

If you touch a Registry that's not dynamic (read: datapack), you have to use polymer, remake polymer yourself, or make it client-side too

supple sparrow
#

can u help me rq

#

heres my script thing and the error that my friends getting for this mod is: java.lang.NullPointerException: Item id not set at java.base/

#

@lean sable

lean sable
#

!!llm

vestal rootBOT
#

Whilst LLMs (Large Language Models) like ChatGPT and Gemini are impressive tools, **they are not recommended for first-time Fabric mod developers due to their inconsistency and potential for generating inaccurate code. **

LLMs may generate incorrect code that:

  • Targets the wrong Minecraft version, leading to outdated or incompatible features.
  • Uses incorrect mappings, causing errors or unexpected behavior.
  • Is designed for the wrong loader (NeoForge vs. Fabric), resulting in incompatibility.
  • Relies on non-existent Fabric API modules, creating code that references features that don't exist (called LLM hallucinations)

It's crucial to remember that LLMs should be seen as problem-solving aids, not code-generating machines. The output they provide often requires significant modification and understanding of Java before it can be implemented as a functional mod.

Therefore, learning Java is an absolute necessity before attempting to use any LLM-generated code in your mod. Knowing how the generated code works is key to using it effectively and fixing any problems that may arise.

supple sparrow
#

no he is running it on his server

#

@lean sable

lean sable
#

Does it work for you?

supple sparrow
#

i can try

#

[19:23:42] [main/ERROR]: Failed to start the minecraft server
java.lang.RuntimeException: Could not execute entrypoint stage 'main' due to errors, provided by 'headrevival' at 'camum.headrevival.HeadRevivalMod'!
at net.fabricmc.loader.impl.FabricLoaderImpl.lambda$invokeEntrypoints$2(FabricLoaderImpl.java:409) ~[fabric-loader-0.17.2.jar:?]
at net.fabricmc.loader.impl.util.ExceptionUtil.gatherExceptions(ExceptionUtil.java:33) ~[fabric-loader-0.17.2.jar:?]
at net.fabricmc.loader.impl.FabricLoaderImpl.invokeEntrypoints(FabricLoaderImpl.java:407) ~[fabric-loader-0.17.2.jar:?]
at net.fabricmc.loader.impl.game.minecraft.Hooks.startServer(Hooks.java:63) ~[fabric-loader-0.17.2.jar:?]
at knot/net.minecraft.server.Main.main(Main.java:114) [server-intermediary.jar:?]
at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:506) [fabric-loader-0.17.2.jar:?]
at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:72) [fabric-loader-0.17.2.jar:?]
at net.fabricmc.loader.impl.launch.knot.KnotServer.main(KnotServer.java:23) [fabric-loader-0.17.2.jar:?]
at net.fabricmc.loader.impl.launch.server.FabricServerLauncher.main(FabricServerLauncher.java:69) [fabric-loader-0.17.2.jar:?]

#

Caused by: java.lang.NullPointerException: Item id not set
at java.base/java.util.Objects.requireNonNull(Objects.java:259) ~[?:?]
at knot/net.minecraft.class_1792$class_1793.method_63689(class_1792.java:340) ~[server-intermediary.jar:?]
at knot/net.minecraft.class_1792.<init>(class_1792.java:134) ~[server-intermediary.jar:?]
at knot/camum.headrevival.MyItems.registerModItems(MyItems.java:20) ~[headrevival-1.21.8.jar:?]
at knot/camum.headrevival.HeadRevivalMod.onInitialize(HeadRevivalMod.java:12) ~[headrevival-1.21.8.jar:?]
at net.fabricmc.loader.impl.FabricLoaderImpl.invokeEntrypoints(FabricLoaderImpl.java:405) ~[fabric-loader-0.17.2.jar:?]
... 6 more

C:\Users\camum\Desktop\Minecraft>pause
Press any key to continue . . .

#

that is the error im getting

#

@lean sable

supple sparrow
#

?

lean sable
#

Pick one and stick with it

supple sparrow
#

gng im looking for anything to make the mod work atp

#

🙏