This commit is contained in:
Christian 2013-12-10 17:29:26 -05:00
parent 531334b122
commit 985e4ceb4a
21 changed files with 8 additions and 1200 deletions

View File

@ -55,7 +55,6 @@ import cpw.mods.fml.common.ObfuscationReflectionHelper;
import cpw.mods.fml.common.WrongMinecraftVersionException;
import cpw.mods.fml.common.network.packet.EntitySpawnAdjustmentPacket;
import cpw.mods.fml.common.network.packet.EntitySpawnPacket;
import cpw.mods.fml.common.network.packet.ModMissingPacket;
import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration;
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
import cpw.mods.fml.common.registry.IThrowableEntity;
@ -480,10 +479,9 @@ public class FMLClientHandler implements IFMLSidedHandler
return client.func_71401_C();
}
@Override
public void displayMissingMods(ModMissingPacket modMissingPacket)
public void displayMissingMods(Object modMissingPacket)
{
showGuiScreen(new GuiModsMissingForServer(modMissingPacket));
// showGuiScreen(new GuiModsMissingForServer(modMissingPacket));
}
/**

View File

@ -15,14 +15,14 @@ package cpw.mods.fml.client;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import cpw.mods.fml.common.network.packet.ModMissingPacket;
import cpw.mods.fml.common.MissingModsException;
import cpw.mods.fml.common.versioning.ArtifactVersion;
public class GuiModsMissingForServer extends GuiScreen
{
private ModMissingPacket modsMissing;
private MissingModsException modsMissing;
public GuiModsMissingForServer(ModMissingPacket modsMissing)
public GuiModsMissingForServer(MissingModsException modsMissing)
{
this.modsMissing = modsMissing;
}
@ -46,14 +46,14 @@ public class GuiModsMissingForServer extends GuiScreen
public void func_73863_a(int p_73863_1_, int p_73863_2_, float p_73863_3_)
{
this.func_146276_q_();
int offset = Math.max(85 - modsMissing.getModList().size() * 10, 10);
int offset = Math.max(85 - modsMissing.missingMods.size() * 10, 10);
this.func_73732_a(this.field_146289_q, "Forge Mod Loader could not connect to this server", this.field_146294_l / 2, offset, 0xFFFFFF);
offset += 10;
this.func_73732_a(this.field_146289_q, "The mods and versions listed below could not be found", this.field_146294_l / 2, offset, 0xFFFFFF);
offset += 10;
this.func_73732_a(this.field_146289_q, "They are required to play on this server", this.field_146294_l / 2, offset, 0xFFFFFF);
offset += 5;
for (ArtifactVersion v : modsMissing.getModList())
for (ArtifactVersion v : modsMissing.missingMods)
{
offset += 10;
this.func_73732_a(this.field_146289_q, String.format("%s : %s", v.getLabel(), v.getRangeString()), this.field_146294_l / 2, offset, 0xEEEEEE);

View File

@ -19,7 +19,6 @@ import net.minecraft.network.NetworkManager;
import net.minecraft.server.MinecraftServer;
import cpw.mods.fml.common.network.packet.EntitySpawnAdjustmentPacket;
import cpw.mods.fml.common.network.packet.EntitySpawnPacket;
import cpw.mods.fml.common.network.packet.ModMissingPacket;
import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration;
import cpw.mods.fml.relauncher.Side;
@ -43,8 +42,6 @@ public interface IFMLSidedHandler
MinecraftServer getServer();
void displayMissingMods(ModMissingPacket modMissingPacket);
boolean shouldServerShouldBeKilledQuietly();
void addModAsResource(ModContainer container);

View File

@ -19,7 +19,7 @@ import cpw.mods.fml.common.versioning.ArtifactVersion;
public class MissingModsException extends RuntimeException
{
private static final long serialVersionUID = 1L;
public Set<ArtifactVersion> missingMods;
public final Set<ArtifactVersion> missingMods;
public MissingModsException(Set<ArtifactVersion> missingMods)
{

View File

@ -1,44 +0,0 @@
/*
* Forge Mod Loader
* Copyright (c) 2012-2013 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v2.1
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* cpw - implementation
*/
package cpw.mods.fml.common.asm;
import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.ClassNode;
import cpw.mods.fml.common.registry.BlockProxy;
public class ASMTransformer implements IClassTransformer
{
@Override
public byte[] transform(String name,String transformedName, byte[] bytes)
{
if ("net.minecraft.src.Block".equals(name))
{
ClassReader cr = new ClassReader(bytes);
ClassNode cn = new ClassNode(Opcodes.ASM4);
cr.accept(cn, ClassReader.EXPAND_FRAMES);
cn.interfaces.add(Type.getInternalName(BlockProxy.class));
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
cn.accept(cw);
return cw.toByteArray();
}
return bytes;
}
}

