Search in sources :

Example 1 with IModeItem

use of mekanism.common.item.interfaces.IModeItem in project Mekanism by mekanism.

the class RenderTickHandler method renderStatusBar.

private void renderStatusBar(MatrixStack matrix, @Nonnull PlayerEntity player) {
    // to be more faded in color, and blinks to full color just before disappearing
    if (modeSwitchTimer > 1) {
        if (minecraft.screen == null && minecraft.font != null) {
            ItemStack stack = player.getMainHandItem();
            if (IModeItem.isModeItem(stack, EquipmentSlotType.MAINHAND)) {
                ITextComponent scrollTextComponent = ((IModeItem) stack.getItem()).getScrollTextComponent(stack);
                if (scrollTextComponent != null) {
                    int x = minecraft.getWindow().getGuiScaledWidth();
                    int y = minecraft.getWindow().getGuiScaledHeight();
                    int color = Color.rgbad(1, 1, 1, modeSwitchTimer / 100F).argb();
                    minecraft.font.draw(matrix, scrollTextComponent, (x - minecraft.font.width(scrollTextComponent)) / 2, y - 60, color);
                }
            }
        }
        modeSwitchTimer--;
    }
}
Also used : IModeItem(mekanism.common.item.interfaces.IModeItem) ITextComponent(net.minecraft.util.text.ITextComponent) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IModeItem (mekanism.common.item.interfaces.IModeItem)1 ItemStack (net.minecraft.item.ItemStack)1 ITextComponent (net.minecraft.util.text.ITextComponent)1