Skip to content

Commit c7aec0c

Browse files
authored
Merge branch '1.21' into hexal-spells
2 parents 7b68ba5 + 42ea85d commit c7aec0c

89 files changed

Lines changed: 493 additions & 463 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/pr.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
branches: indev/1.21.1
1313

1414
env:
15-
JAVA_VERSION: '21.0.5'
15+
JAVA_VERSION: '21'
1616

1717
jobs:
1818
build:
@@ -62,12 +62,13 @@ jobs:
6262
dependencies: >-
6363
'https://cdn.modrinth.com/data/Ha28R6CL/versions/2i87JpYj/fabric-language-kotlin-1.13.11%2Bkotlin.2.3.21.jar'
6464
'https://cdn.modrinth.com/data/9s6osm5g/versions/HpMb5wGb/cloth-config-15.0.140-fabric.jar'
65-
'https://github.com/SuperKnux/HexMod/raw/refs/heads/indev/1.21.1/libs/paucal-0.7.1-noelle+1.21.1-fabric.jar'
65+
'https://ci.blamejared.com/job/petrakat/job/PAUCAL/job/1.21/27/artifact/Fabric/build/libs/paucal-0.7.1-pre-27+1.21.1-fabric.jar'
6666
'https://cdn.modrinth.com/data/fin1PX4m/versions/SBDJBD0a/inline-fabric-1.21.1-1.2.2.jar'
6767
'https://cdn.modrinth.com/data/K01OU20C/versions/nLsCe2VD/cardinal-components-api-6.1.3.jar'
6868
'https://cdn.modrinth.com/data/nU0bVIaL/versions/XIjNwQkI/Patchouli-1.21.1-93-FABRIC.jar'
6969
'https://cdn.modrinth.com/data/mOgUt4GM/versions/v6Xx3fbU/modmenu-11.0.4.jar'
7070
'https://cdn.modrinth.com/data/5aaWibi9/versions/JagCscwi/trinkets-3.10.0.jar'
71+
'https://cdn.modrinth.com/data/lhGA9TYQ/versions/Pzc2FP5K/architectury-13.0.11-fabric.jar'
7172
- modloader: neoforge
7273
mc-runtime-test: neoforge
7374
fabric-api: none
@@ -88,17 +89,18 @@ jobs:
8889
java-version: ${{ env.JAVA_VERSION }}
8990

9091
- name: Create cache key
92+
id: cache-key
9193
run: |
9294
cat <<END_OF_FILE > dependencies.txt
9395
${{ matrix.dependencies }}
9496
END_OF_FILE
95-
96-
- name: Cache dependencies
97+
echo "key=$(sha256sum dependencies.txt | awk '{print $1}')" >> $GITHUB_OUTPUT
98+
- name: Restore cached dependencies
9799
id: cache
98-
uses: actions/cache@v4
100+
uses: actions/cache/restore@v4
99101
with:
100102
path: run/mods
101-
key: ${{ hashFiles('dependencies.txt') }}
103+
key: ${{ steps.cache-key.outputs.key }}
102104

103105
- name: Download dependencies
104106
if: steps.cache.outputs.cache-hit != 'true'
@@ -107,6 +109,14 @@ jobs:
107109
wget --directory-prefix=run/mods/ "$url"
108110
done
109111
112+
# Cache has to be saved here already to avoid also caching the build artifact at the end of the run
113+
- name: Cache dependencies
114+
uses: actions/cache/save@v4
115+
if: steps.cache.outputs.cache-hit != 'true'
116+
with:
117+
path: run/mods
118+
key: ${{ steps.cache-key.outputs.key }}
119+
110120
- name: Download build artifacts
111121
uses: actions/download-artifact@v4
112122
with:
@@ -115,13 +125,13 @@ jobs:
115125