View File

@ -1,33 +0,0 @@
/*
* Forge Mod Loader
* Copyright (c) 2012-2013 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v2.1
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* cpw - implementation
*/
package cpw.mods.fml.common.network;
import net.minecraft.network.packet.*;
public interface IChatListener
{
/**
* Called when there is a chat message received on the server
* @param handler
* @param message
*/
public Packet3Chat serverChat(NetHandler handler, Packet3Chat message);
/**
* Called when there is a chat message recived on the client
*
* @param handler
* @param message
*/
public Packet3Chat clientChat(NetHandler handler, Packet3Chat message);
}

View File

@ -1,84 +0,0 @@
/*
* Forge Mod Loader
* Copyright (c) 2012-2013 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v2.1
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* cpw - implementation
*/
package cpw.mods.fml.common.network;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.NetLoginHandler;
import net.minecraft.network.packet.NetHandler;
import net.minecraft.network.packet.Packet1Login;
import net.minecraft.server.MinecraftServer;
public interface IConnectionHandler
{
/**
* Called when a player logs into the server
* SERVER SIDE
*
* @param player
* @param netHandler
* @param manager
*/
void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager);
/**
* If you don't want the connection to continue, return a non-empty string here
* If you do, you can do other stuff here- note no FML negotiation has occured yet
* though the client is verified as having FML installed
*
* SERVER SIDE
*
* @param netHandler
* @param manager
*/
String connectionReceived(NetLoginHandler netHandler, INetworkManager manager);
/**
* Fired when a remote connection is opened
* CLIENT SIDE
*
* @param netClientHandler
* @param server
* @param port
*/
void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager);
/**
*
* Fired when a local connection is opened
*
* CLIENT SIDE
*
* @param netClientHandler
* @param server
*/
void connectionOpened(NetHandler netClientHandler, MinecraftServer server, INetworkManager manager);
/**
* Fired when a connection closes
*
* ALL SIDES
*
* @param manager
*/
void connectionClosed(INetworkManager manager);
/**
* Fired when the client established the connection to the server
*
* CLIENT SIDE
* @param clientHandler
* @param manager
* @param login
*/
void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login);
}

View File

@ -1,93 +0,0 @@
/*
* Forge Mod Loader
* Copyright (c) 2012-2013 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v2.1
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* cpw - implementation
*/
package cpw.mods.fml.common.network;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet131MapData;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.server.MinecraftServer;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
/**
* A simple utility class to send packet 250 packets around the place
*
* @author cpw
*
*/
public class PacketDispatcher
{
public static Packet250CustomPayload getPacket(String type, byte[] data)
{
return new Packet250CustomPayload(type, data);
}
public static void sendPacketToServer(Packet packet)
{
FMLCommonHandler.instance().getSidedDelegate().sendPacket(packet);
}
public static void sendPacketToPlayer(Packet packet, Player player)
{
if (player instanceof EntityPlayerMP)
{
((EntityPlayerMP)player).field_71135_a.func_72567_b(packet);
}
}
public static void sendPacketToAllAround(double X, double Y, double Z, double range, int dimensionId, Packet packet)
{
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
if (server != null)
{
server.func_71203_ab().func_72393_a(X, Y, Z, range, dimensionId, packet);
}
else
{
FMLLog.fine("Attempt to send packet to all around without a server instance available");
}
}
public static void sendPacketToAllInDimension(Packet packet, int dimId)
{
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
if (server != null)
{
server.func_71203_ab().func_72396_a(packet, dimId);
}
else
{
FMLLog.fine("Attempt to send packet to all in dimension without a server instance available");
}
}
public static void sendPacketToAllPlayers(Packet packet)
{
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
if (server != null)
{
server.func_71203_ab().func_72384_a(packet);
}
else
{
FMLLog.fine("Attempt to send packet to all in dimension without a server instance available");
}
}
public static Packet131MapData getTinyPacket(Object mod, short tag, byte[] data)
{
NetworkModHolder nmh = FMLNetworkHandler.instance().findNetworkModHandler(mod);
return new Packet131MapData((short) nmh.getNetworkId(), tag, data);
}
}

