parent
8f6bddb25c
commit
1424cff844
6 changed files with 107 additions and 89 deletions
|
@ -4,6 +4,7 @@ import at.petrak.hexcasting.api.misc.ManaConstants
|
||||||
import at.petrak.hexcasting.api.spell.*
|
import at.petrak.hexcasting.api.spell.*
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.iota.Iota
|
import at.petrak.hexcasting.api.spell.iota.Iota
|
||||||
|
import at.petrak.hexcasting.xplat.IXplatAbstractions
|
||||||
import net.minecraft.core.BlockPos
|
import net.minecraft.core.BlockPos
|
||||||
import net.minecraft.core.Direction
|
import net.minecraft.core.Direction
|
||||||
import net.minecraft.core.particles.ParticleTypes
|
import net.minecraft.core.particles.ParticleTypes
|
||||||
|
@ -60,6 +61,13 @@ object OpDestroyWater : SpellAction {
|
||||||
val fluid = ctx.world.getFluidState(here)
|
val fluid = ctx.world.getFluidState(here)
|
||||||
if (fluid != Fluids.EMPTY.defaultFluidState()) {
|
if (fluid != Fluids.EMPTY.defaultFluidState()) {
|
||||||
val blockstate = ctx.world.getBlockState(here)
|
val blockstate = ctx.world.getBlockState(here)
|
||||||
|
if (IXplatAbstractions.INSTANCE.isBreakingAllowed(
|
||||||
|
ctx.world,
|
||||||
|
here,
|
||||||
|
blockstate,
|
||||||
|
ctx.caster
|
||||||
|
)
|
||||||
|
) {
|
||||||
val material = blockstate.material
|
val material = blockstate.material
|
||||||
val success =
|
val success =
|
||||||
if (blockstate.block is BucketPickup && !(blockstate.block as BucketPickup).pickupBlock(
|
if (blockstate.block is BucketPickup && !(blockstate.block as BucketPickup).pickupBlock(
|
||||||
|
@ -102,6 +110,7 @@ object OpDestroyWater : SpellAction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (successes > 0) {
|
if (successes > 0) {
|
||||||
ctx.world.playSound(
|
ctx.world.playSound(
|
||||||
|
|
|
@ -9,6 +9,7 @@ import at.petrak.hexcasting.api.spell.getBlockPos
|
||||||
import at.petrak.hexcasting.api.spell.iota.Iota
|
import at.petrak.hexcasting.api.spell.iota.Iota
|
||||||
import at.petrak.hexcasting.api.spell.mishaps.MishapBadBlock
|
import at.petrak.hexcasting.api.spell.mishaps.MishapBadBlock
|
||||||
import at.petrak.hexcasting.common.misc.AkashicTreeGrower
|
import at.petrak.hexcasting.common.misc.AkashicTreeGrower
|
||||||
|
import at.petrak.hexcasting.xplat.IXplatAbstractions
|
||||||
import net.minecraft.core.BlockPos
|
import net.minecraft.core.BlockPos
|
||||||
import net.minecraft.tags.BlockTags
|
import net.minecraft.tags.BlockTags
|
||||||
import net.minecraft.world.phys.Vec3
|
import net.minecraft.world.phys.Vec3
|
||||||
|
@ -34,7 +35,9 @@ object OpEdifySapling : SpellAction {
|
||||||
|
|
||||||
private data class Spell(val pos: BlockPos) : RenderedSpell {
|
private data class Spell(val pos: BlockPos) : RenderedSpell {
|
||||||
override fun cast(ctx: CastingContext) {
|
override fun cast(ctx: CastingContext) {
|
||||||
if (!ctx.world.mayInteract(ctx.caster, pos))
|
val blockstate = ctx.world.getBlockState(pos)
|
||||||
|
if (!ctx.world.mayInteract(ctx.caster, pos) ||
|
||||||
|
!IXplatAbstractions.INSTANCE.isBreakingAllowed(ctx.world, pos, blockstate, ctx.caster))
|
||||||
return
|
return
|
||||||
|
|
||||||
val bs = ctx.world.getBlockState(pos)
|
val bs = ctx.world.getBlockState(pos)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import at.petrak.hexcasting.api.spell.*
|
||||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.iota.Iota
|
import at.petrak.hexcasting.api.spell.iota.Iota
|
||||||
import at.petrak.hexcasting.ktxt.UseOnContext
|
import at.petrak.hexcasting.ktxt.UseOnContext
|
||||||
|
import at.petrak.hexcasting.xplat.IXplatAbstractions
|
||||||
import net.minecraft.core.BlockPos
|
import net.minecraft.core.BlockPos
|
||||||
import net.minecraft.core.Direction
|
import net.minecraft.core.Direction
|
||||||
import net.minecraft.core.particles.ParticleTypes
|
import net.minecraft.core.particles.ParticleTypes
|
||||||
|
@ -55,6 +56,7 @@ object OpExtinguish : SpellAction {
|
||||||
) {
|
) {
|
||||||
// never seen this pos in my life
|
// never seen this pos in my life
|
||||||
val blockstate = ctx.world.getBlockState(here)
|
val blockstate = ctx.world.getBlockState(here)
|
||||||
|
if (IXplatAbstractions.INSTANCE.isBreakingAllowed(ctx.world, here, blockstate, ctx.caster)) {
|
||||||
val success =
|
val success =
|
||||||
when (blockstate.block) {
|
when (blockstate.block) {
|
||||||
is BaseFireBlock -> {
|
is BaseFireBlock -> {
|
||||||
|
@ -62,7 +64,8 @@ object OpExtinguish : SpellAction {
|
||||||
}
|
}
|
||||||
is CampfireBlock -> {
|
is CampfireBlock -> {
|
||||||
if (blockstate.getValue(CampfireBlock.LIT)) { // check if campfire is lit before putting it out
|
if (blockstate.getValue(CampfireBlock.LIT)) { // check if campfire is lit before putting it out
|
||||||
val wilson = Items.WOODEN_SHOVEL // summon shovel from the ether to do our bidding
|
val wilson =
|
||||||
|
Items.WOODEN_SHOVEL // summon shovel from the ether to do our bidding
|
||||||
val hereVec = Vec3.atCenterOf(here)
|
val hereVec = Vec3.atCenterOf(here)
|
||||||
wilson.useOn(
|
wilson.useOn(
|
||||||
UseOnContext(
|
UseOnContext(
|
||||||
|
@ -105,6 +108,7 @@ object OpExtinguish : SpellAction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (successes > 0) {
|
if (successes > 0) {
|
||||||
ctx.world.playSound(
|
ctx.world.playSound(
|
||||||
|
|
|
@ -9,6 +9,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||||
import at.petrak.hexcasting.api.spell.getBlockPos
|
import at.petrak.hexcasting.api.spell.getBlockPos
|
||||||
import at.petrak.hexcasting.api.spell.iota.Iota
|
import at.petrak.hexcasting.api.spell.iota.Iota
|
||||||
import at.petrak.hexcasting.ktxt.UseOnContext
|
import at.petrak.hexcasting.ktxt.UseOnContext
|
||||||
|
import at.petrak.hexcasting.xplat.IXplatAbstractions
|
||||||
import net.minecraft.core.BlockPos
|
import net.minecraft.core.BlockPos
|
||||||
import net.minecraft.core.Direction
|
import net.minecraft.core.Direction
|
||||||
import net.minecraft.world.InteractionHand
|
import net.minecraft.world.InteractionHand
|
||||||
|
@ -36,12 +37,13 @@ object OpIgnite : SpellAction {
|
||||||
|
|
||||||
private data class Spell(val pos: BlockPos) : RenderedSpell {
|
private data class Spell(val pos: BlockPos) : RenderedSpell {
|
||||||
override fun cast(ctx: CastingContext) {
|
override fun cast(ctx: CastingContext) {
|
||||||
// TODO should we do these checks in the action part of the spell
|
|
||||||
if (!ctx.world.mayInteract(ctx.caster, pos))
|
|
||||||
return
|
|
||||||
|
|
||||||
// steal petra code that steals bucket code
|
// steal petra code that steals bucket code
|
||||||
val maxwell = Items.FIRE_CHARGE
|
val maxwell = Items.FIRE_CHARGE
|
||||||
|
|
||||||
|
// TODO should we do these checks in the action part of the spell
|
||||||
|
if (!ctx.world.mayInteract(ctx.caster, pos) || !IXplatAbstractions.INSTANCE.isPlacingAllowed(ctx.world, pos, ItemStack(maxwell), ctx.caster))
|
||||||
|
return
|
||||||
|
|
||||||
if (maxwell is FireChargeItem) {
|
if (maxwell is FireChargeItem) {
|
||||||
// help
|
// help
|
||||||
maxwell.useOn(
|
maxwell.useOn(
|
||||||
|
|
|
@ -97,7 +97,7 @@ tasks.withType(JavaCompile) {
|
||||||
source(project(":Common").sourceSets.main.allSource)
|
source(project(":Common").sourceSets.main.allSource)
|
||||||
}
|
}
|
||||||
compileKotlin {
|
compileKotlin {
|
||||||
source(project(":Common").sourceSets.main.allSource)
|
source(project(":Common").sourceSets.main.kotlin)
|
||||||
}
|
}
|
||||||
|
|
||||||
sourcesJar {
|
sourcesJar {
|
||||||
|
|
|
@ -155,10 +155,10 @@ tasks.withType(JavaCompile) {
|
||||||
source(project(":Common").sourceSets.main.allSource)
|
source(project(":Common").sourceSets.main.allSource)
|
||||||
}
|
}
|
||||||
compileKotlin {
|
compileKotlin {
|
||||||
source(project(":Common").sourceSets.main.allSource)
|
source(project(":Common").sourceSets.main.kotlin)
|
||||||
}
|
}
|
||||||
compileTestKotlin {
|
compileTestKotlin {
|
||||||
source(project(":Common").sourceSets.main.allSource)
|
source(project(":Common").sourceSets.main.kotlin)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue