Jump to content

[1.14.2] Entity is Invisible!


MatsCraft1

Recommended Posts

My problem is that my Entity is invisible.

Here's all of my code for the Entity.

 

ModEntityRender.java

Spoiler

 


package com.aug15.morestuff.client.renders;

import com.aug15.morestuff.client.models.BoarEntityModel;
import com.aug15.morestuff.entities.EntityBoarNow;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.entity.LivingRenderer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.registry.IRenderFactory;

@OnlyIn(Dist.CLIENT)
public class ModEntityRender extends LivingRenderer<EntityBoarNow, BoarEntityModel>
    {

        public ModEntityRender(EntityRendererManager manager)
        {
            super(manager, new BoarEntityModel(), 0f);
        }

    @Override
    protected ResourceLocation getEntityTexture(EntityBoarNow entity)
    {
        return new ResourceLocation("textures/entity/boar_entity.png");
    }

    public static class RenderFactory implements IRenderFactory<EntityBoarNow>
    {
        @Override
        public EntityRenderer<? super EntityBoarNow> createRenderFor(EntityRendererManager manager) {
            return new ModEntityRender(manager);
        }
    }
}

 

BoarEntityModel.java

Spoiler

package com.aug15.morestuff.client.models;

import com.aug15.morestuff.entities.EntityBoarNow;
import net.minecraft.client.renderer.entity.LivingRenderer;
import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.entity.model.RendererModel;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
public class BoarEntityModel extends EntityModel<EntityBoarNow> {
    public RendererModel Bauch;
    public RendererModel FussHintenLinks;
    public RendererModel FussVorneLinks;
    public RendererModel FussHintenRechts;
    public RendererModel FussVorneRechts;
    public RendererModel Kopf;
    public RendererModel Schnauze;
    public RendererModel Stosszahn;
    public RendererModel StosszahnZwei;

    public BoarEntityModel() {
        this.textureWidth = 64;
        this.textureHeight = 32;
        this.Kopf = new RendererModel(this, 0, 0);
        this.Kopf.setRotationPoint(0.0F, 12.0F, -6.0F);
        this.Kopf.addBox(-4.0F, -4.0F, -8.0F, 8, 8, 8, 0.0F);
        this.Bauch = new RendererModel(this, 28, 8);
        this.Bauch.setRotationPoint(0.0F, 11.0F, 2.0F);
        this.Bauch.addBox(-5.0F, -10.0F, -7.0F, 10, 16, 8, 0.0F);
        this.setRotateAngle(Bauch, 1.5707963267948966F, 0.0F, 0.0F);
        this.StosszahnZwei = new RendererModel(this, 10, 29);
        this.StosszahnZwei.mirror = true;
        this.StosszahnZwei.setRotationPoint(-3.0F, 13.0F, -15.3F);
        this.StosszahnZwei.addBox(0.0F, 0.0F, 0.0F, 1, 2, 1, 0.0F);
        this.setRotateAngle(StosszahnZwei, 0.4363323129985824F, 0.0F, 0.0F);
        this.FussHintenLinks = new RendererModel(this, 0, 16);
        this.FussHintenLinks.setRotationPoint(3.0F, 18.0F, 7.0F);
        this.FussHintenLinks.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, 0.0F);
        this.FussVorneLinks = new RendererModel(this, 0, 16);
        this.FussVorneLinks.setRotationPoint(3.0F, 18.0F, -5.0F);
        this.FussVorneLinks.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, 0.0F);
        this.Stosszahn = new RendererModel(this, 10, 29);
        this.Stosszahn.mirror = true;
        this.Stosszahn.setRotationPoint(2.0F, 13.0F, -15.3F);
        this.Stosszahn.addBox(0.0F, 0.0F, 0.0F, 1, 2, 1, 0.0F);
        this.setRotateAngle(Stosszahn, 0.4363323129985824F, 0.0F, 0.0F);
        this.FussHintenRechts = new RendererModel(this, 0, 16);
        this.FussHintenRechts.setRotationPoint(-3.0F, 18.0F, 7.0F);
        this.FussHintenRechts.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, 0.0F);
        this.FussVorneRechts = new RendererModel(this, 0, 16);
        this.FussVorneRechts.setRotationPoint(-3.0F, 18.0F, -5.0F);
        this.FussVorneRechts.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, 0.0F);
        this.Schnauze = new RendererModel(this, 16, 27);
        this.Schnauze.setRotationPoint(0.0F, 12.0F, -7.0F);
        this.Schnauze.addBox(-2.0F, 0.0F, -9.0F, 4, 3, 2, 0.0F);
    }

    public void render(EntityBoarNow entityIn, float scale) {
        this.Kopf.render(scale);
        this.Bauch.render(scale);
        this.StosszahnZwei.render(scale);
        this.FussHintenLinks.render(scale);
        this.FussVorneLinks.render(scale);
        this.Stosszahn.render(scale);
        this.FussHintenRechts.render(scale);
        this.FussVorneRechts.render(scale);
        this.Schnauze.render(scale);
    }

    public void setRotateAngle(RendererModel modelRenderer, float x, float y, float z) {
        modelRenderer.rotateAngleX = x;
        modelRenderer.rotateAngleY = y;
        modelRenderer.rotateAngleZ = z;

    }
}

 

ModRenderRegistry.java

Spoiler

package com.aug15.morestuff.client.renders;

import com.aug15.morestuff.entities.EntityBoarNow;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.registry.RenderingRegistry;

@OnlyIn(Dist.CLIENT)
public class ModRenderRegistry {

    public static void registerEntityRenderers()
    {
        RenderingRegistry.registerEntityRenderingHandler(EntityBoarNow.class, new ModEntityRender.RenderFactory());
    }

}

MorestuffEntity.java

Spoiler

package com.aug15.morestuff.entities;

import com.aug15.morestuff.MoreStuff;
import com.aug15.morestuff.biomes.ModBiomes;
import com.aug15.morestuff.items.ModItems;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Item;
import net.minecraft.item.SpawnEggItem;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraftforge.event.RegistryEvent;

public class MorestuffEntity {

    public static EntityType<?> ENTITYBOAR = EntityType.Builder.create
            (EntityBoarNow::new, EntityClassification.CREATURE).build("entity_boar").setRegistryName("entity_boar");

    public static void registerEntitySpawnEggs(final RegistryEvent.Register<Item> event)
    {
        event.getRegistry().registerAll(
                ModItems.BOARSPAWNEGG = registerEntitySpawnEgg(ENTITYBOAR, 0x5c401f, 0xb38c5f, "boar_spawnegg"));
    }

    public static void registerEntityWorldSpawns()
    {
        registerEntityWorldSpawn(ENTITYBOAR, Biomes.BIRCH_FOREST, ModBiomes.GREECEFOREST, Biomes.DARK_FOREST, Biomes.FOREST, Biomes.TAIGA);
    }

    public static Item registerEntitySpawnEgg(EntityType<?> type, int farbeEins, int farbeZwei, String name) {
        SpawnEggItem item = new SpawnEggItem(type, farbeEins, farbeZwei, new Item.Properties().group(MoreStuff.morestuff_tools.GroupTools));
        item.setRegistryName(name);
        return item;
    }

    public static void registerEntityWorldSpawn(EntityType<?> entity, Biome... biomes)
    {
        for(Biome biome : biomes)
        {
            if(biome != null)
            {
                biome.getSpawns(entity.getClassification()).add(new Biome.SpawnListEntry(entity, 10, 1, 4));
            }
        }
    }

}

And I called this "EntityBoarNow.java" (strange name, don't ask why)

Spoiler

package com.aug15.morestuff.entities;

import net.minecraft.entity.CreatureEntity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ai.goal.*;
import net.minecraft.world.World;

public class EntityBoarNow extends CreatureEntity {

    @SuppressWarnings("unchecked")
    public EntityBoarNow(EntityType<? extends CreatureEntity> type, World worldIn) {
        super((EntityType<? extends CreatureEntity>) MorestuffEntity.ENTITYBOAR, worldIn);
    }

    @Override
    protected void registerGoals() {
        this.goalSelector.addGoal(0, new SwimGoal(this));
        this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 0.8D, true));
        this.targetSelector.addGoal(2, (new HurtByTargetGoal(this)).setCallsForHelp());
        this.goalSelector.addGoal(3, new WaterAvoidingRandomWalkingGoal(this, 1.0D));
        this.goalSelector.addGoal(4, new RandomWalkingGoal(this, 0.8d));
        this.goalSelector.addGoal(5, new LookRandomlyGoal(this));
    }

   // @Override
   // protected void registerAttributes() {
    //    getAttribute(SharedMonsterAttributes.MAX_HEALTH).;
     //   //getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.8);
    //}
}

This is in my ClientProxy.java

Spoiler

@SubscribeEvent
public static void clientRegistries(final FMLClientSetupEvent event)
{
    ModRenderRegistry.registerEntityRenderers();

}

And this in my Main

Spoiler

@SubscribeEvent
public static void onEntityRegistry(final RegistryEvent.Register<EntityType<?>> event) {

    event.getRegistry().registerAll
            (
                    MorestuffEntity.ENTITYBOAR
            );

    MorestuffEntity.registerEntityWorldSpawns();
}

@SubscribeEvent
public static void clientRegistries(final FMLClientSetupEvent event)
{
    ModRenderRegistry.registerEntityRenderers();
}

 

It might be possible that I missed some file here.

Please be nice to me @diesieben07 this is my first post

Link to comment
Share on other sites

4 minutes ago, diesieben07 said:

Why are you calling registerEntityRenderers from two places?

I guess I was messing around

5 minutes ago, diesieben07 said:

You have not posted the contents of registerEntityRenderers.

I think I have:

Spoiler

 


public static void registerEntityRenderers()
{
    RenderingRegistry.registerEntityRenderingHandler(EntityBoarNow.class, new ModEntityRender.RenderFactory());
}

 

5 minutes ago, diesieben07 said:

Do not create registry entries in static initializers. 

What shall I do instead?

6 minutes ago, diesieben07 said:

Is the entity actually invisible? Or does it render using missing texture or white cube?

At first it was a white box, then I started messing around with the code until it was actually invisible, I can see a shadow but nothing else

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.

Announcements



×
×
  • Create New...

Important Information

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