View File

@ -1,23 +0,0 @@
/*
* Forge Mod Loader
* Copyright (c) 2012-2013 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v2.1
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* cpw - implementation
*/
package cpw.mods.fml.common.network;
/**
*
* @author cpw
*
*/
public interface Player
{
}

View File

@ -1,111 +0,0 @@
/*
* Forge Mod Loader
* Copyright (c) 2012-2013 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v2.1
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* cpw - implementation
*/
package cpw.mods.fml.common.network.packet;
import static cpw.mods.fml.common.network.packet.FMLOldPacket.Type.MOD_IDMAP;
import java.io.IOException;
import java.util.Set;
import java.util.logging.Level;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.NetHandler;
import com.google.common.collect.MapDifference;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams;
import com.google.common.primitives.Bytes;
import com.google.common.primitives.UnsignedBytes;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.network.FMLNetworkException;
import cpw.mods.fml.common.network.FMLNetworkHandler;
import cpw.mods.fml.common.registry.GameData;
import cpw.mods.fml.common.registry.ItemData;
public class ModIdMapPacket extends FMLOldPacket {
private byte[][] partials;
public ModIdMapPacket()
{
super(MOD_IDMAP);
}
@Override
public byte[] generatePacketData(Object... data)
{
NBTTagList completeList = (NBTTagList) data[0];
NBTTagCompound wrap = new NBTTagCompound();
wrap.func_74782_a("List", completeList);
try
{
return CompressedStreamTools.func_74798_a(wrap);
}
catch (Exception e)
{
FMLLog.log(Level.SEVERE, e, "A critical error writing the id map");
throw new FMLNetworkException(e);
}
}
@Override
public FMLOldPacket consumePacketData(byte[] data)
{
ByteArrayDataInput bdi = ByteStreams.newDataInput(data);
int chunkIdx = UnsignedBytes.toInt(bdi.readByte());
int chunkTotal = UnsignedBytes.toInt(bdi.readByte());
int chunkLength = bdi.readInt();
if (partials == null)
{
partials = new byte[chunkTotal][];
}
partials[chunkIdx] = new byte[chunkLength];
bdi.readFully(partials[chunkIdx]);
for (int i = 0; i < partials.length; i++)
{
if (partials[i] == null)
{
return null;
}
}
return this;
}
@Override
public void execute(INetworkManager network, FMLNetworkHandler handler, NetHandler netHandler, String userName)
{
byte[] allData = Bytes.concat(partials);
GameData.initializeServerGate(1);
try
{
NBTTagCompound serverList = CompressedStreamTools.func_74792_a(allData);
NBTTagList list = serverList.func_74761_m("List");
Set<ItemData> itemData = GameData.buildWorldItemData(list);
GameData.validateWorldSave(itemData);
MapDifference<Integer, ItemData> serverDifference = GameData.gateWorldLoadingForValidation();
if (serverDifference!=null)
{
FMLCommonHandler.instance().disconnectIDMismatch(serverDifference, netHandler, network);
}
}
catch (IOException e)
{
}
}
}

View File

