diff --git a/src/main/java/at/petrak/hexcasting/api/item/CasterItem.java b/src/main/java/at/petrak/hexcasting/api/item/CasterItem.java deleted file mode 100644 index 501e7a6e..00000000 --- a/src/main/java/at/petrak/hexcasting/api/item/CasterItem.java +++ /dev/null @@ -1,4 +0,0 @@ -package at.petrak.hexcasting.api.item; - -public interface CasterItem { -} diff --git a/src/main/java/at/petrak/hexcasting/common/items/HexItemTags.java b/src/main/java/at/petrak/hexcasting/api/mod/HexItemTags.java similarity index 79% rename from src/main/java/at/petrak/hexcasting/common/items/HexItemTags.java rename to src/main/java/at/petrak/hexcasting/api/mod/HexItemTags.java index e4a1cce5..3c330936 100644 --- a/src/main/java/at/petrak/hexcasting/common/items/HexItemTags.java +++ b/src/main/java/at/petrak/hexcasting/api/mod/HexItemTags.java @@ -1,6 +1,5 @@ -package at.petrak.hexcasting.common.items; +package at.petrak.hexcasting.api.mod; -import at.petrak.hexcasting.HexMod; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.ItemTags; import net.minecraft.tags.TagKey; @@ -14,6 +13,6 @@ public class HexItemTags { public static final TagKey AMETHYST_DUST = ItemTags.create(new ResourceLocation("forge", "dusts/amethyst")); private static TagKey create(String name) { - return ItemTags.create(new ResourceLocation(HexMod.MOD_ID, name)); + return ItemTags.create(new ResourceLocation("hexcasting", name)); } } diff --git a/src/main/java/at/petrak/hexcasting/api/spell/casting/CastingHarness.kt b/src/main/java/at/petrak/hexcasting/api/spell/casting/CastingHarness.kt index 3702e9b6..c8bf3b55 100644 --- a/src/main/java/at/petrak/hexcasting/api/spell/casting/CastingHarness.kt +++ b/src/main/java/at/petrak/hexcasting/api/spell/casting/CastingHarness.kt @@ -3,7 +3,6 @@ package at.petrak.hexcasting.api.spell.casting import at.petrak.hexcasting.api.mod.HexConfig import at.petrak.hexcasting.api.PatternRegistry import at.petrak.hexcasting.api.circle.BlockEntityAbstractImpetus -import at.petrak.hexcasting.api.item.CasterItem import at.petrak.hexcasting.api.spell.Operator import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.SpellDatum @@ -18,6 +17,7 @@ import at.petrak.hexcasting.api.cap.HexCapabilities import at.petrak.hexcasting.api.advancements.HexAdvancementTriggers import at.petrak.hexcasting.api.utils.ManaHelper import at.petrak.hexcasting.api.spell.Widget +import at.petrak.hexcasting.api.mod.HexItemTags import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag import net.minecraft.nbt.Tag @@ -283,7 +283,7 @@ class CastingHarness private constructor( } else { false } - if (casterStack.item is CasterItem || ipsCanDrawFromInv) { + if (casterStack.`is`(HexItemTags.WANDS) || ipsCanDrawFromInv) { val manableItems = this.ctx.caster.inventory.items .filter(ManaHelper::isManaItem) .sortedWith(Comparator(ManaHelper::compare).reversed()) diff --git a/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapEntityTooFarAway.kt b/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapEntityTooFarAway.kt index 3ef6e443..2d340bbf 100644 --- a/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapEntityTooFarAway.kt +++ b/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapEntityTooFarAway.kt @@ -1,9 +1,9 @@ package at.petrak.hexcasting.api.spell.mishaps -import at.petrak.hexcasting.api.item.CasterItem 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 @@ -18,7 +18,7 @@ class MishapEntityTooFarAway(val entity: Entity) : Mishap() { // Knock the player's items out of their hands val items = mutableListOf() for (hand in InteractionHand.values()) { - if (hand != ctx.castingHand || ctx.caster.getItemInHand(hand).item !is CasterItem) { + if (hand != ctx.castingHand || ctx.caster.getItemInHand(hand).`is`(HexItemTags.WANDS)) { items.add(ctx.caster.getItemInHand(hand).copy()) ctx.caster.setItemInHand(hand, ItemStack.EMPTY) } diff --git a/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapLocationTooFarAway.kt b/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapLocationTooFarAway.kt index 56ccbb1d..25aa9656 100644 --- a/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapLocationTooFarAway.kt +++ b/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapLocationTooFarAway.kt @@ -1,9 +1,9 @@ package at.petrak.hexcasting.api.spell.mishaps -import at.petrak.hexcasting.api.item.CasterItem 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.item.DyeColor @@ -18,7 +18,7 @@ class MishapLocationTooFarAway(val location: Vec3) : Mishap() { // Knock the player's items out of their hands val items = mutableListOf() for (hand in InteractionHand.values()) { - if (hand != ctx.castingHand || ctx.caster.getItemInHand(hand).item !is CasterItem) { + if (hand != ctx.castingHand || ctx.caster.getItemInHand(hand).`is`(HexItemTags.WANDS)) { items.add(ctx.caster.getItemInHand(hand).copy()) ctx.caster.setItemInHand(hand, ItemStack.EMPTY) } diff --git a/src/main/java/at/petrak/hexcasting/client/gui/GuiSpellcasting.kt b/src/main/java/at/petrak/hexcasting/client/gui/GuiSpellcasting.kt index 61204421..9d2289be 100644 --- a/src/main/java/at/petrak/hexcasting/client/gui/GuiSpellcasting.kt +++ b/src/main/java/at/petrak/hexcasting/client/gui/GuiSpellcasting.kt @@ -9,7 +9,6 @@ import at.petrak.hexcasting.api.spell.casting.ResolvedPattern import at.petrak.hexcasting.api.spell.casting.ResolvedPatternValidity import at.petrak.hexcasting.common.items.HexItems import at.petrak.hexcasting.common.items.ItemSpellbook -import at.petrak.hexcasting.common.items.ItemWand import at.petrak.hexcasting.common.lib.HexSounds import at.petrak.hexcasting.common.network.HexMessages import at.petrak.hexcasting.common.network.MsgNewSpellPatternSyn @@ -18,6 +17,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.mod.HexItemTags import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.Minecraft @@ -87,7 +87,7 @@ class GuiSpellcasting(private val handOpenedWith: InteractionHand, val player = minecraft.player if (player != null) { val heldItem = player.getItemInHand(handOpenedWith) - if (heldItem.isEmpty || heldItem.item !is ItemWand) + if (heldItem.isEmpty || !heldItem.`is`(HexItemTags.WANDS)) onClose() } } diff --git a/src/main/java/at/petrak/hexcasting/common/items/ItemWand.java b/src/main/java/at/petrak/hexcasting/common/items/ItemWand.java index 997cf3b6..67115c04 100644 --- a/src/main/java/at/petrak/hexcasting/common/items/ItemWand.java +++ b/src/main/java/at/petrak/hexcasting/common/items/ItemWand.java @@ -1,7 +1,6 @@ package at.petrak.hexcasting.common.items; import at.petrak.hexcasting.HexMod; -import at.petrak.hexcasting.api.item.CasterItem; import at.petrak.hexcasting.api.player.HexPlayerDataHelper; import at.petrak.hexcasting.common.lib.HexSounds; import at.petrak.hexcasting.common.network.HexMessages; @@ -17,7 +16,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraftforge.network.PacketDistributor; -public class ItemWand extends Item implements CasterItem { +public class ItemWand extends Item { // 0 = normal. 1 = old. 2 = bosnia public static final ResourceLocation FUNNY_LEVEL_PREDICATE = new ResourceLocation(HexMod.MOD_ID, "funny_level"); diff --git a/src/main/java/at/petrak/hexcasting/common/network/MsgNewSpellPatternSyn.java b/src/main/java/at/petrak/hexcasting/common/network/MsgNewSpellPatternSyn.java index 258ae720..e9419c0f 100644 --- a/src/main/java/at/petrak/hexcasting/common/network/MsgNewSpellPatternSyn.java +++ b/src/main/java/at/petrak/hexcasting/common/network/MsgNewSpellPatternSyn.java @@ -1,12 +1,12 @@ package at.petrak.hexcasting.common.network; +import at.petrak.hexcasting.api.player.HexPlayerDataHelper; import at.petrak.hexcasting.api.spell.casting.ControllerInfo; import at.petrak.hexcasting.api.spell.casting.ResolvedPattern; import at.petrak.hexcasting.api.spell.casting.ResolvedPatternValidity; import at.petrak.hexcasting.api.spell.math.HexCoord; import at.petrak.hexcasting.api.spell.math.HexPattern; -import at.petrak.hexcasting.common.items.ItemWand; -import at.petrak.hexcasting.api.player.HexPlayerDataHelper; +import at.petrak.hexcasting.api.mod.HexItemTags; import at.petrak.hexcasting.common.lib.HexSounds; import io.netty.buffer.ByteBuf; import net.minecraft.network.FriendlyByteBuf; @@ -53,7 +53,7 @@ public record MsgNewSpellPatternSyn(InteractionHand handUsed, HexPattern pattern ServerPlayer sender = networkCtx.get().getSender(); if (sender != null) { var held = sender.getItemInHand(this.handUsed); - if (held.getItem() instanceof ItemWand) { + if (held.is(HexItemTags.WANDS)) { boolean autoFail = false; if (!resolvedPatterns.isEmpty()) { diff --git a/src/main/java/at/petrak/hexcasting/datagen/HexItemTagProvider.java b/src/main/java/at/petrak/hexcasting/datagen/HexItemTagProvider.java index d3bec49d..90b23874 100644 --- a/src/main/java/at/petrak/hexcasting/datagen/HexItemTagProvider.java +++ b/src/main/java/at/petrak/hexcasting/datagen/HexItemTagProvider.java @@ -2,7 +2,7 @@ package at.petrak.hexcasting.datagen; import at.petrak.hexcasting.HexMod; import at.petrak.hexcasting.common.blocks.HexBlockTags; -import at.petrak.hexcasting.common.items.HexItemTags; +import at.petrak.hexcasting.api.mod.HexItemTags; import at.petrak.hexcasting.common.items.HexItems; import net.minecraft.data.DataGenerator; import net.minecraft.data.tags.BlockTagsProvider; diff --git a/src/main/java/at/petrak/hexcasting/datagen/HexRecipes.java b/src/main/java/at/petrak/hexcasting/datagen/HexRecipes.java index 3c07c1b6..fc3a97c5 100644 --- a/src/main/java/at/petrak/hexcasting/datagen/HexRecipes.java +++ b/src/main/java/at/petrak/hexcasting/datagen/HexRecipes.java @@ -3,7 +3,7 @@ package at.petrak.hexcasting.datagen; import at.petrak.hexcasting.HexMod; import at.petrak.hexcasting.api.advancements.OvercastTrigger; import at.petrak.hexcasting.common.blocks.HexBlocks; -import at.petrak.hexcasting.common.items.HexItemTags; +import at.petrak.hexcasting.api.mod.HexItemTags; import at.petrak.hexcasting.common.items.HexItems; import at.petrak.hexcasting.common.recipe.SealFocusRecipe; import at.petrak.hexcasting.common.recipe.ingredient.StateIngredientHelper;