TerraFirmaCraft

TerraFirmaCraft

2M Downloads

The nutrition of sandwich turns to lastest one's

noahg7 opened this issue ยท 7 comments

commented

I'm sorry I'm not English-speaking. You could be inconvenient to read.

Describe the bug
Make sure to include:

  1. What did you expect to happen?
    Making two sandwiches that have different nutrition
  2. What actually happened instead (i.e. what was the bug)
    The nutrition of previous sandwich has changed to lastest one's If you make the same bread sandwich.

To Reproduce
Attention to detail is important!
ex)

  1. Make sandwich with oat bread and cooked bear.
  2. Then make sandwich with oat bread and lemons.
    The nutrition of first sandwich would turn to FRUIT.
    Repeating that, all former sandwiches' nutrition would turn to lastest one's.
    It seems to happen with the same kind of bread.
    For example, it doesn't happen between oat sandwich and barley sandwich.

Meta Info

  • TFC Version: 1.0.5.132
  • Were any other mods included? Can you reproduce it without these other mods?
    Only using TFC.
  • If necessary, what other mods (including versions) MUST be present to experience the bug?
commented

Researched this problem. It is caused by the fact, that sandwich capability exist only as one instance per world. So not only preveois sandwich changes. ALL sandwiches with that bread type in the game will do. Even if you do not craft, it happens on recipe completion (when the last ingredient placed in the grid.
Another strange thing is that barley sandwiches... never expires. Only barley! All other are correct.
Will check soups and salads, may be problem is there too...

commented

this might be somehow linked to #944 , there is indeed something that make sandwich have a strange behavior with nutrition and expiration values.

commented

Tested, confirm - it also happens to soups and salads of the same type. All soups/salads/sandwiches in the world will become as the last created recipe (not even creafted, only created!). In case of soup - when taking out of pot.

commented

It is caused by the fact, that sandwich capability exist only as one instance per world.

I'm not sure where you get this idea from? The capability instance is created per ItemStack in initCapabilities, not stored as an instance property of Item.

commented

It was my first guess. For now I'm working around this part:

for (Food food : new Food[] {Food.BARLEY_BREAD_SANDWICH, Food.CORNBREAD_SANDWICH, Food.OAT_BREAD_SANDWICH, Food.RICE_BREAD_SANDWICH, Food.RYE_BREAD_SANDWICH, Food.WHEAT_BREAD_SANDWICH})
{
    simpleItems.add(register(r, "food/" + food.name().toLowerCase(), new ItemSandwich(food), CT_FOOD));
}

I think, that there is a place, where a some singletone breakes all. And this looks like something related to the problem.

UPDATE: confirmed, ItemSandwich is a singletone relative to the bread type. Only one instance per bread type exist.

commented

Yes, it's an item. Every item in the entire goddamn game is a singleton. That is a useless observation that has nothing to do with this issue.

commented

Yes, it's an item. Every item in the entire goddamn game is a singleton. It has nothing to do with that.

Oh, yep. You're right, missed that moment.
But why the hell metadata was stored in an item?)