4
4
import net .fabricmc .fabric .api .client .screen .v1 .ScreenEvents ;
5
5
import net .fabricmc .fabric .api .client .screen .v1 .ScreenMouseEvents ;
6
6
import net .fabricmc .loader .api .FabricLoader ;
7
- import net .krlite .equator .util .Pusher ;
8
7
import net .minecraft .client .MinecraftClient ;
9
8
import net .minecraft .client .gui .screen .TitleScreen ;
10
9
import net .minecraft .client .sound .PositionedSoundInstance ;
11
- import net .minecraft .client .sound .SoundInstance ;
12
- import net .minecraft .sound .SoundEvent ;
13
10
import net .minecraft .sound .SoundEvents ;
14
11
import net .minecraft .text .MutableText ;
15
12
import net .minecraft .text .Text ;
19
16
20
17
import java .util .ArrayList ;
21
18
import java .util .Objects ;
19
+ import java .util .concurrent .atomic .AtomicBoolean ;
22
20
23
21
public class Splasher implements ModInitializer {
24
22
public static final String MOD_ID = "splasher" ;
25
23
public static final Logger LOGGER = LoggerFactory .getLogger (MOD_ID );
26
24
public static final SplasherConfig CONFIG = new SplasherConfig (FabricLoader .getInstance ().getConfigDir ().resolve (MOD_ID + ".toml" ).toFile ());
27
- public static final Pusher PUSHER = new Pusher (CONFIG .randomRate == SplasherConfig .RandomRate .JEB );
25
+ private static final AtomicBoolean shouldSplash = new AtomicBoolean (CONFIG .randomRate == SplasherConfig .RandomRate .JEB );
28
26
29
27
public record Node (double x , double y ) {
30
28
public double getCross (Node p1 , Node p2 ) {
@@ -57,6 +55,14 @@ public Rect rotate(Node origin, double clockwiseDegree) {
57
55
}
58
56
}
59
57
58
+ public static void push () {
59
+ shouldSplash .set (true );
60
+ }
61
+
62
+ public static boolean shouldSplash () {
63
+ return shouldSplash .getAndSet (false );
64
+ }
65
+
60
66
// Splash text data
61
67
private static final ArrayList <Formatting > FORMATTINGS = new ArrayList <>();
62
68
private static int color = 0xFFFF00 ;
@@ -71,8 +77,9 @@ public void onInitialize() {
71
77
if (screen instanceof TitleScreen ) {
72
78
ScreenMouseEvents .beforeMouseClick (screen )
73
79
.register ((currentScreen , mouseX , mouseY , button ) -> {
74
- if (isMouseOverSplashText (new Node (scaledWidth / 2.0 + 90 , 70 - 6 ), new Node (mouseX , mouseY )) && CONFIG .randomRate .onClick ()) {
75
- PUSHER .push (Splasher ::playClickingSound );
80
+ if (isMouseOverSplashText (new Node (scaledWidth / 2.0 + (CONFIG .lefty ? -90 : 90 ), 70 - 6 ), new Node (mouseX , mouseY )) && CONFIG .randomRate .onClick ()) {
81
+ push ();
82
+ playClickingSound ();
76
83
}
77
84
});
78
85
}
@@ -88,7 +95,7 @@ public static boolean isMouseOverSplashText(Node origin, Node mouse) {
88
95
return new Rect (
89
96
origin .append (new Node (-width / 2 , -height / 2 )),
90
97
origin .append (new Node (width / 2 , height / 2 ))
91
- ).rotate (origin , -20 ).contains (mouse );
98
+ ).rotate (origin , CONFIG . lefty ? 20 : -20 ).contains (mouse );
92
99
}
93
100
94
101
public static void updateSize (float width , float height ) {
0 commit comments