FindTreeTutorialStepInstance.java
net.minecraft.client.tutorial.FindTreeTutorialStepInstance
信息
- 全限定名:net.minecraft.client.tutorial.FindTreeTutorialStepInstance
- 类型:public class
- 包:net.minecraft.client.tutorial
- 源码路径:src/main/java/net/minecraft/client/tutorial/FindTreeTutorialStepInstance.java
- 起始行号:L23
- 实现:TutorialStepInstance
- 职责:
TODO
字段/常量
-
HINT_DELAY- 类型:
int - 修饰符:
private static final - 源码定位:
L24 - 说明:
TODO
- 类型:
-
TITLE- 类型:
Component - 修饰符:
private static final - 源码定位:
L25 - 说明:
TODO
- 类型:
-
DESCRIPTION- 类型:
Component - 修饰符:
private static final - 源码定位:
L26 - 说明:
TODO
- 类型:
-
tutorial- 类型:
Tutorial - 修饰符:
private final - 源码定位:
L27 - 说明:
TODO
- 类型:
-
toast- 类型:
TutorialToast - 修饰符:
private - 源码定位:
L28 - 说明:
TODO
- 类型:
-
timeWaiting- 类型:
int - 修饰符:
private - 源码定位:
L29 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public FindTreeTutorialStepInstance(Tutorial tutorial) @ L31
- 构造器名:FindTreeTutorialStepInstance
- 源码定位:L31
- 修饰符:public
参数:
- tutorial: Tutorial
说明:
TODO
方法
下面的方法块按源码顺序生成。
public void tick() @ L35
- 方法名:tick
- 源码定位:L35
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void clear() @ L57
- 方法名:clear
- 源码定位:L57
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void onLookAt(ClientLevel level, HitResult hit) @ L65
- 方法名:onLookAt
- 源码定位:L65
- 返回类型:void
- 修饰符:public
参数:
- level: ClientLevel
- hit: HitResult
说明:
TODO
public void onGetItem(ItemStack itemStack) @ L75
- 方法名:onGetItem
- 源码定位:L75
- 返回类型:void
- 修饰符:public
参数:
- itemStack: ItemStack
说明:
TODO
private static boolean hasCollectedTreeItems(LocalPlayer player) @ L82
- 方法名:hasCollectedTreeItems
- 源码定位:L82
- 返回类型:boolean
- 修饰符:private static
参数:
- player: LocalPlayer
说明:
TODO
public static boolean hasPunchedTreesPreviously(LocalPlayer player) @ L86
- 方法名:hasPunchedTreesPreviously
- 源码定位:L86
- 返回类型:boolean
- 修饰符:public static
参数:
- player: LocalPlayer
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class FindTreeTutorialStepInstance implements TutorialStepInstance {
private static final int HINT_DELAY = 6000;
private static final Component TITLE = Component.translatable("tutorial.find_tree.title");
private static final Component DESCRIPTION = Component.translatable("tutorial.find_tree.description");
private final Tutorial tutorial;
private @Nullable TutorialToast toast;
private int timeWaiting;
public FindTreeTutorialStepInstance(Tutorial tutorial) {
this.tutorial = tutorial;
}
@Override
public void tick() {
this.timeWaiting++;
if (!this.tutorial.isSurvival()) {
this.tutorial.setStep(TutorialSteps.NONE);
} else {
Minecraft minecraft = this.tutorial.getMinecraft();
if (this.timeWaiting == 1) {
LocalPlayer player = minecraft.player;
if (player != null && (hasCollectedTreeItems(player) || hasPunchedTreesPreviously(player))) {
this.tutorial.setStep(TutorialSteps.CRAFT_PLANKS);
return;
}
}
if (this.timeWaiting >= 6000 && this.toast == null) {
this.toast = new TutorialToast(minecraft.font, TutorialToast.Icons.TREE, TITLE, DESCRIPTION, false);
minecraft.getToastManager().addToast(this.toast);
}
}
}
@Override
public void clear() {
if (this.toast != null) {
this.toast.hide();
this.toast = null;
}
}
@Override
public void onLookAt(ClientLevel level, HitResult hit) {
if (hit.getType() == HitResult.Type.BLOCK) {
BlockState state = level.getBlockState(((BlockHitResult)hit).getBlockPos());
if (state.is(BlockTags.COMPLETES_FIND_TREE_TUTORIAL)) {
this.tutorial.setStep(TutorialSteps.PUNCH_TREE);
}
}
}
@Override
public void onGetItem(ItemStack itemStack) {
if (itemStack.is(ItemTags.COMPLETES_FIND_TREE_TUTORIAL)) {
this.tutorial.setStep(TutorialSteps.CRAFT_PLANKS);
}
}
private static boolean hasCollectedTreeItems(LocalPlayer player) {
return player.getInventory().hasAnyMatching(item -> item.is(ItemTags.COMPLETES_FIND_TREE_TUTORIAL));
}
public static boolean hasPunchedTreesPreviously(LocalPlayer player) {
for (Holder<Block> holder : BuiltInRegistries.BLOCK.getTagOrEmpty(BlockTags.COMPLETES_FIND_TREE_TUTORIAL)) {
Block block = holder.value();
if (player.getStats().getValue(Stats.BLOCK_MINED.get(block)) > 0) {
return true;
}
}
return false;
}
}引用的其他类
-
- 引用位置:
字段/构造调用 - 关联成员:
TutorialToast()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Component.translatable()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: