start work on making sounds badnt

This commit is contained in:
petrak@ 2022-11-21 17:55:36 -06:00
parent 979fc3aa35
commit 7699a5e468
43 changed files with 277 additions and 222 deletions

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.addldata; package at.petrak.hexcasting.api.addldata;
import at.petrak.hexcasting.api.spell.iota.Iota; import at.petrak.hexcasting.api.spell.iota.Iota;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;

View file

@ -4,7 +4,7 @@ import at.petrak.hexcasting.api.spell.iota.Iota;
import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.api.utils.NBTHelper; import at.petrak.hexcasting.api.utils.NBTHelper;
import at.petrak.hexcasting.client.ClientTickCounter; import at.petrak.hexcasting.client.ClientTickCounter;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils; import net.minecraft.nbt.NbtUtils;

View file

@ -1,8 +1,8 @@
package at.petrak.hexcasting.api.spell package 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.casting.OperatorSideEffect
import at.petrak.hexcasting.api.spell.casting.SpellContinuation import at.petrak.hexcasting.api.spell.casting.SpellContinuation
import at.petrak.hexcasting.api.spell.casting.sideeffects.OperatorSideEffect
import at.petrak.hexcasting.api.spell.iota.Iota import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell package at.petrak.hexcasting.api.spell
import at.petrak.hexcasting.api.spell.casting.OperatorSideEffect
import at.petrak.hexcasting.api.spell.casting.SpellContinuation import at.petrak.hexcasting.api.spell.casting.SpellContinuation
import at.petrak.hexcasting.api.spell.casting.sideeffects.OperatorSideEffect
import at.petrak.hexcasting.api.spell.iota.Iota import at.petrak.hexcasting.api.spell.iota.Iota
/** /**

View file

@ -1,8 +1,8 @@
package at.petrak.hexcasting.api.spell package 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.casting.OperatorSideEffect
import at.petrak.hexcasting.api.spell.casting.SpellContinuation import at.petrak.hexcasting.api.spell.casting.SpellContinuation
import at.petrak.hexcasting.api.spell.casting.sideeffects.OperatorSideEffect
import at.petrak.hexcasting.api.spell.iota.Iota import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs

View file

@ -12,6 +12,7 @@ import at.petrak.hexcasting.api.mod.HexStatistics
import at.petrak.hexcasting.api.spell.Action import at.petrak.hexcasting.api.spell.Action
import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.ParticleSpray
import at.petrak.hexcasting.api.spell.SpellList import at.petrak.hexcasting.api.spell.SpellList
import at.petrak.hexcasting.api.spell.casting.sideeffects.OperatorSideEffect
import at.petrak.hexcasting.api.spell.iota.Iota import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.iota.ListIota import at.petrak.hexcasting.api.spell.iota.ListIota
import at.petrak.hexcasting.api.spell.iota.PatternIota import at.petrak.hexcasting.api.spell.iota.PatternIota
@ -19,7 +20,7 @@ import at.petrak.hexcasting.api.spell.math.HexDir
import at.petrak.hexcasting.api.spell.math.HexPattern import at.petrak.hexcasting.api.spell.math.HexPattern
import at.petrak.hexcasting.api.spell.mishaps.* import at.petrak.hexcasting.api.spell.mishaps.*
import at.petrak.hexcasting.api.utils.* import at.petrak.hexcasting.api.utils.*
import at.petrak.hexcasting.common.lib.HexIotaTypes import at.petrak.hexcasting.common.lib.hex.HexIotaTypes
import at.petrak.hexcasting.xplat.IXplatAbstractions import at.petrak.hexcasting.xplat.IXplatAbstractions
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.CompoundTag
@ -382,6 +383,7 @@ class CastingHarness private constructor(
escapeNext = true, escapeNext = true,
) to ResolvedPatternType.EVALUATED ) to ResolvedPatternType.EVALUATED
} }
SpecialPatterns.INTROSPECTION.anglesSignature() -> { SpecialPatterns.INTROSPECTION.anglesSignature() -> {
// we have escaped the parens onto the stack; we just also record our count. // we have escaped the parens onto the stack; we just also record our count.
val newParens = this.parenthesized.toMutableList() val newParens = this.parenthesized.toMutableList()
@ -391,6 +393,7 @@ class CastingHarness private constructor(
parenCount = this.parenCount + 1 parenCount = this.parenCount + 1
) to if (this.parenCount == 0) ResolvedPatternType.EVALUATED else ResolvedPatternType.ESCAPED ) to if (this.parenCount == 0) ResolvedPatternType.EVALUATED else ResolvedPatternType.ESCAPED
} }
SpecialPatterns.RETROSPECTION.anglesSignature() -> { SpecialPatterns.RETROSPECTION.anglesSignature() -> {
val newParenCount = this.parenCount - 1 val newParenCount = this.parenCount - 1
displayDepth-- displayDepth--
@ -415,6 +418,7 @@ class CastingHarness private constructor(
) to ResolvedPatternType.ESCAPED ) to ResolvedPatternType.ESCAPED
} }
} }
else -> { else -> {
val newParens = this.parenthesized.toMutableList() val newParens = this.parenthesized.toMutableList()
newParens.add(iota) newParens.add(iota)
@ -438,14 +442,17 @@ class CastingHarness private constructor(
escapeNext = true escapeNext = true
) to ResolvedPatternType.EVALUATED ) to ResolvedPatternType.EVALUATED
} }
SpecialPatterns.INTROSPECTION.anglesSignature() -> { SpecialPatterns.INTROSPECTION.anglesSignature() -> {
this.getFunctionalData().copy( this.getFunctionalData().copy(
parenCount = this.parenCount + 1 parenCount = this.parenCount + 1
) to ResolvedPatternType.EVALUATED ) to ResolvedPatternType.EVALUATED
} }
SpecialPatterns.RETROSPECTION.anglesSignature() -> { SpecialPatterns.RETROSPECTION.anglesSignature() -> {
throw MishapTooManyCloseParens() throw MishapTooManyCloseParens()
} }
else -> { else -> {
null null
} }

View file

@ -8,7 +8,7 @@ import at.petrak.hexcasting.api.utils.NBTBuilder
import at.petrak.hexcasting.api.utils.getList import at.petrak.hexcasting.api.utils.getList
import at.petrak.hexcasting.api.utils.hasList import at.petrak.hexcasting.api.utils.hasList
import at.petrak.hexcasting.api.utils.serializeToNBT import at.petrak.hexcasting.api.utils.serializeToNBT
import at.petrak.hexcasting.common.lib.HexIotaTypes import at.petrak.hexcasting.common.lib.hex.HexIotaTypes
import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.CompoundTag
import net.minecraft.nbt.Tag import net.minecraft.nbt.Tag
import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerLevel
@ -194,6 +194,7 @@ sealed interface ContinuationFrame {
world world
)!!.list )!!.list
) )
"end" -> FinishEval "end" -> FinishEval
"foreach" -> ForEach( "foreach" -> ForEach(
HexIotaTypes.LIST.deserialize(tag.getList("data", Tag.TAG_COMPOUND), world)!!.list, HexIotaTypes.LIST.deserialize(tag.getList("data", Tag.TAG_COMPOUND), world)!!.list,
@ -207,6 +208,7 @@ sealed interface ContinuationFrame {
world world
)!!.list.toMutableList() )!!.list.toMutableList()
) )
else -> Evaluate(SpellList.LList(0, listOf())) else -> Evaluate(SpellList.LList(0, listOf()))
} }
} }

View file

@ -1,34 +0,0 @@
package at.petrak.hexcasting.api.spell.casting
import at.petrak.hexcasting.common.lib.HexSounds
import net.minecraft.sounds.SoundEvent
/**
* Sound that plays as a side-effect-adjacent when casting
*/
enum class EvalSound {
/** Silence */
NONE,
/** The generic "bvwonh" sound for non-spell ops */
GENERIC,
/** The "bwoink!" for spell ops */
SPELL_BOINK,
/** The "gvwoh" for mishaps */
MISHAP;
/**
* Which sound type has the greater priority?
*/
fun greaterOf(that: EvalSound): EvalSound =
EvalSound.values()[maxOf(this.ordinal, that.ordinal)]
fun soundEvent(): SoundEvent? = when (this) {
NONE -> null
GENERIC -> HexSounds.ADD_PATTERN
SPELL_BOINK -> HexSounds.ACTUALLY_CAST
MISHAP -> HexSounds.FAIL_PATTERN
}
}

