Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Help with making sword in 1.15.2 mod


coxakil50
 Share

Recommended Posts

That stuff is controlled by the IItemTier you input in the first part of the SwordItem's constructor. Investigate the ItemTier class to see how vanilla does that. All you should have to do is make something that implements IItemTier and use it in your sword's constructor.

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

Link to comment
Share on other sites

I create a class "ToolBase" where i implement IItemTier. In "RegistryHandler" class (where i create item) i wrote :

"public static final RegistryObject<Item> SWORD = Items.register("sword", ToolBase::new)" 

 

In the "ToolBase" i wrote :

public class ToolBase implements IItemTier {

 

@Override

public int getMaxUses() {

return 0;

}

@Override

public float getEfficiency() {

return 0;

}

@Override

public float getAttackDamage() {

return 0;

}

@Override

public int getHarvestLevel() {

return 0;

}

@Override

public int getEnchantability() {

return 0;

}

@Override

public Ingredient getRepairMaterial() {

return null;

 

And I have an error, I don't know what I should add

Link to comment
Share on other sites

IItemTier isn't an item class, so of course you can't register it as one. Like I said, look at how vanilla does it.

You need to register something that extends from Item, so SwordItem, ToolItem, etc. If you're just trying to make a simple sword, you could just register a new instance of SwordItem without making a custom item class.

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

Link to comment
Share on other sites

1. Don't create base classes.

2. Don't static initialize registry objects (your item in this case).

  • Like 1

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Hello! When I try to launch the game with forge, i get an error message Error: java.lang.ExceptionInInitializerError: null Help me please   Time: 28/11/21 12:47 Description: Initializing game java.lang.ExceptionInInitializerError: null     at net.minecraft.world.item.Item.handler$zde000$getDisplayName(Item.java:529) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:mixin,re:classloading,pl:mixin:APP:structure_gel.mixins.json:ItemMixin,pl:mixin:A}     at net.minecraft.world.item.Item.m_7626_(Item.java) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:mixin,re:classloading,pl:mixin:APP:structure_gel.mixins.json:ItemMixin,pl:mixin:A}     at net.minecraft.world.item.ItemStack.m_41786_(ItemStack.java:584) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:mixin,xf:fml:forge:itemstack,re:classloading,xf:fml:forge:itemstack}     at net.minecraft.world.item.ItemStack.m_41651_(ItemStack.java:620) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:mixin,xf:fml:forge:itemstack,re:classloading,xf:fml:forge:itemstack}     at net.minecraft.client.Minecraft.m_91316_(Minecraft.java:695) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.searchtree.ReloadableSearchTree.m_8074_(SourceFile:36) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading}     at net.minecraft.client.searchtree.ReloadableIdSearchTree.m_8080_(SourceFile:48) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading}     at net.minecraft.client.Minecraft.lambda$createSearchTrees$10(Minecraft.java:713) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?] {re:computing_frames,re:mixin}     at net.minecraft.client.Minecraft.m_91271_(Minecraft.java:712) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.<init>(Minecraft.java:506) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.main.Main.main(Main.java:151) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?] {}     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}     at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?] {}     at net.minecraftforge.fml.loading.targets.CommonClientLaunchHandler.lambda$launchService$0(CommonClientLaunchHandler.java:45) ~[fmlloader-1.17.1-37.0.125.jar%2322!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:90) [bootstraplauncher-0.1.17.jar:?] {} Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext.getModEventBus()" because the return value of "net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext.get()" is null     at com.legacy.structure_gel.core.SGConfig$Common.<init>(SGConfig.java:49) ~[structure_gel-1.17.1-2.0.1.jar%2372!:2.0.1] {re:classloading}     at net.minecraftforge.common.ForgeConfigSpec$Builder.configure(ForgeConfigSpec.java:618) ~[forge-1.17.1-37.0.125-universal.jar%2378!:?] {re:classloading}     at com.legacy.structure_gel.core.SGConfig.<clinit>(SGConfig.java:25) ~[structure_gel-1.17.1-2.0.1.jar%2372!:2.0.1] {re:mixin,re:classloading}     ... 25 more A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace:     at net.minecraft.world.item.Item.handler$zde000$getDisplayName(Item.java:529) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:mixin,re:classloading,pl:mixin:APP:structure_gel.mixins.json:ItemMixin,pl:mixin:A}     at net.minecraft.world.item.Item.m_7626_(Item.java) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:mixin,re:classloading,pl:mixin:APP:structure_gel.mixins.json:ItemMixin,pl:mixin:A}     at net.minecraft.world.item.ItemStack.m_41786_(ItemStack.java:584) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:mixin,xf:fml:forge:itemstack,re:classloading,xf:fml:forge:itemstack}     at net.minecraft.world.item.ItemStack.m_41651_(ItemStack.java:620) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:mixin,xf:fml:forge:itemstack,re:classloading,xf:fml:forge:itemstack}     at net.minecraft.client.Minecraft.m_91316_(Minecraft.java:695) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.searchtree.ReloadableSearchTree.m_8074_(SourceFile:36) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading}     at net.minecraft.client.searchtree.ReloadableIdSearchTree.m_8080_(SourceFile:48) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading}     at net.minecraft.client.Minecraft.lambda$createSearchTrees$10(Minecraft.java:713) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?] {re:computing_frames,re:mixin}     at net.minecraft.client.Minecraft.m_91271_(Minecraft.java:712) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.<init>(Minecraft.java:506) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A} -- Initialization -- Details: Stacktrace:     at net.minecraft.client.main.Main.main(Main.java:151) ~[client-1.17.1-20210706.113038-srg.jar%2374!:?] {re:classloading,pl:runtimedistcleaner:A}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?] {}     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}     at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?] {}     at net.minecraftforge.fml.loading.targets.CommonClientLaunchHandler.lambda$launchService$0(CommonClientLaunchHandler.java:45) ~[fmlloader-1.17.1-37.0.125.jar%2322!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.0.7.jar%235!:?] {}     at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:90) [bootstraplauncher-0.1.17.jar:?] {} -- System Details -- Details:     Minecraft Version: 1.17.1     Minecraft Version ID: 1.17.1     Operating System: Windows 10 (amd64) version 10.0     Java Version: 16.0.1, Microsoft     Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Microsoft     Memory: 1031916112 bytes (984 MiB) / 1342177280 bytes (1280 MiB) up to 2147483648 bytes (2048 MiB)     CPUs: 8     Processor Vendor: GenuineIntel     Processor Name: Intel(R) Core(TM) i5-10310U CPU @ 1.70GHz     Identifier: Intel64 Family 6 Model 142 Stepping 12     Microarchitecture: whiskey Lake     Frequency (GHz): 2,21     Number of physical packages: 1     Number of physical CPUs: 4     Number of logical CPUs: 8     Graphics card #0 name: Intel(R) UHD Graphics     Graphics card #0 vendor: Intel Corporation (0x8086)     Graphics card #0 VRAM (MB): 1024,00     Graphics card #0 deviceId: 0x9b41     Graphics card #0 versionInfo: DriverVersion=27.20.100.9749     Memory slot #0 capacity (MB): 8192,00     Memory slot #0 clockSpeed (GHz): 2,13     Memory slot #0 type: LPDDR3     Memory slot #1 capacity (MB): 8192,00     Memory slot #1 clockSpeed (GHz): 2,13     Memory slot #1 type: LPDDR3     Virtual memory max (MB): 18039,55     Virtual memory used (MB): 9973,79     Swap memory total (MB): 1932,72     Swap memory used (MB): 549,59     JVM Flags: 9 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -Xmx2G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M     Launched Version: 1.17.1-forge-37.0.125     Backend library: LWJGL version 3.2.2 SNAPSHOT     Backend API: Intel(R) UHD Graphics GL version 3.2.0 - Build 27.20.100.9749, Intel     Window size: <not initialized>     GL Caps: Using framebuffer using OpenGL 3.2     GL debug messages:      Using VBOs: Yes     Is Modded: Definitely; Client brand changed to 'forge'     Type: Client (map_client.txt)     CPU: 8x Intel(R) Core(TM) i5-10310U CPU @ 1.70GHz     OptiFine Version: OptiFine_1.17.1_HD_U_H1     OptiFine Build: 20211104-012451     Render Distance Chunks: 12     Mipmaps: 4     Anisotropic Filtering: 1     Antialiasing: 0     Multitexture: false     Shaders: null     OpenGlVersion: 3.2.0 - Build 27.20.100.9749     OpenGlRenderer: Intel(R) UHD Graphics     OpenGlVendor: Intel     CpuCount: 8     ModLauncher: 9.0.7+91+master.8569cdf     ModLauncher launch target: forgeclient     ModLauncher naming: srg     ModLauncher services:           mixin PLUGINSERVICE           eventbus PLUGINSERVICE           object_holder_definalize PLUGINSERVICE           runtime_enum_extender PLUGINSERVICE           capability_token_subclass PLUGINSERVICE           capability_inject_definalize PLUGINSERVICE           accesstransformer PLUGINSERVICE           runtimedistcleaner PLUGINSERVICE           mixin TRANSFORMATIONSERVICE           OptiFine TRANSFORMATIONSERVICE           fml TRANSFORMATIONSERVICE      FML Language Providers:          minecraft@1.0         javafml@null     Mod List:          client-1.17.1-20210706.113038-srg.jar             |Minecraft                     |minecraft                     |1.17.1              |NONE      |Manifest: a1:d4:5e:04:4f:d3:d6:e0:7b:37:97:cf:77:b0:de:ad:4a:47:ce:8c:96:49:5f:0a:cf:8c:ae:b2:6d:4b:8a:3f         forge-1.17.1-37.0.125-universal.jar               |Forge                         |forge                         |37.0.125            |NONE      |Manifest: 22:af:21:d8:19:82:7f:93:94:fe:2b:ac:b7:e4:41:57:68:39:87:b1:a7:5c:c6:44:f9:25:74:21:14:f5:0d:90    
    • hmm, I didn't edit it, for the time being: https://paste.centos.org/view/8598a48d
    • this is full log, my problem is not to load examplemod, minecraft doesn't crush mod list of minecract title screen shows only 2 mods (minecraft and forge)  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.