PunchTreeTutorialStepInstance.java
net.minecraft.client.tutorial.PunchTreeTutorialStepInstance
信息
- 全限定名:net.minecraft.client.tutorial.PunchTreeTutorialStepInstance
- 类型:public class
- 包:net.minecraft.client.tutorial
- 源码路径:src/main/java/net/minecraft/client/tutorial/PunchTreeTutorialStepInstance.java
- 起始行号:L18
- 实现:TutorialStepInstance
- 职责:
TODO
字段/常量
-
HINT_DELAY- 类型:
int - 修饰符:
private static final - 源码定位:
L19 - 说明:
TODO
- 类型:
-
TITLE- 类型:
Component - 修饰符:
private static final - 源码定位:
L20 - 说明:
TODO
- 类型:
-
DESCRIPTION- 类型:
Component - 修饰符:
private static final - 源码定位:
L21 - 说明:
TODO
- 类型:
-
tutorial- 类型:
Tutorial - 修饰符:
private final - 源码定位:
L22 - 说明:
TODO
- 类型:
-
toast- 类型:
TutorialToast - 修饰符:
private - 源码定位:
L23 - 说明:
TODO
- 类型:
-
timeWaiting- 类型:
int - 修饰符:
private - 源码定位:
L24 - 说明:
TODO
- 类型:
-
resetCount- 类型:
int - 修饰符:
private - 源码定位:
L25 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public PunchTreeTutorialStepInstance(Tutorial tutorial) @ L27
- 构造器名:PunchTreeTutorialStepInstance
- 源码定位:L27
- 修饰符:public
参数:
- tutorial: Tutorial
说明:
TODO
方法
下面的方法块按源码顺序生成。
public void tick() @ L31
- 方法名:tick
- 源码定位:L31
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void clear() @ L60
- 方法名:clear
- 源码定位:L60
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void onDestroyBlock(ClientLevel level, BlockPos pos, BlockState state, float percent) @ L68
- 方法名:onDestroyBlock
- 源码定位:L68
- 返回类型:void
- 修饰符:public
参数:
- level: ClientLevel
- pos: BlockPos
- state: BlockState
- percent: float
说明:
TODO
public void onGetItem(ItemStack itemStack) @ L86
- 方法名:onGetItem
- 源码定位:L86
- 返回类型:void
- 修饰符:public
参数:
- itemStack: ItemStack
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class PunchTreeTutorialStepInstance implements TutorialStepInstance {
private static final int HINT_DELAY = 600;
private static final Component TITLE = Component.translatable("tutorial.punch_tree.title");
private static final Component DESCRIPTION = Component.translatable("tutorial.punch_tree.description", Tutorial.key("attack"));
private final Tutorial tutorial;
private @Nullable TutorialToast toast;
private int timeWaiting;
private int resetCount;
public PunchTreeTutorialStepInstance(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) {
if (player.getInventory().contains(ItemTags.LOGS)) {
this.tutorial.setStep(TutorialSteps.CRAFT_PLANKS);
return;
}
if (FindTreeTutorialStepInstance.hasPunchedTreesPreviously(player)) {
this.tutorial.setStep(TutorialSteps.CRAFT_PLANKS);
return;
}
}
}
if ((this.timeWaiting >= 600 || this.resetCount > 3) && this.toast == null) {
this.toast = new TutorialToast(minecraft.font, TutorialToast.Icons.TREE, TITLE, DESCRIPTION, true);
minecraft.getToastManager().addToast(this.toast);
}
}
}
@Override
public void clear() {
if (this.toast != null) {
this.toast.hide();
this.toast = null;
}
}
@Override
public void onDestroyBlock(ClientLevel level, BlockPos pos, BlockState state, float percent) {
boolean isLogBlock = state.is(BlockTags.LOGS);
if (isLogBlock && percent > 0.0F) {
if (this.toast != null) {
this.toast.updateProgress(percent);
}
if (percent >= 1.0F) {
this.tutorial.setStep(TutorialSteps.OPEN_INVENTORY);
}
} else if (this.toast != null) {
this.toast.updateProgress(0.0F);
} else if (isLogBlock) {
this.resetCount++;
}
}
@Override
public void onGetItem(ItemStack itemStack) {
if (itemStack.is(ItemTags.LOGS)) {
this.tutorial.setStep(TutorialSteps.CRAFT_PLANKS);
}
}
}引用的其他类
-
- 引用位置:
字段/构造调用 - 关联成员:
TutorialToast()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
FindTreeTutorialStepInstance.hasPunchedTreesPreviously()
- 引用位置:
-
- 引用位置:
参数/字段/方法调用 - 关联成员:
Tutorial.key()
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Component.translatable()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: