Fix RegistryManager#getRegistry not working for generic registry entries

This commit is contained in:
tterrag 2019-02-14 18:50:15 -05:00
parent 9d56309a05
commit 2ec74e5c22
2 changed files with 3 additions and 5 deletions

View File

@ -24,7 +24,6 @@ import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.EntityType;
import net.minecraft.init.Bootstrap;
import net.minecraft.item.Item;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionType;
import net.minecraft.tileentity.TileEntityType;
@ -40,7 +39,6 @@ import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfessio
* Created to have a central place to access the registries directly if modders need.
* It is still advised that if you are registering things to go through {@link GameRegistry} register methods, but queries and iterations can use this.
*/
@SuppressWarnings("unchecked")
public class ForgeRegistries
{
static { init(); } // This must be above the fields so we guarantee it's run before findRegistry is called. Yay static inializers
@ -53,8 +51,8 @@ public class ForgeRegistries
public static final IForgeRegistry<PotionType> POTION_TYPES = RegistryManager.ACTIVE.getRegistry(PotionType.class);
public static final IForgeRegistry<Enchantment> ENCHANTMENTS = RegistryManager.ACTIVE.getRegistry(Enchantment.class);
public static final IForgeRegistry<VillagerProfession> VILLAGER_PROFESSIONS = RegistryManager.ACTIVE.getRegistry(VillagerProfession.class);
public static final IForgeRegistry<EntityType<?>> ENTITIES = (IForgeRegistry)RegistryManager.ACTIVE.getRegistry(EntityType.class); //Untyped casys needed to fix javac issues.
public static final IForgeRegistry<TileEntityType<?>> TILE_ENTITIES = (IForgeRegistry)RegistryManager.ACTIVE.getRegistry(TileEntityType.class);
public static final IForgeRegistry<EntityType<?>> ENTITIES = RegistryManager.ACTIVE.getRegistry(EntityType.class); //Untyped casys needed to fix javac issues.
public static final IForgeRegistry<TileEntityType<?>> TILE_ENTITIES = RegistryManager.ACTIVE.getRegistry(TileEntityType.class);
public static final IForgeRegistry<ModDimension> MOD_DIMENSIONS = RegistryManager.ACTIVE.getRegistry(ModDimension.class);
/**
* This function is just to make sure static inializers in other classes have run and setup their registries before we query them.

View File

@ -73,7 +73,7 @@ public class RegistryManager
return (ForgeRegistry<V>)this.registries.get(key);
}
public <V extends IForgeRegistryEntry<V>> IForgeRegistry<V> getRegistry(Class<V> cls)
public <V extends IForgeRegistryEntry<V>> IForgeRegistry<V> getRegistry(Class<? super V> cls)
{
return getRegistry(superTypes.get(cls));
}