Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Custom Entity Error


Recommended Posts

I have a custom entity but when i try to spawn it i get 


java.lang.NullPointerException: Cannot invoke "net.minecraft.client.renderer.entity.EntityRenderer.shouldRender(net.minecraft.entity.Entity, net.minecraft.client.renderer.culling.ClippingHelper, double, double, double)" because "entityrenderer" is null

 

Link to post
Share on other sites
Just now, diesieben07 said:

Show where you register it.

package mod.trianglesinpoo.mcores;


    import mod.trianglesinpoo.mcores.Main;
    import mod.trianglesinpoo.mcores.ModEntityTypes;
    import mod.trianglesinpoo.mcores.PartymiteRenderer;
    import net.minecraftforge.api.distmarker.Dist;
    import net.minecraftforge.eventbus.api.SubscribeEvent;
    import net.minecraftforge.fml.client.registry.RenderingRegistry;
    import net.minecraftforge.fml.common.Mod;
    import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;

    @Mod.EventBusSubscriber(modid = Main.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
    public class ClientEvents {
        @SubscribeEvent
        public static void onClientSetup(FMLClientSetupEvent event) {
             RenderingRegistry.registerEntityRenderingHandler(ModEntityTypes.MITE.get(), PartymiteRenderer::new);
        }
    }


 

Link to post
Share on other sites
Just now, diesieben07 said:

Show more of your code. Your entity class and where you reigster your entity.

package mod.trianglesinpoo.mcores;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;

import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class PartymiteModel <T extends PartymiteEntity> extends EntityModel<T>{
	private final ModelRenderer head;
	private final ModelRenderer body;

	public PartymiteModel() {
		texWidth = 64;
		texHeight = 64;

		head = new ModelRenderer(this);
		head.setPos(0.0F, 24.0F, 0.0F);
		head.texOffs(0, 25).addBox(-3.0F, -3.0F, -2.0F, 2.0F, 3.0F, 4.0F, 0.0F, true);

		body = new ModelRenderer(this);
		body.setPos(0.0F, 24.0F, 0.0F);
		body.texOffs(0, 6).addBox(-1.0F, -4.0F, -3.0F, 5.0F, 4.0F, 6.0F, 0.0F, false);
	}





	public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
		modelRenderer.xRot = x;
		modelRenderer.yRot = y;
		modelRenderer.zRot = z;
	}

	@Override
	public void setupAnim(T p_225597_1_, float p_225597_2_, float p_225597_3_, float p_225597_4_, float p_225597_5_,
			float p_225597_6_) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void renderToBuffer(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay,
			float p_225598_5_, float p_225598_6_, float p_225598_7_, float p_225598_8_) {
		head.render(matrixStack, buffer, packedLight, packedOverlay);
		body.render(matrixStack, buffer, packedLight, packedOverlay);
		
	}
}
public class ModEntityTypes {
	 private static final DeferredRegister<EntityType<?>> MOBS = DeferredRegister.create(ForgeRegistries.ENTITIES, Main.MODID);
	
	 public static final RegistryObject<EntityType<PartymiteEntity>> MITE = MOBS.register("partymite", () -> EntityType.Builder.<PartymiteEntity>of(PartymiteEntity::new, EntityClassification.CREATURE).sized(0.5F, 0.6f)
			 .build(new ResourceLocation(Main.MODID,"partymite").toString()));
	 public static void init() {
		 MOBS.register(FMLJavaModLoadingContext.get().getModEventBus());
	 }
}

 

Link to post
Share on other sites
Just now, diesieben07 said:

And now your entity class.

public class PartymiteEntity extends AnimalEntity{
	public static final Ingredient T = Ingredient.of(ItemHolder.PBANANA.get());
	protected PartymiteEntity(EntityType<? extends AnimalEntity> p_i48568_1_, World p_i48568_2_) {
		super(p_i48568_1_, p_i48568_2_);
		// TODO Auto-generated constructor stub
	}

	@Override
	public AgeableEntity getBreedOffspring(ServerWorld p_241840_1_, AgeableEntity p_241840_2_) {
		// TODO Auto-generated method stub
		return ModEntityTypes.MITE.get().create(p_241840_1_);
	}

