/* * Decompiled with CFR 0.152. */ package net.minecraft.client.gui.narration; import java.util.List; import java.util.function.BiConsumer; import java.util.function.Consumer; import net.minecraft.network.chat.Component; import net.minecraft.util.Unit; public class NarrationThunk { private final T contents; private final BiConsumer, T> converter; public static final NarrationThunk EMPTY = new NarrationThunk(Unit.INSTANCE, (o, c) -> {}); private NarrationThunk(T contents, BiConsumer, T> converter) { this.contents = contents; this.converter = converter; } public static NarrationThunk from(String text) { return new NarrationThunk(text, Consumer::accept); } public static NarrationThunk from(Component text) { return new NarrationThunk(text, (o, c) -> o.accept(c.getString())); } public static NarrationThunk from(List lines) { return new NarrationThunk(lines, (o, c) -> lines.stream().map(Component::getString).forEach((Consumer)o)); } public void getText(Consumer output) { this.converter.accept(output, (Consumer)this.contents); } public boolean equals(Object o) { if (this == o) { return true; } if (o instanceof NarrationThunk) { NarrationThunk thunk = (NarrationThunk)o; return thunk.converter == this.converter && thunk.contents.equals(this.contents); } return false; } public int hashCode() { int result = this.contents.hashCode(); result = 31 * result + this.converter.hashCode(); return result; } }