77import konstructs .api .messages .BlockUpdateEvent ;
88import konstructs .api .messages .BoxQueryResult ;
99import konstructs .api .messages .GlobalConfig ;
10+ import konstructs .api .messages .GetBlockFactory ;
1011import konstructs .plugin .Config ;
1112import konstructs .plugin .KonstructsActor ;
1213import konstructs .plugin .PluginConstructor ;
@@ -24,11 +25,10 @@ class ProcessDirtBlock {}
2425 private ArrayList <QueuedGrassBlock > dirtBlocksToGrow ;
2526 private ArrayList <BlockTypeId > validGrassBlocks ;
2627 private ArrayList <BlockTypeId > growsOn ;
27- private ArrayList <BlockTypeId > growsUnder ;
2828 private int change_rate ;
2929 private float default_tick_speed ;
3030 private HashMap <BlockTypeId , BlockConfig > blockConfig ;
31-
31+ private BlockFactory factory = null ;
3232 private BlockFilter blockFilter ;
3333
3434 private float simulation_speed ;
@@ -41,15 +41,14 @@ class ProcessDirtBlock {}
4141 public GrassActor (ActorRef universe ,
4242 com .typesafe .config .Config config ,
4343 com .typesafe .config .Config grow ,
44- com .typesafe .config .Config under ,
4544 int change_rate ,
4645 int default_tick_speed ) {
4746 super (universe );
47+ universe .tell (GetBlockFactory .MESSAGE , getSelf ());
4848
4949 dirtBlocksToGrow = new ArrayList <>();
5050 validGrassBlocks = new ArrayList <>();
5151 growsOn = new ArrayList <>();
52- growsUnder = new ArrayList <>();
5352 blockConfig = new HashMap <>();
5453
5554 simulation_speed = 1 ;
@@ -77,10 +76,6 @@ public GrassActor(ActorRef universe,
7776 growsOn .add (BlockTypeId .fromString ((String )e .getValue ().unwrapped ()));
7877 }
7978
80- for (Map .Entry <String , ConfigValue > e : under .entrySet ()) {
81- growsUnder .add (BlockTypeId .fromString ((String )e .getValue ().unwrapped ()));
82- }
83-
8479 // Create a block filter used in growDirtBlock(..)
8580 blockFilter = BlockFilterFactory .NOTHING ;
8681 for (BlockTypeId bt : growsOn ) {
@@ -103,9 +98,11 @@ public void onReceive(Object message) {
10398 if (message instanceof ProcessDirtBlock ) {
10499 processDirtBlock ();
105100 return ;
101+ } else if (message instanceof BlockFactory ) {
102+ factory = (BlockFactory )message ;
103+ } else {
104+ super .onReceive (message ); // Handle konstructs messages
106105 }
107-
108- super .onReceive (message ); // Handle konstructs messages
109106 }
110107
111108 /**
@@ -190,8 +187,8 @@ public void onBoxQueryResult(BoxQueryResult result) {
190187
191188 BlockTypeId typeId = result .getLocal (new Position (x , h , y ));
192189
193- // Found vacuum, continue
194- if (growsUnder . contains (typeId )) continue ;
190+ // Found transparent, skip and anything below is ok
191+ if (factory . getBlockType (typeId ). isTransparent ( )) continue ;
195192
196193 // Found dirt, add to list and stop search
197194 if (growsOn .contains (typeId )) {
@@ -291,12 +288,11 @@ public static Props props(String pluginName,
291288 ActorRef universe ,
292289 @ Config (key = "types" ) com .typesafe .config .Config types ,
293290 @ Config (key = "grows-on" ) com .typesafe .config .Config grow ,
294- @ Config (key = "grows-under" ) com .typesafe .config .Config under ,
295291 @ Config (key = "change-rate" ) int change_rate ,
296292 @ Config (key = "default-tick-speed" ) int default_tick_speed ){
297293
298294 Class currentClass = new Object () { }.getClass ().getEnclosingClass ();
299- return Props .create (currentClass , universe , types , grow , under , change_rate ,
295+ return Props .create (currentClass , universe , types , grow , change_rate ,
300296 default_tick_speed );
301297 }
302298}
0 commit comments