From 5fbb617e2a31c70cc75b57d6c9df574d28d9f75e Mon Sep 17 00:00:00 2001 From: Kli Kli Date: Mon, 25 Sep 2023 13:52:48 +0200 Subject: [PATCH] feat: colorblind mode for chalks (see occultism-client.toml) (#974) * feat: add color supplier to chalk block * feat: add configurable color --- .../common/block/ChalkGlyphBlock.java | 10 ++---- .../config/OccultismClientConfig.java | 32 +++++++++++++++++++ .../occultism/registry/OccultismBlocks.java | 9 +++--- 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/klikli_dev/occultism/common/block/ChalkGlyphBlock.java b/src/main/java/com/klikli_dev/occultism/common/block/ChalkGlyphBlock.java index 19f682bd4..199c1391e 100644 --- a/src/main/java/com/klikli_dev/occultism/common/block/ChalkGlyphBlock.java +++ b/src/main/java/com/klikli_dev/occultism/common/block/ChalkGlyphBlock.java @@ -58,20 +58,16 @@ public class ChalkGlyphBlock extends Block { private static final VoxelShape SHAPE = Block.box(0, 0, 0, 15, 0.04, 15); protected Supplier chalk; - protected int color; + protected Supplier color; - public ChalkGlyphBlock(Properties properties, int color, Supplier chalk) { + public ChalkGlyphBlock(Properties properties, Supplier color, Supplier chalk) { super(properties); this.color = color; this.chalk = chalk; } public int getColor() { - return this.color; - } - - public void setColor(int color) { - this.color = color; + return this.color.get(); } public Item getChalk() { diff --git a/src/main/java/com/klikli_dev/occultism/config/OccultismClientConfig.java b/src/main/java/com/klikli_dev/occultism/config/OccultismClientConfig.java index a47cadd1d..daae39ba9 100644 --- a/src/main/java/com/klikli_dev/occultism/config/OccultismClientConfig.java +++ b/src/main/java/com/klikli_dev/occultism/config/OccultismClientConfig.java @@ -45,6 +45,12 @@ public static class VisualSettings { public final BooleanValue disableHolidayTheming; public final BooleanValue useAlternativeDivinationRodRenderer; + public final ForgeConfigSpec.ConfigValue whiteChalkGlyphColor; + public final ForgeConfigSpec.ConfigValue goldenChalkGlyphColor; + public final ForgeConfigSpec.ConfigValue purpleChalkGlyphColor; + public final ForgeConfigSpec.ConfigValue redChalkGlyphColor; + + public VisualSettings(ForgeConfigSpec.Builder builder) { builder.comment("Visual Settings").push("visual"); this.showItemTagsInTooltip = builder.comment("Shows all tags an item has in the tooltip on hover if advanced tooltips (F3+H) are enabled.") @@ -57,6 +63,32 @@ public VisualSettings(ForgeConfigSpec.Builder builder) { "When true the old divination rod selected block renderer will be used.", "May work for some people that do not see selected block outlines when using the divination rod.") .define("useAlternativeDivinationRodRenderer", false); + + this.whiteChalkGlyphColor = builder.comment( + "The integer code of the color of the white chalk glyph in world.", + "This is intended to allow people with color blindness to change the color of the glyph.", + "For most types of color blindness it should not be necessary to change this." + ).define("whiteChalkGlyphColor", 0xffffff); + + this.goldenChalkGlyphColor = builder.comment( + "The integer code of the color of the golden chalk glyph in world.", + "This is intended to allow people with color blindness to change the color of the glyph.", + "For most types of color blindness it should not be necessary to change this." + ).define("goldenChalkGlyphColor", 0xf0d700); + + + this.purpleChalkGlyphColor = builder.comment( + "The integer code of the color of the purple chalk glyph in world.", + "This is intended to allow people with color blindness to change the color of the glyph.", + "For most types of color blindness it should not be necessary to change this." + ).define("purpleChalkGlyphColor", 0x9c0393); + + this.redChalkGlyphColor = builder.comment( + "The integer code of the color of the red chalk glyph in world.", + "This is intended to allow people with color blindness to change the color of the glyph.", + "For most types of color blindness this value should be changed to a green color, we recommend 33289 (= Hex 0x008209)" + ).define("redChalkGlyphColor", 0xcc0101); + builder.pop(); } } diff --git a/src/main/java/com/klikli_dev/occultism/registry/OccultismBlocks.java b/src/main/java/com/klikli_dev/occultism/registry/OccultismBlocks.java index c2959eaf0..d9f4a9df1 100644 --- a/src/main/java/com/klikli_dev/occultism/registry/OccultismBlocks.java +++ b/src/main/java/com/klikli_dev/occultism/registry/OccultismBlocks.java @@ -34,6 +34,7 @@ import com.klikli_dev.occultism.common.entity.familiar.FamiliarEntity; import com.klikli_dev.occultism.common.level.tree.OtherworldNaturalTreeGrower; import com.klikli_dev.occultism.common.level.tree.OtherworldTreeGrower; +import com.klikli_dev.occultism.config.OccultismClientConfig; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; @@ -89,16 +90,16 @@ public void tick(BlockState pState, ServerLevel pLevel, BlockPos pPos, RandomSou .noCollission() .strength(5f, 30); public static final RegistryObject CHALK_GLYPH_WHITE = register("chalk_glyph_white", - () -> new ChalkGlyphBlock(GLYPH_PROPERTIES, 0xffffff, () -> OccultismItems.CHALK_WHITE.get()), + () -> new ChalkGlyphBlock(GLYPH_PROPERTIES, Occultism.CLIENT_CONFIG.visuals.whiteChalkGlyphColor, () -> OccultismItems.CHALK_WHITE.get()), false, LootTableType.EMPTY); public static final RegistryObject CHALK_GLYPH_GOLD = register("chalk_glyph_gold", - () -> new ChalkGlyphBlock(GLYPH_PROPERTIES, 0xf0d700, () -> OccultismItems.CHALK_GOLD.get()), false, + () -> new ChalkGlyphBlock(GLYPH_PROPERTIES, Occultism.CLIENT_CONFIG.visuals.goldenChalkGlyphColor, () -> OccultismItems.CHALK_GOLD.get()), false, LootTableType.EMPTY); public static final RegistryObject CHALK_GLYPH_PURPLE = register("chalk_glyph_purple", - () -> new ChalkGlyphBlock(GLYPH_PROPERTIES, 0x9c0393, () -> OccultismItems.CHALK_PURPLE.get()), + () -> new ChalkGlyphBlock(GLYPH_PROPERTIES, Occultism.CLIENT_CONFIG.visuals.purpleChalkGlyphColor, () -> OccultismItems.CHALK_PURPLE.get()), false, LootTableType.EMPTY); public static final RegistryObject CHALK_GLYPH_RED = register("chalk_glyph_red", - () -> new ChalkGlyphBlock(GLYPH_PROPERTIES, 0xcc0101, () -> OccultismItems.CHALK_RED.get()), false, + () -> new ChalkGlyphBlock(GLYPH_PROPERTIES, Occultism.CLIENT_CONFIG.visuals.redChalkGlyphColor, () -> OccultismItems.CHALK_RED.get()), false, LootTableType.EMPTY); //Resources