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

74 lines
1.9 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* io.netty.buffer.ByteBuf
* org.jspecify.annotations.Nullable
*/
package net.minecraft.world;
import io.netty.buffer.ByteBuf;
import java.util.function.IntFunction;
import net.minecraft.network.chat.Component;
import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.util.ByIdMap;
import net.minecraft.util.StringRepresentable;
import org.jspecify.annotations.Nullable;
public enum Difficulty implements StringRepresentable
{
PEACEFUL(0, "peaceful"),
EASY(1, "easy"),
NORMAL(2, "normal"),
HARD(3, "hard");
public static final StringRepresentable.EnumCodec<Difficulty> CODEC;
private static final IntFunction<Difficulty> BY_ID;
public static final StreamCodec<ByteBuf, Difficulty> STREAM_CODEC;
private final int id;
private final String key;
private Difficulty(int id, String key) {
this.id = id;
this.key = key;
}
public int getId() {
return this.id;
}
public Component getDisplayName() {
return Component.translatable("options.difficulty." + this.key);
}
public Component getInfo() {
return Component.translatable("options.difficulty." + this.key + ".info");
}
@Deprecated
public static Difficulty byId(int id) {
return BY_ID.apply(id);
}
public static @Nullable Difficulty byName(String name) {
return CODEC.byName(name);
}
public String getKey() {
return this.key;
}
@Override
public String getSerializedName() {
return this.key;
}
static {
CODEC = StringRepresentable.fromEnum(Difficulty::values);
BY_ID = ByIdMap.continuous(Difficulty::getId, Difficulty.values(), ByIdMap.OutOfBoundsStrategy.WRAP);
STREAM_CODEC = ByteBufCodecs.idMapper(BY_ID, Difficulty::getId);
}
}