replace CasterItem with HexItemTags.WANDS

This commit is contained in:
yrsegal@gmail.com 2022-04-16 14:16:39 -04:00
parent 308474e268
commit 23b01093df
10 changed files with 16 additions and 22 deletions

View file

@ -1,4 +0,0 @@
package at.petrak.hexcasting.api.item;
public interface CasterItem {
}

View file

@ -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.resources.ResourceLocation;
import net.minecraft.tags.ItemTags; import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
@ -14,6 +13,6 @@ public class HexItemTags {
public static final TagKey<Item> AMETHYST_DUST = ItemTags.create(new ResourceLocation("forge", "dusts/amethyst")); public static final TagKey<Item> AMETHYST_DUST = ItemTags.create(new ResourceLocation("forge", "dusts/amethyst"));
private static TagKey<Item> create(String name) { private static TagKey<Item> create(String name) {
return ItemTags.create(new ResourceLocation(HexMod.MOD_ID, name)); return ItemTags.create(new ResourceLocation("hexcasting", name));
} }
} }

View file

@ -3,7 +3,6 @@ package at.petrak.hexcasting.api.spell.casting
import at.petrak.hexcasting.api.mod.HexConfig import at.petrak.hexcasting.api.mod.HexConfig
import at.petrak.hexcasting.api.PatternRegistry import at.petrak.hexcasting.api.PatternRegistry
import at.petrak.hexcasting.api.circle.BlockEntityAbstractImpetus 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.Operator
import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.ParticleSpray
import at.petrak.hexcasting.api.spell.SpellDatum 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.advancements.HexAdvancementTriggers
import at.petrak.hexcasting.api.utils.ManaHelper import at.petrak.hexcasting.api.utils.ManaHelper
import at.petrak.hexcasting.api.spell.Widget import at.petrak.hexcasting.api.spell.Widget
import at.petrak.hexcasting.api.mod.HexItemTags
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
@ -283,7 +283,7 @@ class CastingHarness private constructor(
} else { } else {
false false
} }
if (casterStack.item is CasterItem || ipsCanDrawFromInv) { if (casterStack.`is`(HexItemTags.WANDS) || ipsCanDrawFromInv) {
val manableItems = this.ctx.caster.inventory.items val manableItems = this.ctx.caster.inventory.items
.filter(ManaHelper::isManaItem) .filter(ManaHelper::isManaItem)
.sortedWith(Comparator(ManaHelper::compare).reversed()) .sortedWith(Comparator(ManaHelper::compare).reversed())

View file

@ -1,9 +1,9 @@
package at.petrak.hexcasting.api.spell.mishaps 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.SpellDatum
import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.misc.FrozenColorizer import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.mod.HexItemTags
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionHand
import net.minecraft.world.entity.Entity 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 // Knock the player's items out of their hands
val items = mutableListOf<ItemStack>() val items = mutableListOf<ItemStack>()
for (hand in InteractionHand.values()) { 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()) items.add(ctx.caster.getItemInHand(hand).copy())
ctx.caster.setItemInHand(hand, ItemStack.EMPTY) ctx.caster.setItemInHand(hand, ItemStack.EMPTY)
} }

View file

@ -1,9 +1,9 @@
package at.petrak.hexcasting.api.spell.mishaps 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.SpellDatum
import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.misc.FrozenColorizer import at.petrak.hexcasting.api.misc.FrozenColorizer
import at.petrak.hexcasting.api.mod.HexItemTags
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionHand
import net.minecraft.world.item.DyeColor 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 // Knock the player's items out of their hands
val items = mutableListOf<ItemStack>() val items = mutableListOf<ItemStack>()
for (hand in InteractionHand.values()) { 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()) items.add(ctx.caster.getItemInHand(hand).copy())
ctx.caster.setItemInHand(hand, ItemStack.EMPTY) ctx.caster.setItemInHand(hand, ItemStack.EMPTY)
} }

View file

@ -9,7 +9,6 @@ import at.petrak.hexcasting.api.spell.casting.ResolvedPattern
import at.petrak.hexcasting.api.spell.casting.ResolvedPatternValidity import at.petrak.hexcasting.api.spell.casting.ResolvedPatternValidity
import at.petrak.hexcasting.common.items.HexItems import at.petrak.hexcasting.common.items.HexItems
import at.petrak.hexcasting.common.items.ItemSpellbook 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.lib.HexSounds
import at.petrak.hexcasting.common.network.HexMessages import at.petrak.hexcasting.common.network.HexMessages
import at.petrak.hexcasting.common.network.MsgNewSpellPatternSyn 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.HexCoord
import at.petrak.hexcasting.api.spell.math.HexDir 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.mod.HexItemTags
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.PoseStack
import net.minecraft.client.Minecraft import net.minecraft.client.Minecraft
@ -87,7 +87,7 @@ class GuiSpellcasting(private val handOpenedWith: InteractionHand,
val player = minecraft.player val player = minecraft.player
if (player != null) { if (player != null) {
val heldItem = player.getItemInHand(handOpenedWith) val heldItem = player.getItemInHand(handOpenedWith)
if (heldItem.isEmpty || heldItem.item !is ItemWand) if (heldItem.isEmpty || !heldItem.`is`(HexItemTags.WANDS))
onClose() onClose()
} }
} }

