feat[containercleaner]: throw whole stacks
This commit is contained in:
parent
aebd63ac13
commit
63cfbaa56c
1 changed files with 9 additions and 1 deletions
|
@ -24,6 +24,7 @@ public class ContainerCleaner extends AbstractModule {
|
||||||
|
|
||||||
public final ForgeConfigSpec.ConfigValue<Integer> cooldown;
|
public final ForgeConfigSpec.ConfigValue<Integer> cooldown;
|
||||||
public final ForgeConfigSpec.ConfigValue<Boolean> limit;
|
public final ForgeConfigSpec.ConfigValue<Boolean> limit;
|
||||||
|
public final ForgeConfigSpec.ConfigValue<Boolean> all;
|
||||||
public final ForgeConfigSpec.ConfigValue<List<? extends Integer>> blacklist;
|
public final ForgeConfigSpec.ConfigValue<List<? extends Integer>> blacklist;
|
||||||
private int counter;
|
private int counter;
|
||||||
|
|
||||||
|
@ -43,6 +44,12 @@ public class ContainerCleaner extends AbstractModule {
|
||||||
.comment("limit to one action per tick")
|
.comment("limit to one action per tick")
|
||||||
.build(this);
|
.build(this);
|
||||||
|
|
||||||
|
this.all = Setting.Bool.builder()
|
||||||
|
.fallback(true)
|
||||||
|
.name("all")
|
||||||
|
.comment("throw whole stacks instead of single items")
|
||||||
|
.build(this);
|
||||||
|
|
||||||
this.blacklist = new Setting.Many<ItemInput, Integer>(ItemArgument.item(), ItemInput.class)
|
this.blacklist = new Setting.Many<ItemInput, Integer>(ItemArgument.item(), ItemInput.class)
|
||||||
.writer(x -> Item.getId(x.getItem()))
|
.writer(x -> Item.getId(x.getItem()))
|
||||||
.fallback(new ArrayList<Integer>())
|
.fallback(new ArrayList<Integer>())
|
||||||
|
@ -62,7 +69,8 @@ public class ContainerCleaner extends AbstractModule {
|
||||||
ContainerScreen<?> screen = (ContainerScreen<?>) MC.screen;
|
ContainerScreen<?> screen = (ContainerScreen<?>) MC.screen;
|
||||||
for (Slot slot : screen.getMenu().slots) {
|
for (Slot slot : screen.getMenu().slots) {
|
||||||
if (this.blacklist.get().contains(Item.getId(slot.getItem().getItem()))) {
|
if (this.blacklist.get().contains(Item.getId(slot.getItem().getItem()))) {
|
||||||
Inventory.clickSlot(screen.getMenu().containerId, slot.index, ClickType.THROW);
|
int button = this.all.get() ? 1 : 0;
|
||||||
|
Inventory.clickSlot(screen.getMenu().containerId, slot.index, button, ClickType.THROW);
|
||||||
this.counter = this.cooldown.get();
|
this.counter = this.cooldown.get();
|
||||||
if (this.limit.get()) return; // only throw one item per tick
|
if (this.limit.get()) return; // only throw one item per tick
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue