zh_cn:tutorial:callbacks
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
zh_cn:tutorial:callbacks [2021/09/17 04:40] – solidblock | zh_cn:tutorial:callbacks [2023/05/04 11:01] (current) – [实例] solidblock | ||
---|---|---|---|
Line 17: | Line 17: | ||
此例注册一个 '' | 此例注册一个 '' | ||
< | < | ||
- | public class ExampleMod implements ModInitializer | + | public class ExampleMod implements ModInitializer { |
- | { | + | |
[...] | [...] | ||
| | ||
@Override | @Override | ||
- | public void onInitialize() | + | public void onInitialize() { |
- | | + | AttackBlockCallback.EVENT.register((player, |
- | AttackBlockCallback.EVENT.register((player, | + | |
- | | + | |
class_2680 state = world.method_8320(pos); | class_2680 state = world.method_8320(pos); | ||
- | /* 手动的旁观检查是必要的,因为 AttackBlockCallbacks 会在旁观检查之前销毁 | + | /* 手动的旁观者检查是必要的,因为 AttackBlockCallbacks 会在旁观者检查之前应用 |
if (state.method_29291() && !player.method_7325() && | if (state.method_29291() && !player.method_7325() && | ||
- | player.method_6047().method_7960()) | + | player.method_6047().method_7960()) { |
- | | + | |
player.method_5643(class_1282.field_5869, | player.method_5643(class_1282.field_5869, | ||
} | } |
zh_cn/tutorial/callbacks.1631853646.txt.gz · Last modified: 2021/09/17 04:40 by solidblock