View file

@ -1,7 +1,6 @@
package at.petrak.hexcasting.common.items; package at.petrak.hexcasting.common.items;
import at.petrak.hexcasting.HexMod; import at.petrak.hexcasting.HexMod;
import at.petrak.hexcasting.api.item.CasterItem;
import at.petrak.hexcasting.api.player.HexPlayerDataHelper; import at.petrak.hexcasting.api.player.HexPlayerDataHelper;
import at.petrak.hexcasting.common.lib.HexSounds; import at.petrak.hexcasting.common.lib.HexSounds;
import at.petrak.hexcasting.common.network.HexMessages; 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.minecraft.world.level.Level;
import net.minecraftforge.network.PacketDistributor; import net.minecraftforge.network.PacketDistributor;
public class ItemWand extends Item implements CasterItem { public class ItemWand extends Item {
// 0 = normal. 1 = old. 2 = bosnia // 0 = normal. 1 = old. 2 = bosnia
public static final ResourceLocation FUNNY_LEVEL_PREDICATE = new ResourceLocation(HexMod.MOD_ID, "funny_level"); public static final ResourceLocation FUNNY_LEVEL_PREDICATE = new ResourceLocation(HexMod.MOD_ID, "funny_level");

View file

@ -1,12 +1,12 @@
package at.petrak.hexcasting.common.network; 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.ControllerInfo;
import at.petrak.hexcasting.api.spell.casting.ResolvedPattern; import at.petrak.hexcasting.api.spell.casting.ResolvedPattern;
import at.petrak.hexcasting.api.spell.casting.ResolvedPatternValidity; import at.petrak.hexcasting.api.spell.casting.ResolvedPatternValidity;
import at.petrak.hexcasting.api.spell.math.HexCoord; import at.petrak.hexcasting.api.spell.math.HexCoord;
import at.petrak.hexcasting.api.spell.math.HexPattern; import at.petrak.hexcasting.api.spell.math.HexPattern;
import at.petrak.hexcasting.common.items.ItemWand; import at.petrak.hexcasting.api.mod.HexItemTags;
import at.petrak.hexcasting.api.player.HexPlayerDataHelper;
import at.petrak.hexcasting.common.lib.HexSounds; import at.petrak.hexcasting.common.lib.HexSounds;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
@ -53,7 +53,7 @@ public record MsgNewSpellPatternSyn(InteractionHand handUsed, HexPattern pattern
ServerPlayer sender = networkCtx.get().getSender(); ServerPlayer sender = networkCtx.get().getSender();
if (sender != null) { if (sender != null) {
var held = sender.getItemInHand(this.handUsed); var held = sender.getItemInHand(this.handUsed);
if (held.getItem() instanceof ItemWand) { if (held.is(HexItemTags.WANDS)) {
boolean autoFail = false; boolean autoFail = false;
if (!resolvedPatterns.isEmpty()) { if (!resolvedPatterns.isEmpty()) {

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.datagen;
import at.petrak.hexcasting.HexMod; import at.petrak.hexcasting.HexMod;
import at.petrak.hexcasting.common.blocks.HexBlockTags; 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 at.petrak.hexcasting.common.items.HexItems;
import net.minecraft.data.DataGenerator; import net.minecraft.data.DataGenerator;
import net.minecraft.data.tags.BlockTagsProvider; import net.minecraft.data.tags.BlockTagsProvider;

View file

@ -3,7 +3,7 @@ package at.petrak.hexcasting.datagen;
import at.petrak.hexcasting.HexMod; import at.petrak.hexcasting.HexMod;
import at.petrak.hexcasting.api.advancements.OvercastTrigger; import at.petrak.hexcasting.api.advancements.OvercastTrigger;
import at.petrak.hexcasting.common.blocks.HexBlocks; 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.items.HexItems;
import at.petrak.hexcasting.common.recipe.SealFocusRecipe; import at.petrak.hexcasting.common.recipe.SealFocusRecipe;
import at.petrak.hexcasting.common.recipe.ingredient.StateIngredientHelper; import at.petrak.hexcasting.common.recipe.ingredient.StateIngredientHelper;