55import mekanism .api .functions .ConstantPredicates ;
66import mekanism .common .Mekanism ;
77import mekanism .common .content .network .transmitter .Transmitter ;
8+ import mekanism .common .lib .transmitter .ConnectionType ;
89import mekanism .common .lib .transmitter .DynamicNetwork ;
910import mekanism .common .registries .MekanismBlocks ;
1011import mekanism .common .tests .MekanismTests ;
1112import mekanism .common .tests .helpers .MekGameTestHelper ;
13+ import mekanism .common .tests .helpers .TransmitterTestHelper ;
14+ import mekanism .common .tile .transmitter .TileEntityLogisticalTransporter ;
1215import mekanism .common .tile .transmitter .TileEntityTransmitter ;
16+ import mekanism .common .util .EnumUtils ;
17+ import net .minecraft .SharedConstants ;
18+ import net .minecraft .core .Direction ;
19+ import net .minecraft .core .Direction .AxisDirection ;
1320import net .minecraft .gametest .framework .GameTest ;
1421import net .minecraft .server .level .ChunkHolder ;
1522import net .minecraft .server .level .ChunkLevel ;
@@ -36,6 +43,35 @@ public class TransmitterNetworkTest {
3643 builder -> builder .fill (0 , 0 , 0 , 3 * 16 - 1 , 0 , 0 , MekanismBlocks .BASIC_UNIVERSAL_CABLE .getBlock ())
3744 );
3845
46+ @ GameTest (setupTicks = SharedConstants .TICKS_PER_SECOND )
47+ @ TestHolder (description = "Tests the GameTest helpers that use a configurator on a position, to ensure it properly interacts with each side." )
48+ public static void testConfiguratorSideTargeting (final DynamicTest test ) {
49+ test .registerGameTestTemplate (() -> StructureTemplateBuilder .withSize (3 , 3 , 3 )
50+ .fill (1 , 0 , 1 , 1 , 2 , 1 , MekanismBlocks .BASIC_LOGISTICAL_TRANSPORTER .defaultState ())
51+ .fill (1 , 1 , 0 , 1 , 1 , 2 , MekanismBlocks .BASIC_LOGISTICAL_TRANSPORTER .defaultState ())
52+ .fill (0 , 1 , 1 , 2 , 1 , 1 , MekanismBlocks .BASIC_LOGISTICAL_TRANSPORTER .defaultState ())
53+ );
54+
55+ //Note: We make negative axis directions get changed twice so that we have a better estimate of if we properly clicked on the correct side of the block
56+ test .onGameTest (TransmitterTestHelper .class , helper -> helper .startSequence ()
57+ .thenExecute (() -> {
58+ //Use the configurator on all sides
59+ for (Direction direction : EnumUtils .DIRECTIONS ) {
60+ helper .useConfigurator (1 , 2 , 1 , direction , direction .getAxisDirection () == AxisDirection .POSITIVE ? 1 : 2 );
61+ }
62+ })
63+ .thenMap (() -> helper .requireBlockEntity (1 , 2 , 1 , TileEntityLogisticalTransporter .class ).getTransmitter ())
64+ .thenExecute (transporter -> {
65+ //Validate all sides got properly changed
66+ for (Direction direction : EnumUtils .DIRECTIONS ) {
67+ ConnectionType expected = direction .getAxisDirection () == AxisDirection .POSITIVE ? ConnectionType .PUSH : ConnectionType .PULL ;
68+ helper .assertValueEqual (transporter .getConnectionTypeRaw (direction ), expected , "Connection Type " + direction .getName ());
69+ }
70+ })
71+ .thenSucceed ()
72+ );
73+ }
74+
3975 @ GameTest (template = STRAIGHT_CABLE , batch = "1" )
4076 @ TestHolder (description = "Tests that reloading intermediary chunks does not cause a network to break." )
4177 public static void reloadIntermediary (final DynamicTest test ) {
0 commit comments