2019-07-11 19:55:11 +02:00
|
|
|
package com.simibubi.create;
|
|
|
|
|
2019-10-15 22:22:19 +02:00
|
|
|
import com.simibubi.create.foundation.utility.Lang;
|
2019-10-05 19:00:43 +02:00
|
|
|
import com.simibubi.create.modules.logistics.block.inventories.FlexcrateContainer;
|
|
|
|
import com.simibubi.create.modules.logistics.block.inventories.FlexcrateScreen;
|
2020-01-19 19:29:39 +01:00
|
|
|
import com.simibubi.create.modules.logistics.item.filter.AttributeFilterContainer;
|
|
|
|
import com.simibubi.create.modules.logistics.item.filter.AttributeFilterScreen;
|
|
|
|
import com.simibubi.create.modules.logistics.item.filter.FilterContainer;
|
|
|
|
import com.simibubi.create.modules.logistics.item.filter.FilterScreen;
|
2019-10-06 21:49:44 +02:00
|
|
|
import com.simibubi.create.modules.logistics.management.controller.LogisticalInventoryControllerContainer;
|
|
|
|
import com.simibubi.create.modules.logistics.management.controller.LogisticalInventoryControllerScreen;
|
2019-10-05 19:00:43 +02:00
|
|
|
import com.simibubi.create.modules.logistics.management.index.LogisticalIndexContainer;
|
|
|
|
import com.simibubi.create.modules.logistics.management.index.LogisticalIndexScreen;
|
2019-07-23 12:54:53 +02:00
|
|
|
import com.simibubi.create.modules.schematics.block.SchematicTableContainer;
|
|
|
|
import com.simibubi.create.modules.schematics.block.SchematicTableScreen;
|
|
|
|
import com.simibubi.create.modules.schematics.block.SchematicannonContainer;
|
|
|
|
import com.simibubi.create.modules.schematics.block.SchematicannonScreen;
|
2019-07-11 19:55:11 +02:00
|
|
|
|
2019-07-16 16:01:51 +02:00
|
|
|
import net.minecraft.client.gui.IHasContainer;
|
2019-07-11 19:55:11 +02:00
|
|
|
import net.minecraft.client.gui.ScreenManager;
|
2019-07-16 16:01:51 +02:00
|
|
|
import net.minecraft.client.gui.ScreenManager.IScreenFactory;
|
|
|
|
import net.minecraft.client.gui.screen.Screen;
|
2019-07-11 19:55:11 +02:00
|
|
|
import net.minecraft.inventory.container.Container;
|
|
|
|
import net.minecraft.inventory.container.ContainerType;
|
2019-07-16 16:01:51 +02:00
|
|
|
import net.minecraft.inventory.container.ContainerType.IFactory;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
2019-07-11 19:55:11 +02:00
|
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
2019-12-05 23:42:01 +01:00
|
|
|
import net.minecraftforge.event.RegistryEvent;
|
2019-07-16 16:01:51 +02:00
|
|
|
import net.minecraftforge.fml.network.IContainerFactory;
|
2019-07-11 19:55:11 +02:00
|
|
|
|
|
|
|
public enum AllContainers {
|
|
|
|
|
2019-10-15 22:22:19 +02:00
|
|
|
SCHEMATIC_TABLE(SchematicTableContainer::new),
|
2019-08-29 01:51:28 +02:00
|
|
|
SCHEMATICANNON(SchematicannonContainer::new),
|
|
|
|
FLEXCRATE(FlexcrateContainer::new),
|
2019-10-05 19:00:43 +02:00
|
|
|
LOGISTICAL_INDEX(LogisticalIndexContainer::new),
|
2019-10-06 21:49:44 +02:00
|
|
|
LOGISTICAL_CONTROLLER(LogisticalInventoryControllerContainer::new),
|
2019-12-05 23:42:01 +01:00
|
|
|
|
2020-01-19 19:29:39 +01:00
|
|
|
FILTER(FilterContainer::new),
|
|
|
|
ATTRIBUTE_FILTER(AttributeFilterContainer::new),
|
|
|
|
|
2019-08-06 19:00:51 +02:00
|
|
|
;
|
2019-07-11 19:55:11 +02:00
|
|
|
|
|
|
|
public ContainerType<? extends Container> type;
|
2019-07-16 16:01:51 +02:00
|
|
|
private IFactory<?> factory;
|
2019-07-11 19:55:11 +02:00
|
|
|
|
2019-07-16 16:01:51 +02:00
|
|
|
private <C extends Container> AllContainers(IContainerFactory<C> factory) {
|
|
|
|
this.factory = factory;
|
2019-07-11 19:55:11 +02:00
|
|
|
}
|
|
|
|
|
2019-12-05 23:42:01 +01:00
|
|
|
public static void register(RegistryEvent.Register<ContainerType<?>> event) {
|
2019-07-16 16:01:51 +02:00
|
|
|
for (AllContainers container : values()) {
|
|
|
|
container.type = new ContainerType<>(container.factory)
|
2019-10-15 22:22:19 +02:00
|
|
|
.setRegistryName(new ResourceLocation(Create.ID, Lang.asId(container.name())));
|
2019-12-05 23:42:01 +01:00
|
|
|
event.getRegistry().register(container.type);
|
2019-07-16 16:01:51 +02:00
|
|
|
}
|
2019-07-11 19:55:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
|
|
public static void registerScreenFactories() {
|
2019-08-29 01:51:28 +02:00
|
|
|
bind(SCHEMATIC_TABLE, SchematicTableScreen::new);
|
|
|
|
bind(SCHEMATICANNON, SchematicannonScreen::new);
|
|
|
|
bind(FLEXCRATE, FlexcrateScreen::new);
|
2019-10-05 19:00:43 +02:00
|
|
|
bind(LOGISTICAL_INDEX, LogisticalIndexScreen::new);
|
2019-10-06 21:49:44 +02:00
|
|
|
bind(LOGISTICAL_CONTROLLER, LogisticalInventoryControllerScreen::new);
|
2020-01-19 19:29:39 +01:00
|
|
|
bind(FILTER, FilterScreen::new);
|
|
|
|
bind(ATTRIBUTE_FILTER, AttributeFilterScreen::new);
|
2019-07-16 16:01:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
|
|
@SuppressWarnings("unchecked")
|
2019-10-15 22:22:19 +02:00
|
|
|
private static <C extends Container, S extends Screen & IHasContainer<C>> void bind(AllContainers c,
|
|
|
|
IScreenFactory<C, S> factory) {
|
2019-07-16 16:01:51 +02:00
|
|
|
ScreenManager.registerFactory((ContainerType<C>) c.type, factory);
|
2019-07-11 19:55:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|