11package  com .faboslav .friendsandfoes .common .mixin ;
22
3- import  com .faboslav .friendsandfoes .common .FriendsAndFoes ;
4- import  com .llamalad7 .mixinextras .injector .wrapmethod .WrapMethod ;
5- import  com .llamalad7 .mixinextras .injector .wrapoperation .Operation ;
6- import  org .spongepowered .asm .mixin .Mixin ;
73import  net .minecraft .world .entity .LightningBolt ;
4+ import  org .spongepowered .asm .mixin .Mixin ;
85
96//? if <=1.21.8 { 
10- import  com .faboslav .friendsandfoes .common .block .FriendsAndFoesOxidizable ;
11- import  com .faboslav .friendsandfoes .common .tag .FriendsAndFoesTags ;
127import  org .spongepowered .asm .mixin .Shadow ;
13- 
148import  net .minecraft .world .entity .Entity ;
159import  java .util .Optional ;
1610import  net .minecraft .core .BlockPos ;
1913import  net .minecraft .world .level .block .LightningRodBlock ;
2014import  net .minecraft .world .level .block .state .BlockState ;
2115import  org .spongepowered .asm .mixin .Unique ;
16+ import  com .llamalad7 .mixinextras .injector .wrapmethod .WrapMethod ;
17+ import  com .llamalad7 .mixinextras .injector .wrapoperation .Operation ;
18+ import  net .minecraft .world .level .block .Block ;
19+ import  net .minecraft .world .level .block .WeatheringCopper ;
20+ import  com .faboslav .friendsandfoes .common .block .FriendsAndFoesOxidizable ;
21+ import  com .faboslav .friendsandfoes .common .tag .FriendsAndFoesTags ;
2222
2323@ Mixin (LightningBolt .class )
2424public  abstract  class  LightningEntityMixin  extends  Entity 
@@ -40,9 +40,10 @@ public LightningEntityMixin(EntityType<?> type, Level world) {
4040
4141		BlockPos  blockPos  = this .getStrikePosition ();
4242		BlockState  blockState  = this .level ().getBlockState (blockPos );
43+ 		Block  block  = blockState .getBlock ();
4344
4445		if  (blockState .is (FriendsAndFoesTags .LIGHTNING_RODS )) {
45- 			((LightningRodBlock )  this . level (). getBlockState ( blockPos ). getBlock () ).onLightningStrike (blockState , this .level (), blockPos );
46+ 			((LightningRodBlock )block ).onLightningStrike (blockState , this .level (), blockPos );
4647		}
4748	}
4849
@@ -54,12 +55,16 @@ public LightningEntityMixin(EntityType<?> type, Level world) {
5455		BlockPos  blockPos ,
5556		Operation <Void > original 
5657	) {
58+ 		original .call (level , blockPos );
59+ 
5760		BlockState  blockState  = level .getBlockState (blockPos );
61+ 		Block  block  = blockState .getBlock ();
5862
59- 		if  (blockState .is (FriendsAndFoesTags .LIGHTNING_RODS )) {
60- 			FriendsAndFoes .getLogger ().info ("should deoxidize to "  + FriendsAndFoesOxidizable .getFirst (blockState ));
63+ 		if  (blockState .is (FriendsAndFoesTags .LIGHTNING_RODS ) || blockState .is (FriendsAndFoesTags .COPPER_BUTTONS )) {
6164			level .setBlockAndUpdate (blockPos , FriendsAndFoesOxidizable .getFirst (level .getBlockState (blockPos )));
65+ 		}
6266
67+ 		if ((block  instanceof  WeatheringCopper  && !blockState .is (FriendsAndFoesTags .LIGHTNING_RODS )) || blockState .is (FriendsAndFoesTags .COPPER_BUTTONS )) {
6368			BlockPos .MutableBlockPos  mutableBlockPos  = blockPos .mutable ();
6469			int  i  = level .random .nextInt (3 ) + 3 ;
6570
@@ -90,11 +95,19 @@ public LightningEntityMixin(EntityType<?> type, Level world) {
9095	private  static  Optional <BlockPos > friendsandfoes$randomStepCleaningCopper (Level  level , BlockPos  pos ) {
9196		for (BlockPos  blockPos  : BlockPos .randomInCube (level .random , 10 , pos , 1 )) {
9297			BlockState  blockState  = level .getBlockState (blockPos );
93- 			if  (blockState .getBlock () instanceof  FriendsAndFoesOxidizable ) {
98+ 			Block  block  = blockState .getBlock ();
99+ 
100+ 			if  (blockState .is (FriendsAndFoesTags .LIGHTNING_RODS ) || blockState .is (FriendsAndFoesTags .COPPER_BUTTONS )) {
94101				FriendsAndFoesOxidizable .getPrevious (blockState ).ifPresent ((blockStatex ) -> level .setBlockAndUpdate (blockPos , blockStatex ));
95102				level .levelEvent (3002 , blockPos , -1 );
96103				return  Optional .of (blockPos );
97104			}
105+ 
106+ 			if  (block  instanceof  WeatheringCopper ) {
107+ 				WeatheringCopper .getPrevious (blockState ).ifPresent ((blockStatex ) -> level .setBlockAndUpdate (blockPos , blockStatex ));
108+ 				level .levelEvent (3002 , blockPos , -1 );
109+ 				return  Optional .of (blockPos );
110+ 			}
98111		}
99112
100113		return  Optional .empty ();
0 commit comments