mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-16 01:55:06 +00:00
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:
1 parent
0423fa5885
commit
22a88ea2e4
3 files changed
+42
-1
No files matched your search
@@ -17,6 +17,7 @@ import java.util.Arrays;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.MapDifference;
|
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.modloader.ModLoaderClientHelper;
|
||||||
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
||||||
@@ -502,6 +504,21 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||||||
@Override
|
@Override
|
||||||
public void disconnectIDMismatch(MapDifference<Integer, ItemData> s, NetHandler toKill, INetworkManager mgr)
|
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
|
// Nuke the connection
|
||||||
((NetClientHandler)toKill).func_72553_e();
|
((NetClientHandler)toKill).func_72553_e();
|
||||||
// Stop GuiConnecting
|
// Stop GuiConnecting
|
||||||
|
|||||||
@@ -74,8 +74,12 @@ public class GameData {
|
|||||||
|
|
||||||
Map<Integer,ItemData> worldMap = Maps.uniqueIndex(worldSaveItems,idMapFunction);
|
Map<Integer,ItemData> worldMap = Maps.uniqueIndex(worldSaveItems,idMapFunction);
|
||||||
difference = Maps.difference(worldMap, idMap);
|
difference = Maps.difference(worldMap, idMap);
|
||||||
|
FMLLog.fine("The difference set is %s", difference);
|
||||||
if (!difference.entriesDiffering().isEmpty() || !difference.entriesOnlyOnLeft().isEmpty())
|
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;
|
isSaveValid = false;
|
||||||
serverValidationLatch.countDown();
|
serverValidationLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package cpw.mods.fml.common.registry;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
@@ -23,7 +25,14 @@ public class ItemData {
|
|||||||
public ItemData(Item item, ModContainer mc)
|
public ItemData(Item item, ModContainer mc)
|
||||||
{
|
{
|
||||||
this.itemId = item.field_77779_bT;
|
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();
|
this.modId = mc.getModId();
|
||||||
if (!modOrdinals.containsKey(mc.getModId()))
|
if (!modOrdinals.containsKey(mc.getModId()))
|
||||||
{
|
{
|
||||||
@@ -69,4 +78,15 @@ public class ItemData {
|
|||||||
return false;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user