From 02dfe9649fac328725ac4241a49955f4dee43d22 Mon Sep 17 00:00:00 2001 From: Robotgiggle <88736742+Robotgiggle@users.noreply.github.com> Date: Thu, 9 Jul 2026 23:30:57 -0400 Subject: [PATCH 1/3] Null coalesce pattern --- .../casting/actions/math/logic/OpNullCoalesce.kt | 16 ++++++++++++++++ .../hexcasting/common/lib/hex/HexActions.java | 7 +++---- .../assets/hexcasting/lang/en_us.flatten.json5 | 2 ++ .../thehexbook/en_us/entries/patterns/logic.json | 8 ++++++++ 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 Common/src/main/java/at/petrak/hexcasting/common/casting/actions/math/logic/OpNullCoalesce.kt diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/math/logic/OpNullCoalesce.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/math/logic/OpNullCoalesce.kt new file mode 100644 index 000000000..0e7b10b89 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/math/logic/OpNullCoalesce.kt @@ -0,0 +1,16 @@ +package at.petrak.hexcasting.common.casting.actions.math.logic + +import at.petrak.hexcasting.api.casting.castables.ConstMediaAction +import at.petrak.hexcasting.api.casting.eval.CastingEnvironment +import at.petrak.hexcasting.api.casting.iota.Iota +import at.petrak.hexcasting.api.casting.iota.NullIota + +object OpNullCoalesce : ConstMediaAction { + override val argc = 2 + + override fun execute(args: List, env: CastingEnvironment): List { + if (args[0] is NullIota) + return listOf(args[1]) + return listOf(args[0]) + } +} \ No newline at end of file diff --git a/Common/src/main/java/at/petrak/hexcasting/common/lib/hex/HexActions.java b/Common/src/main/java/at/petrak/hexcasting/common/lib/hex/HexActions.java index eb049a8e7..a12d71b86 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/lib/hex/HexActions.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/lib/hex/HexActions.java @@ -26,10 +26,7 @@ import at.petrak.hexcasting.common.casting.actions.local.OpPushLocal; import at.petrak.hexcasting.common.casting.actions.math.OpCoerceToAxial; import at.petrak.hexcasting.common.casting.actions.math.OpRandom; -import at.petrak.hexcasting.common.casting.actions.math.logic.OpBoolIf; -import at.petrak.hexcasting.common.casting.actions.math.logic.OpCoerceToBool; -import at.petrak.hexcasting.common.casting.actions.math.logic.OpEquality; -import at.petrak.hexcasting.common.casting.actions.math.logic.OpTypeEquality; +import at.petrak.hexcasting.common.casting.actions.math.logic.*; import at.petrak.hexcasting.common.casting.actions.queryentity.*; import at.petrak.hexcasting.common.casting.actions.raycast.OpBlockAxisRaycast; import at.petrak.hexcasting.common.casting.actions.raycast.OpBlockRaycast; @@ -199,6 +196,8 @@ public class HexActions { new ActionRegistryEntry(HexPattern.fromAngles("aw", HexDir.NORTH_EAST), OpCoerceToBool.INSTANCE)); public static final ActionRegistryEntry IF = make("if", new ActionRegistryEntry(HexPattern.fromAngles("awdd", HexDir.SOUTH_EAST), OpBoolIf.INSTANCE)); + public static final ActionRegistryEntry NULL_COALESCE = make("null_coalesce", + new ActionRegistryEntry(HexPattern.fromAngles("wawaa", HexDir.SOUTH_EAST), OpNullCoalesce.INSTANCE)); public static final ActionRegistryEntry RANDOM = make("random", new ActionRegistryEntry(HexPattern.fromAngles("eqqq", HexDir.NORTH_WEST), OpRandom.INSTANCE)); diff --git a/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 b/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 index 528f82646..98817bc42 100644 --- a/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 +++ b/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 @@ -815,6 +815,7 @@ not: "Negation Purification", bool_coerce: "Augur's Purification", if: "Augur's Exaltation", + null_coalesce: "Coalescing Distillation", add: "Additive Distillation", sub: "Subtractive Distillation", @@ -1906,6 +1907,7 @@ and: "Returns True if both arguments are true; otherwise returns False.", xor: "Returns True if exactly one of the arguments is true; otherwise returns False.", if: "If the first argument is True, keeps the second and discards the third; otherwise discards the second and keeps the third.", + null_coalesce: "If the first argument is not $(l:casting/influences)$(thing)Null/$, returns it. Otherwise, returns the second argument.", equals: "If the first argument equals the second (within a small tolerance), return True. Otherwise, return False.", not_equals: "If the first argument does not equal the second (outside a small tolerance), return True. Otherwise, return False.", type_equals: "If the type of the first argument matches the type of the second, return True. Otherwise, return False.", diff --git a/Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/patterns/logic.json b/Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/patterns/logic.json index f321377b4..2a4b8c405 100644 --- a/Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/patterns/logic.json +++ b/Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/patterns/logic.json @@ -63,6 +63,14 @@ "output": "any", "text": "hexcasting.page.logic.if" }, + { + "type": "hexcasting:pattern", + "op_id": "hexcasting:null_coalesce", + "anchor": "hexcasting:null_coalesce", + "input": "any, any", + "output": "any", + "text": "hexcasting.page.logic.null_coalesce" + }, { "type": "hexcasting:pattern", "op_id": "hexcasting:equals", From b5dc9fccf590b94c2df38066ce804516948815f7 Mon Sep 17 00:00:00 2001 From: Robotgiggle <88736742+Robotgiggle@users.noreply.github.com> Date: Thu, 9 Jul 2026 23:31:07 -0400 Subject: [PATCH 2/3] Tweak augur exalt description --- .../main/resources/assets/hexcasting/lang/en_us.flatten.json5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 b/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 index 98817bc42..eeb3ac1a1 100644 --- a/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 +++ b/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 @@ -1906,7 +1906,7 @@ or: "Returns True if at least one of the arguments are True; otherwise returns False.", and: "Returns True if both arguments are true; otherwise returns False.", xor: "Returns True if exactly one of the arguments is true; otherwise returns False.", - if: "If the first argument is True, keeps the second and discards the third; otherwise discards the second and keeps the third.", + if: "If the first argument is True, returns the second argument. Otherwise, returns the third argument.", null_coalesce: "If the first argument is not $(l:casting/influences)$(thing)Null/$, returns it. Otherwise, returns the second argument.", equals: "If the first argument equals the second (within a small tolerance), return True. Otherwise, return False.", not_equals: "If the first argument does not equal the second (outside a small tolerance), return True. Otherwise, return False.", From c0e58417677e6bec50f6d8568c7d7f39a5cb7f95 Mon Sep 17 00:00:00 2001 From: Robotgiggle <88736742+Robotgiggle@users.noreply.github.com> Date: Thu, 9 Jul 2026 23:31:14 -0400 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5289464a..fe555b6ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - Updated to Minecraft 1.21.1 ([#985](https://github.com/FallingColors/HexMod/pull/985)) @SuperKnux @slava110 - Added the `hex_unbreakable` tag for blocks that should be immune to Break Block regardless of the configured mining tier ([#1186](https://github.com/FallingColors/HexMod/pull/1186)) @Robotgiggle @slava110 +- Added Coalescing Distillation, which performs the null-coalescing operation ([#1196](https://github.com/FallingColors/HexMod/pull/1196)) @Robotgiggle ### Fixed