Jump to content

Recommended Posts

Posted

Hi All,

 

Once again I have a problem with my Brianmod's grenade feature. I can get a grenade to throw and blow up but while it is in the air (as an entity) it does not look like anything. Not a white box or a pink and black checkered mess. I created an EntityBrianade and a RenderBrianade class. I then have the ItemBrianade class call the entity when it is right clicked. Everything but the appearance of the grenade in flight works like a charm.

 

Here is my RenderBrianade class.

package org.educraft.brianface.renderer.entity;

import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.client.registry.IRenderFactory;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.educraft.brianface.Reference;
import org.educraft.brianface.entityclasses.EntityBrianade;

import javax.annotation.Nullable;

@SideOnly(Side.CLIENT)
public class RenderBrianade<T extends EntityBrianade> extends Render<T> {

    private static final ResourceLocation BRIANADE_TEXTURE = new ResourceLocation(Reference.MOD_ID,"textures/entity/brianade/brianade.png");

    public static final Factory FACTORY = new Factory();

    public RenderBrianade(RenderManager renderManagerIn) {

        super(renderManagerIn/*, new ModelBrianade(), 1.0F*/);

    }

    @Nullable
    //@Override
    protected ResourceLocation getEntityTexture(EntityBrianade entity) {

        return BRIANADE_TEXTURE;
    }

    public static class Factory implements IRenderFactory<EntityBrianade> {

        public static final Factory INSTANCE = new Factory();

        @Override
        public Render<? super EntityBrianade> createRenderFor(RenderManager manager){

            return new RenderBrianade(manager);

        }

    }

}

 

I double checked the location of the texture file. So I know it's there.

 

Here is my class for registering entities:

package org.educraft.brianface.init;

import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.educraft.brianface.entityclasses.EntityBrianade;
import org.educraft.brianface.renderer.entity.RenderBrianade;

public class ModEntities {

    @SideOnly(Side.CLIENT)
    public static void initModels() {

        RenderingRegistry.registerEntityRenderingHandler(EntityBrianade.class, RenderBrianade.Factory.INSTANCE);

    }

}

 

I also call this in my main class.

 

/*
 * This is the main class for the mod. All of the things you make have to be initialized and registered here. This also
 * helps you with your proxy settings so that you do not crash the game when you run a server with this mod.
 */

package org.educraft.brianface;

import net.minecraft.entity.Entity;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;

import org.educraft.brianface.entityclasses.EntityBrianade;
import org.educraft.brianface.init.ModBlocks;
import org.educraft.brianface.init.ModCrafting;
import org.educraft.brianface.init.ModEntities;
import org.educraft.brianface.init.ModItems;
import org.educraft.brianface.proxy.ICommonProxy;
import org.educraft.brianface.worldgenerator.ModWorldGen;

@Mod(modid = Reference.MOD_ID, name = Reference.NAME, version = Reference.VERSION, acceptedMinecraftVersions = Reference.ACCEPTED_VERSIONS)
public class Main 
{
	@Instance
	public static Main instance;
	
	@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
	public static ICommonProxy proxy;

	@EventHandler
	public void preInit(FMLPreInitializationEvent event) 
	{
		System.out.println("PreInit Test");

		ModItems.init();
		ModItems.register();

		ModBlocks.init();
		ModBlocks.register();

		ModEntities.initModels();



		proxy.preInit(event);

		//MaterialGenerator.register();
	}
	
	@EventHandler
	public void init(FMLInitializationEvent event) 
	{
		System.out.println("Init Test");
		ModCrafting.register();

		GameRegistry.registerWorldGenerator(new ModWorldGen(), 0);

		proxy.init(event);
	}
	
	@EventHandler
	public void postInit(FMLPostInitializationEvent event) 
	{
		proxy.postInit(event);
		System.out.println("PostInit Test");
	}

}

I would appreciate any help from the modding community that has so far proven much smarter than me.

 

Here is a link to the repository of the entire mod if I have not provided enough information.

 

Thanks for any help.

 

Posted (edited)

For one your renderer does absolutely nothing. As you are extending Render and not any of it's child classes you must manualy render the model of your choice in there. It most likely will be the ModelBrianade I see a commented out reference to.

 

Rendering registration must be done in a client-only class like your proxy. Your current implementation will crash the server. No, your SideOnly here will not save you. It in fact will be the cause of your crash.

 

Why is the override commented out? If your IDE/compiler throws an error you can't just comment out the Override and pretend that it never happened. This is the purpose of the override - to throw an error if the thing you are overriding can't be overriden for one reason or another.

 

You are doing something weird with types. If your renderer renders an EntityBrianade just use the EntityBrianade as it's type, not <T extends EntityBrianade>

Edited by V0idWa1k3r
  • Like 1

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.