44import net .minecraft .block .TntBlock ;
55import net .minecraft .entity .player .PlayerEntity ;
66import net .minecraft .registry .tag .DamageTypeTags ;
7- import xyz .nucleoid .stimuli .event .DroppedItemsResult ;
7+ // import xyz.nucleoid.stimuli.event.DroppedItemsResult;
88import xyz .nucleoid .stimuli .event .EventRegistrar ;
99import xyz .nucleoid .stimuli .event .EventResult ;
1010import xyz .nucleoid .stimuli .event .StimulusEvent ;
2828import xyz .nucleoid .stimuli .event .world .NetherPortalOpenEvent ;
2929
3030import java .util .Comparator ;
31+ import java .util .List ;
3132
3233public final class GameRuleType {
3334 public static final Comparator <GameRuleType > COMPARATOR = Comparator .comparing (type -> type .priority );
3435
3536 public static final GameRuleType BREAK_BLOCKS = GameRuleType .create ()
36- .enforces (BlockBreakEvent .EVENT , result -> (player , world , pos ) -> result );
37+ .enforces (BlockBreakEvent .EVENT , result -> (player , world , pos ) -> result . asActionResult () );
3738
3839 public static final GameRuleType PLACE_BLOCKS = GameRuleType .create ()
39- .enforces (BlockPlaceEvent .BEFORE , result -> (player , world , pos , state , ctx ) -> result );
40+ .enforces (BlockPlaceEvent .BEFORE , result -> (player , world , pos , state , ctx ) -> result . asActionResult () );
4041
4142 public static final GameRuleType PORTALS = GameRuleType .create ()
42- .enforces (NetherPortalOpenEvent .EVENT , result -> (world , pos ) -> result );
43+ .enforces (NetherPortalOpenEvent .EVENT , result -> (world , pos ) -> result . asActionResult () );
4344
4445 public static final GameRuleType CRAFTING = GameRuleType .create ()
45- .enforces (ItemCraftEvent .EVENT , result -> (player , recipe ) -> result );
46+ .enforces (ItemCraftEvent .EVENT , result -> (player , recipe ) -> result . asActionResult () );
4647
4748 public static final GameRuleType PVP = GameRuleType .create ()
4849 .enforces (PlayerDamageEvent .EVENT , result -> (player , source , amount ) -> {
4950 if (source .getSource () instanceof PlayerEntity ) {
50- return result ;
51+ return result . asActionResult () ;
5152 } else {
52- return EventResult .PASS ;
53+ return EventResult .PASS . asActionResult () ;
5354 }
5455 });
5556
5657 public static final GameRuleType HUNGER = GameRuleType .create ()
57- .enforces (PlayerConsumeHungerEvent .EVENT , result -> (player , foodLevel , saturation , exhaustion ) -> result );
58+ .enforces (PlayerConsumeHungerEvent .EVENT , result -> (player , foodLevel , saturation , exhaustion ) -> result . asActionResult () );
5859
5960 public static final GameRuleType SATURATED_REGENERATION = GameRuleType .create ();
6061
6162 public static final GameRuleType FALL_DAMAGE = GameRuleType .create ()
6263 .enforces (PlayerDamageEvent .EVENT , result -> (player , source , amount ) -> {
6364 if (source .isIn (DamageTypeTags .IS_FALL )) {
64- return result ;
65+ return result . asActionResult () ;
6566 } else {
66- return EventResult .PASS ;
67+ return EventResult .PASS . asActionResult () ;
6768 }
6869 });
6970
7071 public static final GameRuleType USE_BLOCKS = GameRuleType .create ()
7172 .enforces (BlockUseEvent .EVENT , result -> (player , hand , hitResult ) -> result .asActionResult ());
7273 public static final GameRuleType USE_ITEMS = GameRuleType .create ()
73- .enforces (ItemUseEvent .EVENT , result -> (player , hand ) -> result .asActionResult ( ));
74+ .enforces (ItemUseEvent .EVENT , result -> (player , hand ) -> result .asTypedActionResult ( player . getStackInHand ( hand ) ));
7475 public static final GameRuleType USE_ENTITIES = GameRuleType .create ()
75- .enforces (EntityUseEvent .EVENT , result -> (player , entity , hand , hitResult ) -> result );
76+ .enforces (EntityUseEvent .EVENT , result -> (player , entity , hand , hitResult ) -> result . asActionResult () );
7677
7778 public static final GameRuleType INTERACTION = GameRuleType .allOf (USE_BLOCKS , USE_ITEMS , USE_ENTITIES );
7879
7980 public static final GameRuleType BLOCK_DROPS = GameRuleType .create ()
8081 .enforces (BlockDropItemsEvent .EVENT , result -> (entity , world , pos , state , drops ) -> {
8182 return switch (result ) {
82- case PASS -> DroppedItemsResult .pass (drops );
83- case ALLOW -> DroppedItemsResult .allow (drops );
84- case DENY -> DroppedItemsResult .deny ();
83+ case PASS , ALLOW -> result .asTypedActionResult (drops );
84+ case DENY -> result .asTypedActionResult (List .of ());
8585 };
8686 });
8787
8888 public static final GameRuleType THROW_ITEMS = GameRuleType .create ()
89- .enforces (ItemThrowEvent .EVENT , result -> (player , slot , stack ) -> result );
89+ .enforces (ItemThrowEvent .EVENT , result -> (player , slot , stack ) -> result . asActionResult () );
9090 public static final GameRuleType PICKUP_ITEMS = GameRuleType .create ()
91- .enforces (ItemPickupEvent .EVENT , result -> (player , slot , stack ) -> result );
91+ .enforces (ItemPickupEvent .EVENT , result -> (player , slot , stack ) -> result . asActionResult () );
9292
9393 public static final GameRuleType DISPENSER_ACTIVATE = GameRuleType .create ()
94- .enforces (DispenserActivateEvent .EVENT , result -> (world , pos , dispenser , slot , stack ) -> result );
94+ .enforces (DispenserActivateEvent .EVENT , result -> (world , pos , dispenser , slot , stack ) -> result . asActionResult () );
9595
9696 public static final GameRuleType UNSTABLE_TNT = GameRuleType .create ()
9797 .enforces (BlockPlaceEvent .AFTER , result -> (player , world , pos , state ) -> {
@@ -102,13 +102,13 @@ public final class GameRuleType {
102102 });
103103
104104 public static final GameRuleType FIRE_TICK = GameRuleType .create ()
105- .enforces (FireTickEvent .EVENT , result -> (world , pos ) -> result );
105+ .enforces (FireTickEvent .EVENT , result -> (world , pos ) -> result . asActionResult () );
106106 public static final GameRuleType FLUID_FLOW = GameRuleType .create ()
107- .enforces (FluidFlowEvent .EVENT , result -> (world , fluidPos , fluidBlock , flowDirection , flowTo , flowToBlock ) -> result );
107+ .enforces (FluidFlowEvent .EVENT , result -> (world , fluidPos , fluidBlock , flowDirection , flowTo , flowToBlock ) -> result . asActionResult () );
108108 public static final GameRuleType ICE_MELT = GameRuleType .create ()
109- .enforces (IceMeltEvent .EVENT , result -> (world , pos ) -> result );
109+ .enforces (IceMeltEvent .EVENT , result -> (world , pos ) -> result . asActionResult () );
110110 public static final GameRuleType CORAL_DEATH = GameRuleType .create ()
111- .enforces (CoralDeathEvent .EVENT , result -> (world , pos , from , to ) -> result );
111+ .enforces (CoralDeathEvent .EVENT , result -> (world , pos , from , to ) -> result . asActionResult () );
112112
113113 public static final GameRuleType DISMOUNT_VEHICLE = GameRuleType .create ();
114114 public static final GameRuleType STOP_SPECTATING_ENTITY = GameRuleType .create ();
@@ -117,7 +117,7 @@ public final class GameRuleType {
117117 public static final GameRuleType SPREAD_CONTAINER_LOOT = GameRuleType .create ();
118118 public static final GameRuleType MODIFY_INVENTORY = GameRuleType .create ();
119119 public static final GameRuleType MODIFY_ARMOR = GameRuleType .create ();
120- public static final GameRuleType SWAP_OFFHAND = GameRuleType .create ().enforces (PlayerSwapWithOffhandEvent .EVENT , result -> (player ) -> result );
120+ public static final GameRuleType SWAP_OFFHAND = GameRuleType .create ().enforces (PlayerSwapWithOffhandEvent .EVENT , result -> (player ) -> result . asActionResult () );
121121
122122 private GameRuleEnforcer enforcer ;
123123 private Priority priority = Priority .NORMAL ;
0 commit comments