@ -1,82 +0,0 @@
/*
* Forge Mod Loader
* Copyright (c) 2012-2013 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v2.1
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* cpw - implementation
*/
package cpw.mods.fml.common.network.packet;
import static cpw.mods.fml.common.network.packet.FMLOldPacket.Type.MOD_IDENTIFIERS;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.NetHandler;
import com.google.common.collect.Maps;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import cpw.mods.fml.common.network.FMLNetworkHandler;
import cpw.mods.fml.common.network.NetworkModHolder;
public class ModIdentifiersPacket extends FMLOldPacket
{
private Map<String, Integer> modIds = Maps.newHashMap();
public ModIdentifiersPacket()
{
super(MOD_IDENTIFIERS);
}
@Override
public byte[] generatePacketData(Object... data)
{
ByteArrayDataOutput dat = ByteStreams.newDataOutput();
Collection<NetworkModHolder >networkMods = FMLNetworkHandler.instance().getNetworkIdMap().values();
dat.writeInt(networkMods.size());
for (NetworkModHolder handler : networkMods)
{
dat.writeUTF(handler.getContainer().getModId());
dat.writeInt(handler.getNetworkId());
}
// TODO send the other id maps as well
return dat.toByteArray();
}
@Override
public FMLOldPacket consumePacketData(byte[] data)
{
ByteArrayDataInput dat = ByteStreams.newDataInput(data);
int listSize = dat.readInt();
for (int i = 0; i < listSize; i++)
{
String modId = dat.readUTF();
int networkId = dat.readInt();
modIds.put(modId, networkId);
}
return this;
}
@Override
public void execute(INetworkManager network, FMLNetworkHandler handler, NetHandler netHandler, String userName)
{
for (Entry<String,Integer> idEntry : modIds.entrySet())
{
handler.bindNetworkId(idEntry.getKey(), idEntry.getValue());
}
// TODO other id maps
}
}

View File

@ -1,132 +0,0 @@
/*
* Forge Mod Loader
* Copyright (c) 2012-2013 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v2.1
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* cpw - implementation
*/
package cpw.mods.fml.common.network.packet;
import static cpw.mods.fml.common.network.packet.FMLOldPacket.Type.MOD_LIST_REQUEST;
import static cpw.mods.fml.common.network.packet.FMLOldPacket.Type.MOD_LIST_RESPONSE;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.NetHandler;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.network.FMLNetworkHandler;
import cpw.mods.fml.common.network.NetworkModHolder;
import cpw.mods.fml.common.network.PacketDispatcher;
public class ModListRequestPacket extends FMLOldPacket
{
private List<String> sentModList;
private byte compatibilityLevel;
public ModListRequestPacket()
{
super(MOD_LIST_REQUEST);
}
@Override
public byte[] generatePacketData(Object... data)
{
ByteArrayDataOutput dat = ByteStreams.newDataOutput();
Set<ModContainer> activeMods = FMLNetworkHandler.instance().getNetworkModList();
dat.writeInt(activeMods.size());
for (ModContainer mc : activeMods)
{
dat.writeUTF(mc.getModId());
}
dat.writeByte(FMLNetworkHandler.getCompatibilityLevel());
return dat.toByteArray();
}
@Override
public FMLOldPacket consumePacketData(byte[] data)
{
sentModList = Lists.newArrayList();
ByteArrayDataInput in = ByteStreams.newDataInput(data);
int listSize = in.readInt();
for (int i = 0; i < listSize; i++)
{
sentModList.add(in.readUTF());
}
try
{
compatibilityLevel = in.readByte();
}
catch (IllegalStateException e)
{
FMLLog.fine("No compatibility byte found - the server is too old");
}
return this;
}
/**
*
* This packet is executed on the client to evaluate the server's mod list against
* the client
*
* @see cpw.mods.fml.common.network.packet.FMLOldPacket#execute(INetworkManager, FMLNetworkHandler, NetHandler, String)
*/
@Override
public void execute(INetworkManager mgr, FMLNetworkHandler handler, NetHandler netHandler, String userName)
{
List<String> missingMods = Lists.newArrayList();
Map<String,String> modVersions = Maps.newHashMap();
Map<String, ModContainer> indexedModList = Maps.newHashMap(Loader.instance().getIndexedModList());
for (String m : sentModList)
{
ModContainer mc = indexedModList.get(m);
if (mc == null)
{
missingMods.add(m);
continue;
}
indexedModList.remove(m);
modVersions.put(m, mc.getVersion());
}
if (indexedModList.size()>0)
{
for (Entry<String, ModContainer> e : indexedModList.entrySet())
{
if (e.getValue().isNetworkMod())
{
NetworkModHolder missingHandler = FMLNetworkHandler.instance().findNetworkModHandler(e.getValue());
if (missingHandler.requiresServerSide())
{
// TODO : what should we do if a mod is marked "serverSideRequired"? Stop the connection?
FMLLog.warning("The mod %s was not found on the server you connected to, but requested that the server side be present", e.getKey());
}
}
}
}
FMLLog.fine("The server has compatibility level %d", compatibilityLevel);
FMLCommonHandler.instance().getSidedDelegate().setClientCompatibilityLevel(compatibilityLevel);
mgr.func_74429_a(PacketDispatcher.getPacket("FML", FMLOldPacket.makePacket(MOD_LIST_RESPONSE, modVersions, missingMods)));
}
}

View File

@ -1,159 +0,0 @@
/*
* Forge Mod Loader
* Copyright (c) 2012-2013 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v2.1
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* cpw - implementation
*/
package cpw.mods.fml.common.network.packet;
import static cpw.mods.fml.common.network.packet.FMLOldPacket.Type.MOD_IDENTIFIERS;
import static cpw.mods.fml.common.network.packet.FMLOldPacket.Type.MOD_IDMAP;
import static cpw.mods.fml.common.network.packet.FMLOldPacket.Type.MOD_LIST_RESPONSE;
import static cpw.mods.fml.common.network.packet.FMLOldPacket.Type.MOD_MISSING;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Logger;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.NetLoginHandler;
import net.minecraft.network.packet.NetHandler;
import net.minecraft.network.packet.Packet250CustomPayload;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.network.FMLNetworkHandler;
import cpw.mods.fml.common.network.NetworkModHolder;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.registry.GameData;
public class ModListResponsePacket extends FMLOldPacket
{
private Map<String,String> modVersions;
private List<String> missingMods;
public ModListResponsePacket()
{
super(MOD_LIST_RESPONSE);
}
@Override
public byte[] generatePacketData(Object... data)
{
@SuppressWarnings("unchecked")
Map<String,String> modVersions = (Map<String, String>) data[0];
@SuppressWarnings("unchecked")
List<String> missingMods = (List<String>) data[1];
ByteArrayDataOutput dat = ByteStreams.newDataOutput();
dat.writeInt(modVersions.size());
for (Entry<String, String> version : modVersions.entrySet())
{
dat.writeUTF(version.getKey());
dat.writeUTF(version.getValue());
}
dat.writeInt(missingMods.size());
for (String missing : missingMods)
{
dat.writeUTF(missing);
}
return dat.toByteArray();
}
@Override
public FMLOldPacket consumePacketData(byte[] data)
{
ByteArrayDataInput dat = ByteStreams.newDataInput(data);
int versionListSize = dat.readInt();
modVersions = Maps.newHashMapWithExpectedSize(versionListSize);
for (int i = 0; i < versionListSize; i++)
{
String modName = dat.readUTF();
String modVersion = dat.readUTF();
modVersions.put(modName, modVersion);
}
int missingModSize = dat.readInt();
missingMods = Lists.newArrayListWithExpectedSize(missingModSize);
for (int i = 0; i < missingModSize; i++)
{
missingMods.add(dat.readUTF());
}
return this;
}
@Override
public void execute(INetworkManager network, FMLNetworkHandler handler, NetHandler netHandler, String userName)
{
Map<String, ModContainer> indexedModList = Maps.newHashMap(Loader.instance().getIndexedModList());
List<String> missingClientMods = Lists.newArrayList();
List<String> versionIncorrectMods = Lists.newArrayList();
for (String m : missingMods)
{
ModContainer mc = indexedModList.get(m);
NetworkModHolder networkMod = handler.findNetworkModHandler(mc);
if (networkMod.requiresClientSide())
{
missingClientMods.add(m);
}
}
for (Entry<String,String> modVersion : modVersions.entrySet())
{
ModContainer mc = indexedModList.get(modVersion.getKey());
NetworkModHolder networkMod = handler.findNetworkModHandler(mc);
if (!networkMod.acceptVersion(modVersion.getValue()))
{
versionIncorrectMods.add(modVersion.getKey());
}
}
Packet250CustomPayload pkt = new Packet250CustomPayload();
pkt.field_73630_a = "FML";
if (missingClientMods.size()>0 || versionIncorrectMods.size() > 0)
{
pkt.field_73629_c = FMLOldPacket.makePacket(MOD_MISSING, missingClientMods, versionIncorrectMods);
Logger.getLogger("Minecraft").info(String.format("User %s connection failed: missing %s, bad versions %s", userName, missingClientMods, versionIncorrectMods));
FMLLog.info("User %s connection failed: missing %s, bad versions %s", userName, missingClientMods, versionIncorrectMods);
// Mark this as bad
FMLNetworkHandler.setHandlerState((NetLoginHandler) netHandler, FMLNetworkHandler.MISSING_MODS_OR_VERSIONS);
pkt.field_73628_b = pkt.field_73629_c.length;
network.func_74429_a(pkt);
}
else
{
pkt.field_73629_c = FMLOldPacket.makePacket(MOD_IDENTIFIERS, netHandler);
Logger.getLogger("Minecraft").info(String.format("User %s connecting with mods %s", userName, modVersions.keySet()));
FMLLog.info("User %s connecting with mods %s", userName, modVersions.keySet());
pkt.field_73628_b = pkt.field_73629_c.length;
network.func_74429_a(pkt);
NBTTagList itemList = new NBTTagList();
GameData.writeItemData(itemList);
byte[][] registryPackets = FMLOldPacket.makePacketSet(MOD_IDMAP, itemList);
for (int i = 0; i < registryPackets.length; i++)
{
network.func_74429_a(PacketDispatcher.getPacket("FML", registryPackets[i]));
}
}
// reset the continuation flag - we have completed extra negotiation and the login should complete now
NetLoginHandler.func_72531_a((NetLoginHandler) netHandler, true);
}
}

