Skip to content

Commit

Permalink
use InfoUtils for hud message displaying
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed Sep 25, 2021
1 parent a120b43 commit e1c05d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.fallenbreath.tweakermore.impl.tweakmAutoCleanContainer;

import fi.dy.masa.itemscroller.util.InventoryUtils;
import fi.dy.masa.malilib.util.InfoUtils;
import me.fallenbreath.tweakermore.config.TweakerMoreToggles;
import me.fallenbreath.tweakermore.mixins.access.ItemScrollerInventoryUtilsAccessor;
import net.minecraft.client.MinecraftClient;
Expand All @@ -10,7 +11,6 @@
import net.minecraft.client.gui.screen.ingame.CraftingTableScreen;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.container.Slot;
import net.minecraft.text.TranslatableText;

public class TweakAutoCleanContainer
{
Expand All @@ -36,7 +36,7 @@ public static void process(Screen screen)
}
}
// close the container
player.addChatMessage(new TranslatableText("tweakmAutoCleanContainer.container_cleaned", screen.getTitle()), true);
InfoUtils.printActionbarMessage("tweakmAutoCleanContainer.container_cleaned", screen.getTitle());
player.closeContainer();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.fallenbreath.tweakermore.impl.tweakmAutoFillContainer;

import fi.dy.masa.itemscroller.util.InventoryUtils;
import fi.dy.masa.malilib.util.InfoUtils;
import me.fallenbreath.tweakermore.config.TweakerMoreConfigs;
import me.fallenbreath.tweakermore.config.TweakerMoreToggles;
import me.fallenbreath.tweakermore.mixins.access.ItemScrollerInventoryUtilsAccessor;
Expand All @@ -14,7 +15,6 @@
import net.minecraft.container.Slot;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;

import java.util.List;
Expand Down Expand Up @@ -69,12 +69,13 @@ else if (cnt == maxCount && bestSlot != null && !InventoryUtils.areStacksEqual(s
Text stackName = bestSlot.getStack().getName();
InventoryUtils.tryMoveStacks(bestSlot, containerScreen, true, true, false);
long amount = containerInvSlots.stream().filter(Slot::hasStack).count(), total = containerInvSlots.size();
String percentage = String.format("%s%d/%d%s", amount == total ? Formatting.GREEN : Formatting.GOLD, amount, total, Formatting.RESET);
player.addChatMessage(new TranslatableText("tweakmAutoFillContainer.container_filled", screen.getTitle(), stackName, percentage), true);
boolean isFull = Container.calculateComparatorOutput(containerInvSlots.get(0).inventory) >= 15;
String percentage = String.format("%s%d/%d%s", isFull ? Formatting.GREEN : Formatting.GOLD, amount, total, Formatting.RESET);
InfoUtils.printActionbarMessage("tweakmAutoFillContainer.container_filled", screen.getTitle(), stackName, percentage);
}
else
{
player.addChatMessage(new TranslatableText("tweakmAutoFillContainer.best_slot_not_found"), true);
InfoUtils.printActionbarMessage("tweakmAutoFillContainer.best_slot_not_found");
}
player.closeContainer();
}
Expand Down

0 comments on commit e1c05d0

Please sign in to comment.