Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/component/ItemLore.java
+++ b/net/minecraft/world/item/component/ItemLore.java
@@ -17,7 +_,42 @@
@@ -17,7 +_,37 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.TooltipFlag;

Expand All @@ -9,14 +9,12 @@
+public final class ItemLore implements TooltipProvider {
+ private final List<Component> lines;
+ private @org.jspecify.annotations.Nullable List<Component> styledLines;
+ private final boolean gale$hasCustomStyledLines;
+ public ItemLore(List<Component> lines, List<Component> styledLines) {
+ this.lines = lines;
+ if (lines.size() > 256) {
+ throw new IllegalArgumentException("Got " + lines.size() + " lines, but maximum is 256");
+ }
+ this.styledLines = styledLines;
+ this.gale$hasCustomStyledLines = true;
+ }
+ public List<Component> lines() { return this.lines; }
+ public List<Component> styledLines() {
Expand All @@ -33,9 +31,6 @@
+ int hashCode = this.gale$cached_hashCode;
+ if (hashCode == 0) {
+ hashCode = 1 + this.lines.hashCode();
+ if (this.gale$hasCustomStyledLines) {
+ hashCode = 31 * hashCode + this.styledLines.hashCode();
+ }
+ this.gale$cached_hashCode = hashCode;
+ }
+ return hashCode;
Expand All @@ -44,7 +39,7 @@
public static final ItemLore EMPTY = new ItemLore(List.of());
public static final int MAX_LINES = 256;
private static final Style LORE_STYLE = Style.EMPTY.withColor(ChatFormatting.DARK_PURPLE).withItalic(true);
@@ -27,14 +_,23 @@
@@ -27,14 +_,22 @@
.map(ItemLore::new, ItemLore::lines);

public ItemLore(final List<Component> lines) {
Expand All @@ -58,7 +53,6 @@
throw new IllegalArgumentException("Got " + lines.size() + " lines, but maximum is 256");
}
+ this.styledLines = null;
+ this.gale$hasCustomStyledLines = false;
+ // Gale end - Do less work - ItemLore.styledLines (computed only when used)
}
+
Expand All @@ -84,7 +78,7 @@
+ // Gale start - Faster implementation for subclass - ItemLore.equals() (skip styledLines)
+ @Override
+ public boolean equals(Object obj) {
+ return this == obj || obj instanceof net.minecraft.world.item.component.ItemLore other && this.lines.equals(other.lines) && ((!this.gale$hasCustomStyledLines && !other.gale$hasCustomStyledLines) || this.styledLines().equals(other.styledLines()));
+ return this == obj || obj instanceof net.minecraft.world.item.component.ItemLore other && this.lines.equals(other.lines);
+ }
+ // Gale end - Faster implementation for subclass - ItemLore.equals() (skip styledLines)
}
Loading