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-23 12:54:53 +02:00
|
|
|
import com.simibubi.create.foundation.utility.KeyboardHelper;
|
|
|
|
import com.simibubi.create.modules.schematics.ClientSchematicLoader;
|
|
|
|
import com.simibubi.create.modules.schematics.ServerSchematicLoader;
|
|
|
|
import com.simibubi.create.modules.schematics.client.BlueprintHandler;
|
|
|
|
import com.simibubi.create.modules.schematics.client.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";
|
2019-07-22 14:40:28 +02:00
|
|
|
public static final String VERSION = "0.0.3";
|
2019-07-11 09:03:08 +02:00
|
|
|
|
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();
|
2019-07-23 12:54:53 +02:00
|
|
|
TOOL_MENU = new KeyBinding("Tool Menu (Hold)", KeyboardHelper.LALT, NAME);
|
2019-07-15 12:10:57 +02:00
|
|
|
ClientRegistry.registerKeyBinding(TOOL_MENU);
|
|
|
|
});
|
2019-07-11 09:03:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void init(final FMLCommonSetupEvent event) {
|
2019-07-19 17:50:23 +02:00
|
|
|
AllPackets.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());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|