Skip to content

Commit c25df94

Browse files
Remove grows under and replace with transparent
- Let grass grow under everything that is transparent
1 parent 34d03c4 commit c25df94

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ compileJava {
1212
}
1313

1414
dependencies {
15-
compile group: 'org.konstructs', name: 'konstructs-server-api', version: '0.1.6'
15+
compile group: 'org.konstructs', name: 'konstructs-server-api', version: '0.1.20'
1616
}

src/main/java/org/konstructs/grass/GrassActor.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import konstructs.api.messages.BlockUpdateEvent;
88
import konstructs.api.messages.BoxQueryResult;
99
import konstructs.api.messages.GlobalConfig;
10+
import konstructs.api.messages.GetBlockFactory;
1011
import konstructs.plugin.Config;
1112
import konstructs.plugin.KonstructsActor;
1213
import 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
}

src/main/resources/reference.conf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ konstructs {
1515
org/konstructs/grass/dirt = org/konstructs/dirt
1616
}
1717

18-
grows-under {
19-
org/konstructs/grass/vacuum = org/konstructs/vacuum
20-
}
21-
2218
// Valid grass types
2319
types {
2420
org/konstructs/grass/default {

0 commit comments

Comments
 (0)