Compare commits

...

No commits in common. "1.0.0" and "main" have entirely different histories.
1.0.0 ... main

8 changed files with 13 additions and 114 deletions

View File

@ -11,7 +11,6 @@ import at.petrak.hexcasting.common.casting.operators.selectors.*
import net.minecraft.resources.ResourceLocation import net.minecraft.resources.ResourceLocation
import net.touhoudiscord.hexucasting.api.HexucastingAPI.modLoc import net.touhoudiscord.hexucasting.api.HexucastingAPI.modLoc
import net.touhoudiscord.hexucasting.common.casting.actions.spells.OpDaylightAction import net.touhoudiscord.hexucasting.common.casting.actions.spells.OpDaylightAction
import net.touhoudiscord.hexucasting.common.casting.actions.spells.OpStarlightAction
object Patterns { object Patterns {
@ -40,8 +39,6 @@ object Patterns {
@JvmField @JvmField
val DAYLIGHT = make(HexPattern.fromAngles("wewewewewewaaweedeewedeewedeewedeewedeee", HexDir.EAST), modLoc("spells/daylight"), OpDaylightAction, true) val DAYLIGHT = make(HexPattern.fromAngles("wewewewewewaaweedeewedeewedeewedeewedeee", HexDir.EAST), modLoc("spells/daylight"), OpDaylightAction, true)
@JvmField
val STARLIGHT = make(HexPattern.fromAngles("wwwwwdwewwwewaqaeewaqddqaweeaqwadqwwqda", HexDir.EAST), modLoc("spells/starlight"), OpStarlightAction, true)
private fun make (pattern: HexPattern, location: ResourceLocation, operator: Action, isPerWorld: Boolean = false): PatternIota { private fun make (pattern: HexPattern, location: ResourceLocation, operator: Action, isPerWorld: Boolean = false): PatternIota {
val triple = Triple(pattern, location, operator) val triple = Triple(pattern, location, operator)

View File

@ -1,11 +1,8 @@
package net.touhoudiscord.hexucasting.common.casting.actions.spells package net.touhoudiscord.hexucasting.common.casting.actions.spells
import at.petrak.hexcasting.api.misc.MediaConstants import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.*
import at.petrak.hexcasting.api.spell.RenderedSpell
import at.petrak.hexcasting.api.spell.SpellAction
import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getVec3
import at.petrak.hexcasting.api.spell.iota.Iota import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.xplat.IXplatAbstractions import at.petrak.hexcasting.xplat.IXplatAbstractions
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
@ -18,7 +15,7 @@ object OpDaylightAction : SpellAction {
/** /**
* The number of arguments from the stack that this action requires. * The number of arguments from the stack that this action requires.
*/ */
override val argc = 0 override val argc = 1
/** /**
* The method called when this Action is actually executed. Accepts the [args] * The method called when this Action is actually executed. Accepts the [args]
@ -34,8 +31,10 @@ object OpDaylightAction : SpellAction {
* etc.) should be in the private [Spell] data class below. * etc.) should be in the private [Spell] data class below.
*/ */
override fun execute(args: List<Iota>, ctx: CastingContext): Triple<RenderedSpell, Int, List<ParticleSpray>> { override fun execute(args: List<Iota>, ctx: CastingContext): Triple<RenderedSpell, Int, List<ParticleSpray>> {
val time = minOf(args.getPositiveInt(0, argc), 24000)
return Triple( return Triple(
Spell(), Spell(time),
MediaConstants.CRYSTAL_UNIT*2, MediaConstants.CRYSTAL_UNIT*2,
listOf() listOf()
) )
@ -46,14 +45,14 @@ object OpDaylightAction : SpellAction {
* define where/what it should affect (for this example the parameter is [vec]), and the * define where/what it should affect (for this example the parameter is [vec]), and the
* [cast] method within is responsible for using that data to alter the world. * [cast] method within is responsible for using that data to alter the world.
*/ */
private data class Spell(val thisisgivingmeanerrorifidontputsomethinghere: Int = 0) : RenderedSpell { private data class Spell(val time: Int) : RenderedSpell {
override fun cast(ctx: CastingContext) { override fun cast(ctx: CastingContext) {
val w = ctx.world val w = ctx.world
val relativeTime = w.dayTime%24000 val relativeTime = w.dayTime%24000
if (relativeTime > 23459) { if (relativeTime > time) {
w.dayTime += 24000 w.dayTime += 24000
} }
w.dayTime = w.dayTime-relativeTime+23459 w.dayTime = w.dayTime-relativeTime+time
} }
} }
} }

View File

@ -1,59 +0,0 @@
package net.touhoudiscord.hexucasting.common.casting.actions.spells
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.spell.ParticleSpray
import at.petrak.hexcasting.api.spell.RenderedSpell
import at.petrak.hexcasting.api.spell.SpellAction
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getVec3
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.xplat.IXplatAbstractions
import net.minecraft.core.BlockPos
import net.minecraft.world.level.block.Blocks
import net.minecraft.world.phys.Vec3
import net.touhoudiscord.hexucasting.api.config.HexucastingConfig
import net.touhoudiscord.hexucasting.common.casting.actions.OpExampleConstMediaAction.argc
object OpStarlightAction : SpellAction {
/**
* The number of arguments from the stack that this action requires.
*/
override val argc = 0
/**
* The method called when this Action is actually executed. Accepts the [args]
* that were on the stack (there will be [argc] of them), and the [ctx],
* which contains things like references to the caster, the ServerLevel,
* methods to determine whether locations and entities are in ambit, etc.
* Returns a triple of things. The [RenderedSpell] is responsible for the spell actually
* doing things in the world, the [Int] is how much media the spell should cost,
* and the [List] of [ParticleSpray] renders particle effects for the result of the SpellAction.
*
* The [execute] method should only contain code to find the targets of the spell and validate
* them. All the code that actually makes changes to the world (breaking blocks, teleporting things,
* etc.) should be in the private [Spell] data class below.
*/
override fun execute(args: List<Iota>, ctx: CastingContext): Triple<RenderedSpell, Int, List<ParticleSpray>> {
return Triple(
Spell(),
MediaConstants.CRYSTAL_UNIT,
listOf()
)
}
/**
* This class is responsible for actually making changes to the world. It accepts parameters to
* define where/what it should affect (for this example the parameter is [vec]), and the
* [cast] method within is responsible for using that data to alter the world.
*/
private data class Spell(val thisisgivingmeanerrorifidontputsomethinghere: Int = 0) : RenderedSpell {
override fun cast(ctx: CastingContext) {
val w = ctx.world
val relativeTime = w.dayTime%24000
if (relativeTime > 12542) {
w.dayTime += 24000
}
w.dayTime = w.dayTime-relativeTime+12542
}
}
}

View File

@ -6,8 +6,7 @@
"hexcasting.spell.book.hexucasting:spells/starlight": "Starlight", "hexcasting.spell.book.hexucasting:spells/starlight": "Starlight",
"hexucasting.entry.daytime_manip": "Daytime Manipulation", "hexucasting.entry.daytime_manip": "Daytime Manipulation",
"hexucasting.page.daytime_manip.spells/daylight": "This spell will cast time forward to day in the world I cast it upon. Costs two $(l:items/amethyst)$(item)Charged Amethyst/$", "hexucasting.page.daytime_manip.spells/daylight": "This spell will cast time forward to the relative time given in ticks in the world I cast it upon. Costs two $(l:items/amethyst)$(item)Charged Amethyst/$",
"hexucasting.page.daytime_manip.spells/starlight": "This spell will cast time forward to night in the world I cast it upon. Costs two $(l:items/amethyst)$(item)Charged Amethyst/$",
"_comment": "Config Entries", "_comment": "Config Entries",
"text.autoconfig.hexucasting.title": "Your Mod Configs", "text.autoconfig.hexucasting.title": "Your Mod Configs",

View File

@ -10,17 +10,9 @@
"type": "hexcasting:pattern", "type": "hexcasting:pattern",
"op_id": "hexucasting:spells/daylight", "op_id": "hexucasting:spells/daylight",
"anchor": "hexucasting:spells/daylight", "anchor": "hexucasting:spells/daylight",
"input": "", "input": "number",
"output": "", "output": "",
"text": "hexucasting.page.daytime_manip.spells/daylight" "text": "hexucasting.page.daytime_manip.spells/daylight"
},
{
"type": "hexcasting:pattern",
"op_id": "hexucasting:spells/starlight",
"anchor": "hexucasting:spells/starlight",
"input": "",
"output": "",
"text": "hexucasting.page.daytime_manip.spells/starlight"
} }
] ]
} }

View File

@ -1,30 +1 @@
# Empty Hex Casting Addon Framework # Hexucasting
This is a stripped-down template for 1.92.2 Fabric+Forge Hex Casting addons. It's heavily derived (aka, taken wholesale) from [HexCasting](https://www.curseforge.com/minecraft/mc-mods/hexcasting)'s excellent project layout, and was created by stripping everything from [Hexal](https://modrinth.com/mod/hexal)'s repository that wasn't relevant.
This has all the dependencies _necessary_ for functioning as an addon, as well as the dependencies and code for a config system that will work for both forge and fabric. There is an example Action, and an example Spell, and you can look at the existing HexCasting or Hexal code to see how actual Actions and Spells are written.
The approach here does not actually avoid the various complexities of cross-modloader programming. You still need to very carefully maintain functions that are distinct between the two environments. It's just a very well-designed approach for separating these fields, without having to duplicate a lot of work.
There will be some follow-up work to turn it from a generic "Hello World" mod into _your_ Generic "Hello World" mod. Some keywords to look at:
``yourmod.name.here`` is the default package name. While valid for test purposes, you _will_ need to change this before release (and ideally immediately after forking) or risk (near-certain) collisions and annoying bugs, and it's easier the earlier you change it.
IntelliJ (and most other IDEAs) will allow bulk refactoring, though expect to need to change a few ``package`` settings at the top of files.
See [this page](https://docs.oracle.com/javase/specs/jls/se6/html/packages.html#7.7) for information about package naming rules, particularly _don't use a popular TLD that you don't actually own or control_.
``yourmod`` is the default modID. _AFTER_ you've refactored your package name, this is the next thing to change. It's only referenced in a few places, but other mods, compile-time behavior (both Forge and Fabric) and maven will interact with it heavily.
See [this page](https://maven.apache.org/guides/mini/guide-naming-conventions.html) for some naming conventions specific to this ID.
After you've made these changes, it's safe to leave ``YourAPI`` and ``YourConfig`` as their current names, but do feel free to rename them; something specific to your modId or your package will make regularly importing them less obnoxious.
``Your Mod`` is the default mod name. This is more for aesthetics than code relevance, but it does show up in a good few places and it's kinda embarrassing if it's left at default.
Check your ``mods.toml`` (for Forge) and ``fabric.mod.json`` (for Fabric) regarding other mod-specific settings, such as author, icon, dependencies you want presented to the user, so on. There's a lot I'm not going to summarize here.
Actually Running:
Once you've made those updates, you'll need to reload Gradle. Do it a couple of times, for safety's sake.
The automatically generated Run configurations won't work. Sorry. You'll need to use Gradle->Fabric>Tasks->Fabric->run* or Gradle->Forge->Tasks->forgegradle runs->run*. There's probably a way to fix this, but good luck.

View File

@ -10,7 +10,7 @@ jetbrainsAnnotationsVersion=23.0.0
minecraftVersion=1.19.2 minecraftVersion=1.19.2
kotlinVersion=1.7.20 kotlinVersion=1.7.20
modVersion=1.0.0 modVersion=1.1.0
paucalVersion=0.5.0 paucalVersion=0.5.0
hexcastingVersion=0.10.3 hexcastingVersion=0.10.3

View File

@ -16,5 +16,5 @@ pluginManagement {
} }
} }
rootProject.name = 'EmptyHexCastingAddon' rootProject.name = 'Hexucasting'
include("Common", "Fabric", "Forge") include("Common", "Fabric", "Forge")