use of mekanism.api.text.EnumColor in project Mekanism by mekanism.
the class SideDataButton method drawBackground.
@Override
public void drawBackground(@Nonnull MatrixStack matrix, int mouseX, int mouseY, float partialTicks) {
DataType dataType = getDataType();
EnumColor color = dataType == null ? null : getColor();
boolean doColor = color != null && color != EnumColor.GRAY;
if (doColor) {
Color c = Color.rgbi(color.getRgbCode()[0], color.getRgbCode()[1], color.getRgbCode()[2]);
double[] hsv = c.hsvArray();
hsv[1] = Math.max(0, hsv[1] - 0.25F);
hsv[2] = Math.min(1, hsv[2] + 0.4F);
MekanismRenderer.color(Color.hsv(hsv[0], hsv[1], hsv[2]));
} else {
MekanismRenderer.resetColor();
}
super.drawBackground(matrix, mouseX, mouseY, partialTicks);
if (doColor) {
MekanismRenderer.resetColor();
}
}
use of mekanism.api.text.EnumColor in project Mekanism by mekanism.
the class ClientRegistration method registerItemColorHandlers.
@SubscribeEvent
public static void registerItemColorHandlers(ColorHandlerEvent.Item event) {
// Create the texture atlas for the robit's textures here as there isn't a great spot to do it until 1.17
createRobitTextureAtlas();
BlockColors blockColors = event.getBlockColors();
ItemColors itemColors = event.getItemColors();
ClientRegistrationUtil.registerBlockColorHandler(blockColors, (state, world, pos, tintIndex) -> {
if (pos != null) {
TileEntity tile = WorldUtils.getTileEntity(world, pos);
if (tile instanceof TileEntityQIOComponent) {
EnumColor color = ((TileEntityQIOComponent) tile).getColor();
return color != null ? MekanismRenderer.getColorARGB(color, 1) : -1;
}
}
return -1;
}, MekanismBlocks.QIO_DRIVE_ARRAY, MekanismBlocks.QIO_DASHBOARD, MekanismBlocks.QIO_IMPORTER, MekanismBlocks.QIO_EXPORTER, MekanismBlocks.QIO_REDSTONE_ADAPTER);
ClientRegistrationUtil.registerIColoredBlockHandler(blockColors, itemColors, // Fluid Tank
MekanismBlocks.BASIC_FLUID_TANK, MekanismBlocks.ADVANCED_FLUID_TANK, MekanismBlocks.ELITE_FLUID_TANK, MekanismBlocks.ULTIMATE_FLUID_TANK, MekanismBlocks.CREATIVE_FLUID_TANK);
ClientRegistrationUtil.registerBlockColorHandler(blockColors, (state, world, pos, tintIndex) -> {
if (tintIndex == 1 && pos != null) {
TileEntityLogisticalTransporter transporter = WorldUtils.getTileEntity(TileEntityLogisticalTransporter.class, world, pos);
if (transporter != null) {
EnumColor renderColor = transporter.getTransmitter().getColor();
if (renderColor != null) {
return MekanismRenderer.getColorARGB(renderColor, 1);
}
}
}
return -1;
}, MekanismBlocks.BASIC_LOGISTICAL_TRANSPORTER, MekanismBlocks.ADVANCED_LOGISTICAL_TRANSPORTER, MekanismBlocks.ELITE_LOGISTICAL_TRANSPORTER, MekanismBlocks.ULTIMATE_LOGISTICAL_TRANSPORTER);
for (Cell<ResourceType, PrimaryResource, ItemRegistryObject<Item>> item : MekanismItems.PROCESSED_RESOURCES.cellSet()) {
int tint = item.getColumnKey().getTint();
ClientRegistrationUtil.registerItemColorHandler(itemColors, (stack, index) -> index == 1 ? tint : -1, item.getValue());
}
for (Map.Entry<PrimaryResource, BlockRegistryObject<?, ?>> entry : MekanismBlocks.PROCESSED_RESOURCE_BLOCKS.entrySet()) {
int tint = entry.getKey().getTint();
ClientRegistrationUtil.registerBlockColorHandler(blockColors, itemColors, (state, world, pos, index) -> index == 1 ? tint : -1, (stack, index) -> index == 1 ? tint : -1, entry.getValue());
}
ClientRegistrationUtil.registerItemColorHandler(itemColors, (stack, index) -> {
if (index == 1) {
ItemPortableQIODashboard item = (ItemPortableQIODashboard) stack.getItem();
EnumColor color = item.getColor(stack);
return color == null ? 0xFF555555 : MekanismRenderer.getColorARGB(color, 1);
}
return -1;
}, MekanismItems.PORTABLE_QIO_DASHBOARD);
}
use of mekanism.api.text.EnumColor in project Mekanism by mekanism.
the class ColorButton method drawBackground.
@Override
public void drawBackground(@Nonnull MatrixStack matrix, int mouseX, int mouseY, float partialTicks) {
// Ensure the color gets reset. The default GuiButtonImage doesn't so other GuiButton's can have the color leak out of them
EnumColor color = colorSupplier.get();
if (color != null) {
fill(matrix, this.x, this.y, this.x + this.width, this.y + this.height, MekanismRenderer.getColorARGB(color, 1));
MekanismRenderer.resetColor();
}
}
use of mekanism.api.text.EnumColor in project Mekanism by mekanism.
the class AdditionsRecipeProvider method registerBalloon.
private void registerBalloon(Consumer<IFinishedRecipe> consumer, ItemRegistryObject<ItemBalloon> result, String basePath) {
EnumColor color = result.getItem().getColor();
String colorString = color.getRegistryPrefix();
IngredientWithout recolorInput = IngredientWithout.create(Items.BALLOONS, result);
DyeColor dye = color.getDyeColor();
if (dye != null) {
ExtendedShapelessRecipeBuilder.shapelessRecipe(result, 2).addIngredient(Tags.Items.LEATHER).addIngredient(Tags.Items.STRING).addIngredient(dye.getTag()).build(consumer, MekanismAdditions.rl(basePath + colorString));
ExtendedShapelessRecipeBuilder.shapelessRecipe(result).addIngredient(recolorInput).addIngredient(dye.getTag()).build(consumer, MekanismAdditions.rl(basePath + "recolor/" + colorString));
}
ItemStackChemicalToItemStackRecipeBuilder.painting(ItemStackIngredient.from(recolorInput), PigmentStackIngredient.from(MekanismPigments.PIGMENT_COLOR_LOOKUP.get(color), PigmentExtractingRecipeProvider.DYE_RATE), new ItemStack(result)).build(consumer, Mekanism.rl(basePath + "recolor/painting/" + colorString));
}
use of mekanism.api.text.EnumColor in project Mekanism by mekanism.
the class PlasticBlockRecipeProvider method registerPlasticBlock.
private void registerPlasticBlock(Consumer<IFinishedRecipe> consumer, BlockRegistryObject<? extends IColoredBlock, ?> result, String basePath) {
EnumColor color = result.getBlock().getColor();
DyeColor dye = color.getDyeColor();
if (dye != null) {
ExtendedShapedRecipeBuilder.shapedRecipe(result, 4).pattern(PLASTIC).key(Pattern.CONSTANT, MekanismItems.HDPE_SHEET).key(Pattern.DYE, dye.getTag()).build(consumer, MekanismAdditions.rl(basePath + color.getRegistryPrefix()));
}
registerRecolor(consumer, result, AdditionsTags.Items.PLASTIC_BLOCKS_PLASTIC, color, basePath);
}
Aggregations