NeedleDirectionHelper.java
net.minecraft.client.renderer.item.properties.numeric.NeedleDirectionHelper
信息
- 全限定名:net.minecraft.client.renderer.item.properties.numeric.NeedleDirectionHelper
- 类型:public abstract class
- 包:net.minecraft.client.renderer.item.properties.numeric
- 源码路径:src/main/java/net/minecraft/client/renderer/item/properties/numeric/NeedleDirectionHelper.java
- 起始行号:L12
- 职责:
TODO
字段/常量
wobble- 类型:
boolean - 修饰符:
private final - 源码定位:
L13 - 说明:
TODO
- 类型:
内部类/嵌套类型
net.minecraft.client.renderer.item.properties.numeric.NeedleDirectionHelper.Wobbler- 类型:
interface - 修饰符:
public - 源码定位:
L90 - 说明:
TODO
- 类型:
构造器
protected NeedleDirectionHelper(boolean wobble) @ L15
- 构造器名:NeedleDirectionHelper
- 源码定位:L15
- 修饰符:protected
参数:
- wobble: boolean
说明:
TODO
方法
下面的方法块按源码顺序生成。
public float get(ItemStack itemStack, ClientLevel clientLevel, ItemOwner owner, int seed) @ L19
- 方法名:get
- 源码定位:L19
- 返回类型:float
- 修饰符:public
参数:
- itemStack: ItemStack
- clientLevel: ClientLevel
- owner: ItemOwner
- seed: int
说明:
TODO
protected abstract float calculate(ItemStack itemStack, ClientLevel level, int seed, ItemOwner owner) @ L31
- 方法名:calculate
- 源码定位:L31
- 返回类型:float
- 修饰符:protected abstract
参数:
- itemStack: ItemStack
- level: ClientLevel
- seed: int
- owner: ItemOwner
说明:
TODO
protected boolean wobble() @ L33
- 方法名:wobble
- 源码定位:L33
- 返回类型:boolean
- 修饰符:protected
参数:
- 无
说明:
TODO
protected NeedleDirectionHelper.Wobbler newWobbler(float factor) @ L37
- 方法名:newWobbler
- 源码定位:L37
- 返回类型:NeedleDirectionHelper.Wobbler
- 修饰符:protected
参数:
- factor: float
说明:
TODO
public static NeedleDirectionHelper.Wobbler standardWobbler(float factor) @ L41
- 方法名:standardWobbler
- 源码定位:L41
- 返回类型:NeedleDirectionHelper.Wobbler
- 修饰符:public static
参数:
- factor: float
说明:
TODO
public static NeedleDirectionHelper.Wobbler nonWobbler() @ L68
- 方法名:nonWobbler
- 源码定位:L68
- 返回类型:NeedleDirectionHelper.Wobbler
- 修饰符:public static
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public abstract class NeedleDirectionHelper {
private final boolean wobble;
protected NeedleDirectionHelper(boolean wobble) {
this.wobble = wobble;
}
public float get(ItemStack itemStack, @Nullable ClientLevel clientLevel, @Nullable ItemOwner owner, int seed) {
if (owner == null) {
return 0.0F;
} else {
if (clientLevel == null && owner.level() instanceof ClientLevel level) {
clientLevel = level;
}
return clientLevel == null ? 0.0F : this.calculate(itemStack, clientLevel, seed, owner);
}
}
protected abstract float calculate(final ItemStack itemStack, final ClientLevel level, final int seed, final ItemOwner owner);
protected boolean wobble() {
return this.wobble;
}
protected NeedleDirectionHelper.Wobbler newWobbler(float factor) {
return this.wobble ? standardWobbler(factor) : nonWobbler();
}
public static NeedleDirectionHelper.Wobbler standardWobbler(float factor) {
return new NeedleDirectionHelper.Wobbler() {
private float rotation;
private float deltaRotation;
private long lastUpdateTick;
@Override
public float rotation() {
return this.rotation;
}
@Override
public boolean shouldUpdate(long tick) {
return this.lastUpdateTick != tick;
}
@Override
public void update(long tick, float targetRotation) {
this.lastUpdateTick = tick;
float tempDeltaRotation = Mth.positiveModulo(targetRotation - this.rotation + 0.5F, 1.0F) - 0.5F;
this.deltaRotation += tempDeltaRotation * 0.1F;
this.deltaRotation = this.deltaRotation * factor;
this.rotation = Mth.positiveModulo(this.rotation + this.deltaRotation, 1.0F);
}
};
}
public static NeedleDirectionHelper.Wobbler nonWobbler() {
return new NeedleDirectionHelper.Wobbler() {
private float targetValue;
@Override
public float rotation() {
return this.targetValue;
}
@Override
public boolean shouldUpdate(long tick) {
return true;
}
@Override
public void update(long tick, float targetRotation) {
this.targetValue = targetRotation;
}
};
}
@OnlyIn(Dist.CLIENT)
public interface Wobbler {
float rotation();
boolean shouldUpdate(long tick);
void update(long tick, float targetRotation);
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.positiveModulo()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: