aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/ftbsc/bscv/modules/self/ContainerCleaner.java37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/main/java/ftbsc/bscv/modules/self/ContainerCleaner.java b/src/main/java/ftbsc/bscv/modules/self/ContainerCleaner.java
index d08d832..02af2f2 100644
--- a/src/main/java/ftbsc/bscv/modules/self/ContainerCleaner.java
+++ b/src/main/java/ftbsc/bscv/modules/self/ContainerCleaner.java
@@ -1,16 +1,20 @@
package ftbsc.bscv.modules.self;
-import java.util.regex.Pattern;
+import java.util.ArrayList;
+import java.util.List;
+
import com.google.auto.service.AutoService;
-import ftbsc.bscv.Boscovicino;
import ftbsc.bscv.api.ILoadable;
import ftbsc.bscv.modules.AbstractModule;
import ftbsc.bscv.tools.Inventory;
import ftbsc.bscv.tools.Setting;
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
+import net.minecraft.command.arguments.ItemArgument;
+import net.minecraft.command.arguments.ItemInput;
import net.minecraft.inventory.container.ClickType;
import net.minecraft.inventory.container.Slot;
+import net.minecraft.item.Item;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.event.TickEvent.ClientTickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@@ -18,23 +22,14 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
@AutoService(ILoadable.class)
public class ContainerCleaner extends AbstractModule {
- public final ForgeConfigSpec.ConfigValue<String> query;
public final ForgeConfigSpec.ConfigValue<Integer> cooldown;
public final ForgeConfigSpec.ConfigValue<Boolean> limit;
- private Pattern pattern;
+ public final ForgeConfigSpec.ConfigValue<List<? extends Integer>> blacklist;
private int counter;
public ContainerCleaner() {
super();
- this.pattern = Pattern.compile("");
- this.query = Setting.Str.builder()
- .fallback("")
- .name("query")
- .comment("search query for dropping items")
- .callback(to -> this.pattern = Pattern.compile(to))
- .build(this);
-
this.counter = 0;
this.cooldown = Setting.Number.builder()
.fallback(0)
@@ -47,6 +42,13 @@ public class ContainerCleaner extends AbstractModule {
.name("limit")
.comment("limit to one action per tick")
.build(this);
+
+ this.blacklist = new Setting.Many<ItemInput, Integer>(ItemArgument.item(), ItemInput.class)
+ .writer(x -> Item.getId(x.getItem()))
+ .fallback(new ArrayList<Integer>())
+ .name("blacklist")
+ .comment("items to throw away")
+ .build(this);
}
@SubscribeEvent
@@ -59,12 +61,11 @@ public class ContainerCleaner extends AbstractModule {
}
ContainerScreen<?> screen = (ContainerScreen<?>) MC.screen;
for (Slot slot : screen.getMenu().slots) {
- if (Inventory.matchItem(this.pattern, slot.getItem())) {
- Boscovicino.log("dropping item %s", slot.getItem().getItem());
- Inventory.clickSLot(screen.getMenu().containerId, slot, ClickType.THROW);
- this.counter = this.cooldown.get();
- if (this.limit.get()) return; // only throw one item per tick
- }
+ if (this.blacklist.get().contains(Item.getId(slot.getItem().getItem()))) {
+ Inventory.clickSLot(screen.getMenu().containerId, slot, ClickType.THROW);
+ this.counter = this.cooldown.get();
+ if (this.limit.get()) return; // only throw one item per tick
+ }
}
}
}