Change ID management slightly. IDs are tracked by block type for itemblock items now. This means servers will need to update.

Also, ordinal rearrangements within a mod will no longer trigger server disconnection, though a warning will still be logged.
This commit is contained in:
Christian committed 2012-12-12 19:31:05 -05:00
1 parent 0423fa5885
commit 22a88ea2e4
3 files changed
+42 -1

No files matched your search

@@ -74,8 +74,12 @@ public class GameData {
Map<Integer,ItemData> worldMap = Maps.uniqueIndex(worldSaveItems,idMapFunction);
difference = Maps.difference(worldMap, idMap);
FMLLog.fine("The difference set is %s", difference);
if (!difference.entriesDiffering().isEmpty() || !difference.entriesOnlyOnLeft().isEmpty())
{
FMLLog.severe("FML has detected item discrepancies");
FMLLog.severe("Missing items : %s", difference.entriesOnlyOnLeft());
FMLLog.severe("Mismatched items : %s", difference.entriesDiffering());
isSaveValid = false;
serverValidationLatch.countDown();
}
@@ -2,7 +2,9 @@ package cpw.mods.fml.common.registry;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.nbt.NBTTagCompound;
import com.google.common.base.Objects;
@@ -23,7 +25,14 @@ public class ItemData {
public ItemData(Item item, ModContainer mc)
{
this.itemId = item.field_77779_bT;
this.itemType = item.getClass().getName();
if (item.getClass().equals(ItemBlock.class))
{
this.itemType = Block.field_71973_m[this.itemId].getClass().getName();
}
else
{
this.itemType = item.getClass().getName();
}
this.modId = mc.getModId();
if (!modOrdinals.containsKey(mc.getModId()))
{
@@ -69,4 +78,15 @@ public class ItemData {
return false;
}
}
@Override
public String toString()
{
return String.format("Item %d, Type %s, owned by %s, ordinal %d", itemId, itemType, modId, ordinal);
}
public boolean mayDifferByOrdinal(ItemData rightValue)
{
return Objects.equal(itemType, rightValue.itemType) && Objects.equal(modId, rightValue.modId);
}
}