Jump to content

[1.8.9] Composite Models


Notunknown

Recommended Posts

I believe I have solved it, sort of.

 

I solved it by using a custom IBakedModel class:

 

import java.util.ArrayList;
import java.util.List;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemModelMesher;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;

public class ItemTestModel implements IBakedModel
{

@Override
public List<BakedQuad> getFaceQuads(EnumFacing p_177551_1_)
{
	List<BakedQuad> quads = new ArrayList<BakedQuad>();

	ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();

	quads.addAll(0, mesher.getItemModel(new ItemStack(Items.apple)).getFaceQuads(p_177551_1_));		
	quads.addAll(0, mesher.getItemModel(new ItemStack(Items.diamond_horse_armor)).getFaceQuads(p_177551_1_));
	return quads;
}

@Override
public List<BakedQuad> getGeneralQuads()
{
	List<BakedQuad> quads = new ArrayList<BakedQuad>();

	ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();

	quads.addAll(0, mesher.getItemModel(new ItemStack(Items.apple)).getGeneralQuads());		
	quads.addAll(0, mesher.getItemModel(new ItemStack(Items.diamond_horse_armor)).getGeneralQuads());
	return quads;
}

@Override
public boolean isAmbientOcclusion()
{
	return false;
}

@Override
public boolean isGui3d()
{
	return false;
}

@Override
public boolean isBuiltInRenderer()
{
	return false;
}

@Override
public TextureAtlasSprite getParticleTexture()
{
	ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();

	return mesher.getItemModel(new ItemStack(Items.diamond_horse_armor)).getParticleTexture();
}

@Override
public ItemCameraTransforms getItemCameraTransforms()
{
	return ItemCameraTransforms.DEFAULT;
}

}

 

Edit: Ah, I just noticed that the item is held at a strange angle in third person, which I believe is to do with getItemCameraTransforms. If this is the case, what is the ItemCameraTransforms that I should be using, if not DEFAULT?

Link to comment
Share on other sites

Okay, so maybe a more detailed explanation will help:

 

So I am making a mod which includes weapons and tools made from a number of different components, such as a sword blade or pickaxe head. Although all weapons/tools of a type share the same base components, tools may contain one or more optional components.

 

Now, rather than create tens or even hundreds of thousands of different models for each tool and weapon type, I want to create a model for each individual component, then use code based on the items NBT data to select which models to combine together to form the resulting model.

Link to comment
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.
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.