Jump to content

[1.8] Problem with rendering entities


Kluuucha

Recommended Posts

Hello there. It's my first topic, so sorry for begging for help at the very beginning.

I have a problem with entities in my mod. I'm updating mod from 1.7.6 to 1.8 (It's a cooperative mod, so I must use this version, despite it's not too fresh). I need entities to work, 'cause they're the main reason why I'm making this project. I had really bad time removing all the errors, but the worst thing for me was RenderManager. And even after handling all of this, my mobs are crashing the game, when rendering code is included. Here are the files (mod is not called myMod, it's just a replacement)

 

Part of main file (only stuff that's about the mob):

 

package net.mymod.common;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.client.EnumHelperClient;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.registry.LanguageRegistry;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.IResourceManager;

@net.minecraftforge.fml.common.Mod(modid = mymod.modid, name = "myMod", version = "pre-build 0.1a")
public class myMod
{
public static final String modid = "mymod";

@net.minecraftforge.fml.common.Mod.EventHandler
public void init (FMLPreInitializationEvent event)
{
           		EntityRegistry.registerModEntity(EntityMyMob.class, "MyMob", 1, this, 64, 1, true, 0xff8100, 0x5d5852);
	RenderingRegistry.registerEntityRenderingHandler(EntityMyMob.class, new RenderMyMob(Minecraft.getMinecraft().getRenderManager(), new ModelMyMob(), 0.2F));
	EntityRegistry.addSpawn(EntityMyMob.class, 10, 4, 8, EnumCreatureType.CREATURE, BiomeGenBase.desert, BiomeGenBase.desertHills, BiomeGenBase.jungle, BiomeGenBase.jungleHills);
	if(FMLCommonHandler.instance().getSide().isClient())
	{
}

 

EntityMyMob:

 

package net.mymod.common;

import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIPanic;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.world.World;

public class EntityMyMob extends EntityAnimal{

public EntityMyMob(World par1World) {
	super(par1World);
	this.setSize(0.5F, 0.5F);
	this.getNavigator().setAvoidsWater(true);
	this.tasks.addTask(0, new EntityAISwimming(this));
	this.tasks.addTask(1, new EntityAIWander(this, 0.6D));
	this.tasks.addTask(2, new EntityAILookIdle(this));
	this.tasks.addTask(3, new EntityAIPanic(this, 0.8D));
}
    protected boolean canDespawn()
    {
        return false;
    }
protected boolean isAIEnabled()
{
	return true;
}
protected Item getDropItemId()
{
	return Items.string;
}
@Override
public EntityAgeable createChild(EntityAgeable var1) {
	return null;
}

}

 

and RenderMyMob:

 

package net.mymod.common;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;

public class RenderMyMob extends RenderLiving {
private static final ResourceLocation texture = new ResourceLocation("mymod:textures/entity/MyMob.png");
protected ModelMyMob model;

public RenderMyMob(RenderManager rm, ModelBase mb, float f)
{
	super(rm, mb, f);
	model = ((ModelMyMob)mainModel);
}

public void renderMyMob(EntityMyMob entity, double par2, double par4, double par6, float par8, float par9)
{
	super.doRender(entity, par2, par4, par6, par8, par9);
}

public void doRenderLiving(EntityMyMob entity, double par2, double par4, double par6, float par8, float par9)
{
	renderMyMob((EntityMyMob)entity, par2, par4, par6, par8, par9);
}

@Override
public void doRender(Entity entity, double d0, double d1, double d2,
		float f, float f1) 
{
	renderMyMob((EntityMyMob)entity, d0, d1, d2, f, f1);
}

@Override
protected ResourceLocation  getEntityTexture(Entity entity) {
	return texture;
}

}

 

This mob has also custom model, if it's needed I'll post it too. It's highly possible that it doesn't work because it's just messy or something, but I'm struggling with it for long hours and I can't make it work. Thanks in advance, I hope you won't laugh me down :P I'm returning to modding after loooooong break, I'm just lost in changes.

Link to comment
Share on other sites

The

RenderManager

instance is created between the preInit and init phases, so

Minecraft#getRenderManager

returns

null

in preInit.

 

In 1.8, call

RenderingRegistry#registerEntityRenderingHandler

in init. In 1.8.9 and up, call

RenderingRegistry#registerEntityRenderingHandler(Class<T>, IRenderFactory<? super T>)

in preInit instead.

 

In future, post the FML log (logs/fml-client-latest.log) or crash report; preferably using a site like Gist or Pastebin.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I am following a tutorial for modding minecraft 1.20.1, and while running the mod with the minecraft of the idea, no errors was present but, when I switched to real minecraft, it started to want a default constructor "public ZeroToAutomation()" instead of the one recomended by the video "public ZeroToAutomation(FMLJavaModLoadingContext context) {...}", and I can't use the default constructor because I need the FMLJavaModLoadingContext to register the blocks and items.   The problem is at: "net/myself/zerotoautomation/ZeroToAutomation.java" the file contains the default constructor, "Logger"s, and the code for the mod the defaut constructor was added after an error requesting it the Loggers was used to see which methods/constructors was used by the Launcher   things that I tried to fix the issue: remove the default constructor, but an error appeared "net.myself.zerotoautomation.ZeroToAutomation.<init>()", and nothing else on the class runs adding an "public static void init()" method, but it changed nothing   The mod files: https://github.com/Matwaua/Zero_To_Automation/tree/not-finished
    • It is an issue/conflict with distanthorizons
    • I have been trying to combat this issue between oculus and embeddium and to no avail... I have already tried a few online tutorials on how to get this working but it doesn't work at all. https://pastebin.com/geQgifjc
    • wow you sound like fun to play with
    • Instale el mod en mi servidor y este se queda iniciando por horas, en la consola me habla de algo de permisos y trate de seguir la ruta que me da pero no existe.   [13:05:32 INFO]: CustomNPC Permissions available: [13:05:32 INFO]: customnpcs.edit.blocks [13:05:32 INFO]: customnpcs.edit.villager [13:05:32 INFO]: customnpcs.global.bank [13:05:32 INFO]: customnpcs.global.dialog [13:05:32 INFO]: customnpcs.global.faction [13:05:32 INFO]: customnpcs.global.linked [13:05:32 INFO]: customnpcs.global.naturalspawn [13:05:32 INFO]: customnpcs.global.playerdata [13:05:32 INFO]: customnpcs.global.quest [13:05:32 INFO]: customnpcs.global.recipe [13:05:32 INFO]: customnpcs.global.transport [13:05:32 INFO]: customnpcs.npc.advanced [13:05:32 INFO]: customnpcs.npc.ai [13:05:32 INFO]: customnpcs.npc.clone [13:05:32 INFO]: customnpcs.npc.create [13:05:32 INFO]: customnpcs.npc.delete [13:05:32 INFO]: customnpcs.npc.display [13:05:32 INFO]: customnpcs.npc.freeze [13:05:32 INFO]: customnpcs.npc.gui [13:05:32 INFO]: customnpcs.npc.inventory [13:05:32 INFO]: customnpcs.npc.reset [13:05:32 INFO]: customnpcs.npc.stats [13:05:32 INFO]: customnpcs.scenes [13:05:32 INFO]: customnpcs.soulstone.all [13:05:32 INFO]: customnpcs.spawner.create [13:05:32 INFO]: customnpcs.spawner.mob [13:05:32 INFO]: customnpcs.tool.mounter [13:05:32 INFO]: customnpcs.tool.nbtbook [13:05:32 INFO]: customnpcs.tool.pather [13:05:32 INFO]: customnpcs.tool.scripter
  • Topics

×
×
  • Create New...

Important Information

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