116126
- name: Prepare mod jar
117127
run: |
118-
rm -f dist/*-javadoc.jar dist/*-sources.jar
128+
rm -f dist/*-javadoc.jar dist/*-sources.jar dist/*-shadow.jar
119129
cp dist/hexcasting-${{ matrix.modloader }}-*.jar run/mods
120130
121131
- name: Run MC test client
122132
if: matrix.env == 'client'
123133
timeout-minutes: 10
124-
uses: headlesshq/mc-runtime-test@4.4.0
134+
uses: headlesshq/mc-runtime-test@4.5.1
125135
with:
126136
java: ${{ env.JAVA_VERSION }}
127137
mc: 1.21.1
@@ -135,7 +145,7 @@ jobs:
135145
timeout-minutes: 10
136146
uses: headlesshq/mc-server-test@1.1.1
137147
with:
138-
java: 21
148+
java: ${{ env.JAVA_VERSION }}
139149
mc: 1.21.1
140150
modloader: ${{ matrix.modloader }}
141151
fabric-api: ${{ matrix.fabric-api }}

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
1515
- Factorial Purification now works on vectors as well as numbers, applying element-wise
1616
- Added Simulate, which causes the next pattern drawn to be simulated (to check for mishaps) rather than executed ([#1194](https://github.com/FallingColors/HexMod/pull/1194)) @Robotgiggle
1717
- 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
18+
- Added a new Ancient Cypher hex that impulses nearby items towards the caster ([#1106](https://github.com/FallingColors/HexMod/pull/1106)) @IridescentVoid
19+
20+
### Changed
21+
22+
- Reworked Thoth's Gambit in a variety of ways ([#1106](https://github.com/FallingColors/HexMod/pull/1106)) @IridescentVoid
23+
- The argument order now takes the data list first and then the loop body
24+
- The loop body can now be either a list or a single executable iota
25+
- The pattern itself is now a special handler with a variable tail length
26+
- The tail length determines how many extra iotas from the original stack are included in each iteration's stack
27+
- Iotas included via the above process are now popped from the original stack
1828

1929
### Fixed
2030

@@ -24,6 +34,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
2434
### Internal
2535

2636
- Removed APIs deprecated in `0.11.4` ([#1126](https://github.com/FallingColors/HexMod/pull/1126), [#1127](https://github.com/FallingColors/HexMod/pull/1127) [#1129](https://github.com/FallingColors/HexMod/pull/1129), [#1137](https://github.com/FallingColors/HexMod/pull/1137), [#1142](https://github.com/FallingColors/HexMod/pull/1142)) @s5bug
37+
- ListIota now uses the asymptotically-efficient TreeList internally ([#1032](https://github.com/FallingColors/HexMod/pull/1032)) @s5bug
38+
- SpellList has been removed ([#1032](https://github.com/FallingColors/HexMod/pull/1032)) @s5bug
39+
- Casting Image and Casting Frames now store iotas in a TreeList ([#1033](https://github.com/FallingColors/HexMod/pull/1033)) @s5bug
2740

2841
## `0.11.3` - 2025-11-22
2942

Common/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ repositories {
2525

2626
maven { url "https://maven.shedaniel.me/" }
2727
// EMI
28-
maven { url = "https://maven.terraformersmc.com/releases/" }
28+
// temporarily changed from https://maven.terraformersmc.com/releases/ due to intermittent errors
29+
maven { url = "https://maven.gnomecraft.net/releases" }
2930
}
3031

3132
dependencies {

Common/src/main/java/at/petrak/hexcasting/api/casting/ActionUtils.kt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import at.petrak.hexcasting.api.casting.iota.*
66
import at.petrak.hexcasting.api.casting.math.HexPattern
77
import at.petrak.hexcasting.api.casting.mishaps.MishapInvalidIota
88
import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs
9+
import at.petrak.hexcasting.api.utils.TreeList
910
import at.petrak.hexcasting.api.utils.asTranslatedComponent
1011
import at.petrak.hexcasting.api.utils.validateIota
1112
import com.mojang.datafixers.util.Either
@@ -43,7 +44,7 @@ fun List<Iota>.getEntity(level: ServerLevel, idx: Int, argc: Int = 0): Entity {
4344
}
4445
}
4546

46-
fun List<Iota>.getList(idx: Int, argc: Int = 0): SpellList {
47+
fun List<Iota>.getList(idx: Int, argc: Int = 0): TreeList<Iota> {
4748
val x = this.getOrElse(idx) { throw MishapNotEnoughArgs(idx + 1, this.size) }
4849
if (x is ListIota) {
4950
return x.list
@@ -290,7 +291,7 @@ fun List<Iota>.getVecOrVecList(idx: Int, argc: Int = 0): Either<Vec3, List<Vec3>
290291
}
291292
}
292293

293-
fun List<Iota>.getLongOrList(idx: Int, argc: Int = 0): Either<Long, SpellList> {
294+
fun List<Iota>.getLongOrList(idx: Int, argc: Int = 0): Either<Long, TreeList<Iota>> {
294295
val datum = this.getOrElse(idx) { throw MishapNotEnoughArgs(idx + 1, this.size) }
295296
if (datum is DoubleIota) {
296297
val double = datum.double
@@ -308,15 +309,17 @@ fun List<Iota>.getLongOrList(idx: Int, argc: Int = 0): Either<Long, SpellList> {
308309
)
309310
}
310311

311-
fun evaluatable(datum: Iota, reverseIdx: Int): Either<Iota, SpellList> =
312-
when (datum) {
312+
fun List<Iota>.getEvaluatable(idx: Int, argc: Int = 0): Either<Iota, TreeList<Iota>> {
313+
val datum = this.getOrElse(idx) { throw MishapNotEnoughArgs(idx + 1, this.size) }
314+
return when (datum) {
313315
is ListIota -> Either.right(datum.list)
314-
else -> if (datum.executable()) Either.left(datum) else throw MishapInvalidIota(
316+
else -> if (datum.executable()) Either.left(datum) else throw MishapInvalidIota.of(
315317
datum,
316-
reverseIdx,
317-
"hexcasting.mishap.invalid_value.evaluatable".asTranslatedComponent
318+
if (argc == 0) idx else argc - (idx + 1),
319+
"evaluatable"
318320
)
319321
}
322+
}
320323

321324
fun Iota?.orNull() = this ?: NullIota()
322325

@@ -339,7 +342,7 @@ inline val Boolean.asActionResult get() = listOf(BooleanIota(this))
339342
inline val Double.asActionResult get() = listOf(DoubleIota(this))
340343
inline val Number.asActionResult get() = listOf(DoubleIota(this.toDouble()))
341344

342-
inline val SpellList.asActionResult get() = listOf(ListIota(this))
345+
inline val TreeList<Iota>.asActionResult get() = listOf(ListIota(this))
343346
inline val List<Iota>.asActionResult get() = listOf(ListIota(this))
344347

345348
inline val BlockPos.asActionResult get() = listOf(Vec3Iota(Vec3.atCenterOf(this)))

Common/src/main/java/at/petrak/hexcasting/api/casting/SpellList.kt

Lines changed: 0 additions & 108 deletions
This file was deleted.

Common/src/main/java/at/petrak/hexcasting/api/casting/arithmetic/operator/OperatorBasic.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ abstract class OperatorBasic(arity: Int, accepts: IotaMultiPredicate) : Operator
1414

1515
@Throws(Mishap::class)
1616
override fun operate(env: CastingEnvironment, image: CastingImage, continuation: SpellContinuation): OperationResult {
17-
val stack = image.stack.toMutableList()
18-
val args = stack.takeLast(arity)
19-
repeat(arity) { stack.removeLast() }
17+
val stack = image.stack
18+
val args = stack.takeRight(arity)
19+
val stackWithoutArgs = stack.dropRight(arity)
2020

2121
val ret = apply(args, env)
22-
ret.forEach(Consumer { e: Iota -> stack.add(e) })
22+
val stackWithResult = stackWithoutArgs.appendedAll(ret)
2323

24-
val image2 = image.copy(stack = stack, opsConsumed = image.opsConsumed + 1)
24+
val image2 = image.copy(stack = stackWithResult, opsConsumed = image.opsConsumed + 1)
2525
return OperationResult(image2, listOf(), continuation, HexEvalSounds.NORMAL_EXECUTE)
2626
}
2727

Common/src/main/java/at/petrak/hexcasting/api/casting/castables/ConstMediaAction.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ interface ConstMediaAction : Action {
2929
}
3030

3131
override fun operate(env: CastingEnvironment, image: CastingImage, continuation: SpellContinuation): OperationResult {
32-
val stack = image.stack.toMutableList()
32+
val stack = image.stack
3333

3434
if (this.argc > stack.size)
3535
throw MishapNotEnoughArgs(this.argc, stack.size)
36-
val args = stack.takeLast(this.argc)
37-
repeat(this.argc) { stack.removeLast() }
36+
val args = stack.takeRight(this.argc)
37+
val stackWithoutArgs = stack.dropRight(this.argc)
3838
val result = this.executeWithOpCount(args, env)
39-
stack.addAll(result.resultStack)
39+
val stackWithResult = stackWithoutArgs.appendedAll(result.resultStack)
4040

4141
if (env.extractMedia(this.mediaCost, true) > 0)
4242
throw MishapNotEnoughMedia(this.mediaCost)
4343

4444
val sideEffects = mutableListOf<OperatorSideEffect>(OperatorSideEffect.ConsumeMedia(this.mediaCost))
4545

46-
val image2 = image.copy(stack = stack, opsConsumed = image.opsConsumed + result.opCount)
46+
val image2 = image.copy(stack = stackWithResult, opsConsumed = image.opsConsumed + result.opCount)
4747
return OperationResult(image2, sideEffects, continuation, HexEvalSounds.NORMAL_EXECUTE)
4848
}
4949

Common/src/main/java/at/petrak/hexcasting/api/casting/castables/SpellAction.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ interface SpellAction : Action {
3636
}
3737

3838
override fun operate(env: CastingEnvironment, image: CastingImage, continuation: SpellContinuation): OperationResult {
39-
val stack = image.stack.toMutableList()
39+
val stack = image.stack
4040

4141
if (this.argc > stack.size)
4242
throw MishapNotEnoughArgs(this.argc, stack.size)
43-
val args = stack.takeLast(this.argc)
44-
for (_i in 0 until this.argc) stack.removeLast()
43+
val args = stack.takeRight(this.argc)
44+
val stackWithoutArgs = stack.dropRight(this.argc)
4545

4646
// execute!
4747
val userDataMut = image.userData.copy()
@@ -65,7 +65,7 @@ interface SpellAction : Action {
6565
for (spray in result.particles)
6666
sideEffects.add(OperatorSideEffect.Particles(spray))
6767

68-
val image2 = image.copy(stack = stack, opsConsumed = image.opsConsumed + result.opCount, userData = userDataMut)
68+
val image2 = image.copy(stack = stackWithoutArgs, opsConsumed = image.opsConsumed + result.opCount, userData = userDataMut)
6969

7070
val sound = if (this.hasCastingSound(env)) HexEvalSounds.SPELL else HexEvalSounds.MUTE
7171
return OperationResult(image2, sideEffects, continuation, sound)

Common/src/main/java/at/petrak/hexcasting/api/casting/eval/ExecutionClientView.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package at.petrak.hexcasting.api.casting.eval
22

33
import at.petrak.hexcasting.api.casting.iota.Iota
44
import at.petrak.hexcasting.api.casting.iota.IotaType
5-
import net.minecraft.nbt.CompoundTag
65
import net.minecraft.network.RegistryFriendlyByteBuf
76
import net.minecraft.network.codec.ByteBufCodecs
87
import net.minecraft.network.codec.StreamCodec
@@ -17,7 +16,7 @@ data class ExecutionClientView(
1716
val resolutionType: ResolvedPatternType,
1817

1918
val stackDescs: List<Iota>,
20-
val ravenmind: CompoundTag?
19+
val ravenmind: Iota?
2120
) {
2221

2322
companion object {
@@ -30,9 +29,9 @@ data class ExecutionClientView(
3029
ResolvedPatternType::ordinal
3130
), ExecutionClientView::resolutionType,
3231
IotaType.TYPED_STREAM_CODEC.apply(ByteBufCodecs.list()), ExecutionClientView::stackDescs,
33-
ByteBufCodecs.optional(ByteBufCodecs.COMPOUND_TAG).map(
32+
ByteBufCodecs.optional(IotaType.TYPED_STREAM_CODEC).map(
3433
{ it.getOrNull() },
35-
Optional<CompoundTag>::ofNullable
34+
Optional<Iota>::ofNullable
3635
), ExecutionClientView::ravenmind,
3736
::ExecutionClientView
3837
)

0 commit comments

Comments
 (0)