All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.phantomloader.library.forge.events.ModClientEvents Maven / Gradle / Ivy

Go to download

A library that can automate the process of creating minecraft mods for multiple loaders

The newest version!
package io.github.phantomloader.library.forge.events;

import io.github.phantomloader.library.events.ClientEventHandler;
import io.github.phantomloader.library.events.RegisterBlockEntityRenderersEvent;
import io.github.phantomloader.library.events.RegisterEntityRenderersEvent;
import io.github.phantomloader.library.events.RegisterParticlesEvent;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.client.event.RegisterParticleProvidersEvent;
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import java.util.ServiceLoader;

/**
 * 

* Forge event handler for client events. *

* * @author Nico */ @Mod.EventBusSubscriber(value = Dist.CLIENT, modid = "phantom", bus = Mod.EventBusSubscriber.Bus.MOD) public class ModClientEvents { /** Event handlers loaded using service loader */ private static final ServiceLoader HANDLERS = ServiceLoader.load(ClientEventHandler.class); /** *

* Forge event handler. *

* * @param event Forge event. */ @SubscribeEvent public static void creativeTabEvent(BuildCreativeModeTabContentsEvent event) { for(ClientEventHandler handler : HANDLERS) { handler.addItemsToCreativeTab(event.getTabKey(), event::accept); } } /** *

* Forge event handler. *

* * @param event Forge event. */ @SubscribeEvent public static void registerRenders(EntityRenderersEvent.RegisterRenderers event) { for(ClientEventHandler handler : HANDLERS) { handler.registerBlockEntityRenderers(new RegisterBlockEntityRenderersEventForge(event)); handler.registerEntityRenderers(new RegisterEntityRenderersEventForge(event)); } } /** *

* Forge event handler. *

* * @param event Forge event. */ @SubscribeEvent public static void registerParticles(RegisterParticleProvidersEvent event) { for(ClientEventHandler handler : HANDLERS) { handler.registerParticles(new RegisterParticlesEventForge(event)); } } /** *

* Implementation of {@link RegisterBlockEntityRenderersEvent}. * Wraps a {@link EntityRenderersEvent.RegisterRenderers} for it to be used in the common module. *

* * @author Nico */ public static class RegisterBlockEntityRenderersEventForge implements RegisterBlockEntityRenderersEvent { /** Forge event */ private final EntityRenderersEvent.RegisterRenderers forgeEvent; /** *

* Constructs an event. *

* * @param forgeEvent Forge event. */ public RegisterBlockEntityRenderersEventForge(EntityRenderersEvent.RegisterRenderers forgeEvent) { this.forgeEvent = forgeEvent; } @Override public void register(BlockEntityType blockEntity, BlockEntityRendererProvider renderer) { this.forgeEvent.registerBlockEntityRenderer(blockEntity, renderer); } } /** *

* Implementation of {@link RegisterEntityRenderersEvent}. * Wraps a {@link EntityRenderersEvent.RegisterRenderers} for it to be used in the common module. *

* * @author Nico */ public static class RegisterEntityRenderersEventForge implements RegisterEntityRenderersEvent { /** Forge event */ private final EntityRenderersEvent.RegisterRenderers forgeEvent; /** *

* Constructs an event. *

* * @param forgeEvent Forge event. */ public RegisterEntityRenderersEventForge(EntityRenderersEvent.RegisterRenderers forgeEvent) { this.forgeEvent = forgeEvent; } @Override public void register(EntityType entity, EntityRendererProvider renderer) { this.forgeEvent.registerEntityRenderer(entity, renderer); } } /** *

* Implementation of {@link RegisterParticlesEvent}. * Wraps a {@link RegisterParticleProvidersEvent} for it to be used in the common module. *

* * @author Nico */ public static class RegisterParticlesEventForge implements RegisterParticlesEvent { /** Forge event */ private final RegisterParticleProvidersEvent forgeEvent; /** *

* Constructs an event. *

* * @param forgeEvent Forge event. */ public RegisterParticlesEventForge(RegisterParticleProvidersEvent forgeEvent) { this.forgeEvent = forgeEvent; } @Override public void register(ParticleType type, ParticleProvider provider) { this.forgeEvent.registerSpecial(type, provider); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy