Jump to content

[1.15.2] I revamped some classes and I would like to know, why my stuff broke.


Recommended Posts

Posted

Hey,

I once had a working mod, but I did a few changes to my class structure to be a bit more like MinecraftByExample. However in this process I messed up some parts of my mod and I don't know, why stuff is not working anymore. So please answere my question and maybe give a solution too. I would like to know, why my stuff is broken. Here is my current repository, so you know, what I'm talking about

The first thing, that I did was to split the registration into server side and client side (much like minecraftByExample). But when I try to move the registration of my reloadListener from ElementalCombat.java to StartupCommon.java the FMLServerAboutToStartEvent won't get called anymore. What is the reason?

 

Next up are my capabalities. My mod usually fills the ElementalAttack- and ElementalDefenseCapability of a mob whenever it spawns. But when I try to access this data later, I only get the default (empty) capability instead. What is my error? My best guess is, that the capability isn't attached properly. At least I never reach the breakpoint in AttachCapabilityEvent.

At last I want to hear your feedback on my particles. It feels like I could do this part better, because there is a lot of code duplication happening. Sadly I couldn't come up with anything working. All 4 particles behaves basically the same, with the only difference being the texture. So is there an easier way to do it?

Thanks a lot in advance :)

 

PS: I didn't know, if I should create a topic for each of my issues or not...

Posted (edited)
20 minutes ago, Tavi007 said:

that the capability isn't attached properly.

https://github.com/Tavi007/ElementalCombat/blob/1390c4b3be278d93c6be25369ac14cb8f7e74b68/1.15.2/src/main/java/Tavi007/ElementalCombat/StartupCommon.java#L26

Your FMLCommonSetupEvent isn't annotated with

@SubscribeEvent

, it's never called.

https://github.com/Tavi007/ElementalCombat/blob/1390c4b3be278d93c6be25369ac14cb8f7e74b68/1.15.2/src/main/java/Tavi007/ElementalCombat/events/AttachCapabilityEvent.java#L14

For events to be called, you have to register them to the event bus by calling IEventBus#register, you never call MinecraftForge.EVENT_BUS.register(new AttachCapabilityEvent), so it doesn't fire.

20 minutes ago, Tavi007 said:

All 4 particles behaves basically the same, with the only difference being the texture

Maybe you can put the

ResourceLocation

as a parameter in your constructor? I haven't worked with particles myself, just an assumption.

20 minutes ago, Tavi007 said:

if I should create a topic for each of my issues or not...

I don't think you should, they're all small issues that can be tackled in one post instead of spamming the forums with small 1 reply threads.

Edit: Dzuchun is also correct, though you don't have to use

@Mod.EventBusSubscriber

if you're methods aren't static, but you still have to register an instance of your class.

Edit 2: Btw, you can't really have both FMLCommonSetupEvent and ServerAboutToStartEvent in the same

@Mod.EventBusSubscriber

annotated class as they fire on separate buses, FMLCommonSetupEvent fires on the mod bus, ServerAboutToStartEvent on the Forge bus.

Edit 3: This is from the Forge discord,event_handler.png.d5e57748293574b920cf0770db1bb0cb.png

Edited by Novârch
  • Like 1

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Posted (edited)
14 minutes ago, Tavi007 said:

The first thing, that I did was to split the registration into server side and client side (much like minecraftByExample). But when I try to move the registration of my reloadListener from ElementalCombat.java to StartupCommon.java the FMLServerAboutToStartEvent won't get called anymore. What is the reason?

Looks like you're missing StartupCommon class registration for events. You may try to put

@Mod.EventBusSubscriber(bus = Bus.MOD, modid = YOUR_MOD_ID)

before class declaration. Make sure that StartupCommon class is initialized - execute any method in it.

Edited by Dzuchun

Everything said above may be absolutely wrong. No rights reserved.

Posted

Thanks for all your help. Much appreciated!

 

I added the SubscribeEvent annotation and changed the functions to static. I also kept the ServerAboutToStartEvent in my main class, because it is the only event so far, that fires on the forge bus. Now upon starting a world I run into a nullPointer exception in CapabilityProviderEntityAndItem.java (line 42). Apperently ElementalAttackCapability.CAPABILITY_ELEMENTAL_ATTACK is null, which isn't that suprising, cause it is instantiated as null. But minecraftByExample did it the same way and I can't find any difference between his and my code. Any ideas?

Posted (edited)
27 minutes ago, Tavi007 said:

Thanks for all your help. Much appreciated!

 

I added the SubscribeEvent annotation and changed the functions to static. I also kept the ServerAboutToStartEvent in my main class, because it is the only event so far, that fires on the forge bus. Now upon starting a world I run into a nullPointer exception in CapabilityProviderEntityAndItem.java (line 42). Apperently ElementalAttackCapability.CAPABILITY_ELEMENTAL_ATTACK is null, which isn't that suprising, cause it is instantiated as null. But minecraftByExample did it the same way and I can't find any difference between his and my code. Any ideas?

You never register your capability in FMLCommonSetupEvent using CapabilityManager#register.

Edited by Novârch
  • Like 1

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Posted

Ahh, a rookie mistake... The Capaility is now working as it should, so big thank you :).

 

How come, that registering the capability changes the variables from null to something else? All i saw was the null pointer exception and i couldn't deduce, that this is due to the missing registration.

 

Anyway since I have your attention, could you give me advice on another of my issue please?

I want to fill the capability from the livingEntity and itemstack with default values (hence the reloadListener. I use it, to load these values from json). For the entities I modify the spawning event, where I use my dataManger to copy the data into the capability. Now I plan on doing something similar for the itemstacks, but I'm not sure, if I can do the same here... So do you have a good idea on how to fill the capability of an itemstack?

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.