Skip to content

Commit

Permalink
Grimoire texture and code tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
miyucomics committed Mar 9, 2024
1 parent 8e98215 commit 07aed5d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package miyucomics.hexical.mixin;

import at.petrak.hexcasting.api.addldata.ADMediaHolder;
import at.petrak.hexcasting.api.misc.DiscoveryHandlers;
import at.petrak.hexcasting.api.spell.casting.CastingContext;
import at.petrak.hexcasting.api.spell.casting.CastingHarness;
import at.petrak.hexcasting.api.spell.casting.ControllerInfo;
Expand Down Expand Up @@ -31,7 +32,7 @@
import java.util.Collections;
import java.util.List;

@Mixin(value = CastingHarness.class)
@Mixin(value = CastingHarness.class, priority = 1005)
public class CastingHarnessMixin {
@Unique private final CastingHarness hexical$harness = (CastingHarness) (Object) this;

Expand Down Expand Up @@ -67,15 +68,15 @@ private void withdrawMediaWisp(int mediaCost, boolean allowOvercast, CallbackInf
}
}

@Inject(method = "executeIota", at = @At("HEAD"), cancellable = true, locals = LocalCapture.CAPTURE_FAILEXCEPTION, remap = false)
private void executeIotaMacro (Iota iota, ServerWorld world, CallbackInfoReturnable<ControllerInfo> cir) {
@Inject(method = "executeIota", at = @At("HEAD"), cancellable = true, remap = false)
private void expandGrimoire (Iota iota, ServerWorld world, CallbackInfoReturnable<ControllerInfo> cir) {
CastingContext ctx = hexical$harness.getCtx();
List<Iota> toExecute = new ArrayList<>(Collections.singleton(iota));
if (ctx.getSpellCircle() != null)
return;
if (!hexical$harness.getEscapeNext() && iota.getType() == HexIotaTypes.PATTERN && !((PatternIota) iota).getPattern().sigsEqual(HexPattern.fromAngles("qqqaw", HexDir.EAST))) {
HexPattern pattern = ((PatternIota) iota).getPattern();
toExecute = CastingUtils.Companion.grimoireLookup(ctx.getCaster(), pattern);
toExecute = CastingUtils.Companion.grimoireLookup(ctx.getCaster(), pattern, DiscoveryHandlers.collectItemSlots(ctx));
if (toExecute == null)
toExecute = new ArrayList<>(Collections.singleton(iota));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private void onInputUpdate(CallbackInfo info) {
input.pressingRight = keys.rightKey.isPressed();
input.jumping = keys.jumpKey.isPressed();
input.sneaking = keys.sneakKey.isPressed();
if (!client.player.isSprinting())
if (client.player != null)
client.player.setSprinting(keys.sprintKey.isPressed());
}
}
13 changes: 4 additions & 9 deletions common/src/main/java/miyucomics/hexical/utils/CastingUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import at.petrak.hexcasting.api.spell.math.HexPattern
import miyucomics.hexical.interfaces.CastingContextMixinInterface
import miyucomics.hexical.items.GrimoireItem
import miyucomics.hexical.registry.HexicalItems
import net.minecraft.item.ItemStack
import net.minecraft.server.network.ServerPlayerEntity
import net.minecraft.server.world.ServerWorld
import net.minecraft.text.Text
Expand All @@ -29,18 +30,12 @@ class CastingUtils {
return false
}

fun grimoireLookup(player: ServerPlayerEntity, pattern: HexPattern): List<Iota>? {
for (stack in player.inventory.main) {
if (stack.item != HexicalItems.GRIMOIRE_ITEM)
continue
val value = GrimoireItem.getPatternInGrimoire(stack, pattern, player.getWorld())
if (value != null)
return value
}
for (stack in player.inventory.offHand) {
fun grimoireLookup(player: ServerPlayerEntity, pattern: HexPattern, slots: List<ItemStack>): List<Iota>? {
for (stack in slots) {
if (stack.item != HexicalItems.GRIMOIRE_ITEM)
continue
val value = GrimoireItem.getPatternInGrimoire(stack, pattern, player.getWorld())
player.sendMessage(Text.literal(value.toString()))
if (value != null)
return value
}
Expand Down
Binary file modified common/src/main/resources/assets/hexical/textures/item/grimoire.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 07aed5d

Please sign in to comment.