Fix substitutions being broken after freezing - actually store the original state in registry copies, not the computed state, which is wrong because it only sees the sub, not the original.

This commit is contained in:
cpw committed 2016-10-10 15:04:45 -04:00
1 parent 5f06c95cfa
commit d7dda9e960
2 files changed
+31 -1

No files matched your search

@@ -27,7 +27,11 @@ public class SubstitutionInjectionTest
{
private ResourceLocation myDirt = new ResourceLocation("minecraft:dirt");
private BlockDirt toSub = new BlockDirt() {
@Override
public String toString()
{
return "SUB" + super.toString() + "SUB";
}
};
@BeforeClass
@@ -103,5 +107,29 @@ public class SubstitutionInjectionTest
assertEquals("Got my dirt substitute - registry", toSub, fnd);
dirtitem = (ItemBlock)itemRegistry.getValue(myDirt);
assertEquals("ItemBlock points at my block", toSub, dirtitem.block);
// TEST 2 repeat: Does the substitute get injected when told by loading operation? The substitute should be found in the registry
PersistentRegistryManager.injectSnapshot(snapshot, true, true);
ObjectHolderRegistry.INSTANCE.applyObjectHolders();
fnd = blockRegistry.getValue(myDirt);
currDirt = Blocks.DIRT;
assertEquals("Got my dirt substitute - Blocks", toSub, currDirt);
assertEquals("Got my dirt substitute - Blocks and registry", currDirt, fnd);
assertEquals("Got my dirt substitute - registry", toSub, fnd);
dirtitem = (ItemBlock)itemRegistry.getValue(myDirt);
assertEquals("ItemBlock points at my block", toSub, dirtitem.block);
// TEST 3 repeat: Does the substitute get restored when reverting to frozen state? The substitute should be found in the registry again
PersistentRegistryManager.revertToFrozen();
ObjectHolderRegistry.INSTANCE.applyObjectHolders();
fnd = blockRegistry.getValue(myDirt);
currDirt = Blocks.DIRT;
assertEquals("Got my dirt substitute - Blocks", toSub, currDirt);
assertEquals("Got my dirt substitute - Blocks and registry", currDirt, fnd);
assertEquals("Got my dirt substitute - registry", toSub, fnd);
dirtitem = (ItemBlock)itemRegistry.getValue(myDirt);
assertEquals("ItemBlock points at my block", toSub, dirtitem.block);
}
}