Jump to content

Recommended Posts

Posted

This is what ItemStack look now.

 

2020-03-18_18_02_14.png.8f1bd05882b3389aaadb7d36543d8564.png

 

All the thing in the front and back of ItemStack rendered correctly, but when holding in hand, you'll see the every side of this ItemStack is broken.

 

Repo is here

The code closely related with model is under meal folder

 

I used a custom Loader, IModelGeometry and ItemOverrideList.

My goal is select what textures to use by overriding ItemOverrideList#getModelWithOverrides

And at the final of method I directly using ItemLayerModel to bake a new model.To stack textures together is actually what I want.

@Override
public IBakedModel getModelWithOverrides(IBakedModel model, ItemStack stack, @Nullable World worldIn, @Nullable LivingEntity entityIn){
	IBakedModel returnModel = model;
	if(stack.getItem() instanceof Meal){
		CompoundNBT nbt = stack.hasTag() ? stack.getTag() : new CompoundNBT();

		List<Material> textures = new ArrayList<Material>();
		textures.add(this.materials.get("base"));

		if(nbt.contains("ingredients")){
			ListNBT list = (ListNBT)nbt.get("ingredients");
			for(INBT ele : list){
				CompoundNBT element = (CompoundNBT)ele;
				textures.add(this.materials.get(element.getString("name")));
			}
		}
		returnModel = new ItemLayerModel(ImmutableList.copyOf(textures))
			.bake(this.owner, this.bakery, this.spriteGetter, this.modelTransform, this.overrides, this.modelLocation);
	}
	return returnModel;
}

 

It success, the three thing in the item frame is the same Item "salad" with different CompoundNBT.

But as the title, the side of this item is broken.

I tried using ItemLayerModel#getQuadsForSprites before, but every thing is the same, including which little square surface is missiing.

 

Someone has any idea?

  • 3 weeks later...
Posted (edited)

OK, because nobody reply me, so I tried to generate quads by my own code.

Repo is here

 

But I got another problem.

 

Now everything looks fine when stack is in item frame or dropped on the ground, the side quads is not missing.

They are in the right place with right color.

2020-04-06_23_13_13.thumb.jpg.5169449f9559aadd1d7c51695edea155.jpg

2020-04-06_23_13_19.thumb.jpg.ddfd8fb8d517918f22b5e9273f870681.jpg

2020-04-06_23_13_26.thumb.jpg.7f18f6e071c7dd0ada186328b97e6f2d.jpg

 

But when on the left/right hand of first person camera, the side quads missing.

BTW, stack in third person camera looks fine.

2020-04-06_23_12_10.jpg.465ffe7ab561af587e69b3f253e9d361.jpg

 

I don't know where I did it wrong....and it confuse me why only first person camera will get this problem.

I think I did something wrong when processing Model Transform, but I can't find it.?

 

==================================

UPDATE

I found that if right hand is empty or holding a block, stack in left hand will render correctly, otherwise not.

How strange it is......I'm really confused.....

2020-04-06_23_43_25.png.89b1842f2807dd6bbc27d2ba227d2394.png

 

=======================================

Ok.....I found problem and it fixed now.

Only y need to be subtracted by 1 like (1 - y).

But z doesn't need to do this.....

Everything is fine now, and I plan to make catch of the baked quads next, since it won't change after a stack is made.

thx.

Edited by immortalmice
Update info

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.