ScreenDirection.java

net.minecraft.client.gui.navigation.ScreenDirection

信息

  • 全限定名:net.minecraft.client.gui.navigation.ScreenDirection
  • 类型:public enum
  • 包:net.minecraft.client.gui.navigation
  • 源码路径:src/main/java/net/minecraft/client/gui/navigation/ScreenDirection.java
  • 起始行号:L8
  • 职责:

    TODO

字段/常量

  • UP, DOWN, LEFT, RIGHT

    • 类型: ScreenDirection
    • 修饰符: package-private
    • 源码定位: L9
    • 说明:

      TODO

  • coordinateValueComparator

    • 类型: IntComparator
    • 修饰符: private final
    • 源码定位: L14
    • 说明:

      TODO

内部类/嵌套类型

构造器

方法

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

public ScreenAxis getAxis() @ L16

  • 方法名:getAxis
  • 源码定位:L16
  • 返回类型:ScreenAxis
  • 修饰符:public

参数:

说明:

TODO

public ScreenDirection getOpposite() @ L23

  • 方法名:getOpposite
  • 源码定位:L23
  • 返回类型:ScreenDirection
  • 修饰符:public

参数:

说明:

TODO

public boolean isPositive() @ L32

  • 方法名:isPositive
  • 源码定位:L32
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public boolean isAfter(int a, int b) @ L39

  • 方法名:isAfter
  • 源码定位:L39
  • 返回类型:boolean
  • 修饰符:public

参数:

  • a: int
  • b: int

说明:

TODO

public boolean isBefore(int a, int b) @ L43

  • 方法名:isBefore
  • 源码定位:L43
  • 返回类型:boolean
  • 修饰符:public

参数:

  • a: int
  • b: int

说明:

TODO

public IntComparator coordinateValueComparator() @ L47

  • 方法名:coordinateValueComparator
  • 源码定位:L47
  • 返回类型:IntComparator
  • 修饰符:public

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public enum ScreenDirection {
    UP,
    DOWN,
    LEFT,
    RIGHT;
 
    private final IntComparator coordinateValueComparator = (k1, k2) -> k1 == k2 ? 0 : (this.isBefore(k1, k2) ? -1 : 1);
 
    public ScreenAxis getAxis() {
        return switch (this) {
            case UP, DOWN -> ScreenAxis.VERTICAL;
            case LEFT, RIGHT -> ScreenAxis.HORIZONTAL;
        };
    }
 
    public ScreenDirection getOpposite() {
        return switch (this) {
            case UP -> DOWN;
            case DOWN -> UP;
            case LEFT -> RIGHT;
            case RIGHT -> LEFT;
        };
    }
 
    public boolean isPositive() {
        return switch (this) {
            case UP, LEFT -> false;
            case DOWN, RIGHT -> true;
        };
    }
 
    public boolean isAfter(int a, int b) {
        return this.isPositive() ? a > b : b > a;
    }
 
    public boolean isBefore(int a, int b) {
        return this.isPositive() ? a < b : b < a;
    }
 
    public IntComparator coordinateValueComparator() {
        return this.coordinateValueComparator;
    }
}

引用的其他类