-
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
ab1a31b
commit 031519b
Showing
9 changed files
with
96 additions
and
28 deletions.
There are no files selected for viewing
50 changes: 28 additions & 22 deletions
50
src/main/java/miyucomics/hexical/casting/patterns/OpReweave.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,39 +1,45 @@ | ||
package miyucomics.hexical.casting.patterns | ||
|
||
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.* | ||
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.Vec3Iota | ||
import at.petrak.hexcasting.api.spell.mishaps.MishapBadEntity | ||
import at.petrak.hexcasting.api.spell.mishaps.MishapInvalidIota | ||
import at.petrak.hexcasting.api.spell.mishaps.MishapLocationTooFarAway | ||
import miyucomics.hexical.entities.MeshEntity | ||
import net.minecraft.util.math.MathHelper | ||
import net.minecraft.util.math.Vec2f | ||
import net.minecraft.util.math.Vec3d | ||
|
||
class OpReweave : SpellAction { | ||
override val argc = 1 | ||
override val argc = 2 | ||
override fun execute(args: List<Iota>, ctx: CastingContext): Triple<RenderedSpell, Int, List<ParticleSpray>> { | ||
val headOffset = args.getVec3(0, argc) | ||
val xAxis = ctx.caster.rotationVector | ||
val upPitch = (-ctx.caster.pitch + 90) * (Math.PI.toFloat() / 180) | ||
val yaw = -ctx.caster.headYaw * (Math.PI.toFloat() / 180) | ||
val h = MathHelper.cos(yaw).toDouble() | ||
val j = MathHelper.cos(upPitch).toDouble() | ||
val yAxis = Vec3d(MathHelper.sin(yaw).toDouble() * j, MathHelper.sin(upPitch).toDouble(), h * j) | ||
val zAxis = xAxis.crossProduct(yAxis).normalize() | ||
val offset = Vec3d.ZERO | ||
.add(xAxis.multiply(headOffset.x)) | ||
.add(yAxis.multiply(headOffset.y)) | ||
.add(zAxis.multiply(headOffset.z)) | ||
if (offset.length() > 128) | ||
throw MishapLocationTooFarAway(ctx.caster.eyePos.add(offset)) | ||
return Triple(Spell(ctx.caster.eyePos.add(offset)), MediaConstants.SHARD_UNIT * 2, listOf()) | ||
val mesh = args.getEntity(0, argc) | ||
if (mesh !is MeshEntity) | ||
throw MishapBadEntity.of(mesh, "mesh") | ||
|
||
val design = args.getList(1, argc) | ||
if (design.size() > 32) | ||
throw MishapInvalidIota.of(args[1], 1, "mesh_vector_list") | ||
val shape = mutableListOf<Vec3d>() | ||
for (point in design) { | ||
if (point.type != Vec3Iota.TYPE) | ||
throw MishapInvalidIota.of(args[1], 1, "mesh_vector_list") | ||
else { | ||
val vector = (point as Vec3Iota).vec3 | ||
if (vector.length() > 32) | ||
throw MishapInvalidIota.of(args[1], 1, "mesh_vector_list") | ||
shape.add(vector) | ||
} | ||
} | ||
return Triple(Spell(mesh, shape), MediaConstants.DUST_UNIT, listOf()) | ||
} | ||
|
||
private data class Spell(val position: Vec3d) : RenderedSpell { | ||
private data class Spell(val mesh: MeshEntity, val shape: List<Vec3d>) : RenderedSpell { | ||
override fun cast(ctx: CastingContext) { | ||
ctx.caster.teleport(position.x, position.y, position.z) | ||
mesh.setShape(shape) | ||
} | ||
} | ||
} |
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
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
16 changes: 16 additions & 0 deletions
16
src/main/resources/assets/hexical/shaders/post/night_vision.json
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,16 @@ | ||
{ | ||
"targets": [ | ||
"swap" | ||
], | ||
"passes": [ | ||
{ | ||
"name": "hexical:night_vision", | ||
"intarget": "minecraft:main", | ||
"outtarget": "swap" | ||
}, { | ||
"name": "blit", | ||
"intarget": "swap", | ||
"outtarget": "minecraft:main" | ||
} | ||
] | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/resources/assets/hexical/shaders/program/night_vision.fsh
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,13 @@ | ||
#version 150 | ||
|
||
uniform sampler2D DiffuseSampler; | ||
|
||
in vec2 texCoord; | ||
out vec4 fragColor; | ||
|
||
void main() { | ||
vec3 color = texture(DiffuseSampler, texCoord).rgb; | ||
color *= 3.; | ||
color = mix(vec3(dot(color, vec3(.5))), color, .5); | ||
fragColor = vec4(color, 1.0); | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/resources/assets/hexical/shaders/program/night_vision.json
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,28 @@ | ||
{ | ||
"blend": { | ||
"func": "add", | ||
"srcrgb": "srcalpha", | ||
"dstrgb": "1-srcalpha" | ||
}, | ||
"vertex": "sobel", | ||
"fragment": "hexical:night_vision", | ||
"attributes": ["Position"], | ||
"samplers": [ | ||
{ | ||
"name": "DiffuseSampler" | ||
} | ||
], | ||
"uniforms": [ | ||
{ | ||
"name": "ProjMat", | ||
"type": "matrix4x4", | ||
"count": 16, | ||
"values": [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0] | ||
}, { | ||
"name": "OutSize", | ||
"type": "float", | ||
"count": 2, | ||
"values": [1.0, 1.0] | ||
} | ||
] | ||
} |