View File

@ -1,123 +0,0 @@
/*
* Forge Mod Loader
* Copyright (c) 2012-2013 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v2.1
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* cpw - implementation
*/
package cpw.mods.fml.common.network.packet;
import java.util.List;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
import com.google.common.collect.Lists;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.network.FMLNetworkHandler;
import cpw.mods.fml.common.versioning.ArtifactVersion;
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
import cpw.mods.fml.common.versioning.VersionRange;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.NetHandler;
public class ModMissingPacket extends FMLOldPacket
{
private List<ModData> missing;
private List<ModData> badVersion;
public ModMissingPacket()
{
super(Type.MOD_MISSING);
}
@Override
public byte[] generatePacketData(Object... data)
{
ByteArrayDataOutput dat = ByteStreams.newDataOutput();
@SuppressWarnings("unchecked")
List<String> missing = (List<String>) data[0];
@SuppressWarnings("unchecked")
List<String> badVersion = (List<String>) data[1];
dat.writeInt(missing.size());
for (String missed : missing)
{
ModContainer mc = Loader.instance().getIndexedModList().get(missed);
dat.writeUTF(missed);
dat.writeUTF(mc.getVersion());
}
dat.writeInt(badVersion.size());
for (String bad : badVersion)
{
ModContainer mc = Loader.instance().getIndexedModList().get(bad);
dat.writeUTF(bad);
dat.writeUTF(mc.getVersion());
}
return dat.toByteArray();
}
private static class ModData
{
String modId;
String modVersion;
}
@Override
public FMLOldPacket consumePacketData(byte[] data)
{
ByteArrayDataInput dat = ByteStreams.newDataInput(data);
int missingLen = dat.readInt();
missing = Lists.newArrayListWithCapacity(missingLen);
for (int i = 0; i < missingLen; i++)
{
ModData md = new ModData();
md.modId = dat.readUTF();
md.modVersion = dat.readUTF();
missing.add(md);
}
int badVerLength = dat.readInt();
badVersion = Lists.newArrayListWithCapacity(badVerLength);
for (int i = 0; i < badVerLength; i++)
{
ModData md = new ModData();
md.modId = dat.readUTF();
md.modVersion = dat.readUTF();
badVersion.add(md);
}
return this;
}
@Override
public void execute(INetworkManager network, FMLNetworkHandler handler, NetHandler netHandler, String userName)
{
FMLCommonHandler.instance().getSidedDelegate().displayMissingMods(this);
}
public List<ArtifactVersion> getModList()
{
Builder<ArtifactVersion> builder = ImmutableList.<ArtifactVersion>builder();
for (ModData md : missing)
{
builder.add(new DefaultArtifactVersion(md.modId, VersionRange.createFromVersion(md.modVersion, null)));
}
for (ModData md : badVersion)
{
builder.add(new DefaultArtifactVersion(md.modId, VersionRange.createFromVersion(md.modVersion, null)));
}
return builder.build();
}
}

View File

