mirror of
https://github.com/Theta-Dev/ConstructionWand.git
synced 2025-10-10 18:23:32 +02:00
38 lines
No EOL
1.2 KiB
Java
38 lines
No EOL
1.2 KiB
Java
package thetadev.constructionwand.containers;
|
|
|
|
import net.minecraft.world.entity.player.Player;
|
|
import net.minecraft.world.item.ItemStack;
|
|
import thetadev.constructionwand.api.IContainerHandler;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
public class ContainerManager
|
|
{
|
|
private final ArrayList<IContainerHandler> handlers;
|
|
|
|
public ContainerManager() {
|
|
handlers = new ArrayList<IContainerHandler>();
|
|
}
|
|
|
|
public boolean register(IContainerHandler handler) {
|
|
return handlers.add(handler);
|
|
}
|
|
|
|
public int countItems(Player player, ItemStack itemStack, ItemStack inventoryStack) {
|
|
for(IContainerHandler handler : handlers) {
|
|
if(handler.matches(player, itemStack, inventoryStack)) {
|
|
return handler.countItems(player, itemStack, inventoryStack);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public int useItems(Player player, ItemStack itemStack, ItemStack inventoryStack, int count) {
|
|
for(IContainerHandler handler : handlers) {
|
|
if(handler.matches(player, itemStack, inventoryStack)) {
|
|
return handler.useItems(player, itemStack, inventoryStack, count);
|
|
}
|
|
}
|
|
return count;
|
|
}
|
|
} |