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

[SOLVED] [1.12.2]Rendering EntityThrowable with RenderSnowball


Recommended Posts

Haven't checked in with Forge in a long time and I see there's been a lot of changes. Was attempting to update one of my old mods, and I'm needing to render a projectile, but (obviously) the way I used to do it doesn't work anymore. I'm trying this:

 

Spoiler

package blfngl.fallout.util;

import blfngl.fallout.Fallout;
import blfngl.fallout.entity.EntityBullet;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent.Register;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.EntityEntry;

@EventBusSubscriber
public class RegistryHandler
{
	@SubscribeEvent
	public static void registerBlocks(Register<Block> event)
	{
		for (Block block: Fallout.blockList)
			event.getRegistry().register(block);
	}

	@SubscribeEvent
	public static void registerItemBlocks(Register<Item> register)
	{
		for (Block block: Fallout.itemBlockList)
		{
			ItemBlock iBlock = new ItemBlock(block);
			iBlock.setRegistryName(block.getRegistryName());
			register.getRegistry().register(iBlock);
		}
	}

	@SubscribeEvent
	public static void registerItems(Register<Item> register)
	{
		for (Item item: Fallout.itemList)
		{
			register.getRegistry().register(item);
			ModelResourceLocation modelLoc = new ModelResourceLocation(item.getRegistryName(), "inventory");
			ModelLoader.setCustomModelResourceLocation(item, 0, modelLoc);
		}
	}

	@SubscribeEvent
	public static void renderModels(Register<EntityEntry> register)
	{
		int entityId = 0;

		EntityEntry bullet = new EntityEntry(EntityBullet.class, "fallout_bullet")
				.setRegistryName(Reference.MODID, "fallout_bullet");
		register.getRegistry().register(bullet);

		RenderManager renderBullet = new RenderManager(null, Minecraft.getMinecraft().getRenderItem());
		RenderingRegistry.registerEntityRenderingHandler(EntityBullet.class,
				new RenderSnowball(renderBullet, FalloutItems.ammoSpike, Minecraft.getMinecraft().getRenderItem()));
	}
}

 

but I'm not getting anything rendered. The entity is there and affects the world, but isn't visible. Any ideas?

Edited by blfngl
Marked as solved
Link to post
Share on other sites
  • Do not call ModelLoader.setCustomModelResourceLocation during the item registration event. It must be called during ModelRegistryEvent and it must happen through your client proxy (or a client-only event handler using @Mod.EventBusSubscriber(Side.CLIENT)), since ModelLoader is a client-only class.
  • Use EntityEntryBuilder. Just registering the plain entry like you are doing is not enough to properly register an entity.
  • Do not register your entity renderer during the entity registry event, it must happen in the preInit phase and it must happen through your client proxy, since entity rendering is a client-only process.
  • Do not create a new RenderManager.
  • The version of registerEntityRenderingHandler you are using is deprecated. Do not use deprecated methods.
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.