Skip to content

Commit

Permalink
Fix compositing category not showing chance in tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
shedaniel committed Apr 16, 2024
1 parent 3d3796d commit da47c76
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import me.shedaniel.rei.api.client.registry.display.DisplayCategory;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes;
import me.shedaniel.rei.api.common.util.EntryStacks;
import me.shedaniel.rei.plugin.common.BuiltinPlugin;
import me.shedaniel.rei.plugin.common.displays.DefaultCompostingDisplay;
Expand Down Expand Up @@ -94,8 +95,8 @@ public List<Widget> setupDisplay(DefaultCompostingDisplay display, Rectangle bou
for (int y = 0; y < 5; y++)
for (int x = 0; x < 7; x++) {
EntryIngredient entryIngredient = stacks.size() > i ? stacks.get(i) : EntryIngredient.empty();
if (!entryIngredient.isEmpty()) {
ItemStack firstStack = (ItemStack) entryIngredient.get(0).getValue();
if (!entryIngredient.isEmpty() && entryIngredient.get(0).getType() == VanillaEntryTypes.ITEM) {
ItemStack firstStack = entryIngredient.get(0).castValue();
float chance = ComposterBlock.COMPOSTABLES.getFloat(firstStack.getItem());
if (chance > 0.0f) {
entryIngredient = entryIngredient.map(stack -> stack.copy().tooltip(Component.translatable("text.rei.composting.chance", Mth.clamp(Mth.fastFloor(chance * 100), 0, 100)).withStyle(ChatFormatting.YELLOW)));
Expand Down

0 comments on commit da47c76

Please sign in to comment.