Jump to content

( 1.21 Forge)Caused by: java.lang.Throwable: Calling Site from mod: nuclearapocalypse


Elileo28

Recommended Posts

I was making my own effect for after an explosion (radiation) but whenever i try to run the game it crashed with this error '        Caused by: java.lang.Throwable: Calling Site from mod: nuclearapocalypse '
Anyone that can help me?
 

This is my main mod class (NuclearApocalypse.java)

package net.elileo.nuclearapocalypse;

import net.elileo.nuclearapocalypse.command.SkipTimerCommand;
import net.elileo.nuclearapocalypse.effect.RadiationEffect;
import net.elileo.nuclearapocalypse.util.NuclearApocalypseDamageTypes;
import net.minecraft.core.Holder;
import net.minecraft.network.chat.Component;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageType;
import net.minecraft.world.effect.MobEffect;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegisterCommandsEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

import static com.mojang.text2speech.Narrator.LOGGER;

@Mod(NuclearApocalypse.MOD_ID)
public class NuclearApocalypse {

    public static final String MOD_ID = "nuclearapocalypse";
    public static DamageSource RADIATION_DAMAGE_SOURCE;

    public static final DeferredRegister<MobEffect> EFFECTS = DeferredRegister.create(ForgeRegistries.MOB_EFFECTS, MOD_ID);
    public static final RegistryObject<MobEffect> RADIATION = EFFECTS.register("radiation", RadiationEffect::new);

    public static boolean explosionOccurred = false;

    public NuclearApocalypse() {
        IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();

        // Register your custom damage types
        NuclearApocalypseDamageTypes.register(modEventBus);

        // Register effects
        EFFECTS.register(modEventBus);

        // Register common setup
        modEventBus.addListener(this::commonSetup);

        // Register this class for Forge events
        MinecraftForge.EVENT_BUS.register(this);

        LOGGER.info("Nuclear Apocalypse Mod initialized!");
    }

    private void commonSetup(final FMLCommonSetupEvent event) {
        // Initialize the radiation damage source using Holder
        Holder<DamageType> radiationDamageType = NuclearApocalypseDamageTypes.RADIATION.getHolder().orElseThrow(() ->
                new IllegalStateException("Radiation DamageType is not registered."));

        // Initialize the radiation damage source
        RADIATION_DAMAGE_SOURCE = new DamageSource(radiationDamageType);

        LOGGER.info("Nuclear Apocalypse Mod is setting up!");
    }

    @SubscribeEvent
    public static void registerCommands(RegisterCommandsEvent event) {
        SkipTimerCommand.register(event.getDispatcher());
    }

    public static void triggerExplosion() {
        explosionOccurred = true;
    }
}

This is my NuclearApocalypseDamageTypes.java

package net.elileo.nuclearapocalypse.util;

import net.minecraft.core.registries.Registries;
import net.minecraft.world.damagesource.DamageScaling;
import net.minecraft.world.damagesource.DamageType;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;
import net.minecraftforge.eventbus.api.IEventBus;

public class NuclearApocalypseDamageTypes {
    public static final DeferredRegister<DamageType> DAMAGE_TYPES = DeferredRegister.create(Registries.DAMAGE_TYPE, "nuclearapocalypse");

    // Registering the radiation damage type
    public static final RegistryObject<DamageType> RADIATION = DAMAGE_TYPES.register("radiation",
            () -> new DamageType("radiation", DamageScaling.ALWAYS,2.0f));  // Use a valid DamageScaling


    public static void register(IEventBus eventBus) {
        DAMAGE_TYPES.register(eventBus);
    }
}

 

 

 

 

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
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.



×
×
  • Create New...

Important Information

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