@ -1,73 +0,0 @@
package cpw.mods.fml.common.network.packet;
import java.util.Arrays;
import java.util.Map;
import java.util.concurrent.Callable;
import net.minecraft.network.INetHandler;
import net.minecraft.network.play.client.C17PacketCustomPayload;
import net.minecraft.network.play.server.S3FPacketCustomPayload;
import com.google.common.collect.Maps;
import com.google.common.primitives.UnsignedBytes;
import cpw.mods.fml.common.network.handshake.NetworkDispatcher;
import cpw.mods.fml.common.network.packet.FMLOldPacket.Type;
public enum PacketManager {
INSTANCE;
private Map<Class<? extends FMLOldPacket>, PacketExecutor<?,?>> packetExecutors = Maps.newHashMap();
public C17PacketCustomPayload makeGuiPacket(int windowId, int i, int modGuiId, int x, int y, int z)
{
byte[] data = FMLOldPacket.makePacket(Type.GUIOPEN, windowId, i, modGuiId, x, y, z);
C17PacketCustomPayload packet = new C17PacketCustomPayload("FML", data);
return packet;
}
public FMLOldPacket readPacket(NetworkDispatcher dispatcher, C17PacketCustomPayload clientSentPacket)
{
byte[] payload = clientSentPacket.func_149558_e();
return buildPacket(dispatcher, payload);
}
public FMLOldPacket readPacket(NetworkDispatcher dispatcher, S3FPacketCustomPayload serverSentPacket)
{
byte[] payload = serverSentPacket.func_149168_d();
return buildPacket(dispatcher, payload);
}
private FMLOldPacket buildPacket(NetworkDispatcher dispatcher, byte[] payload)
{
int type = UnsignedBytes.toInt(payload[0]);
Type eType = Type.values()[type];
FMLOldPacket pkt;
if (eType.isMultipart())
{
pkt = eType.findCurrentPart(network);
}
else
{
pkt = eType.make();
}
return pkt.consumePacketData(Arrays.copyOfRange(payload, 1, payload.length));
}
static abstract class PacketExecutor<P, T extends INetHandler> implements Callable<Void>
{
P packet;
T netHandler;
}
public Packet makeFMLHandshake()
{
// TODO Auto-generated method stub
return null;
}
}

View File

@ -1,18 +0,0 @@
/*
* Forge Mod Loader
* Copyright (c) 2012-2013 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v2.1
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* cpw - implementation
*/
package cpw.mods.fml.common.registry;
public interface BlockProxy
{
}

View File

