InteractionResult.java
net.minecraft.world.InteractionResult
信息
- 全限定名:net.minecraft.world.InteractionResult
- 类型:public sealed interface
- 包:net.minecraft.world
- 源码路径:src/main/java/net/minecraft/world/InteractionResult.java
- 起始行号:L6
- 职责:
TODO
字段/常量
-
SUCCESS- 类型:
InteractionResult.Success - 修饰符:
package-private - 源码定位:
L11 - 说明:
TODO
- 类型:
-
SUCCESS_SERVER- 类型:
InteractionResult.Success - 修饰符:
package-private - 源码定位:
L12 - 说明:
TODO
- 类型:
-
CONSUME- 类型:
InteractionResult.Success - 修饰符:
package-private - 源码定位:
L13 - 说明:
TODO
- 类型:
-
FAIL- 类型:
InteractionResult.Fail - 修饰符:
package-private - 源码定位:
L14 - 说明:
TODO
- 类型:
-
PASS- 类型:
InteractionResult.Pass - 修饰符:
package-private - 源码定位:
L15 - 说明:
TODO
- 类型:
-
TRY_WITH_EMPTY_HAND- 类型:
InteractionResult.TryEmptyHandInteraction - 修饰符:
package-private - 源码定位:
L16 - 说明:
TODO
- 类型:
内部类/嵌套类型
-
net.minecraft.world.InteractionResult.Fail- 类型:
record - 修饰符:
public - 源码定位:
L22 - 说明:
TODO
- 类型:
-
net.minecraft.world.InteractionResult.ItemContext- 类型:
record - 修饰符:
public - 源码定位:
L25 - 说明:
TODO
- 类型:
-
net.minecraft.world.InteractionResult.Pass- 类型:
record - 修饰符:
public - 源码定位:
L30 - 说明:
TODO
- 类型:
-
net.minecraft.world.InteractionResult.Success- 类型:
record - 修饰符:
public - 源码定位:
L33 - 说明:
TODO
- 类型:
-
net.minecraft.world.InteractionResult.SwingSource- 类型:
enum - 修饰符:
public static - 源码定位:
L56 - 说明:
TODO
- 类型:
-
net.minecraft.world.InteractionResult.TryEmptyHandInteraction- 类型:
record - 修饰符:
public - 源码定位:
L62 - 说明:
TODO
- 类型:
构造器
- 无
方法
下面的方法块按源码顺序生成。
default boolean consumesAction() @ L18
- 方法名:consumesAction
- 源码定位:L18
- 返回类型:boolean
- 修饰符:default
参数:
- 无
说明:
TODO
代码
public sealed interface InteractionResult
permits InteractionResult.Success,
InteractionResult.Fail,
InteractionResult.Pass,
InteractionResult.TryEmptyHandInteraction {
InteractionResult.Success SUCCESS = new InteractionResult.Success(InteractionResult.SwingSource.CLIENT, InteractionResult.ItemContext.DEFAULT);
InteractionResult.Success SUCCESS_SERVER = new InteractionResult.Success(InteractionResult.SwingSource.SERVER, InteractionResult.ItemContext.DEFAULT);
InteractionResult.Success CONSUME = new InteractionResult.Success(InteractionResult.SwingSource.NONE, InteractionResult.ItemContext.DEFAULT);
InteractionResult.Fail FAIL = new InteractionResult.Fail();
InteractionResult.Pass PASS = new InteractionResult.Pass();
InteractionResult.TryEmptyHandInteraction TRY_WITH_EMPTY_HAND = new InteractionResult.TryEmptyHandInteraction();
default boolean consumesAction() {
return false;
}
public record Fail() implements InteractionResult {
}
public record ItemContext(boolean wasItemInteraction, @Nullable ItemStack heldItemTransformedTo) {
static final InteractionResult.ItemContext NONE = new InteractionResult.ItemContext(false, null);
static final InteractionResult.ItemContext DEFAULT = new InteractionResult.ItemContext(true, null);
}
public record Pass() implements InteractionResult {
}
public record Success(InteractionResult.SwingSource swingSource, InteractionResult.ItemContext itemContext) implements InteractionResult {
@Override
public boolean consumesAction() {
return true;
}
public InteractionResult.Success heldItemTransformedTo(ItemStack itemStack) {
return new InteractionResult.Success(this.swingSource, new InteractionResult.ItemContext(true, itemStack));
}
public InteractionResult.Success withoutItem() {
return new InteractionResult.Success(this.swingSource, InteractionResult.ItemContext.NONE);
}
public boolean wasItemInteraction() {
return this.itemContext.wasItemInteraction;
}
public @Nullable ItemStack heldItemTransformedTo() {
return this.itemContext.heldItemTransformedTo;
}
}
public static enum SwingSource {
NONE,
CLIENT,
SERVER;
}
public record TryEmptyHandInteraction() implements InteractionResult {
}
}引用的其他类
- 无