diff --git a/CHANGELOG.md b/CHANGELOG.md index e740ddb..6ea3d17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,3 @@ -- Updated to Trickster 2.0.0-beta.1 +- Updated to Trickster 2.0.0-beta.7 +- Removed cells as Trickster will have inter-spell communication in a future update of the core mod +- Updated to libstellar 2.0.1 due to badly declared dependencies diff --git a/README.md b/README.md index 287560a..1740930 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ A simple add-on for [Trickster](https://github.com/enjarai/trickster) that imple In addition to Trickster, this mod depends on [libstellar](https://github.com/StellarWitch7/libstellar), my personal Kotlin library for making Fabric mods. # Other additions -Versions 2.0.0 and up include more than just RAM, providing other fun things such as world-space fragment storage and a handful of tricks for dealing with the unmentioned *pattern* fragments. \ No newline at end of file +Versions 2.0.0 and up include more than just RAM, providing a handful of tricks for dealing with pattern fragments. diff --git a/build.gradle b/build.gradle index aaa2b59..6bbce3e 100644 --- a/build.gradle +++ b/build.gradle @@ -158,7 +158,7 @@ publishMods { displayName = "Random Access Mind ${property('mod_version')} for Trickster ${property('deps.trickster')}" version = project.version changelog = getRootProject().file("CHANGELOG.md").text - type = ALPHA + type = STABLE modLoaders.add("fabric") def min = property('publish_target_min') diff --git a/gradle.properties b/gradle.properties index d2ea6ba..4017fed 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G org.gradle.parallel=true # Mod Properties -mod_version=2.0.0-alpha.4 +mod_version=2.0.0 maven_group=stellarwitch7 archives_base_name=ram @@ -23,6 +23,6 @@ deps.scala=3.1.3 # Dependencies deps.fabric-api=0.100.1+1.21 -deps.libstellar=2.0.0 -deps.trickster=2.0.0-beta.1 +deps.libstellar=2.0.1 +deps.trickster=2.0.0-beta.7 deps.modmenu=11.0.1 diff --git a/src/main/java/stellarwitch7/ram/spell/fragment/CellFragment.java b/src/main/java/stellarwitch7/ram/spell/fragment/CellFragment.java deleted file mode 100644 index 773357f..0000000 --- a/src/main/java/stellarwitch7/ram/spell/fragment/CellFragment.java +++ /dev/null @@ -1,50 +0,0 @@ -package stellarwitch7.ram.spell.fragment; - -import java.util.UUID; - -import dev.enjarai.trickster.EndecTomfoolery; -import stellarwitch7.ram.cca.world.ModWorldComponents$; -import dev.enjarai.trickster.spell.Fragment; -import dev.enjarai.trickster.spell.fragment.BooleanFragment; -import dev.enjarai.trickster.spell.fragment.FragmentType; -import dev.enjarai.trickster.spell.trick.Trick; -import io.wispforest.endec.StructEndec; -import io.wispforest.endec.impl.StructEndecBuilder; -import stellarwitch7.ram.spell.fragment.ModFragmentTypes$; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.text.Text; - -public record CellFragment(UUID uuid) implements Fragment { - public static final StructEndec ENDEC = StructEndecBuilder.of( - EndecTomfoolery.UUID.fieldOf("uuid", CellFragment::uuid), - CellFragment::new - ); - - @Override - public FragmentType type() { - return ModFragmentTypes$.MODULE$.CELL(); - } - - @Override - public Text asText() { - return Text.literal(uuid.toString()); - } - - @Override - public boolean asBoolean() { - return true; - } - - @Override - public int getWeight() { - return 32; - } - - public Fragment get(Trick source, ServerWorld world) { - return ModWorldComponents$.MODULE$.CELLS().get(world).readCell(source, uuid); - } - - public void set(Trick source, ServerWorld world, Fragment value) { - ModWorldComponents$.MODULE$.CELLS().get(world).writeCell(source, uuid, value); - } -} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 4bb847b..5b430d9 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -39,18 +39,11 @@ "value": "stellarwitch7.ram.cca.block.ModBlockComponents", "adapter": "kotori_scala" } - ], - "cardinal-components-world": [ - { - "value": "stellarwitch7.ram.cca.world.ModWorldComponents", - "adapter": "kotori_scala" - } ] }, "custom": { "cardinal-components": [ - "ram:ram", - "ram:cells" + "ram:ram" ] }, "mixins": [ @@ -66,8 +59,8 @@ "java": ">=21", "fabric-api": "*", "kotori_scala": "*", - "libstellar": ">=1.1.8", - "trickster": ">=2.0.0-beta.1" + "libstellar": ">=2.0.1", + "trickster": ">=2.0.0-beta.7" }, "suggests": { } diff --git a/src/main/scala/stellarwitch7/ram/RandomAccessMind.scala b/src/main/scala/stellarwitch7/ram/RandomAccessMind.scala index 9298ba3..78f61d1 100644 --- a/src/main/scala/stellarwitch7/ram/RandomAccessMind.scala +++ b/src/main/scala/stellarwitch7/ram/RandomAccessMind.scala @@ -17,6 +17,5 @@ object RandomAccessMind extends ModInitializer { LOGGER.info("SIGSEGV") ModTricks.register() - ModFragmentTypes.register() } } diff --git a/src/main/scala/stellarwitch7/ram/cca/world/CellsComponent.scala b/src/main/scala/stellarwitch7/ram/cca/world/CellsComponent.scala deleted file mode 100644 index 7b7a909..0000000 --- a/src/main/scala/stellarwitch7/ram/cca/world/CellsComponent.scala +++ /dev/null @@ -1,67 +0,0 @@ -package stellarwitch7.ram.cca.world - -import dev.enjarai.trickster.EndecTomfoolery -import dev.enjarai.trickster.spell.Fragment -import dev.enjarai.trickster.spell.fragment.VoidFragment -import dev.enjarai.trickster.spell.trick.Trick -import io.wispforest.endec.Endec -import io.wispforest.endec.StructEndec -import io.wispforest.endec.impl.KeyedEndec -import io.wispforest.endec.impl.StructEndecBuilder -import net.minecraft.nbt.NbtCompound -import net.minecraft.registry.RegistryWrapper -import net.minecraft.world.World -import org.ladysnake.cca.api.v3.component.Component -import stellarwitch7.ram.spell.fragment.CellFragment -import stellarwitch7.ram.spell.blunder.CellNotWithinWorldBlunder -import stellarwitch7.ram.spell.blunder.ImmutableCellBlunder -import scala.collection.mutable.HashMap -import java.util.UUID -import scala.collection.JavaConverters._ - -class CellsComponent(private val world: World) extends Component { - private val cells: HashMap[UUID, Cell] = HashMap() - - override def readFromNbt(tag: NbtCompound, registryLookup: RegistryWrapper.WrapperLookup): Unit = - cells.addAll(tag.get(CellsComponent.endec).asScala) - - override def writeToNbt(tag: NbtCompound, registryLookup: RegistryWrapper.WrapperLookup): Unit = - tag.put(CellsComponent.endec, cells.asJava) - - def acquireCell(): CellFragment = { - var uuid = UUID.randomUUID() - - while (cells.contains(uuid)) { - uuid = UUID.randomUUID() - } - - cells.put(uuid, Cell(false, VoidFragment.INSTANCE)) - CellFragment(uuid) - } - - def writeCell(source: Trick, uuid: UUID, value: Fragment): Unit = - cells.get(uuid).map(cell => - if cell.locked then - throw ImmutableCellBlunder(source) - else - cell.locked = true - cell.value = value - ).getOrElse(throw CellNotWithinWorldBlunder(source)) - - def readCell(source: Trick, uuid: UUID): Fragment = - cells.get(uuid).map(_.value).getOrElse(throw CellNotWithinWorldBlunder(source)) -} - -object CellsComponent { - val endec: KeyedEndec[java.util.Map[UUID, Cell]] = KeyedEndec("cells", Endec.map(EndecTomfoolery.UUID, Cell.endec), new java.util.HashMap()) -} - -private class Cell(var locked: Boolean, var value: Fragment) { } - -private object Cell { - val endec: StructEndec[Cell] = StructEndecBuilder.of( - Endec.BOOLEAN.fieldOf("locked", _.locked), - Fragment.ENDEC.fieldOf("value", _.value), - new Cell(_, _) - ) -} diff --git a/src/main/scala/stellarwitch7/ram/cca/world/ModWorldComponents.scala b/src/main/scala/stellarwitch7/ram/cca/world/ModWorldComponents.scala deleted file mode 100644 index e36b627..0000000 --- a/src/main/scala/stellarwitch7/ram/cca/world/ModWorldComponents.scala +++ /dev/null @@ -1,11 +0,0 @@ -package stellarwitch7.ram.cca.world - -import org.ladysnake.cca.api.v3.component.ComponentKey -import stellarwitch7.libstellar.registry.cca.world.CCAWorldComponentRegistrar -import stellarwitch7.ram.RandomAccessMind - -object ModWorldComponents extends CCAWorldComponentRegistrar() { - override val modID: String = RandomAccessMind.MOD_ID - - val CELLS: ComponentKey[CellsComponent] = register("cells", classOf[CellsComponent], CellsComponent(_), None) -} diff --git a/src/main/scala/stellarwitch7/ram/spell/blunder/CellNotWithinWorldBlunder.scala b/src/main/scala/stellarwitch7/ram/spell/blunder/CellNotWithinWorldBlunder.scala deleted file mode 100644 index df69cf8..0000000 --- a/src/main/scala/stellarwitch7/ram/spell/blunder/CellNotWithinWorldBlunder.scala +++ /dev/null @@ -1,10 +0,0 @@ -package stellarwitch7.ram.spell.blunder - -import dev.enjarai.trickster.spell.trick.Trick -import dev.enjarai.trickster.spell.blunder.TrickBlunderException -import net.minecraft.text.MutableText - -class CellNotWithinWorldBlunder(source: Trick) extends TrickBlunderException(source) { - override def createMessage(): MutableText = - super.createMessage().append("Cell cannot be accessed as it does not exist") -} diff --git a/src/main/scala/stellarwitch7/ram/spell/blunder/ImmutableCellBlunder.scala b/src/main/scala/stellarwitch7/ram/spell/blunder/ImmutableCellBlunder.scala deleted file mode 100644 index 07ffc43..0000000 --- a/src/main/scala/stellarwitch7/ram/spell/blunder/ImmutableCellBlunder.scala +++ /dev/null @@ -1,10 +0,0 @@ -package stellarwitch7.ram.spell.blunder - -import dev.enjarai.trickster.spell.trick.Trick -import dev.enjarai.trickster.spell.blunder.TrickBlunderException -import net.minecraft.text.MutableText - -class ImmutableCellBlunder(source: Trick) extends TrickBlunderException(source) { - override def createMessage(): MutableText = - super.createMessage().append("Cannot write to cell as it has already been written to") -} diff --git a/src/main/scala/stellarwitch7/ram/spell/fragment/ModFragmentTypes.scala b/src/main/scala/stellarwitch7/ram/spell/fragment/ModFragmentTypes.scala deleted file mode 100644 index 1f171ac..0000000 --- a/src/main/scala/stellarwitch7/ram/spell/fragment/ModFragmentTypes.scala +++ /dev/null @@ -1,14 +0,0 @@ -package stellarwitch7.ram.spell.fragment - -import dev.enjarai.trickster.spell.fragment.FragmentType -import net.minecraft.registry.Registry -import stellarwitch7.libstellar.registry.Registrar -import stellarwitch7.ram.RandomAccessMind -import java.util.* - -object ModFragmentTypes extends Registrar[FragmentType[?]] { - override val modID: String = RandomAccessMind.MOD_ID - override val registry: Registry[FragmentType[?]] = FragmentType.REGISTRY - - val CELL: FragmentType[CellFragment] = register("cell", FragmentType(CellFragment.ENDEC, OptionalInt.empty())) -} diff --git a/src/main/scala/stellarwitch7/ram/spell/trick/ModTricks.scala b/src/main/scala/stellarwitch7/ram/spell/trick/ModTricks.scala index 7a4cc79..c182f67 100644 --- a/src/main/scala/stellarwitch7/ram/spell/trick/ModTricks.scala +++ b/src/main/scala/stellarwitch7/ram/spell/trick/ModTricks.scala @@ -24,9 +24,4 @@ object ModTricks extends Registrar[Trick] { val PATTERN_FROM_INT = register("pattern_from_int", PatternFromIntTrick()) val PATTERN_FROM_INT_LIST = register("pattern_from_int_list", PatternFromIntListTrick()) val GLYPH_FROM_SPELL_PART = register("glyph_from_spell_part", GlyphFromSpellPartTrick()) - - // cell - val ACQUIRE_CELL = register("acquire_cell", AcquireCellTrick()) - val READ_CELL = register("read_cell", ReadCellTrick()) - val WRITE_CELL = register("write_cell", WriteCellTrick()) } diff --git a/src/main/scala/stellarwitch7/ram/spell/trick/cell/AcquireCellTrick.scala b/src/main/scala/stellarwitch7/ram/spell/trick/cell/AcquireCellTrick.scala deleted file mode 100644 index 19d0e41..0000000 --- a/src/main/scala/stellarwitch7/ram/spell/trick/cell/AcquireCellTrick.scala +++ /dev/null @@ -1,12 +0,0 @@ -package stellarwitch7.ram.spell.trick.cell - -import dev.enjarai.trickster.spell.Fragment -import dev.enjarai.trickster.spell.Pattern -import dev.enjarai.trickster.spell.SpellContext -import dev.enjarai.trickster.spell.trick.Trick -import stellarwitch7.ram.cca.world.ModWorldComponents - -class AcquireCellTrick extends Trick(Pattern.of(4, 6, 0, 4, 5)) { - override def activate(ctx: SpellContext, fragments: java.util.List[Fragment]): Fragment = - ModWorldComponents.CELLS.get(ctx.source.getWorld()).acquireCell() -} diff --git a/src/main/scala/stellarwitch7/ram/spell/trick/cell/ReadCellTrick.scala b/src/main/scala/stellarwitch7/ram/spell/trick/cell/ReadCellTrick.scala deleted file mode 100644 index 11c03f6..0000000 --- a/src/main/scala/stellarwitch7/ram/spell/trick/cell/ReadCellTrick.scala +++ /dev/null @@ -1,14 +0,0 @@ -package stellarwitch7.ram.spell.trick.cell - -import dev.enjarai.trickster.spell.Fragment -import dev.enjarai.trickster.spell.Pattern -import dev.enjarai.trickster.spell.SpellContext -import dev.enjarai.trickster.spell.trick.Trick -import stellarwitch7.ram.cca.world.ModWorldComponents -import stellarwitch7.ram.spell.fragment.ModFragmentTypes -import scala.collection.JavaConverters._ - -class ReadCellTrick extends Trick(Pattern.of(4, 6, 0, 4, 2)) { - override def activate(ctx: SpellContext, fragments: java.util.List[Fragment]): Fragment = - expectInput(fragments, ModFragmentTypes.CELL, 0).get(this, ctx.source.getWorld()) -} diff --git a/src/main/scala/stellarwitch7/ram/spell/trick/cell/WriteCellTrick.scala b/src/main/scala/stellarwitch7/ram/spell/trick/cell/WriteCellTrick.scala deleted file mode 100644 index 2911b97..0000000 --- a/src/main/scala/stellarwitch7/ram/spell/trick/cell/WriteCellTrick.scala +++ /dev/null @@ -1,18 +0,0 @@ -package stellarwitch7.ram.spell.trick.cell - -import dev.enjarai.trickster.spell.Fragment -import dev.enjarai.trickster.spell.Pattern -import dev.enjarai.trickster.spell.SpellContext -import dev.enjarai.trickster.spell.trick.Trick -import stellarwitch7.ram.spell.fragment.ModFragmentTypes -import scala.collection.JavaConverters._ - -class WriteCellTrick extends Trick(Pattern.of(4, 6, 0, 4, 8)) { - override def activate(ctx: SpellContext, fragments: java.util.List[Fragment]): Fragment = { - val cell = expectInput(fragments, ModFragmentTypes.CELL, 0) - val value = expectInput(fragments, 1) - cell.set(this, ctx.source.getWorld(), value.applyEphemeral()) - - cell - } -}