View file

@ -0,0 +1,15 @@
package at.petrak.hexcasting.api.spell.casting.sideeffects;
import net.minecraft.sounds.SoundEvent;
import org.jetbrains.annotations.Nullable;
/**
* The kind of sound that plays after a cast.
*
* @param sound the actual sound file
* @param priority the priority of this sound. the sound with the highest priority in a given cast will be
* playd.
* shortcutMetacasting takes precedence over this.
*/
public record EvalSound(@Nullable SoundEvent sound, int priority) {
}

View file

@ -1,4 +1,4 @@
package at.petrak.hexcasting.api.spell.casting package at.petrak.hexcasting.api.spell.casting.sideeffects
import at.petrak.hexcasting.api.advancements.HexAdvancementTriggers import at.petrak.hexcasting.api.advancements.HexAdvancementTriggers
import at.petrak.hexcasting.api.block.circle.BlockEntityAbstractImpetus import at.petrak.hexcasting.api.block.circle.BlockEntityAbstractImpetus
@ -6,6 +6,7 @@ import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.mod.HexStatistics import at.petrak.hexcasting.api.mod.HexStatistics
import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.ParticleSpray
import at.petrak.hexcasting.api.spell.RenderedSpell import at.petrak.hexcasting.api.spell.RenderedSpell
import at.petrak.hexcasting.api.spell.casting.CastingHarness
import at.petrak.hexcasting.api.spell.mishaps.Mishap import at.petrak.hexcasting.api.spell.mishaps.Mishap
import at.petrak.hexcasting.api.utils.asTranslatedComponent import at.petrak.hexcasting.api.utils.asTranslatedComponent
import at.petrak.hexcasting.common.lib.HexItems import at.petrak.hexcasting.common.lib.HexItems

View file

