Jump to content

[1.7.2][Solved] Render Not Being Registered


TLHPoE

Recommended Posts

I've had this problem before, but I cannot find the old post in my history. :(

 

Yesterday my entities were rendering perfectly, but now they don't render at all. None of the methods in the render class are called except for the constructor, which leads me to believe that the renders are not being registered properly.

 

ClientProxy:

package legions;

import java.io.File;

import legions.entity.EntityArcherL;
import legions.entity.EntityInfantryL;
import legions.entity.EntityTroopLeaderL;
import legions.handler.ClientFMLEventHandlerL;
import legions.handler.ClientForgeEventHandlerL;
import legions.handler.KeyHandlerL;
import legions.network.PacketCommandL;
import legions.render.RenderHumanL;
import net.minecraftforge.common.config.Configuration;
import cpw.mods.fml.client.registry.RenderingRegistry;

public class ClientProxyL extends ServerProxyL {
public static Configuration config;
public static ClientFMLEventHandlerL fmlEvents;
public static ClientForgeEventHandlerL forgeEvents;
public static KeyHandlerL keyHandler;

@Override
public void initClient() {
	config = new Configuration(new File("./config/Legions/Client.cfg"), true);
	config.load();
	addKeys();
	loadConfigurations();
	addEvents();
	addRenders();
	config.save();
}

public void loadConfigurations() {
	shouldSlide = config.get("Gui", "Enable Sliding Menu", true).getBoolean(true);
}

public void addKeys() {
	keyHandler = new KeyHandlerL();
}

public void addEvents() {
	fmlEvents = new ClientFMLEventHandlerL();
	forgeEvents = new ClientForgeEventHandlerL();
}

public void addRenders() {
	for(int i = 0; i < 1000; i++) {
		System.err.println("ADDING RENDERS");
	}
	RenderingRegistry.registerEntityRenderingHandler(EntityInfantryL.class, new RenderHumanL());
	RenderingRegistry.registerEntityRenderingHandler(EntityArcherL.class, new RenderHumanL());
	RenderingRegistry.registerEntityRenderingHandler(EntityTroopLeaderL.class, new RenderHumanL());
}

public static boolean shouldSlide;
public static int currentMenu = 0;
public static int guiY = -64;
public static PacketCommandL commandPacket;
}

 

Entity (I have 3 more entities that are virtually the same):

package legions.entity;

import legions.TroopL;
import legions.UtilL;
import net.minecraft.entity.EntityLiving;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class EntityInfantryL extends EntityLiving {
public int type;
public boolean hired = false;

public EntityInfantryL(World world) {
	super(world);
	this.setDead();
}

public EntityInfantryL(World world, int type) {
	super(world);
	this.type = type;
	this.setSize(0.6F, 1.8F);
}

@Override
public void writeEntityToNBT(NBTTagCompound nbt) {
	super.writeEntityToNBT(nbt);
	nbt.setInteger("Type", type);
}

@Override
protected boolean canDespawn() {
	return false;
}

@Override
public void readEntityFromNBT(NBTTagCompound nbt) {
	super.readEntityFromNBT(nbt);
	type = nbt.getInteger("Type");
}

public void giveEquipment() {
	switch(type) {
	case (TroopL.BASIC_INFANTRY_1):
		this.setCurrentItemOrArmor(0, new ItemStack(Items.wooden_sword));
		break;
	case (TroopL.BASIC_INFANTRY_2):
		this.setCurrentItemOrArmor(0, new ItemStack(Items.stone_sword));
		this.setCurrentItemOrArmor(4, new ItemStack(Items.golden_helmet));
		this.setCurrentItemOrArmor(3, new ItemStack(Items.golden_chestplate));
		this.setCurrentItemOrArmor(2, new ItemStack(Items.golden_leggings));
		this.setCurrentItemOrArmor(1, new ItemStack(Items.golden_boots));
		break;
	case (TroopL.BASIC_INFANTRY_3):
		this.setCurrentItemOrArmor(0, new ItemStack(Items.iron_sword));
		this.setCurrentItemOrArmor(4, new ItemStack(Items.iron_helmet));
		this.setCurrentItemOrArmor(3, new ItemStack(Items.iron_chestplate));
		this.setCurrentItemOrArmor(2, new ItemStack(Items.iron_leggings));
		this.setCurrentItemOrArmor(1, new ItemStack(Items.iron_boots));
		break;
	case (TroopL.BASIC_INFANTRY_4):
		this.setCurrentItemOrArmor(0, new ItemStack(Items.diamond_sword));
		this.setCurrentItemOrArmor(4, new ItemStack(Items.diamond_helmet));
		this.setCurrentItemOrArmor(3, new ItemStack(Items.diamond_chestplate));
		this.setCurrentItemOrArmor(2, new ItemStack(Items.diamond_leggings));
		this.setCurrentItemOrArmor(1, new ItemStack(Items.diamond_boots));
		break;
	}
}

public static EntityInfantryL spawnInfantry(World world, int type, double x, double y, double z) {
	EntityInfantryL e = new EntityInfantryL(world, type);
	e.setLocationAndAngles(x, y, z, MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0F), 0.0F);
	e.rotationYawHead = e.rotationYaw;
	e.renderYawOffset = e.rotationYaw;
	world.spawnEntityInWorld(e);
	e.giveEquipment();
	return e;
}

public static EntityInfantryL spawnRandomInfantry(World world, double x, double y, double z) {
	EntityInfantryL e = new EntityInfantryL(world, UtilL.getRandomIntegerBetween(0, 3));
	System.err.println("SPAWNED INFANTRY WITH TYPE " + e.type);
	e.setLocationAndAngles(x, y, z, MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0F), 0.0F);
	e.rotationYawHead = e.rotationYaw;
	e.renderYawOffset = e.rotationYaw;
	world.spawnEntityInWorld(e);
	e.giveEquipment();
	return e;
}
}

 

Render:

package legions.render;

import legions.UtilL;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.entity.RenderBiped;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;

import org.lwjgl.opengl.GL11;

public class RenderHumanL extends RenderBiped {
private static final float SCALE = 0.9375F;
private static final ResourceLocation TEXTURE = UtilL.newResource("textures/entity/human.png");

public RenderHumanL() {
	super(new ModelBiped(), 0.5F);
}

@Override
public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) {
	System.err.println("RENDER");
	super.doRender(par1EntityLiving, par2, par4, par6, par8, par9);
}

@Override
protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) {
	System.err.println("SCALE");
	GL11.glScalef(SCALE, SCALE, SCALE);
}

@Override
protected ResourceLocation getEntityTexture(Entity par1Entity) {
	System.err.println("TEXTURE");
	return TEXTURE;
}
}

 

ServerProxy:

package legions;

import java.io.File;

import legions.entity.EntityArcherL;
import legions.entity.EntityInfantryL;
import legions.entity.EntityTroopLeaderL;
import legions.handler.ServerForgeEventHandlerL;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.config.Configuration;
import cpw.mods.fml.common.registry.EntityRegistry;

public class ServerProxyL {
public static Configuration config;
public static ServerForgeEventHandlerL forgeEvents;

public void initServer() {
	config = new Configuration(new File("./config/Legions/Server.cfg"), true);
	config.load();
	addEvents();
	addEntities();
	config.save();
}

public void addEvents() {
	forgeEvents = new ServerForgeEventHandlerL();
}

public void addEntities() {
	addEntity(EntityInfantryL.class, "infantry");
	addEntity(EntityArcherL.class, "archer");
	addEntity(EntityTroopLeaderL.class, "leader");
}

public void initClient() {
}

private static void addEntity(Class<? extends Entity> clazz, String name) {
	EntityRegistry.registerModEntity(clazz, name, EntityRegistry.findGlobalUniqueEntityId(), Legions.instance, 64, 20, true);
}
}

 

I have prints in the render class (not the constructor) and before I register the renders. The only prints that fire are the ones before I register the renders.

Kain

Link to comment
Share on other sites

Why do you init the renderers inside the config.load() and config.save(), seems stupid.

 

@Override
public void initClient() {
	config = new Configuration(new File("./config/Legions/Client.cfg"), true);
	config.load();
                loadConfigurations();
                config.save();

	addKeys();	
	addEvents();
	addRenders();

}

 

That would make more sense for me. I dont know if that affects the renderers, tell me if it does, other wise I will look through your code more carefully.

Link to comment
Share on other sites

As I've been a modder since a long time ago I know perfectly well what configs are, but why are you putting your entity codes within the config.load and save? It shouldn't be there except if you were to add config stuff there!

Link to comment
Share on other sites

I know how configurations work, but I don't know why I saved after loading everything else...

 

I changed it, but nothing has changed.

 

ServerProxy:

package legions;

import java.io.File;

import legions.entity.EntityArcherL;
import legions.entity.EntityInfantryL;
import legions.entity.EntityTroopLeaderL;
import legions.handler.ServerForgeEventHandlerL;
import net.minecraft.entity.Entity;
import net.minecraftforge.common.config.Configuration;
import cpw.mods.fml.common.registry.EntityRegistry;

