Updated to the new Forge registry setup. Closes #1015
This commit is contained in:
parent
f32d655af2
commit
a5563eec33
10 changed files with 42 additions and 37 deletions
|
@ -47,6 +47,7 @@ minecraft {
|
|||
//set a full version string with appended build number to be used in mod registration
|
||||
def buildnum = (config.build_number!="") ? '.' + config.build_number : ""
|
||||
replace '@MOD_VERSION@', config.mod_version + buildnum
|
||||
replace '1.0.0.0', config.forge_version
|
||||
replaceIn 'BiomesOPlenty.java'
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
minecraft_version=1.12
|
||||
forge_version=14.21.0.2340
|
||||
forge_version=14.21.0.2349
|
||||
mod_version=7.0.0
|
||||
mappings_version=snapshot_nodoc_20170619
|
||||
|
|
|
@ -17,7 +17,7 @@ import net.minecraft.util.NonNullList;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
|
||||
public class BiomeEssenceRecipe extends net.minecraftforge.fml.common.registry.IForgeRegistryEntry.Impl<IRecipe> implements IRecipe
|
||||
public class BiomeEssenceRecipe extends net.minecraftforge.registries.IForgeRegistryEntry.Impl<IRecipe> implements IRecipe
|
||||
{
|
||||
static {
|
||||
RecipeSorter.register("biomesoplenty:biomeessenceRecipe", BiomeEssenceRecipe.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
@ -619,7 +620,8 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry
|
|||
BOPCommand.biomeCount++;
|
||||
|
||||
BOPBiomes.REG_INSTANCE.registerBiome(biome, idName);
|
||||
Biome.registerBiome(id, biome.getResourceLocation().toString(), biome);
|
||||
biome.setRegistryName(biome.getResourceLocation());
|
||||
ForgeRegistries.BIOMES.register(biome);
|
||||
|
||||
//Enable spwning and village generation in the biome
|
||||
if (biome.canSpawnInBiome)
|
||||
|
@ -647,7 +649,8 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry
|
|||
BOPCommand.biomeCount++;
|
||||
|
||||
BOPBiomes.REG_INSTANCE.registerBiome(biome, idName);
|
||||
Biome.registerBiome(id, biome.getResourceLocation().toString(), biome);
|
||||
biome.setRegistryName(biome.getResourceLocation());
|
||||
ForgeRegistries.BIOMES.register(biome);
|
||||
|
||||
return Optional.of((Biome)biome);
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ import net.minecraft.util.ResourceLocation;
|
|||
import net.minecraftforge.common.EnumPlantType;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ModBlocks
|
||||
|
@ -314,10 +315,11 @@ public class ModBlocks
|
|||
|
||||
public static Block registerFluidBlock(Fluid fluid, Block fluidBlock, String name)
|
||||
{
|
||||
Block block = GameRegistry.register(fluidBlock, new ResourceLocation(BiomesOPlenty.MOD_ID, name));
|
||||
BiomesOPlenty.proxy.registerFluidBlockRendering(block, name);
|
||||
fluidBlock.setRegistryName(new ResourceLocation(BiomesOPlenty.MOD_ID, name));
|
||||
ForgeRegistries.BLOCKS.register(fluidBlock);
|
||||
BiomesOPlenty.proxy.registerFluidBlockRendering(fluidBlock, name);
|
||||
fluid.setBlock(fluidBlock);
|
||||
return block;
|
||||
return fluidBlock;
|
||||
}
|
||||
|
||||
|
||||
|
@ -410,12 +412,18 @@ public class ModBlocks
|
|||
Item itemBlock = clazz != null ? (Item)clazz.getConstructor(Block.class).newInstance(block) : null;
|
||||
ResourceLocation location = new ResourceLocation(BiomesOPlenty.MOD_ID, blockName);
|
||||
|
||||
GameRegistry.register(block, location);
|
||||
if (itemBlock != null) GameRegistry.register(itemBlock, location);
|
||||
block.setRegistryName(new ResourceLocation(BiomesOPlenty.MOD_ID, blockName));
|
||||
|
||||
ForgeRegistries.BLOCKS.register(block);
|
||||
if (itemBlock != null)
|
||||
{
|
||||
itemBlock.setRegistryName(new ResourceLocation(BiomesOPlenty.MOD_ID, blockName));
|
||||
ForgeRegistries.ITEMS.register(itemBlock);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException("An error occurred associating an item block during registration...", e);
|
||||
throw new RuntimeException("An error occurred associating an item block during registration of " + blockName, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ import net.minecraft.item.ItemSeeds;
|
|||
import net.minecraft.item.ItemSoup;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ModItems
|
||||
|
@ -154,7 +155,8 @@ public class ModItems
|
|||
item.setCreativeTab(CreativeTabBOP.instance);
|
||||
}
|
||||
|
||||
GameRegistry.register(item, new ResourceLocation(BiomesOPlenty.MOD_ID, name));
|
||||
item.setRegistryName(new ResourceLocation(BiomesOPlenty.MOD_ID, name));
|
||||
ForgeRegistries.ITEMS.register(item);
|
||||
BOPCommand.itemCount++;
|
||||
BiomesOPlenty.proxy.registerItemSided(item);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import biomesoplenty.common.potion.PotionPossession;
|
|||
import biomesoplenty.core.BiomesOPlenty;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
public class ModPotions
|
||||
{
|
||||
|
@ -29,23 +30,9 @@ public class ModPotions
|
|||
|
||||
public static Potion registerPotion(String name, Potion potion)
|
||||
{
|
||||
Potion.REGISTRY.register(getSparePotionId(), new ResourceLocation(BiomesOPlenty.MOD_ID, name), potion);
|
||||
ResourceLocation location = new ResourceLocation(BiomesOPlenty.MOD_ID, name);
|
||||
potion.setRegistryName(location);
|
||||
ForgeRegistries.POTIONS.register(potion);
|
||||
return potion;
|
||||
}
|
||||
|
||||
|
||||
// gets the next free potion id
|
||||
// will expand the potions array if necessary
|
||||
// this isn't very efficient, but it only has to run once, right at the start, so clarity and simplicity are more important than speed
|
||||
public static int getSparePotionId()
|
||||
{
|
||||
int nextId = 1;
|
||||
|
||||
// look for a free slot in the Potions array
|
||||
// (note we start counting from 1 - vanilla MC doens't use ID 0, nor will we)
|
||||
for (; Potion.REGISTRY.getObjectById(nextId) != null; nextId++) {}
|
||||
|
||||
return nextId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import static biomesoplenty.api.sound.BOPSounds.wasp_hurt;
|
|||
import biomesoplenty.core.BiomesOPlenty;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
public class ModSounds
|
||||
{
|
||||
|
@ -31,7 +32,9 @@ public class ModSounds
|
|||
private static SoundEvent registerSound(String soundName)
|
||||
{
|
||||
ResourceLocation location = new ResourceLocation(BiomesOPlenty.MOD_ID, soundName);
|
||||
SoundEvent.registerSound(location.toString());
|
||||
return SoundEvent.REGISTRY.getObject(location);
|
||||
SoundEvent event = new SoundEvent(location);
|
||||
event.setRegistryName(location);
|
||||
ForgeRegistries.SOUND_EVENTS.register(event);
|
||||
return event;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
|||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
|
||||
@Mod(modid = BiomesOPlenty.MOD_ID, version = BiomesOPlenty.MOD_VERSION , name = BiomesOPlenty.MOD_NAME, dependencies = "required-after:forge@[14.21.0.2340,)", guiFactory = BiomesOPlenty.GUI_FACTORY)
|
||||
@Mod(modid = BiomesOPlenty.MOD_ID, version = BiomesOPlenty.MOD_VERSION , name = BiomesOPlenty.MOD_NAME, dependencies = "required-after:forge@[1.0.0.0,)", guiFactory = BiomesOPlenty.GUI_FACTORY)
|
||||
public class BiomesOPlenty
|
||||
{
|
||||
public static final String MOD_NAME = "Biomes O' Plenty";
|
||||
|
|
|
@ -98,13 +98,14 @@ public class ClientProxy extends CommonProxy
|
|||
registerEntityRenderer(EntityMudball.class, RenderMudball.class);
|
||||
|
||||
replaceForgeResources();
|
||||
|
||||
ModelLoader.registerItemVariants(ForgeModContainer.getInstance().universalBucket, bucketModelLocations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerColouring()
|
||||
{
|
||||
// do this here purely for timing reasons
|
||||
ModelLoader.registerItemVariants(ForgeModContainer.getInstance().universalBucket, bucketModelLocations);
|
||||
|
||||
for (Block block : blocksToColour)
|
||||
{
|
||||
IBOPBlock bopBlock = (IBOPBlock)block;
|
||||
|
|
Loading…
Reference in a new issue