fix lots of ops bypassing spawn protection
This commit is contained in:
parent
4a172b6fb8
commit
8fc3b080ad
13 changed files with 45 additions and 6 deletions
|
@ -34,6 +34,9 @@ object OpBreakBlock : SpellOperator {
|
|||
override fun cast(ctx: CastingContext) {
|
||||
val pos = BlockPos(v)
|
||||
|
||||
if (!ctx.world.mayInteract(ctx.caster, pos))
|
||||
return
|
||||
|
||||
val blockstate = ctx.world.getBlockState(pos)
|
||||
val tier =
|
||||
HexConfig.Server.getOpBreakHarvestLevelBecauseForgeThoughtItWasAGoodIdeaToImplementHarvestTiersUsingAnHonestToGodTopoSort()
|
||||
|
|
|
@ -34,6 +34,10 @@ class OpConjure(val light: Boolean) : SpellOperator {
|
|||
private data class Spell(val target: Vec3, val light: Boolean) : RenderedSpell {
|
||||
override fun cast(ctx: CastingContext) {
|
||||
val pos = BlockPos(target)
|
||||
|
||||
if (!ctx.world.mayInteract(ctx.caster, pos))
|
||||
return
|
||||
|
||||
val placeContext = DirectionalPlaceContext(ctx.world, pos, Direction.DOWN, ItemStack.EMPTY, Direction.UP)
|
||||
|
||||
val worldState = ctx.world.getBlockState(pos)
|
||||
|
|
|
@ -30,11 +30,15 @@ object OpCreateWater : SpellOperator {
|
|||
|
||||
private data class Spell(val target: Vec3) : RenderedSpell {
|
||||
override fun cast(ctx: CastingContext) {
|
||||
val pos = BlockPos(target)
|
||||
|
||||
if (!ctx.world.mayInteract(ctx.caster, pos))
|
||||
return
|
||||
// Just steal bucket code lmao
|
||||
val charlie = Items.WATER_BUCKET
|
||||
if (charlie is BucketItem) {
|
||||
// make the player null so we don't give them a usage statistic for example
|
||||
charlie.emptyContents(null, ctx.world, BlockPos(target), null)
|
||||
charlie.emptyContents(null, ctx.world, pos, null)
|
||||
} else {
|
||||
HexMod.getLogger().warn("Items.WATER_BUCKET wasn't a BucketItem?")
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ object OpDestroyWater : SpellOperator {
|
|||
val here = todo.removeFirst()
|
||||
val distFromFocus =
|
||||
ctx.caster.position().distanceToSqr(Vec3(here.x.toDouble(), here.y.toDouble(), here.z.toDouble()))
|
||||
if (distFromFocus < Operator.MAX_DISTANCE * Operator.MAX_DISTANCE && seen.add(here)) {
|
||||
if (distFromFocus < Operator.MAX_DISTANCE * Operator.MAX_DISTANCE && seen.add(here) && ctx.world.mayInteract(ctx.caster, here)) {
|
||||
// never seen this pos in my life
|
||||
val fluid = ctx.world.getFluidState(here)
|
||||
if (fluid != Fluids.EMPTY.defaultFluidState()) {
|
||||
|
|
|
@ -36,6 +36,9 @@ object OpEdifySapling : SpellOperator {
|
|||
|
||||
private data class Spell(val pos: BlockPos) : RenderedSpell {
|
||||
override fun cast(ctx: CastingContext) {
|
||||
if (!ctx.world.mayInteract(ctx.caster, pos))
|
||||
return
|
||||
|
||||
val bs = ctx.world.getBlockState(pos)
|
||||
for (i in 0 until 8) {
|
||||
val success = AkashicTreeGrower.INSTANCE.growTree(
|
||||
|
|
|
@ -6,6 +6,7 @@ import at.petrak.hexcasting.api.spell.RenderedSpell
|
|||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.SpellOperator
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.util.Mth
|
||||
import net.minecraft.world.level.Explosion
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
@ -30,6 +31,9 @@ class OpExplode(val fire: Boolean) : SpellOperator {
|
|||
|
||||
private data class Spell(val pos: Vec3, val strength: Double, val fire: Boolean) : RenderedSpell {
|
||||
override fun cast(ctx: CastingContext) {
|
||||
if (!ctx.world.mayInteract(ctx.caster, BlockPos(pos)))
|
||||
return
|
||||
|
||||
ctx.world.explode(
|
||||
ctx.caster,
|
||||
pos.x,
|
||||
|
|
|
@ -55,7 +55,7 @@ object OpExtinguish : SpellOperator {
|
|||
here.z.toDouble()
|
||||
)
|
||||
) // max distance to prevent runaway shenanigans
|
||||
if (distFromFocus < Operator.MAX_DISTANCE * Operator.MAX_DISTANCE && seen.add(here) && distFromTarget < 10) {
|
||||
if (distFromFocus < Operator.MAX_DISTANCE * Operator.MAX_DISTANCE && seen.add(here) && distFromTarget < 10 && ctx.world.mayInteract(ctx.caster, here)) {
|
||||
// never seen this pos in my life
|
||||
val blockstate = ctx.world.getBlockState(here)
|
||||
val success =
|
||||
|
|
|
@ -35,6 +35,10 @@ object OpIgnite : SpellOperator {
|
|||
|
||||
private data class Spell(val target: Vec3) : RenderedSpell {
|
||||
override fun cast(ctx: CastingContext) {
|
||||
val pos = BlockPos(target)
|
||||
if (!ctx.world.mayInteract(ctx.caster, pos))
|
||||
return
|
||||
|
||||
// steal petra code that steals bucket code
|
||||
val maxwell = Items.FIRE_CHARGE
|
||||
if (maxwell is FireChargeItem) {
|
||||
|
@ -45,7 +49,7 @@ object OpIgnite : SpellOperator {
|
|||
null,
|
||||
InteractionHand.MAIN_HAND,
|
||||
ItemStack(maxwell.asItem()),
|
||||
BlockHitResult(target, Direction.UP, BlockPos(target), false)
|
||||
BlockHitResult(target, Direction.UP, pos, false)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
|
|
|
@ -39,6 +39,10 @@ object OpPlaceBlock : SpellOperator {
|
|||
private data class Spell(val vec: Vec3) : RenderedSpell {
|
||||
override fun cast(ctx: CastingContext) {
|
||||
val pos = BlockPos(vec)
|
||||
|
||||
if (!ctx.world.mayInteract(ctx.caster, pos))
|
||||
return
|
||||
|
||||
val bstate = ctx.world.getBlockState(pos)
|
||||
if (bstate.isAir || bstate.material.isReplaceable) {
|
||||
val placeeSlot = ctx.getOperativeSlot { it.item is BlockItem }
|
||||
|
|
|
@ -36,6 +36,10 @@ object OpTheOnlyReasonAnyoneDownloadedPsi : SpellOperator {
|
|||
override fun cast(ctx: CastingContext) {
|
||||
// https://github.com/VazkiiMods/Psi/blob/master/src/main/java/vazkii/psi/common/spell/trick/PieceTrickOvergrow.java
|
||||
val pos = BlockPos(target)
|
||||
|
||||
if (!ctx.world.mayInteract(ctx.caster, pos))
|
||||
return
|
||||
|
||||
val hit = BlockHitResult(Vec3.ZERO, Direction.UP, pos, false)
|
||||
val save: ItemStack = ctx.caster.getItemInHand(InteractionHand.MAIN_HAND)
|
||||
ctx.caster.setItemInHand(InteractionHand.MAIN_HAND, ItemStack(Items.BONE_MEAL))
|
||||
|
|
|
@ -31,11 +31,16 @@ object OpCreateLava : SpellOperator {
|
|||
|
||||
private data class Spell(val target: Vec3) : RenderedSpell {
|
||||
override fun cast(ctx: CastingContext) {
|
||||
val pos = BlockPos(target)
|
||||
|
||||
if (!ctx.world.mayInteract(ctx.caster, pos))
|
||||
return
|
||||
|
||||
// Just steal bucket code lmao
|
||||
val charlie = Items.LAVA_BUCKET
|
||||
if (charlie is BucketItem) {
|
||||
// make the player null so we don't give them a usage statistic for example
|
||||
charlie.emptyContents(null, ctx.world, BlockPos(target), null)
|
||||
charlie.emptyContents(null, ctx.world, pos, null)
|
||||
} else {
|
||||
HexMod.getLogger().warn("Items.LAVA_BUCKET wasn't a BucketItem?")
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import at.petrak.hexcasting.api.spell.RenderedSpell
|
|||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.SpellOperator
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.entity.EntityType
|
||||
import net.minecraft.world.entity.LightningBolt
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
@ -29,6 +30,9 @@ object OpLightning : SpellOperator {
|
|||
|
||||
private data class Spell(val target: Vec3) : RenderedSpell {
|
||||
override fun cast(ctx: CastingContext) {
|
||||
if (!ctx.world.mayInteract(ctx.caster, BlockPos(target)))
|
||||
return
|
||||
|
||||
val lightning = LightningBolt(EntityType.LIGHTNING_BOLT, ctx.world)
|
||||
lightning.setPosRaw(target.x, target.y, target.z)
|
||||
ctx.world.addWithUUID(lightning) // why the hell is it called this it doesnt even involve a uuid
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "hexcasting.entry.101",
|
||||
"category": "hexcasting:casting",
|
||||
"icon": "hexcasting:akashic_wand",
|
||||
"icon": "hexcasting:wand_akashic",
|
||||
"advancement": "hexcasting:root",
|
||||
"priority": true,
|
||||
"pages": [
|
||||
|
|
Loading…
Reference in a new issue