asdf tried to get things working but there's a lot broken!
This commit is contained in:
parent
34f769a895
commit
72efd81285
11 changed files with 48 additions and 20 deletions
|
@ -25,6 +25,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package at.petrak.hexcasting.api.casting.eval.env;
|
||||
|
||||
import at.petrak.hexcasting.api.casting.ParticleSpray;
|
||||
import at.petrak.hexcasting.api.casting.circles.BlockEntityAbstractImpetus;
|
||||
import at.petrak.hexcasting.api.casting.eval.CastResult;
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment;
|
||||
import at.petrak.hexcasting.api.casting.eval.MishapEnvironment;
|
||||
|
@ -12,6 +13,7 @@ import net.minecraft.server.level.ServerLevel;
|
|||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -32,6 +34,22 @@ public class CircleCastEnv extends CastingEnvironment {
|
|||
return null;
|
||||
}
|
||||
|
||||
public @Nullable BlockEntityAbstractImpetus getCircle() {
|
||||
var entity = this.world.getBlockEntity(impetusLoc);
|
||||
|
||||
if (entity instanceof BlockEntityAbstractImpetus)
|
||||
return (BlockEntityAbstractImpetus) entity;
|
||||
return null;
|
||||
}
|
||||
|
||||
public BlockPos getImpetusLoc() {
|
||||
return impetusLoc;
|
||||
}
|
||||
|
||||
public Direction getStartDir() {
|
||||
return startDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MishapEnvironment getMishapEnvironment() {
|
||||
return null;
|
||||
|
|
|
@ -20,8 +20,13 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
|
||||
public class StaffCastEnv extends PlayerBasedCastEnv {
|
||||
private InteractionHand castingHand;
|
||||
|
||||
|
||||
public StaffCastEnv(ServerPlayer caster, InteractionHand castingHand) {
|
||||
super(caster, castingHand);
|
||||
|
||||
this.castingHand = castingHand;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,6 +48,11 @@ public class StaffCastEnv extends PlayerBasedCastEnv {
|
|||
return remaining;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionHand castingHand() {
|
||||
return castingHand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FrozenColorizer getColorizer() {
|
||||
return HexAPI.instance().getColorizer(this.caster);
|
||||
|
|
|
@ -54,7 +54,7 @@ data class FrameForEach(
|
|||
val (stackTop, newImage, newCont) = if (data.nonEmpty) {
|
||||
// Increment the evaluation depth,
|
||||
// push the next datum to the top of the stack,
|
||||
Triple(data.car, harness.image.incDepth(), continuation
|
||||
Triple(data.car, harness.image.copy(userData = CastingImage.incDepth(harness.image.userData)), continuation
|
||||
// put the next Thoth object back on the stack for the next Thoth cycle,
|
||||
.pushFrame(FrameForEach(data.cdr, code, stack, acc))
|
||||
// and prep the Thoth'd code block for evaluation.
|
||||
|
|
|
@ -3,6 +3,7 @@ package at.petrak.hexcasting.common.casting.operators.circles
|
|||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.eval.env.CircleCastEnv
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.mishaps.MishapNoSpellCircle
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
@ -11,11 +12,11 @@ class OpCircleBounds(val max: Boolean) : ConstMediaAction {
|
|||
override val argc = 0
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val circle = ctx.spellCircle
|
||||
if (circle == null)
|
||||
if (ctx !is CircleCastEnv)
|
||||
throw MishapNoSpellCircle()
|
||||
val circle = ctx.circle ?: throw MishapNoSpellCircle()
|
||||
|
||||
val aabb = circle.aabb
|
||||
val aabb = circle.getBounds(listOf())
|
||||
|
||||
return if (max)
|
||||
Vec3(aabb.maxX - 0.5, aabb.maxY - 0.5, aabb.maxZ - 0.5).asActionResult
|
||||
|
|
|
@ -4,6 +4,7 @@ import at.petrak.hexcasting.api.block.circle.BlockAbstractImpetus
|
|||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.eval.env.CircleCastEnv
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.mishaps.MishapNoSpellCircle
|
||||
|
||||
|
@ -11,13 +12,9 @@ object OpImpetusDir : ConstMediaAction {
|
|||
override val argc = 0
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val circle = ctx.spellCircle
|
||||
if (circle == null)
|
||||
if (ctx !is CircleCastEnv)
|
||||
throw MishapNoSpellCircle()
|
||||
|
||||
val pos = circle.impetusPos
|
||||
val bs = ctx.world.getBlockState(pos)
|
||||
val dir = bs.getValue(BlockAbstractImpetus.FACING)
|
||||
return dir.step().asActionResult
|
||||
return ctx.startDir.step().asActionResult
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package at.petrak.hexcasting.common.casting.operators.circles
|
|||
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
|
||||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.eval.env.CircleCastEnv
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.mishaps.MishapNoSpellCircle
|
||||
|
||||
|
@ -10,10 +11,9 @@ object OpImpetusPos : ConstMediaAction {
|
|||
override val argc = 0
|
||||
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val circle = ctx.spellCircle
|
||||
if (circle == null)
|
||||
if (ctx !is CircleCastEnv)
|
||||
throw MishapNoSpellCircle()
|
||||
|
||||
return circle.impetusPos.asActionResult
|
||||
return ctx.impetusLoc.asActionResult
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,10 +68,10 @@ object OpMakeBattery : SpellAction {
|
|||
val entityStack = itemEntity.item.copy()
|
||||
val mediamount = extractMedia(entityStack, drainForBatteries = true)
|
||||
if (mediamount > 0) {
|
||||
ctx.caster.setItemInHand(
|
||||
ctx.caster?.setItemInHand(
|
||||
hand,
|
||||
ItemMediaHolder.withMedia(ItemStack(HexItems.BATTERY), mediamount, mediamount)
|
||||
)
|
||||
) ?: return
|
||||
}
|
||||
|
||||
itemEntity.item = entityStack
|
||||
|
|
|
@ -47,7 +47,7 @@ class OpMakePackagedSpell<T : ItemPackagedHex>(val itemType: T, val cost: Int) :
|
|||
)
|
||||
}
|
||||
|
||||
val trueName = MishapOthersName.getTrueNameFromArgs(patterns, ctx.caster)
|
||||
val trueName = ctx.caster?.let { MishapOthersName.getTrueNameFromArgs(patterns, it) }
|
||||
if (trueName != null)
|
||||
throw MishapOthersName(trueName)
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import at.petrak.hexcasting.api.casting.iota.Iota
|
|||
import at.petrak.hexcasting.api.casting.mishaps.MishapBadBlock
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.core.particles.BlockParticleOption
|
||||
import net.minecraft.core.particles.ParticleTypes
|
||||
import net.minecraft.sounds.SoundSource
|
||||
|
@ -27,14 +28,14 @@ object OpPlaceBlock : SpellAction {
|
|||
override fun execute(
|
||||
args: List<Iota>,
|
||||
ctx: CastingEnvironment
|
||||
): Triple<RenderedSpell, Int, List<ParticleSpray>>? {
|
||||
): Triple<RenderedSpell, Int, List<ParticleSpray>> {
|
||||
val pos = args.getBlockPos(0, argc)
|
||||
ctx.assertVecInRange(pos)
|
||||
|
||||
val blockHit = BlockHitResult(
|
||||
Vec3.atCenterOf(pos), ctx.caster.direction, pos, false
|
||||
Vec3.atCenterOf(pos), ctx.caster?.direction ?: Direction.NORTH, pos, false
|
||||
)
|
||||
val itemUseCtx = UseOnContext(ctx.caster, ctx.castingHand, blockHit)
|
||||
val itemUseCtx = UseOnContext(ctx.caster, ctx.castingHand(), blockHit)
|
||||
val placeContext = BlockPlaceContext(itemUseCtx)
|
||||
|
||||
val worldState = ctx.world.getBlockState(pos)
|
||||
|
|
|
@ -31,7 +31,7 @@ object OpPrint : Action {
|
|||
|
||||
private data class Spell(val datum: Iota) : RenderedSpell {
|
||||
override fun cast(ctx: CastingEnvironment) {
|
||||
ctx.caster.sendSystemMessage(datum.display())
|
||||
ctx.caster?.sendSystemMessage(datum.display())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue