Merge branch 'main' of https://github.com/gamma-delta/HexMod
This commit is contained in:
commit
a0517426e0
44 changed files with 383 additions and 274 deletions
|
@ -6,6 +6,7 @@ import net.minecraft.ChatFormatting;
|
|||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -21,12 +22,7 @@ public interface DataHolderItem {
|
|||
|
||||
@Nullable
|
||||
default SpellDatum<?> readDatum(ItemStack stack, ServerLevel world) {
|
||||
if (!(stack.getItem() instanceof DataHolderItem dh)) {
|
||||
// this should be checked via mishap beforehand
|
||||
throw new IllegalArgumentException("stack's item must be an ItemDataholder but was " + stack.getItem());
|
||||
}
|
||||
|
||||
var tag = dh.readDatumTag(stack);
|
||||
var tag = readDatumTag(stack);
|
||||
if (tag != null) {
|
||||
return SpellDatum.fromNBT(tag, world);
|
||||
} else {
|
||||
|
@ -51,7 +47,7 @@ public interface DataHolderItem {
|
|||
pTooltipComponents.add(new TranslatableComponent("hexcasting.spelldata.onitem", component));
|
||||
|
||||
if (pIsAdvanced.isAdvanced()) {
|
||||
pTooltipComponents.add(NbtUtils.toPrettyComponent(datumTag));
|
||||
pTooltipComponents.add(new TextComponent("").append(NbtUtils.toPrettyComponent(datumTag)));
|
||||
}
|
||||
} else if (NBTHelper.hasString(pStack, DataHolderItem.TAG_OVERRIDE_VISUALLY)) {
|
||||
pTooltipComponents.add(new TranslatableComponent("hexcasting.spelldata.onitem",
|
||||
|
|
|
@ -5,10 +5,10 @@ package at.petrak.hexcasting.api.spell
|
|||
import at.petrak.hexcasting.api.spell.math.HexPattern
|
||||
import at.petrak.hexcasting.api.spell.mishaps.MishapInvalidIota
|
||||
import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import com.mojang.datafixers.util.Either
|
||||
import com.mojang.math.Vector3f
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import kotlin.math.abs
|
||||
|
@ -20,7 +20,7 @@ fun numOrVec(datum: SpellDatum<*>, reverseIdx: Int): Either<Double, Vec3> =
|
|||
else -> throw MishapInvalidIota(
|
||||
datum,
|
||||
reverseIdx,
|
||||
TranslatableComponent("hexcasting.mishap.invalid_value.numvec")
|
||||
"hexcasting.mishap.invalid_value.numvec".asTranslatedComponent
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ fun numOrList(datum: SpellDatum<*>, reverseIdx: Int): Either<Double, SpellList>
|
|||
else -> throw MishapInvalidIota(
|
||||
datum,
|
||||
reverseIdx,
|
||||
TranslatableComponent("hexcasting.mishap.invalid_value.numlist")
|
||||
"hexcasting.mishap.invalid_value.numlist".asTranslatedComponent
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,13 +4,10 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
|
|||
import at.petrak.hexcasting.api.spell.math.HexPattern
|
||||
import at.petrak.hexcasting.api.spell.mishaps.MishapInvalidSpellDatumType
|
||||
import at.petrak.hexcasting.api.utils.*
|
||||
import net.minecraft.ChatFormatting
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.nbt.NbtUtils
|
||||
import net.minecraft.nbt.Tag
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.TextComponent
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import net.minecraft.server.level.ServerLevel
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
@ -155,69 +152,59 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
|
|||
if (keys.size != 1)
|
||||
throw IllegalArgumentException("Expected exactly one kv pair: $nbt")
|
||||
|
||||
return when (val key = keys.iterator().next()) {
|
||||
TAG_DOUBLE -> TextComponent(
|
||||
String.format(
|
||||
"%.4f",
|
||||
nbt.getDouble(TAG_DOUBLE)
|
||||
)
|
||||
).withStyle(ChatFormatting.GREEN)
|
||||
val out = "".asTextComponent
|
||||
when (val key = keys.iterator().next()) {
|
||||
TAG_DOUBLE -> out += String.format(
|
||||
"%.4f",
|
||||
nbt.getDouble(TAG_DOUBLE)
|
||||
).green
|
||||
TAG_VEC3 -> {
|
||||
val vec = vecFromNBT(nbt.getLongArray(key))
|
||||
// the focus color is really more red, but we don't want to show an error-y color
|
||||
TextComponent(
|
||||
String.format(
|
||||
out += String.format(
|
||||
"(%.2f, %.2f, %.2f)",
|
||||
vec.x,
|
||||
vec.y,
|
||||
vec.z
|
||||
)
|
||||
).withStyle(ChatFormatting.LIGHT_PURPLE)
|
||||
).lightPurple
|
||||
}
|
||||
TAG_LIST -> {
|
||||
val out = TextComponent("[").withStyle(ChatFormatting.WHITE)
|
||||
out += "[".white
|
||||
|
||||
val arr = nbt.getList(key, Tag.TAG_COMPOUND)
|
||||
for ((i, subtag) in arr.withIndex()) {
|
||||
// this is safe because otherwise we wouldn't have been able to get the list before
|
||||
out.append(displayFromNBT(subtag as CompoundTag))
|
||||
out += displayFromNBT(subtag.asCompound)
|
||||
if (i != arr.lastIndex) {
|
||||
out.append(", ")
|
||||
out += ", ".white
|
||||
}
|
||||
}
|
||||
|
||||
out.append("]")
|
||||
out += "]".white
|
||||
}
|
||||
TAG_WIDGET -> {
|
||||
val widget = Widget.valueOf(nbt.getString(key))
|
||||
if (widget == Widget.GARBAGE) TextComponent("arimfexendrapuse").withStyle(
|
||||
ChatFormatting.DARK_GRAY,
|
||||
ChatFormatting.OBFUSCATED
|
||||
)
|
||||
// use dark purple instead of pink, so that vec3 can be pink instead of error red
|
||||
else TextComponent(widget.toString()).withStyle(ChatFormatting.DARK_PURPLE)
|
||||
out += if (widget == Widget.GARBAGE)
|
||||
"arimfexendrapuse".darkGray.obfuscated
|
||||
else
|
||||
widget.toString().darkPurple
|
||||
}
|
||||
TAG_PATTERN -> {
|
||||
val pat = HexPattern.fromNBT(nbt.getCompound(TAG_PATTERN))
|
||||
var angleDesc = pat.anglesSignature()
|
||||
if (angleDesc.isNotBlank()) angleDesc = " $angleDesc";
|
||||
val out = TextComponent("HexPattern(").withStyle(ChatFormatting.GOLD)
|
||||
out.append(TextComponent("${pat.startDir}$angleDesc").withStyle(ChatFormatting.WHITE))
|
||||
out.append(")")
|
||||
out += "HexPattern(".gold
|
||||
out += "${pat.startDir}$angleDesc".white
|
||||
out += ")".gold
|
||||
}
|
||||
TAG_ENTITY -> {
|
||||
val subtag = nbt.getCompound(TAG_ENTITY)
|
||||
val json = subtag.getString(TAG_ENTITY_NAME_CHEATY)
|
||||
// handle pre-0.5.0 foci not having the tag
|
||||
try {
|
||||
val subtag = nbt.getCompound(TAG_ENTITY)
|
||||
val json = subtag.getString(TAG_ENTITY_NAME_CHEATY)
|
||||
val out = Component.Serializer.fromJson(json)!!
|
||||
out.withStyle(ChatFormatting.AQUA)
|
||||
} catch (exn: NullPointerException) {
|
||||
TranslatableComponent("hexcasting.spelldata.entity.whoknows").withStyle(ChatFormatting.WHITE)
|
||||
}
|
||||
out += Component.Serializer.fromJson(json)?.aqua ?: "hexcasting.spelldata.entity.whoknows".asTranslatedComponent.white
|
||||
}
|
||||
else -> throw IllegalArgumentException("Unknown key $key: $nbt")
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// Set of legal types to go in a spell
|
||||
|
|
|
@ -16,7 +16,6 @@ import at.petrak.hexcasting.api.utils.*
|
|||
import at.petrak.hexcasting.xplat.IXplatAbstractions
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.nbt.Tag
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerLevel
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
@ -236,13 +235,7 @@ class CastingHarness private constructor(
|
|||
}
|
||||
}
|
||||
|
||||
fun generateDescs(): List<Component> {
|
||||
val descs = ArrayList<Component>(this.stack.size)
|
||||
for (datum in this.stack) {
|
||||
descs.add(datum.display())
|
||||
}
|
||||
return descs
|
||||
}
|
||||
fun generateDescs() = stack.map(SpellDatum<*>::display)
|
||||
|
||||
/**
|
||||
* Return the functional update represented by the current state (for use with `copy`)
|
||||
|
|
|
@ -7,10 +7,10 @@ import at.petrak.hexcasting.api.mod.HexStatistics
|
|||
import at.petrak.hexcasting.api.spell.ParticleSpray
|
||||
import at.petrak.hexcasting.api.spell.RenderedSpell
|
||||
import at.petrak.hexcasting.api.spell.mishaps.Mishap
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import at.petrak.hexcasting.common.lib.HexItems
|
||||
import at.petrak.hexcasting.common.lib.HexSounds
|
||||
import net.minecraft.Util
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import net.minecraft.sounds.SoundSource
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.item.ItemStack
|
||||
|
@ -25,7 +25,7 @@ sealed class OperatorSideEffect {
|
|||
data class RequiredEnlightenment(val awardStat: Boolean) : OperatorSideEffect() {
|
||||
override fun performEffect(harness: CastingHarness): Boolean {
|
||||
harness.ctx.caster.sendMessage(
|
||||
TranslatableComponent("hexcasting.message.cant_great_spell"),
|
||||
"hexcasting.message.cant_great_spell".asTranslatedComponent,
|
||||
Util.NIL_UUID
|
||||
)
|
||||
|
||||
|
@ -53,7 +53,7 @@ sealed class OperatorSideEffect {
|
|||
val leftoverMana = harness.withdrawMana(this.amount, overcastOk)
|
||||
if (leftoverMana > 0 && !overcastOk) {
|
||||
harness.ctx.caster.sendMessage(
|
||||
TranslatableComponent("hexcasting.message.cant_overcast"),
|
||||
"hexcasting.message.cant_overcast".asTranslatedComponent,
|
||||
Util.NIL_UUID
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,19 +1,22 @@
|
|||
package at.petrak.hexcasting.api.spell.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.mod.HexItemTags
|
||||
import at.petrak.hexcasting.api.spell.ParticleSpray
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType
|
||||
import at.petrak.hexcasting.api.spell.math.HexPattern
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import at.petrak.hexcasting.api.utils.lightPurple
|
||||
import at.petrak.hexcasting.api.utils.obfuscated
|
||||
import at.petrak.hexcasting.common.lib.HexItems
|
||||
import at.petrak.hexcasting.mixin.accessor.AccessorLivingEntity
|
||||
import net.minecraft.ChatFormatting
|
||||
import net.minecraft.Util
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.Style
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.InteractionHand
|
||||
import net.minecraft.world.damagesource.DamageSource
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.entity.item.ItemEntity
|
||||
|
@ -40,6 +43,8 @@ sealed class Mishap : Throwable() {
|
|||
|
||||
abstract fun errorMessage(ctx: CastingContext, errorCtx: Context): Component
|
||||
|
||||
// Useful helper functions
|
||||
|
||||
protected fun dyeColor(color: DyeColor): FrozenColorizer =
|
||||
FrozenColorizer(
|
||||
ItemStack(HexItems.DYE_COLORIZERS[color]!!),
|
||||
|
@ -47,11 +52,35 @@ sealed class Mishap : Throwable() {
|
|||
)
|
||||
|
||||
protected fun error(stub: String, vararg args: Any): Component =
|
||||
TranslatableComponent("hexcasting.mishap.$stub", *args)
|
||||
"hexcasting.mishap.$stub".asTranslatedComponent(*args)
|
||||
|
||||
protected fun actionName(action: ResourceLocation?): Component =
|
||||
TranslatableComponent("hexcasting.spell.${action ?: "unknown"}")
|
||||
.setStyle(Style.EMPTY.withColor(ChatFormatting.LIGHT_PURPLE).withUnderlined(true))
|
||||
"hexcasting.spell.${action ?: "unknown"}".asTranslatedComponent.lightPurple.obfuscated
|
||||
|
||||
protected fun yeetHeldItemsTowards(ctx: CastingContext, targetPos: Vec3) {
|
||||
// Knock the player's items out of their hands
|
||||
val items = mutableListOf<ItemStack>()
|
||||
for (hand in InteractionHand.values()) {
|
||||
if (hand != ctx.castingHand || ctx.caster.getItemInHand(hand).`is`(HexItemTags.WANDS)) {
|
||||
items.add(ctx.caster.getItemInHand(hand).copy())
|
||||
ctx.caster.setItemInHand(hand, ItemStack.EMPTY)
|
||||
}
|
||||
}
|
||||
|
||||
val delta = targetPos.subtract(ctx.position).normalize().scale(0.5)
|
||||
|
||||
for (item in items) {
|
||||
yeetItem(item, ctx, delta)
|
||||
}
|
||||
}
|
||||
|
||||
protected fun yeetHeldItem(ctx: CastingContext, hand: InteractionHand) {
|
||||
val item = ctx.caster.getItemInHand(hand).copy()
|
||||
ctx.caster.setItemInHand(hand, ItemStack.EMPTY)
|
||||
|
||||
val delta = ctx.caster.lookAngle.scale(0.5)
|
||||
yeetItem(item, ctx, delta)
|
||||
}
|
||||
|
||||
protected fun yeetItem(stack: ItemStack, ctx: CastingContext, delta: Vec3) {
|
||||
val entity = ItemEntity(
|
||||
|
@ -66,6 +95,10 @@ sealed class Mishap : Throwable() {
|
|||
ctx.world.addWithUUID(entity)
|
||||
}
|
||||
|
||||
protected fun blockAtPos(ctx: CastingContext, pos: BlockPos): Component {
|
||||
return ctx.world.getBlockState(pos).block.name
|
||||
}
|
||||
|
||||
data class Context(val pattern: HexPattern, val action: ResourceLocation?)
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -5,7 +5,6 @@ import at.petrak.hexcasting.api.misc.HexDamageSources
|
|||
import at.petrak.hexcasting.api.spell.ParticleSpray
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.entity.npc.Villager
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
|
@ -14,14 +13,13 @@ class MishapAlreadyBrainswept(val villager: Villager) : Mishap() {
|
|||
dyeColor(DyeColor.GREEN)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
||||
villager.hurt(HexDamageSources.overcastDamageFrom(ctx.caster), villager.health)
|
||||
trulyHurt(villager, HexDamageSources.overcastDamageFrom(ctx.caster), villager.health)
|
||||
}
|
||||
|
||||
override fun particleSpray(ctx: CastingContext): ParticleSpray {
|
||||
return ParticleSpray.burst(villager.eyePosition, 1.0)
|
||||
}
|
||||
override fun particleSpray(ctx: CastingContext) =
|
||||
ParticleSpray.burst(villager.eyePosition, 1.0)
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
error("already_brainswept")
|
||||
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ import at.petrak.hexcasting.api.misc.FrozenColorizer
|
|||
import at.petrak.hexcasting.api.spell.ParticleSpray
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.level.Explosion
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
@ -19,19 +19,16 @@ class MishapBadBlock(val pos: BlockPos, val expected: Component) : Mishap() {
|
|||
ctx.world.explode(null, pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, 0.25f, Explosion.BlockInteraction.NONE)
|
||||
}
|
||||
|
||||
override fun particleSpray(ctx: CastingContext): ParticleSpray {
|
||||
return ParticleSpray.burst(Vec3.atCenterOf(pos), 1.0)
|
||||
}
|
||||
override fun particleSpray(ctx: CastingContext) =
|
||||
ParticleSpray.burst(Vec3.atCenterOf(pos), 1.0)
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component {
|
||||
val bs = ctx.world.getBlockState(this.pos)
|
||||
return error("bad_block", expected, this.pos.toShortString(), bs.block.name)
|
||||
}
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
error("bad_block", expected, this.pos.toShortString(), blockAtPos(ctx, this.pos))
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun of(pos: BlockPos, stub: String): MishapBadBlock {
|
||||
return MishapBadBlock(pos, TranslatableComponent("hexcasting.mishap.bad_block.$stub"))
|
||||
return MishapBadBlock(pos, "hexcasting.mishap.bad_block.$stub".asTranslatedComponent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import at.petrak.hexcasting.api.spell.ParticleSpray
|
|||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.entity.npc.Villager
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
@ -23,8 +22,6 @@ class MishapBadBrainsweep(val villager: Villager, val pos: BlockPos) : Mishap()
|
|||
return ParticleSpray.burst(Vec3.atCenterOf(pos), 1.0)
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component {
|
||||
val bs = ctx.world.getBlockState(this.pos)
|
||||
return error("bad_brainsweep", bs.block.name)
|
||||
}
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
error("bad_brainsweep", blockAtPos(ctx, this.pos))
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ package at.petrak.hexcasting.api.spell.mishaps
|
|||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import net.minecraft.world.entity.item.ItemEntity
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
|
@ -16,17 +16,15 @@ class MishapBadItem(val item: ItemEntity, val wanted: Component) : Mishap() {
|
|||
item.deltaMovement = item.deltaMovement.add((Math.random() - 0.5) * 0.05, 0.75, (Math.random() - 0.5) * 0.05)
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component {
|
||||
return if (item.item.isEmpty)
|
||||
error("no_item", actionName(errorCtx.action), wanted)
|
||||
else
|
||||
error("bad_item", actionName(errorCtx.action), wanted, item.item.count, item.item.displayName)
|
||||
}
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) = if (item.item.isEmpty)
|
||||
error("no_item", actionName(errorCtx.action), wanted)
|
||||
else
|
||||
error("bad_item", actionName(errorCtx.action), wanted, item.item.count, item.item.displayName)
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun of(item: ItemEntity, stub: String): MishapBadItem {
|
||||
return MishapBadItem(item, TranslatableComponent("hexcasting.mishap.bad_item.$stub"))
|
||||
return MishapBadItem(item, "hexcasting.mishap.bad_item.$stub".asTranslatedComponent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package at.petrak.hexcasting.api.spell.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import net.minecraft.world.InteractionHand
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.item.ItemStack
|
||||
|
@ -14,24 +14,18 @@ class MishapBadOffhandItem(val item: ItemStack, val hand: InteractionHand, val w
|
|||
dyeColor(DyeColor.BROWN)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
||||
val item = ctx.caster.getItemInHand(hand).copy()
|
||||
ctx.caster.setItemInHand(hand, ItemStack.EMPTY.copy())
|
||||
|
||||
val delta = ctx.caster.lookAngle.scale(0.5)
|
||||
yeetItem(item, ctx, delta)
|
||||
yeetHeldItem(ctx, hand)
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component {
|
||||
if (item.isEmpty)
|
||||
return error("no_item.offhand", actionName(errorCtx.action), wanted)
|
||||
|
||||
return error("bad_item.offhand", actionName(errorCtx.action), wanted, item.count, item.displayName)
|
||||
}
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) = if (item.isEmpty)
|
||||
error("no_item.offhand", actionName(errorCtx.action), wanted)
|
||||
else
|
||||
error("bad_item.offhand", actionName(errorCtx.action), wanted, item.count, item.displayName)
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun of(item: ItemStack, hand: InteractionHand, stub: String, vararg args: Any): MishapBadOffhandItem {
|
||||
return MishapBadOffhandItem(item, hand, TranslatableComponent("hexcasting.mishap.bad_item.$stub", *args))
|
||||
return MishapBadOffhandItem(item, hand, "hexcasting.mishap.bad_item.$stub".asTranslatedComponent(*args))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import at.petrak.hexcasting.api.misc.FrozenColorizer
|
|||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapDisallowedSpell : Mishap() {
|
||||
|
@ -17,6 +16,6 @@ class MishapDisallowedSpell : Mishap() {
|
|||
// NO-OP
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
error("disallowed", actionName(errorCtx.action))
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import at.petrak.hexcasting.api.misc.HexDamageSources
|
|||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.Widget
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
|
@ -20,9 +20,8 @@ class MishapDivideByZero(val operand1: Component, val operand2: Component, val s
|
|||
trulyHurt(ctx.caster, HexDamageSources.OVERCAST, ctx.caster.health / 2)
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component {
|
||||
return error("divide_by_zero.$suffix", operand1, operand2)
|
||||
}
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
error("divide_by_zero.$suffix", operand1, operand2)
|
||||
|
||||
companion object {
|
||||
private const val PREFIX = "hexcasting.mishap.divide_by_zero"
|
||||
|
@ -38,25 +37,25 @@ class MishapDivideByZero(val operand1: Component, val operand2: Component, val s
|
|||
fun tan(angle: Double): MishapDivideByZero {
|
||||
val translatedAngle = translate(angle)
|
||||
return MishapDivideByZero(
|
||||
TranslatableComponent("$PREFIX.sin", translatedAngle),
|
||||
TranslatableComponent("$PREFIX.cos", translatedAngle)
|
||||
"$PREFIX.sin".asTranslatedComponent(translatedAngle),
|
||||
"$PREFIX.cos".asTranslatedComponent(translatedAngle)
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
val zero
|
||||
get() = TranslatableComponent("$PREFIX.zero")
|
||||
get() = "$PREFIX.zero".asTranslatedComponent
|
||||
|
||||
@JvmStatic
|
||||
val zerothPower
|
||||
get() = TranslatableComponent("$PREFIX.zero.power")
|
||||
get() = "$PREFIX.zero.power".asTranslatedComponent
|
||||
|
||||
@JvmStatic
|
||||
val zeroVector
|
||||
get() = TranslatableComponent("$PREFIX.zero.vec")
|
||||
get() = "$PREFIX.zero.vec".asTranslatedComponent
|
||||
|
||||
@JvmStatic
|
||||
fun powerOf(power: Component) = TranslatableComponent("$PREFIX.power", power)
|
||||
fun powerOf(power: Component) = "$PREFIX.power".asTranslatedComponent(power)
|
||||
|
||||
@JvmStatic
|
||||
fun powerOf(datum: Any) = when (datum) {
|
||||
|
|
|
@ -1,36 +1,19 @@
|
|||
package at.petrak.hexcasting.api.spell.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.mod.HexItemTags
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.InteractionHand
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.item.ItemStack
|
||||
|
||||
class MishapEntityTooFarAway(val entity: Entity) : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.PINK)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
||||
// Knock the player's items out of their hands
|
||||
val items = mutableListOf<ItemStack>()
|
||||
for (hand in InteractionHand.values()) {
|
||||
if (hand != ctx.castingHand || ctx.caster.getItemInHand(hand).`is`(HexItemTags.WANDS)) {
|
||||
items.add(ctx.caster.getItemInHand(hand).copy())
|
||||
ctx.caster.setItemInHand(hand, ItemStack.EMPTY)
|
||||
}
|
||||
}
|
||||
|
||||
val delta = entity.position().subtract(ctx.position).normalize().scale(0.5)
|
||||
|
||||
for (item in items) {
|
||||
yeetItem(item, ctx, delta)
|
||||
}
|
||||
yeetHeldItemsTowards(ctx, entity.position())
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
error("entity_too_far", SpellDatum.make(entity).display(), actionName(errorCtx.action))
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package at.petrak.hexcasting.api.spell.mishaps
|
|||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapError(val exception: Exception) : Mishap() {
|
||||
|
@ -11,8 +10,9 @@ class MishapError(val exception: Exception) : Mishap() {
|
|||
dyeColor(DyeColor.BLACK)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
error("unknown", actionName(errorCtx.action), exception)
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package at.petrak.hexcasting.api.spell.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapEvalTooDeep : Mishap() {
|
||||
|
@ -14,6 +13,6 @@ class MishapEvalTooDeep : Mishap() {
|
|||
ctx.caster.airSupply -= 290
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
error("eval_too_deep")
|
||||
}
|
||||
|
|
|
@ -1,36 +1,19 @@
|
|||
package at.petrak.hexcasting.api.spell.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.mod.HexItemTags
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.InteractionHand
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.item.ItemStack
|
||||
|
||||
class MishapImmuneEntity(val entity: Entity) : Mishap() {
|
||||
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer =
|
||||
dyeColor(DyeColor.BLUE)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
||||
val items = mutableListOf<ItemStack>()
|
||||
for (hand in InteractionHand.values()) {
|
||||
if (hand != ctx.castingHand || ctx.caster.getItemInHand(hand).`is`(HexItemTags.WANDS)) {
|
||||
items.add(ctx.caster.getItemInHand(hand).copy())
|
||||
ctx.caster.setItemInHand(hand, ItemStack.EMPTY)
|
||||
}
|
||||
}
|
||||
|
||||
val delta = entity.position().subtract(ctx.position).normalize().scale(0.5)
|
||||
|
||||
for (item in items) {
|
||||
yeetItem(item, ctx, delta)
|
||||
}
|
||||
yeetHeldItemsTowards(ctx, entity.position())
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component {
|
||||
return error("immune_entity", actionName(errorCtx.action), entity.displayName)
|
||||
}
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
error("immune_entity", actionName(errorCtx.action), entity.displayName)
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import at.petrak.hexcasting.api.spell.SpellList
|
|||
import at.petrak.hexcasting.api.spell.Widget
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.spell.math.HexPattern
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.entity.item.ItemEntity
|
||||
|
@ -33,14 +33,9 @@ class MishapInvalidIota(
|
|||
stack[stack.size - 1 - reverseIdx] = SpellDatum.make(Widget.GARBAGE)
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||
error(
|
||||
"invalid_value",
|
||||
actionName(errorCtx.action),
|
||||
expected,
|
||||
reverseIdx,
|
||||
perpetrator.display()
|
||||
)
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
error("invalid_value", actionName(errorCtx.action), expected, reverseIdx,
|
||||
perpetrator.display())
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
|
@ -60,7 +55,7 @@ class MishapInvalidIota(
|
|||
|
||||
else -> "unknown"
|
||||
}
|
||||
return MishapInvalidIota(perpetrator, reverseIdx, TranslatableComponent(key))
|
||||
return MishapInvalidIota(perpetrator, reverseIdx, key.asTranslatedComponent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import at.petrak.hexcasting.api.spell.SpellDatum
|
|||
import at.petrak.hexcasting.api.spell.Widget
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.spell.casting.ResolvedPatternType
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapInvalidPattern : Mishap() {
|
||||
|
@ -18,6 +17,6 @@ class MishapInvalidPattern : Mishap() {
|
|||
stack.add(SpellDatum.make(Widget.GARBAGE))
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
error("invalid_pattern")
|
||||
}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package at.petrak.hexcasting.api.spell.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import net.minecraft.Util
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
/**
|
||||
|
@ -15,10 +14,11 @@ class MishapInvalidSpellDatumType(val perpetrator: Any) : Mishap() {
|
|||
dyeColor(DyeColor.BLACK)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
||||
// Send it twice, just to make it clear
|
||||
val msg = this.errorMessage(ctx, errorCtx)
|
||||
ctx.caster.sendMessage(msg, Util.NIL_UUID)
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
error("invalid_spell_datum_type", this.perpetrator.toString(), this.perpetrator.javaClass.typeName)
|
||||
}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package at.petrak.hexcasting.api.spell.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.spell.Widget
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import net.minecraft.network.chat.Component
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.Widget
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
|
@ -16,7 +15,7 @@ class MishapLocationInWrongDimension(val properDimension: ResourceLocation) : Mi
|
|||
stack.add(SpellDatum.make(Widget.GARBAGE))
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||
error("wrong_dimension", actionName(errorCtx.action!!), properDimension.toString(),
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
error("wrong_dimension", actionName(errorCtx.action), properDimension.toString(),
|
||||
ctx.world.dimension().location().toString())
|
||||
}
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
package at.petrak.hexcasting.api.spell.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.mod.HexItemTags
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.InteractionHand
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class MishapLocationTooFarAway(val location: Vec3, val type: String = "too_far") : Mishap() {
|
||||
|
@ -15,22 +11,9 @@ class MishapLocationTooFarAway(val location: Vec3, val type: String = "too_far")
|
|||
dyeColor(DyeColor.MAGENTA)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
||||
// Knock the player's items out of their hands
|
||||
val items = mutableListOf<ItemStack>()
|
||||
for (hand in InteractionHand.values()) {
|
||||
if (hand != ctx.castingHand || ctx.caster.getItemInHand(hand).`is`(HexItemTags.WANDS)) {
|
||||
items.add(ctx.caster.getItemInHand(hand).copy())
|
||||
ctx.caster.setItemInHand(hand, ItemStack.EMPTY)
|
||||
}
|
||||
}
|
||||
|
||||
val delta = location.subtract(ctx.position).normalize().scale(0.5)
|
||||
|
||||
for (item in items) {
|
||||
yeetItem(item, ctx, delta)
|
||||
}
|
||||
yeetHeldItemsTowards(ctx, location)
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||
error("location_$type", SpellDatum.make(location).display(), actionName(errorCtx.action!!))
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
error("location_$type", SpellDatum.make(location).display(), actionName(errorCtx.action))
|
||||
}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package at.petrak.hexcasting.api.spell.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapNoAkashicRecord(val pos: BlockPos) : Mishap() {
|
||||
|
@ -15,6 +14,6 @@ class MishapNoAkashicRecord(val pos: BlockPos) : Mishap() {
|
|||
ctx.caster.giveExperiencePoints(-100)
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
error("no_akashic_record", pos.toShortString())
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package at.petrak.hexcasting.api.spell.mishaps
|
|||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapNoSpellCircle : Mishap() {
|
||||
|
@ -14,6 +13,6 @@ class MishapNoSpellCircle : Mishap() {
|
|||
ctx.caster.inventory.dropAll()
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
error("no_spell_circle", actionName(errorCtx.action))
|
||||
}
|
||||
|
|
|
@ -16,6 +16,6 @@ class MishapNotEnoughArgs(val expected: Int, val got: Int) : Mishap() {
|
|||
stack.add(SpellDatum.make(Widget.GARBAGE))
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
error("not_enough_args", actionName(errorCtx.action), expected, got)
|
||||
}
|
||||
|
|
|
@ -15,11 +15,10 @@ class MishapOthersName(val other: Player) : Mishap() {
|
|||
dyeColor(DyeColor.BLACK)
|
||||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
||||
val effect = MobEffectInstance(MobEffects.BLINDNESS, 20 * 60)
|
||||
ctx.caster.addEffect(effect)
|
||||
ctx.caster.addEffect(MobEffectInstance(MobEffects.BLINDNESS, 20 * 60))
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
error("others_name", other.name)
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -14,6 +14,6 @@ class MishapTooManyCloseParens : Mishap() {
|
|||
stack.add(SpellDatum.make(errorCtx.pattern))
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
error("too_many_close_parens")
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@ package at.petrak.hexcasting.api.spell.mishaps
|
|||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.spell.DatumType
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.SpellList
|
||||
import at.petrak.hexcasting.api.spell.Widget
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
/**
|
||||
|
@ -19,13 +19,17 @@ class MishapUnescapedValue(
|
|||
|
||||
override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList<SpellDatum<*>>) {
|
||||
val idx = stack.indexOfLast { it.getType() == DatumType.LIST }
|
||||
if (idx != -1)
|
||||
stack[idx] = SpellDatum.make(Widget.GARBAGE)
|
||||
if (idx != -1) {
|
||||
val list = stack[idx].payload as SpellList
|
||||
val idxOfIota = list.indexOfFirst { it == perpetrator }
|
||||
if (idxOfIota != -1) {
|
||||
stack[idx] = SpellDatum.make(list.modifyAt(idxOfIota) {
|
||||
SpellList.LPair(SpellDatum.make(Widget.GARBAGE), it.cdr)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
|
||||
error(
|
||||
"unescaped",
|
||||
perpetrator.display()
|
||||
)
|
||||
override fun errorMessage(ctx: CastingContext, errorCtx: Context) =
|
||||
error("unescaped", perpetrator.display())
|
||||
}
|
||||
|
|
|
@ -3,9 +3,11 @@ package at.petrak.hexcasting.api.utils
|
|||
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.math.HexCoord
|
||||
import net.minecraft.ChatFormatting
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.nbt.ListTag
|
||||
import net.minecraft.nbt.LongArrayTag
|
||||
import net.minecraft.network.chat.*
|
||||
import net.minecraft.world.InteractionHand
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.phys.Vec2
|
||||
|
@ -81,6 +83,91 @@ fun pxToCoord(px: Vec2, size: Float, offset: Vec2): HexCoord {
|
|||
HexCoord(q, r + (rf + 0.5 * qf).roundToInt())
|
||||
}
|
||||
|
||||
fun String.withStyle(op: (Style) -> Style): MutableComponent = asTextComponent.withStyle(op)
|
||||
fun String.withStyle(style: Style): MutableComponent = asTextComponent.withStyle(style)
|
||||
fun String.withStyle(formatting: ChatFormatting): MutableComponent = asTextComponent.withStyle(formatting)
|
||||
fun String.withStyle(vararg formatting: ChatFormatting): MutableComponent = asTextComponent.withStyle(*formatting)
|
||||
|
||||
infix fun String.styledWith(op: (Style) -> Style) = withStyle(op)
|
||||
infix fun String.styledWith(style: Style) = withStyle(style)
|
||||
infix fun String.styledWith(formatting: ChatFormatting) = withStyle(formatting)
|
||||
|
||||
infix fun MutableComponent.styledWith(op: (Style) -> Style): MutableComponent = withStyle(op)
|
||||
infix fun MutableComponent.styledWith(style: Style): MutableComponent = withStyle(style)
|
||||
infix fun MutableComponent.styledWith(formatting: ChatFormatting): MutableComponent = withStyle(formatting)
|
||||
|
||||
val String.black get() = this styledWith ChatFormatting.BLACK
|
||||
val MutableComponent.black get() = this styledWith ChatFormatting.BLACK
|
||||
|
||||
val String.darkBlue get() = this styledWith ChatFormatting.DARK_BLUE
|
||||
val MutableComponent.darkBlue get() = this styledWith ChatFormatting.DARK_BLUE
|
||||
|
||||
val String.darkGreen get() = this styledWith ChatFormatting.DARK_GREEN
|
||||
val MutableComponent.darkGreen get() = this styledWith ChatFormatting.DARK_GREEN
|
||||
|
||||
val String.darkAqua get() = this styledWith ChatFormatting.DARK_AQUA
|
||||
val MutableComponent.darkAqua get() = this styledWith ChatFormatting.DARK_AQUA
|
||||
|
||||
val String.darkRed get() = this styledWith ChatFormatting.DARK_RED
|
||||
val MutableComponent.darkRed get() = this styledWith ChatFormatting.DARK_RED
|
||||
|
||||
val String.darkPurple get() = this styledWith ChatFormatting.DARK_PURPLE
|
||||
val MutableComponent.darkPurple get() = this styledWith ChatFormatting.DARK_PURPLE
|
||||
|
||||
val String.gold get() = this styledWith ChatFormatting.GOLD
|
||||
val MutableComponent.gold get() = this styledWith ChatFormatting.GOLD
|
||||
|
||||
val String.gray get() = this styledWith ChatFormatting.GRAY
|
||||
val MutableComponent.gray get() = this styledWith ChatFormatting.GRAY
|
||||
|
||||
val String.darkGray get() = this styledWith ChatFormatting.DARK_GRAY
|
||||
val MutableComponent.darkGray get() = this styledWith ChatFormatting.DARK_GRAY
|
||||
|
||||
val String.blue get() = this styledWith ChatFormatting.BLUE
|
||||
val MutableComponent.blue get() = this styledWith ChatFormatting.BLUE
|
||||
|
||||
val String.green get() = this styledWith ChatFormatting.GREEN
|
||||
val MutableComponent.green get() = this styledWith ChatFormatting.GREEN
|
||||
|
||||
val String.aqua get() = this styledWith ChatFormatting.AQUA
|
||||
val MutableComponent.aqua get() = this styledWith ChatFormatting.AQUA
|
||||
|
||||
val String.red get() = this styledWith ChatFormatting.RED
|
||||
val MutableComponent.red get() = this styledWith ChatFormatting.RED
|
||||
|
||||
val String.lightPurple get() = this styledWith ChatFormatting.LIGHT_PURPLE
|
||||
val MutableComponent.lightPurple get() = this styledWith ChatFormatting.LIGHT_PURPLE
|
||||
|
||||
val String.yellow get() = this styledWith ChatFormatting.YELLOW
|
||||
val MutableComponent.yellow get() = this styledWith ChatFormatting.YELLOW
|
||||
|
||||
val String.white get() = this styledWith ChatFormatting.WHITE
|
||||
val MutableComponent.white get() = this styledWith ChatFormatting.WHITE
|
||||
|
||||
val String.obfuscated get() = this styledWith ChatFormatting.OBFUSCATED
|
||||
val MutableComponent.obfuscated get() = this styledWith ChatFormatting.OBFUSCATED
|
||||
|
||||
val String.bold get() = this styledWith ChatFormatting.BOLD
|
||||
val MutableComponent.bold get() = this styledWith ChatFormatting.BOLD
|
||||
|
||||
val String.strikethrough get() = this styledWith ChatFormatting.STRIKETHROUGH
|
||||
val MutableComponent.strikethrough get() = this styledWith ChatFormatting.STRIKETHROUGH
|
||||
|
||||
val String.underline get() = this styledWith ChatFormatting.UNDERLINE
|
||||
val MutableComponent.underline get() = this styledWith ChatFormatting.UNDERLINE
|
||||
|
||||
val String.italic get() = this styledWith ChatFormatting.ITALIC
|
||||
val MutableComponent.italic get() = this styledWith ChatFormatting.ITALIC
|
||||
|
||||
operator fun MutableComponent.plusAssign(component: Component) {
|
||||
append(component)
|
||||
}
|
||||
|
||||
val String.asTextComponent get() = TextComponent(this)
|
||||
val String.asTranslatedComponent get() = TranslatableComponent(this)
|
||||
|
||||
fun String.asTranslatedComponent(vararg args: Any) = TranslatableComponent(this, *args)
|
||||
|
||||
fun Iterable<SpellDatum<*>>.serializeToNBT(): ListTag {
|
||||
val tag = ListTag()
|
||||
for (elt in this)
|
||||
|
|
|
@ -20,8 +20,10 @@ import net.minecraft.world.item.ItemStack
|
|||
import net.minecraft.world.level.levelgen.XoroshiroRandomSource
|
||||
import net.minecraft.world.level.levelgen.synth.PerlinNoise
|
||||
import net.minecraft.world.phys.Vec2
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.floor
|
||||
import kotlin.math.min
|
||||
import kotlin.math.sin
|
||||
|
||||
/**
|
||||
* Source of perlin noise
|
||||
|
@ -156,18 +158,20 @@ fun drawPatternFromPoints(
|
|||
}
|
||||
}
|
||||
|
||||
fun makeZappy(points: List<Vec2>, hops: Float, variance: Float, speed: Float, flowIrregular: Float) =
|
||||
makeZappy(points, hops.toInt(), variance, speed, flowIrregular)
|
||||
|
||||
/**
|
||||
* Split up a sequence of linePoints with a lightning effect
|
||||
* @param hops: rough number of points to subdivide each segment into
|
||||
* @param speed: rate at which the lightning effect should move/shake/etc
|
||||
*/
|
||||
fun makeZappy(points: List<Vec2>, hops: Float, variance: Float, speed: Float, flowIrregular: Float): List<Vec2> {
|
||||
fun makeZappy(points: List<Vec2>, hops: Int, variance: Float, speed: Float, flowIrregular: Float): List<Vec2> {
|
||||
// Nothing in, nothing out
|
||||
if (points.isEmpty()) {
|
||||
return emptyList()
|
||||
}
|
||||
val scaleVariance = { it: Double -> Math.min(1.0, 8 * (0.5 - Math.abs(0.5 - it))) }
|
||||
val hops = hops.toInt()
|
||||
val scaleVariance = { it: Double -> 1.0.coerceAtMost(8 * (0.5 - abs(0.5 - it))) }
|
||||
val zSeed = ClientTickCounter.total.toDouble() * speed
|
||||
// Create our output list of zap points
|
||||
val zappyPts = mutableListOf(points[0])
|
||||
|
@ -187,7 +191,7 @@ fun makeZappy(points: List<Vec2>, hops: Float, variance: Float, speed: Float, fl
|
|||
// as well as some random variance...
|
||||
// (We use i, j (segment #, subsegment #) as seeds for the Perlin noise,
|
||||
// and zSeed (i.e. time elapsed) to perturb the shape gradually over time)
|
||||
val minorPerturb = NOISE.getValue(i.toDouble(), j.toDouble(), Math.sin(zSeed)) * flowIrregular
|
||||
val minorPerturb = NOISE.getValue(i.toDouble(), j.toDouble(), sin(zSeed)) * flowIrregular
|
||||
val theta = (3 * NOISE.getValue(i.toDouble() + j.toDouble() / (hops + 1) + minorPerturb - zSeed, 1337.0, 0.0) * TAU).toFloat()
|
||||
val r = (NOISE.getValue(i.toDouble() + j.toDouble() / (hops + 1) - zSeed, 69420.0, 0.0) * maxVariance * scaleVariance(progress)).toFloat()
|
||||
val randomHop = Vec2(r * Mth.cos(theta), r * Mth.sin(theta))
|
||||
|
|
|
@ -8,6 +8,7 @@ import at.petrak.hexcasting.api.spell.math.HexAngle
|
|||
import at.petrak.hexcasting.api.spell.math.HexCoord
|
||||
import at.petrak.hexcasting.api.spell.math.HexDir
|
||||
import at.petrak.hexcasting.api.spell.math.HexPattern
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import at.petrak.hexcasting.api.utils.otherHand
|
||||
import at.petrak.hexcasting.client.drawPatternFromPoints
|
||||
import at.petrak.hexcasting.client.drawSpot
|
||||
|
@ -25,7 +26,6 @@ import net.minecraft.client.gui.screens.Screen
|
|||
import net.minecraft.client.renderer.GameRenderer
|
||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.TextComponent
|
||||
import net.minecraft.sounds.SoundSource
|
||||
import net.minecraft.util.Mth
|
||||
import net.minecraft.world.InteractionHand
|
||||
|
@ -38,7 +38,7 @@ class GuiSpellcasting(
|
|||
private val handOpenedWith: InteractionHand,
|
||||
private var patterns: MutableList<ResolvedPattern>,
|
||||
private var stackDescs: List<Component>
|
||||
) : Screen(TextComponent("")) {
|
||||
) : Screen("gui.hexcasting.spellcasting".asTranslatedComponent) {
|
||||
private var drawState: PatternDrawState = PatternDrawState.BetweenPatterns
|
||||
private val usedSpots: MutableSet<HexCoord> = HashSet()
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public class ConjureParticle extends TextureSheetParticle {
|
|||
this.setAlpha(a / 255f * lightness);
|
||||
|
||||
this.friction = 0.96F;
|
||||
this.gravity = light ? -0.01F : 0F;
|
||||
this.gravity = light && dy != 0 && dx != 0 && dz != 0 ? -0.01F : 0F;
|
||||
this.speedUpWhenYMotionIsBlocked = true;
|
||||
this.sprites = pSprites;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
|
|||
import at.petrak.hexcasting.api.spell.casting.SpellContinuation
|
||||
import at.petrak.hexcasting.api.spell.mishaps.MishapInvalidIota
|
||||
import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
|
@ -20,7 +20,7 @@ object OpLastNToList : Operator {
|
|||
throw MishapInvalidIota(
|
||||
datum,
|
||||
0,
|
||||
TranslatableComponent("hexcasting.mishap.invalid_value.int.between", 0, stack.size)
|
||||
"hexcasting.mishap.invalid_value.int.between".asTranslatedComponent(0, stack.size)
|
||||
)
|
||||
}
|
||||
val output = mutableListOf<SpellDatum<*>>()
|
||||
|
|
|
@ -6,7 +6,7 @@ import at.petrak.hexcasting.api.spell.asSpellResult
|
|||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.spell.getChecked
|
||||
import at.petrak.hexcasting.api.spell.mishaps.MishapInvalidIota
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import kotlin.math.acos
|
||||
|
||||
object OpArcCos : ConstManaOperator {
|
||||
|
@ -19,7 +19,7 @@ object OpArcCos : ConstManaOperator {
|
|||
throw MishapInvalidIota(
|
||||
SpellDatum.make(value),
|
||||
0,
|
||||
TranslatableComponent("hexcasting.mishap.invalid_value.double.between", -1, 1)
|
||||
"hexcasting.mishap.invalid_value.double.between".asTranslatedComponent(-1, 1)
|
||||
)
|
||||
return acos(value).asSpellResult
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import at.petrak.hexcasting.api.spell.asSpellResult
|
|||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.spell.getChecked
|
||||
import at.petrak.hexcasting.api.spell.mishaps.MishapInvalidIota
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import kotlin.math.asin
|
||||
|
||||
object OpArcSin : ConstManaOperator {
|
||||
|
@ -19,7 +19,7 @@ object OpArcSin : ConstManaOperator {
|
|||
throw MishapInvalidIota(
|
||||
SpellDatum.make(value),
|
||||
0,
|
||||
TranslatableComponent("hexcasting.mishap.invalid_value.double.between", -1, 1)
|
||||
"hexcasting.mishap.invalid_value.double.between".asTranslatedComponent(-1, 1)
|
||||
)
|
||||
return asin(value).asSpellResult
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ import at.petrak.hexcasting.api.spell.casting.SpellContinuation
|
|||
import at.petrak.hexcasting.api.spell.getChecked
|
||||
import at.petrak.hexcasting.api.spell.mishaps.MishapInvalidIota
|
||||
import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.ln
|
||||
import kotlin.math.roundToInt
|
||||
|
@ -32,7 +32,7 @@ object OpAlwinfyHasAscendedToABeingOfPureMath : Operator {
|
|||
throw MishapInvalidIota(
|
||||
stack.last(),
|
||||
0,
|
||||
TranslatableComponent("hexcasting.mishap.invalid_value.int", 0)
|
||||
"hexcasting.mishap.invalid_value.int".asTranslatedComponent(0)
|
||||
)
|
||||
stack.removeLast()
|
||||
val code = codeDouble.roundToInt()
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package at.petrak.hexcasting.common.casting.operators.stack
|
||||
|
||||
import at.petrak.hexcasting.api.spell.ConstManaOperator
|
||||
import at.petrak.hexcasting.api.spell.getChecked
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.spell.getChecked
|
||||
import at.petrak.hexcasting.api.spell.mishaps.MishapInvalidIota
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
|
@ -20,7 +20,7 @@ object OpDuplicateN : ConstManaOperator {
|
|||
throw MishapInvalidIota(
|
||||
args[1],
|
||||
0,
|
||||
TranslatableComponent("hexcasting.mishap.invalid_value.int.between", 0, args.size)
|
||||
"hexcasting.mishap.invalid_value.int.between".asTranslatedComponent(0, args.size)
|
||||
)
|
||||
|
||||
val count = countDouble.roundToInt()
|
||||
|
|
|
@ -2,13 +2,13 @@ package at.petrak.hexcasting.common.casting.operators.stack
|
|||
|
||||
import at.petrak.hexcasting.api.spell.OperationResult
|
||||
import at.petrak.hexcasting.api.spell.Operator
|
||||
import at.petrak.hexcasting.api.spell.getChecked
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.spell.casting.SpellContinuation
|
||||
import at.petrak.hexcasting.api.spell.getChecked
|
||||
import at.petrak.hexcasting.api.spell.mishaps.MishapInvalidIota
|
||||
import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
|
@ -28,7 +28,7 @@ object OpFisherman : Operator {
|
|||
throw MishapInvalidIota(
|
||||
datum,
|
||||
0,
|
||||
TranslatableComponent("hexcasting.mishap.invalid_value.int.between", 1, stack.size)
|
||||
"hexcasting.mishap.invalid_value.int.between".asTranslatedComponent(1, stack.size)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,13 +3,12 @@ package at.petrak.hexcasting.common.items.magic;
|
|||
import at.petrak.hexcasting.api.item.ManaHolderItem;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.locale.Language;
|
||||
import net.minecraft.network.chat.*;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
|
@ -38,6 +37,7 @@ public class ItemCreativeUnlocker extends Item implements ManaHolderItem {
|
|||
|
||||
@Override
|
||||
public void setMana(ItemStack stack, int mana) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,7 +47,7 @@ public class ItemCreativeUnlocker extends Item implements ManaHolderItem {
|
|||
|
||||
@Override
|
||||
public boolean canRecharge(ItemStack stack) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,15 +56,15 @@ public class ItemCreativeUnlocker extends Item implements ManaHolderItem {
|
|||
}
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand usedHand) {
|
||||
if (level instanceof ServerLevel slevel) {
|
||||
public ItemStack finishUsingItem(ItemStack stack, Level level, LivingEntity consumer) {
|
||||
if (level instanceof ServerLevel slevel && consumer instanceof ServerPlayer player) {
|
||||
var rootAdv = slevel.getServer().getAdvancements().getAdvancement(modLoc("root"));
|
||||
if (rootAdv != null) {
|
||||
var children = new ArrayList<Advancement>();
|
||||
children.add(rootAdv);
|
||||
addChildren(rootAdv, children);
|
||||
|
||||
var adman = ((ServerPlayer) player).getAdvancements();
|
||||
var adman = player.getAdvancements();
|
||||
|
||||
for (var kid : children) {
|
||||
var progress = adman.getOrStartProgress(kid);
|
||||
|
@ -77,14 +77,37 @@ public class ItemCreativeUnlocker extends Item implements ManaHolderItem {
|
|||
}
|
||||
}
|
||||
|
||||
return InteractionResultHolder.success(player.getItemInHand(usedHand));
|
||||
ItemStack copy = stack.copy();
|
||||
super.finishUsingItem(stack, level, consumer);
|
||||
return copy;
|
||||
}
|
||||
|
||||
private static final TextColor HEX_COLOR = TextColor.fromRgb(0xb38ef3);
|
||||
|
||||
private static MutableComponent rainbow(MutableComponent component, int shift, Level level) {
|
||||
if (level == null) {
|
||||
return component.withStyle(ChatFormatting.WHITE);
|
||||
}
|
||||
|
||||
return component.withStyle((s) -> s.withColor(
|
||||
TextColor.fromRgb(Mth.hsvToRgb((level.getGameTime() + shift) * 2 % 360 / 360F, 1F, 1F))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltipComponents,
|
||||
TooltipFlag isAdvanced) {
|
||||
tooltipComponents.add(new TranslatableComponent("item.hexcasting.creative_unlocker.tooltip.0").withStyle(ChatFormatting.GRAY));
|
||||
tooltipComponents.add(new TranslatableComponent("item.hexcasting.creative_unlocker.tooltip.1").withStyle(ChatFormatting.GRAY));
|
||||
String prefix = "item.hexcasting.creative_unlocker.";
|
||||
|
||||
String emphasis = Language.getInstance().getOrDefault(prefix + "for_emphasis");
|
||||
MutableComponent emphasized = new TextComponent("");
|
||||
for (int i = 0; i < emphasis.length(); i++) {
|
||||
emphasized.append(rainbow(new TextComponent("" + emphasis.charAt(i)), i, level));
|
||||
}
|
||||
|
||||
MutableComponent modName = new TranslatableComponent(prefix + "mod_name").withStyle((s) -> s.withColor(HEX_COLOR));
|
||||
|
||||
tooltipComponents.add(new TranslatableComponent(prefix + "tooltip.0", emphasized).withStyle(ChatFormatting.GRAY));
|
||||
tooltipComponents.add(new TranslatableComponent(prefix + "tooltip.1", modName).withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
|
||||
private static void addChildren(Advancement root, List<Advancement> out) {
|
||||
|
|
|
@ -9,10 +9,7 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.food.FoodProperties;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Tiers;
|
||||
import net.minecraft.world.item.*;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.LinkedHashMap;
|
||||
|
@ -58,7 +55,7 @@ public class HexItems {
|
|||
public static final ItemArtifact ARTIFACT = make("artifact", new ItemArtifact(unstackable()));
|
||||
|
||||
public static final ItemJewelerHammer JEWELER_HAMMER = make("jeweler_hammer",
|
||||
new ItemJewelerHammer(Tiers.IRON, 0, -2.8F, props().stacksTo(1)));
|
||||
new ItemJewelerHammer(Tiers.IRON, 0, -2.8F, props().stacksTo(1).defaultDurability(Tiers.DIAMOND.getUses())));
|
||||
|
||||
public static final ItemScroll SCROLL = make("scroll", new ItemScroll(props()));
|
||||
|
||||
|
@ -87,7 +84,9 @@ public class HexItems {
|
|||
new Item(props().food(new FoodProperties.Builder().nutrition(14).saturationMod(1.2f).build())));
|
||||
|
||||
public static final ItemCreativeUnlocker CREATIVE_UNLOCKER = make("creative_unlocker",
|
||||
new ItemCreativeUnlocker(props()));
|
||||
new ItemCreativeUnlocker(unstackable()
|
||||
.rarity(Rarity.EPIC)
|
||||
.food(new FoodProperties.Builder().nutrition(20).saturationMod(1f).alwaysEat().build())));
|
||||
|
||||
//
|
||||
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package at.petrak.hexcasting.mixin.client;
|
||||
|
||||
import at.petrak.hexcasting.common.particles.ConjureParticleOptions;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@Mixin(ClientLevel.class)
|
||||
public abstract class MixinClientLevel {
|
||||
|
||||
@Inject(method = "doAnimateTick",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/Block;animateTick(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Ljava/util/Random;)V"),
|
||||
locals = LocalCapture.CAPTURE_FAILSOFT)
|
||||
public void addBuddingAmethystParticles(int baseX, int baseY, int baseZ, int range, Random rand, Block marked, BlockPos.MutableBlockPos pos, CallbackInfo ci,
|
||||
int trueX, int trueY, int trueZ, BlockState state) {
|
||||
ClientLevel self = ((ClientLevel) (Object) this);
|
||||
|
||||
if (state.is(Blocks.BUDDING_AMETHYST)) {
|
||||
ParticleOptions options = new ConjureParticleOptions(0x8932b8, true);
|
||||
Vec3 center = Vec3.atCenterOf(pos);
|
||||
for (Direction direction : Direction.values()) {
|
||||
int dX = direction.getStepX();
|
||||
int dY = direction.getStepY();
|
||||
int dZ = direction.getStepZ();
|
||||
|
||||
int count = rand.nextInt(10) / 5;
|
||||
for (int i = 0; i < count; i++) {
|
||||
double pX = center.x + (dX == 0 ? Mth.nextDouble(rand, -0.5D, 0.5D) : (double) dX * 0.55D);
|
||||
double pY = center.y + (dY == 0 ? Mth.nextDouble(rand, -0.5D, 0.5D) : (double) dY * 0.55D);
|
||||
double pZ = center.z + (dZ == 0 ? Mth.nextDouble(rand, -0.5D, 0.5D) : (double) dZ * 0.55D);
|
||||
self.addParticle(options, pX, pY, pZ, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -57,9 +57,11 @@
|
|||
"item.hexcasting.pride_colorizer_12": "Intersex Pigment",
|
||||
"item.hexcasting.pride_colorizer_13": "Aroace Pigment",
|
||||
"item.hexcasting.uuid_colorizer": "Soulglimmer Pigment",
|
||||
"item.hexcasting.creative_unlocker": "Creative Unlocker",
|
||||
"item.hexcasting.creative_unlocker.tooltip.0": "Contains INFINITE MEDIA.",
|
||||
"item.hexcasting.creative_unlocker.tooltip.1": "Right-click to unlock all Hexcasting advancements and abilities.",
|
||||
"item.hexcasting.creative_unlocker": "The Media Cube",
|
||||
"item.hexcasting.creative_unlocker.tooltip.0": "Contains %s.",
|
||||
"item.hexcasting.creative_unlocker.for_emphasis": "INFINITE MEDIA",
|
||||
"item.hexcasting.creative_unlocker.tooltip.1": "Consume to unlock all %s knowledge.",
|
||||
"item.hexcasting.creative_unlocker.mod_name": "Hexcasting",
|
||||
|
||||
|
||||
"block.hexcasting.conjured": "Conjured Block",
|
||||
|
@ -130,21 +132,23 @@
|
|||
"hexcasting.spelldata.entity.whoknows": "An Entity (this should only show up if this was stored before the 0.5.0 update, use Scribe's Reflection, Scribe's Gambit to fix)",
|
||||
"hexcasting.spelldata.akashic.nopos": "The owning record does not know of any iota here (this is a bug)",
|
||||
|
||||
"gui.hexcasting.spellcasting": "Hex Grid",
|
||||
|
||||
"advancement.hexcasting:root": "Hexcasting Research",
|
||||
"advancement.hexcasting:root.desc": "Find a concentrated form of media growing deep beneath the earth.",
|
||||
"advancement.hexcasting:enlightenment": "Achieve Enlightenment",
|
||||
"advancement.hexcasting:enlightenment.desc": "Go nearly insane from casting a hex from almost all of your health.",
|
||||
"advancement.hexcasting:enlightenment.desc": "Go nearly insane from casting a hex using almost all of your health.",
|
||||
"advancement.hexcasting:wasteful_cast": "Waste Not...",
|
||||
"advancement.hexcasting:wasteful_cast.desc": "Waste a large amount of media when casting a hex.",
|
||||
"advancement.hexcasting:big_cast": "... Want Not",
|
||||
"advancement.hexcasting:big_cast.desc": "Cast a spell requiring a truly huge amount of media.",
|
||||
"advancement.hexcasting:big_cast.desc": "Cast a single spell requiring a truly huge amount of media.",
|
||||
"advancement.hexcasting:y_u_no_cast_angy": "Blind Diversion",
|
||||
"advancement.hexcasting:y_u_no_cast_angy.desc": "Try to cast a spell from a scroll, but fail.",
|
||||
"advancement.hexcasting:opened_eyes": "Opened Eyes",
|
||||
"advancement.hexcasting:opened_eyes.desc": "Have nature take a piece of your mind in payment for a hex.",
|
||||
|
||||
"stat.hexcasting.mana_used": "Media consumed (in dust)",
|
||||
"stat.hexcasting.mana_overcasted": "Media overcast (in dust)",
|
||||
"stat.hexcasting.mana_used": "Media Consumed (in dust)",
|
||||
"stat.hexcasting.mana_overcasted": "Media Overcast (in dust)",
|
||||
"stat.hexcasting.patterns_drawn": "Patterns Drawn",
|
||||
"stat.hexcasting.spells_cast": "Spells Cast",
|
||||
|
||||
|
|
|
@ -5,8 +5,19 @@
|
|||
"refmap": "hexcasting.mixins.refmap.json",
|
||||
"package": "at.petrak.hexcasting.mixin",
|
||||
"mixins": [
|
||||
"MixinMob", "MixinRaider", "MixinReloadableServerResources", "MixinVillager", "MixinWitch",
|
||||
"accessor.AccessorLivingEntity", "accessor.AccessorLootTable", "accessor.AccessorRecipeProvider",
|
||||
"accessor.AccessorTagsProvider", "accessor.AccessorUseOnContext", "accessor.CriteriaTriggersAccessor"
|
||||
"MixinMob",
|
||||
"MixinRaider",
|
||||
"MixinReloadableServerResources",
|
||||
"MixinVillager",
|
||||
"MixinWitch",
|
||||
"accessor.AccessorLivingEntity",
|
||||
"accessor.AccessorLootTable",
|
||||
"accessor.AccessorRecipeProvider",
|
||||
"accessor.AccessorTagsProvider",
|
||||
"accessor.AccessorUseOnContext",
|
||||
"accessor.CriteriaTriggersAccessor"
|
||||
],
|
||||
"client": [
|
||||
"client.MixinClientLevel"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import net.minecraft.commands.synchronization.EmptyArgumentSerializer
|
|||
import net.minecraft.core.Registry
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.InteractionResult
|
||||
import net.minecraft.world.level.storage.loot.LootPool
|
||||
import java.util.function.BiConsumer
|
||||
|
||||
object FabricHexInitializer : ModInitializer {
|
||||
|
@ -68,11 +67,10 @@ object FabricHexInitializer : ModInitializer {
|
|||
|
||||
CommandRegistrationCallback.EVENT.register { dp, _ -> HexCommands.register(dp) }
|
||||
|
||||
LootTableLoadingCallback.EVENT.register { recman, manager, id, supplier, setter ->
|
||||
LootTableLoadingCallback.EVENT.register { _, _, id, supplier, _ ->
|
||||
HexLootHandler.lootLoad(
|
||||
id,
|
||||
{ b: LootPool -> supplier.withPool(b) },
|
||||
)
|
||||
) { supplier.withPool(it) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue