Skip to content

Commit 8ba8856

Browse files
committed
optimize sensors
1 parent 579665e commit 8ba8856

File tree

5 files changed

+20
-2
lines changed

5 files changed

+20
-2
lines changed

Diff for: src/main/kotlin/dev/sterner/common/entity/SoulSteelGolemEntity.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ open class SoulSteelGolemEntity(level: Level) :
166166
NearbyLivingEntitySensor<SoulSteelGolemEntity>().setRadius(24.0, 16.0),
167167

168168
//Golem Harvester
169-
GolemHarvestSensor(),
169+
GolemHarvestSensor().setPredicate { _, u -> u.getGolemCore() == GolemCore.HARVEST },
170170
//Golem Gatherer
171-
GolemGatherSensor(),
171+
GolemGatherSensor().setPredicate { _, u -> u.getGolemCore() == GolemCore.GATHER },
172172
//Golem Guard
173173
NearbyHostileSensor<SoulSteelGolemEntity>().setPredicate { _, u -> u.getGolemCore() == GolemCore.GUARD },
174174
HurtBySensor<SoulSteelGolemEntity>().setPredicate { _, u -> u.getGolemCore() == GolemCore.GUARD },

Diff for: src/main/kotlin/dev/sterner/common/entity/ai/sensor/GolemGatherSensor.kt

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ class GolemGatherSensor : PredicateSensor<ItemEntity, SoulSteelGolemEntity>(
3737
}
3838

3939
override fun doTick(level: ServerLevel, entity: SoulSteelGolemEntity) {
40+
if (entity.getGolemCore() != GolemCore.GATHER) {
41+
return // Exit early if the predicate is false
42+
}
43+
4044
BrainUtils.setMemory(
4145
entity,
4246
VoidBoundMemoryTypeRegistry.NEARBY_ITEMS.get(),

Diff for: src/main/kotlin/dev/sterner/common/entity/ai/sensor/GolemGuardSensor.kt

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ class GolemGuardSensor : PredicateSensor<LivingEntity, SoulSteelGolemEntity>(
3636
}
3737

3838
override fun doTick(level: ServerLevel, entity: SoulSteelGolemEntity) {
39+
if (entity.getGolemCore() != GolemCore.GUARD) {
40+
return // Exit early if the predicate is false
41+
}
42+
3943
val v: List<LivingEntity> = EntityRetrievalUtil.getEntities(
4044
level,
4145
this.radius.inflateAABB(entity.boundingBox)

Diff for: src/main/kotlin/dev/sterner/common/entity/ai/sensor/GolemHarvestSensor.kt

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ class GolemHarvestSensor : PredicateSensor<BlockState, SoulSteelGolemEntity>(
4242
}
4343

4444
override fun doTick(level: ServerLevel, entity: SoulSteelGolemEntity) {
45+
if (entity.getGolemCore() != GolemCore.HARVEST) {
46+
return // Exit early if the predicate is false
47+
}
48+
49+
//test golemcore predicate here
50+
4551
val blocks: MutableList<Pair<BlockPos, BlockState>> = ObjectArrayList()
4652

4753
for (pos in BlockPos.betweenClosed(

Diff for: src/main/kotlin/dev/sterner/common/entity/ai/sensor/GolemStorageSensor.kt

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ class GolemStorageSensor : PredicateSensor<BlockEntity, SoulSteelGolemEntity>(
3737
}
3838

3939
override fun doTick(level: ServerLevel, entity: SoulSteelGolemEntity) {
40+
if (!(entity.getGolemCore() == GolemCore.FILL || entity.getGolemCore() == GolemCore.EMPTY)) {
41+
return // Exit early if the predicate is false
42+
}
43+
4044
val blocks: MutableList<BlockPos> = ObjectArrayList()
4145

4246
for (pos in BlockPos.betweenClosed(

0 commit comments

Comments
 (0)