Jump to content

Recommended Posts

Posted

Are you asking how to assign custom model to Item?

How do you know it's working if you never saw it working (you don't know how to use it)? :o

  Quote

1.7.10 is no longer supported by forge, you are on your own.

Posted

If by pre-generated you mean during pre-postInit no. The available instances get created by the player in-game, some will be loaded from a file and could be generated during pre-postInit, the only way to make all of them available during pre-postInit would be to force a server restart each time they add an instance which I do not want to do.

 

I have this in my ClientProxy#postInit

ModelResourceLocation itemModel = Refs.modelResourceLocation;
ModelLoader.setCustomModelResourceLocation(MeleeCore.meleeCore, 0, itemModel);	

 

This is what I have for the ModelBakeEvent

        @SideOnly(Side.CLIENT)
@SubscribeEvent
public void onModelBakeEvent(ModelBakeEvent event)
{
	 Object obj = event.modelRegistry.getObject(DraftableSmartItemModel.modelResourceLocation);
	 if(obj instanceof IBakedModel)
	 {
		 event.modelRegistry.putObject(DraftableSmartItemModel.modelResourceLocation, new DraftableSmartItemModel());
	 }
}

 

Here is what I have for ISmartItemModel:

public class DraftableSmartItemModel implements ISmartItemModel{

public static final ModelResourceLocation modelResourceLocation = new ModelResourceLocation(Refs.MODID + ":draftable_Item","inventory"); // this file doesn't exist

@Override
public IFlexibleBakedModel handleItemState(ItemStack stack) {
      IFlexibleBakedModel model = null;
      if(stack.getTagCompound().hasKey(Refs.DRAFTABLE) && DraftableReg.Exists(stack.getTagCompound().getString(Refs.DRAFTABLE)))
         model = DraftableReg.getModel(stack.getTagCompound().getString(Refs.DRAFTABLE));
      return model;
   }
}

 

This is in the item class(I have my own registry of instances of this class)

         public ItemStack CreateItem() {
	LogHelper.info("creating " + name);
	ItemStack toReturn = new ItemStack(this, 1, 0);
	NBTTagCompound tag = new NBTTagCompound();
	tag.setString(Refs.DRAFTABLE, name);
	toReturn.setTagCompound(tag);
	return toReturn;
}

 

The models are just showing up as purple and black boxes. Is there something wrong with how I am assigning the models to the items?

Current Project: Armerger 

Planned mods: Light Drafter  | Ore Swords

Looking for help getting a mod off the ground? Coding  | Textures

Posted

postInit because I'm a noob when it comes to this, moved to preInit and both places now use

Refs.modelResourceLocation, I just moved the variable from DraftableSmartItemModel to Refs.

 

These are in DraftableReg

       @SideOnly(Side.CLIENT)
public static IFlexibleBakedModel GetModel(String draftItem) {
	return models.get(draftItem);
}

        public static void RegisterDraftable(IDraftable draftable){
	LogHelper.info("Registering Draftable :" + draftable.GetName());
	knowledgeBase.put(draftable.GetName(), draftable);
}

@SideOnly(Side.CLIENT)
public static void RegisterDraftableModel(IDraftable draftable){
	LogHelper.info("Registering Model for :" + draftable.GetName());
	models.put(draftable.GetName(), new DraftableBakedModel(draftable));
}

My proxies have a Register method that gets used to call either one or both of these register methods.

 

I put a breakpoint in GetModel and it doesn't get called, so something is still wrong with how I am assigning my DraftableSmartItemModel to the items.

Current Project: Armerger 

Planned mods: Light Drafter  | Ore Swords

Looking for help getting a mod off the ground? Coding  | Textures

Posted

I put a breakpoint in handleItemState and it never gets called so no.

This is the only error I can find in the log

 

  Reveal hidden contents

 

Current Project: Armerger 

Planned mods: Light Drafter  | Ore Swords

Looking for help getting a mod off the ground? Coding  | Textures

Posted

You can implement two? Idk, I am alredy on 1.9 where there are no longer any of those. I totally skipped 1.8.9 (meaning I didn't touch rendering knowing that it will change).

 

And yeah - I suggest going to 1.9 directly, a lot of stuff has been replaced.

  Quote

1.7.10 is no longer supported by forge, you are on your own.

Posted

Alright so I now have gotten rid of all the obvious errors in code after updateing to 1.9 and I am essentially at the same point again. So for custom item model in 1.9 do I use a similar process as what you described but only using IBakedModel or is it something else?

Current Project: Armerger 

Planned mods: Light Drafter  | Ore Swords

Looking for help getting a mod off the ground? Coding  | Textures

Posted

ICustomModelLoader

 

  Reveal hidden contents

 

IModel

 

  Reveal hidden contents

 

IBakedModel

 

  Reveal hidden contents

 

ItemOverrideList

 

  Reveal hidden contents

 

 

I have this in my ClientProxy#preInit

ModelLoader.setCustomModelResourceLocation(MeleeCore.meleeCore, 0, Refs.modelResourceLocation);
ModelLoaderRegistry.registerLoader(new DraftableModelLoader());

and this in my CommonProxy#preInit

GameRegistry.registerItem(MeleeCore.meleeCore, Refs.MODID + "_" + MeleeCore.meleeCore.GetName());

Current Project: Armerger 

Planned mods: Light Drafter  | Ore Swords

Looking for help getting a mod off the ground? Coding  | Textures

Posted

in my ICustomModelLoader#accepts I put this

@Override
public boolean accepts(ResourceLocation modelLocation) {
	if(Refs.modelResourceLocation == modelLocation)
		Refs.NOP();
	return Refs.modelResourceLocation == modelLocation;
}

when I put a breakpoint on the nop it never gets triggered.

which means that

ModelLoader.setCustomModelResourceLocation(MeleeCore.meleeCore, 0, Refs.modelResourceLocation);

isn't doing what I thought it was.

Current Project: Armerger 

Planned mods: Light Drafter  | Ore Swords

Looking for help getting a mod off the ground? Coding  | Textures

Posted

Ok so I have it using my models now, I need to compare the modelResourceLocations with .equals not ==, I hate when that is the problem.

 

Anyways my Models seem to be completely transparent, so on to how I am creating the models.

          public DraftableBakedModel(IDraftable draft){
	 DraftableMap parts = draft.GetPartArray();
	 for(int xPos = 0; xPos < parts.GetWidth(); xPos++){
		 for(int yPos = 0; yPos < parts.GetHeight(); yPos++){
            for(int zPos = 0; zPos < parts.GetDepth(); zPos++){
               if(parts.GetPart(xPos + "," + yPos + "," + zPos) != null)
            	   quads.addAll(parts.GetPart(xPos + "," + yPos + "," + zPos).GetQuadsAt(xPos, yPos, zPos));
            }
		 }
	 }
 }

 

in the IPartType implementation

 

  Reveal hidden contents

 

 

and in my ILuxin implementations

        public int[] GetColor() {
	return new int[]{0,0,255,127};
}

Current Project: Armerger 

Planned mods: Light Drafter  | Ore Swords

Looking for help getting a mod off the ground? Coding  | Textures

Posted

I'll be diving into minecraft code when I get home but I think I just need to figure out what minecraft does with the tint value. If they don't use it I may need to write my own ItemRenderer, if I do need to do you have any suggested resources to help me accomplish that?

Current Project: Armerger 

Planned mods: Light Drafter  | Ore Swords

Looking for help getting a mod off the ground? Coding  | Textures

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.