Skip to content

Commit 0acd73f

Browse files
committed
A whole lot was done
Summon One Way Portal is about done Summon Two Way Portal is about done Added an Icon removed Congrats Removed Signum Added Summon One Way Portal Great Spell And more idk Updated mod version from 0.0.1 to 0.1.0 Things to do: Make Portal manipulation spells Make Summon Looking Glass Fix falling into the floor after going through a portal And more idk
1 parent 9c3aa7e commit 0acd73f

File tree

13 files changed

+238
-197
lines changed

13 files changed

+238
-197
lines changed

Common/src/main/java/net/portalhexaddon/casting/patterns/math/OpSignum.kt

Lines changed: 0 additions & 98 deletions
This file was deleted.

Common/src/main/java/net/portalhexaddon/casting/patterns/spells/OpCongrats.kt

Lines changed: 0 additions & 66 deletions
This file was deleted.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package net.portalhexaddon.casting.patterns.spells
2+
3+
import at.petrak.hexcasting.api.misc.MediaConstants
4+
import at.petrak.hexcasting.api.spell.*
5+
import at.petrak.hexcasting.api.spell.casting.CastingContext
6+
import at.petrak.hexcasting.api.spell.iota.Iota
7+
import com.mojang.math.Vector3f
8+
import net.minecraft.world.phys.Vec3
9+
import net.portalhexaddon.portals.MakePortalNgon
10+
import qouteall.imm_ptl.core.api.PortalAPI
11+
import qouteall.imm_ptl.core.portal.Portal
12+
13+
class OpOneWayPortal : SpellAction {
14+
override val argc: Int = 4
15+
/**
16+
* The method called when this Action is actually executed. Accepts the [args]
17+
* that were on the stack (there will be [argc] of them), and the [ctx],
18+
* which contains things like references to the caster, the ServerLevel,
19+
* methods to determine whether locations and entities are in ambit, etc.
20+
* Returns the list of iotas that should be added back to the stack as the
21+
* result of this action executing.
22+
*/
23+
override fun execute(args: List<Iota>, ctx: CastingContext): Triple<RenderedSpell, Int, List<ParticleSpray>> {
24+
val PrtPos: Vec3 = args.getVec3(0,argc)
25+
val PrtPosOut: Vec3 = args.getVec3(1,argc)
26+
val PrtRot: Vec3 = args.getVec3(2,argc)
27+
val PrtSize: Double = args.getDoubleBetween(3,1.0/10.0,10.0,argc)
28+
29+
val cost = (16 * MediaConstants.CRYSTAL_UNIT * PrtSize).toInt()
30+
31+
val PrtPos3f = Vector3f(PrtPos.x.toFloat(), PrtPos.y.toFloat(), PrtPos.z.toFloat())
32+
33+
ctx.assertVecInRange(PrtPos)
34+
ctx.assertVecInRange(PrtPosOut)
35+
36+
return Triple(
37+
Spell(PrtPos3f,PrtPosOut,PrtRot,PrtSize),
38+
cost,
39+
listOf(ParticleSpray.burst(ctx.caster.position(), 1.0))
40+
)
41+
42+
}
43+
44+
private data class Spell(val PrtPos: Vector3f, val PrtPosOut: Vec3, val PrtRot: Vec3, val PrtSize: Double) : RenderedSpell {
45+
override fun cast(ctx: CastingContext) {
46+
val level = ctx.world
47+
val portal: Portal? = Portal.entityType.create(level)
48+
var PrtRotCors: Vec3 = PrtRot.cross(Vec3(0.0, 1.0, 0.0))
49+
var PrtRotCorsCors = Vec3(0.0,0.0,0.0)
50+
51+
if (1.0 == PrtRot.y) {
52+
PrtRotCors = Vec3(0.0,0.0,1.0)
53+
PrtRotCorsCors = Vec3(1.0,0.0,0.0)
54+
} else if (-1.0 == PrtRot.y) {
55+
PrtRotCors = Vec3(1.0,0.0,0.0)
56+
PrtRotCorsCors = Vec3(0.0,0.0,-1.0)
57+
} else {
58+
PrtRotCorsCors = PrtRotCors.cross(PrtRot)
59+
}
60+
61+
portal!!.originPos = Vec3(PrtPos)
62+
portal.setDestinationDimension(ctx.world.dimension())
63+
portal.setDestination(PrtPosOut)
64+
portal.setOrientationAndSize(
65+
PrtRotCors,
66+
PrtRotCorsCors,
67+
PrtSize,
68+
PrtSize
69+
)
70+
MakePortalNgon.makePortalNGon(portal,6)
71+
72+
val portal2 = PortalAPI.createFlippedPortal(portal)
73+
74+
portal.level.addFreshEntity(portal2)
75+
portal.level.addFreshEntity(portal)
76+
}
77+
}
78+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package net.portalhexaddon.casting.patterns.spells
2+
3+
import at.petrak.hexcasting.api.misc.MediaConstants
4+
import at.petrak.hexcasting.api.spell.*
5+
import at.petrak.hexcasting.api.spell.casting.CastingContext
6+
import at.petrak.hexcasting.api.spell.iota.Iota
7+
import com.mojang.math.Vector3f
8+
import net.minecraft.world.phys.Vec3
9+
import net.portalhexaddon.portals.MakePortalNgon
10+
import qouteall.imm_ptl.core.api.PortalAPI
11+
import qouteall.imm_ptl.core.portal.Portal
12+
import qouteall.imm_ptl.core.portal.PortalManipulation
13+
import qouteall.imm_ptl.core.portal.PortalManipulation.createFlippedPortal
14+
15+
class OpTwoWayPortal : SpellAction {
16+
/**
17+
* The number of arguments from the stack that this action requires.
18+
*/
19+
override val argc: Int = 4
20+
val cost = 64 * MediaConstants.CRYSTAL_UNIT
21+
22+
/**
23+
* The method called when this Action is actually executed. Accepts the [args]
24+
* that were on the stack (there will be [argc] of them), and the [ctx],
25+
* which contains things like references to the caster, the ServerLevel,
26+
* methods to determine whether locations and entities are in ambit, etc.
27+
* Returns a triple of things. The [RenderedSpell] is responsible for the spell actually
28+
* doing things in the world, the [Int] is how much media the spell should cost,
29+
* and the [List] of [ParticleSpray] renders particle effects for the result of the SpellAction.
30+
*
31+
* The [execute] method should only contain code to find the targets of the spell and validate
32+
* them. All the code that actually makes changes to the world (breaking blocks, teleporting things,
33+
* etc.) should be in the private [Spell] data class below.
34+
*/
35+
override fun execute(args: List<Iota>, ctx: CastingContext): Triple<RenderedSpell, Int, List<ParticleSpray>> {
36+
val PrtPos: Vec3 = args.getVec3(0,argc)
37+
val PrtPosOut: Vec3 = args.getVec3(1,argc)
38+
val PrtRot: Vec3 = args.getVec3(2,argc)
39+
val PrtSize: Double = args.getDoubleBetween(3,1.0/10.0,10.0,argc)
40+
41+
val PrtPos3f = Vector3f(PrtPos.x.toFloat(), PrtPos.y.toFloat(), PrtPos.z.toFloat())
42+
43+
ctx.assertVecInRange(PrtPos)
44+
ctx.assertVecInRange(PrtPosOut)
45+
46+
return Triple(
47+
Spell(PrtPos3f,PrtPosOut,PrtRot,PrtSize),
48+
0,
49+
listOf(ParticleSpray.burst(ctx.caster.position(), 1.0))
50+
)
51+
52+
}
53+
54+
private data class Spell(val PrtPos: Vector3f, val PrtPosOut: Vec3, val PrtRot: Vec3, val PrtSize: Double) : RenderedSpell {
55+
override fun cast(ctx: CastingContext) {
56+
val level = ctx.world
57+
val portal: Portal? = Portal.entityType.create(level)
58+
var PrtRotCors: Vec3 = PrtRot.cross(Vec3(0.0, 1.0, 0.0))
59+
var PrtRotCorsCors = Vec3(0.0,0.0,0.0)
60+
61+
if (1.0 == PrtRot.y) {
62+
PrtRotCors = Vec3(0.0,0.0,1.0)
63+
PrtRotCorsCors = Vec3(1.0,0.0,0.0)
64+
} else if (-1.0 == PrtRot.y) {
65+
PrtRotCors = Vec3(1.0,0.0,0.0)
66+
PrtRotCorsCors = Vec3(0.0,0.0,-1.0)
67+
} else {
68+
PrtRotCorsCors = PrtRotCors.cross(PrtRot)
69+
}
70+
71+
portal!!.originPos = Vec3(PrtPos)
72+
portal.setDestinationDimension(ctx.world.dimension())
73+
portal.setDestination(PrtPosOut)
74+
portal.setOrientationAndSize(
75+
PrtRotCors,
76+
PrtRotCorsCors,
77+
PrtSize,
78+
PrtSize
79+
)
80+
MakePortalNgon.makePortalNGon(portal,6)
81+
82+
val portal2 = PortalAPI.createReversePortal(portal) //Reverse makes a portal at the output
83+
val portal3 = PortalAPI.createFlippedPortal(portal) //Flip rotates the portal
84+
val portal4 = PortalAPI.createFlippedPortal(portal2)
85+
86+
portal.level.addFreshEntity(portal)
87+
portal.level.addFreshEntity(portal2)
88+
portal.level.addFreshEntity(portal3)
89+
portal.level.addFreshEntity(portal4)
90+
}
91+
}
92+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package net.portalhexaddon.items;
2+
3+
4+
public class HexStaffs {
5+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package net.portalhexaddon.portals
2+
3+
import qouteall.imm_ptl.core.portal.GeometryPortalShape
4+
import qouteall.imm_ptl.core.portal.Portal
5+
import java.util.stream.Collectors
6+
import java.util.stream.IntStream
7+
import kotlin.math.cos
8+
import kotlin.math.sin
9+
10+
class MakePortalNgon {
11+
companion object {
12+
fun makePortalNGon(portal: Portal, sides: Int) { //GOTTEN FROM IMEMRSIVE PORTALS PortalCommand
13+
val shape = GeometryPortalShape()
14+
val triangleNum = sides
15+
val twoPi = Math.PI * 2
16+
shape.triangles = IntStream.range(0, triangleNum)
17+
.mapToObj { i: Int ->
18+
GeometryPortalShape.TriangleInPlane(
19+
0.0, 0.0,
20+
portal.width * 0.5 * cos(twoPi * (i.toDouble()) / triangleNum),
21+
portal.height * 0.5 * sin(twoPi * (i.toDouble()) / triangleNum),
22+
portal.width * 0.5 * cos(twoPi * (i.toDouble() + 1) / triangleNum),
23+
portal.height * 0.5 * sin(twoPi * (i.toDouble() + 1) / triangleNum)
24+
)
25+
}.collect(Collectors.toList())
26+
portal.specialShape = shape
27+
portal.cullableXStart = 0.0
28+
portal.cullableXEnd = 0.0
29+
portal.cullableYStart = 0.0
30+
portal.cullableYEnd = 0.0
31+
}
32+
}}

0 commit comments

Comments
 (0)