Perform registration during the registration events. Closes #1444

This commit is contained in:
Adubbz 2019-08-10 13:35:50 +10:00
parent f51511b738
commit d664cd9e1e
8 changed files with 44 additions and 18 deletions

View file

@ -15,6 +15,7 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.DistExecutor;
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.FMLDedicatedServerSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
@ -36,18 +37,11 @@ public class BiomesOPlenty
{
instance = this;
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::commonSetup);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::dedicatedServerSetup);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::loadComplete);
MinecraftForge.EVENT_BUS.addListener(this::serverStarting);
ModConfig.init();
ModSounds.init();
ModEntities.init();
ModBlocks.init();
ModItems.init();
ModBiomes.init();
ModVanillaCompat.init();
}
public void dedicatedServerSetup(FMLDedicatedServerSetupEvent event)
@ -66,6 +60,13 @@ public class BiomesOPlenty
}
}
private void commonSetup(final FMLCommonSetupEvent event)
{
ModConfig.setup();
ModBiomes.setup();
ModVanillaCompat.setup();
}
private void clientSetup(final FMLClientSetupEvent event)
{
ModEntities.registerRendering();

View file

@ -83,14 +83,19 @@ import biomesoplenty.common.biome.overworld.WhiteBeachBiome;
import biomesoplenty.common.biome.overworld.WoodlandBiome;
import biomesoplenty.common.biome.overworld.XericShrublandBiome;
import biomesoplenty.common.world.WorldTypeBOP;
import net.minecraft.block.Block;
import net.minecraft.world.biome.Biomes;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
import net.minecraftforge.common.BiomeManager;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.ForgeRegistries;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModBiomes
{
public static WorldTypeBOP worldType;
@ -98,15 +103,14 @@ public class ModBiomes
public static Multimap<Integer, WeightedSubBiome> subBiomes = HashMultimap.create();
public static List<Integer> islandBiomes = Lists.newArrayList();
public static void init()
public static void setup()
{
worldType = new WorldTypeBOP();
registerBiomes();
registerBiomeDictionaryTags();
}
private static void registerBiomes()
@SubscribeEvent
public static void registerBiomes(RegistryEvent.Register<Biome> event)
{
//Technical Biomes (Need to be registered before main biomes that use them)
mangrove = registerBiome(new MangroveBiome(), "mangrove");

View file

@ -20,13 +20,18 @@ import net.minecraft.item.Item;
import net.minecraft.potion.Effects;
import net.minecraft.util.SoundEvents;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.ForgeRegistries;
import static biomesoplenty.api.block.BOPBlocks.*;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModBlocks
{
public static void init()
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event)
{
//Terrain
white_sand = registerBlock(new WhiteSandBlock(0xF3F1E4, Block.Properties.create(Material.SAND, MaterialColor.QUARTZ).hardnessAndResistance(0.5F).sound(SoundType.SAND).harvestLevel(0).harvestTool(ToolType.SHOVEL)), "white_sand");

View file

@ -38,7 +38,7 @@ public class ModConfig
}
}
public static void init()
public static void setup()
{
Path configPath = FMLPaths.CONFIGDIR.get();
Path bopConfigPath = Paths.get(configPath.toAbsolutePath().toString(), "biomesoplenty");

View file

@ -16,14 +16,19 @@ import net.minecraft.entity.EntityType;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.ForgeRegistries;
import static biomesoplenty.core.BiomesOPlenty.MOD_ID;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModEntities
{
public static void init()
@SubscribeEvent
public static void registerEntities(RegistryEvent.Register<EntityType<?>> event)
{
BOPEntities.boat_bop = EntityType.Builder.<BoatEntityBOP>create(BoatEntityBOP::new, EntityClassification.MISC).setTrackingRange(80).setUpdateInterval(3).setShouldReceiveVelocityUpdates(true).size(1.375f, 0.5625f).setCustomClientFactory(BoatEntityBOP::new).build(MOD_ID + ":boat_bop");
BOPEntities.boat_bop.setRegistryName("boat_bop");

View file

@ -15,13 +15,18 @@ import biomesoplenty.common.item.MusicDiscItemBOP;
import biomesoplenty.common.util.inventory.ItemGroupBOP;
import net.minecraft.item.AxeItem;
import net.minecraft.item.Item;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.ForgeRegistries;
import static biomesoplenty.api.item.BOPItems.*;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModItems
{
public static void init()
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
mud_ball = registerItem(new Item(new Item.Properties().group(ItemGroupBOP.instance)), "mud_ball");
mud_brick = registerItem(new Item(new Item.Properties().group(ItemGroupBOP.instance)), "mud_brick");

View file

@ -8,15 +8,21 @@
package biomesoplenty.init;
import biomesoplenty.core.BiomesOPlenty;
import net.minecraft.entity.EntityType;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.ForgeRegistries;
import static biomesoplenty.api.sound.BOPSounds.music_disc_wanderer;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModSounds
{
public static void init()
@SubscribeEvent
public static void registerSounds(RegistryEvent.Register<SoundEvent> event)
{
music_disc_wanderer = registerSound("music_disc.wanderer");
}

View file

@ -19,7 +19,7 @@ import net.minecraft.world.gen.placement.Placement;
public class ModVanillaCompat
{
public static void init()
public static void setup()
{
//Vanilla Biome Features
addFeature(Biomes.BADLANDS, GenerationStage.Decoration.VEGETAL_DECORATION, Biome.createDecoratedFeature(Feature.BUSH, new BushConfig(BOPBlocks.desert_grass.getDefaultState()), Placement.COUNT_HEIGHTMAP_DOUBLE, new FrequencyConfig(4)));