mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 03:49:14 +00:00
Try and make sure active substitutions are immediately available in the block to item map.
This commit is contained in:
1 parent
95825e5de0
commit
a54b939ea3
2 files changed
+19
-5
No files matched your search
+3
-1
@@ -565,7 +565,7 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespacedDefaul
|
||||
}
|
||||
}
|
||||
|
||||
void activateSubstitution(ResourceLocation nameToReplace)
|
||||
I activateSubstitution(ResourceLocation nameToReplace)
|
||||
{
|
||||
if (getPersistentSubstitutions().containsKey(nameToReplace))
|
||||
{
|
||||
@@ -573,7 +573,9 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespacedDefaul
|
||||
I sub = getPersistentSubstitutions().get(nameToReplace);
|
||||
getExistingDelegate(original).changeReference(sub);
|
||||
activeSubstitutions.put(nameToReplace, sub);
|
||||
return original;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void addSubstitutionAlias(String modId, ResourceLocation nameToReplace, I replacement) throws ExistingSubstitutionException
|
||||
|
||||
@@ -14,6 +14,8 @@ package net.minecraftforge.fml.common.registry;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -190,16 +192,26 @@ public class GameData
|
||||
if (type == GameRegistry.Type.BLOCK)
|
||||
{
|
||||
iBlockRegistry.addSubstitutionAlias(Loader.instance().activeModContainer().getModId(), nameToSubstitute, (Block)toReplace);
|
||||
iBlockRegistry.activateSubstitution(nameToSubstitute);
|
||||
Block orig = iBlockRegistry.activateSubstitution(nameToSubstitute);
|
||||
if (BLOCK_TO_ITEM.containsKey(orig))
|
||||
{
|
||||
Item i = BLOCK_TO_ITEM.get(orig);
|
||||
BLOCK_TO_ITEM.forcePut((Block)toReplace,i);
|
||||
}
|
||||
}
|
||||
else if (type == GameRegistry.Type.ITEM)
|
||||
{
|
||||
iItemRegistry.addSubstitutionAlias(Loader.instance().activeModContainer().getModId(), nameToSubstitute, (Item)toReplace);
|
||||
iItemRegistry.activateSubstitution(nameToSubstitute);
|
||||
Item orig = iItemRegistry.activateSubstitution(nameToSubstitute);
|
||||
if (BLOCK_TO_ITEM.containsValue(orig))
|
||||
{
|
||||
Block b = BLOCK_TO_ITEM.inverse().get(orig);
|
||||
BLOCK_TO_ITEM.forcePut(b, (Item)toReplace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<Block, Item> BLOCK_TO_ITEM = Maps.newHashMap();
|
||||
private static BiMap<Block, Item> BLOCK_TO_ITEM = HashBiMap.create();
|
||||
|
||||
//Internal: DO NOT USE, will change without warning.
|
||||
public static Map getBlockItemMap()
|
||||
@@ -254,7 +266,7 @@ public class GameData
|
||||
if (item instanceof ItemBlock)
|
||||
{
|
||||
ItemBlock itemBlock = (ItemBlock)item;
|
||||
BLOCK_TO_ITEM.put(itemBlock.getBlock().delegate.get(), item);
|
||||
BLOCK_TO_ITEM.forcePut(itemBlock.getBlock().delegate.get(), item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user