Add registries for soundevents, enchantments and potiontypes
MinecraftForge-2576 [1.9] SoundEvents (and Enchantments and PotionTypes) need a FML registry
This commit is contained in:
parent
acf8220414
commit
e72c224294
5 changed files with 97 additions and 33 deletions
|
@ -1,5 +1,17 @@
|
|||
--- ../src-base/minecraft/net/minecraft/enchantment/Enchantment.java
|
||||
+++ ../src-work/minecraft/net/minecraft/enchantment/Enchantment.java
|
||||
@@ -12,9 +12,9 @@
|
||||
import net.minecraft.util.registry.RegistryNamespaced;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
-public abstract class Enchantment
|
||||
+public abstract class Enchantment extends net.minecraftforge.fml.common.registry.IForgeRegistryEntry.Impl<Enchantment>
|
||||
{
|
||||
- public static final RegistryNamespaced<ResourceLocation, Enchantment> field_185264_b = new RegistryNamespaced();
|
||||
+ public static final RegistryNamespaced<ResourceLocation, Enchantment> field_185264_b = net.minecraftforge.fml.common.registry.GameData.getEnchantmentRegistry();
|
||||
private final EntityEquipmentSlot[] field_185263_a;
|
||||
private final Enchantment.Rarity field_77333_a;
|
||||
public EnumEnchantmentType field_77351_y;
|
||||
@@ -118,7 +118,7 @@
|
||||
|
||||
public boolean func_92089_a(ItemStack p_92089_1_)
|
||||
|
|
16
patches/minecraft/net/minecraft/potion/PotionType.java.patch
Normal file
16
patches/minecraft/net/minecraft/potion/PotionType.java.patch
Normal file
|
@ -0,0 +1,16 @@
|
|||
--- ../src-base/minecraft/net/minecraft/potion/PotionType.java
|
||||
+++ ../src-work/minecraft/net/minecraft/potion/PotionType.java
|
||||
@@ -8,10 +8,11 @@
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
-public class PotionType
|
||||
+public class PotionType extends net.minecraftforge.fml.common.registry.IForgeRegistryEntry.Impl<PotionType>
|
||||
{
|
||||
+ @Deprecated // unused
|
||||
private static final ResourceLocation field_185177_b = new ResourceLocation("water");
|
||||
- public static final RegistryNamespacedDefaultedByKey<ResourceLocation, PotionType> field_185176_a = new RegistryNamespacedDefaultedByKey(field_185177_b);
|
||||
+ public static final RegistryNamespacedDefaultedByKey<ResourceLocation, PotionType> field_185176_a = net.minecraftforge.fml.common.registry.GameData.getPotionTypesRegistry();
|
||||
private static int field_185178_c;
|
||||
private final String field_185179_d;
|
||||
private final ImmutableList<PotionEffect> field_185180_e;
|
14
patches/minecraft/net/minecraft/util/SoundEvent.java.patch
Normal file
14
patches/minecraft/net/minecraft/util/SoundEvent.java.patch
Normal file
|
@ -0,0 +1,14 @@
|
|||
--- ../src-base/minecraft/net/minecraft/util/SoundEvent.java
|
||||
+++ ../src-work/minecraft/net/minecraft/util/SoundEvent.java
|
||||
@@ -4,9 +4,9 @@
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
-public class SoundEvent
|
||||
+public class SoundEvent extends net.minecraftforge.fml.common.registry.IForgeRegistryEntry.Impl<SoundEvent>
|
||||
{
|
||||
- public static final RegistryNamespaced<ResourceLocation, SoundEvent> field_187505_a = new RegistryNamespaced();
|
||||
+ public static final RegistryNamespaced<ResourceLocation, SoundEvent> field_187505_a = net.minecraftforge.fml.common.registry.GameData.getSoundEventRegistry();
|
||||
private final ResourceLocation field_187506_b;
|
||||
private static int field_187507_c = 0;
|
||||
|
|
@ -17,11 +17,15 @@ import java.util.Map;
|
|||
import com.google.common.collect.HashBiMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionType;
|
||||
import net.minecraft.util.ObjectIntIdentityMap;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.registry.RegistryNamespaced;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
|
@ -31,14 +35,21 @@ import com.google.common.collect.BiMap;
|
|||
|
||||
public class GameData
|
||||
{
|
||||
static final int MIN_BLOCK_ID = 0;
|
||||
static final int MAX_BLOCK_ID = 4095;
|
||||
static final int MIN_ITEM_ID = 4096;
|
||||
static final int MAX_ITEM_ID = 31999;
|
||||
static final int MIN_POTION_ID = 0; // 0-~31 are vanilla, forge start at 32
|
||||
static final int MAX_POTION_ID = 255; // S1DPacketEntityEffect sends bytes, we can only use 255
|
||||
static final int MIN_BIOME_ID = 0; // 0-~31 are vanilla, forge start at 32
|
||||
static final int MAX_BIOME_ID = 255; // S1DPacketEntityEffect sends bytes, we can only use 255
|
||||
private static final int MIN_BLOCK_ID = 0;
|
||||
private static final int MAX_BLOCK_ID = 4095;
|
||||
private static final int MIN_ITEM_ID = 4096;
|
||||
private static final int MAX_ITEM_ID = 31999;
|
||||
private static final int MIN_POTION_ID = 0; // 0-~31 are vanilla, forge start at 32
|
||||
private static final int MAX_POTION_ID = 255; // SPacketEntityEffect sends bytes, we can only use 255
|
||||
private static final int MIN_BIOME_ID = 0;
|
||||
private static final int MAX_BIOME_ID = 255; // Maximum number in a byte in the chunk
|
||||
private static final int MIN_SOUND_ID = 0; // Varint
|
||||
private static final int MAX_SOUND_ID = Integer.MAX_VALUE; // Varint (SPacketSoundEffect)
|
||||
private static final int MIN_POTIONTYPE_ID = 0; // Int
|
||||
private static final int MAX_POTIONTYPE_ID = Integer.MAX_VALUE; // Int (SPacketEffect)
|
||||
private static final int MIN_ENCHANTMENT_ID = 0; // Int
|
||||
private static final int MAX_ENCHANTMENT_ID = Integer.MAX_VALUE; // Int - not serialized as an ID?
|
||||
|
||||
private static final ResourceLocation BLOCK_TO_ITEM = new ResourceLocation("minecraft:blocktoitemmap");
|
||||
private static final ResourceLocation BLOCKSTATE_TO_ID = new ResourceLocation("minecraft:blockstatetoid");
|
||||
|
||||
|
@ -50,51 +61,63 @@ public class GameData
|
|||
iItemRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ITEMS, Item.class, null, MIN_ITEM_ID, MAX_ITEM_ID, true, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE);
|
||||
iPotionRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONS, Potion.class, null, MIN_POTION_ID, MAX_POTION_ID, false, PotionCallbacks.INSTANCE, PotionCallbacks.INSTANCE, PotionCallbacks.INSTANCE);
|
||||
iBiomeRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BIOMES, BiomeGenBase.class, null, MIN_BIOME_ID, MAX_BIOME_ID, false, BiomeCallbacks.INSTANCE, BiomeCallbacks.INSTANCE, BiomeCallbacks.INSTANCE);
|
||||
iSoundEventRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.SOUNDEVENTS, SoundEvent.class, null, MIN_SOUND_ID, MAX_SOUND_ID, false, null, null, null);
|
||||
ResourceLocation WATER = new ResourceLocation("water");
|
||||
iPotionTypeRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONTYPES, PotionType.class, WATER, MIN_POTIONTYPE_ID, MAX_POTIONTYPE_ID, false, null, null, null);
|
||||
iEnchantmentRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ENCHANTMENTS, Enchantment.class, null, MIN_ENCHANTMENT_ID, MAX_ENCHANTMENT_ID, false, null, null, null);
|
||||
}
|
||||
// public api
|
||||
// internal registry objects
|
||||
private final FMLControlledNamespacedRegistry<Block> iBlockRegistry;
|
||||
private final FMLControlledNamespacedRegistry<Item> iItemRegistry;
|
||||
private final FMLControlledNamespacedRegistry<Potion> iPotionRegistry;
|
||||
private final FMLControlledNamespacedRegistry<BiomeGenBase> iBiomeRegistry;
|
||||
private final FMLControlledNamespacedRegistry<SoundEvent> iSoundEventRegistry;
|
||||
private final FMLControlledNamespacedRegistry<PotionType> iPotionTypeRegistry;
|
||||
private final FMLControlledNamespacedRegistry<Enchantment> iEnchantmentRegistry;
|
||||
|
||||
/**
|
||||
* Get the currently active block registry.
|
||||
*
|
||||
* @return Block Registry.
|
||||
*/
|
||||
/** INTERNAL ONLY */
|
||||
@Deprecated
|
||||
public static FMLControlledNamespacedRegistry<Block> getBlockRegistry()
|
||||
{
|
||||
return getMain().iBlockRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently active item registry.
|
||||
*
|
||||
* @return Item Registry.
|
||||
*/
|
||||
/** INTERNAL ONLY */
|
||||
@Deprecated
|
||||
public static FMLControlledNamespacedRegistry<Item> getItemRegistry()
|
||||
{
|
||||
return getMain().iItemRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently active potion registry.
|
||||
*
|
||||
* @return Potion Registry.
|
||||
*/
|
||||
/** INTERNAL ONLY */
|
||||
@Deprecated
|
||||
public static FMLControlledNamespacedRegistry<Potion> getPotionRegistry() {
|
||||
return getMain().iPotionRegistry;
|
||||
}
|
||||
|
||||
/** INTERNAL ONLY */
|
||||
@Deprecated
|
||||
public static FMLControlledNamespacedRegistry<BiomeGenBase> getBiomeRegistry() { return getMain().iBiomeRegistry; }
|
||||
|
||||
/** INTERNAL ONLY */
|
||||
@Deprecated
|
||||
public static FMLControlledNamespacedRegistry<SoundEvent> getSoundEventRegistry() { return getMain().iSoundEventRegistry; }
|
||||
|
||||
/***************************************************
|
||||
* INTERNAL CODE FROM HERE ON DO NOT USE!
|
||||
***************************************************/
|
||||
/** INTERNAL ONLY */
|
||||
@Deprecated
|
||||
public static FMLControlledNamespacedRegistry<PotionType> getPotionTypesRegistry() { return getMain().iPotionTypeRegistry; }
|
||||
|
||||
/** INTERNAL ONLY */
|
||||
@Deprecated
|
||||
public static FMLControlledNamespacedRegistry<Enchantment> getEnchantmentRegistry() { return getMain().iEnchantmentRegistry; }
|
||||
|
||||
@Deprecated
|
||||
static Item findItem(String modId, String name)
|
||||
{
|
||||
return getMain().iItemRegistry.getObject(new ResourceLocation(modId, name));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
static Block findBlock(String modId, String name)
|
||||
{
|
||||
return getMain().iBlockRegistry.getObject(new ResourceLocation(modId, name));
|
||||
|
@ -105,17 +128,13 @@ public class GameData
|
|||
return mainData;
|
||||
}
|
||||
|
||||
// internal registry objects
|
||||
private final FMLControlledNamespacedRegistry<Block> iBlockRegistry;
|
||||
private final FMLControlledNamespacedRegistry<Item> iItemRegistry;
|
||||
private final FMLControlledNamespacedRegistry<Potion> iPotionRegistry;
|
||||
private final FMLControlledNamespacedRegistry<BiomeGenBase> iBiomeRegistry;
|
||||
|
||||
@Deprecated
|
||||
int registerItem(Item item, String name) // from GameRegistry
|
||||
{
|
||||
return iItemRegistry.add(-1, addPrefix(name), item);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
int registerBlock(Block block, String name) // from GameRegistry
|
||||
{
|
||||
return iBlockRegistry.add(-1, addPrefix(name), block);
|
||||
|
|
|
@ -130,6 +130,9 @@ public class PersistentRegistryManager
|
|||
public static final ResourceLocation ITEMS = new ResourceLocation("minecraft:items");
|
||||
public static final ResourceLocation POTIONS = new ResourceLocation("minecraft:potions");
|
||||
public static final ResourceLocation BIOMES = new ResourceLocation("minecraft:biomes");
|
||||
public static final ResourceLocation SOUNDEVENTS = new ResourceLocation("minecraft:soundevents");
|
||||
public static final ResourceLocation POTIONTYPES = new ResourceLocation("minecraft:potiontypes");
|
||||
public static final ResourceLocation ENCHANTMENTS = new ResourceLocation("minecraft:enchantments");
|
||||
|
||||
public static <T extends IForgeRegistryEntry<T>> FMLControlledNamespacedRegistry<T> createRegistry(ResourceLocation registryName, Class<T> registryType, ResourceLocation optionalDefaultKey, int minId, int maxId, boolean hasDelegates, IForgeRegistry.AddCallback<T> addCallback, IForgeRegistry.ClearCallback<T> clearCallback, IForgeRegistry.CreateCallback<T> createCallback)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue