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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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