7
7
import konstructs .api .messages .BlockUpdateEvent ;
8
8
import konstructs .api .messages .BoxQueryResult ;
9
9
import konstructs .api .messages .GlobalConfig ;
10
+ import konstructs .api .messages .GetBlockFactory ;
10
11
import konstructs .plugin .Config ;
11
12
import konstructs .plugin .KonstructsActor ;
12
13
import konstructs .plugin .PluginConstructor ;
@@ -24,11 +25,10 @@ class ProcessDirtBlock {}
24
25
private ArrayList <QueuedGrassBlock > dirtBlocksToGrow ;
25
26
private ArrayList <BlockTypeId > validGrassBlocks ;
26
27
private ArrayList <BlockTypeId > growsOn ;
27
- private ArrayList <BlockTypeId > growsUnder ;
28
28
private int change_rate ;
29
29
private float default_tick_speed ;
30
30
private HashMap <BlockTypeId , BlockConfig > blockConfig ;
31
-
31
+ private BlockFactory factory = null ;
32
32
private BlockFilter blockFilter ;
33
33
34
34
private float simulation_speed ;
@@ -41,15 +41,14 @@ class ProcessDirtBlock {}
41
41
public GrassActor (ActorRef universe ,
42
42
com .typesafe .config .Config config ,
43
43
com .typesafe .config .Config grow ,
44
- com .typesafe .config .Config under ,
45
44
int change_rate ,
46
45
int default_tick_speed ) {
47
46
super (universe );
47
+ universe .tell (GetBlockFactory .MESSAGE , getSelf ());
48
48
49
49
dirtBlocksToGrow = new ArrayList <>();
50
50
validGrassBlocks = new ArrayList <>();
51
51
growsOn = new ArrayList <>();
52
- growsUnder = new ArrayList <>();
53
52
blockConfig = new HashMap <>();
54
53
55
54
simulation_speed = 1 ;
@@ -77,10 +76,6 @@ public GrassActor(ActorRef universe,
77
76
growsOn .add (BlockTypeId .fromString ((String )e .getValue ().unwrapped ()));
78
77
}
79
78
80
- for (Map .Entry <String , ConfigValue > e : under .entrySet ()) {
81
- growsUnder .add (BlockTypeId .fromString ((String )e .getValue ().unwrapped ()));
82
- }
83
-
84
79
// Create a block filter used in growDirtBlock(..)
85
80
blockFilter = BlockFilterFactory .NOTHING ;
86
81
for (BlockTypeId bt : growsOn ) {
@@ -103,9 +98,11 @@ public void onReceive(Object message) {
103
98
if (message instanceof ProcessDirtBlock ) {
104
99
processDirtBlock ();
105
100
return ;
101
+ } else if (message instanceof BlockFactory ) {
102
+ factory = (BlockFactory )message ;
103
+ } else {
104
+ super .onReceive (message ); // Handle konstructs messages
106
105
}
107
-
108
- super .onReceive (message ); // Handle konstructs messages
109
106
}
110
107
111
108
/**
@@ -190,8 +187,8 @@ public void onBoxQueryResult(BoxQueryResult result) {
190
187
191
188
BlockTypeId typeId = result .getLocal (new Position (x , h , y ));
192
189
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 ;
195
192
196
193
// Found dirt, add to list and stop search
197
194
if (growsOn .contains (typeId )) {
@@ -291,12 +288,11 @@ public static Props props(String pluginName,
291
288
ActorRef universe ,
292
289
@ Config (key = "types" ) com .typesafe .config .Config types ,
293
290
@ Config (key = "grows-on" ) com .typesafe .config .Config grow ,
294
- @ Config (key = "grows-under" ) com .typesafe .config .Config under ,
295
291
@ Config (key = "change-rate" ) int change_rate ,
296
292
@ Config (key = "default-tick-speed" ) int default_tick_speed ){
297
293
298
294
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 ,
300
296
default_tick_speed );
301
297
}
302
298
}
0 commit comments