22
33import com .gregtechceu .gtceu .GTCEu ;
44import com .gregtechceu .gtceu .api .GTValues ;
5- import com .gregtechceu .gtceu .api .blockentity .MetaMachineBlockEntity ;
65import com .gregtechceu .gtceu .api .capability .recipe .IO ;
6+ import com .gregtechceu .gtceu .api .data .tag .TagPrefix ;
7+ import com .gregtechceu .gtceu .common .block .ItemPipeBlock ;
8+ import com .gregtechceu .gtceu .common .blockentity .ItemPipeBlockEntity ;
9+ import com .gregtechceu .gtceu .common .cover .data .DistributionMode ;
710import com .gregtechceu .gtceu .common .data .GTItems ;
811import com .gregtechceu .gtceu .common .data .GTMachines ;
12+ import com .gregtechceu .gtceu .common .data .GTMaterialBlocks ;
13+ import com .gregtechceu .gtceu .common .data .GTMaterials ;
914import com .gregtechceu .gtceu .common .machine .storage .BufferMachine ;
1015import com .gregtechceu .gtceu .gametest .util .TestUtils ;
1116
2227@ GameTestHolder (GTCEu .MOD_ID )
2328public class ConveyorCoverTest {
2429
25- public static void setupCrates (GameTestHelper helper ) {
26- helper .setBlock (new BlockPos (0 , 1 , 0 ), GTMachines .BUFFER [GTValues .LV ].getBlock ());
27- helper .setBlock (new BlockPos (0 , 2 , 0 ), GTMachines .BUFFER [GTValues .LV ].getBlock ());
30+ private static BufferMachine placeCrate (GameTestHelper helper , BlockPos pos ) {
31+ return (BufferMachine ) TestUtils .setMachine (helper , pos , GTMachines .BUFFER [GTValues .LV ]);
2832 }
2933
3034 // Test for seeing if conveyors pass items
3135 @ GameTest (template = "empty_5x5" , batch = "coverTests" )
3236 public static void conveyorTransfersItemsTest (GameTestHelper helper ) {
33- setupCrates (helper );
34- BufferMachine crate1 = (BufferMachine ) ((MetaMachineBlockEntity ) helper .getBlockEntity (new BlockPos (0 , 1 , 0 )))
35- .getMetaMachine ();
36- BufferMachine crate2 = (BufferMachine ) ((MetaMachineBlockEntity ) helper .getBlockEntity (new BlockPos (0 , 2 , 0 )))
37- .getMetaMachine ();
37+ BufferMachine crate1 = placeCrate (helper , new BlockPos (0 , 1 , 0 ));
38+ BufferMachine crate2 = placeCrate (helper , new BlockPos (0 , 2 , 0 ));
3839 crate1 .getInventory ().setStackInSlot (0 , new ItemStack (Items .FLINT , 16 ));
3940 // LV Cover
4041 ConveyorCover cover = (ConveyorCover ) TestUtils .placeCover (helper , crate2 , GTItems .CONVEYOR_MODULE_LV .asStack (),
@@ -52,11 +53,8 @@ public static void conveyorTransfersItemsTest(GameTestHelper helper) {
5253 // Test for seeing if conveyors don't pass items if set to the wrong direction
5354 @ GameTest (template = "empty_5x5" , batch = "coverTests" )
5455 public static void conveyorTransfersItemsWrongDirectionTest (GameTestHelper helper ) {
55- setupCrates (helper );
56- BufferMachine crate1 = (BufferMachine ) ((MetaMachineBlockEntity ) helper .getBlockEntity (new BlockPos (0 , 1 , 0 )))
57- .getMetaMachine ();
58- BufferMachine crate2 = (BufferMachine ) ((MetaMachineBlockEntity ) helper .getBlockEntity (new BlockPos (0 , 2 , 0 )))
59- .getMetaMachine ();
56+ BufferMachine crate1 = placeCrate (helper , new BlockPos (0 , 1 , 0 ));
57+ BufferMachine crate2 = placeCrate (helper , new BlockPos (0 , 2 , 0 ));
6058 crate1 .getInventory ().setStackInSlot (0 , new ItemStack (Items .FLINT , 16 ));
6159 // LV Cover
6260 ConveyorCover cover = (ConveyorCover ) TestUtils .placeCover (helper , crate2 , GTItems .CONVEYOR_MODULE_LV .asStack (),
@@ -76,11 +74,8 @@ public static void conveyorTransfersItemsWrongDirectionTest(GameTestHelper helpe
7674 // Test for seeing if pumps transfer items
7775 @ GameTest (template = "empty_5x5" , batch = "coverTests" )
7876 public static void conveyorPumpDoesntTransferItemsTest (GameTestHelper helper ) {
79- setupCrates (helper );
80- BufferMachine crate1 = (BufferMachine ) ((MetaMachineBlockEntity ) helper .getBlockEntity (new BlockPos (0 , 1 , 0 )))
81- .getMetaMachine ();
82- BufferMachine crate2 = (BufferMachine ) ((MetaMachineBlockEntity ) helper .getBlockEntity (new BlockPos (0 , 2 , 0 )))
83- .getMetaMachine ();
77+ BufferMachine crate1 = placeCrate (helper , new BlockPos (0 , 1 , 0 ));
78+ BufferMachine crate2 = placeCrate (helper , new BlockPos (0 , 2 , 0 ));
8479 crate1 .getInventory ().setStackInSlot (0 , new ItemStack (Items .FLINT , 16 ));
8580 // LV Cover
8681 PumpCover cover = (PumpCover ) TestUtils .placeCover (helper , crate2 , GTItems .ELECTRIC_PUMP_LV .asStack (),
@@ -95,4 +90,38 @@ public static void conveyorPumpDoesntTransferItemsTest(GameTestHelper helper) {
9590 });
9691 TestUtils .succeedAfterTest (helper );
9792 }
93+
94+ // Test for conveyor round-robin mode
95+ @ GameTest (template = "empty_5x5" , batch = "coverTests" )
96+ public static void conveyorRoundRobinTest (GameTestHelper helper ) {
97+ BufferMachine inputCrate = placeCrate (helper , new BlockPos (0 , 1 , 0 ));
98+ BufferMachine outCrate1 = placeCrate (helper , new BlockPos (0 , 2 , 0 ));
99+ BufferMachine outCrate2 = placeCrate (helper , new BlockPos (0 , 3 , 0 ));
100+ inputCrate .getInventory ().setStackInSlot (0 , new ItemStack (Items .FLINT , 32 ));
101+
102+ // Item pipes connecting crates
103+ ItemPipeBlock itemPipeBlock = GTMaterialBlocks .ITEM_PIPE_BLOCKS
104+ .get (TagPrefix .pipeNormalItem , GTMaterials .Tin ).get ();
105+ for (int y = 1 ; y <= 3 ; y ++) {
106+ BlockPos pos = new BlockPos (1 , y , 0 );
107+ helper .setBlock (pos , itemPipeBlock );
108+ ItemPipeBlockEntity pipeBlockEntity = (ItemPipeBlockEntity ) helper .getBlockEntity (pos );
109+ pipeBlockEntity .setConnection (Direction .WEST , true , false );
110+ pipeBlockEntity .setConnection (Direction .UP , true , false );
111+ pipeBlockEntity .setConnection (Direction .DOWN , true , false );
112+ }
113+ // LV Cover
114+ ConveyorCover cover = (ConveyorCover ) TestUtils .placeCover (helper , inputCrate ,
115+ GTItems .CONVEYOR_MODULE_LV .asStack (), Direction .EAST );
116+ // Set cover to push from crate into item pipes, round-robin mode
117+ cover .setIo (IO .OUT );
118+ cover .setDistributionMode (DistributionMode .ROUND_ROBIN_GLOBAL );
119+
120+ helper .succeedWhen (() -> helper .assertTrue (
121+ TestUtils .isItemStackEqual (outCrate1 .getInventory ().getStackInSlot (0 ),
122+ new ItemStack (Items .FLINT , 16 )) &&
123+ TestUtils .isItemStackEqual (outCrate2 .getInventory ().getStackInSlot (0 ),
124+ new ItemStack (Items .FLINT , 16 )),
125+ "Conveyor didn't split items equally" ));
126+ }
98127}
0 commit comments