@ -55,18 +55,6 @@ public class GameData {
return idMapping;
}
public static Set<ItemData> buildWorldItemData(NBTTagList modList)
{
Set<ItemData> worldSaveItems = Sets.newHashSet();
for (int i = 0; i < modList.func_74745_c(); i++)
{
NBTTagCompound mod = modList.func_150305_b(i);
ItemData dat = new ItemData(mod);
worldSaveItems.add(dat);
}
return worldSaveItems;
}
static Item findItem(String modId, String name)
{
return (Item) itemRegistry.func_82594_a(modId + ":" + name);

View File

@ -1,167 +0,0 @@
/*
* Forge Mod Loader
* Copyright (c) 2012-2013 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v2.1
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* cpw - implementation
*/
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;
import com.google.common.collect.HashMultiset;
import com.google.common.collect.Maps;
import com.google.common.collect.Multiset;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.LoaderException;
import cpw.mods.fml.common.ModContainer;
public class ItemData {
private static Map<String, Multiset<String>> modOrdinals = Maps.newHashMap();
private final String modId;
private final String itemType;
private final int itemId;
private final int ordinal;
private String forcedModId;
private String forcedName;
public ItemData(Item item, ModContainer mc)
{
this.itemId = item.field_77779_bT;
if (item.getClass().equals(ItemBlock.class))
{
this.itemType = Block.field_71973_m[this.getItemId()].getClass().getName();
}
else
{
this.itemType = item.getClass().getName();
}
this.modId = mc.getModId();
if (!modOrdinals.containsKey(mc.getModId()))
{
modOrdinals.put(mc.getModId(), HashMultiset.<String>create());
}
this.ordinal = modOrdinals.get(mc.getModId()).add(itemType, 1);
}
public ItemData(NBTTagCompound tag)
{
this.modId = tag.func_74779_i("ModId");
this.itemType = tag.func_74779_i("ItemType");
this.itemId = tag.func_74762_e("ItemId");
this.ordinal = tag.func_74762_e("ordinal");
this.forcedModId = tag.func_74764_b("ForcedModId") ? tag.func_74779_i("ForcedModId") : null;
this.forcedName = tag.func_74764_b("ForcedName") ? tag.func_74779_i("ForcedName") : null;
}
public String getItemType()
{
return this.forcedName !=null ? forcedName : itemType;
}
public String getModId()
{
return this.forcedModId != null ? forcedModId : modId;
}
public int getOrdinal()
{
return ordinal;
}
public int getItemId()
{
return itemId;
}
public NBTTagCompound toNBT()
{
NBTTagCompound tag = new NBTTagCompound();
tag.func_74778_a("ModId", modId);
tag.func_74778_a("ItemType", itemType);
tag.func_74768_a("ItemId", itemId);
tag.func_74768_a("ordinal", ordinal);
if (forcedModId != null)
{
tag.func_74778_a("ForcedModId", forcedModId);
}
if (forcedName != null)
{
tag.func_74778_a("ForcedName", forcedName);
}
return tag;
}
@Override
public int hashCode()
{
return Objects.hashCode(itemId, ordinal);
}
@Override
public boolean equals(Object obj)
{
try
{
ItemData other = (ItemData) obj;
return Objects.equal(getModId(), other.getModId()) && Objects.equal(getItemType(), other.getItemType()) && Objects.equal(itemId, other.itemId) && ( isOveridden() || Objects.equal(ordinal, other.ordinal));
}
catch (ClassCastException cce)
{
return false;
}
}
@Override
public String toString()
{
return String.format("Item %d, Type %s, owned by %s, ordinal %d, name %s, claimedModId %s", itemId, itemType, modId, ordinal, forcedName, forcedModId);
}
public boolean mayDifferByOrdinal(ItemData rightValue)
{
return Objects.equal(getItemType(), rightValue.getItemType()) && Objects.equal(getModId(), rightValue.getModId());
}
public boolean isOveridden()
{
return forcedName != null;
}
public void setName(String name, String modId)
{
if (name == null)
{
this.forcedName = null;
this.forcedModId = null;
return;
}
String localModId = modId;
if (modId == null)
{
localModId = Loader.instance().activeModContainer().getModId();
}
if (modOrdinals.get(localModId).count(name)>0)
{
FMLLog.severe("The mod %s is attempting to redefine the item at id %d with a non-unique name (%s.%s)", Loader.instance().activeModContainer(), itemId, localModId, name);
throw new LoaderException();
}
modOrdinals.get(localModId).add(name);
this.forcedModId = modId;
this.forcedName = name;
}
}

View File

@ -1,18 +0,0 @@
/*
* Forge Mod Loader
* Copyright (c) 2012-2013 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v2.1
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* cpw - implementation
*/
package cpw.mods.fml.common.registry;
public interface ItemProxy
{
}

View File

@ -36,7 +36,6 @@ import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.network.packet.EntitySpawnAdjustmentPacket;
import cpw.mods.fml.common.network.packet.EntitySpawnPacket;
import cpw.mods.fml.common.network.packet.ModMissingPacket;
import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
@ -156,11 +155,6 @@ public class FMLServerHandler implements IFMLSidedHandler
// NOOP
}
@Override
public void displayMissingMods(ModMissingPacket modMissingPacket)
{
// NOOP on server
}
@Override
public boolean shouldServerShouldBeKilledQuietly()
{
return false;

View File

@ -1,12 +1,3 @@
# Marker interfaces to add to minecraft - helps in bukkit and client/server unification
# Only runs at runtime because it's not necessary at compile time
# has deobf and obf mappings so it runs OK in mcp
# entityplayer -> network/player
uf cpw/mods/fml/common/network/Player
net.minecraft.entity.player.EntityPlayer cpw/mods/fml/common/network/Player
# block -> blockproxy
aqz cpw/mods/fml/common/registry/BlockProxy
net.minecraft.block.Block cpw/mods/fml/common/registry/BlockProxy
# item -> itemproxy
yc cpw/mods/fml/common/registry/ItemProxy
net.minecraft.item.Item cpw/mods/fml/common/registry/ItemProxy