-
Notifications
You must be signed in to change notification settings - Fork 5
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
3de1feb
commit 8f91c3e
Showing
28 changed files
with
222 additions
and
85 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
common/src/main/java/miyucomics/hexical/casting/mishaps/GrimoireAccessDeniedMishap.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,21 @@ | ||
package miyucomics.hexical.casting.mishaps | ||
|
||
import at.petrak.hexcasting.api.misc.FrozenColorizer | ||
import at.petrak.hexcasting.api.spell.ParticleSpray | ||
import at.petrak.hexcasting.api.spell.casting.CastingContext | ||
import at.petrak.hexcasting.api.spell.iota.Iota | ||
import at.petrak.hexcasting.api.spell.mishaps.Mishap | ||
import miyucomics.hexical.Hexical | ||
import net.minecraft.text.Text | ||
import net.minecraft.util.DyeColor | ||
import net.minecraft.util.Hand | ||
|
||
class GrimoireAccessDeniedMishap : Mishap() { | ||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = dyeColor(DyeColor.BLUE) | ||
override fun particleSpray(ctx: CastingContext) = ParticleSpray.burst(ctx.caster.pos, 1.0) | ||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Text = error(Hexical.MOD_ID + ":grimoire_access_denied") | ||
|
||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<Iota>) { | ||
yeetHeldItem(ctx, Hand.OFF_HAND) | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...ing/patterns/operators/eval/OpNephthys.kt → ...ical/casting/operators/eval/OpNephthys.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
2 changes: 1 addition & 1 deletion
2
...tterns/spells/grimoire/OpGrimoireErase.kt → ...ing/operators/grimoire/OpGrimoireErase.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
15 changes: 15 additions & 0 deletions
15
common/src/main/java/miyucomics/hexical/casting/operators/grimoire/OpGrimoireIndex.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 miyucomics.hexical.casting.operators.grimoire | ||
|
||
import at.petrak.hexcasting.api.spell.* | ||
import at.petrak.hexcasting.api.spell.casting.CastingContext | ||
import at.petrak.hexcasting.api.spell.iota.Iota | ||
import at.petrak.hexcasting.api.spell.iota.ListIota | ||
import miyucomics.hexical.items.GrimoireItem | ||
|
||
class OpGrimoireIndex : ConstMediaAction { | ||
override val argc = 0 | ||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> { | ||
val (stack, _) = ctx.getHeldItemToOperateOn { it.item is GrimoireItem } | ||
return listOf(ListIota(GrimoireItem.getPatternsInGrimoire(stack))) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
common/src/main/java/miyucomics/hexical/casting/operators/grimoire/OpGrimoireQuery.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,18 @@ | ||
package miyucomics.hexical.casting.operators.grimoire | ||
|
||
import at.petrak.hexcasting.api.spell.* | ||
import at.petrak.hexcasting.api.spell.casting.CastingContext | ||
import at.petrak.hexcasting.api.spell.iota.DoubleIota | ||
import at.petrak.hexcasting.api.spell.iota.Iota | ||
import at.petrak.hexcasting.api.spell.iota.ListIota | ||
import at.petrak.hexcasting.api.spell.iota.NullIota | ||
import miyucomics.hexical.items.GrimoireItem | ||
|
||
class OpGrimoireQuery : ConstMediaAction { | ||
override val argc = 1 | ||
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> { | ||
val (stack, _) = ctx.getHeldItemToOperateOn { it.item is GrimoireItem } | ||
val uses = GrimoireItem.getUses(stack, args.getPattern(0, argc)) ?: return listOf(NullIota()) | ||
return listOf(DoubleIota(uses.toDouble())) | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
common/src/main/java/miyucomics/hexical/casting/operators/grimoire/OpGrimoireRestrict.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,29 @@ | ||
package miyucomics.hexical.casting.operators.grimoire | ||
|
||
import at.petrak.hexcasting.api.spell.* | ||
import at.petrak.hexcasting.api.spell.casting.CastingContext | ||
import at.petrak.hexcasting.api.spell.iota.Iota | ||
import at.petrak.hexcasting.api.spell.math.HexPattern | ||
import miyucomics.hexical.casting.mishaps.GrimoireAccessDeniedMishap | ||
import miyucomics.hexical.items.GrimoireItem | ||
import net.minecraft.item.ItemStack | ||
|
||
class OpGrimoireRestrict : SpellAction { | ||
override val argc = 2 | ||
|
||
override fun execute(args: List<Iota>, ctx: CastingContext): Triple<RenderedSpell, Int, List<ParticleSpray>> { | ||
val pattern = args.getPattern(0, argc) | ||
val uses = args.getPositiveInt(1, argc) | ||
val (stack, _) = ctx.getHeldItemToOperateOn { it.item is GrimoireItem } | ||
val currentUses = GrimoireItem.getUses(stack, pattern) ?: return Triple(Spell(pattern, stack, uses), 0, listOf()) | ||
if (uses > currentUses) | ||
throw GrimoireAccessDeniedMishap() | ||
return Triple(Spell(pattern, stack, uses), 0, listOf()) | ||
} | ||
|
||
private data class Spell(val pattern: HexPattern, val stack: ItemStack, val uses: Int) : RenderedSpell { | ||
override fun cast(ctx: CastingContext) { | ||
GrimoireItem.restrict(stack, pattern, uses) | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...tterns/spells/grimoire/OpGrimoireWrite.kt → ...ing/operators/grimoire/OpGrimoireWrite.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
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
2 changes: 1 addition & 1 deletion
2
.../casting/patterns/spells/OpChorusBlink.kt → ...s/hexical/casting/spells/OpChorusBlink.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
2 changes: 1 addition & 1 deletion
2
...ing/patterns/spells/OpConjureMageBlock.kt → ...ical/casting/spells/OpConjureMageBlock.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
2 changes: 1 addition & 1 deletion
2
...casting/patterns/spells/OpConjureSpeck.kt → .../hexical/casting/spells/OpConjureSpeck.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
2 changes: 1 addition & 1 deletion
2
...casting/patterns/spells/OpConjureStaff.kt → .../hexical/casting/spells/OpConjureStaff.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
2 changes: 1 addition & 1 deletion
2
...ting/patterns/spells/OpModifyMageBlock.kt → ...xical/casting/spells/OpModifyMageBlock.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
2 changes: 1 addition & 1 deletion
2
.../casting/patterns/spells/OpProgramLamp.kt → ...ical/casting/spells/lamp/OpProgramLamp.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
2 changes: 1 addition & 1 deletion
2
...g/patterns/spells/OpSetArchLampStorage.kt → ...sting/spells/lamp/OpSetArchLampStorage.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
2 changes: 1 addition & 1 deletion
2
...ng/patterns/spells/OpTerminateArchLamp.kt → ...asting/spells/lamp/OpTerminateArchLamp.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
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
36 changes: 31 additions & 5 deletions
36
common/src/main/java/miyucomics/hexical/entities/SpeckEntityRenderer.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,33 +1,59 @@ | ||
package miyucomics.hexical.entities | ||
|
||
import at.petrak.hexcasting.client.* | ||
import at.petrak.hexcasting.client.drawLineSeq | ||
import at.petrak.hexcasting.client.findDupIndices | ||
import at.petrak.hexcasting.client.makeZappy | ||
import com.mojang.blaze3d.systems.RenderSystem | ||
import net.minecraft.client.render.* | ||
import net.minecraft.client.render.GameRenderer | ||
import net.minecraft.client.render.VertexConsumerProvider | ||
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 | ||
import net.minecraft.util.math.Quaternion | ||
import net.minecraft.util.math.Vec2f | ||
import net.minecraft.util.math.Vec3d | ||
import net.minecraft.util.math.Vec3f | ||
import kotlin.math.asin | ||
import kotlin.math.atan2 | ||
|
||
|
||
class SpeckEntityRenderer(ctx: EntityRendererFactory.Context?) : EntityRenderer<SpeckEntity?>(ctx) { | ||
override fun render(entity: SpeckEntity?, yaw: Float, tickDelta: Float, matrices: MatrixStack?, vertexConsumers: VertexConsumerProvider?, light: Int) { | ||
val oldShader = RenderSystem.getShader() | ||
RenderSystem.setShader(GameRenderer::getPositionColorShader) | ||
RenderSystem.enableDepthTest() | ||
matrices!!.push() | ||
|
||
val size = 0.25f | ||
val pattern = entity!!.getPattern() | ||
val lines = pattern.toLines(size, pattern.getCenter(size).negate()).toMutableList() | ||
for (i in lines.indices) | ||
lines[i] = Vec2f(lines[i].x, -lines[i].y) | ||
val zappy = makeZappy(lines, findDupIndices(pattern.positions()), 10, 1.5f, 0.1f, 0.2f, 0f, 1f, hashCode().toDouble()) | ||
val outer = -0x9b3701 | ||
val outer = entity.getPigment().getColor(entity.age.toFloat(), entity.pos) | ||
|
||
val mat = matrices.peek() | ||
drawLineSeq(mat.positionMatrix, zappy, 0.05f, 0.01f, outer, outer) | ||
val rotation = Vec3f.NEGATIVE_Y.getRadialQuaternion(entity.yaw) | ||
rotation.hamiltonProduct(Vec3f.POSITIVE_X.getRadialQuaternion((entity.pitch - Math.PI / 2).toFloat())) | ||
matrices.multiply(rotation) | ||
drawLineSeq(matrices.peek().positionMatrix, zappy, 0.05f, 0.01f, outer, outer) | ||
matrices.pop() | ||
RenderSystem.setShader { oldShader } | ||
} | ||
|
||
fun getQuaternion(direction: Vec3d, forward: Boolean): Quaternion { | ||
var copiedVector = direction | ||
copiedVector = copiedVector.normalize() | ||
val pitch = asin(-copiedVector.y).toFloat() | ||
val yaw = (-atan2(copiedVector.x, copiedVector.z)).toFloat() | ||
val rotation = Vec3f.NEGATIVE_Y.getRadialQuaternion(yaw) | ||
if (forward) { | ||
rotation.hamiltonProduct(Vec3f.POSITIVE_X.getRadialQuaternion((pitch + Math.PI / 2).toFloat())) | ||
} else { | ||
rotation.hamiltonProduct(Vec3f.POSITIVE_X.getRadialQuaternion((pitch - Math.PI / 2).toFloat())) | ||
} | ||
return rotation | ||
} | ||
|
||
override fun getTexture(entity: SpeckEntity?): Identifier? { return null } | ||
} |
Oops, something went wrong.