2019-07-11 09:03:08 +02:00
|
|
|
package com.simibubi.create;
|
|
|
|
|
2019-07-11 19:55:11 +02:00
|
|
|
import org.apache.logging.log4j.LogManager;
|
2019-07-11 09:03:08 +02:00
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
2019-07-15 12:10:57 +02:00
|
|
|
import com.simibubi.create.gui.Keyboard;
|
2019-07-11 09:03:08 +02:00
|
|
|
import com.simibubi.create.networking.Packets;
|
2019-07-15 12:10:57 +02:00
|
|
|
import com.simibubi.create.schematic.BlueprintHandler;
|
2019-07-12 12:13:05 +02:00
|
|
|
import com.simibubi.create.schematic.SchematicHologram;
|
2019-07-11 09:03:08 +02:00
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
2019-07-15 12:10:57 +02:00
|
|
|
import net.minecraft.client.settings.KeyBinding;
|
2019-07-11 09:03:08 +02:00
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemGroup;
|
2019-07-11 19:55:11 +02:00
|
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
2019-07-11 09:03:08 +02:00
|
|
|
import net.minecraftforge.event.RegistryEvent;
|
|
|
|
import net.minecraftforge.eventbus.api.IEventBus;
|
|
|
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
2019-07-11 19:55:11 +02:00
|
|
|
import net.minecraftforge.fml.DistExecutor;
|
2019-07-15 12:10:57 +02:00
|
|
|
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
2019-07-11 09:03:08 +02:00
|
|
|
import net.minecraftforge.fml.common.Mod;
|
|
|
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
|
|
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
2019-07-11 19:55:11 +02:00
|
|
|
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
|
2019-07-17 14:36:51 +02:00
|
|
|
import net.minecraftforge.fml.common.gameevent.TickEvent.ServerTickEvent;
|
2019-07-11 09:03:08 +02:00
|
|
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
|
|
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
2019-07-17 14:36:51 +02:00
|
|
|
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
|
2019-07-11 09:03:08 +02:00
|
|
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
|
|
|
|
|
|
|
@EventBusSubscriber(bus = Bus.FORGE)
|
|
|
|
@Mod(Create.ID)
|
|
|
|
public class Create {
|
|
|
|
|
|
|
|
public static final String ID = "create";
|
|
|
|
public static final String NAME = "Create";
|
|
|
|
public static final String VERSION = "0.0.1";
|
|
|
|
|
2019-07-11 19:55:11 +02:00
|
|
|
public static Logger logger = LogManager.getLogger();
|
2019-07-11 09:03:08 +02:00
|
|
|
|
|
|
|
public static ItemGroup creativeTab = new CreateItemGroup();
|
2019-07-11 19:55:11 +02:00
|
|
|
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
|
|
public static ClientSchematicLoader cSchematicLoader;
|
2019-07-15 12:10:57 +02:00
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
|
|
public static KeyBinding TOOL_MENU;
|
2019-07-11 19:55:11 +02:00
|
|
|
|
|
|
|
public static ServerSchematicLoader sSchematicLoader;
|
2019-07-11 09:03:08 +02:00
|
|
|
|
|
|
|
public Create() {
|
|
|
|
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
|
|
|
modEventBus.addListener(this::clientInit);
|
|
|
|
modEventBus.addListener(this::init);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void clientInit(FMLClientSetupEvent event) {
|
2019-07-15 12:10:57 +02:00
|
|
|
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
|
|
|
|
AllItems.initColorHandlers();
|
|
|
|
AllTileEntities.registerRenderers();
|
|
|
|
cSchematicLoader = new ClientSchematicLoader();
|
|
|
|
new SchematicHologram();
|
|
|
|
new BlueprintHandler();
|
|
|
|
ScrollFixer.init();
|
|
|
|
TOOL_MENU = new KeyBinding("Tool Menu (Hold)", Keyboard.LALT, NAME);
|
|
|
|
ClientRegistry.registerKeyBinding(TOOL_MENU);
|
|
|
|
});
|
2019-07-11 09:03:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void init(final FMLCommonSetupEvent event) {
|
|
|
|
Packets.registerPackets();
|
2019-07-11 19:55:11 +02:00
|
|
|
DistExecutor.runWhenOn(Dist.CLIENT, () -> AllContainers::registerScreenFactories);
|
2019-07-15 12:10:57 +02:00
|
|
|
sSchematicLoader = new ServerSchematicLoader();
|
2019-07-11 19:55:11 +02:00
|
|
|
}
|
|
|
|
|
2019-07-17 14:36:51 +02:00
|
|
|
@SubscribeEvent
|
|
|
|
public static void onTick(ServerTickEvent event) {
|
|
|
|
sSchematicLoader.tick();
|
|
|
|
}
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public static void onServerClose(FMLServerStoppingEvent event) {
|
|
|
|
sSchematicLoader.shutdown();
|
|
|
|
}
|
|
|
|
|
2019-07-11 19:55:11 +02:00
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
|
|
@SubscribeEvent
|
|
|
|
public static void onClientTick(ClientTickEvent event) {
|
|
|
|
cSchematicLoader.tick();
|
2019-07-11 09:03:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventBusSubscriber(bus = Bus.MOD)
|
|
|
|
public static class RegistryListener {
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public static void registerItems(RegistryEvent.Register<Item> event) {
|
|
|
|
AllItems.registerItems(event.getRegistry());
|
|
|
|
AllBlocks.registerItemBlocks(event.getRegistry());
|
|
|
|
}
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public static void registerBlocks(RegistryEvent.Register<Block> event) {
|
|
|
|
AllBlocks.registerBlocks(event.getRegistry());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|