Jump to content

Recommended Posts

Posted (edited)

I can't get items to render correctly for items or item blocks.  Projectiles are white cubes, item blocks are the black and purple checker boards.  (Blocks and mobs render just fine, even if the registration for mobs is deprecated.)  Here's what I'm doing:

 

ClientProxy.java:

package jaredbgreat.rpgdungeons.proxies;

import jaredbgreat.rpgdungeons.Info;
import jaredbgreat.rpgdungeons.entity.mobs.EntityFallenAngel;
import jaredbgreat.rpgdungeons.entity.mobs.EntityRevenant;
import jaredbgreat.rpgdungeons.entity.mobs.EntityVampire;
import jaredbgreat.rpgdungeons.entity.model.ModelFallenAngel;
import jaredbgreat.rpgdungeons.entity.render.RenderFallenAngel;
import jaredbgreat.rpgdungeons.entity.render.RenderVampire;
import jaredbgreat.rpgdungeons.items.ModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.entity.RenderZombie;
import net.minecraftforge.fml.client.registry.RenderingRegistry;

public class ClientProxy extends CommonProxy {
	
	@Override
	public void regsterRendering() {
    	RenderingRegistry.registerEntityRenderingHandler(EntityRevenant.class, 
    			new RenderZombie(Minecraft.getMinecraft().getRenderManager()));
    	RenderingRegistry.registerEntityRenderingHandler(EntityVampire.class, 
    			new RenderVampire(Minecraft.getMinecraft().getRenderManager(), 
    					new ModelBiped(), 0.5f));
    	RenderingRegistry.registerEntityRenderingHandler(EntityFallenAngel.class, 
    			new RenderFallenAngel(Minecraft.getMinecraft().getRenderManager(), 
    					new ModelFallenAngel(0), 0.5f));
	}	


	@Override
	public void registerItemRenders() {
		// FIXME: This whole setup does not work from  pre-init -- must be from init.
		// Might as will be with the registerRendering.
//		ModelLoader.setCustomModelResourceLocation(ModItems.lightball, 0, 
//				new ModelResourceLocation(ModItems.lightball.getRegistryName(), "projectile"));
		Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
					.register(ModItems.lightball, 0, 
							new ModelResourceLocation(Info.ID + ":" 
									+ ModItems.lightball.getUnlocalizedName().substring(5), "inventory"));
	}
	
	
	

}

 

lightball.java:

package jaredbgreat.rpgdungeons.items;

import jaredbgreat.rpgdungeons.Info;
import jaredbgreat.rpgdungeons.entity.projectiles.EntityLightBall;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;

public class ItemLightBall extends Item {
	
	public ItemLightBall() {
		//setCreativeTab(CreativeTabs.MISC); // No creative tab -- these are not for the player
		setUnlocalizedName("lightball");
		setRegistryName("lightball"); //setRegistryName(Info.ID + ":lightball");
	}
	
	
	@Override
	public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, 
				EntityPlayer player, EnumHand hand) {
		if(!player.capabilities.isCreativeMode) {
			stack.stackSize--;
		}
		if(!world.isRemote) {
			EntityLightBall fired = new EntityLightBall(world, player);
			world.spawnEntityInWorld(fired);
			fired.setHeadingFromThrower(player, player.rotationPitch, player.rotationYawHead, 
					0.0f, (float)1.2, (float)0.0);
		}		
		return new ActionResult(EnumActionResult.SUCCESS, stack);		
	}
	
}

 

lightball.json:

{
	"parent": "item/generated",
	"textures": {
		"layer0": "rpgdungeonsjbg:projectiles/lightball"
	}
}

 

 

My one attempt at getting a block item to render:

{
    "parent": "block/cube_all",
    "textures": {
        "all": "rpgdungeonsjbg:blocks/Doomed/aqconc07"
    }
}

 

 

I've looked at many tutorials and some other modders code, and the vanilla JSONs.  The full project is here: https://github.com/BlackJar72/RPGDungeons

 

Can anyone tell me what I'm doing wrong?

 

Edited by JaredBGreat

Developer of Doomlike Dungeons.

Posted
1 hour ago, diesieben07 said:
  • The concept of a "common proxy" does not make sense. The whole point of @SidedProxy is to abstract over client specific and server specific behavior, the opposite of "common". Common code should go in your main mod class.
  • The version of registerEntityRenderingHandler is deprecated. Use the one that is not deprecated.
  • Please use the registry events to register your blocks and items, etc.
  • Use ModelLoader.setCustomModelResourceLocation in ModelRegistryEvent to register your item models. Do not use the ItemModelMesher.

Well...

 

There is no server-specific behavior at this point -- if I need some I'll make a ServerProxy class --  I seriously doubt this mod will ever need sided initialization for anything but client-side code related to rendering.

 

I tried ModelLoader.setCustomModelResourceLocation first; I commented it out and tried the other method because it didn't work.  I then switched to ItemModelMesher based on some tutorials, which gave me the same result as the ModelLoader based system.

 

I might consider a more currently proper way of registering entities once I have the things that are broken figured out -- right now that part works fine, though.

 

I suppose I could look at these registry events and see if that makes any difference.

Developer of Doomlike Dungeons.

Posted (edited)

Well, I haven't tried the registry events yet, but did put lightball back in creative tab for testing.  It turn out it shows up fine as an item or item-entity when ModelMesher is used, but not when ModelLoader is used (maybe this will change if using the registry events).  Rather, the problem has been that it is not being applied to projectile entity when fired; I have half a mind just to make a whole new model for it (I was trying to base it on the snowball model and rendering).

 

I also wonder if they need to be an item -- the player isn't supposed to have them.

 

I will try re-writing to use the new event system when I have more time (not this afternoon, maybe tomorrow).

 

Thanks.

 

EDIT: I tried just moving it to pre-init (since I don't have to learn the new systm for that), and had no problem with the correct way (the other crashed when called from preinit).

Edited by JaredBGreat

Developer of Doomlike Dungeons.

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.