2020-10-14 22:04:52 +02:00
|
|
|
package de.ellpeck.prettypipes.pipe.modules.craft;
|
|
|
|
|
|
|
|
import de.ellpeck.prettypipes.misc.FilterSlot;
|
|
|
|
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;
|
2024-02-03 15:17:58 +01:00
|
|
|
import net.neoforged.neoforge.items.ItemStackHandler;
|
2020-10-14 22:04:52 +02:00
|
|
|
|
|
|
|
public class CraftingModuleContainer extends AbstractPipeContainer<CraftingModuleItem> {
|
|
|
|
|
|
|
|
public ItemStackHandler input;
|
|
|
|
public ItemStackHandler output;
|
2020-10-15 06:07:06 +02:00
|
|
|
public boolean modified;
|
2020-10-14 22:04:52 +02:00
|
|
|
|
2021-12-02 16:55:04 +01:00
|
|
|
public CraftingModuleContainer(MenuType<?> type, int id, Player player, BlockPos pos, int moduleIndex) {
|
2020-10-14 22:04:52 +02:00
|
|
|
super(type, id, player, pos, moduleIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void addSlots() {
|
|
|
|
this.input = this.module.getInput(this.moduleStack);
|
2021-12-02 17:46:56 +01:00
|
|
|
for (var i = 0; i < this.input.getSlots(); i++) {
|
2020-10-14 22:04:52 +02:00
|
|
|
this.addSlot(new FilterSlot(this.input, i, (176 - this.module.inputSlots * 18) / 2 + 1 + i % 9 * 18, 17 + 32 + i / 9 * 18, false) {
|
|
|
|
@Override
|
2021-12-02 16:55:04 +01:00
|
|
|
public void setChanged() {
|
|
|
|
super.setChanged();
|
2020-10-14 22:04:52 +02:00
|
|
|
CraftingModuleContainer.this.modified = true;
|
|
|
|
}
|
2021-12-02 16:55:04 +01:00
|
|
|
|
2020-10-14 22:04:52 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
this.output = this.module.getOutput(this.moduleStack);
|
2021-12-02 17:46:56 +01:00
|
|
|
for (var i = 0; i < this.output.getSlots(); i++) {
|
2020-10-14 22:04:52 +02:00
|
|
|
this.addSlot(new FilterSlot(this.output, i, (176 - this.module.outputSlots * 18) / 2 + 1 + i % 9 * 18, 85 + i / 9 * 18, false) {
|
|
|
|
@Override
|
2021-12-02 16:55:04 +01:00
|
|
|
public void setChanged() {
|
|
|
|
super.setChanged();
|
2020-10-14 22:04:52 +02:00
|
|
|
CraftingModuleContainer.this.modified = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-12-02 16:55:04 +01:00
|
|
|
public void removed(Player playerIn) {
|
|
|
|
super.removed(playerIn);
|
2020-10-14 22:04:52 +02:00
|
|
|
if (this.modified)
|
|
|
|
this.module.save(this.input, this.output, this.moduleStack);
|
|
|
|
}
|
|
|
|
}
|