1
1
package net .blay09 .mods .waystones .client ;
2
2
3
+ import net .blay09 .mods .balm .api .Balm ;
3
4
import net .blay09 .mods .balm .api .client .BalmClient ;
5
+ import net .blay09 .mods .balm .api .event .client .UseItemInputEvent ;
4
6
import net .blay09 .mods .waystones .InternalClientMethodsImpl ;
5
7
import net .blay09 .mods .waystones .api .client .WaystonesClientAPI ;
8
+ import net .blay09 .mods .waystones .block .entity .WaystoneBlockEntityBase ;
6
9
import net .blay09 .mods .waystones .client .requirement .RequirementClientRegistry ;
7
10
import net .blay09 .mods .waystones .compat .Compat ;
11
+ import net .blay09 .mods .waystones .network .message .RequestEditWaystoneMessage ;
8
12
import net .minecraft .client .ClientBrandRetriever ;
13
+ import net .minecraft .client .Minecraft ;
14
+ import net .minecraft .world .phys .BlockHitResult ;
15
+ import net .minecraft .world .phys .HitResult ;
9
16
10
17
import java .util .Locale ;
11
18
@@ -22,5 +29,22 @@ public static void initialize() {
22
29
InventoryButtonGuiHandler .initialize ();
23
30
24
31
Compat .isVivecraftInstalled = ClientBrandRetriever .getClientModName ().toLowerCase (Locale .ENGLISH ).contains (Compat .VIVECRAFT );
32
+
33
+ Balm .getEvents ().onEvent (UseItemInputEvent .class , event -> {
34
+ final var mc = Minecraft .getInstance ();
35
+ if (mc .level == null || mc .player == null || mc .hitResult == null || mc .hitResult .getType () != HitResult .Type .BLOCK ) {
36
+ return ;
37
+ }
38
+
39
+ if (mc .player .isShiftKeyDown ()) {
40
+ final var blockHitResult = (BlockHitResult ) mc .hitResult ;
41
+ final var targetBlockEntity = mc .level .getBlockEntity (blockHitResult .getBlockPos ());
42
+ if (targetBlockEntity instanceof WaystoneBlockEntityBase waystoneBlockEntity ) {
43
+ Balm .getNetworking ().sendToServer (new RequestEditWaystoneMessage (waystoneBlockEntity .getBlockPos ()));
44
+ mc .player .swing (event .getHand ());
45
+ event .setCanceled (true );
46
+ }
47
+ }
48
+ });
25
49
}
26
50
}
0 commit comments