Merge branch 'main' of https://github.com/gamma-delta/HexMod
This commit is contained in:
commit
fb863d89e6
4 changed files with 58 additions and 28 deletions
|
@ -6,12 +6,16 @@
|
|||
"DCD"
|
||||
],
|
||||
"key": {
|
||||
"C": {
|
||||
"C": [{
|
||||
"tag": "forge:dusts/glowstone"
|
||||
},
|
||||
"D": {
|
||||
}, {
|
||||
"item": "minecraft:glowstone_dust"
|
||||
}],
|
||||
"D": [{
|
||||
"tag": "forge:leather"
|
||||
},
|
||||
}, {
|
||||
"item": "minecraft:leather"
|
||||
}],
|
||||
"I": {
|
||||
"item": "hexcasting:charged_amethyst"
|
||||
}
|
||||
|
@ -19,4 +23,4 @@
|
|||
"result": {
|
||||
"item": "hexcasting:focus"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
package at.petrak.hexcasting.common.casting.operators.spells
|
||||
|
||||
import at.petrak.hexcasting.api.misc.ManaConstants
|
||||
import at.petrak.hexcasting.api.spell.getChecked
|
||||
import at.petrak.hexcasting.api.spell.ParticleSpray
|
||||
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.*
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.spell.mishaps.MishapBadBlock
|
||||
import at.petrak.hexcasting.common.blocks.BlockConjured
|
||||
import at.petrak.hexcasting.common.lib.HexBlocks
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions
|
||||
|
@ -21,14 +18,25 @@ class OpConjure(val light: Boolean) : SpellOperator {
|
|||
override fun execute(
|
||||
args: List<SpellDatum<*>>,
|
||||
ctx: CastingContext
|
||||
): Triple<RenderedSpell, Int, List<ParticleSpray>> {
|
||||
): Triple<RenderedSpell, Int, List<ParticleSpray>>? {
|
||||
val target = args.getChecked<Vec3>(0, argc)
|
||||
ctx.assertVecInRange(target)
|
||||
|
||||
val pos = BlockPos(target)
|
||||
|
||||
if (!ctx.world.mayInteract(ctx.caster, pos))
|
||||
return null
|
||||
|
||||
val placeContext = DirectionalPlaceContext(ctx.world, pos, Direction.DOWN, ItemStack.EMPTY, Direction.UP)
|
||||
|
||||
val worldState = ctx.world.getBlockState(pos)
|
||||
if (!worldState.canBeReplaced(placeContext))
|
||||
throw MishapBadBlock.of(pos, "replaceable")
|
||||
|
||||
return Triple(
|
||||
Spell(target, light),
|
||||
ManaConstants.DUST_UNIT,
|
||||
listOf(ParticleSpray.Cloud(Vec3.atCenterOf(BlockPos(target)), 1.0))
|
||||
listOf(ParticleSpray.Cloud(Vec3.atCenterOf(pos), 1.0))
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
package at.petrak.hexcasting.common.casting.operators.spells
|
||||
|
||||
import at.petrak.hexcasting.api.misc.ManaConstants
|
||||
import at.petrak.hexcasting.api.spell.getChecked
|
||||
import at.petrak.hexcasting.api.spell.ParticleSpray
|
||||
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.*
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.spell.mishaps.MishapBadBlock
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.particles.BlockParticleOption
|
||||
import net.minecraft.core.particles.ParticleTypes
|
||||
import net.minecraft.sounds.SoundSource
|
||||
import net.minecraft.world.InteractionResult
|
||||
import net.minecraft.world.item.BlockItem
|
||||
import net.minecraft.world.item.context.BlockPlaceContext
|
||||
import net.minecraft.world.item.context.UseOnContext
|
||||
import net.minecraft.world.phys.BlockHitResult
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
@ -24,13 +22,30 @@ object OpPlaceBlock : SpellOperator {
|
|||
override fun execute(
|
||||
args: List<SpellDatum<*>>,
|
||||
ctx: CastingContext
|
||||
): Triple<RenderedSpell, Int, List<ParticleSpray>> {
|
||||
val pos = args.getChecked<Vec3>(0, argc)
|
||||
ctx.assertVecInRange(pos)
|
||||
): Triple<RenderedSpell, Int, List<ParticleSpray>>? {
|
||||
val target = args.getChecked<Vec3>(0, argc)
|
||||
ctx.assertVecInRange(target)
|
||||
|
||||
val pos = BlockPos(target)
|
||||
|
||||
if (!ctx.world.mayInteract(ctx.caster, pos))
|
||||
return null
|
||||
|
||||
|
||||
val blockHit = BlockHitResult(
|
||||
Vec3.ZERO, ctx.caster.direction, pos, false
|
||||
)
|
||||
val itemUseCtx = UseOnContext(ctx.caster, ctx.castingHand, blockHit)
|
||||
val placeContext = BlockPlaceContext(itemUseCtx)
|
||||
|
||||
val worldState = ctx.world.getBlockState(pos)
|
||||
if (!worldState.canBeReplaced(placeContext))
|
||||
throw MishapBadBlock.of(pos, "replaceable")
|
||||
|
||||
return Triple(
|
||||
Spell(pos),
|
||||
Spell(target),
|
||||
ManaConstants.DUST_UNIT,
|
||||
listOf(ParticleSpray.Cloud(Vec3.atCenterOf(BlockPos(pos)), 1.0))
|
||||
listOf(ParticleSpray.Cloud(Vec3.atCenterOf(pos), 1.0))
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -41,8 +56,14 @@ object OpPlaceBlock : SpellOperator {
|
|||
if (!ctx.world.mayInteract(ctx.caster, pos))
|
||||
return
|
||||
|
||||
val blockHit = BlockHitResult(
|
||||
Vec3.ZERO, ctx.caster.direction, pos, false
|
||||
)
|
||||
val itemUseCtx = UseOnContext(ctx.caster, ctx.castingHand, blockHit)
|
||||
val placeContext = BlockPlaceContext(itemUseCtx)
|
||||
|
||||
val bstate = ctx.world.getBlockState(pos)
|
||||
if (bstate.isAir || bstate.material.isReplaceable) {
|
||||
if (bstate.canBeReplaced(placeContext)) {
|
||||
val placeeSlot = ctx.getOperativeSlot { it.item is BlockItem }
|
||||
if (placeeSlot != null) {
|
||||
val placeeStack = ctx.caster.inventory.getItem(placeeSlot).copy()
|
||||
|
@ -64,11 +85,7 @@ object OpPlaceBlock : SpellOperator {
|
|||
spoofedStack.count = 1
|
||||
ctx.caster.setItemInHand(ctx.castingHand, spoofedStack)
|
||||
|
||||
val blockHit = BlockHitResult(
|
||||
Vec3.ZERO, ctx.caster.direction, pos, false
|
||||
)
|
||||
val itemUseCtx = UseOnContext(ctx.caster, ctx.castingHand, blockHit)
|
||||
val res = spoofedStack.useOn(itemUseCtx)
|
||||
val res = spoofedStack.useOn(placeContext)
|
||||
|
||||
ctx.caster.setItemInHand(ctx.castingHand, oldStack)
|
||||
if (res != InteractionResult.FAIL) {
|
||||
|
|
|
@ -381,6 +381,7 @@
|
|||
"hexcasting.mishap.bad_item.rechargable": "a rechargable item",
|
||||
"hexcasting.mishap.bad_block": "Expected %s at %s, but got %s",
|
||||
"hexcasting.mishap.bad_block.sapling": "a sapling",
|
||||
"hexcasting.mishap.bad_block.replaceable": "somewhere to place a block",
|
||||
"hexcasting.mishap.bad_brainsweep": "The %s rejected the villager's mind",
|
||||
"hexcasting.mishap.already_brainswept": "The villager has already been used",
|
||||
"hexcasting.mishap.no_spell_circle": "%s requires a spell circle",
|
||||
|
|
Loading…
Reference in a new issue