public class ServerProxyL {
public static Configuration config;
public static ServerForgeEventHandlerL forgeEvents;

public void initServer() {
	loadConfigurations();
	addEvents();
	addEntities();
}

public void loadConfigurations() {
	config = new Configuration(new File("./config/Legions/Server.cfg"), true);
	config.load();
	config.save();
}

public void addEvents() {
	forgeEvents = new ServerForgeEventHandlerL();
}

public void addEntities() {
	addEntity(EntityInfantryL.class, "infantry");
	addEntity(EntityArcherL.class, "archer");
	addEntity(EntityTroopLeaderL.class, "leader");
}

public void initClient() {
}

private static void addEntity(Class<? extends Entity> clazz, String name) {
	EntityRegistry.registerModEntity(clazz, name, EntityRegistry.findGlobalUniqueEntityId(), Legions.instance, 64, 20, true);
}
}

 

ClientProxy:

package legions;

import java.io.File;

import legions.entity.EntityArcherL;
import legions.entity.EntityInfantryL;
import legions.entity.EntityTroopLeaderL;
import legions.handler.ClientFMLEventHandlerL;
import legions.handler.ClientForgeEventHandlerL;
import legions.handler.KeyHandlerL;
import legions.network.PacketCommandL;
import legions.render.RenderHumanL;
import net.minecraftforge.common.config.Configuration;
import cpw.mods.fml.client.registry.RenderingRegistry;

public class ClientProxyL extends ServerProxyL {
public static Configuration config;
public static ClientFMLEventHandlerL fmlEvents;
public static ClientForgeEventHandlerL forgeEvents;
public static KeyHandlerL keyHandler;

@Override
public void initClient() {
	loadConfigurations();
	addKeys();
	addEvents();
	addRenders();
}

public void loadConfigurations() {
	config = new Configuration(new File("./config/Legions/Client.cfg"), true);
	config.load();
	shouldSlide = config.get("Gui", "Enable Sliding Menu", true).getBoolean(true);
	config.save();
}

public void addKeys() {
	keyHandler = new KeyHandlerL();
}

public void addEvents() {
	fmlEvents = new ClientFMLEventHandlerL();
	forgeEvents = new ClientForgeEventHandlerL();
}

public void addRenders() {
	RenderingRegistry.registerEntityRenderingHandler(EntityInfantryL.class, new RenderHumanL());
	RenderingRegistry.registerEntityRenderingHandler(EntityArcherL.class, new RenderHumanL());
	RenderingRegistry.registerEntityRenderingHandler(EntityTroopLeaderL.class, new RenderHumanL());
}

public static boolean shouldSlide;
public static int currentMenu = 0;
public static int guiY = -64;
public static PacketCommandL commandPacket;
}

Kain

Link to comment
Share on other sites

If I remember correctly, you are suppose to leave the methods in your server proxy "blank."

They set the things you want in the method in the client proxy - in other words, delete the things inside the methods in ServerProxyL.

 

One more thing, let me see your main class after you fixed those things.

Link to comment
Share on other sites

I'm pretty sure I'm not suppose to cram everything into my client proxy. I did that with the same outcome.

 

 

Here's my main class:

package legions;

import static legions.ReferenceL.ID;
import static legions.ReferenceL.NAME;
import static legions.ReferenceL.VERSION;
import legions.handler.PacketHandlerL;
import legions.network.PacketCommandL;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;

@Mod(modid = ID, name = NAME, version = VERSION)
public class Legions {
@Instance(ID)
public static Legions instance;
@SidedProxy(clientSide = ID + ".ClientProxyL", serverSide = ID + ".ServerProxyL")
public static ServerProxyL proxy;
public static PacketHandlerL packetHandler;

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
	proxy.initServer();
	proxy.initClient();
}

@EventHandler
public void init(FMLInitializationEvent event) {
	packetHandler = new PacketHandlerL();
	packetHandler.initialise();
}

@EventHandler
public void postInit(FMLPostInitializationEvent event) {
	packetHandler.registerPacket(PacketCommandL.class);
	packetHandler.postInitialise();
}
}

Kain

Link to comment
Share on other sites

Ok, everything is being called right. I tried using another method of registering the render, but nothing.

 

public void addRenders() {
	RenderHumanL render = new RenderHumanL();
	render.setRenderManager(RenderManager.instance);
	RenderManager.instance.entityRenderMap.put(EntityInfantryL.class, render);
	RenderManager.instance.entityRenderMap.put(EntityArcherL.class, render);
	RenderManager.instance.entityRenderMap.put(EntityTroopLeaderL.class, render);
}

 

I'm gonna try registering the renders in different intialization events.

 

Edit: Nope

Kain

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.