1
1
package org .gtreimagined .gt4r .reactor .tile ;
2
2
3
+ import lombok .Getter ;
3
4
import muramasa .antimatter .blockentity .BlockEntityFakeBlock ;
4
5
import muramasa .antimatter .blockentity .BlockEntityMachine ;
6
+ import muramasa .antimatter .machine .Tier ;
5
7
import muramasa .antimatter .machine .types .Machine ;
6
8
import muramasa .antimatter .tool .AntimatterToolType ;
7
9
import net .minecraft .core .BlockPos ;
8
10
import net .minecraft .core .Direction ;
11
+ import net .minecraft .nbt .CompoundTag ;
9
12
import net .minecraft .server .level .ServerPlayer ;
10
13
import net .minecraft .world .InteractionHand ;
11
14
import net .minecraft .world .InteractionResult ;
12
15
import net .minecraft .world .entity .player .Player ;
13
16
import net .minecraft .world .level .Level ;
17
+ import net .minecraft .world .level .block .entity .BlockEntity ;
14
18
import net .minecraft .world .level .block .state .BlockState ;
15
19
import net .minecraft .world .phys .BlockHitResult ;
16
20
import net .minecraftforge .common .capabilities .Capability ;
17
21
import net .minecraftforge .common .util .LazyOptional ;
18
22
import net .minecraftforge .network .NetworkHooks ;
23
+ import org .gtreimagined .gt4r .data .Machines ;
19
24
import org .jetbrains .annotations .NotNull ;
20
25
import org .jetbrains .annotations .Nullable ;
21
26
22
27
public class BlockEntityReactorChamber extends BlockEntityMachine <BlockEntityReactorChamber > {
23
- BlockEntityReactorCore reactor ;
28
+ @ Getter
29
+ private BlockEntityReactorCore reactor ;
30
+ private Direction reactorSide ;
24
31
25
32
public BlockEntityReactorChamber (Machine <?> type , BlockPos pos , BlockState state ) {
26
33
super (type , pos , state );
27
34
}
28
35
36
+ @ Override
37
+ public void onFirstTickServer (Level level , BlockPos pos , BlockState state ) {
38
+ super .onFirstTickServer (level , pos , state );
39
+ if (reactor == null ) {
40
+ for (var d : Direction .values ()) {
41
+ BlockEntity be = level .getBlockEntity (pos .relative (d ));
42
+ if (be instanceof BlockEntityReactorCore core ){
43
+ setReactor (core );
44
+ reactorSide = d ;
45
+ break ;
46
+ }
47
+ }
48
+ }
49
+ }
50
+
51
+ @ Override
52
+ public void onFirstTickClient (Level level , BlockPos pos , BlockState state ) {
53
+ super .onFirstTickClient (level , pos , state );
54
+ if (reactor == null ) {
55
+ for (var d : Direction .values ()) {
56
+ BlockEntity be = level .getBlockEntity (pos .relative (d ));
57
+ if (be instanceof BlockEntityReactorCore core ){
58
+ reactor = core ;
59
+ reactorSide = d ;
60
+ break ;
61
+ }
62
+ }
63
+ }
64
+ }
65
+
29
66
@ Override
30
67
public @ NotNull <U > LazyOptional <U > getCapability (@ NotNull Capability <U > cap , @ Nullable Direction side ) {
31
68
if (reactor != null ) {
@@ -49,5 +86,8 @@ public InteractionResult onInteractServer(BlockState state, Level world, BlockPo
49
86
50
87
public void setReactor (BlockEntityReactorCore reactor ) {
51
88
this .reactor = reactor ;
89
+ if (this .level != null && isServerSide ()) {
90
+ sidedSync (true );
91
+ }
52
92
}
53
93
}
0 commit comments