Skip to content

Commit

Permalink
Added mirror sprite
Browse files Browse the repository at this point in the history
  • Loading branch information
miyucomics committed Jul 7, 2024
1 parent 71ca625 commit a3ef463
Show file tree
Hide file tree
Showing 16 changed files with 157 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.mishaps.MishapInvalidIota
import miyucomics.hexical.casting.iota.getIdentifier
import net.minecraft.util.registry.Registry

class OpGetFoodData(private val mode: Int) : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val stack = args.getItemStack(0, argc)
if (!stack.isFood)
val id = args.getIdentifier(0, argc)
if (!Registry.ITEM.containsId(id))
throw MishapInvalidIota.of(args[0], 0, "food")
val foodComponent = stack.item.foodComponent!!
val food = Registry.ITEM.get(id).foodComponent?: throw MishapInvalidIota.of(args[0], 0, "food")
return when (mode) {
0 -> foodComponent.hunger.asActionResult
1 -> foodComponent.saturationModifier.asActionResult
2 -> foodComponent.isMeat.asActionResult
3 -> foodComponent.isSnack.asActionResult
0 -> food.hunger.asActionResult
1 -> food.saturationModifier.asActionResult
2 -> food.isMeat.asActionResult
3 -> food.isSnack.asActionResult
else -> throw IllegalStateException()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class OpGetStatusEffectInstanceData(private val mode: Int) : ConstMediaAction {
val instance = entity.getStatusEffect(Registry.STATUS_EFFECT.get(effect)) ?: return listOf(NullIota())
return when (mode) {
0 -> instance.amplifier.asActionResult
1 -> instance.duration.asActionResult
1 -> (instance.duration / 20).asActionResult
else -> throw IllegalStateException()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ class LivingScrollEntity(entityType: EntityType<LivingScrollEntity?>?, world: Wo
this.dataTracker.set(renderDataTracker, patterns[((world.time / 20).toInt() % patterns.size)])
}

override fun writeCustomDataToNbt(nbt: NbtCompound?) {
nbt!!.putByte("direction", facing.id.toByte())
override fun writeCustomDataToNbt(nbt: NbtCompound) {
nbt.putInt("direction", facing.id)
nbt.putBoolean("aged", this.dataTracker.get(agedDataTracker))
nbt.putInt("size", this.dataTracker.get(sizeDataTracker))

Expand All @@ -118,8 +118,8 @@ class LivingScrollEntity(entityType: EntityType<LivingScrollEntity?>?, world: Wo
super.writeCustomDataToNbt(nbt)
}

override fun readCustomDataFromNbt(nbt: NbtCompound?) {
this.facing = Direction.byId(nbt!!.getByte("direction").toInt())
override fun readCustomDataFromNbt(nbt: NbtCompound) {
this.facing = Direction.byId(nbt.getInt("direction"))
this.dataTracker.set(agedDataTracker, nbt.getBoolean("aged"))
this.dataTracker.set(sizeDataTracker, nbt.getInt("size"))
setFacing(this.facing)
Expand Down
38 changes: 38 additions & 0 deletions src/main/java/miyucomics/hexical/entities/SpikeEntity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package miyucomics.hexical.entities

import net.minecraft.entity.Entity
import net.minecraft.entity.EntityType
import net.minecraft.entity.data.DataTracker
import net.minecraft.entity.data.TrackedData
import net.minecraft.entity.data.TrackedDataHandlerRegistry
import net.minecraft.nbt.NbtCompound
import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket
import net.minecraft.util.math.Direction
import net.minecraft.world.World

class SpikeEntity(entityType: EntityType<SpikeEntity?>?, world: World?) : Entity(entityType, world) {
private var direction: Direction = Direction.UP
companion object {
}

fun setDirection() {
if (this.direction.axis.isHorizontal) {
this.pitch = 0.0f
this.yaw = (this.direction.horizontal * 90).toFloat()
} else {
this.pitch = (-90 * this.direction.direction.offset()).toFloat()
this.yaw = 0.0f
}
}

override fun initDataTracker() {
}

override fun readCustomDataFromNbt(nbt: NbtCompound) {
}

override fun writeCustomDataToNbt(nbt: NbtCompound) {
}

override fun createSpawnPacket() = EntitySpawnS2CPacket(this)
}
15 changes: 15 additions & 0 deletions src/main/java/miyucomics/hexical/entities/SpikeRenderer.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package miyucomics.hexical.entities

import net.minecraft.client.render.*
import net.minecraft.client.render.entity.EntityRenderer
import net.minecraft.client.render.entity.EntityRendererFactory
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.util.Identifier

class SpikeRenderer(ctx: EntityRendererFactory.Context?) : EntityRenderer<SpikeEntity?>(ctx) {
override fun getTexture(spike: SpikeEntity?) = Identifier("textures/block/amethyst_cluster.png")
override fun render(spike: SpikeEntity?, yaw: Float, deltaTick: Float, matrices: MatrixStack, vertexConsumers: VertexConsumerProvider, light: Int) {
matrices.push()
matrices.pop()
}
}
3 changes: 3 additions & 0 deletions src/main/java/miyucomics/hexical/registry/HexicalEntities.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@ object HexicalEntities {
val MAGIC_MISSILE_ENTITY: EntityType<MagicMissileEntity?> = EntityType.Builder.create(::MagicMissileEntity, SpawnGroup.MISC).setDimensions(0.5f, 0.5f).maxTrackingRange(4).trackingTickInterval(20).build(HexicalMain.MOD_ID + ":magic_missile")
val LIVING_SCROLL_ENTITY: EntityType<LivingScrollEntity?> = EntityType.Builder.create(::LivingScrollEntity, SpawnGroup.MISC).setDimensions(0.5f, 0.5f).maxTrackingRange(10).trackingTickInterval(1).build(HexicalMain.MOD_ID + ":living_scroll")
val SPECK_ENTITY: EntityType<SpeckEntity?> = EntityType.Builder.create(::SpeckEntity, SpawnGroup.MISC).setDimensions(0.5f, 0.5f).maxTrackingRange(10).trackingTickInterval(1).build(HexicalMain.MOD_ID + ":speck")
val SPIKE_ENTITY: EntityType<SpikeEntity?> = EntityType.Builder.create(::SpikeEntity, SpawnGroup.MISC).setDimensions(0.5f, 0.5f).maxTrackingRange(10).trackingTickInterval(1).build(HexicalMain.MOD_ID + ":spike")

@JvmStatic
fun init() {
Registry.register(Registry.ENTITY_TYPE, HexicalMain.id("living_scroll"), LIVING_SCROLL_ENTITY)
Registry.register(Registry.ENTITY_TYPE, HexicalMain.id("magic_missile"), MAGIC_MISSILE_ENTITY)
Registry.register(Registry.ENTITY_TYPE, HexicalMain.id("speck"), SPECK_ENTITY)
Registry.register(Registry.ENTITY_TYPE, HexicalMain.id("spike"), SPIKE_ENTITY)
}

@JvmStatic
fun clientInit() {
EntityRendererRegistry.register(LIVING_SCROLL_ENTITY) { ctx: EntityRendererFactory.Context? -> LivingScrollRenderer(ctx) }
EntityRendererRegistry.register(MAGIC_MISSILE_ENTITY) { ctx: EntityRendererFactory.Context? -> MagicMissileRenderer(ctx) }
EntityRendererRegistry.register(SPECK_ENTITY) { ctx: EntityRendererFactory.Context? -> SpeckRenderer(ctx) }
EntityRendererRegistry.register(SPIKE_ENTITY) { ctx: EntityRendererFactory.Context? -> SpikeRenderer(ctx) }
}
}
30 changes: 16 additions & 14 deletions src/main/resources/assets/hexical/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
{
"advancements.hexical.arch_lamp.title": "Phenomenal Cosmic Powers!",
"advancements.hexical.arch_lamp.title": "Itty Bitty Living Space",
"advancements.hexical.arch_lamp.description": "Acquire an archgenie lamp.",
"advancements.hexical.augmented_reality.title": "Augmented Reality",
"advancements.hexical.augmented_reality.description": "Conjure a speck.",
"advancements.hexical.broken_mind.title": "Out with the Old...",
"advancements.hexical.broken_mind.description": "Use up a lamp's media.",
"advancements.hexical.diy_conjuring.title": "DIY Conjuring!",
"advancements.hexical.diy_conjuring.description": "Add a custom modifier to a mage block.",
"advancements.hexical.reload_lamp.title": "Phenomenal Cosmic Powers!",
"advancements.hexical.reload_lamp.description": "Reload the lamp.",
"advancements.hexical.educate_genie.title": "New Order",
"advancements.hexical.educate_genie.description": "Educate the genie with new instructions.",
"advancements.hexical.hallucinate.title": "Only in my Head",
"advancements.hexical.hallucinate.description": "Play a sound only you can hear!",
"advancements.hexical.lamp.title": "Diamond in the Rough",
"advancements.hexical.lamp.description": "Acquire a genie lamp.",
"advancements.hexical.reload_lamp.title": "In with the New!",
"advancements.hexical.reload_lamp.description": "Reload the lamp.",
"advancements.hexical.augmented_reality.title": "Augmented Reality",
"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.hallucinate.title": "Only in my Head",
"advancements.hexical.hallucinate.description": "Play a sound only you can hear!",
"advancements.hexical.media_slurp.title": "Rose-Tinted Glasses",
"advancements.hexical.media_slurp.description": "Augment your vision after drinking pure media.",

"block.hexical.hex_candle": "Hex Candle",
"block.hexical.mage_block": "Mage Block",
Expand Down Expand Up @@ -425,13 +427,13 @@
"hexcasting.spell.hexical:edible": "Edibility Purification",
"hexical.page.edible.summary": "Takes in an item entity and pushes whether you can eat it.",
"hexcasting.spell.hexical:get_hunger": "Calorie Purification",
"hexical.page.get_hunger.summary": "Takes in an item entity and pushes the amount it will fill you.",
"hexical.page.get_hunger.summary": "Takes in an item identifier and pushes the amount it will fill you.",
"hexcasting.spell.hexical:get_saturation": "Satiation Purification",
"hexical.page.get_saturation.summary": "Takes in an item entity and pushes the saturation value, which roughly affects how long it will fill you.",
"hexical.page.get_saturation.summary": "Takes in an item identifier and pushes the saturation value, which roughly affects how long it will fill you.",
"hexcasting.spell.hexical:is_meat": "Flesh Purification",
"hexical.page.is_meat.summary": "Takes in an item entity and pushes whether it's considered a meat (whether wolves can eat it).",
"hexical.page.is_meat.summary": "Takes in an item identifier and pushes whether it's considered a meat (wolves can eat it).",
"hexcasting.spell.hexical:is_snack": "Dessert Purification",
"hexical.page.is_snack.summary": "Takes in an item entity and pushes whether it's a snack (you can eat it really quickly).",
"hexical.page.is_snack.summary": "Takes in an item identifier and pushes whether it's a snack (you can eat it really quickly).",

"hexical.page.identifiers.title": "Identifiers",
"hexical.page.identifiers.0": "My _Hexes has so far been quite blind to the world. I can get a creature's height, velocity, and more but I can't directly identify that entity. Nature's solution to the problem is the $(o)identifier iota$(). Every entity, block, status effect, enchantment, sound, etc... has a unique identifier that my _Hexes can identify. Once I have two identifiers, I can compare them with each other.",
Expand Down Expand Up @@ -469,7 +471,7 @@

"hexical.page.world.title": "World",
"hexcasting.spell.hexical:get_light": "Luminance Purification",
"hexical.page.get_light.summary": "Pushes the light level at the position. If inside a nontransparent block, it returns zero.",
"hexical.page.get_light.summary": "Pushes the light level at the position as a number 0 to 15. If inside a nontransparent block, it returns zero.",
"hexcasting.spell.hexical:get_weather": "Meterologist's Reflection",
"hexical.page.get_weather.summary": "Pushes a number corresponding to the weather. 0 for clear, 1 for rain, and 2 for thundering.",
"hexcasting.spell.hexical:get_time": "Temporal Reflection",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"parent": "minecraft:item/handheld_rod",
"textures": {
"layer0": "hexical:item/conjured_staff"
"layer0": "hexical:item/conjured_staff_staff"
},
"overrides": [
{
Expand All @@ -21,6 +21,12 @@
"sprite": 0.3
},
"model": "hexical:item/conjured_staff_key"
},
{
"predicate": {
"sprite": 0.4
},
"model": "hexical:item/conjured_staff_mirror"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "hexical:item/conjured_staff_mirror"
}
}
48 changes: 12 additions & 36 deletions src/main/resources/assets/hexical/player_animation/casting.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,14 @@
"bones": {
"right_arm": {
"rotation": {
"0.0": {
"vector": [-180, 0, -10]
},
"0.125": {
"vector": [0, 0, 0]
}
"0.0": { "vector": [-180, 0, -10] },
"0.125": { "vector": [0, 0, 0] }
}
},
"left_arm": {
"rotation": {
"0.0": {
"vector": [-180, 0, 10]
},
"0.125": {
"vector": [0, 0, 0]
}
"0.0": { "vector": [-180, 0, 10] },
"0.125": { "vector": [0, 0, 0] }
}
}
}
Expand All @@ -32,34 +24,18 @@
"bones": {
"right_arm": {
"rotation": {
"0.0": {
"vector": [-180, 0, -30]
},
"0.1": {
"vector": [-150, 0, -30]
},
"0.3": {
"vector": [-210, 0, -30]
},
"0.4": {
"vector": [-180, 0, -30]
}
"0.0": { "vector": [-180, 0, -30] },
"0.1": { "vector": [-150, 0, -30] },
"0.3": { "vector": [-210, 0, -30] },
"0.4": { "vector": [-180, 0, -30] }
}
},
"left_arm": {
"rotation": {
"0.0": {
"vector": [-180, 0, 30]
},
"0.1": {
"vector": [-150, 0, 30]
},
"0.3": {
"vector": [-210, 0, 30]
},
"0.4": {
"vector": [-180, 0, 30]
}
"0.0": { "vector": [-180, 0, 30] },
"0.1": { "vector": [-150, 0, 30] },
"0.3": { "vector": [-210, 0, 30] },
"0.4": { "vector": [-180, 0, 30] }
}
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"parent": "hexcasting:root",
"criteria": {
"sip": {
"trigger": "minecraft:item_used_on_block",
"conditions": {
"location": {
"block": {
"blocks": [
"hexical:media_jar"
]
}
}
}
}
},
"display": {
"announce_to_chat": true,
"title": {
"translate": "advancements.hexical.media_slurp.title"
},
"description": {
"translate": "advancements.hexical.media_slurp.description"
},
"frame": "task",
"hidden": true,
"icon": {
"item": "hexical:media_jar"
},
"show_toast": true
},
"requirements": [["sip"]]
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@
"type": "hexcasting:pattern",
"op_id": "hexical:get_hunger",
"anchor": "hexical:get_hunger",
"input": "item entity",
"output": "number",
"input": "identifier",
"output": "number",
"text": "hexical.page.get_hunger.summary"
},
{
"type": "hexcasting:pattern",
"op_id": "hexical:get_saturation",
"anchor": "hexical:get_saturation",
"input": "item entity",
"input": "identifier",
"output": "number",
"text": "hexical.page.get_saturation.summary"
},
{
"type": "hexcasting:pattern",
"op_id": "hexical:is_meat",
"anchor": "hexical:is_meat",
"input": "item entity",
"input": "identifier",
"output": "boolean",
"text": "hexical.page.is_meat.summary"
},
{
"type": "hexcasting:pattern",
"op_id": "hexical:is_snack",
"anchor": "hexical:is_snack",
"input": "item entity",
"input": "identifier",
"output": "boolean",
"text": "hexical.page.is_snack.summary"
}
Expand Down
Loading

0 comments on commit a3ef463

Please sign in to comment.