Capture Biome Registry within FML

This commit is contained in:
cpw 2016-03-09 23:00:44 -05:00
parent 8e9b403fbf
commit cdf8a820a6
3 changed files with 26 additions and 0 deletions

View file

@ -1,5 +1,14 @@
--- ../src-base/minecraft/net/minecraft/world/biome/BiomeGenBase.java --- ../src-base/minecraft/net/minecraft/world/biome/BiomeGenBase.java
+++ ../src-work/minecraft/net/minecraft/world/biome/BiomeGenBase.java +++ ../src-work/minecraft/net/minecraft/world/biome/BiomeGenBase.java
@@ -70,7 +70,7 @@
protected static final WorldGenTrees worldGeneratorTrees = new WorldGenTrees(false);
protected static final WorldGenBigTree worldGeneratorBigTree = new WorldGenBigTree(false);
protected static final WorldGenSwamp worldGeneratorSwamp = new WorldGenSwamp();
- public static final RegistryNamespaced<ResourceLocation, BiomeGenBase> field_185377_q = new RegistryNamespaced();
+ public static final RegistryNamespaced<ResourceLocation, BiomeGenBase> field_185377_q = net.minecraftforge.fml.common.registry.GameData.getBiomeRegistry();
private final String biomeName;
private final float minHeight;
private final float maxHeight;
@@ -128,11 +128,12 @@ @@ -128,11 +128,12 @@
this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityWitch.class, 5, 1, 1)); this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityWitch.class, 5, 1, 1));
this.spawnableWaterCreatureList.add(new BiomeGenBase.SpawnListEntry(EntitySquid.class, 10, 4, 4)); this.spawnableWaterCreatureList.add(new BiomeGenBase.SpawnListEntry(EntitySquid.class, 10, 4, 4));

View file

@ -21,6 +21,8 @@ import net.minecraft.item.ItemBlock;
import net.minecraft.potion.Potion; import net.minecraft.potion.Potion;
import net.minecraft.util.ObjectIntIdentityMap; import net.minecraft.util.ObjectIntIdentityMap;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.RegistryNamespaced;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer; import net.minecraftforge.fml.common.ModContainer;
@ -36,6 +38,8 @@ public class GameData
static final int MAX_ITEM_ID = 31999; static final int MAX_ITEM_ID = 31999;
public static final int MIN_POTION_ID = 0; // 0-~31 are vanilla, forge start at 32 public static final int MIN_POTION_ID = 0; // 0-~31 are vanilla, forge start at 32
public static final int MAX_POTION_ID = 255; // S1DPacketEntityEffect sends bytes, we can only use 255 public static final int MAX_POTION_ID = 255; // S1DPacketEntityEffect sends bytes, we can only use 255
public static final int MIN_BIOME_ID = 0; // 0-~31 are vanilla, forge start at 32
public static final int MAX_BIOME_ID = 255; // S1DPacketEntityEffect sends bytes, we can only use 255
private static final GameData mainData = new GameData(); private static final GameData mainData = new GameData();
// public api // public api
@ -69,6 +73,8 @@ public class GameData
return getMain().iPotionRegistry; return getMain().iPotionRegistry;
} }
public static FMLControlledNamespacedRegistry<BiomeGenBase> getBiomeRegistry() { return getMain().iBiomeRegistry; }
/*************************************************** /***************************************************
* INTERNAL CODE FROM HERE ON DO NOT USE! * INTERNAL CODE FROM HERE ON DO NOT USE!
@ -114,6 +120,7 @@ public class GameData
private final FMLControlledNamespacedRegistry<Block> iBlockRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BLOCKS, Block.class, new ResourceLocation("minecraft:air"), MAX_BLOCK_ID, MIN_BLOCK_ID, true, BlockStateCapture.INSTANCE); private final FMLControlledNamespacedRegistry<Block> iBlockRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BLOCKS, Block.class, new ResourceLocation("minecraft:air"), MAX_BLOCK_ID, MIN_BLOCK_ID, true, BlockStateCapture.INSTANCE);
private final FMLControlledNamespacedRegistry<Item> iItemRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ITEMS, Item.class, null, MAX_ITEM_ID, MIN_ITEM_ID, true, ItemBlockCapture.INSTANCE); private final FMLControlledNamespacedRegistry<Item> iItemRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ITEMS, Item.class, null, MAX_ITEM_ID, MIN_ITEM_ID, true, ItemBlockCapture.INSTANCE);
private final FMLControlledNamespacedRegistry<Potion> iPotionRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONS, Potion.class, null, MAX_POTION_ID, MIN_POTION_ID, false, PotionArrayCapture.INSTANCE); private final FMLControlledNamespacedRegistry<Potion> iPotionRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONS, Potion.class, null, MAX_POTION_ID, MIN_POTION_ID, false, PotionArrayCapture.INSTANCE);
private final FMLControlledNamespacedRegistry<BiomeGenBase> iBiomeRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BIOMES, BiomeGenBase.class, null, MAX_BIOME_ID, MIN_BIOME_ID, false, BiomeCapture.INSTANCE);
int registerItem(Item item, String name) // from GameRegistry int registerItem(Item item, String name) // from GameRegistry
{ {
@ -257,4 +264,13 @@ public class GameData
// no op for the minute? // no op for the minute?
} }
} }
private static class BiomeCapture implements FMLControlledNamespacedRegistry.AddCallback<BiomeGenBase>
{
static final BiomeCapture INSTANCE = new BiomeCapture();
@Override
public void onAdd(BiomeGenBase potion, int id) {
// no op for the minute?
}
}
} }

View file

@ -129,6 +129,7 @@ public class PersistentRegistryManager
public static final ResourceLocation BLOCKS = new ResourceLocation("minecraft:blocks"); public static final ResourceLocation BLOCKS = new ResourceLocation("minecraft:blocks");
public static final ResourceLocation ITEMS = new ResourceLocation("minecraft:items"); public static final ResourceLocation ITEMS = new ResourceLocation("minecraft:items");
public static final ResourceLocation POTIONS = new ResourceLocation("minecraft:potions"); public static final ResourceLocation POTIONS = new ResourceLocation("minecraft:potions");
public static final ResourceLocation BIOMES = new ResourceLocation("minecraft:biomes");
public static <T> FMLControlledNamespacedRegistry<T> createRegistry(ResourceLocation registryName, Class<T> registryType, ResourceLocation optionalDefaultKey, int maxId, int minId, boolean hasDelegates, FMLControlledNamespacedRegistry.AddCallback<T> addCallback) public static <T> FMLControlledNamespacedRegistry<T> createRegistry(ResourceLocation registryName, Class<T> registryType, ResourceLocation optionalDefaultKey, int maxId, int minId, boolean hasDelegates, FMLControlledNamespacedRegistry.AddCallback<T> addCallback)
{ {