#Cannot resolve symbol 'SwordItem'

1 messages · Page 1 of 1 (latest)

compact bay
#

Hey, i just got into java modding and learned the language like 3 days ago, so this is probably a dumb question but im trying to make a sword. The fabric documentation says to create a sword like this

public static final Item ENDERIUM_SWORD = register(
"enderium_sword",
settings -> new SwordItem(ENDERIUM_TOOL_MATERIAL, 1f, 1f, settings),
new Item.Settings()
);

but for some reason, it says it cant resolve the symbol SwordItem. I've seen lots of other people using SwordItem and they have an import for it at

import net.minecraft.item.SwordItem;

but one, IntelliJ doesnt automatically add that and when i manually add that it says

No libraries found for 'net.minecraft.item.SwordItem

Anyone know why this happenes? The version is 1.21.5

neon cypress
#

I't different now

#

here is how the wooden sword is declared:
public static final Item WOODEN_SWORD = register("wooden_sword", new Item.Settings().sword(ToolMaterial.WOOD, 3.0F, -2.4F));

compact bay
#

ok, why isnt that on the fabric documentation, was that changed between 1.21.4 and 1.21.5?

neon cypress
#

I don't know when it changed, I also found it weird when I found out, but I'm a beginner too

#

tools, armor and things like that now are basically 100% "data-driven"

compact bay
#

dang, i picked a bad time to pick up java modding

neon cypress
#
.component(
                DataComponentTypes.TOOL,
                new ToolComponent(
                    List.of(
                        ToolComponent.Rule.ofAlwaysDropping(RegistryEntryList.of(Blocks.COBWEB.getRegistryEntry()), 15.0F),
                        ToolComponent.Rule.of(registryEntryLookup.getOrThrow(BlockTags.SWORD_INSTANTLY_MINES), Float.MAX_VALUE),
                        ToolComponent.Rule.of(registryEntryLookup.getOrThrow(BlockTags.SWORD_EFFICIENT), 1.5F)
                    ),
                    1.0F,
                    2,
                    false
                )
            )
#

like this

#

I mean, being data-driven makes things easier, not harder

#

but, anyways, it's really easy to make a sword

compact bay
#

lol i dont even know what being "data-driven" means

neon cypress
compact bay
#

i have a tool material already

neon cypress
neon cypress
compact bay
#

Do i create the tool material inside the ModItems class?

#

I have it in its own ModTools class rn

neon cypress
#

you can have a class only for that, no problem

#

it's up to you

#

In this Minecraft Modding Tutorial, we are adding Custom Tools to Minecraft with Fabric from Minecraft 1.21.1

== 1.21 MODDING COURSES ==
▶️ NeoForge Modding with Minecraft 1.21.X:
https://url.kaupenjoe.net/CourseNeoForge121X
▶️ Fabric Modding with Minecraft 1.21.X:
https://url.kaupenjoe.net/CourseFabric121X
▶️ Forge Modding with M...

▶ Play video
#

the only thing different is that instead of using SwordItem and stuff

compact bay
#

thats outdated though

neon cypress
#

you will create an item

#

yeah that is

#

but, like I said, that's basically the only difference

#

on that part

#

you can also search on github for mods on 1.21.5 and read how they do things

compact bay
#

yeah, i just wondered if i need to make the tool material in the Mod items class because i get this error

#

Cannot resolve symbol 'ENDERIUM_TOOL_MATERIAL'

#

this is my toolmaterial defenition

#

public static final ToolMaterial ENDERIUM_TOOL_MATERIAL = new ToolMaterial(
BlockTags.INCORRECT_FOR_WOODEN_TOOL,
455,
5.0F,
1.5F,
22,
null
);

#

and this is the sword registration

#

public static final Item ENDERIUM_SWORD = register("enderium_sword", new Item.Settings().sword(ToolMaterial.ENDERIUM_TOOL_MATERIAL, 7.5F, -2.4F));

neon cypress
#

what's the name of the class

#

where you put the tool material?

compact bay
#

ModTools

neon cypress
#

then it's ModTools.ENDERIUM_TOOL_MATERIAL

#

not ToolMaterial.ENDERIUM_TOOL_MATERIAL

#

if you want to take a look at a 1.12.5 mod that adds items

#

as you can see most of the items are actually a datapack

#

only the items with custom behaviour are created in Java

#

things are changing I guess

compact bay
#

oh, well, ty for helping

neon cypress
#

no problem

#

good luck

compact bay
#

one more question, that mod doesnt ever register a sword, but why does this:

public static final Item ENDERIUM_SWORD = register("enderium_sword", new Item.Settings().sword(ModTools.ENDERIUM_TOOL_MATERIAL, 7.5F, -2.4F));

throw the error

Expected 1 argument but found 2

#

nvm

#

i fixed it

#

is there a new format to the texture json as well?

green stone
#

You need a client item file.

#

And... I can't find the handy explanation for those at the moment.

#

This is from the NeoForge team but it explains it pretty well.

feral stream
#

Use 1.21.1 if you can't handle from MC Source Code how to make something

upbeat imp