22
33import net .automotons .blocks .AutomotonBlock ;
44import net .automotons .blocks .AutomotonBlockEntity ;
5+ import net .automotons .blocks .PointerBlock ;
56import net .automotons .items .HeadItem ;
67import net .automotons .items .ModuleItem ;
78import net .automotons .items .RoboticsBookItem ;
1011import net .automotons .screens .AutomotonScreenHandler ;
1112import net .fabricmc .fabric .api .object .builder .v1 .block .FabricBlockSettings ;
1213import net .fabricmc .fabric .api .screenhandler .v1 .ScreenHandlerRegistry ;
14+ import net .fabricmc .fabric .api .tag .TagRegistry ;
1315import net .minecraft .block .Block ;
16+ import net .minecraft .block .BlockState ;
17+ import net .minecraft .block .HorizontalFacingBlock ;
1418import net .minecraft .block .Material ;
1519import net .minecraft .block .entity .BlockEntityType ;
1620import net .minecraft .item .BlockItem ;
1721import net .minecraft .item .Item ;
1822import net .minecraft .loot .entry .LootPoolEntryType ;
1923import net .minecraft .screen .ScreenHandlerType ;
24+ import net .minecraft .tag .Tag ;
2025import net .minecraft .util .Identifier ;
2126import net .minecraft .util .Pair ;
2227import net .minecraft .util .registry .Registry ;
@@ -32,9 +37,12 @@ public class AutomotonsRegistry{
3237
3338 // For BlockItems
3439 private static final List <Pair <Identifier , Block >> WITH_ITEMS = new ArrayList <>();
40+ // For scanning module
41+ private static final Tag <Block > SCANNABLE = TagRegistry .block (autoId ("automoton_scannable" ));
3542
3643 // Blocks
3744 public static Block AUTOMOTON = new AutomotonBlock (FabricBlockSettings .of (Material .METAL ).breakByHand (true ).strength (6f ).nonOpaque ().solidBlock ((state , world , pos ) -> false ));
45+ public static Block POINTER = new PointerBlock (FabricBlockSettings .of (Material .METAL ).breakByHand (true ).breakInstantly ());
3846
3947 // Item Settings
4048 private static final Item .Settings TABBED = new Item .Settings ().group (Automotons .ITEMS );
@@ -95,6 +103,12 @@ public class AutomotonsRegistry{
95103 public static Item MOVE_LEFT_MODULE = new ModuleItem (TABBED , AutomotonBlockEntity ::moveLeft );
96104 public static Item MOVE_RIGHT_MODULE = new ModuleItem (TABBED , AutomotonBlockEntity ::moveRight );
97105 public static Item MOVE_BACK_MODULE = new ModuleItem (TABBED , AutomotonBlockEntity ::moveBack );
106+ public static Item SCAN_MODULE = new ModuleItem (TABBED , entity -> {
107+ BlockState below = entity .getWorld ().getBlockState (entity .getPos ().down ());
108+ if (below .isIn (SCANNABLE ) && below .getProperties ().contains (HorizontalFacingBlock .FACING ))
109+ return entity .move (below .get (HorizontalFacingBlock .FACING ));
110+ return false ;
111+ });
98112
99113 // Block Entity Types
100114 public static BlockEntityType <AutomotonBlockEntity > AUTOMOTON_BE = BlockEntityType .Builder
@@ -111,6 +125,7 @@ public class AutomotonsRegistry{
111125 public static void registerObjects (){
112126 // Blocks
113127 WITH_ITEMS .add (new Pair <>(autoId ("automoton" ), AUTOMOTON ));
128+ WITH_ITEMS .add (new Pair <>(autoId ("pointer" ), POINTER ));
114129
115130 for (Pair <Identifier , Block > item : WITH_ITEMS ){
116131 register (Registry .BLOCK , item .getLeft (), item .getRight ());
@@ -146,6 +161,7 @@ public static void registerObjects(){
146161 register (Registry .ITEM , autoId ("move_left_module" ), MOVE_LEFT_MODULE );
147162 register (Registry .ITEM , autoId ("move_right_module" ), MOVE_RIGHT_MODULE );
148163 register (Registry .ITEM , autoId ("move_back_module" ), MOVE_BACK_MODULE );
164+ register (Registry .ITEM , autoId ("scan_module" ), SCAN_MODULE );
149165
150166 // Block Entity Types
151167 register (Registry .BLOCK_ENTITY_TYPE , autoId ("automoton" ), AUTOMOTON_BE );
0 commit comments