	public static AttributeModifierMap.MutableAttribute setCustomAttributes() {
		return MobEntity.createMobAttributes().add(Attributes.MAX_HEALTH, 15.0D).add(Attributes.MOVEMENT_SPEED, 1.0D);
	}
	@Override protected void registerGoals() {
		super.registerGoals();
		this.goalSelector.addGoal(0,new SwimGoal(this));
		this.goalSelector.addGoal(1,new PanicGoal(this, 2.350D));
		this.goalSelector.addGoal(2, new BreedGoal(this,2.0D));
		this.goalSelector.addGoal(3, new TemptGoal(this,2.5D,false,T));
		this.goalSelector.addGoal(4,new FollowParentGoal(this,2.5D));
		this.goalSelector.addGoal(5,new WaterAvoidingRandomWalkingGoal(this, 2.0D));
		this.goalSelector.addGoal(6, new LookAtGoal(this,PlayerEntity.class,8.0F));
		this.goalSelector.addGoal(7, new LookRandomlyGoal(this));
		
	}
	@Nullable
	@Override
	protected SoundEvent getAmbientSound() {
		return SoundEvents.ENDERMITE_AMBIENT;
	}
	@Nullable
	@Override
	protected SoundEvent getHurtSound(DamageSource s) {
		return SoundEvents.ENDERMITE_HURT;
	}
	@Nullable
	@Override
	protected SoundEvent getDeathSound() {
		return SoundEvents.ENDERMITE_DEATH;
	}
	@Override
	protected void playStepSound(BlockPos pos,BlockState blockIn) {
		this.playSound(SoundEvents.ENDERMITE_STEP,0.15F,1.0F);
	}
}

 

Link to post
Share on other sites
46 minutes ago, diesieben07 said:

Ugh, no idea why I did not see this earlier.

This is the wrong event bus for this event.

I fixed it and now i get 

[12:33:21] [Render thread/FATAL] [minecraft/Minecraft]: Reported exception thrown!
net.minecraft.crash.ReportedException: Rendering entity in world

 

Link to post
Share on other sites
8 minutes ago, diesieben07 said:

Post the full log. 

12:33:21] [Render thread/FATAL] [minecraft/Minecraft]: Reported exception thrown!
net.minecraft.crash.ReportedException: Rendering entity in world
	at net.minecraft.client.renderer.entity.EntityRendererManager.render(EntityRendererManager.java:279) ~[forge-1.16.5-36.1.4_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.WorldRenderer.renderEntity(WorldRenderer.java:1202) ~[forge-1.16.5-36.1.4_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.WorldRenderer.renderLevel(WorldRenderer.java:1010) ~[forge-1.16.5-36.1.4_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.GameRenderer.renderLevel(GameRenderer.java:608) ~[forge-1.16.5-36.1.4_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.GameRenderer.render(GameRenderer.java:425) ~[forge-1.16.5-36.1.4_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.runTick(Minecraft.java:976) ~[forge-1.16.5-36.1.4_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.run(Minecraft.java:607) ~[forge-1.16.5-36.1.4_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.5-36.1.4_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?] {}
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}
	at java.lang.reflect.Method.invoke(Method.java:564) ~[?:?] {}
	at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:52) ~[forge-1.16.5-36.1.4_mapped_official_1.16.5-recomp.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.9.jar:?] {}
	at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) [forge-1.16.5-36.1.4_mapped_official_1.16.5-recomp.jar:?] {}
Caused by: java.lang.NullPointerException
	at java.util.Objects.requireNonNull(Objects.java:222) ~[?:?] {}
	at java.util.Optional.of(Optional.java:111) ~[?:?] {}
	at net.minecraft.client.renderer.RenderState$TextureState.<init>(RenderState.java:618) ~[forge-1.16.5-36.1.4_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.RenderType.entityCutoutNoCull(RenderType.java:93) ~[forge-1.16.5-36.1.4_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.RenderType.entityCutoutNoCull(RenderType.java:98) ~[forge-1.16.5-36.1.4_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.model.Model.renderType(Model.java:26) ~[forge-1.16.5-36.1.4_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.entity.LivingRenderer.getRenderType(LivingRenderer.java:140) ~[forge-1.16.5-36.1.4_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.entity.LivingRenderer.render(LivingRenderer.java:116) ~[forge-1.16.5-36.1.4_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.entity.MobRenderer.render(MobRenderer.java:40) ~[forge-1.16.5-36.1.4_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.entity.MobRenderer.render(MobRenderer.java:20) ~[forge-1.16.5-36.1.4_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.entity.EntityRendererManager.render(EntityRendererManager.java:251) ~[forge-1.16.5-36.1.4_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	... 18 more
[12:33:21] [Render thread/INFO] [STDOUT/]: [net.minecraft.util.registry.Bootstrap:realStdoutPrintln:123]: ---- Minecraft Crash Report ----
// I bet Cylons wouldn't have this problem.

Time: 2021-05-04, 12:33 p.m.
Description: Rendering entity in world

 

Link to post
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.

Guest
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 Privacy Policy.