diff --git a/Common/src/main/java/at/petrak/hexcasting/api/addldata/Colorizer.java b/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADColorizer.java similarity index 97% rename from Common/src/main/java/at/petrak/hexcasting/api/addldata/Colorizer.java rename to Common/src/main/java/at/petrak/hexcasting/api/addldata/ADColorizer.java index 17453a16..cc11653b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/addldata/Colorizer.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADColorizer.java @@ -6,7 +6,7 @@ import net.minecraft.world.phys.Vec3; import java.util.UUID; -public interface Colorizer { +public interface ADColorizer { int color(UUID owner, float time, Vec3 position); static int morphBetweenColors(int[] colors, Vec3 gradientDir, float time, Vec3 position) { diff --git a/Common/src/main/java/at/petrak/hexcasting/api/addldata/HexHolder.java b/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADHexHolder.java similarity index 55% rename from Common/src/main/java/at/petrak/hexcasting/api/addldata/HexHolder.java rename to Common/src/main/java/at/petrak/hexcasting/api/addldata/ADHexHolder.java index a0a73bba..f40d45e3 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/addldata/HexHolder.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADHexHolder.java @@ -1,21 +1,21 @@ package at.petrak.hexcasting.api.addldata; -import at.petrak.hexcasting.api.spell.LegacySpellDatum; +import at.petrak.hexcasting.api.spell.iota.Iota; import net.minecraft.server.level.ServerLevel; import org.jetbrains.annotations.Nullable; import java.util.List; -public interface HexHolder { +public interface ADHexHolder { boolean canDrawManaFromInventory(); boolean hasHex(); @Nullable - List> getHex(ServerLevel level); + List getHex(ServerLevel level); - void writeHex(List> patterns, int mana); + void writeHex(List patterns, int mana); void clearHex(); } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADIotaHolder.java b/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADIotaHolder.java new file mode 100644 index 00000000..da346bdb --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADIotaHolder.java @@ -0,0 +1,32 @@ +package at.petrak.hexcasting.api.addldata; + +import at.petrak.hexcasting.api.spell.iota.Iota; +import at.petrak.hexcasting.common.lib.HexIotaTypes; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; +import org.jetbrains.annotations.Nullable; + +public interface ADIotaHolder { + @Nullable + CompoundTag readIotaTag(); + + @Nullable + default Iota readIota(ServerLevel world) { + var tag = readIotaTag(); + if (tag != null) { + return HexIotaTypes.deserialize(tag, world); + } else { + return null; + } + } + + @Nullable + default Iota emptyIota() { + return null; + } + + /** + * @return if the writing succeeded/would succeed + */ + boolean writeIota(@Nullable Iota iota, boolean simulate); +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADMediaHolder.java b/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADMediaHolder.java new file mode 100644 index 00000000..9ffc009d --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/addldata/ADMediaHolder.java @@ -0,0 +1,42 @@ +package at.petrak.hexcasting.api.addldata; + +public interface ADMediaHolder { + + int getMedia(); + + int getMaxMedia(); + + void setMedia(int media); + + boolean canRecharge(); + + boolean canProvide(); + + /** + * When scanning an inventory for media-containing items, the items with the highest priority will + * get their media consumed first. + */ + int getConsumptionPriority(); + + boolean canConstructBattery(); + + default int withdrawMedia(int cost, boolean simulate) { + if (!canProvide()) { + return 0; + } + var manaHere = getMedia(); + if (cost < 0) { + cost = manaHere; + } + if (!simulate) { + var manaLeft = manaHere - cost; + setMedia(manaLeft); + } + return Math.min(cost, manaHere); + } + + public int CHARGED_AMETHYST_PRIORITY = 1000; + public int AMETHYST_SHARD_PRIORITY = 2000; + public int AMETHYST_DUST_PRIORITY = 3000; + public int BATTERY_PRIORITY = 4000; +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/addldata/DataHolder.java b/Common/src/main/java/at/petrak/hexcasting/api/addldata/DataHolder.java deleted file mode 100644 index ae323a8a..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/addldata/DataHolder.java +++ /dev/null @@ -1,28 +0,0 @@ -package at.petrak.hexcasting.api.addldata; - -import at.petrak.hexcasting.api.spell.LegacySpellDatum; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.server.level.ServerLevel; -import org.jetbrains.annotations.Nullable; - -public interface DataHolder { - @Nullable - CompoundTag readRawDatum(); - - @Nullable - default LegacySpellDatum readDatum(ServerLevel world) { - var tag = readRawDatum(); - if (tag != null) { - return LegacySpellDatum.fromNBT(tag, world); - } else { - return null; - } - } - - @Nullable - default LegacySpellDatum emptyDatum() { - return null; - } - - boolean writeDatum(@Nullable LegacySpellDatum datum, boolean simulate); -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/addldata/ManaHolder.java b/Common/src/main/java/at/petrak/hexcasting/api/addldata/ManaHolder.java deleted file mode 100644 index 01debb5a..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/addldata/ManaHolder.java +++ /dev/null @@ -1,33 +0,0 @@ -package at.petrak.hexcasting.api.addldata; - -public interface ManaHolder { - - int getMana(); - - int getMaxMana(); - - void setMana(int mana); - - boolean canRecharge(); - - boolean canProvide(); - - int getConsumptionPriority(); - - boolean canConstructBattery(); - - default int withdrawMana(int cost, boolean simulate) { - if (!canProvide()) { - return 0; - } - var manaHere = getMana(); - if (cost < 0) { - cost = manaHere; - } - if (!simulate) { - var manaLeft = manaHere - cost; - setMana(manaLeft); - } - return Math.min(cost, manaHere); - } -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/addldata/package-info.java b/Common/src/main/java/at/petrak/hexcasting/api/addldata/package-info.java new file mode 100644 index 00000000..a11787c8 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/addldata/package-info.java @@ -0,0 +1,10 @@ +/** + * An "Additional Data," or AD, is what I am calling the abstraction over capabilities on Forge and + * cardinal components on Fabric. + *

+ * An {@code ADFooBar} in this package will be implemented by a {@code CCFooBar} on Fabric. + * On Forge, there are a set of private records that implement them. + *

+ * The point is, this provides an interface for interacting with however whatever platform sticks extra info on stuff. + */ +package at.petrak.hexcasting.api.addldata; diff --git a/Common/src/main/java/at/petrak/hexcasting/api/item/ColorizerItem.java b/Common/src/main/java/at/petrak/hexcasting/api/item/ColorizerItem.java index 8e9d5671..3cb09b50 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/item/ColorizerItem.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/item/ColorizerItem.java @@ -5,6 +5,12 @@ import net.minecraft.world.phys.Vec3; import java.util.UUID; +/** + * Items which can be used as a colorizer can implement this interface. + *

+ * On both the Forge and Fabric sides, the registry will be scanned for all items which implement this interface, + * and the appropriate cap/CC will be attached. + */ public interface ColorizerItem { - int color(ItemStack stack, UUID owner, float time, Vec3 position); + int color(ItemStack stack, UUID owner, float time, Vec3 position); } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/item/DataHolderItem.java b/Common/src/main/java/at/petrak/hexcasting/api/item/DataHolderItem.java deleted file mode 100644 index 880bca65..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/item/DataHolderItem.java +++ /dev/null @@ -1,63 +0,0 @@ -package at.petrak.hexcasting.api.item; - -import at.petrak.hexcasting.api.spell.LegacySpellDatum; -import at.petrak.hexcasting.api.utils.NBTHelper; -import net.minecraft.ChatFormatting; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.NbtUtils; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.TooltipFlag; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -public interface DataHolderItem { - String TAG_OVERRIDE_VISUALLY = "VisualOverride"; - - @Nullable CompoundTag readDatumTag(ItemStack stack); - - @Nullable - default LegacySpellDatum readDatum(ItemStack stack, ServerLevel world) { - if (!(stack.getItem() instanceof DataHolderItem dh)) { - // this should be checked via mishap beforehand - throw new IllegalArgumentException("stack's item must be an ItemDataholder but was " + stack.getItem()); - } - - var tag = dh.readDatumTag(stack); - if (tag != null) { - return LegacySpellDatum.fromNBT(tag, world); - } else { - return null; - } - } - - @Nullable - default LegacySpellDatum emptyDatum(ItemStack stack) { - return null; - } - - boolean canWrite(ItemStack stack, @Nullable LegacySpellDatum datum); - - void writeDatum(ItemStack stack, @Nullable LegacySpellDatum datum); - - static void appendHoverText(DataHolderItem self, ItemStack pStack, List pTooltipComponents, - TooltipFlag pIsAdvanced) { - var datumTag = self.readDatumTag(pStack); - if (datumTag != null) { - var component = LegacySpellDatum.displayFromNBT(datumTag); - pTooltipComponents.add(new TranslatableComponent("hexcasting.spelldata.onitem", component)); - - if (pIsAdvanced.isAdvanced()) { - pTooltipComponents.add(new TextComponent("").append(NbtUtils.toPrettyComponent(datumTag))); - } - } else if (NBTHelper.hasString(pStack, DataHolderItem.TAG_OVERRIDE_VISUALLY)) { - pTooltipComponents.add(new TranslatableComponent("hexcasting.spelldata.onitem", - new TranslatableComponent("hexcasting.spelldata.anything").withStyle(ChatFormatting.LIGHT_PURPLE))); - - } - } -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/item/HexHolderItem.java b/Common/src/main/java/at/petrak/hexcasting/api/item/HexHolderItem.java index 80ba9866..70816aab 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/item/HexHolderItem.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/item/HexHolderItem.java @@ -1,22 +1,28 @@ package at.petrak.hexcasting.api.item; -import at.petrak.hexcasting.api.spell.LegacySpellDatum; +import at.petrak.hexcasting.api.spell.iota.Iota; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.Nullable; import java.util.List; -public interface HexHolderItem extends ManaHolderItem { +/** + * Items which can cast a packaged Hex can implement this interface. + *

+ * On both the Forge and Fabric sides, the registry will be scanned for all items which implement this interface, + * and the appropriate cap/CC will be attached. + */ +public interface HexHolderItem extends MediaHolderItem { - boolean canDrawManaFromInventory(ItemStack stack); + boolean canDrawManaFromInventory(ItemStack stack); - boolean hasHex(ItemStack stack); + boolean hasHex(ItemStack stack); - @Nullable - List> getHex(ItemStack stack, ServerLevel level); + @Nullable + List getHex(ItemStack stack, ServerLevel level); - void writeHex(ItemStack stack, List> patterns, int mana); + void writeHex(ItemStack stack, List program, int mana); - void clearHex(ItemStack stack); + void clearHex(ItemStack stack); } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/item/IotaHolderItem.java b/Common/src/main/java/at/petrak/hexcasting/api/item/IotaHolderItem.java new file mode 100644 index 00000000..904853a9 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/item/IotaHolderItem.java @@ -0,0 +1,69 @@ +package at.petrak.hexcasting.api.item; + +import at.petrak.hexcasting.api.spell.iota.Iota; +import at.petrak.hexcasting.api.utils.NBTHelper; +import at.petrak.hexcasting.common.lib.HexIotaTypes; +import net.minecraft.ChatFormatting; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TooltipFlag; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +/** + * Items that store an iota to their tag can implement this interface. + *

+ * On both the Forge and Fabric sides, the registry will be scanned for all items which implement this interface, + * and the appropriate cap/CC will be attached. + */ +public interface IotaHolderItem { + String TAG_OVERRIDE_VISUALLY = "VisualOverride"; + + @Nullable CompoundTag readIotaTag(ItemStack stack); + + @Nullable + default Iota readIota(ItemStack stack, ServerLevel world) { + if (!(stack.getItem() instanceof IotaHolderItem dh)) { + // this should be checked via mishap beforehand + throw new IllegalArgumentException("stack's item must be an IotaHolderItem but was " + stack.getItem()); + } + + var tag = dh.readIotaTag(stack); + if (tag != null) { + return HexIotaTypes.deserialize(tag, world); + } else { + return null; + } + } + + @Nullable + default Iota emptyIota(ItemStack stack) { + return null; + } + + boolean canWrite(ItemStack stack, @Nullable Iota iota); + + void writeDatum(ItemStack stack, @Nullable Iota iota); + + static void appendHoverText(IotaHolderItem self, ItemStack stack, List components, + TooltipFlag flag) { + var datumTag = self.readIotaTag(stack); + if (datumTag != null) { + var cmp = HexIotaTypes.getDisplay(datumTag); + components.add(new TranslatableComponent("hexcasting.spelldata.onitem", cmp)); + + if (flag.isAdvanced()) { + components.add(new TextComponent("").append(NbtUtils.toPrettyComponent(datumTag))); + } + } else if (NBTHelper.hasString(stack, IotaHolderItem.TAG_OVERRIDE_VISUALLY)) { + components.add(new TranslatableComponent("hexcasting.spelldata.onitem", + new TranslatableComponent("hexcasting.spelldata.anything").withStyle(ChatFormatting.LIGHT_PURPLE))); + } + } +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/item/ManaHolderItem.java b/Common/src/main/java/at/petrak/hexcasting/api/item/ManaHolderItem.java deleted file mode 100644 index 4247bba9..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/item/ManaHolderItem.java +++ /dev/null @@ -1,35 +0,0 @@ -package at.petrak.hexcasting.api.item; - -import net.minecraft.world.item.ItemStack; - -public interface ManaHolderItem { - int getMana(ItemStack stack); - - int getMaxMana(ItemStack stack); - - void setMana(ItemStack stack, int mana); - - boolean manaProvider(ItemStack stack); - - boolean canRecharge(ItemStack stack); - - default float getManaFullness(ItemStack stack) { - int max = getMaxMana(stack); - if (max == 0) { - return 0; - } - return (float) getMana(stack) / (float) max; - } - - default int withdrawMana(ItemStack stack, int cost, boolean simulate) { - var manaHere = getMana(stack); - if (cost < 0) { - cost = manaHere; - } - if (!simulate) { - var manaLeft = manaHere - cost; - setMana(stack, manaLeft); - } - return Math.min(cost, manaHere); - } -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/item/MediaHolderItem.java b/Common/src/main/java/at/petrak/hexcasting/api/item/MediaHolderItem.java new file mode 100644 index 00000000..206db239 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/api/item/MediaHolderItem.java @@ -0,0 +1,41 @@ +package at.petrak.hexcasting.api.item; + +import net.minecraft.world.item.ItemStack; + +/** + * Items which can store Media can implement this interface. + *

+ * On both the Forge and Fabric sides, the registry will be scanned for all items which implement this interface, + * and the appropriate cap/CC will be attached. + */ +public interface MediaHolderItem { + int getMedia(ItemStack stack); + + int getMaxMedia(ItemStack stack); + + void setMedia(ItemStack stack, int media); + + boolean canProvideMedia(ItemStack stack); + + boolean canRecharge(ItemStack stack); + + default float getManaFullness(ItemStack stack) { + int max = getMaxMedia(stack); + if (max == 0) { + return 0; + } + return (float) getMedia(stack) / (float) max; + } + + default int withdrawMana(ItemStack stack, int cost, boolean simulate) { + var manaHere = getMedia(stack); + if (cost < 0) { + cost = manaHere; + } + if (!simulate) { + var manaLeft = manaHere - cost; + setMedia(stack, manaLeft); + } + return Math.min(cost, manaHere); + } +} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/misc/FrozenColorizer.java b/Common/src/main/java/at/petrak/hexcasting/api/misc/FrozenColorizer.java index 19652762..679948c5 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/misc/FrozenColorizer.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/misc/FrozenColorizer.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.api.misc; -import at.petrak.hexcasting.api.addldata.Colorizer; +import at.petrak.hexcasting.api.addldata.ADColorizer; import at.petrak.hexcasting.common.items.colorizer.ItemPrideColorizer; import at.petrak.hexcasting.common.lib.HexItems; import at.petrak.hexcasting.xplat.IXplatAbstractions; @@ -31,7 +31,8 @@ public record FrozenColorizer(ItemStack item, UUID owner) { 0xFF200000, 0xFF202000, 0xFF002000, 0xFF002020, 0xFF000020, 0xFF200020 }; - private static final Map> OLD_PRIDE_COLORIZERS = Arrays.stream(ItemPrideColorizer.Type.values()) + private static final Map> OLD_PRIDE_COLORIZERS = Arrays.stream( + ItemPrideColorizer.Type.values()) .collect(Collectors.>toMap( (type) -> modLoc("pride_colorizer_" + type.ordinal()).toString(), (type) -> (() -> HexItems.PRIDE_COLORIZERS.get(type)))); @@ -85,7 +86,7 @@ public record FrozenColorizer(ItemStack item, UUID owner) { double luminance = (0.2126 * r + 0.7152 * g + 0.0722 * b) / 0xFF; // Standard relative luminance calculation if (luminance < 0.05) { - int rawMod = Colorizer.morphBetweenColors(MINIMUM_LUMINANCE_COLOR_WHEEL, new Vec3(0.1, 0.1, 0.1), + int rawMod = ADColorizer.morphBetweenColors(MINIMUM_LUMINANCE_COLOR_WHEEL, new Vec3(0.1, 0.1, 0.1), time / 20 / 20, position); r += FastColor.ARGB32.red(rawMod); diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/CastingHarness.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/CastingHarness.kt index a338b76b..3989d79b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/CastingHarness.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/casting/CastingHarness.kt @@ -375,9 +375,9 @@ class CastingHarness private constructor( val casterHexHolder = IXplatAbstractions.INSTANCE.findHexHolder(casterStack) val hexHolderDrawsFromInventory = if (casterHexHolder != null) { if (casterManaHolder != null) { - val manaAvailable = casterManaHolder.mana + val manaAvailable = casterManaHolder.media val manaToTake = min(costLeft, manaAvailable) - if (!fake) casterManaHolder.mana = manaAvailable - manaToTake + if (!fake) casterManaHolder.media = manaAvailable - manaToTake costLeft -= manaToTake } casterHexHolder.canDrawManaFromInventory() diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/EntityIota.java b/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/EntityIota.java index c991ff8d..b6f9e96f 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/EntityIota.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/EntityIota.java @@ -1,10 +1,12 @@ package at.petrak.hexcasting.api.spell.iota; +import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.common.lib.HexIotaTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtUtils; import net.minecraft.nbt.Tag; import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import org.jetbrains.annotations.NotNull; @@ -30,7 +32,7 @@ public class EntityIota extends Iota { public @NotNull Tag serialize() { var out = new CompoundTag(); out.putUUID("uuid", this.getEntity().getUUID()); - out.putString("name", Component.Serializer.toJson(this.getEntity().getDisplayName())); + out.putString("name", Component.Serializer.toJson(this.getEntity().getName())); return out; } @@ -38,7 +40,12 @@ public class EntityIota extends Iota { @Nullable @Override public EntityIota deserialize(Tag tag, ServerLevel world) throws IllegalArgumentException { - var uuid = NbtUtils.loadUUID(tag); + var ctag = HexUtils.downcast(tag, CompoundTag.TYPE); + Tag uuidTag = ctag.get("uuid"); + if (uuidTag == null) { + return null; + } + var uuid = NbtUtils.loadUUID(uuidTag); var entity = world.getEntity(uuid); if (entity == null) { return null; @@ -48,7 +55,14 @@ public class EntityIota extends Iota { @Override public Component display(Tag tag) { - return null; + if (!(tag instanceof CompoundTag ctag)) { + return new TranslatableComponent("hexcasting.spelldata.entity.whoknows"); + } + if (!ctag.contains("name", Tag.TAG_STRING)) { + return new TranslatableComponent("hexcasting.spelldata.entity.whoknows"); + } + var nameJson = ctag.getString("name"); + return Component.Serializer.fromJsonLenient(nameJson); } @Override diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/Iota.java b/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/Iota.java index c48f09ec..298e814e 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/Iota.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/Iota.java @@ -30,6 +30,11 @@ public abstract class Iota { */ abstract public boolean toleratesOther(Iota that); + /** + * Serialize this under the {@code data} tag. + *

+ * You probably don't want to call this directly; use {@link HexIotaTypes#serialize}. + */ abstract public @NotNull Tag serialize(); /** diff --git a/Common/src/main/java/at/petrak/hexcasting/api/utils/ManaHelper.kt b/Common/src/main/java/at/petrak/hexcasting/api/utils/ManaHelper.kt index 239e3a25..1554d605 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/utils/ManaHelper.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/utils/ManaHelper.kt @@ -1,4 +1,5 @@ @file:JvmName("ManaHelper") + package at.petrak.hexcasting.api.utils import at.petrak.hexcasting.xplat.IXplatAbstractions @@ -10,7 +11,7 @@ fun isManaItem(stack: ItemStack): Boolean { val manaHolder = IXplatAbstractions.INSTANCE.findManaHolder(stack) ?: return false if (!manaHolder.canProvide()) return false - return manaHolder.withdrawMana(-1, true) > 0 + return manaHolder.withdrawMedia(-1, true) > 0 } /** @@ -33,7 +34,7 @@ fun extractMana( if (drainForBatteries && !manaHolder.canConstructBattery()) return 0 - return manaHolder.withdrawMana(cost, simulate) + return manaHolder.withdrawMedia(cost, simulate) } /** @@ -46,7 +47,7 @@ fun compareManaItem(astack: ItemStack, bstack: ItemStack): Int { return if (astack.item != bstack.item) { (aMana?.consumptionPriority ?: 0) - (bMana?.consumptionPriority ?: 0) } else if (aMana != null && bMana != null) { - aMana.mana - bMana.mana + aMana.media - bMana.media } else { astack.count - bstack.count } diff --git a/Common/src/main/java/at/petrak/hexcasting/client/RegisterClientStuff.java b/Common/src/main/java/at/petrak/hexcasting/client/RegisterClientStuff.java index 4341a357..dde3b323 100644 --- a/Common/src/main/java/at/petrak/hexcasting/client/RegisterClientStuff.java +++ b/Common/src/main/java/at/petrak/hexcasting/client/RegisterClientStuff.java @@ -3,8 +3,8 @@ package at.petrak.hexcasting.client; import at.petrak.hexcasting.api.block.circle.BlockAbstractImpetus; import at.petrak.hexcasting.api.block.circle.BlockEntityAbstractImpetus; import at.petrak.hexcasting.api.client.ScryingLensOverlayRegistry; -import at.petrak.hexcasting.api.item.DataHolderItem; -import at.petrak.hexcasting.api.item.ManaHolderItem; +import at.petrak.hexcasting.api.item.IotaHolderItem; +import at.petrak.hexcasting.api.item.MediaHolderItem; import at.petrak.hexcasting.api.misc.ManaConstants; import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.spell.Widget; @@ -20,7 +20,7 @@ import at.petrak.hexcasting.common.items.ItemFocus; import at.petrak.hexcasting.common.items.ItemScroll; import at.petrak.hexcasting.common.items.ItemSlate; import at.petrak.hexcasting.common.items.ItemWand; -import at.petrak.hexcasting.common.items.magic.ItemManaBattery; +import at.petrak.hexcasting.common.items.magic.ItemMediaBattery; import at.petrak.hexcasting.common.items.magic.ItemPackagedHex; import at.petrak.hexcasting.common.lib.HexBlockEntities; import at.petrak.hexcasting.common.lib.HexBlocks; @@ -61,15 +61,15 @@ public class RegisterClientStuff { registerPackagedSpellOverrides(HexItems.ARTIFACT); var x = IClientXplatAbstractions.INSTANCE; - x.registerItemProperty(HexItems.BATTERY, ItemManaBattery.MANA_PREDICATE, + x.registerItemProperty(HexItems.BATTERY, ItemMediaBattery.MANA_PREDICATE, (stack, level, holder, holderID) -> { - var item = (ManaHolderItem) stack.getItem(); + var item = (MediaHolderItem) stack.getItem(); return item.getManaFullness(stack); }); - x.registerItemProperty(HexItems.BATTERY, ItemManaBattery.MAX_MANA_PREDICATE, + x.registerItemProperty(HexItems.BATTERY, ItemMediaBattery.MAX_MANA_PREDICATE, (stack, level, holder, holderID) -> { - var item = (ItemManaBattery) stack.getItem(); - var max = item.getMaxMana(stack); + var item = (ItemMediaBattery) stack.getItem(); + var max = item.getMaxMedia(stack); return (float) Math.sqrt((float) max / ManaConstants.CRYSTAL_UNIT / 10); }); @@ -253,11 +253,11 @@ public class RegisterClientStuff { (stack, level, holder, holderID) -> NBTHelper.hasString(stack, ItemScroll.TAG_OP_ID) ? 1f : 0f); } - private static void registerDataHolderOverrides(DataHolderItem item) { + private static void registerDataHolderOverrides(IotaHolderItem item) { IClientXplatAbstractions.INSTANCE.registerItemProperty((Item) item, ItemFocus.DATATYPE_PRED, (stack, level, holder, holderID) -> { - var datum = item.readDatumTag(stack); - String override = NBTHelper.getString(stack, DataHolderItem.TAG_OVERRIDE_VISUALLY); + var datum = item.readIotaTag(stack); + String override = NBTHelper.getString(stack, IotaHolderItem.TAG_OVERRIDE_VISUALLY); String typename = null; if (override != null) { typename = override; diff --git a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/impetuses/BlockStoredPlayerImpetus.java b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/impetuses/BlockStoredPlayerImpetus.java index 8aaf43c0..e07c9117 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/impetuses/BlockStoredPlayerImpetus.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/impetuses/BlockStoredPlayerImpetus.java @@ -52,7 +52,7 @@ public class BlockStoredPlayerImpetus extends BlockAbstractImpetus { var datumContainer = IXplatAbstractions.INSTANCE.findDataHolder(usedStack); if (datumContainer != null) { if (pLevel instanceof ServerLevel level) { - var stored = datumContainer.readDatum(level); + var stored = datumContainer.readIota(level); if (stored != null && stored.getType() == DatumType.ENTITY) { var entity = (Entity) stored.getPayload(); if (entity instanceof Player player) { @@ -61,7 +61,7 @@ public class BlockStoredPlayerImpetus extends BlockAbstractImpetus { level.sendBlockUpdated(pPos, pState, pState, Block.UPDATE_CLIENTS); pLevel.playSound(null, pPos, HexSounds.IMPETUS_STOREDPLAYER_DING, SoundSource.BLOCKS, - 1f, 1f); + 1f, 1f); } } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpRead.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpRead.kt index ea550d43..3d371db0 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpRead.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpRead.kt @@ -12,14 +12,14 @@ object OpRead : ConstManaOperator { override fun execute(args: List>, ctx: CastingContext): List> { val (handStack, hand) = ctx.getHeldItemToOperateOn { val dataHolder = IXplatAbstractions.INSTANCE.findDataHolder(it) - dataHolder != null && (dataHolder.readDatum(ctx.world) != null || dataHolder.emptyDatum() != null) + dataHolder != null && (dataHolder.readIota(ctx.world) != null || dataHolder.emptyIota() != null) } val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(handStack) ?: throw MishapBadOffhandItem.of(handStack, hand, "iota.read") - val datum = datumHolder.readDatum(ctx.world) - ?: datumHolder.emptyDatum() + val datum = datumHolder.readIota(ctx.world) + ?: datumHolder.emptyIota() ?: throw MishapBadOffhandItem.of(handStack, hand, "iota.read") return listOf(datum) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpReadable.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpReadable.kt index edfa2f1e..374b0f2a 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpReadable.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpReadable.kt @@ -17,8 +17,8 @@ object OpReadable : ConstManaOperator { val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(handStack) ?: return false.asSpellResult - datumHolder.readDatum(ctx.world) - ?: datumHolder.emptyDatum() + datumHolder.readIota(ctx.world) + ?: datumHolder.emptyIota() ?: return false.asSpellResult return true.asSpellResult diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerRead.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerRead.kt index 99f3021a..9e0cb4e5 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerRead.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerRead.kt @@ -1,9 +1,9 @@ package at.petrak.hexcasting.common.casting.operators import at.petrak.hexcasting.api.spell.ConstManaOperator -import at.petrak.hexcasting.api.spell.getChecked import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.casting.CastingContext +import at.petrak.hexcasting.api.spell.getChecked import at.petrak.hexcasting.api.spell.mishaps.MishapBadItem import at.petrak.hexcasting.xplat.IXplatAbstractions import net.minecraft.world.entity.item.ItemEntity @@ -23,8 +23,8 @@ object OpTheCoolerRead : ConstManaOperator { val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(stack) ?: throw MishapBadItem.of(target, "iota.read") - val datum = datumHolder.readDatum(ctx.world) - ?: datumHolder.emptyDatum() + val datum = datumHolder.readIota(ctx.world) + ?: datumHolder.emptyIota() ?: throw MishapBadItem.of(target, "iota.read") return listOf(datum) } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerReadable.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerReadable.kt index 88d95db7..93626512 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerReadable.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpTheCoolerReadable.kt @@ -22,7 +22,7 @@ object OpTheCoolerReadable : ConstManaOperator { val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(stack) ?: return false.asSpellResult - if (datumHolder.readDatum(ctx.world) == null && datumHolder.emptyDatum() == null) + if (datumHolder.readIota(ctx.world) == null && datumHolder.emptyIota() == null) return false.asSpellResult return true.asSpellResult diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpWritable.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpWritable.kt index 7db4f1bd..5c1f509a 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpWritable.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpWritable.kt @@ -16,12 +16,12 @@ object OpWritable : ConstManaOperator { val (handStack) = ctx.getHeldItemToOperateOn { val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(it) - datumHolder != null && datumHolder.writeDatum(datum, true) + datumHolder != null && datumHolder.writeIota(datum, true) } val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(handStack) ?: return false.asSpellResult - if (!datumHolder.writeDatum(datum, true)) + if (!datumHolder.writeIota(datum, true)) return false.asSpellResult val trueName = MishapOthersName.getTrueNameFromDatum(datum, ctx.caster) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpWrite.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpWrite.kt index ab1fddd1..987bb34e 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpWrite.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/OpWrite.kt @@ -1,8 +1,8 @@ package at.petrak.hexcasting.common.casting.operators +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.RenderedSpell -import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.SpellOperator import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.mishaps.MishapBadOffhandItem @@ -21,13 +21,13 @@ object OpWrite : SpellOperator { val (handStack, hand) = ctx.getHeldItemToOperateOn { val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(it) - datumHolder != null && datumHolder.writeDatum(datum, true) + datumHolder != null && datumHolder.writeIota(datum, true) } val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(handStack) ?: throw MishapBadOffhandItem.of(handStack, hand, "iota.write") - if (!datumHolder.writeDatum(datum, true)) + if (!datumHolder.writeIota(datum, true)) throw MishapBadOffhandItem.of(handStack, hand, "iota.readonly", datum.display()) val trueName = MishapOthersName.getTrueNameFromDatum(datum, ctx.caster) @@ -46,11 +46,11 @@ object OpWrite : SpellOperator { val (handStack) = ctx.getHeldItemToOperateOn { val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(it) - datumHolder != null && datumHolder.writeDatum(datum, true) + datumHolder != null && datumHolder.writeIota(datum, true) } val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(handStack) - datumHolder?.writeDatum(datum, false) + datumHolder?.writeIota(datum, false) } } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpErase.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpErase.kt index 3d7baf09..0988a569 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpErase.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpErase.kt @@ -1,9 +1,9 @@ package at.petrak.hexcasting.common.casting.operators.spells import at.petrak.hexcasting.api.misc.ManaConstants +import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.RenderedSpell -import at.petrak.hexcasting.api.spell.LegacySpellDatum import at.petrak.hexcasting.api.spell.SpellOperator import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.mishaps.MishapBadOffhandItem @@ -21,13 +21,13 @@ class OpErase : SpellOperator { val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(it) (hexHolder?.hasHex() == true) || - (datumHolder?.writeDatum(null, true) == true) + (datumHolder?.writeIota(null, true) == true) } val hexHolder = IXplatAbstractions.INSTANCE.findHexHolder(handStack) val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(handStack) if ((hexHolder?.hasHex() != true) && - (datumHolder?.writeDatum(null, true) != true) + (datumHolder?.writeIota(null, true) != true) ) { throw MishapBadOffhandItem.of(handStack, hand, "eraseable") } @@ -45,7 +45,7 @@ class OpErase : SpellOperator { val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(it) (hexHolder?.hasHex() == true) || - (datumHolder?.writeDatum(null, true) == true) + (datumHolder?.writeIota(null, true) == true) } val hexHolder = IXplatAbstractions.INSTANCE.findHexHolder(handStack) val datumHolder = IXplatAbstractions.INSTANCE.findDataHolder(handStack) @@ -53,8 +53,8 @@ class OpErase : SpellOperator { if (hexHolder?.hasHex() == true) hexHolder.clearHex() - if (datumHolder != null && datumHolder.writeDatum(null, true)) - datumHolder.writeDatum(null, false) + if (datumHolder != null && datumHolder.writeIota(null, true)) + datumHolder.writeIota(null, false) } } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpMakeBattery.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpMakeBattery.kt index 182d335b..f89340d2 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpMakeBattery.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpMakeBattery.kt @@ -2,17 +2,13 @@ package at.petrak.hexcasting.common.casting.operators.spells import at.petrak.hexcasting.api.misc.ManaConstants import at.petrak.hexcasting.api.mod.HexItemTags -import at.petrak.hexcasting.api.spell.getChecked -import at.petrak.hexcasting.api.spell.ParticleSpray -import at.petrak.hexcasting.api.spell.RenderedSpell -import at.petrak.hexcasting.api.spell.LegacySpellDatum -import at.petrak.hexcasting.api.spell.SpellOperator +import at.petrak.hexcasting.api.spell.* import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.mishaps.MishapBadItem import at.petrak.hexcasting.api.spell.mishaps.MishapBadOffhandItem import at.petrak.hexcasting.api.utils.extractMana import at.petrak.hexcasting.api.utils.isManaItem -import at.petrak.hexcasting.common.items.magic.ItemManaHolder +import at.petrak.hexcasting.common.items.magic.ItemMediaHolder import at.petrak.hexcasting.common.lib.HexItems import net.minecraft.world.entity.item.ItemEntity import net.minecraft.world.item.ItemStack @@ -59,8 +55,10 @@ object OpMakeBattery : SpellOperator { ) } - return Triple(Spell(entity), - ManaConstants.CRYSTAL_UNIT, listOf(ParticleSpray.burst(entity.position(), 0.5))) + return Triple( + Spell(entity), + ManaConstants.CRYSTAL_UNIT, listOf(ParticleSpray.burst(entity.position(), 0.5)) + ) } private data class Spell(val itemEntity: ItemEntity) : RenderedSpell { @@ -72,7 +70,7 @@ object OpMakeBattery : SpellOperator { if (manaAmt > 0) { ctx.caster.setItemInHand( hand, - ItemManaHolder.withMana(ItemStack(HexItems.BATTERY), manaAmt, manaAmt) + ItemMediaHolder.withMana(ItemStack(HexItems.BATTERY), manaAmt, manaAmt) ) } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpRecharge.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpRecharge.kt index 14cb3ac7..5c19595a 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpRecharge.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpRecharge.kt @@ -18,7 +18,7 @@ object OpRecharge : SpellOperator { ): Triple>? { val (handStack, hand) = ctx.getHeldItemToOperateOn { val mana = IXplatAbstractions.INSTANCE.findManaHolder(it) - mana != null && mana.canRecharge() && mana.mana /* doo doo da do doo */ < mana.maxMana + mana != null && mana.canRecharge() && mana.media /* doo doo da do doo */ < mana.maxMedia } val mana = IXplatAbstractions.INSTANCE.findManaHolder(handStack) @@ -40,7 +40,7 @@ object OpRecharge : SpellOperator { ) } - if (mana.mana >= mana.maxMana) + if (mana.media >= mana.maxMedia) return null return Triple( @@ -54,19 +54,19 @@ object OpRecharge : SpellOperator { override fun cast(ctx: CastingContext) { val (handStack) = ctx.getHeldItemToOperateOn { val mana = IXplatAbstractions.INSTANCE.findManaHolder(it) - mana != null && mana.canRecharge() && mana.mana < mana.maxMana + mana != null && mana.canRecharge() && mana.media < mana.maxMedia } val mana = IXplatAbstractions.INSTANCE.findManaHolder(handStack) if (mana != null && itemEntity.isAlive) { val entityStack = itemEntity.item.copy() - val maxMana = mana.maxMana - val existingMana = mana.mana + val maxMana = mana.maxMedia + val existingMana = mana.media val manaAmt = extractMana(entityStack, maxMana - existingMana) - mana.mana = manaAmt + existingMana + mana.media = manaAmt + existingMana itemEntity.item = entityStack if (entityStack.isEmpty) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/items/ItemAbacus.java b/Common/src/main/java/at/petrak/hexcasting/common/items/ItemAbacus.java index 3db355c2..ab264338 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/items/ItemAbacus.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/items/ItemAbacus.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.common.items; -import at.petrak.hexcasting.api.item.DataHolderItem; +import at.petrak.hexcasting.api.item.IotaHolderItem; import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.utils.NBTHelper; import at.petrak.hexcasting.common.lib.HexSounds; @@ -18,7 +18,7 @@ import org.jetbrains.annotations.Nullable; import java.util.List; -public class ItemAbacus extends Item implements DataHolderItem { +public class ItemAbacus extends Item implements IotaHolderItem { public static final String TAG_VALUE = "value"; public ItemAbacus(Properties pProperties) { @@ -26,7 +26,7 @@ public class ItemAbacus extends Item implements DataHolderItem { } @Override - public @Nullable CompoundTag readDatumTag(ItemStack stack) { + public @Nullable CompoundTag readIotaTag(ItemStack stack) { var datum = LegacySpellDatum.make(NBTHelper.getDouble(stack, TAG_VALUE)); return datum.serializeToNBT(); } @@ -65,6 +65,6 @@ public class ItemAbacus extends Item implements DataHolderItem { @Override public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List pTooltipComponents, TooltipFlag pIsAdvanced) { - DataHolderItem.appendHoverText(this, pStack, pTooltipComponents, pIsAdvanced); + IotaHolderItem.appendHoverText(this, pStack, pTooltipComponents, pIsAdvanced); } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/items/ItemFocus.java b/Common/src/main/java/at/petrak/hexcasting/common/items/ItemFocus.java index 36f357cd..a1bc751b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/items/ItemFocus.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/items/ItemFocus.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.common.items; -import at.petrak.hexcasting.api.item.DataHolderItem; +import at.petrak.hexcasting.api.item.IotaHolderItem; import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.spell.Widget; import at.petrak.hexcasting.api.utils.NBTHelper; @@ -17,7 +17,7 @@ import java.util.List; import static at.petrak.hexcasting.api.HexAPI.modLoc; -public class ItemFocus extends Item implements DataHolderItem { +public class ItemFocus extends Item implements IotaHolderItem { public static final ResourceLocation DATATYPE_PRED = modLoc("datatype"); public static final ResourceLocation SEALED_PRED = modLoc("sealed"); @@ -29,7 +29,7 @@ public class ItemFocus extends Item implements DataHolderItem { } @Override - public @Nullable CompoundTag readDatumTag(ItemStack stack) { + public @Nullable CompoundTag readIotaTag(ItemStack stack) { return NBTHelper.getCompound(stack, TAG_DATA); } @@ -39,7 +39,7 @@ public class ItemFocus extends Item implements DataHolderItem { } @Override - public @Nullable LegacySpellDatum emptyDatum(ItemStack stack) { + public @Nullable LegacySpellDatum emptyIota(ItemStack stack) { return LegacySpellDatum.make(Widget.NULL); } @@ -61,6 +61,6 @@ public class ItemFocus extends Item implements DataHolderItem { @Override public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List pTooltipComponents, TooltipFlag pIsAdvanced) { - DataHolderItem.appendHoverText(this, pStack, pTooltipComponents, pIsAdvanced); + IotaHolderItem.appendHoverText(this, pStack, pTooltipComponents, pIsAdvanced); } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/items/ItemScroll.java b/Common/src/main/java/at/petrak/hexcasting/common/items/ItemScroll.java index 2b65a915..adf19f8e 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/items/ItemScroll.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/items/ItemScroll.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.common.items; -import at.petrak.hexcasting.api.item.DataHolderItem; +import at.petrak.hexcasting.api.item.IotaHolderItem; import at.petrak.hexcasting.api.spell.DatumType; import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.spell.math.HexPattern; @@ -36,7 +36,7 @@ import static at.petrak.hexcasting.api.HexAPI.modLoc; *
* TAG_OP_ID: invalid */ -public class ItemScroll extends Item implements DataHolderItem { +public class ItemScroll extends Item implements IotaHolderItem { public static final String TAG_OP_ID = "op_id"; public static final String TAG_PATTERN = "pattern"; public static final ResourceLocation ANCIENT_PREDICATE = modLoc("ancient"); @@ -49,7 +49,7 @@ public class ItemScroll extends Item implements DataHolderItem { } @Override - public @Nullable CompoundTag readDatumTag(ItemStack stack) { + public @Nullable CompoundTag readIotaTag(ItemStack stack) { CompoundTag pattern = NBTHelper.getCompound(stack, TAG_PATTERN); if (pattern == null) { return null; diff --git a/Common/src/main/java/at/petrak/hexcasting/common/items/ItemSlate.java b/Common/src/main/java/at/petrak/hexcasting/common/items/ItemSlate.java index 980d69b3..386a0522 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/items/ItemSlate.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/items/ItemSlate.java @@ -2,12 +2,12 @@ package at.petrak.hexcasting.common.items; import at.petrak.hexcasting.annotations.SoftImplement; import at.petrak.hexcasting.api.HexAPI; -import at.petrak.hexcasting.api.item.DataHolderItem; +import at.petrak.hexcasting.api.item.IotaHolderItem; import at.petrak.hexcasting.api.spell.DatumType; import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.spell.math.HexPattern; -import at.petrak.hexcasting.client.gui.PatternTooltipGreeble; import at.petrak.hexcasting.api.utils.NBTHelper; +import at.petrak.hexcasting.client.gui.PatternTooltipGreeble; import at.petrak.hexcasting.common.blocks.circles.BlockEntitySlate; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; @@ -27,7 +27,7 @@ import java.util.Optional; import static at.petrak.hexcasting.api.HexAPI.modLoc; -public class ItemSlate extends BlockItem implements DataHolderItem { +public class ItemSlate extends BlockItem implements IotaHolderItem { public static final ResourceLocation WRITTEN_PRED = modLoc("written"); public ItemSlate(Block pBlock, Properties pProperties) { @@ -51,19 +51,21 @@ public class ItemSlate extends BlockItem implements DataHolderItem { @SoftImplement("IForgeItem") public boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity) { - if (!hasPattern(stack)) + if (!hasPattern(stack)) { NBTHelper.remove(stack, "BlockEntityTag"); + } return false; } @Override public void inventoryTick(ItemStack pStack, Level pLevel, Entity pEntity, int pSlotId, boolean pIsSelected) { - if (!hasPattern(pStack)) + if (!hasPattern(pStack)) { NBTHelper.remove(pStack, "BlockEntityTag"); + } } @Override - public @Nullable CompoundTag readDatumTag(ItemStack stack) { + public @Nullable CompoundTag readIotaTag(ItemStack stack) { var bet = NBTHelper.getCompound(stack, "BlockEntityTag"); if (bet == null || !bet.contains(BlockEntitySlate.TAG_PATTERN, Tag.TAG_COMPOUND)) { @@ -90,8 +92,9 @@ public class ItemSlate extends BlockItem implements DataHolderItem { if (datum == null) { var beTag = NBTHelper.getOrCreateCompound(stack, "BlockEntityTag"); beTag.remove(BlockEntitySlate.TAG_PATTERN); - if (beTag.isEmpty()) + if (beTag.isEmpty()) { NBTHelper.remove(stack, "BlockEntityTag"); + } } else if (datum.getPayload() instanceof HexPattern pat) { var beTag = NBTHelper.getOrCreateCompound(stack, "BlockEntityTag"); beTag.put(BlockEntitySlate.TAG_PATTERN, pat.serializeToNBT()); diff --git a/Common/src/main/java/at/petrak/hexcasting/common/items/ItemSpellbook.java b/Common/src/main/java/at/petrak/hexcasting/common/items/ItemSpellbook.java index b162dc05..8d2e7f8e 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/items/ItemSpellbook.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/items/ItemSpellbook.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.common.items; -import at.petrak.hexcasting.api.item.DataHolderItem; +import at.petrak.hexcasting.api.item.IotaHolderItem; import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.spell.Widget; import at.petrak.hexcasting.api.utils.NBTHelper; @@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable; import java.util.List; import java.util.stream.Stream; -public class ItemSpellbook extends Item implements DataHolderItem { +public class ItemSpellbook extends Item implements IotaHolderItem { public static String TAG_SELECTED_PAGE = "page_idx"; // this is a CompoundTag of string numerical keys to SpellData // it is 1-indexed, so that 0/0 can be the special case of "it is empty" @@ -86,7 +86,7 @@ public class ItemSpellbook extends Item implements DataHolderItem { } } - DataHolderItem.appendHoverText(this, stack, tooltip, isAdvanced); + IotaHolderItem.appendHoverText(this, stack, tooltip, isAdvanced); super.appendHoverText(stack, level, tooltip, isAdvanced); } @@ -112,7 +112,7 @@ public class ItemSpellbook extends Item implements DataHolderItem { } @Override - public @Nullable CompoundTag readDatumTag(ItemStack stack) { + public @Nullable CompoundTag readIotaTag(ItemStack stack) { int idx = GetPage(stack, 1); var key = String.valueOf(idx); var tag = NBTHelper.getCompound(stack, TAG_PAGES); @@ -124,7 +124,7 @@ public class ItemSpellbook extends Item implements DataHolderItem { } @Override - public @Nullable LegacySpellDatum emptyDatum(ItemStack stack) { + public @Nullable LegacySpellDatum emptyIota(ItemStack stack) { return LegacySpellDatum.make(Widget.NULL); } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/items/colorizer/ItemPrideColorizer.java b/Common/src/main/java/at/petrak/hexcasting/common/items/colorizer/ItemPrideColorizer.java index 6379877b..758c6b58 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/items/colorizer/ItemPrideColorizer.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/items/colorizer/ItemPrideColorizer.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.common.items.colorizer; -import at.petrak.hexcasting.api.addldata.Colorizer; +import at.petrak.hexcasting.api.addldata.ADColorizer; import at.petrak.hexcasting.api.item.ColorizerItem; import net.minecraft.Util; import net.minecraft.world.item.Item; @@ -44,7 +44,7 @@ public class ItemPrideColorizer extends Item implements ColorizerItem { @Override public int color(ItemStack stack, UUID owner, float time, Vec3 position) { - return Colorizer.morphBetweenColors(getColors(), new Vec3(0.1, 0.1, 0.1), time / 20 / 20, position); + return ADColorizer.morphBetweenColors(getColors(), new Vec3(0.1, 0.1, 0.1), time / 20 / 20, position); } public int[] getColors() { diff --git a/Common/src/main/java/at/petrak/hexcasting/common/items/colorizer/ItemUUIDColorizer.java b/Common/src/main/java/at/petrak/hexcasting/common/items/colorizer/ItemUUIDColorizer.java index a0d0250c..f7634975 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/items/colorizer/ItemUUIDColorizer.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/items/colorizer/ItemUUIDColorizer.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.common.items.colorizer; -import at.petrak.hexcasting.api.addldata.Colorizer; +import at.petrak.hexcasting.api.addldata.ADColorizer; import at.petrak.hexcasting.api.item.ColorizerItem; import at.petrak.paucal.api.PaucalAPI; import net.minecraft.world.item.Item; @@ -35,7 +35,7 @@ public class ItemUUIDColorizer extends Item implements ColorizerItem { } } if (ok) { - return Colorizer.morphBetweenColors(colors, new Vec3(0.1, 0.1, 0.1), time / 20 / 20, position); + return ADColorizer.morphBetweenColors(colors, new Vec3(0.1, 0.1, 0.1), time / 20 / 20, position); } } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemCreativeUnlocker.java b/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemCreativeUnlocker.java index 33c46cef..5ac53bd4 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemCreativeUnlocker.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemCreativeUnlocker.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.common.items.magic; -import at.petrak.hexcasting.api.item.ManaHolderItem; +import at.petrak.hexcasting.api.item.MediaHolderItem; import at.petrak.hexcasting.api.misc.ManaConstants; import at.petrak.hexcasting.api.utils.NBTHelper; import at.petrak.hexcasting.common.lib.HexItems; @@ -27,7 +27,7 @@ import java.util.Locale; import static at.petrak.hexcasting.api.HexAPI.modLoc; -public class ItemCreativeUnlocker extends Item implements ManaHolderItem { +public class ItemCreativeUnlocker extends Item implements MediaHolderItem { public static boolean isDebug(ItemStack stack) { return stack.is(HexItems.CREATIVE_UNLOCKER) @@ -42,22 +42,22 @@ public class ItemCreativeUnlocker extends Item implements ManaHolderItem { } @Override - public int getMana(ItemStack stack) { + public int getMedia(ItemStack stack) { return Integer.MAX_VALUE; } @Override - public int getMaxMana(ItemStack stack) { + public int getMaxMedia(ItemStack stack) { return Integer.MAX_VALUE - 1; } @Override - public void setMana(ItemStack stack, int mana) { + public void setMedia(ItemStack stack, int media) { // NO-OP } @Override - public boolean manaProvider(ItemStack stack) { + public boolean canProvideMedia(ItemStack stack) { return true; } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemManaBattery.java b/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemMediaBattery.java similarity index 84% rename from Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemManaBattery.java rename to Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemMediaBattery.java index ff00529f..3887e05b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemManaBattery.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemMediaBattery.java @@ -9,16 +9,16 @@ import org.jetbrains.annotations.NotNull; import static at.petrak.hexcasting.api.HexAPI.modLoc; -public class ItemManaBattery extends ItemManaHolder { +public class ItemMediaBattery extends ItemMediaHolder { public static final ResourceLocation MANA_PREDICATE = modLoc("mana"); public static final ResourceLocation MAX_MANA_PREDICATE = modLoc("max_mana"); - public ItemManaBattery(Properties pProperties) { + public ItemMediaBattery(Properties pProperties) { super(pProperties); } @Override - public boolean manaProvider(ItemStack stack) { + public boolean canProvideMedia(ItemStack stack) { return true; } @@ -40,7 +40,7 @@ public class ItemManaBattery extends ItemManaHolder { }; for (int manamount : manamounts) { var stack = new ItemStack(this); - items.add(ItemManaHolder.withMana(stack, manamount, manamount)); + items.add(ItemMediaHolder.withMana(stack, manamount, manamount)); } } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemManaHolder.java b/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemMediaHolder.java similarity index 70% rename from Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemManaHolder.java rename to Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemMediaHolder.java index 243f8962..f37c592c 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemManaHolder.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemMediaHolder.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.common.items.magic; -import at.petrak.hexcasting.api.item.ManaHolderItem; +import at.petrak.hexcasting.api.item.MediaHolderItem; import at.petrak.hexcasting.api.utils.ManaHelper; import at.petrak.hexcasting.api.utils.NBTHelper; import net.minecraft.ChatFormatting; @@ -15,17 +15,17 @@ import org.jetbrains.annotations.Nullable; import java.util.List; -public abstract class ItemManaHolder extends Item implements ManaHolderItem { +public abstract class ItemMediaHolder extends Item implements MediaHolderItem { public static final String TAG_MANA = "hexcasting:mana"; public static final String TAG_MAX_MANA = "hexcasting:start_mana"; - public ItemManaHolder(Properties pProperties) { + public ItemMediaHolder(Properties pProperties) { super(pProperties); } public static ItemStack withMana(ItemStack stack, int mana, int maxMana) { Item item = stack.getItem(); - if (item instanceof ItemManaHolder) { + if (item instanceof ItemMediaHolder) { NBTHelper.putInt(stack, TAG_MANA, mana); NBTHelper.putInt(stack, TAG_MAX_MANA, maxMana); } @@ -34,36 +34,36 @@ public abstract class ItemManaHolder extends Item implements ManaHolderItem { } @Override - public int getMana(ItemStack stack) { + public int getMedia(ItemStack stack) { return NBTHelper.getInt(stack, TAG_MANA); } @Override - public int getMaxMana(ItemStack stack) { + public int getMaxMedia(ItemStack stack) { return NBTHelper.getInt(stack, TAG_MAX_MANA); } @Override - public void setMana(ItemStack stack, int mana) { - NBTHelper.putInt(stack, TAG_MANA, Mth.clamp(mana, 0, getMaxMana(stack))); + public void setMedia(ItemStack stack, int media) { + NBTHelper.putInt(stack, TAG_MANA, Mth.clamp(media, 0, getMaxMedia(stack))); } @Override public boolean isBarVisible(ItemStack pStack) { - return getMaxMana(pStack) > 0; + return getMaxMedia(pStack) > 0; } @Override public int getBarColor(ItemStack pStack) { - var mana = getMana(pStack); - var maxMana = getMaxMana(pStack); + var mana = getMedia(pStack); + var maxMana = getMaxMedia(pStack); return ManaHelper.manaBarColor(mana, maxMana); } @Override public int getBarWidth(ItemStack pStack) { - var mana = getMana(pStack); - var maxMana = getMaxMana(pStack); + var mana = getMedia(pStack); + var maxMana = getMaxMedia(pStack); return ManaHelper.manaBarWidth(mana, maxMana); } @@ -75,11 +75,11 @@ public abstract class ItemManaHolder extends Item implements ManaHolderItem { @Override public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List pTooltipComponents, TooltipFlag pIsAdvanced) { - if (pIsAdvanced.isAdvanced() && getMaxMana(pStack) > 0) { + if (pIsAdvanced.isAdvanced() && getMaxMedia(pStack) > 0) { pTooltipComponents.add( new TranslatableComponent("item.hexcasting.manaholder.amount", - String.format("%,d", getMana(pStack)), - String.format("%,d", getMaxMana(pStack)), + String.format("%,d", getMedia(pStack)), + String.format("%,d", getMaxMedia(pStack)), 100f * getManaFullness(pStack)).withStyle(ChatFormatting.GRAY)); } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemPackagedHex.java b/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemPackagedHex.java index 2a4f76b2..738c1c2e 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemPackagedHex.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemPackagedHex.java @@ -32,7 +32,7 @@ import static at.petrak.hexcasting.api.HexAPI.modLoc; /** * Item that holds a list of patterns in it ready to be cast */ -public abstract class ItemPackagedHex extends ItemManaHolder implements HexHolderItem { +public abstract class ItemPackagedHex extends ItemMediaHolder implements HexHolderItem { public static final String TAG_PATTERNS = "patterns"; public static final ResourceLocation HAS_PATTERNS_PRED = modLoc("has_patterns"); @@ -48,7 +48,7 @@ public abstract class ItemPackagedHex extends ItemManaHolder implements HexHolde } @Override - public boolean manaProvider(ItemStack stack) { + public boolean canProvideMedia(ItemStack stack) { return false; } @@ -116,7 +116,7 @@ public abstract class ItemPackagedHex extends ItemManaHolder implements HexHolde var harness = new CastingHarness(ctx); var info = harness.executeIotas(instrs, sPlayer.getLevel()); - boolean broken = breakAfterDepletion() && getMana(stack) == 0; + boolean broken = breakAfterDepletion() && getMedia(stack) == 0; Stat stat; if (broken) { diff --git a/Common/src/main/java/at/petrak/hexcasting/common/lib/HexIotaTypes.java b/Common/src/main/java/at/petrak/hexcasting/common/lib/HexIotaTypes.java index cafb180a..f188e602 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/lib/HexIotaTypes.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/lib/HexIotaTypes.java @@ -6,6 +6,7 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions; import net.minecraft.core.Registry; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; +import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import org.jetbrains.annotations.ApiStatus; @@ -26,6 +27,21 @@ public class HexIotaTypes { KEY_TYPE = HexAPI.MOD_ID + ":type", KEY_DATA = HexAPI.MOD_ID + ":data"; + public static CompoundTag serialize(Iota iota) { + var type = iota.getType(); + var typeId = REGISTRY.getKey(type); + if (typeId == null) { + throw new IllegalStateException( + "Tried to serialize an unregistered iota type. Iota: " + iota + + " ; Type" + type.getClass().getTypeName()); + } + var dataTag = iota.serialize(); + var out = new CompoundTag(); + out.putString(KEY_TYPE, typeId.toString()); + out.put(KEY_DATA, dataTag); + return out; + } + /** * This method attempts to find the type from the {@code type} key. * See {@link HexIotaTypes#getTypeFromTag} for the storage format. @@ -69,6 +85,19 @@ public class HexIotaTypes { return type.deserialize(tag, world); } + @Nullable + public static Component getDisplay(CompoundTag tag) { + var type = getTypeFromTag(tag); + if (type == null) { + return null; + } + var dataKey = tag.get(KEY_DATA); + if (dataKey == null) { + return null; + } + return type.display(tag); + } + @ApiStatus.Internal public static void registerTypes() { BiConsumer, ResourceLocation> r = (type, id) -> Registry.register(REGISTRY, id, type); diff --git a/Common/src/main/java/at/petrak/hexcasting/common/lib/HexItems.java b/Common/src/main/java/at/petrak/hexcasting/common/lib/HexItems.java index 6e068812..1e993cf2 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/lib/HexItems.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/lib/HexItems.java @@ -64,8 +64,8 @@ public class HexItems { public static final ItemSlate SLATE = make("slate", new ItemSlate(HexBlocks.SLATE, props())); - public static final ItemManaBattery BATTERY = make("battery", - new ItemManaBattery(new Item.Properties().stacksTo(1))); + public static final ItemMediaBattery BATTERY = make("battery", + new ItemMediaBattery(new Item.Properties().stacksTo(1))); public static final EnumMap DYE_COLORIZERS = Util.make(() -> { var out = new EnumMap(DyeColor.class); diff --git a/Common/src/main/java/at/petrak/hexcasting/common/network/MsgShiftScrollSyn.java b/Common/src/main/java/at/petrak/hexcasting/common/network/MsgShiftScrollSyn.java index 2ecd835c..bff44706 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/network/MsgShiftScrollSyn.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/network/MsgShiftScrollSyn.java @@ -121,7 +121,7 @@ public record MsgShiftScrollSyn(InteractionHand hand, double scrollDelta, boolea sender.level.playSound(null, sender.getX(), sender.getY(), sender.getZ(), HexSounds.ABACUS, SoundSource.PLAYERS, 0.5f, pitch); - var datumTag = HexItems.ABACUS.readDatumTag(stack); + var datumTag = HexItems.ABACUS.readIotaTag(stack); if (datumTag != null) { var popup = LegacySpellDatum.displayFromNBT(datumTag); sender.displayClientMessage( diff --git a/Common/src/main/java/at/petrak/hexcasting/common/recipe/SealFocusRecipe.java b/Common/src/main/java/at/petrak/hexcasting/common/recipe/SealFocusRecipe.java index 29b468fa..0cfc8040 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/recipe/SealFocusRecipe.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/recipe/SealFocusRecipe.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.common.recipe; -import at.petrak.hexcasting.api.item.DataHolderItem; +import at.petrak.hexcasting.api.item.IotaHolderItem; import at.petrak.hexcasting.api.utils.NBTHelper; import at.petrak.hexcasting.common.items.ItemFocus; import at.petrak.hexcasting.common.lib.HexItems; @@ -23,7 +23,7 @@ public class SealFocusRecipe extends ShapelessRecipe { private static ItemStack getSealedStack() { ItemStack output = new ItemStack(HexItems.FOCUS); NBTHelper.putBoolean(output, ItemFocus.TAG_SEALED, true); - NBTHelper.putString(output, DataHolderItem.TAG_OVERRIDE_VISUALLY, "any"); + NBTHelper.putString(output, IotaHolderItem.TAG_OVERRIDE_VISUALLY, "any"); return output; } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/recipe/SealSpellbookRecipe.java b/Common/src/main/java/at/petrak/hexcasting/common/recipe/SealSpellbookRecipe.java index 0d69d11b..3a18cb98 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/recipe/SealSpellbookRecipe.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/recipe/SealSpellbookRecipe.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.common.recipe; -import at.petrak.hexcasting.api.item.DataHolderItem; +import at.petrak.hexcasting.api.item.IotaHolderItem; import at.petrak.hexcasting.api.utils.NBTHelper; import at.petrak.hexcasting.common.items.ItemSpellbook; import at.petrak.hexcasting.common.lib.HexItems; @@ -23,7 +23,7 @@ public class SealSpellbookRecipe extends ShapelessRecipe { private static ItemStack getSealedStack() { ItemStack output = new ItemStack(HexItems.SPELLBOOK); ItemSpellbook.SetSealed(output, true); - NBTHelper.putString(output, DataHolderItem.TAG_OVERRIDE_VISUALLY, "any"); + NBTHelper.putString(output, IotaHolderItem.TAG_OVERRIDE_VISUALLY, "any"); return output; } diff --git a/Common/src/main/java/at/petrak/hexcasting/xplat/IXplatAbstractions.java b/Common/src/main/java/at/petrak/hexcasting/xplat/IXplatAbstractions.java index 68a534e8..70435721 100644 --- a/Common/src/main/java/at/petrak/hexcasting/xplat/IXplatAbstractions.java +++ b/Common/src/main/java/at/petrak/hexcasting/xplat/IXplatAbstractions.java @@ -1,9 +1,9 @@ package at.petrak.hexcasting.xplat; import at.petrak.hexcasting.api.HexAPI; -import at.petrak.hexcasting.api.addldata.DataHolder; -import at.petrak.hexcasting.api.addldata.HexHolder; -import at.petrak.hexcasting.api.addldata.ManaHolder; +import at.petrak.hexcasting.api.addldata.ADHexHolder; +import at.petrak.hexcasting.api.addldata.ADIotaHolder; +import at.petrak.hexcasting.api.addldata.ADMediaHolder; import at.petrak.hexcasting.api.misc.FrozenColorizer; import at.petrak.hexcasting.api.player.FlightAbility; import at.petrak.hexcasting.api.player.Sentinel; @@ -96,13 +96,13 @@ public interface IXplatAbstractions { void clearCastingData(ServerPlayer player); @Nullable - ManaHolder findManaHolder(ItemStack stack); + ADMediaHolder findManaHolder(ItemStack stack); @Nullable - DataHolder findDataHolder(ItemStack stack); + ADIotaHolder findDataHolder(ItemStack stack); @Nullable - HexHolder findHexHolder(ItemStack stack); + ADHexHolder findHexHolder(ItemStack stack); // coooollooorrrs diff --git a/Common/src/main/resources/assets/hexcasting/lang/en_us.json b/Common/src/main/resources/assets/hexcasting/lang/en_us.json index 3db36fae..267fc472 100644 --- a/Common/src/main/resources/assets/hexcasting/lang/en_us.json +++ b/Common/src/main/resources/assets/hexcasting/lang/en_us.json @@ -136,7 +136,7 @@ "hexcasting.spelldata.onitem": "Contains: %s", "hexcasting.spelldata.anything": "Anything", "hexcasting.spelldata.unknown": "Unknown data (this is a bug)", - "hexcasting.spelldata.entity.whoknows": "An Entity (this should only show up if this was stored before the 0.5.0 update, use Scribe's Reflection, Scribe's Gambit to fix)", + "hexcasting.spelldata.entity.whoknows": "An Unknown Entity", "hexcasting.spelldata.akashic.nopos": "The owning record does not know of any iota here (this is a bug)", "gui.hexcasting.spellcasting": "Hex Grid", diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/CCDataHolder.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/CCDataHolder.java deleted file mode 100644 index 59d09523..00000000 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/CCDataHolder.java +++ /dev/null @@ -1,66 +0,0 @@ -package at.petrak.hexcasting.fabric.cc; - -import at.petrak.hexcasting.api.addldata.DataHolder; -import at.petrak.hexcasting.api.item.DataHolderItem; -import at.petrak.hexcasting.api.spell.LegacySpellDatum; -import dev.onyxstudios.cca.api.v3.item.ItemComponent; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.item.ItemStack; -import org.jetbrains.annotations.Nullable; - -import java.util.function.Function; - -public abstract class CCDataHolder extends ItemComponent implements DataHolder { - public CCDataHolder(ItemStack stack) { - super(stack, HexCardinalComponents.DATA_HOLDER); - } - - public static class ItemBased extends CCDataHolder { - private final DataHolderItem dataHolder; - - public ItemBased(ItemStack stack) { - super(stack); - if (!(stack.getItem() instanceof DataHolderItem data)) { - throw new IllegalStateException("item is not a data holder: " + stack); - } - this.dataHolder = data; - } - - @Override - public @Nullable CompoundTag readRawDatum() { - return this.dataHolder.readDatumTag(this.stack); - } - - @Override - public boolean writeDatum(@Nullable LegacySpellDatum datum, boolean simulate) { - var canWrite = this.dataHolder.canWrite(this.stack, datum); - if (!canWrite) { - return false; - } - if (!simulate) { - this.dataHolder.writeDatum(this.stack, datum); - } - return true; - } - } - - public static class Static extends CCDataHolder { - private final Function> provider; - - public Static(ItemStack stack, Function> provider) { - super(stack); - this.provider = provider; - } - - @Override - public @Nullable CompoundTag readRawDatum() { - LegacySpellDatum datum = this.provider.apply(this.stack); - return datum == null ? null : datum.serializeToNBT(); - } - - @Override - public boolean writeDatum(@Nullable LegacySpellDatum datum, boolean simulate) { - return false; - } - } -} diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/HexCardinalComponents.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/HexCardinalComponents.java index 9ca06285..ee22624d 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/HexCardinalComponents.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/HexCardinalComponents.java @@ -1,12 +1,17 @@ package at.petrak.hexcasting.fabric.cc; +import at.petrak.hexcasting.api.addldata.ADMediaHolder; import at.petrak.hexcasting.api.item.ColorizerItem; -import at.petrak.hexcasting.api.item.DataHolderItem; import at.petrak.hexcasting.api.item.HexHolderItem; -import at.petrak.hexcasting.api.item.ManaHolderItem; +import at.petrak.hexcasting.api.item.IotaHolderItem; +import at.petrak.hexcasting.api.item.MediaHolderItem; import at.petrak.hexcasting.api.mod.HexConfig; -import at.petrak.hexcasting.api.spell.LegacySpellDatum; +import at.petrak.hexcasting.api.spell.iota.DoubleIota; import at.petrak.hexcasting.common.lib.HexItems; +import at.petrak.hexcasting.fabric.cc.adimpl.CCColorizer; +import at.petrak.hexcasting.fabric.cc.adimpl.CCHexHolder; +import at.petrak.hexcasting.fabric.cc.adimpl.CCIotaHolder; +import at.petrak.hexcasting.fabric.cc.adimpl.CCMediaHolder; import dev.onyxstudios.cca.api.v3.component.ComponentKey; import dev.onyxstudios.cca.api.v3.component.ComponentRegistry; import dev.onyxstudios.cca.api.v3.entity.EntityComponentFactoryRegistry; @@ -37,10 +42,10 @@ public class HexCardinalComponents implements EntityComponentInitializer, ItemCo public static final ComponentKey COLORIZER = ComponentRegistry.getOrCreate(modLoc("colorizer"), CCColorizer.class); - public static final ComponentKey DATA_HOLDER = ComponentRegistry.getOrCreate(modLoc("data_holder"), - CCDataHolder.class); - public static final ComponentKey MANA_HOLDER = ComponentRegistry.getOrCreate(modLoc("mana_holder"), - CCManaHolder.class); + public static final ComponentKey DATA_HOLDER = ComponentRegistry.getOrCreate(modLoc("data_holder"), + CCIotaHolder.class); + public static final ComponentKey MEDIA_HOLDER = ComponentRegistry.getOrCreate(modLoc("mana_holder"), + CCMediaHolder.class); public static final ComponentKey HEX_HOLDER = ComponentRegistry.getOrCreate(modLoc("hex_holder"), CCHexHolder.class); @@ -59,21 +64,21 @@ public class HexCardinalComponents implements EntityComponentInitializer, ItemCo public void registerItemComponentFactories(ItemComponentFactoryRegistry registry) { registry.register(i -> i instanceof ColorizerItem, COLORIZER, CCColorizer.ItemBased::new); - registry.register(i -> i instanceof DataHolderItem, DATA_HOLDER, CCDataHolder.ItemBased::new); + registry.register(i -> i instanceof IotaHolderItem, DATA_HOLDER, CCIotaHolder.ItemBased::new); // oh havoc, you think you're so funny // the worst part is you're /right/ - registry.register(Items.PUMPKIN_PIE, DATA_HOLDER, stack -> new CCDataHolder.Static(stack, - s -> LegacySpellDatum.make(Math.PI * s.getCount()))); + registry.register(Items.PUMPKIN_PIE, DATA_HOLDER, stack -> + new CCIotaHolder.Static(stack, s -> new DoubleIota(Math.PI * s.getCount()))); - registry.register(i -> i instanceof ManaHolderItem, MANA_HOLDER, CCManaHolder.ItemBased::new); - registry.register(HexItems.AMETHYST_DUST, MANA_HOLDER, s -> new CCManaHolder.Static( - () -> HexConfig.common().dustManaAmount(), 30, s + registry.register(i -> i instanceof MediaHolderItem, MEDIA_HOLDER, CCMediaHolder.ItemBased::new); + registry.register(HexItems.AMETHYST_DUST, MEDIA_HOLDER, s -> new CCMediaHolder.Static( + () -> HexConfig.common().dustManaAmount(), ADMediaHolder.AMETHYST_DUST_PRIORITY, s )); - registry.register(Items.AMETHYST_SHARD, MANA_HOLDER, s -> new CCManaHolder.Static( - () -> HexConfig.common().shardManaAmount(), 20, s + registry.register(Items.AMETHYST_SHARD, MEDIA_HOLDER, s -> new CCMediaHolder.Static( + () -> HexConfig.common().shardManaAmount(), ADMediaHolder.AMETHYST_SHARD_PRIORITY, s )); - registry.register(HexItems.CHARGED_AMETHYST, MANA_HOLDER, s -> new CCManaHolder.Static( - () -> HexConfig.common().chargedCrystalManaAmount(), 10, s + registry.register(HexItems.CHARGED_AMETHYST, MEDIA_HOLDER, s -> new CCMediaHolder.Static( + () -> HexConfig.common().chargedCrystalManaAmount(), ADMediaHolder.CHARGED_AMETHYST_PRIORITY, s )); registry.register(i -> i instanceof HexHolderItem, HEX_HOLDER, CCHexHolder.ItemBased::new); diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/CCColorizer.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/adimpl/CCColorizer.java similarity index 84% rename from Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/CCColorizer.java rename to Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/adimpl/CCColorizer.java index ee62b59e..eedb8112 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/CCColorizer.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/adimpl/CCColorizer.java @@ -1,7 +1,8 @@ -package at.petrak.hexcasting.fabric.cc; +package at.petrak.hexcasting.fabric.cc.adimpl; -import at.petrak.hexcasting.api.addldata.Colorizer; +import at.petrak.hexcasting.api.addldata.ADColorizer; import at.petrak.hexcasting.api.item.ColorizerItem; +import at.petrak.hexcasting.fabric.cc.HexCardinalComponents; import dev.onyxstudios.cca.api.v3.item.ItemComponent; import net.minecraft.world.item.ItemStack; import net.minecraft.world.phys.Vec3; @@ -11,7 +12,7 @@ import java.util.UUID; /** * The colorizer itself */ -public abstract class CCColorizer extends ItemComponent implements Colorizer { +public abstract class CCColorizer extends ItemComponent implements ADColorizer { public CCColorizer(ItemStack stack) { super(stack, HexCardinalComponents.COLORIZER); } diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/CCHexHolder.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/adimpl/CCHexHolder.java similarity index 90% rename from Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/CCHexHolder.java rename to Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/adimpl/CCHexHolder.java index 5459ec10..efcda913 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/CCHexHolder.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/adimpl/CCHexHolder.java @@ -1,8 +1,9 @@ -package at.petrak.hexcasting.fabric.cc; +package at.petrak.hexcasting.fabric.cc.adimpl; -import at.petrak.hexcasting.api.addldata.HexHolder; +import at.petrak.hexcasting.api.addldata.ADHexHolder; import at.petrak.hexcasting.api.item.HexHolderItem; import at.petrak.hexcasting.api.spell.LegacySpellDatum; +import at.petrak.hexcasting.fabric.cc.HexCardinalComponents; import dev.onyxstudios.cca.api.v3.item.ItemComponent; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.item.ItemStack; @@ -10,7 +11,7 @@ import org.jetbrains.annotations.Nullable; import java.util.List; -public abstract class CCHexHolder extends ItemComponent implements HexHolder { +public abstract class CCHexHolder extends ItemComponent implements ADHexHolder { public CCHexHolder(ItemStack stack) { super(stack, HexCardinalComponents.HEX_HOLDER); } diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/adimpl/CCIotaHolder.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/adimpl/CCIotaHolder.java new file mode 100644 index 00000000..75faac40 --- /dev/null +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/adimpl/CCIotaHolder.java @@ -0,0 +1,68 @@ +package at.petrak.hexcasting.fabric.cc.adimpl; + +import at.petrak.hexcasting.api.addldata.ADIotaHolder; +import at.petrak.hexcasting.api.item.IotaHolderItem; +import at.petrak.hexcasting.api.spell.iota.Iota; +import at.petrak.hexcasting.common.lib.HexIotaTypes; +import at.petrak.hexcasting.fabric.cc.HexCardinalComponents; +import dev.onyxstudios.cca.api.v3.item.ItemComponent; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.Nullable; + +import java.util.function.Function; + +public abstract class CCIotaHolder extends ItemComponent implements ADIotaHolder { + public CCIotaHolder(ItemStack stack) { + super(stack, HexCardinalComponents.DATA_HOLDER); + } + + public static class ItemBased extends CCIotaHolder { + private final IotaHolderItem iotaHolder; + + public ItemBased(ItemStack stack) { + super(stack); + if (!(stack.getItem() instanceof IotaHolderItem data)) { + throw new IllegalStateException("item is not a data holder: " + stack); + } + this.iotaHolder = data; + } + + @Override + public @Nullable CompoundTag readIotaTag() { + return this.iotaHolder.readIotaTag(this.stack); + } + + @Override + public boolean writeIota(@Nullable Iota iota, boolean simulate) { + var canWrite = this.iotaHolder.canWrite(this.stack, iota); + if (!canWrite) { + return false; + } + if (!simulate) { + this.iotaHolder.writeDatum(this.stack, iota); + } + return true; + } + } + + public static class Static extends CCIotaHolder { + private final Function provider; + + public Static(ItemStack stack, Function provider) { + super(stack); + this.provider = provider; + } + + @Override + public @Nullable CompoundTag readIotaTag() { + var iota = this.provider.apply(this.stack); + return iota == null ? null : HexIotaTypes.serialize(iota); + } + + @Override + public boolean writeIota(@Nullable Iota datum, boolean simulate) { + return false; + } + } +} diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/CCManaHolder.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/adimpl/CCMediaHolder.java similarity index 57% rename from Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/CCManaHolder.java rename to Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/adimpl/CCMediaHolder.java index c1096a9b..0285d381 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/CCManaHolder.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/adimpl/CCMediaHolder.java @@ -1,56 +1,57 @@ -package at.petrak.hexcasting.fabric.cc; +package at.petrak.hexcasting.fabric.cc.adimpl; -import at.petrak.hexcasting.api.addldata.ManaHolder; -import at.petrak.hexcasting.api.item.ManaHolderItem; +import at.petrak.hexcasting.api.addldata.ADMediaHolder; +import at.petrak.hexcasting.api.item.MediaHolderItem; +import at.petrak.hexcasting.fabric.cc.HexCardinalComponents; import dev.onyxstudios.cca.api.v3.item.ItemComponent; import net.minecraft.world.item.ItemStack; import java.util.function.Supplier; -public abstract class CCManaHolder extends ItemComponent implements ManaHolder { - public CCManaHolder(ItemStack stack) { - super(stack, HexCardinalComponents.MANA_HOLDER); +public abstract class CCMediaHolder extends ItemComponent implements ADMediaHolder { + public CCMediaHolder(ItemStack stack) { + super(stack, HexCardinalComponents.MEDIA_HOLDER); } - public static class ItemBased extends CCManaHolder { - private final ManaHolderItem manaHolder; + public static class ItemBased extends CCMediaHolder { + private final MediaHolderItem mediaHolder; public ItemBased(ItemStack stack) { super(stack); - if (!(stack.getItem() instanceof ManaHolderItem mana)) { - throw new IllegalStateException("item is not a mana holder: " + stack); + if (!(stack.getItem() instanceof MediaHolderItem mana)) { + throw new IllegalStateException("item is not a media holder: " + stack); } - this.manaHolder = mana; + this.mediaHolder = mana; } @Override - public int getMana() { - return this.manaHolder.getMana(this.stack); + public int getMedia() { + return this.mediaHolder.getMedia(this.stack); } @Override - public int getMaxMana() { - return this.manaHolder.getMaxMana(this.stack); + public int getMaxMedia() { + return this.mediaHolder.getMaxMedia(this.stack); } @Override - public void setMana(int mana) { - this.manaHolder.setMana(this.stack, mana); + public void setMedia(int media) { + this.mediaHolder.setMedia(this.stack, media); } @Override public boolean canRecharge() { - return this.manaHolder.canRecharge(this.stack); + return this.mediaHolder.canRecharge(this.stack); } @Override public boolean canProvide() { - return this.manaHolder.manaProvider(this.stack); + return this.mediaHolder.canProvideMedia(this.stack); } @Override public int getConsumptionPriority() { - return 40; + return ADMediaHolder.BATTERY_PRIORITY; } @Override @@ -59,12 +60,12 @@ public abstract class CCManaHolder extends ItemComponent implements ManaHolder { } @Override - public int withdrawMana(int cost, boolean simulate) { - return this.manaHolder.withdrawMana(this.stack, cost, simulate); + public int withdrawMedia(int cost, boolean simulate) { + return this.mediaHolder.withdrawMana(this.stack, cost, simulate); } } - public static class Static extends CCManaHolder { + public static class Static extends CCMediaHolder { private final Supplier baseWorth; private final int consumptionPriority; @@ -75,17 +76,17 @@ public abstract class CCManaHolder extends ItemComponent implements ManaHolder { } @Override - public int getMana() { + public int getMedia() { return baseWorth.get() * stack.getCount(); } @Override - public int getMaxMana() { - return getMana(); + public int getMaxMedia() { + return getMedia(); } @Override - public void setMana(int mana) { + public void setMedia(int media) { // NO-OP } @@ -110,7 +111,7 @@ public abstract class CCManaHolder extends ItemComponent implements ManaHolder { } @Override - public int withdrawMana(int cost, boolean simulate) { + public int withdrawMedia(int cost, boolean simulate) { int worth = baseWorth.get(); if (cost < 0) { cost = worth * stack.getCount(); diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/package-info.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/package-info.java new file mode 100644 index 00000000..c1f2319c --- /dev/null +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/cc/package-info.java @@ -0,0 +1,8 @@ +/** + * Some Cardinal Components in the mod are substitutes for Forge's ability to store arbitrary data on an entity; + * some are implementations of the Additional Data abstraction. + *

+ * In the root of this folder are the substitutes for entitydata; + * in the {@link at.petrak.hexcasting.fabric.cc.adimpl adimpl} folder are the implementations of additional datas. + */ +package at.petrak.hexcasting.fabric.cc; \ No newline at end of file diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/recipe/FabricUnsealedIngredient.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/recipe/FabricUnsealedIngredient.java index f76786ee..ab42ce9a 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/recipe/FabricUnsealedIngredient.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/recipe/FabricUnsealedIngredient.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.fabric.recipe; -import at.petrak.hexcasting.api.item.DataHolderItem; +import at.petrak.hexcasting.api.item.IotaHolderItem; import at.petrak.hexcasting.api.utils.NBTHelper; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -30,7 +30,7 @@ public class FabricUnsealedIngredient extends BaseCustomIngredient { .filter((it) -> it != DatumType.EMPTY && it != DatumType.OTHER) .map((type) -> { ItemStack newStack = stack.copy(); - NBTHelper.putString(newStack, DataHolderItem.TAG_OVERRIDE_VISUALLY, SpellDatum.tagForType(type)); + NBTHelper.putString(newStack, IotaHolderItem.TAG_OVERRIDE_VISUALLY, SpellDatum.tagForType(type)); return new Ingredient.ItemValue(newStack); })); this.stack = stack; diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/xplat/FabricXplatImpl.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/xplat/FabricXplatImpl.java index 5b36c0e4..04d2063d 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/xplat/FabricXplatImpl.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/xplat/FabricXplatImpl.java @@ -1,9 +1,9 @@ package at.petrak.hexcasting.fabric.xplat; import at.petrak.hexcasting.api.HexAPI; -import at.petrak.hexcasting.api.addldata.DataHolder; -import at.petrak.hexcasting.api.addldata.HexHolder; -import at.petrak.hexcasting.api.addldata.ManaHolder; +import at.petrak.hexcasting.api.addldata.ADHexHolder; +import at.petrak.hexcasting.api.addldata.ADIotaHolder; +import at.petrak.hexcasting.api.addldata.ADMediaHolder; import at.petrak.hexcasting.api.misc.FrozenColorizer; import at.petrak.hexcasting.api.mod.HexConfig; import at.petrak.hexcasting.api.mod.HexItemTags; @@ -213,21 +213,21 @@ public class FabricXplatImpl implements IXplatAbstractions { @Override public @Nullable - ManaHolder findManaHolder(ItemStack stack) { - var cc = HexCardinalComponents.MANA_HOLDER.maybeGet(stack); + ADMediaHolder findManaHolder(ItemStack stack) { + var cc = HexCardinalComponents.MEDIA_HOLDER.maybeGet(stack); return cc.orElse(null); } @Override public @Nullable - DataHolder findDataHolder(ItemStack stack) { + ADIotaHolder findDataHolder(ItemStack stack) { var cc = HexCardinalComponents.DATA_HOLDER.maybeGet(stack); return cc.orElse(null); } @Override public @Nullable - HexHolder findHexHolder(ItemStack stack) { + ADHexHolder findHexHolder(ItemStack stack) { var cc = HexCardinalComponents.HEX_HOLDER.maybeGet(stack); return cc.orElse(null); } diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/cap/ForgeCapabilityHandler.java b/Forge/src/main/java/at/petrak/hexcasting/forge/cap/ForgeCapabilityHandler.java index dca1a0ec..66b8af42 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/cap/ForgeCapabilityHandler.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/cap/ForgeCapabilityHandler.java @@ -1,16 +1,18 @@ package at.petrak.hexcasting.forge.cap; -import at.petrak.hexcasting.api.addldata.Colorizer; -import at.petrak.hexcasting.api.addldata.DataHolder; -import at.petrak.hexcasting.api.addldata.HexHolder; -import at.petrak.hexcasting.api.addldata.ManaHolder; +import at.petrak.hexcasting.api.addldata.ADColorizer; +import at.petrak.hexcasting.api.addldata.ADHexHolder; +import at.petrak.hexcasting.api.addldata.ADIotaHolder; +import at.petrak.hexcasting.api.addldata.ADMediaHolder; import at.petrak.hexcasting.api.block.circle.BlockEntityAbstractImpetus; import at.petrak.hexcasting.api.item.ColorizerItem; -import at.petrak.hexcasting.api.item.DataHolderItem; import at.petrak.hexcasting.api.item.HexHolderItem; -import at.petrak.hexcasting.api.item.ManaHolderItem; +import at.petrak.hexcasting.api.item.IotaHolderItem; +import at.petrak.hexcasting.api.item.MediaHolderItem; import at.petrak.hexcasting.api.mod.HexConfig; -import at.petrak.hexcasting.api.spell.LegacySpellDatum; +import at.petrak.hexcasting.api.spell.iota.DoubleIota; +import at.petrak.hexcasting.api.spell.iota.Iota; +import at.petrak.hexcasting.common.lib.HexIotaTypes; import at.petrak.hexcasting.common.lib.HexItems; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; @@ -36,69 +38,100 @@ import java.util.function.BooleanSupplier; import java.util.function.Function; import java.util.function.Supplier; -public class ForgeCapabilityHandler { - private static final ResourceLocation DATA_HOLDER_CAPABILITY = new ResourceLocation("hexcasting", "data_holder"); - private static final ResourceLocation DATA_ITEM_CAPABILITY = new ResourceLocation("hexcasting", "data_item"); - private static final ResourceLocation MANA_HOLDER_CAPABILITY = new ResourceLocation("hexcasting", "mana_holder"); - private static final ResourceLocation MANA_ITEM_CAPABILITY = new ResourceLocation("hexcasting", "mana_item"); - private static final ResourceLocation SPELL_HOLDER_CAPABILITY = new ResourceLocation("hexcasting", "spell_item"); - private static final ResourceLocation COLORIZER_CAPABILITY = new ResourceLocation("hexcasting", "colorizer"); +import static at.petrak.hexcasting.api.HexAPI.modLoc; - private static final ResourceLocation IMPETUS_HANDLER = new ResourceLocation("hexcasting", "impetus_items"); +public class ForgeCapabilityHandler { + /** + * Items that store an iota to their tag. + */ + public static final ResourceLocation IOTA_STORAGE_CAP = modLoc("data_holder"); + /** + * Items that intrinsically store an iota. + */ + public static final ResourceLocation IOTA_STATIC_CAP = modLoc("data_item"); + /** + * Items that store a variable amount of media to their tag. + */ + public static final ResourceLocation MEDIA_STORAGE_CAP = modLoc("mana_holder"); + /** + * Items that statically provide media. + */ + public static final ResourceLocation MEDIA_STATIC_CAP = modLoc("mana_item"); + /** + * Items that store a packaged Hex. + */ + public static final ResourceLocation HEX_HOLDER_CAP = modLoc("spell_item"); + /** + * Items that work as pigments. + */ + public static final ResourceLocation PIGMENT_CAP = modLoc("colorizer"); + + private static final ResourceLocation IMPETUS_HANDLER = modLoc("impetus_items"); public static void registerCaps(RegisterCapabilitiesEvent evt) { - evt.register(ManaHolder.class); - evt.register(DataHolder.class); - evt.register(HexHolder.class); - evt.register(Colorizer.class); + evt.register(ADMediaHolder.class); + evt.register(ADIotaHolder.class); + evt.register(ADHexHolder.class); + evt.register(ADColorizer.class); } public static void attachItemCaps(AttachCapabilitiesEvent evt) { ItemStack stack = evt.getObject(); - if (stack.getItem() instanceof ManaHolderItem holder) - evt.addCapability(MANA_HOLDER_CAPABILITY, provide(stack, HexCapabilities.MANA, - () -> new ItemBasedManaHolder(holder, stack))); - else if (stack.is(HexItems.AMETHYST_DUST)) - evt.addCapability(MANA_ITEM_CAPABILITY, provide(stack, HexCapabilities.MANA, - () -> new StaticManaHolder(HexConfig.common()::dustManaAmount, 3, stack))); - else if (stack.is(Items.AMETHYST_SHARD)) - evt.addCapability(MANA_ITEM_CAPABILITY, provide(stack, HexCapabilities.MANA, - () -> new StaticManaHolder(HexConfig.common()::shardManaAmount, 2, stack))); - else if (stack.is(HexItems.CHARGED_AMETHYST)) - evt.addCapability(MANA_ITEM_CAPABILITY, provide(stack, HexCapabilities.MANA, - () -> new StaticManaHolder(HexConfig.common()::chargedCrystalManaAmount, 1, stack))); - if (stack.getItem() instanceof DataHolderItem holder) - evt.addCapability(DATA_HOLDER_CAPABILITY, provide(stack, HexCapabilities.DATUM, - () -> new ItemBasedDataHolder(holder, stack))); - else if (stack.is(Items.PUMPKIN_PIE)) // haha yes - evt.addCapability(DATA_ITEM_CAPABILITY, provide(stack, HexCapabilities.DATUM, - () -> new StaticDatumHolder((s) -> LegacySpellDatum.make(Math.PI * s.getCount()), stack))); + if (stack.getItem() instanceof MediaHolderItem holder) { + evt.addCapability(MEDIA_STORAGE_CAP, + provide(stack, HexCapabilities.MANA, () -> new ItemBasedManaHolder(holder, stack))); + } else if (stack.is(HexItems.AMETHYST_DUST)) { + evt.addCapability(MEDIA_STATIC_CAP, provide(stack, HexCapabilities.MANA, () -> + new StaticManaHolder(HexConfig.common()::dustManaAmount, ADMediaHolder.AMETHYST_DUST_PRIORITY, stack))); + } else if (stack.is(Items.AMETHYST_SHARD)) { + evt.addCapability(MEDIA_STATIC_CAP, provide(stack, HexCapabilities.MANA, () -> new StaticManaHolder( + HexConfig.common()::shardManaAmount, ADMediaHolder.AMETHYST_SHARD_PRIORITY, stack))); + } else if (stack.is(HexItems.CHARGED_AMETHYST)) { + evt.addCapability(MEDIA_STATIC_CAP, + provide(stack, HexCapabilities.MANA, () -> new StaticManaHolder( + HexConfig.common()::chargedCrystalManaAmount, ADMediaHolder.CHARGED_AMETHYST_PRIORITY, stack))); + } - if (stack.getItem() instanceof HexHolderItem holder) - evt.addCapability(SPELL_HOLDER_CAPABILITY, provide(stack, HexCapabilities.STORED_HEX, - () -> new ItemBasedHexHolder(holder, stack))); + if (stack.getItem() instanceof IotaHolderItem holder) { + evt.addCapability(IOTA_STORAGE_CAP, + provide(stack, HexCapabilities.DATUM, () -> new ItemBasedDataHolder(holder, stack))); + } else if (stack.is(Items.PUMPKIN_PIE)) { + // haha yes + evt.addCapability(IOTA_STATIC_CAP, provide(stack, HexCapabilities.DATUM, () -> + new StaticDatumHolder((s) -> new DoubleIota(Math.PI * s.getCount()), stack))); + } - if (stack.getItem() instanceof ColorizerItem colorizer) - evt.addCapability(COLORIZER_CAPABILITY, provide(stack, HexCapabilities.COLOR, - () -> new ItemBasedColorizer(colorizer, stack))); + if (stack.getItem() instanceof HexHolderItem holder) { + evt.addCapability(HEX_HOLDER_CAP, + provide(stack, HexCapabilities.STORED_HEX, () -> new ItemBasedHexHolder(holder, stack))); + } + + if (stack.getItem() instanceof ColorizerItem colorizer) { + evt.addCapability(PIGMENT_CAP, + provide(stack, HexCapabilities.COLOR, () -> new ItemBasedColorizer(colorizer, stack))); + } } public static void attachBlockEntityCaps(AttachCapabilitiesEvent evt) { - if (evt.getObject() instanceof BlockEntityAbstractImpetus impetus) + if (evt.getObject() instanceof BlockEntityAbstractImpetus impetus) { evt.addCapability(IMPETUS_HANDLER, provide(impetus, CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, - () -> new ForgeImpetusCapability(impetus))); + () -> new ForgeImpetusCapability(impetus))); + } } - private static SimpleProvider provide(BlockEntity be, Capability capability, NonNullSupplier supplier) { + private static SimpleProvider provide(BlockEntity be, Capability capability, + NonNullSupplier supplier) { return provide(be::isRemoved, capability, supplier); } - private static SimpleProvider provide(ItemStack stack, Capability capability, NonNullSupplier supplier) { + private static SimpleProvider provide(ItemStack stack, Capability capability, + NonNullSupplier supplier) { return provide(stack::isEmpty, capability, supplier); } - private static SimpleProvider provide(BooleanSupplier invalidated, Capability capability, NonNullSupplier supplier) { + private static SimpleProvider provide(BooleanSupplier invalidated, Capability capability, + NonNullSupplier supplier) { return new SimpleProvider<>(invalidated, capability, LazyOptional.of(supplier)); } @@ -109,8 +142,9 @@ public class ForgeCapabilityHandler { @NotNull @Override public LazyOptional getCapability(@NotNull Capability cap, @Nullable Direction side) { - if (invalidated.getAsBoolean()) + if (invalidated.getAsBoolean()) { return LazyOptional.empty(); + } return cap == capability ? instance.cast() : LazyOptional.empty(); } @@ -118,19 +152,19 @@ public class ForgeCapabilityHandler { private record StaticManaHolder(Supplier baseWorth, int consumptionPriority, - ItemStack stack) implements ManaHolder { + ItemStack stack) implements ADMediaHolder { @Override - public int getMana() { + public int getMedia() { return baseWorth.get() * stack.getCount(); } @Override - public int getMaxMana() { - return getMana(); + public int getMaxMedia() { + return getMedia(); } @Override - public void setMana(int mana) { + public void setMedia(int media) { // NO-OP } @@ -155,7 +189,7 @@ public class ForgeCapabilityHandler { } @Override - public int withdrawMana(int cost, boolean simulate) { + public int withdrawMedia(int cost, boolean simulate) { int worth = baseWorth.get(); if (cost < 0) { cost = worth * stack.getCount(); @@ -169,22 +203,22 @@ public class ForgeCapabilityHandler { } } - private record ItemBasedManaHolder(ManaHolderItem holder, - ItemStack stack) implements ManaHolder { + private record ItemBasedManaHolder(MediaHolderItem holder, + ItemStack stack) implements ADMediaHolder { @Override - public int getMana() { - return holder.getMana(stack); + public int getMedia() { + return holder.getMedia(stack); } @Override - public int getMaxMana() { - return holder.getMaxMana(stack); + public int getMaxMedia() { + return holder.getMaxMedia(stack); } @Override - public void setMana(int mana) { - holder.setMana(stack, mana); + public void setMedia(int media) { + holder.setMedia(stack, media); } @Override @@ -194,7 +228,7 @@ public class ForgeCapabilityHandler { @Override public boolean canProvide() { - return holder.manaProvider(stack); + return holder.canProvideMedia(stack); } @Override @@ -208,68 +242,68 @@ public class ForgeCapabilityHandler { } @Override - public int withdrawMana(int cost, boolean simulate) { + public int withdrawMedia(int cost, boolean simulate) { return holder.withdrawMana(stack, cost, simulate); } } - private record StaticDatumHolder(Function> provider, - ItemStack stack) implements DataHolder { + private record StaticDatumHolder(Function provider, + ItemStack stack) implements ADIotaHolder { @Override public @Nullable - CompoundTag readRawDatum() { - LegacySpellDatum datum = provider.apply(stack); - return datum == null ? null : datum.serializeToNBT(); + CompoundTag readIotaTag() { + var iota = provider.apply(stack); + return iota == null ? null : HexIotaTypes.serialize(iota); } @Override public @Nullable - LegacySpellDatum readDatum(ServerLevel world) { + Iota readIota(ServerLevel world) { return provider.apply(stack); } @Override - public boolean writeDatum(@Nullable LegacySpellDatum datum, boolean simulate) { + public boolean writeIota(@Nullable Iota iota, boolean simulate) { return false; } } - private record ItemBasedDataHolder(DataHolderItem holder, - ItemStack stack) implements DataHolder { + private record ItemBasedDataHolder(IotaHolderItem holder, + ItemStack stack) implements ADIotaHolder { @Override public @Nullable - CompoundTag readRawDatum() { - return holder.readDatumTag(stack); + CompoundTag readIotaTag() { + return holder.readIotaTag(stack); } @Override public @Nullable - LegacySpellDatum readDatum(ServerLevel world) { - return holder.readDatum(stack, world); + Iota readIota(ServerLevel world) { + return holder.readIota(stack, world); } @Override public @Nullable - LegacySpellDatum emptyDatum() { - return holder.emptyDatum(stack); + Iota emptyIota() { + return holder.emptyIota(stack); } @Override - public boolean writeDatum(@Nullable LegacySpellDatum datum, boolean simulate) { - if (!holder.canWrite(stack, datum)) { + public boolean writeIota(@Nullable Iota iota, boolean simulate) { + if (!holder.canWrite(stack, iota)) { return false; } if (!simulate) { - holder.writeDatum(stack, datum); + holder.writeDatum(stack, iota); } return true; } } private record ItemBasedHexHolder(HexHolderItem holder, - ItemStack stack) implements HexHolder { + ItemStack stack) implements ADHexHolder { @Override public boolean canDrawManaFromInventory() { @@ -282,12 +316,12 @@ public class ForgeCapabilityHandler { } @Override - public @Nullable List> getHex(ServerLevel level) { + public @Nullable List getHex(ServerLevel level) { return holder.getHex(stack, level); } @Override - public void writeHex(List> patterns, int mana) { + public void writeHex(List patterns, int mana) { holder.writeHex(stack, patterns, mana); } @@ -298,7 +332,7 @@ public class ForgeCapabilityHandler { } private record ItemBasedColorizer(ColorizerItem holder, - ItemStack stack) implements Colorizer { + ItemStack stack) implements ADColorizer { @Override public int color(UUID owner, float time, Vec3 position) { return holder.color(stack, owner, time, position); diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/cap/HexCapabilities.java b/Forge/src/main/java/at/petrak/hexcasting/forge/cap/HexCapabilities.java index 71d3d2fe..b53ca007 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/cap/HexCapabilities.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/cap/HexCapabilities.java @@ -1,21 +1,21 @@ package at.petrak.hexcasting.forge.cap; -import at.petrak.hexcasting.api.addldata.Colorizer; -import at.petrak.hexcasting.api.addldata.DataHolder; -import at.petrak.hexcasting.api.addldata.HexHolder; -import at.petrak.hexcasting.api.addldata.ManaHolder; +import at.petrak.hexcasting.api.addldata.ADColorizer; +import at.petrak.hexcasting.api.addldata.ADHexHolder; +import at.petrak.hexcasting.api.addldata.ADIotaHolder; +import at.petrak.hexcasting.api.addldata.ADMediaHolder; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.common.capabilities.CapabilityToken; public final class HexCapabilities { - public static final Capability MANA = CapabilityManager.get(new CapabilityToken<>() { + public static final Capability MANA = CapabilityManager.get(new CapabilityToken<>() { }); - public static final Capability DATUM = CapabilityManager.get(new CapabilityToken<>() { + public static final Capability DATUM = CapabilityManager.get(new CapabilityToken<>() { }); - public static final Capability STORED_HEX = CapabilityManager.get(new CapabilityToken<>() { + public static final Capability STORED_HEX = CapabilityManager.get(new CapabilityToken<>() { }); - public static final Capability COLOR = CapabilityManager.get(new CapabilityToken<>() { + public static final Capability COLOR = CapabilityManager.get(new CapabilityToken<>() { }); } diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/xplat/HexItemModels.java b/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/xplat/HexItemModels.java index 3e287071..dd7107b2 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/xplat/HexItemModels.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/xplat/HexItemModels.java @@ -6,7 +6,7 @@ import at.petrak.hexcasting.common.items.ItemScroll; import at.petrak.hexcasting.common.items.ItemSlate; import at.petrak.hexcasting.common.items.ItemWand; import at.petrak.hexcasting.common.items.colorizer.ItemPrideColorizer; -import at.petrak.hexcasting.common.items.magic.ItemManaBattery; +import at.petrak.hexcasting.common.items.magic.ItemMediaBattery; import at.petrak.hexcasting.common.items.magic.ItemPackagedHex; import at.petrak.hexcasting.common.lib.HexBlocks; import at.petrak.hexcasting.common.lib.HexItems; @@ -122,8 +122,8 @@ public class HexItemModels extends PaucalItemModelProvider { float fillProp = (float) fill / maxFill; getBuilder(HexItems.BATTERY.getRegistryName().getPath()).override() - .predicate(ItemManaBattery.MANA_PREDICATE, fillProp) - .predicate(ItemManaBattery.MAX_MANA_PREDICATE, size) + .predicate(ItemMediaBattery.MANA_PREDICATE, fillProp) + .predicate(ItemMediaBattery.MAX_MANA_PREDICATE, size) .model(new ModelFile.UncheckedModelFile(modLoc("item/" + name))) .end(); } diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/recipe/ForgeUnsealedIngredient.java b/Forge/src/main/java/at/petrak/hexcasting/forge/recipe/ForgeUnsealedIngredient.java index ced8ded1..b34ea5b3 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/recipe/ForgeUnsealedIngredient.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/recipe/ForgeUnsealedIngredient.java @@ -1,7 +1,7 @@ package at.petrak.hexcasting.forge.recipe; -import at.petrak.hexcasting.api.addldata.DataHolder; -import at.petrak.hexcasting.api.item.DataHolderItem; +import at.petrak.hexcasting.api.addldata.ADIotaHolder; +import at.petrak.hexcasting.api.item.IotaHolderItem; import at.petrak.hexcasting.api.spell.DatumType; import at.petrak.hexcasting.api.spell.LegacySpellDatum; import at.petrak.hexcasting.api.spell.Widget; @@ -30,7 +30,7 @@ public class ForgeUnsealedIngredient extends AbstractIngredient { .filter((it) -> it != DatumType.EMPTY && it != DatumType.OTHER) .map((type) -> { ItemStack newStack = stack.copy(); - NBTHelper.putString(newStack, DataHolderItem.TAG_OVERRIDE_VISUALLY, LegacySpellDatum.tagForType(type)); + NBTHelper.putString(newStack, IotaHolderItem.TAG_OVERRIDE_VISUALLY, LegacySpellDatum.tagForType(type)); return new Ingredient.ItemValue(newStack); })); this.stack = stack; @@ -45,13 +45,13 @@ public class ForgeUnsealedIngredient extends AbstractIngredient { @Override public boolean test(@Nullable ItemStack input) { - if (input == null) { - return false; - } + if (input == null) { + return false; + } if (this.stack.getItem() == input.getItem() && this.stack.getDamageValue() == input.getDamageValue()) { - DataHolder holder = IXplatAbstractions.INSTANCE.findDataHolder(this.stack); + ADIotaHolder holder = IXplatAbstractions.INSTANCE.findDataHolder(this.stack); if (holder != null) { - return holder.readRawDatum() != null && holder.writeDatum(LegacySpellDatum.make(Widget.NULL), true); + return holder.readIotaTag() != null && holder.writeIota(LegacySpellDatum.make(Widget.NULL), true); } } diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/xplat/ForgeXplatImpl.java b/Forge/src/main/java/at/petrak/hexcasting/forge/xplat/ForgeXplatImpl.java index 8503beb6..9da5f9dc 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/xplat/ForgeXplatImpl.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/xplat/ForgeXplatImpl.java @@ -1,10 +1,10 @@ package at.petrak.hexcasting.forge.xplat; import at.petrak.hexcasting.api.HexAPI; -import at.petrak.hexcasting.api.addldata.Colorizer; -import at.petrak.hexcasting.api.addldata.DataHolder; -import at.petrak.hexcasting.api.addldata.HexHolder; -import at.petrak.hexcasting.api.addldata.ManaHolder; +import at.petrak.hexcasting.api.addldata.ADColorizer; +import at.petrak.hexcasting.api.addldata.ADHexHolder; +import at.petrak.hexcasting.api.addldata.ADIotaHolder; +import at.petrak.hexcasting.api.addldata.ADMediaHolder; import at.petrak.hexcasting.api.misc.FrozenColorizer; import at.petrak.hexcasting.api.mod.HexItemTags; import at.petrak.hexcasting.api.player.FlightAbility; @@ -253,21 +253,21 @@ public class ForgeXplatImpl implements IXplatAbstractions { @Override public @Nullable - ManaHolder findManaHolder(ItemStack stack) { + ADMediaHolder findManaHolder(ItemStack stack) { var maybeCap = stack.getCapability(HexCapabilities.MANA).resolve(); return maybeCap.orElse(null); } @Override public @Nullable - DataHolder findDataHolder(ItemStack stack) { + ADIotaHolder findDataHolder(ItemStack stack) { var maybeCap = stack.getCapability(HexCapabilities.DATUM).resolve(); return maybeCap.orElse(null); } @Override public @Nullable - HexHolder findHexHolder(ItemStack stack) { + ADHexHolder findHexHolder(ItemStack stack) { var maybeCap = stack.getCapability(HexCapabilities.STORED_HEX).resolve(); return maybeCap.orElse(null); } @@ -281,7 +281,7 @@ public class ForgeXplatImpl implements IXplatAbstractions { public int getRawColor(FrozenColorizer colorizer, float time, Vec3 position) { var maybeColorizer = colorizer.item().getCapability(HexCapabilities.COLOR).resolve(); if (maybeColorizer.isPresent()) { - Colorizer col = maybeColorizer.get(); + ADColorizer col = maybeColorizer.get(); return col.color(colorizer.owner(), time, position); }