User Tools

Site Tools


drafts:new_mixin_example

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
drafts:new_mixin_example [2023/09/13 18:46] – removed - external edit (Unknown date) 127.0.0.1drafts:new_mixin_example [2023/09/13 18:46] (current) – ↷ Page moved and renamed from playground:playground to drafts:new_mixin_example nebelnidas
Line 1: Line 1:
 +====== Playground ======
 +Possible addition to [[tutorial:mixin_examples|Mixin Examples]]
 +[[http://example.com|External Link]]
 +===== Modifying a static block =====
 +<code diff>
 +static {
 +int i = 4;
 +}
 +</code>
  
 +{{
 +https://dokuwiki-image-link.cph101.repl.co/test.svg
 +}}
 +
 +<yarncode java [enable_line_numbers="true"]>
 +public class ExampleMod implements ModInitializer {
 +    [...]
 +    
 +    @Override
 +    public void onInitialize() {
 +        AttackBlockCallback.EVENT.register((player, world, hand, pos, direction) -> {
 +            class_2680 state = world.method_8320(pos);
 +            /* Manual spectator check is necessary because AttackBlockCallbacks
 +               fire before the spectator check */
 +            if (state.method_29291() && !player.method_7325() && 
 +                player.method_6047().method_7960()) {
 +                player.method_5643(player.method_48923().method_48830(), 1.0F);
 +            } 
 +            return class_1269.field_5811;
 +        });
 +    }
 +}
 +</yarncode>
 +
 +
 +[[ns:page|{{:info.png}}]]