Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello, 

I'm trying to create a tnt but I can't manage to register the EntityRenderer.

Here is the error

C:\Users\hadri\Desktop\futurcraft\src\main\java\fr\steakmans\futurcraft\utils\ClientModEvents.java:24: error: incompatible types: inference variable T has incompatible bounds
        e.registerEntityRenderer(ModEntities.PRIMED_INCENDIARY_TNT.get(), IncendiaryTntRenderer::new);
                                ^
    equality constraints: IncendiaryPrimedTnt
    lower bounds: Entity
  where T is a type-variable:
    T extends Entity declared in method <T>registerEntityRenderer(EntityType<? extends T>,EntityRendererProvider<T>)

And here is my ClientModEvents:

package fr.steakmans.futurcraft.utils;

import fr.steakmans.futurcraft.Main;
import fr.steakmans.futurcraft.entity.ModEntities;
import fr.steakmans.futurcraft.entity.explosion.IncendiaryPrimedTnt;
import fr.steakmans.futurcraft.entity.explosion.renderer.IncendiaryTntRenderer;
import net.minecraft.client.renderer.entity.EntityRenderers;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;

@Mod.EventBusSubscriber(modid = Main.MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class ClientModEvents {

    @SubscribeEvent
    public void clientSetup(FMLClientSetupEvent e) {

    }

    @SubscribeEvent
    public void registerRenderers(EntityRenderersEvent.RegisterRenderers e) {
        e.registerEntityRenderer(ModEntities.PRIMED_INCENDIARY_TNT.get(), IncendiaryTntRenderer::new);
    }

}

And lastly, here is my ModEntities:
 

package fr.steakmans.futurcraft.entity;

import fr.steakmans.futurcraft.Main;
import fr.steakmans.futurcraft.entity.explosion.IncendiaryPrimedTnt;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.entity.item.PrimedTnt;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

public class ModEntities {

    public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, Main.MODID);

    public static final RegistryObject<EntityType<Entity>> PRIMED_INCENDIARY_TNT = ENTITIES.register("primed_incendiary_tnt", () -> 	 EntityType.Builder.of(IncendiaryPrimedTnt::new, MobCategory.MISC).build(new ResourceLocation(Main.MODID, "incendiary_primed_tnt").toString()));

}

 

1 hour ago, steakmans said:
RegistryObject<EntityType<Entity>> PRIMED_INCENDIARY_TNT

you need to specify the EntityType to the Entity you register (IncendiaryPrimedTnt)

  • Author

When I do  that there is another error:
 

C:\Users\hadri\Desktop\futurcraft\src\main\java\fr\steakmans\futurcraft\entity\ModEntities.java:18: error: incompatible types: inference variable I has incompatible bounds
    public static final RegistryObject<EntityType<IncendiaryPrimedTnt>> PRIMED_INCENDIARY_TNT = ENTITIES.register("primed_incendiary_tnt", () -> EntityType.Builder.of(IncendiaryPrimedTnt::new, MobCategory.MISC).build(new ResourceLocation(Main.MODID, "incendiary_primed_tnt").toString()));
                                                                                                                 ^
    equality constraints: EntityType<IncendiaryPrimedTnt>
    lower bounds: EntityType<Entity>
  where I is a type-variable:
    I extends EntityType<?> declared in method <I>register(String,Supplier<? extends I>)

 

unfortunately I'm not at my pc, but it should EntityType.Builder<YourEntity>.of or EntityType.Builder.<YourEntity>of

  • Author

The second one worked but nom I have (again) another error:
 

java.lang.NullPointerException: Cannot invoke "net.minecraft.client.renderer.entity.EntityRenderer.shouldRender(net.minecraft.world.entity.Entity, net.minecraft.client.renderer.culling.Frustum, double, double, double)" because "entityrenderer" is null
	at net.minecraft.client.renderer.entity.EntityRenderDispatcher.shouldRender(EntityRenderDispatcher.java:116) ~[forge-1.18.2-40.0.48_mapped_official_1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.LevelRenderer.renderLevel(LevelRenderer.java:1193) ~[forge-1.18.2-40.0.48_mapped_official_1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.GameRenderer.renderLevel(GameRenderer.java:1059) ~[forge-1.18.2-40.0.48_mapped_official_1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.GameRenderer.render(GameRenderer.java:833) ~[forge-1.18.2-40.0.48_mapped_official_1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.runTick(Minecraft.java:1044) ~[forge-1.18.2-40.0.48_mapped_official_1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.run(Minecraft.java:663) ~[forge-1.18.2-40.0.48_mapped_official_1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.main(Main.java:205) ~[forge-1.18.2-40.0.48_mapped_official_1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ~[?:?] {}
	at java.lang.reflect.Method.invoke(Method.java:577) ~[?:?] {}
	at net.minecraftforge.fml.loading.targets.ForgeClientUserdevLaunchHandler.lambda$launchService$0(ForgeClientUserdevLaunchHandler.java:38) ~[fmlloader-1.18.2-40.0.48.jar%230!/:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.1.3.jar%2310!/:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.1.3.jar%2310!/:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.1.3.jar%2310!/:?] {}
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.1.3.jar%2310!/:?] {}
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.1.3.jar%2310!/:?] {}
	at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.1.3.jar%2310!/:?] {}
	at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.1.3.jar%2310!/:?] {}
	at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:149) [bootstraplauncher-1.0.0.jar:?] {}

 

your EventHandler for the registery of the EntityRenderer is not called,
since ClientModEvents#registerRenderers must be static if you use @EventBusSubscriber

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.