SplashManager.java

net.minecraft.client.resources.SplashManager

信息

  • 全限定名:net.minecraft.client.resources.SplashManager
  • 类型:public class
  • 包:net.minecraft.client.resources
  • 源码路径:src/main/java/net/minecraft/client/resources/SplashManager.java
  • 起始行号:L24
  • 继承:SimplePreparableReloadListener<List>
  • 职责:

    TODO

字段/常量

  • DEFAULT_STYLE

    • 类型: Style
    • 修饰符: private static final
    • 源码定位: L25
    • 说明:

      TODO

  • CHRISTMAS

    • 类型: Component
    • 修饰符: public static final
    • 源码定位: L26
    • 说明:

      TODO

  • NEW_YEAR

    • 类型: Component
    • 修饰符: public static final
    • 源码定位: L27
    • 说明:

      TODO

  • HALLOWEEN

    • 类型: Component
    • 修饰符: public static final
    • 源码定位: L28
    • 说明:

      TODO

  • SPLASHES_LOCATION

    • 类型: Identifier
    • 修饰符: private static final
    • 源码定位: L29
    • 说明:

      TODO

  • RANDOM

    • 类型: RandomSource
    • 修饰符: private static final
    • 源码定位: L30
    • 说明:

      TODO

  • splashes

    • 类型: List<Component>
    • 修饰符: private
    • 源码定位: L31
    • 说明:

      TODO

  • user

    • 类型: User
    • 修饰符: private final
    • 源码定位: L32
    • 说明:

      TODO

内部类/嵌套类型

构造器

public SplashManager(User user) @ L34

  • 构造器名:SplashManager
  • 源码定位:L34
  • 修饰符:public

参数:

  • user: User

说明:

TODO

方法

下面的方法块按源码顺序生成。

private static Component literalSplash(String text) @ L38

  • 方法名:literalSplash
  • 源码定位:L38
  • 返回类型:Component
  • 修饰符:private static

参数:

  • text: String

说明:

TODO

protected List<Component> prepare(ResourceManager manager, ProfilerFiller profiler) @ L42

  • 方法名:prepare
  • 源码定位:L42
  • 返回类型:List
  • 修饰符:protected

参数:

  • manager: ResourceManager
  • profiler: ProfilerFiller

说明:

TODO

protected void apply(List<Component> preparations, ResourceManager manager, ProfilerFiller profiler) @ L55

  • 方法名:apply
  • 源码定位:L55
  • 返回类型:void
  • 修饰符:protected

参数:

  • preparations: List
  • manager: ResourceManager
  • profiler: ProfilerFiller

说明:

TODO

public SplashRenderer getSplash() @ L59

  • 方法名:getSplash
  • 源码定位:L59
  • 返回类型:SplashRenderer
  • 修饰符:public

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class SplashManager extends SimplePreparableReloadListener<List<Component>> {
    private static final Style DEFAULT_STYLE = Style.EMPTY.withColor(-256);
    public static final Component CHRISTMAS = literalSplash("Merry X-mas!");
    public static final Component NEW_YEAR = literalSplash("Happy new year!");
    public static final Component HALLOWEEN = literalSplash("OOoooOOOoooo! Spooky!");
    private static final Identifier SPLASHES_LOCATION = Identifier.withDefaultNamespace("texts/splashes.txt");
    private static final RandomSource RANDOM = RandomSource.create();
    private List<Component> splashes = List.of();
    private final User user;
 
    public SplashManager(User user) {
        this.user = user;
    }
 
    private static Component literalSplash(String text) {
        return Component.literal(text).setStyle(DEFAULT_STYLE);
    }
 
    protected List<Component> prepare(ResourceManager manager, ProfilerFiller profiler) {
        try {
            List var4;
            try (BufferedReader reader = Minecraft.getInstance().getResourceManager().openAsReader(SPLASHES_LOCATION)) {
                var4 = reader.lines().map(String::trim).filter(line -> line.hashCode() != 125780783).map(SplashManager::literalSplash).toList();
            }
 
            return var4;
        } catch (IOException var8) {
            return List.of();
        }
    }
 
    protected void apply(List<Component> preparations, ResourceManager manager, ProfilerFiller profiler) {
        this.splashes = List.copyOf(preparations);
    }
 
    public @Nullable SplashRenderer getSplash() {
        MonthDay monthDay = SpecialDates.dayNow();
        if (monthDay.equals(SpecialDates.CHRISTMAS)) {
            return SplashRenderer.CHRISTMAS;
        } else if (monthDay.equals(SpecialDates.NEW_YEAR)) {
            return SplashRenderer.NEW_YEAR;
        } else if (monthDay.equals(SpecialDates.HALLOWEEN)) {
            return SplashRenderer.HALLOWEEN;
        } else if (this.splashes.isEmpty()) {
            return null;
        } else {
            return this.user != null && RANDOM.nextInt(this.splashes.size()) == 42
                ? new SplashRenderer(literalSplash(this.user.getName().toUpperCase(Locale.ROOT) + " IS YOU"))
                : new SplashRenderer(this.splashes.get(RANDOM.nextInt(this.splashes.size())));
        }
    }
}

引用的其他类

  • Minecraft

    • 引用位置: 方法调用
    • 关联成员: Minecraft.getInstance()
  • User

    • 引用位置: 参数/字段
  • SplashRenderer

    • 引用位置: 构造调用/返回值
    • 关联成员: SplashRenderer()
  • Component

    • 引用位置: 参数/字段/方法调用/返回值
    • 关联成员: Component.literal()
  • Style

    • 引用位置: 字段
  • Identifier

    • 引用位置: 字段/方法调用
    • 关联成员: Identifier.withDefaultNamespace()
  • ResourceManager

    • 引用位置: 参数
  • SimplePreparableReloadListener

    • 引用位置: 继承
  • RandomSource

    • 引用位置: 字段/方法调用
    • 关联成员: RandomSource.create()
  • SpecialDates

    • 引用位置: 方法调用
    • 关联成员: SpecialDates.dayNow()
  • ProfilerFiller

    • 引用位置: 参数