2020-04-16 23:40:35 +02:00
|
|
|
package de.ellpeck.prettypipes.pipe.modules.insertion;
|
2020-04-16 21:19:40 +02:00
|
|
|
|
2022-06-30 16:35:01 +02:00
|
|
|
import de.ellpeck.prettypipes.misc.DirectionSelector;
|
|
|
|
import de.ellpeck.prettypipes.misc.DirectionSelector.IDirectionContainer;
|
2020-04-16 21:19:40 +02:00
|
|
|
import de.ellpeck.prettypipes.misc.ItemFilter;
|
|
|
|
import de.ellpeck.prettypipes.misc.ItemFilter.IFilteredContainer;
|
2020-05-07 15:48:46 +02:00
|
|
|
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
2021-12-02 16:55:04 +01:00
|
|
|
import net.minecraft.core.BlockPos;
|
|
|
|
import net.minecraft.world.entity.player.Player;
|
|
|
|
import net.minecraft.world.inventory.MenuType;
|
2020-04-16 21:19:40 +02:00
|
|
|
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2022-06-30 16:35:01 +02:00
|
|
|
public class FilterModuleContainer extends AbstractPipeContainer<FilterModuleItem> implements IFilteredContainer, IDirectionContainer {
|
2020-04-16 21:19:40 +02:00
|
|
|
|
|
|
|
public ItemFilter filter;
|
2022-06-30 16:35:01 +02:00
|
|
|
public DirectionSelector directionSelector;
|
2020-04-16 21:19:40 +02:00
|
|
|
|
2021-12-02 16:55:04 +01:00
|
|
|
public FilterModuleContainer(@Nullable MenuType<?> type, int id, Player player, BlockPos pos, int moduleIndex) {
|
2020-04-16 21:19:40 +02:00
|
|
|
super(type, id, player, pos, moduleIndex);
|
|
|
|
}
|
|
|
|
|
2021-12-28 12:55:11 +01:00
|
|
|
@Override
|
|
|
|
public void onFilterPopulated() {
|
|
|
|
// reload the filter so that it displays correctly on the client
|
|
|
|
this.filter.load();
|
|
|
|
}
|
|
|
|
|
2020-04-16 21:19:40 +02:00
|
|
|
@Override
|
|
|
|
protected void addSlots() {
|
2021-03-03 00:10:24 +01:00
|
|
|
this.filter = this.module.getItemFilter(this.moduleStack, this.tile);
|
2022-06-30 16:35:01 +02:00
|
|
|
this.directionSelector = this.module.getDirectionSelector(this.moduleStack, this.tile);
|
|
|
|
|
2021-12-02 17:46:56 +01:00
|
|
|
for (var slot : this.filter.getSlots((176 - Math.min(this.module.filterSlots, 9) * 18) / 2 + 1, 17 + 32))
|
2020-04-16 21:19:40 +02:00
|
|
|
this.addSlot(slot);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-12-02 16:55:04 +01:00
|
|
|
public void removed(Player playerIn) {
|
|
|
|
super.removed(playerIn);
|
2020-04-16 21:19:40 +02:00
|
|
|
this.filter.save();
|
2022-06-30 16:35:01 +02:00
|
|
|
this.directionSelector.save();
|
2020-04-16 21:19:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemFilter getFilter() {
|
|
|
|
return this.filter;
|
|
|
|
}
|
2022-06-30 16:35:01 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public DirectionSelector getSelector() {
|
|
|
|
return this.directionSelector;
|
|
|
|
}
|
|
|
|
|
2020-04-16 21:19:40 +02:00
|
|
|
}
|