Skip to content

Commit d073dfa

Browse files
committed
Added CastingEnvironment#getCasterPosition and its implementations
1 parent 7202ed7 commit d073dfa

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

Common/src/main/java/at/petrak/hexcasting/api/casting/eval/CastingEnvironment.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ public ServerPlayer getCaster() {
128128
@Nullable
129129
public abstract LivingEntity getCastingEntity();
130130

131+
/**
132+
* Gets the caster's position. Useful for compatibility.
133+
*
134+
* @return the position of the caster
135+
*/
136+
public abstract Vec3 getCastingPosition();
137+
131138
/**
132139
* Get an interface used to do mishaps
133140
*/

Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/CircleCastEnv.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public CircleCastEnv(ServerLevel world, CircleExecutionState execState) {
4848
return this.execState.getCaster(this.world);
4949
}
5050

51+
@Override
52+
public Vec3 getCastingPosition() {
53+
return this.getImpetus() == null ? this.execState.impetusPos.getCenter() : this.getImpetus().getBlockPos().getCenter();
54+
}
55+
5156
public @Nullable BlockEntityAbstractImpetus getImpetus() {
5257
var entity = this.world.getBlockEntity(execState.impetusPos);
5358

Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/PlayerBasedCastEnv.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ public ServerPlayer getCaster() {
6262
return this.caster;
6363
}
6464

65+
@Override
66+
public Vec3 getCastingPosition() {
67+
return this.caster.position();
68+
}
69+
6570
@Override
6671
public void postExecution(CastResult result) {
6772
super.postExecution(result);

0 commit comments

Comments
 (0)