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:
parent
d13187d689
commit
1dcf3bfbdc
3 changed files with 42 additions and 1 deletions
|
@ -17,6 +17,7 @@ import java.util.Arrays;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
@ -42,6 +43,7 @@ import com.google.common.base.Throwables;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.MapDifference;
|
||||
import com.google.common.collect.MapDifference.ValueDifference;
|
||||
|
||||
import cpw.mods.fml.client.modloader.ModLoaderClientHelper;
|
||||
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
||||
|
@ -502,6 +504,21 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
@Override
|
||||
public void disconnectIDMismatch(MapDifference<Integer, ItemData> s, NetHandler toKill, INetworkManager mgr)
|
||||
{
|
||||
boolean criticalMismatch = !s.entriesOnlyOnLeft().isEmpty();
|
||||
for (Entry<Integer, ValueDifference<ItemData>> mismatch : s.entriesDiffering().entrySet())
|
||||
{
|
||||
ValueDifference<ItemData> vd = mismatch.getValue();
|
||||
if (!vd.leftValue().mayDifferByOrdinal(vd.rightValue()))
|
||||
{
|
||||
criticalMismatch = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!criticalMismatch)
|
||||
{
|
||||
// We'll carry on with this connection, and just log a message instead
|
||||
return;
|
||||
}
|
||||
// Nuke the connection
|
||||
((NetClientHandler)toKill).func_72553_e();
|
||||
// Stop GuiConnecting
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue