mirror of
https://github.com/Theta-Dev/ConstructionWand.git
synced 2025-08-27 21:21:11 +02:00
Modular WandActions and WandSuppliers. Wand Cores and Wand Reservoirs can be added to your wand, they determine which action and supplier gets used.
38 lines
No EOL
1.2 KiB
Java
38 lines
No EOL
1.2 KiB
Java
package thetadev.constructionwand.containers;
|
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
|
import net.minecraft.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(PlayerEntity 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(PlayerEntity 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;
|
|
}
|
|
} |