VecDeltaCodec.java
net.minecraft.network.protocol.game.VecDeltaCodec
信息
- 全限定名:net.minecraft.network.protocol.game.VecDeltaCodec
- 类型:public class
- 包:net.minecraft.network.protocol.game
- 源码路径:src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java
- 起始行号:L6
- 职责:
TODO
字段/常量
-
TRUNCATION_STEPS- 类型:
double - 修饰符:
private static final - 源码定位:
L7 - 说明:
TODO
- 类型:
-
base- 类型:
Vec3 - 修饰符:
private - 源码定位:
L8 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
static long encode(double input) @ L10
- 方法名:encode
- 源码定位:L10
- 返回类型:long
- 修饰符:static
参数:
- input: double
说明:
TODO
static double decode(long v) @ L15
- 方法名:decode
- 源码定位:L15
- 返回类型:double
- 修饰符:static
参数:
- v: long
说明:
TODO
public Vec3 decode(long xa, long ya, long za) @ L20
- 方法名:decode
- 源码定位:L20
- 返回类型:Vec3
- 修饰符:public
参数:
- xa: long
- ya: long
- za: long
说明:
TODO
public long encodeX(Vec3 pos) @ L31
- 方法名:encodeX
- 源码定位:L31
- 返回类型:long
- 修饰符:public
参数:
- pos: Vec3
说明:
TODO
public long encodeY(Vec3 pos) @ L35
- 方法名:encodeY
- 源码定位:L35
- 返回类型:long
- 修饰符:public
参数:
- pos: Vec3
说明:
TODO
public long encodeZ(Vec3 pos) @ L39
- 方法名:encodeZ
- 源码定位:L39
- 返回类型:long
- 修饰符:public
参数:
- pos: Vec3
说明:
TODO
public Vec3 delta(Vec3 pos) @ L43
- 方法名:delta
- 源码定位:L43
- 返回类型:Vec3
- 修饰符:public
参数:
- pos: Vec3
说明:
TODO
public void setBase(Vec3 base) @ L47
- 方法名:setBase
- 源码定位:L47
- 返回类型:void
- 修饰符:public
参数:
- base: Vec3
说明:
TODO
public Vec3 getBase() @ L51
- 方法名:getBase
- 源码定位:L51
- 返回类型:Vec3
- 修饰符:public
参数:
- 无
说明:
TODO
代码
public class VecDeltaCodec {
private static final double TRUNCATION_STEPS = 4096.0;
private Vec3 base = Vec3.ZERO;
@VisibleForTesting
static long encode(double input) {
return Math.round(input * 4096.0);
}
@VisibleForTesting
static double decode(long v) {
return v / 4096.0;
}
public Vec3 decode(long xa, long ya, long za) {
if (xa == 0L && ya == 0L && za == 0L) {
return this.base;
} else {
double x = xa == 0L ? this.base.x : decode(encode(this.base.x) + xa);
double y = ya == 0L ? this.base.y : decode(encode(this.base.y) + ya);
double z = za == 0L ? this.base.z : decode(encode(this.base.z) + za);
return new Vec3(x, y, z);
}
}
public long encodeX(Vec3 pos) {
return encode(pos.x) - encode(this.base.x);
}
public long encodeY(Vec3 pos) {
return encode(pos.y) - encode(this.base.y);
}
public long encodeZ(Vec3 pos) {
return encode(pos.z) - encode(this.base.z);
}
public Vec3 delta(Vec3 pos) {
return pos.subtract(this.base);
}
public void setBase(Vec3 base) {
this.base = base;
}
public Vec3 getBase() {
return this.base;
}
}引用的其他类
- Vec3
- 引用位置:
参数/字段/构造调用/返回值 - 关联成员:
Vec3()
- 引用位置: