Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- Moved certain lang keys for type iotas from Hexal into MoreIotas, since MoreIotas is what actually implements type iotas.
- Phase Block now ensures that the caster has permission to break the target block.
- Trade now mishaps if the list contains more than 2 motes, and makes it clear that the list should match a single trade offer.
- Mote iotas now serialize the full item record they contain, rather than just the English display name.

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
* media. When the item is used up, all references to it become null.
*/
public class MoteIota extends Iota {
static final String TAG_DISPLAY_NAME = "name";
static final String TAG_COUNT = "count";
static final String TAG_ITEM_RECORD = "item_record";

/**
* Used to get the UUID of the temporarily bound storage from userData, if one exists.
Expand Down Expand Up @@ -197,9 +196,7 @@ var record = MediafiedItemManager.getRecord(this.getItemIndex());
if (record == null || (rec = record.get()) == null)
return tag;


tag.putString(TAG_DISPLAY_NAME, rec.getDisplayName().getString());
tag.putLong(TAG_COUNT, rec.getCount());
rec.writeToTag(tag);

return tag;
}
Expand All @@ -223,10 +220,11 @@ public Component display(Tag tag) {
return Component.translatable("hexcasting.spelldata.unknown");
}

if (!ctag.contains(TAG_DISPLAY_NAME) || !ctag.contains(TAG_COUNT))
var itemRecord = ItemRecord.readFromTag(ctag);
if (itemRecord == null)
return Component.translatable("hexcasting.tooltip.null_iota").withStyle(ChatFormatting.GRAY);

return Component.translatable("hexal.spelldata.mote", ctag.getString(TAG_DISPLAY_NAME), ctag.getLong(TAG_COUNT)).withStyle(ChatFormatting.YELLOW);
return Component.translatable("hexal.spelldata.mote", itemRecord.getDisplayName(), itemRecord.getCount()).withStyle(ChatFormatting.YELLOW);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ data class ItemRecord(var item: Item, var tag: CompoundTag?, var count: Long) {
/**
* Taken from https://github.com/AppliedEnergistics/Applied-Energistics-2/blob/9ff272a869508125daf5727746c9d9b8b00248bd/src/main/java/appeng/api/stacks/AEItemKey.java#L130
*/
@JvmStatic
fun readFromTag(tag: CompoundTag): ItemRecord? {
return try {
val item = BuiltInRegistries.ITEM.getOptional(ResourceLocation(tag.getString(TAG_ITEM_ID))).orElseThrow { IllegalArgumentException("Unknown item id.") }
Expand Down
Loading