Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fa25484
chore: migrate potion registry to IXplatRegister
Olfi01 Jul 25, 2026
e0f955b
fix: add back potion recipes to fabric
Olfi01 Jul 25, 2026
44be385
chore: migrate HexSounds to IXplatRegister
Olfi01 Jul 25, 2026
cf3e8a2
chore: migrate HexBlocks and HexItems to IXplatRegister
Olfi01 Jul 26, 2026
df1acfa
chore: migrate HexBlockEntities to IXplatRegister
Olfi01 Jul 26, 2026
9337654
chore: migrate HexCreativeTabs to IXplatRegister
Olfi01 Jul 26, 2026
8cbf7b5
chore: migrate HexDataComponents to IXplatRegister
Olfi01 Jul 26, 2026
7305fe9
chore: merge HexBlocks register methods
Olfi01 Jul 26, 2026
0df8a79
chore: migrate HexRecipeStuffRegistry to IXplatRegister
Olfi01 Jul 26, 2026
1959c6a
chore: migrate HexEntities to IXplatRegister
Olfi01 Jul 26, 2026
ec3210f
chore: migrate HexParticles to IXplatRegister
Olfi01 Jul 26, 2026
eb218be
chore: migrate HexAdvancementTriggers to IXplatRegister
Olfi01 Jul 26, 2026
4d15708
chore: migrate HexIotaTypes to IXplatRegister
Olfi01 Jul 26, 2026
2442ba1
chore: migrate HexActions to IXplatRegister
Olfi01 Jul 26, 2026
fada949
chore: migrate HexSpecialHandlers to IXplatRegister
Olfi01 Jul 26, 2026
45053a7
chore: migrate HexArithmetics to IXplatRegister
Olfi01 Jul 26, 2026
eceaa01
chore: migrate HexContinuationTypes to IXplatRegister
Olfi01 Jul 26, 2026
c7e0fa5
chore: migrate HexEvalSounds to IXplatRegister
Olfi01 Jul 26, 2026
1d99a9a
chore: migrate HexStateIngredients to IXplatRegister
Olfi01 Jul 26, 2026
dba28fa
chore: migrate HexBrainsweepeeIngredients to IXplatRegister
Olfi01 Jul 26, 2026
ecc2cab
chore: migrate HexLootFunctions to IXplatRegister
Olfi01 Jul 26, 2026
f273ba3
chore: cleanup imports
Olfi01 Jul 26, 2026
204253d
fix: IotaPredicates calling IotaType holders too early
Olfi01 Jul 26, 2026
fb1188c
fix: Stop lazily initializing registries on Fabric, this sometimes ma…
Olfi01 Jul 26, 2026
9364174
chore: cleanup unused field
Olfi01 Jul 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,35 +1,26 @@
package at.petrak.hexcasting.api.advancements;

import at.petrak.hexcasting.xplat.IXplatAbstractions;
import at.petrak.hexcasting.xplat.IXplatRegister;
import net.minecraft.advancements.CriterionTrigger;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Supplier;

import static at.petrak.hexcasting.api.HexAPI.modLoc;

public class HexAdvancementTriggers {
private static final Map<ResourceLocation, CriterionTrigger<?>> TRIGGERS = new LinkedHashMap<>();
private static final IXplatRegister<CriterionTrigger<?>> REGISTER = IXplatAbstractions.INSTANCE.createRegistar(Registries.TRIGGER_TYPE);

public static final OvercastTrigger OVERCAST_TRIGGER = register("overcast", new OvercastTrigger());
public static final SpendMediaTrigger SPEND_MEDIA_TRIGGER = register("spend_media", new SpendMediaTrigger());
public static final FailToCastGreatSpellTrigger FAIL_GREAT_SPELL_TRIGGER = register("fail_to_cast_great_spell", new FailToCastGreatSpellTrigger());

public static void registerTriggers(BiConsumer<CriterionTrigger<?>, ResourceLocation> r) {
for (var e : TRIGGERS.entrySet()) {
r.accept(e.getValue(), e.getKey());
}
public static void register() {
REGISTER.registerAll();
}

private static <T extends CriterionTrigger<?>> T register(
String id,
T lift
) {
var old = TRIGGERS.put(modLoc(id), lift);
if (old != null) {
throw new IllegalArgumentException("Typo? Duplicate id " + id);
}
return lift;
}
public static final Supplier<OvercastTrigger> OVERCAST_TRIGGER = REGISTER.register("overcast", OvercastTrigger::new);
public static final Supplier<SpendMediaTrigger> SPEND_MEDIA_TRIGGER = REGISTER.register("spend_media", SpendMediaTrigger::new);
public static final Supplier<FailToCastGreatSpellTrigger> FAIL_GREAT_SPELL_TRIGGER = REGISTER.register("fail_to_cast_great_spell", FailToCastGreatSpellTrigger::new);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class OperatorBasic(arity: Int, accepts: IotaMultiPredicate) : Operator
val stackWithResult = stackWithoutArgs.appendedAll(ret)

val image2 = image.copy(stack = stackWithResult, opsConsumed = image.opsConsumed + 1)
return OperationResult(image2, listOf(), continuation, HexEvalSounds.NORMAL_EXECUTE)
return OperationResult(image2, listOf(), continuation, HexEvalSounds.NORMAL_EXECUTE.get())
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ interface Action {
image.withNewParenthesized(thisIota),
listOf(),
continuation,
HexEvalSounds.NORMAL_EXECUTE,
HexEvalSounds.NORMAL_EXECUTE.get(),
ResolvedPatternType.ESCAPED
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface ConstMediaAction : Action {
val sideEffects = mutableListOf<OperatorSideEffect>(OperatorSideEffect.ConsumeMedia(this.mediaCost))

val image2 = image.copy(stack = stackWithResult, opsConsumed = image.opsConsumed + result.opCount)
return OperationResult(image2, sideEffects, continuation, HexEvalSounds.NORMAL_EXECUTE)
return OperationResult(image2, sideEffects, continuation, HexEvalSounds.NORMAL_EXECUTE.get())
}

data class CostMediaActionResult(val resultStack: List<Iota>, val opCount: Long = 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ interface SpellAction : Action {

val image2 = image.copy(stack = stackWithoutArgs, opsConsumed = image.opsConsumed + result.opCount, userData = userDataMut)

val sound = if (this.hasCastingSound(env)) HexEvalSounds.SPELL else HexEvalSounds.MUTE
val sound = if (this.hasCastingSound(env)) HexEvalSounds.SPELL.get() else HexEvalSounds.MUTE.get()
return OperationResult(image2, sideEffects, continuation, sound)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public long extractMediaFromInsertedItem(ItemStack stack, boolean simulate) {
}

public void insertMedia(ItemStack stack) {
if (getMedia() >= 0 && !stack.isEmpty() && stack.getItem() == HexItems.CREATIVE_UNLOCKER) {
if (getMedia() >= 0 && !stack.isEmpty() && stack.getItem() == HexItems.CREATIVE_UNLOCKER.get()) {
setInfiniteMedia();
stack.shrink(1);
} else {
Expand Down Expand Up @@ -299,12 +299,12 @@ public void applyScryingLensOverlay(List<Pair<ItemStack, Component>> lines,
BlockState state, BlockPos pos, Player observer, Level world, Direction hitFace) {
if (world.getBlockEntity(pos) instanceof BlockEntityAbstractImpetus beai) {
if (beai.getMedia() < 0) {
lines.add(new Pair<>(new ItemStack(HexItems.AMETHYST_DUST), ItemCreativeUnlocker.infiniteMedia(world)));
lines.add(new Pair<>(new ItemStack(HexItems.AMETHYST_DUST.get()), ItemCreativeUnlocker.infiniteMedia(world)));
} else {
var dustCount = (float) beai.getMedia() / (float) MediaConstants.DUST_UNIT;
var dustCmp = Component.translatable("hexcasting.tooltip.media",
DUST_AMOUNT.format(dustCount));
lines.add(new Pair<>(new ItemStack(HexItems.AMETHYST_DUST), dustCmp));
lines.add(new Pair<>(new ItemStack(HexItems.AMETHYST_DUST.get()), dustCmp));
}

if (this.displayMsg != null && this.displayItem != null) {
Expand Down Expand Up @@ -414,7 +414,7 @@ public boolean canPlaceItem(int index, ItemStack stack) {
return false;
}

if (stack.is(HexItems.CREATIVE_UNLOCKER)) {
if (stack.is(HexItems.CREATIVE_UNLOCKER.get())) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static void sfx(BlockPos pos, BlockState bs, Level world, BlockEntityAbstractImp
activator = impetus.getExecutionState().caster;

if (impetus == null || impetus.getExecutionState() == null)
colorizer = new FrozenPigment(new ItemStack(HexItems.DYE_PIGMENTS.get(DyeColor.RED)), activator);
colorizer = new FrozenPigment(new ItemStack(HexItems.DYE_PIGMENTS.get(DyeColor.RED).get()), activator);
else
colorizer = impetus.getPigment();

Expand All @@ -123,7 +123,7 @@ static void sfx(BlockPos pos, BlockState bs, Level world, BlockEntityAbstractImp
var spray = new ParticleSpray(vpos, vecOutDir.scale(success ? 1.0 : 1.5), success ? 0.1 : 0.5,
Mth.PI / (success ? 4 : 2), success ? 30 : 100);
spray.sprayParticles(serverLevel,
success ? colorizer : new FrozenPigment(new ItemStack(HexItems.DYE_PIGMENTS.get(DyeColor.RED)),
success ? colorizer : new FrozenPigment(new ItemStack(HexItems.DYE_PIGMENTS.get(DyeColor.RED).get()),
activator));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class PackagedItemCastEnv extends PlayerBasedSpiralPatternCastEnv {

protected EvalSound sound = HexEvalSounds.NOTHING;
protected EvalSound sound = HexEvalSounds.NOTHING.get();

public PackagedItemCastEnv(ServerPlayer caster, InteractionHand castingHand) {
super(caster, castingHand);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ protected long extractMediaFromInventory(long costLeft, boolean allowOvercast, b

var actuallyTaken = Mth.ceil(mediaAbleToCastFromHP - (this.caster.getHealth() * mediaToHealth));

HexAdvancementTriggers.OVERCAST_TRIGGER.trigger(this.caster, actuallyTaken);
HexAdvancementTriggers.OVERCAST_TRIGGER.get().trigger(this.caster, actuallyTaken);
this.caster.awardStat(HexStatistics.MEDIA_OVERCAST, actuallyTaken);

costLeft -= actuallyTaken;
Expand All @@ -181,7 +181,7 @@ protected long extractMediaFromInventory(long costLeft, boolean allowOvercast, b

if (!simulate) {
this.caster.awardStat(HexStatistics.MEDIA_USED, (int) (startCost - costLeft));
HexAdvancementTriggers.SPEND_MEDIA_TRIGGER.trigger(
HexAdvancementTriggers.SPEND_MEDIA_TRIGGER.get().trigger(
this.caster,
startCost - costLeft,
costLeft < 0 ? -costLeft : 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ sealed class OperatorSideEffect {
spray.sprayParticles(
harness.env.world,
FrozenPigment(
ItemStack(HexItems.DYE_PIGMENTS[DyeColor.RED]!!),
ItemStack(HexItems.DYE_PIGMENTS[DyeColor.RED]!!.get()),
Util.NIL_UUID
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ class CastingVM(var image: CastingImage, val env: CastingEnvironment) {
newData = null,
sideEffects = listOf(OperatorSideEffect.DoMishap(MishapStackSize(), Mishap.Context(null, null))),
resolutionType = ResolvedPatternType.ERRORED,
sound = HexEvalSounds.MISHAP,
sound = HexEvalSounds.MISHAP.get(),
)
} else if (result.newData != null && result.newData.opsConsumed > env.maxOpCount()) {
result.copy(
newData = null,
sideEffects = listOf(OperatorSideEffect.DoMishap(MishapEvalTooMuch(), Mishap.Context(null, null))),
resolutionType = ResolvedPatternType.ERRORED,
sound = HexEvalSounds.MISHAP,
sound = HexEvalSounds.MISHAP.get(),
)
} else {
result
Expand Down Expand Up @@ -145,7 +145,7 @@ class CastingVM(var image: CastingImage, val env: CastingEnvironment) {
escapeNext = false,
)
}
return CastResult(iota, continuation, newImage, listOf(), ResolvedPatternType.ESCAPED, HexEvalSounds.NORMAL_EXECUTE)
return CastResult(iota, continuation, newImage, listOf(), ResolvedPatternType.ESCAPED, HexEvalSounds.NORMAL_EXECUTE.get())
}

val result = if (this.image.parenCount > 0) {
Expand All @@ -164,7 +164,7 @@ class CastingVM(var image: CastingImage, val env: CastingEnvironment) {
stack = newStack,
simulateNext = false
)
return CastResult(iota, continuation, newImage, listOf(), ResolvedPatternType.SIMULATED, HexEvalSounds.NORMAL_EXECUTE)
return CastResult(iota, continuation, newImage, listOf(), ResolvedPatternType.SIMULATED, HexEvalSounds.NORMAL_EXECUTE.get())
}

// otherwise, return the original CastResult to perform all the side effects, stack manip, etc
Expand All @@ -186,7 +186,7 @@ class CastingVM(var image: CastingImage, val env: CastingEnvironment) {
)
),
ResolvedPatternType.ERRORED,
HexEvalSounds.MISHAP
HexEvalSounds.MISHAP.get()
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ data class FrameEvaluate(val list: TreeList<Iota>, val isMetacasting: Boolean) :
} else continuation
// ...before evaluating the first one in the list.
val update = harness.executeInner(list.head(), level, newCont)
if (this.isMetacasting && update.sound != HexEvalSounds.MISHAP) {
update.copy(sound = HexEvalSounds.HERMES)
if (this.isMetacasting && update.sound != HexEvalSounds.MISHAP.get()) {
update.copy(sound = HexEvalSounds.HERMES.get())
} else {
update
}
} else {
// If there are no patterns (e.g. empty Hermes), just return OK.
CastResult(ListIota(list), continuation, null, listOf(), ResolvedPatternType.EVALUATED, HexEvalSounds.HERMES)
CastResult(ListIota(list), continuation, null, listOf(), ResolvedPatternType.EVALUATED, HexEvalSounds.HERMES.get())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object FrameFinishEval : ContinuationFrame {
null,
listOf(),
ResolvedPatternType.EVALUATED,
HexEvalSounds.NOTHING,
HexEvalSounds.NOTHING.get(),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ data class FrameForEach(
newImage.withResetEscape().copy(stack = newStack),
listOf(),
ResolvedPatternType.EVALUATED,
HexEvalSounds.THOTH,
HexEvalSounds.THOTH.get(),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class BooleanIota extends Iota {
private boolean value;
public BooleanIota(boolean d) {
super(() -> HexIotaTypes.BOOLEAN);
super(() -> HexIotaTypes.BOOLEAN.get());
this.value = d;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class ContinuationIota extends Iota {
private SpellContinuation value;

public ContinuationIota(SpellContinuation cont) {
super(() -> HexIotaTypes.CONTINUATION);
super(() -> HexIotaTypes.CONTINUATION.get());
this.value = cont;
}

Expand All @@ -44,7 +44,7 @@ public boolean toleratesOther(Iota that) {

@Override
public @NotNull CastResult execute(CastingVM vm, ServerLevel world, SpellContinuation continuation) {
return new CastResult(this, this.getContinuation(), vm.getImage(), List.of(), ResolvedPatternType.EVALUATED, HexEvalSounds.HERMES);
return new CastResult(this, this.getContinuation(), vm.getImage(), List.of(), ResolvedPatternType.EVALUATED, HexEvalSounds.HERMES.get());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class DoubleIota extends Iota {
private double value;

public DoubleIota(double d) {
super(() -> HexIotaTypes.DOUBLE);
super(() -> HexIotaTypes.DOUBLE.get());
this.value = d;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public EntityIota(@NotNull Entity e) {
}

public EntityIota(UUID entityId, @Nullable Component entityName, boolean isPlayer) {
super(() -> HexIotaTypes.ENTITY);
super(() -> HexIotaTypes.ENTITY.get());
this.entityId = entityId;
this.entityName = entityName;
this.isPlayer = isPlayer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class GarbageIota extends Iota {
public GarbageIota() {
// We have to pass *something* here, but there's nothing that actually needs to go there,
// so we just do this i guess
super(() -> HexIotaTypes.GARBAGE);
super(() -> HexIotaTypes.GARBAGE.get());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected Iota(@NotNull Supplier<IotaType<? extends Iota>> type) {
)
),
ResolvedPatternType.INVALID,
HexEvalSounds.MISHAP);
HexEvalSounds.MISHAP.get());
}

/**
Expand All @@ -74,7 +74,7 @@ protected Iota(@NotNull Supplier<IotaType<? extends Iota>> type) {
vm.getImage().withNewParenthesized(this),
List.of(),
ResolvedPatternType.ESCAPED,
HexEvalSounds.NORMAL_EXECUTE);
HexEvalSounds.NORMAL_EXECUTE.get());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ListIota extends Iota {
private final int size;

public ListIota(@NotNull TreeList<Iota> list) {
super(() -> HexIotaTypes.LIST);
super(() -> HexIotaTypes.LIST.get());
this.list = list;
int maxChildDepth = 0;
int totalSize = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class NullIota extends Iota {
Component.translatable("hexcasting.tooltip.null_iota").withStyle(ChatFormatting.GRAY);

public NullIota() {
super(() -> HexIotaTypes.NULL);
super(() -> HexIotaTypes.NULL.get());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class PatternIota extends Iota {
private HexPattern value;

public PatternIota(@NotNull HexPattern pattern) {
super(() -> HexIotaTypes.PATTERN);
super(() -> HexIotaTypes.PATTERN.get());
this.value = pattern;
}

Expand Down Expand Up @@ -120,7 +120,7 @@ public boolean executable() {
vm.getImage().withNewParenthesized(this),
List.of(),
ResolvedPatternType.ESCAPED,
HexEvalSounds.NORMAL_EXECUTE);
HexEvalSounds.NORMAL_EXECUTE.get());
} else {
// if you draw something invalid outside parens, it mishaps
throw new MishapInvalidPattern(this.getPattern());
Expand Down Expand Up @@ -167,7 +167,7 @@ public boolean executable() {
null,
List.of(new OperatorSideEffect.DoMishap(mishap, new Mishap.Context(this.getPattern(), castedName.get()))),
mishap.resolutionType(vm.getEnv()),
HexEvalSounds.MISHAP);
HexEvalSounds.MISHAP.get());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public class Vec3Iota extends Iota {
private Vec3 value;
public Vec3Iota(@NotNull Vec3 datum) {
super(() -> HexIotaTypes.VEC3);
super(() -> HexIotaTypes.VEC3.get());
this.value = datum;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ abstract class Mishap : RuntimeException() {

protected fun dyeColor(color: DyeColor): FrozenPigment =
FrozenPigment(
ItemStack(HexItems.DYE_PIGMENTS[color]!!),
ItemStack(HexItems.DYE_PIGMENTS[color]!!.get()),
Util.NIL_UUID
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MishapUnenlightened : Mishap() {

val castingPlayer = env.castingEntity as? ServerPlayer
if (castingPlayer != null) {
HexAdvancementTriggers.FAIL_GREAT_SPELL_TRIGGER.trigger(castingPlayer)
HexAdvancementTriggers.FAIL_GREAT_SPELL_TRIGGER.get().trigger(castingPlayer)
}
return stack
}
Expand Down
Loading
Loading