Rect2i.java

net.minecraft.client.renderer.Rect2i

信息

  • 全限定名:net.minecraft.client.renderer.Rect2i
  • 类型:public class
  • 包:net.minecraft.client.renderer
  • 源码路径:src/main/java/net/minecraft/client/renderer/Rect2i.java
  • 起始行号:L7
  • 职责:

    TODO

字段/常量

  • xPos

    • 类型: int
    • 修饰符: private
    • 源码定位: L8
    • 说明:

      TODO

  • yPos

    • 类型: int
    • 修饰符: private
    • 源码定位: L9
    • 说明:

      TODO

  • width

    • 类型: int
    • 修饰符: private
    • 源码定位: L10
    • 说明:

      TODO

  • height

    • 类型: int
    • 修饰符: private
    • 源码定位: L11
    • 说明:

      TODO

内部类/嵌套类型

构造器

public Rect2i(int x, int y, int width, int height) @ L13

  • 构造器名:Rect2i
  • 源码定位:L13
  • 修饰符:public

参数:

  • x: int
  • y: int
  • width: int
  • height: int

说明:

TODO

方法

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

public Rect2i intersect(Rect2i other) @ L20

  • 方法名:intersect
  • 源码定位:L20
  • 返回类型:Rect2i
  • 修饰符:public

参数:

  • other: Rect2i

说明:

TODO

public int getX() @ L36

  • 方法名:getX
  • 源码定位:L36
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public int getY() @ L40

  • 方法名:getY
  • 源码定位:L40
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public void setX(int x) @ L44

  • 方法名:setX
  • 源码定位:L44
  • 返回类型:void
  • 修饰符:public

参数:

  • x: int

说明:

TODO

public void setY(int y) @ L48

  • 方法名:setY
  • 源码定位:L48
  • 返回类型:void
  • 修饰符:public

参数:

  • y: int

说明:

TODO

public int getWidth() @ L52

  • 方法名:getWidth
  • 源码定位:L52
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public int getHeight() @ L56

  • 方法名:getHeight
  • 源码定位:L56
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public void setWidth(int width) @ L60

  • 方法名:setWidth
  • 源码定位:L60
  • 返回类型:void
  • 修饰符:public

参数:

  • width: int

说明:

TODO

public void setHeight(int height) @ L64

  • 方法名:setHeight
  • 源码定位:L64
  • 返回类型:void
  • 修饰符:public

参数:

  • height: int

说明:

TODO

public void setPosition(int x, int y) @ L68

  • 方法名:setPosition
  • 源码定位:L68
  • 返回类型:void
  • 修饰符:public

参数:

  • x: int
  • y: int

说明:

TODO

public boolean contains(int x, int y) @ L73

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

参数:

  • x: int
  • y: int

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class Rect2i {
    private int xPos;
    private int yPos;
    private int width;
    private int height;
 
    public Rect2i(int x, int y, int width, int height) {
        this.xPos = x;
        this.yPos = y;
        this.width = width;
        this.height = height;
    }
 
    public Rect2i intersect(Rect2i other) {
        int x0 = this.xPos;
        int y0 = this.yPos;
        int x1 = this.xPos + this.width;
        int y1 = this.yPos + this.height;
        int x2 = other.getX();
        int y2 = other.getY();
        int x3 = x2 + other.getWidth();
        int y3 = y2 + other.getHeight();
        this.xPos = Math.max(x0, x2);
        this.yPos = Math.max(y0, y2);
        this.width = Math.max(0, Math.min(x1, x3) - this.xPos);
        this.height = Math.max(0, Math.min(y1, y3) - this.yPos);
        return this;
    }
 
    public int getX() {
        return this.xPos;
    }
 
    public int getY() {
        return this.yPos;
    }
 
    public void setX(int x) {
        this.xPos = x;
    }
 
    public void setY(int y) {
        this.yPos = y;
    }
 
    public int getWidth() {
        return this.width;
    }
 
    public int getHeight() {
        return this.height;
    }
 
    public void setWidth(int width) {
        this.width = width;
    }
 
    public void setHeight(int height) {
        this.height = height;
    }
 
    public void setPosition(int x, int y) {
        this.xPos = x;
        this.yPos = y;
    }
 
    public boolean contains(int x, int y) {
        return x >= this.xPos && x <= this.xPos + this.width && y >= this.yPos && y <= this.yPos + this.height;
    }
}

引用的其他类