66import net .minecraft .core .*;
77import net .minecraft .core .registries .Registries ;
88import net .minecraft .network .chat .Component ;
9+ import net .minecraft .network .chat .Style ;
910import net .minecraft .resources .Identifier ;
1011import net .minecraft .resources .ResourceKey ;
1112import net .minecraft .world .level .block .Block ;
1213import net .minecraft .world .level .block .Blocks ;
1314import net .minecraft .world .level .block .NoteBlock ;
1415import net .minecraft .world .level .block .SoundType ;
1516import net .minecraft .world .level .block .state .BlockBehaviour ;
17+ import net .minecraft .world .level .block .state .BlockState ;
1618import net .minecraft .world .level .block .state .properties .NoteBlockInstrument ;
1719import net .minecraft .world .level .material .MapColor ;
1820import org .bukkit .plugin .java .JavaPlugin ;
1921import parallelmc .parallelworlds .blocks .QuicksandBlock ;
2022import parallelmc .parallelworlds .blocks .TestBlock ;
2123import parallelmc .parallelworlds .registry .ParallelBlockRegistry ;
2224
25+ import java .util .function .Function ;
26+
2327
2428public class ParallelWorldsBootstrapper implements PluginBootstrap {
2529
@@ -28,11 +32,17 @@ public void bootstrap(BootstrapContext context) {
2832
2933 ParallelBlockRegistry registry = ParallelBlockRegistry .getInstance ();
3034
31- ResourceKey <Block > quicksandKey = ResourceKey .create (Registries .BLOCK , Identifier .fromNamespaceAndPath ("parallelutils" , "quicksand" ));
32- Block quicksandBlock = new QuicksandBlock (BlockBehaviour .Properties .of ().mapColor (MapColor .SAND ).strength (0.25F ).sound (SoundType .SAND )
33- .dynamicShape ().noOcclusion ().isRedstoneConductor ((blockState , blockGetter , blockPos ) -> false ).setId (quicksandKey ));
34- registry .registerBlock (quicksandKey , quicksandBlock ,
35- Blocks .NOTE_BLOCK .getStateDefinition ().any ().setValue (NoteBlock .INSTRUMENT , NoteBlockInstrument .BANJO ).setValue (NoteBlock .NOTE , 1 ), Component .literal ("Quicksand" ));
35+ if (registry == null ) throw new RuntimeException ("ParallelBlockRegistry is null!" );
36+
37+ register (registry , "polished_sandstone" , Block ::new ,
38+ BlockBehaviour .Properties .of ().mapColor (MapColor .SAND ).requiresCorrectToolForDrops ().strength (0.8F ).sound (SoundType .STONE ),
39+ Blocks .NOTE_BLOCK .getStateDefinition ().any ().setValue (NoteBlock .INSTRUMENT , NoteBlockInstrument .BANJO ).setValue (NoteBlock .NOTE , 0 ),
40+ Component .literal ("Polished Sandstone" ).setStyle (Style .EMPTY ));
41+
42+ register (registry , "quicksand" , QuicksandBlock ::new ,
43+ BlockBehaviour .Properties .of ().mapColor (MapColor .SAND ).strength (0.25F ).sound (SoundType .SAND ).dynamicShape ().noOcclusion ().isRedstoneConductor ((blockState , blockGetter , blockPos ) -> false ),
44+ Blocks .NOTE_BLOCK .getStateDefinition ().any ().setValue (NoteBlock .INSTRUMENT , NoteBlockInstrument .BANJO ).setValue (NoteBlock .NOTE , 1 ),
45+ Component .literal ("Quicksand" ).setStyle (Style .EMPTY ));
3646
3747 registry .freeze ();
3848 }
@@ -42,6 +52,11 @@ public JavaPlugin createPlugin(PluginProviderContext context) {
4252 return PluginBootstrap .super .createPlugin (context );
4353 }
4454
55+ private static void register (ParallelBlockRegistry registry , String name , Function <BlockBehaviour .Properties , Block > factory , BlockBehaviour .Properties properties , BlockState targetBlockstate , Component itemName ) {
56+ ResourceKey <Block > blockKey = ResourceKey .create (Registries .BLOCK , Identifier .fromNamespaceAndPath ("parallelutils" , name ));
57+ Block block = factory .apply (properties .setId (blockKey ));
58+ registry .registerBlock (blockKey , block , targetBlockstate , itemName );
59+ }
4560
4661
4762}
0 commit comments