Skip to content

Commit

Permalink
Added tooltip line which displays the machine color, if any (#1868)
Browse files Browse the repository at this point in the history
* Added tooltip line which displays the machine color, if any

* Added chat formatting color to dyes enum

* Minor cleanup
  • Loading branch information
minecraft7771 authored Apr 10, 2023
1 parent 3f0c9a3 commit deb860c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
39 changes: 23 additions & 16 deletions src/main/java/gregtech/api/enums/Dyes.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;

import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;

Expand All @@ -14,22 +15,22 @@ public enum Dyes implements IColorModulationContainer {
/**
* The valid Colors, see VALUES Array below
*/
dyeBlack(0, 32, 32, 32, "Black"),
dyeRed(1, 255, 0, 0, "Red"),
dyeGreen(2, 0, 255, 0, "Green"),
dyeBrown(3, 96, 64, 0, "Brown"),
dyeBlue(4, 0, 32, 255, "Blue"),
dyePurple(5, 128, 0, 128, "Purple"),
dyeCyan(6, 0, 255, 255, "Cyan"),
dyeLightGray(7, 192, 192, 192, "Light Gray"),
dyeGray(8, 128, 128, 128, "Gray"),
dyePink(9, 255, 192, 192, "Pink"),
dyeLime(10, 128, 255, 128, "Lime"),
dyeYellow(11, 255, 255, 0, "Yellow"),
dyeLightBlue(12, 96, 128, 255, "Light Blue"),
dyeMagenta(13, 255, 0, 255, "Magenta"),
dyeOrange(14, 255, 128, 0, "Orange"),
dyeWhite(15, 255, 255, 255, "White"),
dyeBlack(0, 32, 32, 32, "Black", EnumChatFormatting.BLACK),
dyeRed(1, 255, 0, 0, "Red", EnumChatFormatting.RED),
dyeGreen(2, 0, 255, 0, "Green", EnumChatFormatting.DARK_GREEN),
dyeBrown(3, 96, 64, 0, "Brown", EnumChatFormatting.GOLD),
dyeBlue(4, 0, 32, 255, "Blue", EnumChatFormatting.DARK_BLUE),
dyePurple(5, 128, 0, 128, "Purple", EnumChatFormatting.DARK_PURPLE),
dyeCyan(6, 0, 255, 255, "Cyan", EnumChatFormatting.DARK_AQUA),
dyeLightGray(7, 192, 192, 192, "Light Gray", EnumChatFormatting.GRAY),
dyeGray(8, 128, 128, 128, "Gray", EnumChatFormatting.DARK_GRAY),
dyePink(9, 255, 192, 192, "Pink", EnumChatFormatting.LIGHT_PURPLE),
dyeLime(10, 128, 255, 128, "Lime", EnumChatFormatting.GREEN),
dyeYellow(11, 255, 255, 0, "Yellow", EnumChatFormatting.YELLOW),
dyeLightBlue(12, 96, 128, 255, "Light Blue", EnumChatFormatting.AQUA),
dyeMagenta(13, 255, 0, 255, "Magenta", EnumChatFormatting.LIGHT_PURPLE),
dyeOrange(14, 255, 128, 0, "Orange", EnumChatFormatting.GOLD),
dyeWhite(15, 255, 255, 255, "White", EnumChatFormatting.WHITE),
/**
* The NULL Color
*/
Expand All @@ -48,13 +49,19 @@ public enum Dyes implements IColorModulationContainer {
public final String mName;
public final short[] mRGBa;
public final short[] mOriginalRGBa;
public final EnumChatFormatting formatting;
private final ArrayList<Fluid> mFluidDyes = new GT_ArrayList<>(false, 1);

Dyes(int aIndex, int aR, int aG, int aB, String aName) {
this(aIndex, aR, aR, aB, aName, EnumChatFormatting.GRAY);
}

Dyes(int aIndex, int aR, int aG, int aB, String aName, EnumChatFormatting formatting) {
mIndex = (byte) aIndex;
mName = aName;
mRGBa = new short[] { (short) aR, (short) aG, (short) aB, 0 };
mOriginalRGBa = mRGBa.clone();
this.formatting = formatting;
}

public static Dyes get(int aColor) {
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/gregtech/common/blocks/GT_Item_Machines.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.GregTech_API;
import gregtech.api.enums.Dyes;
import gregtech.api.enums.Materials;
import gregtech.api.interfaces.ISecondaryDescribable;
import gregtech.api.interfaces.metatileentity.IConnectable;
Expand Down Expand Up @@ -158,6 +159,17 @@ public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List<String>
}

CoverableTileEntity.addInstalledCoversInformation(aNBT, aList);
if (aNBT.hasKey("mColor") && aNBT.getByte("mColor") != -1) {
aList.add(
GT_LanguageManager.addStringLocalization(
"GT_TileEntity_COLORED",
"Colored",
!GregTech_API.sPostloadFinished) + " ("
+ Dyes.get(aNBT.getByte("mColor") - 1).formatting
+ Dyes.get(aNBT.getByte("mColor") - 1).mName
+ EnumChatFormatting.GRAY
+ ")");
}
}
} catch (Throwable e) {
GT_FML_LOGGER.error("addInformation", e);
Expand Down

0 comments on commit deb860c

Please sign in to comment.