forked from FrostDracony/NewFantasyMod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
120 lines (104 loc) · 4.9 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package mod.dragonita.fantasymod;
import java.util.stream.Collectors;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import network.PacketHandler;
import mod.dragonita.fantasymod.init.ModBlocks;
import mod.dragonita.fantasymod.init.ModDimensions;
import mod.dragonita.fantasymod.init.ModEntityTypes;
import mod.dragonita.fantasymod.init.ModItems;
import mod.dragonita.fantasymod.init.ModTileEntityTypes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.GenerationStage;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig;
import net.minecraft.world.gen.placement.ConfiguredPlacement;
import net.minecraft.world.gen.placement.CountRangeConfig;
import net.minecraft.world.gen.placement.Placement;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DeferredWorkQueue;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.ForgeRegistries;
@SuppressWarnings("deprecation")
@Mod(Main.MODID)
public final class Main
{
public static final String MODID = "fantasymod";
public static final Logger LOGGER = LogManager.getLogger(MODID);
public static final ResourceLocation DIMENSION_TYPE = new ResourceLocation(Main.MODID, "rainbow_dimension");
private static int ID;
public Main()
{
// Register the setup method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
// Register the enqueueIMC method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
// Register the processIMC method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);
// Register the doClientStuff method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);
LOGGER.debug("Hello from Fantasy Mod");
final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
// Register Deferred Registers (Does not need to be before Configs)
ModBlocks.BLOCKS.register(modEventBus);
ModItems.ITEMS.register(modEventBus);
ModEntityTypes.ENTITY_TYPES.register(modEventBus);
ModTileEntityTypes.TILE_ENTITY_TYPES.register(modEventBus);
ModDimensions.DIMENSION.register(modEventBus);
MinecraftForge.EVENT_BUS.register(this);
}
public void setup(final FMLCommonSetupEvent event) {
PacketHandler.init();
DeferredWorkQueue.runLater(new Runnable() {
@Override
public void run() {
for(Biome biome : ForgeRegistries.BIOMES) {
//if(biome == Biomes.PLAINS) {
ConfiguredPlacement<CountRangeConfig> customConfig = Placement.COUNT_RANGE
.configure(new CountRangeConfig(20, 5, 5, 25));
biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE
.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, ModBlocks.RAINBOW_ORE.get().getDefaultState(), 10))
.withPlacement(customConfig));
//}
}
}
});
}
private void doClientStuff(final FMLClientSetupEvent event) {
// do something that can only be done on the client
LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().gameSettings);
}
private void enqueueIMC(final InterModEnqueueEvent event)
{
// some example code to dispatch IMC to another mod
InterModComms.sendTo("fantasymod", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";});
}
private void processIMC(final InterModProcessEvent event)
{
// some example code to receive and process InterModComms from other mods
LOGGER.info("Got IMC {}", event.getIMCStream().
map(m->m.getMessageSupplier().get()).
collect(Collectors.toList()));
}
@SubscribeEvent
public void onServerStarting(FMLServerStartingEvent event) {
// do something when the server starts
LOGGER.info("HELLO from server starting");
}
@SubscribeEvent
public static void loadCompleteEvent(FMLLoadCompleteEvent event) {
}
}