2025-11-24 22:52:51 +03:00

86 lines
2.6 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.mojang.datafixers.kinds.App
* com.mojang.datafixers.kinds.Applicative
* com.mojang.serialization.Codec
* com.mojang.serialization.MapCodec
* com.mojang.serialization.codecs.RecordCodecBuilder
* org.jspecify.annotations.Nullable
*/
package net.minecraft.network.chat.contents;
import com.mojang.datafixers.kinds.App;
import com.mojang.datafixers.kinds.Applicative;
import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import java.util.Optional;
import java.util.function.Supplier;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.ComponentContents;
import net.minecraft.network.chat.FormattedText;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.contents.KeybindResolver;
import org.jspecify.annotations.Nullable;
public class KeybindContents
implements ComponentContents {
public static final MapCodec<KeybindContents> MAP_CODEC = RecordCodecBuilder.mapCodec(i -> i.group((App)Codec.STRING.fieldOf("keybind").forGetter(o -> o.name)).apply((Applicative)i, KeybindContents::new));
private final String name;
private @Nullable Supplier<Component> nameResolver;
public KeybindContents(String name) {
this.name = name;
}
private Component getNestedComponent() {
if (this.nameResolver == null) {
this.nameResolver = KeybindResolver.keyResolver.apply(this.name);
}
return this.nameResolver.get();
}
@Override
public <T> Optional<T> visit(FormattedText.ContentConsumer<T> output) {
return this.getNestedComponent().visit(output);
}
@Override
public <T> Optional<T> visit(FormattedText.StyledContentConsumer<T> output, Style currentStyle) {
return this.getNestedComponent().visit(output, currentStyle);
}
/*
* Enabled force condition propagation
* Lifted jumps to return sites
*/
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof KeybindContents)) return false;
KeybindContents that = (KeybindContents)o;
if (!this.name.equals(that.name)) return false;
return true;
}
public int hashCode() {
return this.name.hashCode();
}
public String toString() {
return "keybind{" + this.name + "}";
}
public String getName() {
return this.name;
}
public MapCodec<KeybindContents> codec() {
return MAP_CODEC;
}
}