Time.java
net.minecraft.client.renderer.item.properties.numeric.Time
信息
- 全限定名:net.minecraft.client.renderer.item.properties.numeric.Time
- 类型:public class
- 包:net.minecraft.client.renderer.item.properties.numeric
- 源码路径:src/main/java/net/minecraft/client/renderer/item/properties/numeric/Time.java
- 起始行号:L17
- 继承:NeedleDirectionHelper
- 实现:RangeSelectItemModelProperty
- 职责:
TODO
字段/常量
-
MAP_CODEC- 类型:
MapCodec<Time> - 修饰符:
public static final - 源码定位:
L18 - 说明:
TODO
- 类型:
-
source- 类型:
Time.TimeSource - 修饰符:
private final - 源码定位:
L25 - 说明:
TODO
- 类型:
-
randomSource- 类型:
RandomSource - 修饰符:
private final - 源码定位:
L26 - 说明:
TODO
- 类型:
-
wobbler- 类型:
NeedleDirectionHelper.Wobbler - 修饰符:
private final - 源码定位:
L27 - 说明:
TODO
- 类型:
内部类/嵌套类型
net.minecraft.client.renderer.item.properties.numeric.Time.TimeSource- 类型:
enum - 修饰符:
public static - 源码定位:
L52 - 说明:
TODO
- 类型:
构造器
public Time(boolean wooble, Time.TimeSource source) @ L29
- 构造器名:Time
- 源码定位:L29
- 修饰符:public
参数:
- wooble: boolean
- source: Time.TimeSource
说明:
TODO
方法
下面的方法块按源码顺序生成。
protected float calculate(ItemStack itemStack, ClientLevel level, int seed, ItemOwner owner) @ L35
- 方法名:calculate
- 源码定位:L35
- 返回类型:float
- 修饰符:protected
参数:
- itemStack: ItemStack
- level: ClientLevel
- seed: int
- owner: ItemOwner
说明:
TODO
public MapCodec<Time> type() @ L46
- 方法名:type
- 源码定位:L46
- 返回类型:MapCodec
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class Time extends NeedleDirectionHelper implements RangeSelectItemModelProperty {
public static final MapCodec<Time> MAP_CODEC = RecordCodecBuilder.mapCodec(
i -> i.group(
Codec.BOOL.optionalFieldOf("wobble", true).forGetter(NeedleDirectionHelper::wobble),
Time.TimeSource.CODEC.fieldOf("source").forGetter(o -> o.source)
)
.apply(i, Time::new)
);
private final Time.TimeSource source;
private final RandomSource randomSource = RandomSource.create();
private final NeedleDirectionHelper.Wobbler wobbler;
public Time(boolean wooble, Time.TimeSource source) {
super(wooble);
this.source = source;
this.wobbler = this.newWobbler(0.9F);
}
@Override
protected float calculate(ItemStack itemStack, ClientLevel level, int seed, ItemOwner owner) {
float targetRotation = this.source.get(level, itemStack, owner, this.randomSource);
long gameTime = level.getGameTime();
if (this.wobbler.shouldUpdate(gameTime)) {
this.wobbler.update(gameTime, targetRotation);
}
return this.wobbler.rotation();
}
@Override
public MapCodec<Time> type() {
return MAP_CODEC;
}
@OnlyIn(Dist.CLIENT)
public static enum TimeSource implements StringRepresentable {
RANDOM("random") {
@Override
public float get(ClientLevel level, ItemStack itemStack, ItemOwner owner, RandomSource random) {
return random.nextFloat();
}
},
DAYTIME("daytime") {
@Override
public float get(ClientLevel level, ItemStack itemStack, ItemOwner owner, RandomSource random) {
return level.environmentAttributes().getValue(EnvironmentAttributes.SUN_ANGLE, owner.position()) / 360.0F;
}
},
MOON_PHASE("moon_phase") {
@Override
public float get(ClientLevel level, ItemStack itemStack, ItemOwner owner, RandomSource random) {
return (float)level.environmentAttributes().getValue(EnvironmentAttributes.MOON_PHASE, owner.position()).index() / MoonPhase.COUNT;
}
};
public static final Codec<Time.TimeSource> CODEC = StringRepresentable.fromEnum(Time.TimeSource::values);
private final String name;
private TimeSource(String name) {
this.name = name;
}
@Override
public String getSerializedName() {
return this.name;
}
abstract float get(final ClientLevel level, final ItemStack itemStack, final ItemOwner owner, final RandomSource random);
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
字段/继承
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
RandomSource.create()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
StringRepresentable.fromEnum()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: