From ffb8de1f52604b4726e8c382105cf69eca5a45c2 Mon Sep 17 00:00:00 2001 From: pipythonmc <47196755+pythonmcpi@users.noreply.github.com> Date: Sun, 12 Apr 2026 20:40:20 -0700 Subject: [PATCH] Fix OpCreateFluid's check to return the correct message when position is out of ambit --- .../casting/actions/spells/OpCreateFluid.kt | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/OpCreateFluid.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/OpCreateFluid.kt index 46c0662619..6278ab1d76 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/OpCreateFluid.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/actions/spells/OpCreateFluid.kt @@ -4,9 +4,8 @@ import at.petrak.hexcasting.api.casting.ParticleSpray import at.petrak.hexcasting.api.casting.RenderedSpell import at.petrak.hexcasting.api.casting.castables.SpellAction import at.petrak.hexcasting.api.casting.eval.CastingEnvironment -import at.petrak.hexcasting.api.casting.getVec3 +import at.petrak.hexcasting.api.casting.getBlockPos import at.petrak.hexcasting.api.casting.iota.Iota -import at.petrak.hexcasting.api.casting.mishaps.MishapBadLocation import at.petrak.hexcasting.xplat.IXplatAbstractions import net.minecraft.core.BlockPos import net.minecraft.server.level.ServerPlayer @@ -24,17 +23,8 @@ class OpCreateFluid(val cost: Long, val bucket: Item, val cauldron: BlockState, args: List, env: CastingEnvironment ): SpellAction.Result { - val vecPos = args.getVec3(0, argc) - val pos = BlockPos.containing(vecPos) - - if (!env.canEditBlockAt(pos) || !IXplatAbstractions.INSTANCE.isPlacingAllowed( - env.world, - pos, - ItemStack(bucket), - env.castingEntity as? ServerPlayer - ) - ) - throw MishapBadLocation(vecPos, "forbidden") + val pos = args.getBlockPos(0, argc) + env.assertPosInRangeForEditing(pos) return SpellAction.Result( Spell(pos, bucket, cauldron, fluid), @@ -45,6 +35,8 @@ class OpCreateFluid(val cost: Long, val bucket: Item, val cauldron: BlockState, private data class Spell(val pos: BlockPos, val bucket: Item, val cauldron: BlockState, val fluid: Fluid) : RenderedSpell { override fun cast(env: CastingEnvironment) { + if (!IXplatAbstractions.INSTANCE.isPlacingAllowed(env.world, pos, ItemStack(bucket), env.castingEntity as? ServerPlayer)) + return val state = env.world.getBlockState(pos)