Create/src/main/java/com/simibubi/create/Create.java

158 lines
6.3 KiB
Java
Raw Normal View History

package com.simibubi.create;
import java.util.Random;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
2021-08-25 17:49:01 +02:00
import com.simibubi.create.api.behaviour.BlockSpoutingBehaviour;
2020-05-23 14:02:38 +02:00
import com.simibubi.create.content.CreateItemGroup;
import com.simibubi.create.content.contraptions.TorquePropagator;
import com.simibubi.create.content.curiosities.weapons.BuiltinPotatoProjectileTypes;
2020-05-23 14:02:38 +02:00
import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler;
import com.simibubi.create.content.logistics.block.display.AllDisplayBehaviours;
2022-02-01 01:14:21 +01:00
import com.simibubi.create.content.logistics.trains.GlobalRailwayManager;
2020-05-23 14:02:38 +02:00
import com.simibubi.create.content.palettes.AllPaletteBlocks;
import com.simibubi.create.content.palettes.PalettesItemGroup;
import com.simibubi.create.content.schematics.SchematicProcessor;
2020-05-23 14:02:38 +02:00
import com.simibubi.create.content.schematics.ServerSchematicLoader;
import com.simibubi.create.content.schematics.filtering.SchematicInstances;
import com.simibubi.create.foundation.advancement.AllAdvancements;
import com.simibubi.create.foundation.advancement.AllTriggers;
import com.simibubi.create.foundation.block.CopperRegistries;
import com.simibubi.create.foundation.command.ServerLagger;
2020-05-23 14:02:38 +02:00
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.data.CreateRegistrate;
import com.simibubi.create.foundation.data.LangMerger;
import com.simibubi.create.foundation.data.recipe.MechanicalCraftingRecipeGen;
import com.simibubi.create.foundation.data.recipe.ProcessingRecipeGen;
import com.simibubi.create.foundation.data.recipe.SequencedAssemblyRecipeGen;
import com.simibubi.create.foundation.data.recipe.StandardRecipeGen;
2020-05-23 14:02:38 +02:00
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.worldgen.AllWorldFeatures;
import com.tterrag.registrate.util.nullness.NonNullSupplier;
import net.minecraft.core.particles.ParticleType;
2021-11-02 06:18:30 +01:00
import net.minecraft.data.DataGenerator;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
2021-11-02 06:18:30 +01:00
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.ForgeMod;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
2021-11-02 06:18:30 +01:00
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent;
import net.minecraftforge.registries.DataSerializerEntry;
@Mod(Create.ID)
public class Create {
public static final String ID = "create";
public static final String NAME = "Create";
2022-03-23 20:02:36 +01:00
public static final String VERSION = "0.5-unstable";
public static final Logger LOGGER = LogManager.getLogger();
public static final Gson GSON = new GsonBuilder().setPrettyPrinting()
.disableHtmlEscaping()
.create();
public static final CreativeModeTab BASE_CREATIVE_TAB = new CreateItemGroup();
public static final CreativeModeTab PALETTES_CREATIVE_TAB = new PalettesItemGroup();
public static final ServerSchematicLoader SCHEMATIC_RECEIVER = new ServerSchematicLoader();
public static final RedstoneLinkNetworkHandler REDSTONE_LINK_NETWORK_HANDLER = new RedstoneLinkNetworkHandler();
public static final TorquePropagator TORQUE_PROPAGATOR = new TorquePropagator();
2022-02-01 01:14:21 +01:00
public static final GlobalRailwayManager RAILWAYS = new GlobalRailwayManager();
public static final ServerLagger LAGGER = new ServerLagger();
public static final Random RANDOM = new Random();
private static final NonNullSupplier<CreateRegistrate> REGISTRATE = CreateRegistrate.lazy(ID);
public Create() {
onCtor();
}
public static void onCtor() {
ModLoadingContext modLoadingContext = ModLoadingContext.get();
AllSoundEvents.prepare();
2020-05-22 20:12:53 +02:00
AllBlocks.register();
2020-05-28 01:30:14 +02:00
AllItems.register();
AllFluids.register();
2020-06-19 22:59:38 +02:00
AllTags.register();
AllPaletteBlocks.register();
AllContainerTypes.register();
2020-06-01 00:12:10 +02:00
AllEntityTypes.register();
AllTileEntities.register();
2020-08-08 23:16:22 +02:00
AllMovementBehaviours.register();
AllDisplayBehaviours.register();
AllInteractionBehaviours.register();
AllWorldFeatures.register();
AllEnchantments.register();
AllConfigs.register(modLoadingContext);
BlockSpoutingBehaviour.register();
ForgeMod.enableMilkFluid();
CopperRegistries.inject();
IEventBus modEventBus = FMLJavaModLoadingContext.get()
.getModEventBus();
IEventBus forgeEventBus = MinecraftForge.EVENT_BUS;
modEventBus.addListener(Create::init);
modEventBus.addListener(EventPriority.LOWEST, Create::gatherData);
modEventBus.addGenericListener(Feature.class, AllWorldFeatures::registerOreFeatures);
modEventBus.addGenericListener(RecipeSerializer.class, AllRecipeTypes::register);
2020-05-23 14:02:38 +02:00
modEventBus.addGenericListener(ParticleType.class, AllParticleTypes::register);
modEventBus.addGenericListener(SoundEvent.class, AllSoundEvents::register);
modEventBus.addGenericListener(DataSerializerEntry.class, AllEntityDataSerializers::register);
2022-02-01 01:14:21 +01:00
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> CreateClient.onCtorClient(modEventBus, forgeEventBus));
}
public static void init(final FMLCommonSetupEvent event) {
AllPackets.registerPackets();
SchematicInstances.register();
BuiltinPotatoProjectileTypes.register();
event.enqueueWork(() -> {
AllTriggers.register();
SchematicProcessor.register();
AllWorldFeatures.registerFeatures();
AllWorldFeatures.registerPlacementTypes();
});
}
public static void gatherData(GatherDataEvent event) {
DataGenerator gen = event.getGenerator();
gen.addProvider(new AllAdvancements(gen));
gen.addProvider(new LangMerger(gen));
gen.addProvider(AllSoundEvents.provider(gen));
gen.addProvider(new StandardRecipeGen(gen));
gen.addProvider(new MechanicalCraftingRecipeGen(gen));
gen.addProvider(new SequencedAssemblyRecipeGen(gen));
ProcessingRecipeGen.registerAll(gen);
}
public static CreateRegistrate registrate() {
return REGISTRATE.get();
}
public static ResourceLocation asResource(String path) {
return new ResourceLocation(ID, path);
}
}