Skip to content

Commit

Permalink
Conjure Hexxy advancement
Browse files Browse the repository at this point in the history
  • Loading branch information
miyucomics committed Aug 25, 2024
1 parent 72825c1 commit 9100d11
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 4 deletions.
21 changes: 21 additions & 0 deletions src/main/java/miyucomics/hexical/advancements/HexxyCriterion.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package miyucomics.hexical.advancements

import com.google.gson.JsonObject
import miyucomics.hexical.HexicalMain
import net.minecraft.advancement.criterion.AbstractCriterion
import net.minecraft.advancement.criterion.AbstractCriterionConditions
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer
import net.minecraft.predicate.entity.EntityPredicate
import net.minecraft.server.network.ServerPlayerEntity
import net.minecraft.util.Identifier

class HexxyCriterion : AbstractCriterion<HexxyCriterion.Condition>() {
override fun conditionsFromJson(obj: JsonObject, playerPredicate: EntityPredicate.Extended, predicateDeserializer: AdvancementEntityPredicateDeserializer) = Condition()
fun trigger(player: ServerPlayerEntity) = trigger(player) { true }
override fun getId() = ID

class Condition : AbstractCriterionConditions(ID, EntityPredicate.Extended.EMPTY)
companion object {
val ID: Identifier = HexicalMain.id("summon_hexxy")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getVec3
import at.petrak.hexcasting.api.spell.iota.EntityIota
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.iota.PatternIota
import at.petrak.hexcasting.api.spell.math.HexDir
import at.petrak.hexcasting.api.spell.math.HexPattern
import at.petrak.hexcasting.xplat.IXplatAbstractions
import miyucomics.hexical.entities.SpeckEntity
import miyucomics.hexical.registry.HexicalAdvancements
Expand All @@ -16,17 +19,20 @@ class OpConjureSpeck : ConstMediaAction {
override val mediaCost: Int = MediaConstants.DUST_UNIT / 100
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val iota = args[0]
if (iota is PatternIota && iota.pattern == HexPattern.fromAngles("deaqq", HexDir.SOUTH_EAST))
HexicalAdvancements.HEXXY.trigger(ctx.caster)

val position = args.getVec3(1, argc)
val rotation = args.getVec3(2, argc)
ctx.assertVecInRange(position)

val speck = SpeckEntity(ctx.world)
speck.setPosition(position.subtract(0.0, speck.standingEyeHeight.toDouble(), 0.0))
speck.lookAt(EntityAnchorArgumentType.EntityAnchor.FEET, speck.pos.add(rotation))
speck.setIota(iota)
speck.setPigment(IXplatAbstractions.INSTANCE.getColorizer(ctx.caster))
speck.setSize(1f)
speck.setThickness(1f)
speck.setIota(iota)
ctx.world.spawnEntity(speck)

HexicalAdvancements.AR.trigger(ctx.caster)
return listOf(EntityIota(speck))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import net.minecraft.advancement.criterion.Criteria

object HexicalAdvancements {
lateinit var AR: ARCriterion
lateinit var HEXXY: HexxyCriterion
lateinit var DIY: DIYCriterion
lateinit var HALLUCINATE: HallucinateCriterion
lateinit var EDUCATE_GENIE: EducateGenieCriterion
Expand All @@ -14,6 +15,7 @@ object HexicalAdvancements {
@JvmStatic
fun init() {
AR = Criteria.register(ARCriterion())
HEXXY = Criteria.register(HexxyCriterion())
DIY = Criteria.register(DIYCriterion())
HALLUCINATE = Criteria.register(HallucinateCriterion())
EDUCATE_GENIE = Criteria.register(EducateGenieCriterion())
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/assets/hexical/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"advancements.hexical.augmented_reality.description": "Conjure a speck.",
"advancements.hexical.diy_conjuring.title": "DIY Conjuring!",
"advancements.hexical.diy_conjuring.description": "Add a custom modifier to a mage block.",
"advancements.hexical.conjure_hexxy.title": "Conjure Hexxy",
"advancements.hexical.conjure_hexxy.description": "Give Hexxy a physical form in your world.",
"advancements.hexical.hallucinate.title": "Only In My Head",
"advancements.hexical.hallucinate.description": "Play a sound only you can hear!",
"advancements.hexical.media_slurp.title": "Tripping",
Expand Down Expand Up @@ -607,4 +609,4 @@
"hexical.page.get_biome.summary": "Pushes the identifier of the biome type that the vector is within.",
"hexcasting.spell.hexical:get_dimension": "Plane Reflection",
"hexical.page.get_dimension.summary": "Pushes the identifier of the dimension the _Hex is being cast in."
}
}
24 changes: 24 additions & 0 deletions src/main/resources/data/hexical/advancements/conjure_hexxy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"parent": "hexcasting:root",
"criteria": {
"hexxy": {
"trigger": "hexical:summon_hexxy"
}
},
"display": {
"announce_to_chat": true,
"title": {
"translate": "advancements.hexical.conjure_hexxy.title"
},
"description": {
"translate": "advancements.hexical.conjure_hexxy.description"
},
"frame": "challenge",
"hidden": true,
"icon": {
"item": "hexcasting:lens"
},
"show_toast": true
},
"requirements": [["hexxy"]]
}

0 comments on commit 9100d11

Please sign in to comment.