@ -0,0 +1,10 @@
package at.petrak.hexcasting.api.spell.casting.sideeffects
/**
* Package for all the side effects that happen during one cast.
*
* This lives outside of nested evaluations so we don't get giant sound spam
*/
class SideEffectsTracker private constructor(private val ops: MutableList<OperatorSideEffect>, private var sound: EvalSound) {
public constructor() : this(mutableListOf(), EvalSound.NONE)
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.iota; package at.petrak.hexcasting.api.spell.iota;
import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.nbt.ByteTag; import net.minecraft.nbt.ByteTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.iota; package at.petrak.hexcasting.api.spell.iota;
import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.nbt.DoubleTag; import net.minecraft.nbt.DoubleTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.iota; package at.petrak.hexcasting.api.spell.iota;
import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils; import net.minecraft.nbt.NbtUtils;

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.api.spell.iota; package at.petrak.hexcasting.api.spell.iota;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.api.spell.iota; package at.petrak.hexcasting.api.spell.iota;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.api.spell.iota; package at.petrak.hexcasting.api.spell.iota;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import net.minecraft.client.gui.Font; import net.minecraft.client.gui.Font;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.api.spell.iota;
import at.petrak.hexcasting.api.spell.SpellList; import at.petrak.hexcasting.api.spell.SpellList;
import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.Font; import net.minecraft.client.gui.Font;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
@ -117,7 +117,8 @@ public class ListIota extends Iota {
// We aim to not break one iota between lines // We aim to not break one iota between lines
var listTag = HexUtils.downcast(tag, ListTag.TYPE); var listTag = HexUtils.downcast(tag, ListTag.TYPE);
var start = FormattedCharSequence.forward(listTag.isEmpty() ? "[]" : "[", Style.EMPTY.withColor(ChatFormatting.DARK_PURPLE)); var start = FormattedCharSequence.forward(listTag.isEmpty() ? "[]" : "[",
Style.EMPTY.withColor(ChatFormatting.DARK_PURPLE));
var cursor = font.width(start); var cursor = font.width(start);
var currentLine = new ArrayList<>(List.of(start)); var currentLine = new ArrayList<>(List.of(start));
var out = new ArrayList<FormattedCharSequence>(); var out = new ArrayList<FormattedCharSequence>();

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.api.spell.iota; package at.petrak.hexcasting.api.spell.iota;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
@ -15,7 +15,8 @@ import org.jetbrains.annotations.Nullable;
public class NullIota extends Iota { public class NullIota extends Iota {
private static final Object NULL_SUBSTITUTE = new Object(); private static final Object NULL_SUBSTITUTE = new Object();
public static final Component DISPLAY = Component.translatable("hexcasting.tooltip.null_iota").withStyle(ChatFormatting.GRAY); public static final Component DISPLAY =
Component.translatable("hexcasting.tooltip.null_iota").withStyle(ChatFormatting.GRAY);
public NullIota() { public NullIota() {
// We have to pass *something* here, but there's nothing that actually needs to go there, // We have to pass *something* here, but there's nothing that actually needs to go there,

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.api.spell.iota;
import at.petrak.hexcasting.api.spell.math.HexPattern; import at.petrak.hexcasting.api.spell.math.HexPattern;
import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.spell.iota; package at.petrak.hexcasting.api.spell.iota;
import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.nbt.LongArrayTag; import net.minecraft.nbt.LongArrayTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;

View file

@ -5,7 +5,7 @@ package at.petrak.hexcasting.api.utils
import at.petrak.hexcasting.api.spell.iota.Iota import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.iota.ListIota import at.petrak.hexcasting.api.spell.iota.ListIota
import at.petrak.hexcasting.api.spell.math.HexCoord import at.petrak.hexcasting.api.spell.math.HexCoord
import at.petrak.hexcasting.common.lib.HexIotaTypes import at.petrak.hexcasting.common.lib.hex.HexIotaTypes
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.nbt.* import net.minecraft.nbt.*
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component

View file

@ -18,7 +18,7 @@ import at.petrak.hexcasting.common.items.magic.ItemMediaBattery;
import at.petrak.hexcasting.common.items.magic.ItemPackagedHex; import at.petrak.hexcasting.common.items.magic.ItemPackagedHex;
import at.petrak.hexcasting.common.lib.HexBlockEntities; import at.petrak.hexcasting.common.lib.HexBlockEntities;
import at.petrak.hexcasting.common.lib.HexBlocks; import at.petrak.hexcasting.common.lib.HexBlocks;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import at.petrak.hexcasting.common.lib.HexItems; import at.petrak.hexcasting.common.lib.HexItems;
import at.petrak.hexcasting.xplat.IClientXplatAbstractions; import at.petrak.hexcasting.xplat.IClientXplatAbstractions;
import com.mojang.datafixers.util.Pair; import com.mojang.datafixers.util.Pair;
@ -56,11 +56,11 @@ import java.util.function.UnaryOperator;
public class RegisterClientStuff { public class RegisterClientStuff {
public static void init() { public static void init() {
registerDataHolderOverrides(HexItems.FOCUS, registerDataHolderOverrides(HexItems.FOCUS,
stack -> HexItems.FOCUS.readIotaTag(stack) != null, stack -> HexItems.FOCUS.readIotaTag(stack) != null,
ItemFocus::isSealed); ItemFocus::isSealed);
registerDataHolderOverrides(HexItems.SPELLBOOK, registerDataHolderOverrides(HexItems.SPELLBOOK,
stack -> HexItems.SPELLBOOK.readIotaTag(stack) != null, stack -> HexItems.SPELLBOOK.readIotaTag(stack) != null,
ItemSpellbook::isSealed); ItemSpellbook::isSealed);
registerPackagedSpellOverrides(HexItems.CYPHER); registerPackagedSpellOverrides(HexItems.CYPHER);
registerPackagedSpellOverrides(HexItems.TRINKET); registerPackagedSpellOverrides(HexItems.TRINKET);
@ -68,23 +68,23 @@ public class RegisterClientStuff {
var x = IClientXplatAbstractions.INSTANCE; var x = IClientXplatAbstractions.INSTANCE;
x.registerItemProperty(HexItems.BATTERY, ItemMediaBattery.MEDIA_PREDICATE, x.registerItemProperty(HexItems.BATTERY, ItemMediaBattery.MEDIA_PREDICATE,
(stack, level, holder, holderID) -> { (stack, level, holder, holderID) -> {
var item = (MediaHolderItem) stack.getItem(); var item = (MediaHolderItem) stack.getItem();
return item.getMediaFullness(stack); return item.getMediaFullness(stack);
}); });
x.registerItemProperty(HexItems.BATTERY, ItemMediaBattery.MAX_MEDIA_PREDICATE, x.registerItemProperty(HexItems.BATTERY, ItemMediaBattery.MAX_MEDIA_PREDICATE,
(stack, level, holder, holderID) -> { (stack, level, holder, holderID) -> {
var item = (ItemMediaBattery) stack.getItem(); var item = (ItemMediaBattery) stack.getItem();
var max = item.getMaxMedia(stack); var max = item.getMaxMedia(stack);
return (float) Math.sqrt((float) max / MediaConstants.CRYSTAL_UNIT / 10); return (float) Math.sqrt((float) max / MediaConstants.CRYSTAL_UNIT / 10);
}); });
registerScrollOverrides(HexItems.SCROLL_SMOL); registerScrollOverrides(HexItems.SCROLL_SMOL);
registerScrollOverrides(HexItems.SCROLL_MEDIUM); registerScrollOverrides(HexItems.SCROLL_MEDIUM);
registerScrollOverrides(HexItems.SCROLL_LARGE); registerScrollOverrides(HexItems.SCROLL_LARGE);
x.registerItemProperty(HexItems.SLATE, ItemSlate.WRITTEN_PRED, x.registerItemProperty(HexItems.SLATE, ItemSlate.WRITTEN_PRED,
(stack, level, holder, holderID) -> ItemSlate.hasPattern(stack) ? 1f : 0f); (stack, level, holder, holderID) -> ItemSlate.hasPattern(stack) ? 1f : 0f);
registerWandOverrides(HexItems.STAFF_OAK); registerWandOverrides(HexItems.STAFF_OAK);
registerWandOverrides(HexItems.STAFF_BIRCH); registerWandOverrides(HexItems.STAFF_BIRCH);
@ -158,117 +158,117 @@ public class RegisterClientStuff {
private static void addScryingLensStuff() { private static void addScryingLensStuff() {
ScryingLensOverlayRegistry.addPredicateDisplayer( ScryingLensOverlayRegistry.addPredicateDisplayer(
(state, pos, observer, world, direction) -> state.getBlock() instanceof BlockAbstractImpetus, (state, pos, observer, world, direction) -> state.getBlock() instanceof BlockAbstractImpetus,
(lines, state, pos, observer, world, direction) -> { (lines, state, pos, observer, world, direction) -> {
if (world.getBlockEntity(pos) instanceof BlockEntityAbstractImpetus beai) { if (world.getBlockEntity(pos) instanceof BlockEntityAbstractImpetus beai) {
beai.applyScryingLensOverlay(lines, state, pos, observer, world, direction); beai.applyScryingLensOverlay(lines, state, pos, observer, world, direction);
} }
}); });
ScryingLensOverlayRegistry.addDisplayer(Blocks.NOTE_BLOCK, ScryingLensOverlayRegistry.addDisplayer(Blocks.NOTE_BLOCK,
(lines, state, pos, observer, world, direction) -> { (lines, state, pos, observer, world, direction) -> {
int note = state.getValue(NoteBlock.NOTE); int note = state.getValue(NoteBlock.NOTE);
float rCol = Math.max(0.0F, Mth.sin((note / 24F + 0.0F) * Mth.TWO_PI) * 0.65F + 0.35F); float rCol = Math.max(0.0F, Mth.sin((note / 24F + 0.0F) * Mth.TWO_PI) * 0.65F + 0.35F);
float gCol = Math.max(0.0F, Mth.sin((note / 24F + 0.33333334F) * Mth.TWO_PI) * 0.65F + 0.35F); float gCol = Math.max(0.0F, Mth.sin((note / 24F + 0.33333334F) * Mth.TWO_PI) * 0.65F + 0.35F);
float bCol = Math.max(0.0F, Mth.sin((note / 24F + 0.6666667F) * Mth.TWO_PI) * 0.65F + 0.35F); float bCol = Math.max(0.0F, Mth.sin((note / 24F + 0.6666667F) * Mth.TWO_PI) * 0.65F + 0.35F);
int noteColor = 0xFF_000000 | Mth.color(rCol, gCol, bCol); int noteColor = 0xFF_000000 | Mth.color(rCol, gCol, bCol);
var instrument = state.getValue(NoteBlock.INSTRUMENT); var instrument = state.getValue(NoteBlock.INSTRUMENT);
lines.add(new Pair<>( lines.add(new Pair<>(
new ItemStack(Items.MUSIC_DISC_CHIRP), new ItemStack(Items.MUSIC_DISC_CHIRP),
Component.literal(String.valueOf(instrument.ordinal())) Component.literal(String.valueOf(instrument.ordinal()))
.withStyle(color(instrumentColor(instrument))))); .withStyle(color(instrumentColor(instrument)))));
lines.add(new Pair<>( lines.add(new Pair<>(
new ItemStack(Items.NOTE_BLOCK), new ItemStack(Items.NOTE_BLOCK),
Component.literal(String.valueOf(note)) Component.literal(String.valueOf(note))
.withStyle(color(noteColor)))); .withStyle(color(noteColor))));
}); });
ScryingLensOverlayRegistry.addDisplayer(HexBlocks.AKASHIC_BOOKSHELF, ScryingLensOverlayRegistry.addDisplayer(HexBlocks.AKASHIC_BOOKSHELF,
(lines, state, pos, observer, world, direction) -> { (lines, state, pos, observer, world, direction) -> {
if (world.getBlockEntity(pos) instanceof BlockEntityAkashicBookshelf tile) { if (world.getBlockEntity(pos) instanceof BlockEntityAkashicBookshelf tile) {
var iotaTag = tile.getIotaTag(); var iotaTag = tile.getIotaTag();
if (iotaTag != null) { if (iotaTag != null) {
var display = HexIotaTypes.getDisplay(iotaTag); var display = HexIotaTypes.getDisplay(iotaTag);
lines.add(new Pair<>(new ItemStack(Items.BOOK), display)); lines.add(new Pair<>(new ItemStack(Items.BOOK), display));
}
} }
}); }
});
ScryingLensOverlayRegistry.addDisplayer(Blocks.COMPARATOR, ScryingLensOverlayRegistry.addDisplayer(Blocks.COMPARATOR,
(lines, state, pos, observer, world, direction) -> { (lines, state, pos, observer, world, direction) -> {
int comparatorValue = ScryingLensOverlayRegistry.getComparatorValue(true); int comparatorValue = ScryingLensOverlayRegistry.getComparatorValue(true);
lines.add(new Pair<>( lines.add(new Pair<>(
new ItemStack(Items.REDSTONE), new ItemStack(Items.REDSTONE),
Component.literal(comparatorValue == -1 ? "" : String.valueOf(comparatorValue)) Component.literal(comparatorValue == -1 ? "" : String.valueOf(comparatorValue))
.withStyle(redstoneColor(comparatorValue)))); .withStyle(redstoneColor(comparatorValue))));
boolean compare = state.getValue(ComparatorBlock.MODE) == ComparatorMode.COMPARE; boolean compare = state.getValue(ComparatorBlock.MODE) == ComparatorMode.COMPARE;
lines.add(new Pair<>( lines.add(new Pair<>(
new ItemStack(Items.REDSTONE_TORCH), new ItemStack(Items.REDSTONE_TORCH),
Component.literal(compare ? ">=" : "-") Component.literal(compare ? ">=" : "-")
.withStyle(redstoneColor(compare ? 0 : 15)))); .withStyle(redstoneColor(compare ? 0 : 15))));
}); });
ScryingLensOverlayRegistry.addDisplayer(Blocks.POWERED_RAIL, ScryingLensOverlayRegistry.addDisplayer(Blocks.POWERED_RAIL,
(lines, state, pos, observer, world, direction) -> { (lines, state, pos, observer, world, direction) -> {
int power = getPoweredRailStrength(world, pos, state); int power = getPoweredRailStrength(world, pos, state);
lines.add(new Pair<>( lines.add(new Pair<>(
new ItemStack(Items.POWERED_RAIL), new ItemStack(Items.POWERED_RAIL),
Component.literal(String.valueOf(power)) Component.literal(String.valueOf(power))
.withStyle(redstoneColor(power, 9)))); .withStyle(redstoneColor(power, 9))));
}); });
ScryingLensOverlayRegistry.addDisplayer(Blocks.REPEATER, ScryingLensOverlayRegistry.addDisplayer(Blocks.REPEATER,
(lines, state, pos, observer, world, direction) -> lines.add(new Pair<>( (lines, state, pos, observer, world, direction) -> lines.add(new Pair<>(
new ItemStack(Items.CLOCK), new ItemStack(Items.CLOCK),
Component.literal(String.valueOf(state.getValue(RepeaterBlock.DELAY))) Component.literal(String.valueOf(state.getValue(RepeaterBlock.DELAY)))
.withStyle(ChatFormatting.YELLOW)))); .withStyle(ChatFormatting.YELLOW))));
ScryingLensOverlayRegistry.addPredicateDisplayer( ScryingLensOverlayRegistry.addPredicateDisplayer(
(state, pos, observer, world, direction) -> state.getBlock() instanceof BeehiveBlock, (state, pos, observer, world, direction) -> state.getBlock() instanceof BeehiveBlock,
(lines, state, pos, observer, world, direction) -> { (lines, state, pos, observer, world, direction) -> {
int count = ScryingLensOverlayRegistry.getBeeValue(); int count = ScryingLensOverlayRegistry.getBeeValue();
lines.add(new Pair<>(new ItemStack(Items.BEE_NEST), count == -1 ? Component.empty() : lines.add(new Pair<>(new ItemStack(Items.BEE_NEST), count == -1 ? Component.empty() :
Component.translatable( Component.translatable(
"hexcasting.tooltip.lens.bee" + (count == 1 ? ".single" : ""), "hexcasting.tooltip.lens.bee" + (count == 1 ? ".single" : ""),
count count
))); )));
}); });
ScryingLensOverlayRegistry.addPredicateDisplayer( ScryingLensOverlayRegistry.addPredicateDisplayer(
(state, pos, observer, world, direction) -> state.isSignalSource() && !state.is( (state, pos, observer, world, direction) -> state.isSignalSource() && !state.is(
Blocks.COMPARATOR), Blocks.COMPARATOR),
(lines, state, pos, observer, world, direction) -> { (lines, state, pos, observer, world, direction) -> {
int signalStrength = 0; int signalStrength = 0;
if (state.getBlock() instanceof RedStoneWireBlock) { if (state.getBlock() instanceof RedStoneWireBlock) {
signalStrength = state.getValue(RedStoneWireBlock.POWER); signalStrength = state.getValue(RedStoneWireBlock.POWER);
} else { } else {
for (Direction dir : Direction.values()) { for (Direction dir : Direction.values()) {
signalStrength = Math.max(signalStrength, state.getSignal(world, pos, dir)); signalStrength = Math.max(signalStrength, state.getSignal(world, pos, dir));
}
} }
}
lines.add(0, new Pair<>( lines.add(0, new Pair<>(
new ItemStack(Items.REDSTONE), new ItemStack(Items.REDSTONE),
Component.literal(String.valueOf(signalStrength)) Component.literal(String.valueOf(signalStrength))
.withStyle(redstoneColor(signalStrength)))); .withStyle(redstoneColor(signalStrength))));
}); });
ScryingLensOverlayRegistry.addPredicateDisplayer( ScryingLensOverlayRegistry.addPredicateDisplayer(
(state, pos, observer, world, direction) -> state.hasAnalogOutputSignal(), (state, pos, observer, world, direction) -> state.hasAnalogOutputSignal(),
(lines, state, pos, observer, world, direction) -> { (lines, state, pos, observer, world, direction) -> {
int comparatorValue = ScryingLensOverlayRegistry.getComparatorValue(false); int comparatorValue = ScryingLensOverlayRegistry.getComparatorValue(false);
lines.add( lines.add(
new Pair<>( new Pair<>(
new ItemStack(Items.COMPARATOR), new ItemStack(Items.COMPARATOR),
Component.literal(comparatorValue == -1 ? "" : String.valueOf(comparatorValue)) Component.literal(comparatorValue == -1 ? "" : String.valueOf(comparatorValue))
.withStyle(redstoneColor(comparatorValue)))); .withStyle(redstoneColor(comparatorValue))));
}); });
} }
private static UnaryOperator<Style> color(int color) { private static UnaryOperator<Style> color(int color) {
@ -305,15 +305,15 @@ public class RegisterClientStuff {
private static void registerDataHolderOverrides(IotaHolderItem item, Predicate<ItemStack> hasIota, private static void registerDataHolderOverrides(IotaHolderItem item, Predicate<ItemStack> hasIota,
Predicate<ItemStack> isSealed) { Predicate<ItemStack> isSealed) {
IClientXplatAbstractions.INSTANCE.registerItemProperty((Item) item, ItemFocus.OVERLAY_PRED, IClientXplatAbstractions.INSTANCE.registerItemProperty((Item) item, ItemFocus.OVERLAY_PRED,
(stack, level, holder, holderID) -> { (stack, level, holder, holderID) -> {
if (!hasIota.test(stack) && !NBTHelper.hasString(stack, IotaHolderItem.TAG_OVERRIDE_VISUALLY)) { if (!hasIota.test(stack) && !NBTHelper.hasString(stack, IotaHolderItem.TAG_OVERRIDE_VISUALLY)) {
return 0; return 0;
} }
if (!isSealed.test(stack)) { if (!isSealed.test(stack)) {
return 1; return 1;
} }
return 2; return 2;
}); });
} }
private static int getPoweredRailStrength(Level level, BlockPos pos, BlockState state) { private static int getPoweredRailStrength(Level level, BlockPos pos, BlockState state) {
@ -325,7 +325,8 @@ public class RegisterClientStuff {
} }
// Copypasta from PoweredRailBlock.class // Copypasta from PoweredRailBlock.class
private static int findPoweredRailSignal(Level level, BlockPos pos, BlockState state, boolean travelPositive, int depth) { private static int findPoweredRailSignal(Level level, BlockPos pos, BlockState state, boolean travelPositive,
int depth) {
if (depth >= 8) { if (depth >= 8) {
return 0; return 0;
} else { } else {
@ -417,7 +418,8 @@ public class RegisterClientStuff {
} else if (shape == RailShape.NORTH_SOUTH && (otherShape == RailShape.EAST_WEST || otherShape == RailShape.ASCENDING_EAST || otherShape == RailShape.ASCENDING_WEST)) { } else if (shape == RailShape.NORTH_SOUTH && (otherShape == RailShape.EAST_WEST || otherShape == RailShape.ASCENDING_EAST || otherShape == RailShape.ASCENDING_WEST)) {
return 0; return 0;
} else if (otherState.getValue(PoweredRailBlock.POWERED)) { } else if (otherState.getValue(PoweredRailBlock.POWERED)) {
return level.hasNeighborSignal(pos) ? 8 - depth : findPoweredRailSignal(level, pos, otherState, travelPositive, depth + 1); return level.hasNeighborSignal(pos) ? 8 - depth : findPoweredRailSignal(level, pos, otherState,
travelPositive, depth + 1);
} else { } else {
return 0; return 0;
} }
@ -426,37 +428,37 @@ public class RegisterClientStuff {
private static void registerScrollOverrides(ItemScroll scroll) { private static void registerScrollOverrides(ItemScroll scroll) {
IClientXplatAbstractions.INSTANCE.registerItemProperty(scroll, ItemScroll.ANCIENT_PREDICATE, IClientXplatAbstractions.INSTANCE.registerItemProperty(scroll, ItemScroll.ANCIENT_PREDICATE,
(stack, level, holder, holderID) -> NBTHelper.hasString(stack, ItemScroll.TAG_OP_ID) ? 1f : 0f); (stack, level, holder, holderID) -> NBTHelper.hasString(stack, ItemScroll.TAG_OP_ID) ? 1f : 0f);
} }
private static void registerPackagedSpellOverrides(ItemPackagedHex item) { private static void registerPackagedSpellOverrides(ItemPackagedHex item) {
IClientXplatAbstractions.INSTANCE.registerItemProperty(item, ItemPackagedHex.HAS_PATTERNS_PRED, IClientXplatAbstractions.INSTANCE.registerItemProperty(item, ItemPackagedHex.HAS_PATTERNS_PRED,
(stack, level, holder, holderID) -> (stack, level, holder, holderID) ->
item.hasHex(stack) ? 1f : 0f item.hasHex(stack) ? 1f : 0f
); );
} }
private static void registerWandOverrides(ItemStaff item) { private static void registerWandOverrides(ItemStaff item) {
IClientXplatAbstractions.INSTANCE.registerItemProperty(item, ItemStaff.FUNNY_LEVEL_PREDICATE, IClientXplatAbstractions.INSTANCE.registerItemProperty(item, ItemStaff.FUNNY_LEVEL_PREDICATE,
(stack, level, holder, holderID) -> { (stack, level, holder, holderID) -> {
if (!stack.hasCustomHoverName()) { if (!stack.hasCustomHoverName()) {
return 0; return 0;
} }
var name = stack.getHoverName().getString().toLowerCase(Locale.ROOT); var name = stack.getHoverName().getString().toLowerCase(Locale.ROOT);
if (name.contains("old")) { if (name.contains("old")) {
return 1f; return 1f;
} else if (name.contains("wand of the forest")) { } else if (name.contains("wand of the forest")) {
return 2f; return 2f;
} else { } else {
return 0f; return 0f;
} }
}); });
} }
public static void registerBlockEntityRenderers(@NotNull BlockEntityRendererRegisterererer registerer) { public static void registerBlockEntityRenderers(@NotNull BlockEntityRendererRegisterererer registerer) {
registerer.registerBlockEntityRenderer(HexBlockEntities.SLATE_TILE, BlockEntitySlateRenderer::new); registerer.registerBlockEntityRenderer(HexBlockEntities.SLATE_TILE, BlockEntitySlateRenderer::new);
registerer.registerBlockEntityRenderer(HexBlockEntities.AKASHIC_BOOKSHELF_TILE, registerer.registerBlockEntityRenderer(HexBlockEntities.AKASHIC_BOOKSHELF_TILE,
BlockEntityAkashicBookshelfRenderer::new); BlockEntityAkashicBookshelfRenderer::new);
} }
@FunctionalInterface @FunctionalInterface

View file

@ -15,7 +15,7 @@ import at.petrak.hexcasting.api.utils.gold
import at.petrak.hexcasting.client.* import at.petrak.hexcasting.client.*
import at.petrak.hexcasting.client.ktxt.accumulatedScroll import at.petrak.hexcasting.client.ktxt.accumulatedScroll
import at.petrak.hexcasting.client.sound.GridSoundInstance import at.petrak.hexcasting.client.sound.GridSoundInstance
import at.petrak.hexcasting.common.lib.HexIotaTypes import at.petrak.hexcasting.common.lib.hex.HexIotaTypes
import at.petrak.hexcasting.common.lib.HexSounds import at.petrak.hexcasting.common.lib.HexSounds
import at.petrak.hexcasting.common.network.MsgNewSpellPatternSyn import at.petrak.hexcasting.common.network.MsgNewSpellPatternSyn
import at.petrak.hexcasting.xplat.IClientXplatAbstractions import at.petrak.hexcasting.xplat.IClientXplatAbstractions

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.blocks.akashic;
import at.petrak.hexcasting.api.spell.iota.Iota; import at.petrak.hexcasting.api.spell.iota.Iota;
import at.petrak.hexcasting.api.spell.math.HexPattern; import at.petrak.hexcasting.api.spell.math.HexPattern;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;

View file

@ -4,7 +4,7 @@ import at.petrak.hexcasting.api.block.HexBlockEntity;
import at.petrak.hexcasting.api.spell.iota.Iota; import at.petrak.hexcasting.api.spell.iota.Iota;
import at.petrak.hexcasting.api.spell.math.HexPattern; import at.petrak.hexcasting.api.spell.math.HexPattern;
import at.petrak.hexcasting.common.lib.HexBlockEntities; import at.petrak.hexcasting.common.lib.HexBlockEntities;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;

View file

@ -4,8 +4,8 @@ import at.petrak.hexcasting.api.spell.Action
import at.petrak.hexcasting.api.spell.OperationResult import at.petrak.hexcasting.api.spell.OperationResult
import at.petrak.hexcasting.api.spell.RenderedSpell import at.petrak.hexcasting.api.spell.RenderedSpell
import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.casting.OperatorSideEffect
import at.petrak.hexcasting.api.spell.casting.SpellContinuation import at.petrak.hexcasting.api.spell.casting.SpellContinuation
import at.petrak.hexcasting.api.spell.casting.sideeffects.OperatorSideEffect
import at.petrak.hexcasting.api.spell.iota.Iota import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs
@ -23,8 +23,8 @@ object OpPrint : Action {
val datum = stack[stack.lastIndex] val datum = stack[stack.lastIndex]
return OperationResult( return OperationResult(
continuation, stack, ravenmind, listOf( continuation, stack, ravenmind, listOf(
OperatorSideEffect.AttemptSpell(Spell(datum), hasCastingSound = false, awardStat = false) OperatorSideEffect.AttemptSpell(Spell(datum), hasCastingSound = false, awardStat = false)
) )
) )
} }

View file

@ -4,7 +4,7 @@ import at.petrak.hexcasting.api.item.IotaHolderItem;
import at.petrak.hexcasting.api.spell.iota.DoubleIota; import at.petrak.hexcasting.api.spell.iota.DoubleIota;
import at.petrak.hexcasting.api.spell.iota.Iota; import at.petrak.hexcasting.api.spell.iota.Iota;
import at.petrak.hexcasting.api.utils.NBTHelper; import at.petrak.hexcasting.api.utils.NBTHelper;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import at.petrak.hexcasting.common.lib.HexSounds; import at.petrak.hexcasting.common.lib.HexSounds;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
@ -66,7 +66,7 @@ public class ItemAbacus extends Item implements IotaHolderItem {
@Override @Override
public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List<Component> pTooltipComponents, public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List<Component> pTooltipComponents,
TooltipFlag pIsAdvanced) { TooltipFlag pIsAdvanced) {
IotaHolderItem.appendHoverText(this, pStack, pTooltipComponents, pIsAdvanced); IotaHolderItem.appendHoverText(this, pStack, pTooltipComponents, pIsAdvanced);
} }
} }

View file

@ -4,7 +4,7 @@ import at.petrak.hexcasting.api.item.IotaHolderItem;
import at.petrak.hexcasting.api.spell.iota.Iota; import at.petrak.hexcasting.api.spell.iota.Iota;
import at.petrak.hexcasting.api.spell.iota.NullIota; import at.petrak.hexcasting.api.spell.iota.NullIota;
import at.petrak.hexcasting.api.utils.NBTHelper; import at.petrak.hexcasting.api.utils.NBTHelper;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;

View file

@ -7,7 +7,7 @@ import at.petrak.hexcasting.api.spell.math.HexPattern;
import at.petrak.hexcasting.api.utils.NBTHelper; import at.petrak.hexcasting.api.utils.NBTHelper;
import at.petrak.hexcasting.client.gui.PatternTooltipComponent; import at.petrak.hexcasting.client.gui.PatternTooltipComponent;
import at.petrak.hexcasting.common.entities.EntityWallScroll; import at.petrak.hexcasting.common.entities.EntityWallScroll;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import at.petrak.hexcasting.common.misc.PatternTooltip; import at.petrak.hexcasting.common.misc.PatternTooltip;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
@ -121,7 +121,7 @@ public class ItemScroll extends Item implements IotaHolderItem {
var ancientId = NBTHelper.getString(pStack, TAG_OP_ID); var ancientId = NBTHelper.getString(pStack, TAG_OP_ID);
if (ancientId != null) { if (ancientId != null) {
return Component.translatable(descID + ".of", return Component.translatable(descID + ".of",
Component.translatable("hexcasting.spell." + ResourceLocation.tryParse(ancientId))); Component.translatable("hexcasting.spell." + ResourceLocation.tryParse(ancientId)));
} else if (NBTHelper.hasCompound(pStack, TAG_PATTERN)) { } else if (NBTHelper.hasCompound(pStack, TAG_PATTERN)) {
return Component.translatable(descID); return Component.translatable(descID);
} else { } else {
@ -137,10 +137,10 @@ public class ItemScroll extends Item implements IotaHolderItem {
if (compound != null) { if (compound != null) {
var pattern = HexPattern.fromNBT(compound); var pattern = HexPattern.fromNBT(compound);
return Optional.of(new PatternTooltip( return Optional.of(new PatternTooltip(
pattern, pattern,
NBTHelper.hasString(stack, ItemScroll.TAG_OP_ID) NBTHelper.hasString(stack, ItemScroll.TAG_OP_ID)
? PatternTooltipComponent.ANCIENT_BG ? PatternTooltipComponent.ANCIENT_BG
: PatternTooltipComponent.PRISTINE_BG)); : PatternTooltipComponent.PRISTINE_BG));
} }
return Optional.empty(); return Optional.empty();

View file

@ -9,7 +9,7 @@ import at.petrak.hexcasting.api.spell.math.HexPattern;
import at.petrak.hexcasting.api.utils.NBTHelper; import at.petrak.hexcasting.api.utils.NBTHelper;
import at.petrak.hexcasting.client.gui.PatternTooltipComponent; import at.petrak.hexcasting.client.gui.PatternTooltipComponent;
import at.petrak.hexcasting.common.blocks.circles.BlockEntitySlate; import at.petrak.hexcasting.common.blocks.circles.BlockEntitySlate;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import at.petrak.hexcasting.common.misc.PatternTooltip; import at.petrak.hexcasting.common.misc.PatternTooltip;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;

View file

@ -4,7 +4,7 @@ import at.petrak.hexcasting.api.item.IotaHolderItem;
import at.petrak.hexcasting.api.spell.iota.Iota; import at.petrak.hexcasting.api.spell.iota.Iota;
import at.petrak.hexcasting.api.spell.iota.NullIota; import at.petrak.hexcasting.api.spell.iota.NullIota;
import at.petrak.hexcasting.api.utils.NBTHelper; import at.petrak.hexcasting.api.utils.NBTHelper;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
@ -42,7 +42,7 @@ public class ItemSpellbook extends Item implements IotaHolderItem {
@Override @Override
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltip, public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltip,
TooltipFlag isAdvanced) { TooltipFlag isAdvanced) {
boolean sealed = isSealed(stack); boolean sealed = isSealed(stack);
boolean empty = false; boolean empty = false;
if (NBTHelper.hasNumber(stack, TAG_SELECTED_PAGE)) { if (NBTHelper.hasNumber(stack, TAG_SELECTED_PAGE)) {
@ -51,9 +51,9 @@ public class ItemSpellbook extends Item implements IotaHolderItem {
if (highest != 0) { if (highest != 0) {
if (sealed) { if (sealed) {
tooltip.add(Component.translatable("hexcasting.tooltip.spellbook.page.sealed", tooltip.add(Component.translatable("hexcasting.tooltip.spellbook.page.sealed",
Component.literal(String.valueOf(pageIdx)).withStyle(ChatFormatting.WHITE), Component.literal(String.valueOf(pageIdx)).withStyle(ChatFormatting.WHITE),
Component.literal(String.valueOf(highest)).withStyle(ChatFormatting.WHITE), Component.literal(String.valueOf(highest)).withStyle(ChatFormatting.WHITE),
Component.translatable("hexcasting.tooltip.spellbook.sealed").withStyle(ChatFormatting.GOLD)) Component.translatable("hexcasting.tooltip.spellbook.sealed").withStyle(ChatFormatting.GOLD))
.withStyle(ChatFormatting.GRAY)); .withStyle(ChatFormatting.GRAY));
} else { } else {
tooltip.add(Component.translatable("hexcasting.tooltip.spellbook.page", tooltip.add(Component.translatable("hexcasting.tooltip.spellbook.page",
@ -76,7 +76,7 @@ public class ItemSpellbook extends Item implements IotaHolderItem {
ChatFormatting.GOLD)); ChatFormatting.GOLD));
} else { } else {
tooltip.add(Component.translatable("hexcasting.tooltip.spellbook.empty.sealed", tooltip.add(Component.translatable("hexcasting.tooltip.spellbook.empty.sealed",
Component.translatable("hexcasting.tooltip.spellbook.sealed").withStyle(ChatFormatting.GOLD)) Component.translatable("hexcasting.tooltip.spellbook.sealed").withStyle(ChatFormatting.GOLD))
.withStyle(ChatFormatting.GRAY)); .withStyle(ChatFormatting.GRAY));
} }
} else if (!overridden) { } else if (!overridden) {

View file

@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext;
import at.petrak.hexcasting.api.spell.casting.CastingHarness; import at.petrak.hexcasting.api.spell.casting.CastingHarness;
import at.petrak.hexcasting.api.spell.iota.Iota; import at.petrak.hexcasting.api.spell.iota.Iota;
import at.petrak.hexcasting.api.utils.NBTHelper; import at.petrak.hexcasting.api.utils.NBTHelper;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;

View file

@ -0,0 +1,35 @@
package at.petrak.hexcasting.common.lib.hex;
import at.petrak.hexcasting.api.spell.casting.sideeffects.EvalSound;
import at.petrak.hexcasting.common.lib.HexSounds;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import java.util.LinkedHashMap;
import java.util.Map;
import static at.petrak.hexcasting.api.HexAPI.modLoc;
public class HexEvalSounds {
public static final Registry<EvalSound> REGISTRY = IXplatAbstractions.INSTANCE.getEvalSoundRegistry();
private static final Map<ResourceLocation, EvalSound> TYPES = new LinkedHashMap<>();
public static final EvalSound NOTHING = make("nothing",
new EvalSound(null, Integer.MIN_VALUE));
public static final EvalSound OPERATOR = make("operator",
new EvalSound(HexSounds.ADD_PATTERN, 0));
public static final EvalSound SPELL = make("spell",
new EvalSound(HexSounds.ACTUALLY_CAST, 1000));
public static final EvalSound MISHAP = make("mishap",
new EvalSound(HexSounds.FAIL_PATTERN, Integer.MAX_VALUE));
private static EvalSound make(String name, EvalSound sound) {
var old = TYPES.put(modLoc(name), sound);
if (old != null) {
throw new IllegalArgumentException("Typo? Duplicate id " + name);
}
return sound;
}
}

View file

@ -1,4 +1,4 @@
package at.petrak.hexcasting.common.lib; package at.petrak.hexcasting.common.lib.hex;
import at.petrak.hexcasting.api.HexAPI; import at.petrak.hexcasting.api.HexAPI;
import at.petrak.hexcasting.api.spell.iota.*; import at.petrak.hexcasting.api.spell.iota.*;

View file

@ -0,0 +1,4 @@
/**
* Registries and such of types Hexcasting itself defines
*/
package at.petrak.hexcasting.common.lib.hex;

View file

@ -3,7 +3,7 @@ package at.petrak.hexcasting.common.network;
import at.petrak.hexcasting.api.utils.NBTHelper; import at.petrak.hexcasting.api.utils.NBTHelper;
import at.petrak.hexcasting.common.items.ItemAbacus; import at.petrak.hexcasting.common.items.ItemAbacus;
import at.petrak.hexcasting.common.items.ItemSpellbook; import at.petrak.hexcasting.common.items.ItemSpellbook;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import at.petrak.hexcasting.common.lib.HexItems; import at.petrak.hexcasting.common.lib.HexItems;
import at.petrak.hexcasting.common.lib.HexSounds; import at.petrak.hexcasting.common.lib.HexSounds;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;

View file

@ -9,6 +9,7 @@ import at.petrak.hexcasting.api.player.FlightAbility;
import at.petrak.hexcasting.api.player.Sentinel; import at.petrak.hexcasting.api.player.Sentinel;
import at.petrak.hexcasting.api.spell.casting.CastingHarness; import at.petrak.hexcasting.api.spell.casting.CastingHarness;
import at.petrak.hexcasting.api.spell.casting.ResolvedPattern; import at.petrak.hexcasting.api.spell.casting.ResolvedPattern;
import at.petrak.hexcasting.api.spell.casting.sideeffects.EvalSound;
import at.petrak.hexcasting.api.spell.iota.IotaType; import at.petrak.hexcasting.api.spell.iota.IotaType;
import at.petrak.hexcasting.common.network.IMessage; import at.petrak.hexcasting.common.network.IMessage;
import at.petrak.hexcasting.interop.pehkui.PehkuiInterop; import at.petrak.hexcasting.interop.pehkui.PehkuiInterop;
@ -124,7 +125,7 @@ public interface IXplatAbstractions {
// Blocks // Blocks
<T extends BlockEntity> BlockEntityType<T> createBlockEntityType(BiFunction<BlockPos, BlockState, T> func, <T extends BlockEntity> BlockEntityType<T> createBlockEntityType(BiFunction<BlockPos, BlockState, T> func,
Block... blocks); Block... blocks);
boolean tryPlaceFluid(Level level, InteractionHand hand, BlockPos pos, Fluid fluid); boolean tryPlaceFluid(Level level, InteractionHand hand, BlockPos pos, Fluid fluid);
@ -159,6 +160,8 @@ public interface IXplatAbstractions {
Registry<IotaType<?>> getIotaTypeRegistry(); Registry<IotaType<?>> getIotaTypeRegistry();
Registry<EvalSound> getEvalSoundRegistry();
boolean isBreakingAllowed(Level world, BlockPos pos, BlockState state, Player player); boolean isBreakingAllowed(Level world, BlockPos pos, BlockState state, Player player);
boolean isPlacingAllowed(Level world, BlockPos pos, ItemStack blockStack, Player player); boolean isPlacingAllowed(Level world, BlockPos pos, ItemStack blockStack, Player player);

View file

@ -12,6 +12,7 @@ import at.petrak.hexcasting.common.entities.HexEntities
import at.petrak.hexcasting.common.items.ItemJewelerHammer import at.petrak.hexcasting.common.items.ItemJewelerHammer
import at.petrak.hexcasting.common.items.ItemLens import at.petrak.hexcasting.common.items.ItemLens
import at.petrak.hexcasting.common.lib.* import at.petrak.hexcasting.common.lib.*
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes
import at.petrak.hexcasting.common.loot.HexLootHandler import at.petrak.hexcasting.common.loot.HexLootHandler
import at.petrak.hexcasting.common.misc.AkashicTreeGrower import at.petrak.hexcasting.common.misc.AkashicTreeGrower
import at.petrak.hexcasting.common.misc.Brainsweeping import at.petrak.hexcasting.common.misc.Brainsweeping

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.fabric.cc.adimpl;
import at.petrak.hexcasting.api.item.IotaHolderItem; import at.petrak.hexcasting.api.item.IotaHolderItem;
import at.petrak.hexcasting.api.spell.iota.Iota; import at.petrak.hexcasting.api.spell.iota.Iota;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import at.petrak.hexcasting.fabric.cc.HexCardinalComponents; import at.petrak.hexcasting.fabric.cc.HexCardinalComponents;
import dev.onyxstudios.cca.api.v3.item.ItemComponent; import dev.onyxstudios.cca.api.v3.item.ItemComponent;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;

View file

@ -13,6 +13,7 @@ import at.petrak.hexcasting.common.entities.HexEntities;
import at.petrak.hexcasting.common.items.ItemJewelerHammer; import at.petrak.hexcasting.common.items.ItemJewelerHammer;
import at.petrak.hexcasting.common.items.ItemLens; import at.petrak.hexcasting.common.items.ItemLens;
import at.petrak.hexcasting.common.lib.*; import at.petrak.hexcasting.common.lib.*;
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import at.petrak.hexcasting.common.loot.HexLootHandler; import at.petrak.hexcasting.common.loot.HexLootHandler;
import at.petrak.hexcasting.common.misc.AkashicTreeGrower; import at.petrak.hexcasting.common.misc.AkashicTreeGrower;
import at.petrak.hexcasting.common.misc.Brainsweeping; import at.petrak.hexcasting.common.misc.Brainsweeping;
@ -131,9 +132,12 @@ public class ForgeHexInitializer {
HexComposting.setup(); HexComposting.setup();
HexStrippables.init(); HexStrippables.init();
RegisterPatterns.registerPatterns(); RegisterPatterns.registerPatterns();
// Forge does not strictly require TreeGrowers to initialize during early game stages, unlike Fabric and Quilt. // Forge does not strictly require TreeGrowers to initialize during early game stages, unlike Fabric
// However, all launcher panic if the same resource is registered twice. But do need blocks and items to be completely initialized. // and Quilt.
// Explicitly calling here avoids potential confusion, or reliance on tricks that may fail under compiler optimization. // However, all launcher panic if the same resource is registered twice. But do need blocks and
// items to be completely initialized.
// Explicitly calling here avoids potential confusion, or reliance on tricks that may fail under
// compiler optimization.
AkashicTreeGrower.init(); AkashicTreeGrower.init();
HexInterop.init(); HexInterop.init();
@ -143,7 +147,8 @@ public class ForgeHexInitializer {
modBus.addListener((RegisterEvent evt) -> { modBus.addListener((RegisterEvent evt) -> {
if (evt.getRegistryKey().equals(Registry.ITEM_REGISTRY)) { if (evt.getRegistryKey().equals(Registry.ITEM_REGISTRY)) {
CraftingHelper.register(ForgeUnsealedIngredient.ID, ForgeUnsealedIngredient.Serializer.INSTANCE); CraftingHelper.register(ForgeUnsealedIngredient.ID, ForgeUnsealedIngredient.Serializer.INSTANCE);
CraftingHelper.register(ForgeModConditionalIngredient.ID, ForgeModConditionalIngredient.Serializer.INSTANCE); CraftingHelper.register(ForgeModConditionalIngredient.ID,
ForgeModConditionalIngredient.Serializer.INSTANCE);
HexStatistics.register(); HexStatistics.register();
HexLootFunctions.registerSerializers((lift, id) -> HexLootFunctions.registerSerializers((lift, id) ->
Registry.register(Registry.LOOT_FUNCTION_TYPE, id, lift)); Registry.register(Registry.LOOT_FUNCTION_TYPE, id, lift));

View file

@ -13,7 +13,7 @@ import at.petrak.hexcasting.api.mod.HexConfig;
import at.petrak.hexcasting.api.spell.iota.DoubleIota; import at.petrak.hexcasting.api.spell.iota.DoubleIota;
import at.petrak.hexcasting.api.spell.iota.Iota; import at.petrak.hexcasting.api.spell.iota.Iota;
import at.petrak.hexcasting.common.entities.EntityWallScroll; import at.petrak.hexcasting.common.entities.EntityWallScroll;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import at.petrak.hexcasting.common.lib.HexItems; import at.petrak.hexcasting.common.lib.HexItems;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
@ -146,21 +146,23 @@ public class ForgeCapabilityHandler {
}; };
} }
private static <CAP> SimpleProvider<CAP> provide(Entity entity, Capability<CAP> capability, NonNullSupplier<CAP> supplier) { private static <CAP> SimpleProvider<CAP> provide(Entity entity, Capability<CAP> capability,
NonNullSupplier<CAP> supplier) {
return provide(entity::isRemoved, capability, supplier); return provide(entity::isRemoved, capability, supplier);
} }
private static <CAP> SimpleProvider<CAP> provide(BlockEntity be, Capability<CAP> capability, NonNullSupplier<CAP> supplier) { private static <CAP> SimpleProvider<CAP> provide(BlockEntity be, Capability<CAP> capability,
NonNullSupplier<CAP> supplier) {
return provide(be::isRemoved, capability, supplier); return provide(be::isRemoved, capability, supplier);
} }
private static <CAP> SimpleProvider<CAP> provide(ItemStack stack, Capability<CAP> capability, private static <CAP> SimpleProvider<CAP> provide(ItemStack stack, Capability<CAP> capability,
NonNullSupplier<CAP> supplier) { NonNullSupplier<CAP> supplier) {
return provide(stack::isEmpty, capability, supplier); return provide(stack::isEmpty, capability, supplier);
} }
private static <CAP> SimpleProvider<CAP> provide(BooleanSupplier invalidated, Capability<CAP> capability, private static <CAP> SimpleProvider<CAP> provide(BooleanSupplier invalidated, Capability<CAP> capability,
NonNullSupplier<CAP> supplier) { NonNullSupplier<CAP> supplier) {
return new SimpleProvider<>(invalidated, capability, LazyOptional.of(supplier)); return new SimpleProvider<>(invalidated, capability, LazyOptional.of(supplier));
} }

View file

@ -14,7 +14,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingHarness;
import at.petrak.hexcasting.api.spell.casting.ResolvedPattern; import at.petrak.hexcasting.api.spell.casting.ResolvedPattern;
import at.petrak.hexcasting.api.spell.iota.IotaType; import at.petrak.hexcasting.api.spell.iota.IotaType;
import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import at.petrak.hexcasting.common.lib.HexItems; import at.petrak.hexcasting.common.lib.HexItems;
import at.petrak.hexcasting.common.network.IMessage; import at.petrak.hexcasting.common.network.IMessage;
import at.petrak.hexcasting.forge.cap.CapSyncers; import at.petrak.hexcasting.forge.cap.CapSyncers;
@ -317,7 +317,7 @@ public class ForgeXplatImpl implements IXplatAbstractions {
@Override @Override
public <T extends BlockEntity> BlockEntityType<T> createBlockEntityType(BiFunction<BlockPos, BlockState, T> func, public <T extends BlockEntity> BlockEntityType<T> createBlockEntityType(BiFunction<BlockPos, BlockState, T> func,
Block... blocks) { Block... blocks) {
return BlockEntityType.Builder.of(func::apply, blocks).build(null); return BlockEntityType.Builder.of(func::apply, blocks).build(null);
} }