-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd9ab10
commit d3c77f4
Showing
17 changed files
with
195 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/stellarwitch7/ram/cca/block/ModBlockComponents.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package stellarwitch7.ram.cca.block | ||
|
||
object ModBlockComponents { | ||
//TODO | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,21 @@ | ||
package stellarwitch7.ram.spell.trick | ||
|
||
object ModTricks { | ||
import dev.enjarai.trickster.spell.trick.Trick | ||
import dev.enjarai.trickster.spell.trick.Tricks | ||
import net.minecraft.registry.Registry | ||
import stellarwitch7.libstellar.registry.Registrar | ||
import stellarwitch7.ram.RandomAccessMind | ||
import stellarwitch7.ram.spell.trick.mind.RAMAllocTrick | ||
import stellarwitch7.ram.spell.trick.mind.RAMFreeTrick | ||
import stellarwitch7.ram.spell.trick.mind.RAMReadTrick | ||
import stellarwitch7.ram.spell.trick.mind.RAMWriteTrick | ||
|
||
object ModTricks : Registrar<Trick> { | ||
override val modID: String = RandomAccessMind.MOD_ID | ||
override val registry: Registry<Trick> = Tricks.REGISTRY | ||
|
||
val alloc = register("alloc", RAMAllocTrick()) | ||
val free = register("free", RAMFreeTrick()) | ||
val read = register("read", RAMReadTrick()) | ||
val write = register("write", RAMWriteTrick()) | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/kotlin/stellarwitch7/ram/spell/trick/blunder/NotWithinRAMBoundsBlunder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package stellarwitch7.ram.spell.trick.blunder | ||
|
||
import dev.enjarai.trickster.spell.trick.Trick | ||
import dev.enjarai.trickster.spell.trick.blunder.TrickBlunderException | ||
import net.minecraft.text.MutableText | ||
|
||
class NotWithinRAMBoundsBlunder(source: Trick, private val max: UInt, private val given: Double) : TrickBlunderException(source) { | ||
override fun createMessage(): MutableText { | ||
return super.createMessage() | ||
.append("Invalid RAM slot address. Got ") | ||
.append("{}".format(given)) | ||
.append(", but must be greater or equal to zero and lesser than ") | ||
.append("{}".format(max)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 19 additions & 1 deletion
20
src/main/kotlin/stellarwitch7/ram/spell/trick/mind/RAMFreeTrick.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
package stellarwitch7.ram.spell.trick.mind | ||
|
||
class RAMFreeTrick { | ||
import dev.enjarai.trickster.spell.Fragment | ||
import dev.enjarai.trickster.spell.Pattern | ||
import dev.enjarai.trickster.spell.SpellContext | ||
import dev.enjarai.trickster.spell.fragment.FragmentType | ||
import dev.enjarai.trickster.spell.fragment.VoidFragment | ||
import dev.enjarai.trickster.spell.trick.Trick | ||
import dev.enjarai.trickster.spell.trick.blunder.NoPlayerBlunder | ||
import stellarwitch7.ram.cca.entity.ModEntityComponents | ||
|
||
class RAMFreeTrick : Trick(Pattern.of(1, 4, 6, 8, 4)) { | ||
override fun activate(ctx: SpellContext, fragments: List<Fragment>): Fragment { | ||
val number = expectInput(fragments, FragmentType.NUMBER, 0).number() | ||
|
||
ModEntityComponents.ram.get(ctx.source.player.orElseThrow { | ||
NoPlayerBlunder(this) | ||
}).ram.free(this, number.toInt()) | ||
|
||
return VoidFragment.INSTANCE | ||
} | ||
} |
17 changes: 16 additions & 1 deletion
17
src/main/kotlin/stellarwitch7/ram/spell/trick/mind/RAMReadTrick.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,19 @@ | ||
package stellarwitch7.ram.spell.trick.mind | ||
|
||
class RAMReadTrick { | ||
import dev.enjarai.trickster.spell.Fragment | ||
import dev.enjarai.trickster.spell.Pattern | ||
import dev.enjarai.trickster.spell.SpellContext | ||
import dev.enjarai.trickster.spell.fragment.FragmentType | ||
import dev.enjarai.trickster.spell.trick.Trick | ||
import dev.enjarai.trickster.spell.trick.blunder.NoPlayerBlunder | ||
import stellarwitch7.ram.cca.entity.ModEntityComponents | ||
|
||
class RAMReadTrick : Trick(Pattern.of(1, 4, 3, 6, 8, 5)) { | ||
override fun activate(ctx: SpellContext, fragments: List<Fragment>): Fragment { | ||
val number = expectInput(fragments, FragmentType.NUMBER, 0).number() | ||
|
||
return ModEntityComponents.ram.get(ctx.source.player.orElseThrow { | ||
NoPlayerBlunder(this) | ||
}).ram.read(this, number.toInt()) | ||
} | ||
} |
4 changes: 0 additions & 4 deletions
4
src/main/kotlin/stellarwitch7/ram/spell/trick/mind/RAMStoreTrick.kt
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
src/main/kotlin/stellarwitch7/ram/spell/trick/mind/RAMWriteTrick.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package stellarwitch7.ram.spell.trick.mind | ||
|
||
import dev.enjarai.trickster.spell.Fragment | ||
import dev.enjarai.trickster.spell.Pattern | ||
import dev.enjarai.trickster.spell.SpellContext | ||
import dev.enjarai.trickster.spell.fragment.FragmentType | ||
import dev.enjarai.trickster.spell.fragment.VoidFragment | ||
import dev.enjarai.trickster.spell.trick.Trick | ||
import dev.enjarai.trickster.spell.trick.blunder.NoPlayerBlunder | ||
import stellarwitch7.ram.cca.entity.ModEntityComponents | ||
|
||
class RAMWriteTrick : Trick(Pattern.of(1, 4, 5, 8, 6, 3)) { | ||
override fun activate(ctx: SpellContext, fragments: List<Fragment>): Fragment { | ||
val number = expectInput(fragments, FragmentType.NUMBER, 0).number() | ||
val any = expectInput(fragments, 1) | ||
|
||
ModEntityComponents.ram.get(ctx.source.player.orElseThrow { | ||
NoPlayerBlunder(this) | ||
}).ram.write(this, number.toInt(), any) | ||
|
||
return VoidFragment.INSTANCE | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
trickster: | ||
trick.ram: | ||
alloc: Allocator's Ploy | ||
free: Concierge's Ploy | ||
read: Retrieval Ingress | ||
write: Ploy of Caching |
51 changes: 51 additions & 0 deletions
51
src/main/resources/assets/trickster/lavender/entries/tome_of_tomfoolery/ram.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
```json | ||
{ | ||
"title": "Random Access Mind", | ||
"icon": "minecraft:barrel", | ||
"category": "trickster:basics" | ||
} | ||
``` | ||
|
||
The Random Access Mind, or RAM for short, | ||
is a way of storing arbitrary semi-persistent data alongside other unrelated arbitrary data, | ||
through the use of an allocation system. | ||
|
||
;;;;; | ||
|
||
<|glyph@trickster:templates|trick-id=ram:alloc,title=Allocator's Ploy|> | ||
|
||
-> number | ||
|
||
--- | ||
|
||
Attempts to allocate a RAM slot, blundering if there are none free. Returns the address of the allocated slot. | ||
|
||
;;;;; | ||
|
||
<|glyph@trickster:templates|trick-id=ram:free,title=Concierge's Ploy|> | ||
|
||
number -> | ||
|
||
--- | ||
|
||
Frees the RAM slot at the given address, permitting later re-allocation. | ||
|
||
;;;;; | ||
|
||
<|glyph@trickster:templates|trick-id=ram:read,title=Retrieval Ingress|> | ||
|
||
number -> any | ||
|
||
--- | ||
|
||
Returns the fragment stored within the RAM slot at the given address. | ||
|
||
;;;;; | ||
|
||
<|glyph@trickster:templates|trick-id=ram:write,title=Ploy of Caching|> | ||
|
||
number, any -> | ||
|
||
--- | ||
|
||
Stores the given fragment in the RAM slot at the given address, overwriting what was there previously. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters