Skip to content

Commit ea613ed

Browse files
committed
Better shulker placements and solve TaskFlow memory leak
1 parent a28ea6d commit ea613ed

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

src/main/java/com/lambda/mixin/render/DebugHudMixin.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
package com.lambda.mixin.render;
1919

20-
import com.lambda.task.RootTask;
2120
import com.lambda.util.DebugInfoHud;
2221
import net.minecraft.client.gui.hud.DebugHud;
2322
import org.spongepowered.asm.mixin.Mixin;
@@ -33,9 +32,4 @@ public class DebugHudMixin {
3332
private void onGetRightText(CallbackInfoReturnable<List<String>> cir) {
3433
DebugInfoHud.addDebugInfo(cir.getReturnValue());
3534
}
36-
37-
@Inject(method = "getLeftText", at = @At("TAIL"))
38-
private void onGetLeftText(CallbackInfoReturnable<List<String>> cir) {
39-
cir.getReturnValue().addAll(List.of(RootTask.INSTANCE.toString().split("\n")));
40-
}
4135
}

src/main/kotlin/com/lambda/config/groups/EatConfig.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package com.lambda.config.groups
1919

2020
import com.lambda.context.SafeContext
21-
import com.lambda.interaction.material.StackSelection
2221
import com.lambda.interaction.material.StackSelection.Companion.selectStack
2322
import com.lambda.threading.runSafe
2423
import com.lambda.util.Describable
@@ -32,13 +31,16 @@ interface EatConfig {
3231
val eatOnHunger: Boolean
3332
val minFoodLevel: Int
3433
val nutritiousFood: List<Item>
35-
val selectionPriority: SelectionPriority
3634
val saturated: Saturation
35+
3736
val eatOnFire: Boolean
3837
val resistanceFood: List<Item>
38+
3939
val eatOnDamage: Boolean
4040
val minDamage: Int
4141
val regenerationFood: List<Item>
42+
43+
val selectionPriority: SelectionPriority
4244
val ignoreBadFood: Boolean
4345
val badFood: List<Item>
4446

@@ -67,7 +69,7 @@ interface EatConfig {
6769
}
6870

6971
enum class Reason(val message: (ItemStack) -> String) {
70-
None({ "Waiting for food to eat..." }),
72+
None({ "Waiting for reason to eat..." }),
7173
Hunger({ "Eating ${it.item.name.string} due to Hunger" }),
7274
Damage({ "Eating ${it.item.name.string} due to Damage" }),
7375
Fire({ "Eating ${it.item.name.string} due to Fire" });

src/main/kotlin/com/lambda/task/Task.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import com.lambda.event.EventFlow.unsubscribe
2323
import com.lambda.event.Muteable
2424
import com.lambda.event.events.TickEvent
2525
import com.lambda.event.listener.SafeListener.Companion.listen
26+
import com.lambda.module.modules.client.TaskFlowModule
2627
import com.lambda.threading.runSafe
2728
import com.lambda.util.Communication.logError
2829
import com.lambda.util.Nameable
@@ -126,6 +127,7 @@ abstract class Task<Result> : Nameable, Muteable {
126127
fun success(result: Result) {
127128
unsubscribe()
128129
state = State.COMPLETED
130+
if (!TaskFlowModule.showAllEntries) parent?.subTasks?.remove(this)
129131
runSafe {
130132
executeNextTask(result)
131133
}

src/main/kotlin/com/lambda/task/tasks/PlaceContainer.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import com.lambda.task.tasks.BuildTask.Companion.build
3636
import com.lambda.util.BlockUtils.blockPos
3737
import com.lambda.util.BlockUtils.blockState
3838
import com.lambda.util.item.ItemUtils.shulkerBoxes
39+
import com.lambda.util.math.distSq
3940
import net.minecraft.block.ChestBlock
4041
import net.minecraft.entity.mob.ShulkerEntity
4142
import net.minecraft.item.ItemStack
@@ -72,7 +73,7 @@ class PlaceContainer @Ta5kBuilder constructor(
7273
val containerPosition = options.filter {
7374
// ToDo: Check based on if we can move the player close enough rather than y level once the custom pathfinder is merged
7475
it.blockPos.y == player.blockPos.y
75-
}.minOrNull()?.blockPos ?: run {
76+
}.minByOrNull { it.blockPos distSq player.pos }?.blockPos ?: run {
7677
failure("Couldn't find a valid container placement position for ${startStack.name.string}")
7778
return@onStart
7879
}

0 commit comments

Comments
 (0)