forked from yanggx98/Immersive-Tooltip
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: custom tooltip border colors & background color
* fixes #12
- Loading branch information
1 parent
c7b2f28
commit a5870bb
Showing
11 changed files
with
206 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 28 additions & 7 deletions
35
src/main/java/dev/ultimatchamp/enhancedtooltips/component/ColorBorderComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,42 @@ | ||
package dev.ultimatchamp.enhancedtooltips.component; | ||
|
||
import dev.ultimatchamp.enhancedtooltips.TooltipHelper; | ||
import dev.ultimatchamp.enhancedtooltips.config.EnhancedTooltipsConfig; | ||
import net.minecraft.client.gui.DrawContext; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.Rarity; | ||
|
||
public class ColorBorderComponent extends TooltipBackgroundComponent { | ||
private final int color; | ||
private final ItemStack stack; | ||
|
||
public ColorBorderComponent(int color) { | ||
this.color = color; | ||
public ColorBorderComponent(ItemStack stack) { | ||
this.stack = stack; | ||
} | ||
|
||
@Override | ||
protected void renderBorder(DrawContext context, int x, int y, int width, int height, int z, int page) { | ||
int endColor = 1347420415; | ||
int startColor = 0xff000000 | TooltipHelper.getItemBorderColor(stack); | ||
if (TooltipHelper.getItemBorderColor(stack) == -1) startColor = EnhancedTooltipsConfig.BorderColor.COMMON.getColor().getRGB(); | ||
|
||
renderVerticalLine(context, x, y, height - 2, z, color, endColor); | ||
renderVerticalLine(context, x + width - 1, y, height - 2, z, color, endColor); | ||
renderHorizontalLine(context, x, y - 1, width, z, color); | ||
int endColor = EnhancedTooltipsConfig.BorderColor.END_COLOR.getColor().getRGB(); | ||
|
||
if (EnhancedTooltipsConfig.load().borderColor == EnhancedTooltipsConfig.BorderColorMode.CUSTOM) { | ||
if (stack.getRarity() == Rarity.UNCOMMON) { | ||
startColor = EnhancedTooltipsConfig.load().customBorderColors.uncommon.getRGB(); | ||
} else if (stack.getRarity() == Rarity.RARE) { | ||
startColor = EnhancedTooltipsConfig.load().customBorderColors.rare.getRGB(); | ||
} else if (stack.getRarity() == Rarity.EPIC) { | ||
startColor = EnhancedTooltipsConfig.load().customBorderColors.epic.getRGB(); | ||
} else { | ||
startColor = EnhancedTooltipsConfig.load().customBorderColors.common.getRGB(); | ||
} | ||
|
||
endColor = EnhancedTooltipsConfig.load().customBorderColors.endColor.getRGB(); | ||
} | ||
|
||
renderVerticalLine(context, x, y, height - 2, z, startColor, endColor); | ||
renderVerticalLine(context, x + width - 1, y, height - 2, z, startColor, endColor); | ||
renderHorizontalLine(context, x, y - 1, width, z, startColor); | ||
renderHorizontalLine(context, x, y - 1 + height - 1, width, z, endColor); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.