issues with the UniversalAbilitiesEvent
Foxyas opened this issue ยท 38 comments
idk why and how but the event is not called when is need making the possibility to add new Universal Abilities be limited by mixins
2024-11-12.00-45-15.mp4
idk why and how but the event is not called when is need making the possibility to add new Universal Abilities be limited by mixins
2024-11-12.00-45-15.mp4
What is this SubscribeEvent about?
The @SubscribeEvent is a Anotation that "say" that X method will be executed when the Event selected in the method is called
That's not what I'm saying, I'm saying what is the event you're trying to call for?
That's not what I'm saying, I'm saying what are you doing with the time you're trying to call?
Oh the code just add one new universal Ability if the Entitytype is A latexs and is not a partial Latex
Check earlier in your logs, that event is fired when the variants are registered on game launch.
Check earlier in your logs, that event is fired when the variants are registered on game launch.
i check it and still any of the loggers was called and i can see that the event is not called due the universal abilities not being add when the condition is applied
i check if was a issue with the events due my issues with them before [because i'm dumb] but all the others events of the API are working just fine
question, the MinecraftForge.EVENT_BUS.post(event); call the event and set the abilities list or just call the event?
Can I see the code?
The code is just a normal execution of the event like
//Imports here
@Mod.EventBusSubscriber
public static class className {
@SubscribeEvent
public static void CoolVoidName(TransfurVariant.UniversalAbilitiesEvent event){
//A logger to show if the event is called
// event.addAbility here
}
}
Did you register the custom SubscribeEvent? It doesn't look like it belongs to forge in any way
be like:
public class CustomEvent extends Event {
private final String message;
public CustomEvent(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
}
the event was automatically registered as FORGE or atleast is what the logs say but i can try use a manual registry one
be like:
public class CustomEvent extends Event { private final String message; public CustomEvent(String message) { this.message = message; } public String getMessage() { return message; } }
That would create a new event and i'm trying just to execute the event
idk why and how but the event is not called when is need making the possibility to add new Universal Abilities be limited by mixins
2024-11-12.00-45-15.mp4
What is this SubscribeEvent about?
i test using the own Changed Workspace and still the the event is not called
package net.ltxprogrammer.changed.TESTSTUFF;
import net.ltxprogrammer.changed.entity.variant.TransfurVariant;
import net.ltxprogrammer.changed.init.ChangedAbilities;
import net.ltxprogrammer.changed.init.ChangedTags;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
@Mod.EventBusSubscriber
public class testClass {
@SubscribeEvent
public static void lol(TransfurVariant.UniversalAbilitiesEvent event){
event.addAbility(event.isOfTag(ChangedTags.EntityTypes.LATEX),ChangedAbilities.PUDDLE);
}
}
maybe i find out why, the builder is not registered before the event be able to call, and i find out that because i try use a mixin to add a universal ability in the method "<init>" at "TAIL" and the objects [Builder and the Transfur Variants] was not even registered causing a crash
i check it more and i saw that for some reason not matter where the event is posted the event will not be post
i try make the event be posted in the Build method but still is not called
maybe a option to fix that would be adding a method to add a ability in the player TransfurVariantInstance?
add the universal abilities when the Instance is created or just create a method to add a Ability instance in the list
i make it working BUT i move the Event to the TransfurVariantInstance Instead of the Builder Of the TransfurVariant, because for some REASON that i don't understand why yet the event is not called in the Build of the TransfurVariant
the line that i change
public TransfurVariantInstance(TransfurVariant<T> parent, Player host) {
this.parent = parent;
this.entity = parent.generateForm(host, host.level);
this.host = host;
this.transfurMode = parent.transfurMode;
var builder = new ImmutableMap.Builder<AbstractAbility<?>, AbstractAbilityInstance>();
List<Function<EntityType<?>, ? extends AbstractAbility<?>>> list = new ArrayList<>(parent.abilities);
var event = new TransfurVariant.UniversalAbilitiesEvent(list);
MinecraftForge.EVENT_BUS.post(event);
list.forEach(abilityFunction -> {
var ability = abilityFunction.apply(this.parent.getEntityType());
if (ability != null)
builder.put(ability, ability.makeInstance(IAbstractChangedEntity.forPlayer(host)));
});
abilityInstances = builder.build();
if (abilityInstances.size() > 0)
selectedAbility = abilityInstances.keySet().asList().get(0);
}
and btw when i try use a mixin to Inject a ability in the TransfurVariant.Builder
cause a crash saying that the Object don't was Registered
anyway that fix that i make fix the issue with the event BUT maybe can cause a issue with variants that have a Selected Ability List and would not be the good idea to add a Ability for a Transfur that have a specific Ability list
I think the event is being broadcasted to early in the mod loading process.
I did some changes and that fixed but instead of Being in the builder of the transfur it's had to be in the Creation of the Transfurs Variant Instance
Idk if you would like that change but i make a pull request showing what i change in the code
even mixins fail because the object was not registered when the mixin tried to add the code that apply the extra ability
The MinecraftForge.EVENT_BUS
is shutdown until the mods have completed loading.
I saw that, but I wanted to have the event only happen once at launch.
I don't know if this is possible because I try to use several methods, like having the event be executed before the construction of the Builder of Transfur Variants and making return a list and with that list added to all variants that meet the criteria,add the event handle in the builder [public void i mean], and other kind of method like this but all my attempts fail
you have more experience than me so i guess that you can figure out something =/
I swapped it to
FMLJavaModLoadingContext.get().getModEventBus()
, and I believe it will work.
hoping for good luck :D
The
MinecraftForge.EVENT_BUS
is shutdown until the mods have completed loading.
oh so that explain alot of thing lol
I swapped it to FMLJavaModLoadingContext.get().getModEventBus()
, and I believe it will work.
Hey btw could you add a method for add a Ability for a Transfur Variant Instance? :>
Like a addAbility(), i'm thinking in create a feature where the old you get More Abilities you unlock and a method to add a Ability would help with that alot :>