Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
3.1 kB
7
Indexable
Never
package com.radon.naruto_universe;

import com.radon.naruto_universe.capability.IShinobi;
import com.radon.naruto_universe.client.entity.FireBulletRenderer;
import com.radon.naruto_universe.client.entity.GreatFireballRenderer;
import com.radon.naruto_universe.client.entity.PhoenixFlowerRenderer;
import com.radon.naruto_universe.entity.EntityRegistry;
import com.radon.naruto_universe.item.ItemRegistry;
import com.radon.naruto_universe.particle.FireballParticle;
import com.radon.naruto_universe.particle.ParticleRegistry;
import com.radon.naruto_universe.proxy.ClientProxy;
import com.radon.naruto_universe.proxy.CommonProxy;
import net.minecraft.client.Minecraft;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.client.event.ParticleFactoryRegisterEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;

@Mod("naruto_universe")
public class NarutoUniverse {
    public static final String MOD_ID = "naruto_universe";
    public static final CommonProxy PROXY = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> CommonProxy::new);

    public NarutoUniverse() {
        IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
        bus.addListener(this::onCommonSetup);
        bus.addListener(this::onClientSetup);
        bus.addListener(this::onRegisterEntityRenderers);
        bus.addListener(this::onRegisterCapabilities);
        bus.addListener(this::onRegisterParticles);

        ItemRegistry.ITEMS.register(bus);
        EntityRegistry.ENTITIES.register(bus);
        ParticleRegistry.PARTICLES.register(bus);
    }

    private void onCommonSetup(FMLCommonSetupEvent event) {
        PROXY.onCommonSetup();
    }

    private void onClientSetup(FMLClientSetupEvent event) {
        PROXY.onClientSetup();
    }

    private void onRegisterEntityRenderers(EntityRenderersEvent.RegisterRenderers event) {
        event.registerEntityRenderer(EntityRegistry.PHOENIX_FLOWER.get(), PhoenixFlowerRenderer::new);
        event.registerEntityRenderer(EntityRegistry.GREAT_FIREBALL.get(), GreatFireballRenderer::new);
        event.registerEntityRenderer(EntityRegistry.FIRE_BULLET.get(), FireBulletRenderer::new);
    }

    private void onRegisterCapabilities(RegisterCapabilitiesEvent event) {
        event.register(IShinobi.class);
    }

    private void onRegisterParticles(ParticleFactoryRegisterEvent event) {
        Minecraft.getInstance().particleEngine.register(ParticleRegistry.FIREBALL_PARTICLE.get(), FireballParticle.Provider::new);
    }
}