diff --git a/fml/install/CREDITS-fml.txt b/fml/CREDITS-fml.txt similarity index 100% rename from fml/install/CREDITS-fml.txt rename to fml/CREDITS-fml.txt diff --git a/fml/FML152.json b/fml/FML152.json deleted file mode 100644 index 278cf72354..0000000000 --- a/fml/FML152.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "id": "FML152", - "time": "2013-03-20T12:00:00-04:00", - "releaseTime": "2013-03-20T12:00:00-04:00", - "type": "release", - "minecraftArguments": "${auth_player_name} ${auth_session} --gameDir ${game_directory} --assetsDir ${game_assets} --tweakClass cpw.mods.fml.common.launcher.FMLTweaker", - "libraries": [ - { - "name": "cpw.mods:fml:5.2" - }, - { - "name": "net.minecraft:launchwrapper:1.3" - }, - { - "name": "net.sf.jopt-simple:jopt-simple:4.5" - }, - { - "name": "argo:argo:2.25_fixed" - }, - { - "name": "org.ow2.asm:asm-all:4.1" - }, - { - "name": "org.lwjgl.lwjgl:lwjgl:2.9.0" - }, - { - "name": "org.lwjgl.lwjgl:lwjgl_util:2.9.0" - }, - { - "name": "net.java.jinput:jinput:2.0.5" - }, - { - "name": "org.bouncycastle:bcprov-jdk15on:1.47" - }, - { - "name": "com.google.guava:guava:14.0" - }, - { - "name": "net.java.jutils:jutils:1.0.0" - }, - { - "name": "org.lwjgl.lwjgl:lwjgl-platform:2.9.0", - "natives": { - "linux": "natives-linux", - "windows": "natives-windows", - "osx": "natives-osx" - }, - "extract": { - "exclude": [ - "META-INF/" - ] - } - }, - { - "name": "net.java.jinput:jinput-platform:2.0.5", - "natives": { - "linux": "natives-linux", - "windows": "natives-windows", - "osx": "natives-osx" - }, - "extract": { - "exclude": [ - "META-INF/" - ] - } - } - ], - "mainClass": "net.minecraft.launchwrapper.Launch" -} diff --git a/fml/install/README.txt b/fml/README.txt old mode 100755 new mode 100644 similarity index 100% rename from fml/install/README.txt rename to fml/README.txt diff --git a/fml/applypatches.py b/fml/applypatches.py deleted file mode 100644 index cec544de14..0000000000 --- a/fml/applypatches.py +++ /dev/null @@ -1,14 +0,0 @@ -import os, sys - -def main(): - fml_dir = os.path.abspath(sys.argv[1]) - work_dir = os.path.normpath(sys.argv[2]) - mcp_dir = os.path.normpath(sys.argv[3]) - - sys.path.append(os.path.join(fml_dir, 'install')) - from fml import apply_fml_patches - - apply_fml_patches(fml_dir, mcp_dir, work_dir, False) - -if __name__ == '__main__': - main() diff --git a/fml/build.xml b/fml/build.xml deleted file mode 100644 index 7f4eff29bd..0000000000 --- a/fml/build.xml +++ /dev/null @@ -1,473 +0,0 @@ - - - - The Forge Mod Loader - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - You have decided not to continue. This script will stop now. - Preparing the MCP environment at ${mcp.home} - - Moving old patched sources at ${patch.mcp.srcdir} out of the way - - - - Deleting old patch references at ${clean.mcp.srcdir} - - Creating new patch references at ${clean.mcp.srcdir} - - - - - - Creating clean patched references at ${patch.mcp.srcdir} - - - - - - - - - - - - - Setup complete! You should now be able to open ${basedir}/eclipse as a workspace in eclipse and import/refresh the FML project - - - - - - - - - - - - - - - - - - - - - - - - - Moving old patched sources at ${mcp.home}/src-work out of the way - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - A patch is out of date. Update your patches! - - - - - - - - - - - - - - Extracting fresh eclipse workspace to ${basedir}/eclipse - - - - - - - - - - - - - - - - - - - - - - - - - ${env.JENKINS_HOME} ${universal.jarname} ${sign.KEYPASS} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/fml/bukkit/cpw/mods/fml/server/FMLBukkitHandler.java b/fml/bukkit/cpw/mods/fml/server/FMLBukkitHandler.java deleted file mode 100644 index 4440bd5215..0000000000 --- a/fml/bukkit/cpw/mods/fml/server/FMLBukkitHandler.java +++ /dev/null @@ -1,637 +0,0 @@ -/* - * The FML Forge Mod Loader suite. Copyright (C) 2012 cpw - * - * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -package cpw.mods.fml.server; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.List; -import java.util.Properties; -import java.util.Random; -import java.util.logging.Logger; - -import org.bukkit.Material; - -import net.minecraft.server.Block; -import net.minecraft.server.Item; -import net.minecraft.server.LocaleLanguage; -import net.minecraft.server.MLProp; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.BaseMod; -import net.minecraft.server.BiomeBase; -import net.minecraft.server.EntityItem; -import net.minecraft.server.EntityHuman; -import net.minecraft.server.IChunkProvider; -import net.minecraft.server.ICommandListener; -import net.minecraft.server.IInventory; -import net.minecraft.server.ItemStack; -import net.minecraft.server.NetworkManager; -import net.minecraft.server.Packet1Login; -import net.minecraft.server.Packet250CustomPayload; -import net.minecraft.server.Packet3Chat; -import net.minecraft.server.BukkitRegistry; -import net.minecraft.server.SidedProxy; -import net.minecraft.server.World; -import net.minecraft.server.WorldType; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.IFMLSidedHandler; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.ModContainer; -import cpw.mods.fml.common.ModMetadata; -import cpw.mods.fml.common.ProxyInjector; -import cpw.mods.fml.common.Side; -import cpw.mods.fml.common.TickType; -import cpw.mods.fml.common.modloader.ModLoaderModContainer; -import cpw.mods.fml.common.modloader.ModProperty; -import cpw.mods.fml.common.registry.FMLRegistry; - -/** - * Handles primary communication from hooked code into the system - * - * The FML entry point is {@link #onPreLoad(MinecraftServer)} called from {@link MinecraftServer} - * - * Obfuscated code should focus on this class and other members of the "server" (or "client") code - * - * The actual mod loading is handled at arms length by {@link Loader} - * - * It is expected that a similar class will exist for each target environment: Bukkit and Client side. - * - * It should not be directly modified. - * - * @author cpw - * - */ -public class FMLBukkitHandler implements IFMLSidedHandler -{ - /** - * The singleton - */ - private static final FMLBukkitHandler INSTANCE = new FMLBukkitHandler(); - - /** - * A reference to the server itself - */ - private MinecraftServer server; - - /** - * A handy list of the default overworld biomes - */ - private BiomeBase[] defaultOverworldBiomes; - - FMLBukkitProfiler profiler; - - /** - * Called to start the whole game off from {@link MinecraftServer#startServer} - * @param minecraftServer - */ - public void onPreLoad(MinecraftServer minecraftServer) - { - try - { - Class.forName("BaseModMp", false, getClass().getClassLoader()); - MinecraftServer.log.severe("" - + "Forge Mod Loader has detected that this server has an ModLoaderMP installed alongside Forge Mod Loader.\n" - + "This will cause a serious problem with compatibility. To protect your worlds, this minecraft server will now shutdown.\n" - + "You should follow the installation instructions of either Minecraft Forge of Forge Mod Loader and NOT install ModLoaderMP \n" - + "into the minecraft_server.jar file " - + "before this server will be allowed to start up.\n\nFailure to do so will simply result in more startup failures.\n\n" - + "The authors of Minecraft Forge and Forge Mod Loader strongly suggest you talk to your mod's authors and get them to\nupdate their " - + "requirements. ModLoaderMP is not compatible with Minecraft Forge on the server and they will need to update their mod\n" - + "for Minecraft Forge and other server compatibility, unless they are Minecraft Forge mods, in which case they already\n" - + "don't need ModLoaderMP and the mod author simply has failed to update his requirements and should be informed appropriately.\n\n" - + "The authors of Forge Mod Loader would like to be compatible with ModLoaderMP but it is closed source and owned by SDK.\n" - + "SDK, the author of ModLoaderMP, has a standing invitation to submit compatibility patches \n" - + "to the open source community project that is Forge Mod Loader so that this incompatibility doesn't last. \n" - + "Users who wish to enjoy mods of both types are " - + "encouraged to request of SDK that he submit a\ncompatibility patch to the Forge Mod Loader project at \n" - + "http://github.com/cpw/FML.\nPosting on the minecraft forums at\nhttp://www.minecraftforum.net/topic/86765- (the MLMP thread)\n" - + "may encourage him in this effort. However, I ask that your requests be polite.\n" - + "Now, the server has to shutdown so you can reinstall your minecraft_server.jar\nproperly, until such time as we can work together."); - throw new RuntimeException( - "This FML based server has detected an installation of ModLoaderMP alongside. This will cause serious compatibility issues, so the server will now shut down."); - } - catch (ClassNotFoundException e) - { - // We're safe. continue - } - server = minecraftServer; - FMLCommonHandler.instance().beginLoading(this); - FMLRegistry.registerRegistry(new BukkitRegistry()); - Loader.instance().loadMods(); - } - - /** - * Called a bit later on during server initialization to finish loading mods - */ - public void onLoadComplete() - { - Loader.instance().initializeMods(); - for (Item i : Item.byId) { - if (i!=null && Material.getMaterial(i.id).name().startsWith("X")) { - Material.setMaterialName(i.id, i.l()); - } - } - } - - public void onWorldLoadTick() - { - FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.WORLDLOAD)); - } - - /** - * Every tick just before world and other ticks occur - */ - public void onPreWorldTick(World world) - { - FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.WORLD),world); - } - - /** - * Every tick just after world and other ticks occur - */ - public void onPostWorldTick(World world) - { - FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.WORLD), world); - } - - /** - * Get the server instance - * - * @return - */ - public MinecraftServer getServer() - { - return server; - } - - /** - * Get a handle to the server's logger instance - */ - public Logger getMinecraftLogger() - { - return MinecraftServer.log; - } - - /** - * Called from ChunkProviderServer when a chunk needs to be populated - * - * To avoid polluting the worldgen seed, we generate a new random from the world seed and - * generate a seed from that - * - * @param chunkProvider - * @param chunkX - * @param chunkZ - * @param world - * @param generator - */ - public void onChunkPopulate(IChunkProvider chunkProvider, int chunkX, int chunkZ, World world, IChunkProvider generator) - { - FMLCommonHandler.instance().handleWorldGeneration(chunkX, chunkZ, world.getSeed(), world, generator, chunkProvider); - } - - /** - * Called from the furnace to lookup fuel values - * - * @param itemId - * @param itemDamage - * @return - */ - public int fuelLookup(int itemId, int itemDamage) - { - int fv = 0; - - for (ModContainer mod : Loader.getModList()) - { - fv = Math.max(fv, mod.lookupFuelValue(itemId, itemDamage)); - } - - return fv; - } - - /** - * Is the offered class and instance of BaseMod and therefore a ModLoader mod? - */ - public boolean isModLoaderMod(Class clazz) - { - return BaseMod.class.isAssignableFrom(clazz); - } - - /** - * Load the supplied mod class into a mod container - */ - public ModContainer loadBaseModMod(Class clazz, File canonicalFile) - { - @SuppressWarnings("unchecked") - Class bmClazz = (Class ) clazz; - return new ModLoaderModContainer(bmClazz, canonicalFile); - } - - /** - * Called to notify that an item was picked up from the world - * - * @param entityItem - * @param entityPlayer - */ - public void notifyItemPickup(EntityItem entityItem, EntityHuman entityPlayer) - { - for (ModContainer mod : Loader.getModList()) - { - if (mod.wantsPickupNotification()) - { - mod.getPickupNotifier().notifyPickup(entityItem, entityPlayer); - } - } - } - - /** - * Raise an exception - * - * @param exception - * @param message - * @param stopGame - */ - public void raiseException(Throwable exception, String message, boolean stopGame) - { - FMLCommonHandler.instance().getFMLLogger().throwing("FMLHandler", "raiseException", exception); - throw new RuntimeException(exception); - } - - /** - * Attempt to dispense the item as an entity other than just as a the item itself - * - * @param world - * @param x - * @param y - * @param z - * @param xVelocity - * @param zVelocity - * @param item - * @return - */ - public boolean tryDispensingEntity(World world, double x, double y, double z, byte xVelocity, byte zVelocity, ItemStack item) - { - for (ModContainer mod : Loader.getModList()) - { - if (mod.wantsToDispense() && mod.getDispenseHandler().dispense(x, y, z, xVelocity, zVelocity, world, item)) - { - return true; - } - } - - return false; - } - - /** - * @return the instance - */ - public static FMLBukkitHandler instance() - { - return INSTANCE; - } - - /** - * Build a list of default overworld biomes - * - * @return - */ - public BiomeBase[] getDefaultOverworldBiomes() - { - if (defaultOverworldBiomes == null) - { - ArrayList biomes = new ArrayList(20); - - for (int i = 0; i < 23; i++) - { - if ("Sky".equals(BiomeBase.biomes[i].y) || "Hell".equals(BiomeBase.biomes[i].y)) - { - continue; - } - - biomes.add(BiomeBase.biomes[i]); - } - - defaultOverworldBiomes = new BiomeBase[biomes.size()]; - biomes.toArray(defaultOverworldBiomes); - } - - return defaultOverworldBiomes; - } - - /** - * Called when an item is crafted - * - * @param player - * @param craftedItem - * @param craftingGrid - */ - public void onItemCrafted(EntityHuman player, ItemStack craftedItem, IInventory craftingGrid) - { - for (ModContainer mod : Loader.getModList()) - { - if (mod.wantsCraftingNotification()) - { - mod.getCraftingHandler().onCrafting(player, craftedItem, craftingGrid); - } - } - } - - /** - * Called when an item is smelted - * - * @param player - * @param smeltedItem - */ - public void onItemSmelted(EntityHuman player, ItemStack smeltedItem) - { - for (ModContainer mod : Loader.getModList()) - { - if (mod.wantsCraftingNotification()) - { - mod.getCraftingHandler().onSmelting(player, smeltedItem); - } - } - } - - /** - * Called when a chat packet is received - * - * @param chat - * @param player - * @return true if you want the packet to stop processing and not echo to the rest of the world - */ - public boolean handleChatPacket(Packet3Chat chat, EntityHuman player) - { - for (ModContainer mod : Loader.getModList()) - { - if (mod.wantsNetworkPackets() && mod.getNetworkHandler().onChat(chat, player)) - { - return true; - } - } - - return false; - } - - /** - * Called when a packet 250 packet is received from the player - * - * @param packet - * @param player - */ - public void handlePacket250(Packet250CustomPayload packet, EntityHuman player) - { - if ("REGISTER".equals(packet.tag) || "UNREGISTER".equals(packet.tag)) - { - handleClientRegistration(packet, player); - return; - } - - ModContainer mod = FMLCommonHandler.instance().getModForChannel(packet.tag); - - if (mod != null) - { - mod.getNetworkHandler().onPacket250Packet(packet, player); - } - } - - /** - * Handle register requests for packet 250 channels - * - * @param packet - */ - private void handleClientRegistration(Packet250CustomPayload packet, EntityHuman player) - { - if (packet.data==null) { - return; - } - try - { - for (String channel : new String(packet.data, "UTF8").split("\0")) - { - // Skip it if we don't know it - if (FMLCommonHandler.instance().getModForChannel(channel) == null) - { - continue; - } - - if ("REGISTER".equals(packet.tag)) - { - FMLCommonHandler.instance().activateChannel(player, channel); - } - else - { - FMLCommonHandler.instance().deactivateChannel(player, channel); - } - } - } - catch (UnsupportedEncodingException e) - { - getMinecraftLogger().warning("Received invalid registration packet"); - } - } - - /** - * Handle a login - * - * @param loginPacket - * @param networkManager - */ - public void handleLogin(Packet1Login loginPacket, NetworkManager networkManager) - { - Packet250CustomPayload packet = new Packet250CustomPayload(); - packet.tag = "REGISTER"; - packet.data = FMLCommonHandler.instance().getPacketRegistry(); - packet.length = packet.data.length; - if (packet.length>0) { - networkManager.queue(packet); - } - } - - public void announceLogin(EntityHuman player) { - for (ModContainer mod : Loader.getModList()) - { - if (mod.wantsPlayerTracking()) - { - mod.getPlayerTracker().onPlayerLogin(player); - } - } - } - - @Override - public File getMinecraftRootDirectory() - { - try { - return server.a(".").getCanonicalFile(); - } catch (IOException ioe) { - return new File("."); - } - } - - /** - * @param var2 - * @return - */ - public boolean handleServerCommand(String command, String player, ICommandListener listener) - { - for (ModContainer mod : Loader.getModList()) { - if (mod.wantsConsoleCommands() && mod.getConsoleHandler().handleCommand(command, player, listener)) { - return true; - } - } - return false; - } - - /** - * @param player - */ - public void announceLogout(EntityHuman player) - { - for (ModContainer mod : Loader.getModList()) - { - if (mod.wantsPlayerTracking()) - { - mod.getPlayerTracker().onPlayerLogout(player); - } - } - } - - /** - * @param p_28168_1_ - */ - public void announceDimensionChange(EntityHuman player) - { - for (ModContainer mod : Loader.getModList()) - { - if (mod.wantsPlayerTracking()) - { - mod.getPlayerTracker().onPlayerChangedDimension(player); - } - } - } - - /** - * @param biome - */ - public void addBiomeToDefaultWorldGenerator(BiomeBase biome) - { - WorldType.NORMAL.addNewBiome(biome); - } - - /** - * @param biome - */ - public void removeBiomeFromDefaultWorldGenerator(BiomeBase biome) - { - WorldType.NORMAL.removeBiome(biome); - } - - @Override - public Object getMinecraftInstance() { - return server; - } - - @Override - public String getCurrentLanguage() - { - return LocaleLanguage.a().getCurrentLanguage(); - } - - @Override - public Properties getCurrentLanguageTable() - { - return LocaleLanguage.a().getCurrentLanguageTable(); - } - - @Override - public String getObjectName(Object instance) - { - String objectName; - if (instance instanceof Item) { - objectName=((Item)instance).getName(); - } else if (instance instanceof Block) { - objectName=((Block)instance).getName(); - } else if (instance instanceof ItemStack) { - objectName=Item.byId[((ItemStack)instance).id].a((ItemStack)instance); - } else { - throw new IllegalArgumentException(String.format("Illegal object for naming %s",instance)); - } - objectName+=".name"; - return objectName; - } - - @Override - public ModMetadata readMetadataFrom(InputStream input, ModContainer mod) throws Exception { - // TODO Auto-generated method stub - return null; - } - - @Override - public void profileStart(String profileLabel) { - if (profiler!=null) - { - profiler.start(profileLabel); - } - } - - @Override - public void profileEnd() { - if (profiler!=null) - { - profiler.end(); - } - } - - @Override - public ModProperty getModLoaderPropertyFor(Field f) { - if (f.isAnnotationPresent(MLProp.class)) { - MLProp prop = f.getAnnotation(MLProp.class); - return new ModProperty(prop.info(), prop.min(), prop.max(), prop.name()); - } - return null; - } - - @Override - public List getAdditionalBrandingInformation() { - return null; - } - - @Override - public Side getSide() { - return Side.BUKKIT; - } - - @Override - public ProxyInjector findSidedProxyOn(cpw.mods.fml.common.modloader.BaseMod mod) { - for (Field f : mod.getClass().getDeclaredFields()) - { - if (f.isAnnotationPresent(SidedProxy.class)) - { - SidedProxy sp = f.getAnnotation(SidedProxy.class); - return new ProxyInjector(sp.clientSide(), sp.serverSide(), sp.bukkitSide(), f); - } - } - return null; - } - - public void onServerPostTick() { - FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.GAME)); - } - - public void onServerPreTick() { - FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.GAME)); - } -} diff --git a/fml/bukkit/cpw/mods/fml/server/FMLBukkitProfiler.java b/fml/bukkit/cpw/mods/fml/server/FMLBukkitProfiler.java deleted file mode 100644 index 05ade20c1c..0000000000 --- a/fml/bukkit/cpw/mods/fml/server/FMLBukkitProfiler.java +++ /dev/null @@ -1,131 +0,0 @@ -package cpw.mods.fml.server; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.LinkedList; -import java.util.List; - -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableMultiset; -import com.google.common.collect.Lists; -import com.google.common.collect.Multiset; -import com.google.common.collect.Multiset.Entry; -import com.google.common.collect.Multisets; -import com.google.common.collect.TreeMultiset; -import com.google.common.primitives.Ints; - -public class FMLBukkitProfiler { - private static FMLBukkitProfiler lastInstance; - private static long endTime; - private LinkedList profiles = new LinkedList(); - private TreeMultiset hitCounter = TreeMultiset.create(); - private TreeMultiset timings = TreeMultiset.create(); - private long timestamp; - - public static long beginProfiling(int seconds) - { - long now = System.currentTimeMillis(); - if (lastInstance == null) - { - lastInstance = new FMLBukkitProfiler(); - FMLBukkitHandler.instance().profiler = lastInstance; - endTime = now + seconds * 1000; - } - if (endTime > now) - { - return (endTime - now) / 1000; - } - else - { - return 0; - } - } - - public static long endProfiling() - { - FMLBukkitHandler.instance().profiler = null; - return endTime - System.currentTimeMillis(); - } - - public static void resetProfiling() - { - endProfiling(); - lastInstance = null; - } - - public void start(String profileLabel) - { - profiles.push(profileLabel); - timestamp = System.nanoTime(); - } - - public void end() - { - int timing = (int)((System.nanoTime() - timestamp)/1000L); - String label = Joiner.on('.').join(profiles); - profiles.pop(); - hitCounter.add(label); - timings.add(label,timing); - if (System.currentTimeMillis()>endTime) - { - endProfiling(); - } - } - - public static String[] dumpProfileData(int count) - { - if (lastInstance == null) - { - return new String[] { "No profile data available" }; - } - - if (endTime > System.currentTimeMillis()) - { - return new String[] { String.format("Timing is being gathered for another %d seconds", endTime - System.currentTimeMillis()) }; - } - return lastInstance.profileData(count); - } - - private String[] profileData(int count) { - List> sortedTiming = getEntriesSortedByFrequency(timings, false); - ArrayList timeLine = new ArrayList(); - - double totalTime = timings.size(); - - for (Entry hit : sortedTiming) - { - if (--count == 0) - { - break; - } - timeLine.add(String.format("%s : %d microseconds, %d invocations. %.2f %% of overall time",hit.getElement(), hit.getCount(), hitCounter.count(hit.getElement()), 100.0 * hit.getCount()/totalTime)); - } - return timeLine.toArray(new String[0]); - } - - /* - * Code from http://stackoverflow.com/questions/4345633/simplest-way-to-iterate-through-a-multiset-in-the-order-of-element-frequency - */ - private enum EntryComp implements Comparator>{ - DESCENDING{ - @Override - public int compare(final Entry a, final Entry b){ - return Ints.compare(b.getCount(), a.getCount()); - } - }, - ASCENDING{ - @Override - public int compare(final Entry a, final Entry b){ - return Ints.compare(a.getCount(), b.getCount()); - } - }, - } - - private static List> getEntriesSortedByFrequency(final Multiset ms, final boolean ascending) { - final List> entryList = Lists.newArrayList(ms.entrySet()); - Collections.sort(entryList, ascending ? EntryComp.ASCENDING : EntryComp.DESCENDING); - return entryList; - } - -} diff --git a/fml/bukkit/net/minecraft/server/BaseMod.java b/fml/bukkit/net/minecraft/server/BaseMod.java deleted file mode 100644 index 6adfaf6bc3..0000000000 --- a/fml/bukkit/net/minecraft/server/BaseMod.java +++ /dev/null @@ -1,409 +0,0 @@ -/* - * The FML Forge Mod Loader suite. Copyright (C) 2012 cpw - * - * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -package net.minecraft.server; - -import java.util.Map; -import java.util.Random; - -import org.bukkit.craftbukkit.generator.NetherChunkGenerator; -import org.bukkit.craftbukkit.generator.NormalChunkGenerator; - -import cpw.mods.fml.common.TickType; - -public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod -{ - // CALLBACK MECHANISMS - - /** - * @param minecraftInstance - * @return - */ - public final boolean doTickInGame(TickType tick, boolean tickEnd, Object minecraftInstance, Object... data) - { - if (tick==TickType.GAME && tickEnd) { - return onTickInGame((MinecraftServer)minecraftInstance); - } else { - return true; - } - } - - @Override - public final void onCrafting(Object... craftingParameters) - { - takenFromCrafting((EntityHuman)craftingParameters[0], (ItemStack)craftingParameters[1], (IInventory)craftingParameters[2]); - } - - @Override - public final void onSmelting(Object... smeltingParameters) - { - takenFromFurnace((EntityHuman)smeltingParameters[0], (ItemStack)smeltingParameters[1]); - } - - @Override - public final boolean dispense(double x, double y, double z, byte xVelocity, byte zVelocity, Object... data) - { - return dispenseEntity((World)data[0], x, y, z, xVelocity, zVelocity, (ItemStack)data[1]); - } - - @Override - public final boolean onChat(Object... data) - { - return onChatMessageReceived((EntityHuman)data[1], (Packet3Chat)data[0]); - } - - @Override - public final void onServerLogin(Object handler) { - // NOOP - } - - public final void onServerLogout() { - // NOOP - } - @Override - public final void onPlayerLogin(Object player) - { - onClientLogin((EntityHuman) player); - } - - @Override - public final void onPlayerLogout(Object player) - { - onClientLogout((EntityHuman)player); - } - - @Override - public final void onPlayerChangedDimension(Object player) - { - onClientDimensionChanged((EntityHuman)player); - } - - @Override - public final void onPacket250Packet(Object... data) - { - onPacket250Received((EntityHuman)data[1], (Packet250CustomPayload)data[0]); - } - - @Override - public final void notifyPickup(Object... pickupData) - { - EntityItem item = (EntityItem) pickupData[0]; - EntityHuman player = (EntityHuman) pickupData[1]; - onItemPickup(player, item.itemStack); - } - - @Override - public final void generate(Random random, int chunkX, int chunkZ, Object... additionalData) - { - World w = (World) additionalData[0]; - IChunkProvider cp = (IChunkProvider) additionalData[1]; - - if (cp instanceof ChunkProviderHell || cp instanceof NetherChunkGenerator) - { - generateNether(w, random, chunkX << 4, chunkZ << 4); - } - else if (cp instanceof ChunkProviderGenerate || cp instanceof NormalChunkGenerator) - { - generateSurface(w, random, chunkX << 4, chunkZ << 4); - } - } - - /** - * NO-OP on client side - */ - @Override - public final boolean handleCommand(String command, Object... data) - { - return onServerCommand(command, (String)data[0], (ICommandListener)data[1]); - } - @Override - public void onRegisterAnimations() { - // NOOP on servers - } - - @Override - public void onRenderHarvest(@SuppressWarnings("rawtypes") Map renderers) { - // NOOP on servers - } - - // BASEMOD API - /** - * Override if you wish to provide a fuel item for the furnace and return the fuel value of the item - * - * @param id - * @param metadata - * @return - */ - public int addFuel(int id, int metadata) - { - return 0; - } - - public void addRenderer(Map, Object> renderers) - { - - } - - /** - * Override if you wish to perform some action other than just dispensing the item from the dispenser - * - * @param world - * @param x - * @param y - * @param z - * @param xVel - * @param zVel - * @param item - * @return - */ - public boolean dispenseEntity(World world, double x, double y, double z, int xVel, int zVel, ItemStack item) - { - return false; - } - - /** - * Override if you wish to generate Nether (Hell biome) blocks - * - * @param world - * @param random - * @param chunkX - * @param chunkZ - */ - public void generateNether(World world, Random random, int chunkX, int chunkZ) - { - } - - /** - * Override if you wish to generate Overworld (not hell or the end) blocks - * - * @param world - * @param random - * @param chunkX - * @param chunkZ - */ - public void generateSurface(World world, Random random, int chunkX, int chunkZ) - { - } - - /** - * Return the name of your mod. Defaults to the class name - * - * @return - */ - public String getName() - { - return getClass().getSimpleName(); - } - - /** - * Get your mod priorities - * - * @return - */ - public String getPriorities() - { - return ""; - } - - /** - * Return the version of your mod - * - * @return - */ - public abstract String getVersion(); - - public void keyboardEvent(Object event) - { - - } - - /** - * Load your mod - */ - public abstract void load(); - - /** - * Finish loading your mod - */ - public void modsLoaded() - { - } - - /** - * Handle item pickup - * - * @param player - * @param item - */ - public void onItemPickup(EntityHuman player, ItemStack item) - { - } - - /** - * Ticked every game tick if you have subscribed to tick events through {@link ModLoader#setInGameHook(BaseMod, boolean, boolean)} - * - * @param minecraftServer the server - * @return true to continue receiving ticks - */ - public boolean onTickInGame(MinecraftServer minecraftServer) - { - return false; - } - - public boolean onTickInGUI(float tick, Object game, Object gui) - { - return false; - } - - /** - * Only implemented on the client side - * {@link #onChatMessageReceived(EntityPlayer, Packet3Chat)} - * - * @param text - */ - public void receiveChatPacket(String text) - { - - } - - /** - * Only called on the client side - * {@link #onPacket250Received(EntityPlayer, Packet250CustomPayload)} - * - * @param packet - */ - public void receiveCustomPacket(Packet250CustomPayload packet) - { - - } - - public void registerAnimation(Object game) - { - - } - - public void renderInvBlock(Object renderer, Block block, int metadata, int modelID) - { - - } - - public boolean renderWorldBlock(Object renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID) - { - return false; - - } - - /** - * Called when someone crafts an item from a crafting table - * - * @param player - * @param item - * @param matrix - */ - public void takenFromCrafting(EntityHuman player, ItemStack item, IInventory matrix) - { - } - - /** - * Called when someone takes a smelted item from a furnace - * - * @param player - * @param item - */ - public void takenFromFurnace(EntityHuman player, ItemStack item) - { - } - - /** - * The identifier string for the mod- used in client<->server negotiation - */ - @Override - public String toString() - { - return getName() + " " + getVersion(); - } - - /** - * Called when a 250 packet is received on a channel registered to this mod - * - * @param source - * @param payload - */ - public void onPacket250Received(EntityHuman source, Packet250CustomPayload payload) - { - } - - /** - * Called when a chat message is received. Return true to stop further processing - * - * @param source - * @param chat - * @return true if you want to consume the message so it is not available for further processing - */ - public boolean onChatMessageReceived(EntityHuman source, Packet3Chat chat) - { - return false; - } - /** - * Called when a server command is received - * @param command - * @return true if you want to consume the message so it is not available for further processing - */ - public boolean onServerCommand(String command, String sender, ICommandListener listener) - { - return false; - } - - /** - * Called when a new client logs in. - * - * @param player - */ - public void onClientLogin(EntityHuman player) - { - } - - /** - * Called when a client logs out of the server. - * - * @param player - */ - public void onClientLogout(EntityHuman player) - { - - } - - /** - * - * Called when a client changes dimensions on the server. - * - * @param player - */ - public void onClientDimensionChanged(EntityHuman player) - { - - } - - // Spare client junk - // ------- - // void addRenderer(Map, Render> renderers); - // void registerAnimation(Minecraft game); - // void renderInvBlock(RenderBlocks renderer, Block block, int metadata, int modelID); - // boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID); - // boolean onTickInGUI(float tick, Minecraft game, GuiScreen gui); - // void keyboardEvent(KeyBinding event); - - @Override - public void keyBindingEvent(Object keybinding) { - // NOOP on server - } -} diff --git a/fml/bukkit/net/minecraft/server/BukkitRegistry.java b/fml/bukkit/net/minecraft/server/BukkitRegistry.java deleted file mode 100644 index 3b2c0e3cdb..0000000000 --- a/fml/bukkit/net/minecraft/server/BukkitRegistry.java +++ /dev/null @@ -1,164 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.List; - -import net.minecraft.src.BiomeGenBase; - -import cpw.mods.fml.common.registry.IMinecraftRegistry; -import cpw.mods.fml.server.FMLBukkitHandler; - -public class BukkitRegistry implements IMinecraftRegistry -{ - - @Override - public void addRecipe(net.minecraft.src.ItemStack output, Object... params) - { - CraftingManager.getInstance().registerShapedRecipe((ItemStack) output, params); - } - - @Override - public void addShapelessRecipe(net.minecraft.src.ItemStack output, Object... params) - { - CraftingManager.getInstance().registerShapelessRecipe((ItemStack) output, params); - } - - @SuppressWarnings("unchecked") - @Override - public void addRecipe(net.minecraft.src.IRecipe recipe) - { - CraftingManager.getInstance().getRecipies().add(recipe); - } - - @Override - public void addSmelting(int input, net.minecraft.src.ItemStack output) - { - FurnaceRecipes.getInstance().registerRecipe(input, (ItemStack) output); - } - - @Override - public void registerBlock(net.minecraft.src.Block block) - { - registerBlock(block, ItemBlock.class); - } - - @Override - public void registerBlock(net.minecraft.src.Block block, Class itemclass) - { - try - { - assert block != null : "registerBlock: block cannot be null"; - assert itemclass != null : "registerBlock: itemclass cannot be null"; - int blockItemId = ((Block)block).id - 256; - itemclass.getConstructor(int.class).newInstance(blockItemId); - } - catch (Exception e) - { - //HMMM - } - } - - @SuppressWarnings("unchecked") - @Override - public void registerEntityID(Class entityClass, String entityName, int id) - { - EntityTypes.addNewEntityListMapping((Class) entityClass, entityName, id); - } - - @SuppressWarnings("unchecked") - @Override - public void registerEntityID(Class entityClass, String entityName, int id, int backgroundEggColour, int foregroundEggColour) - { - EntityTypes.addNewEntityListMapping((Class) entityClass, entityName, id, backgroundEggColour, foregroundEggColour); - } - - @SuppressWarnings("unchecked") - @Override - public void registerTileEntity(Class tileEntityClass, String id) - { - TileEntity.addNewTileEntityMapping((Class) tileEntityClass, id); - } - - @Override - public void addBiome(BiomeGenBase biome) - { - FMLBukkitHandler.instance().addBiomeToDefaultWorldGenerator((BiomeBase) biome); - } - - @Override - public void addSpawn(Class entityClass, int weightedProb, int min, int max, net.minecraft.src.EnumCreatureType typeOfCreature, BiomeGenBase... biomes) - { - BiomeBase[] realBiomes=(BiomeBase[]) biomes; - for (BiomeBase biome : realBiomes) - { - @SuppressWarnings("unchecked") - List spawns = ((BiomeBase)biome).getMobs((EnumCreatureType)typeOfCreature); - - for (BiomeMeta entry : spawns) - { - //Adjusting an existing spawn entry - if (entry.a == entityClass) - { - entry.d = weightedProb; - entry.b = min; - entry.c = max; - break; - } - } - - spawns.add(new BiomeMeta(entityClass, weightedProb, min, max)); - } - } - - @Override - @SuppressWarnings("unchecked") - public void addSpawn(String entityName, int weightedProb, int min, int max, net.minecraft.src.EnumCreatureType spawnList, BiomeGenBase... biomes) - { - Class entityClazz = EntityTypes.getEntityToClassMapping().get(entityName); - - if (EntityLiving.class.isAssignableFrom(entityClazz)) - { - addSpawn((Class ) entityClazz, weightedProb, min, max, spawnList, biomes); - } - } - - @Override - public void removeBiome(BiomeGenBase biome) - { - FMLBukkitHandler.instance().removeBiomeFromDefaultWorldGenerator((BiomeBase)biome); - } - - @Override - public void removeSpawn(Class entityClass, net.minecraft.src.EnumCreatureType typeOfCreature, BiomeGenBase... biomesO) - { - BiomeBase[] biomes=(BiomeBase[]) biomesO; - for (BiomeBase biome : biomes) - { - @SuppressWarnings("unchecked") - List spawns = ((BiomeBase)biome).getMobs((EnumCreatureType) typeOfCreature); - - Iterator entries = spawns.iterator(); - while (entries.hasNext()) - { - BiomeMeta entry = entries.next(); - if (entry.a == entityClass) - { - entries.remove(); - } - } - } - } - - @Override - @SuppressWarnings("unchecked") - public void removeSpawn(String entityName, net.minecraft.src.EnumCreatureType spawnList, BiomeGenBase... biomes) - { - Class entityClazz = EntityTypes.getEntityToClassMapping().get(entityName); - - if (EntityLiving.class.isAssignableFrom(entityClazz)) - { - removeSpawn((Class ) entityClazz, spawnList, biomes); - } - } - -} diff --git a/fml/bukkit/net/minecraft/server/MLProp.java b/fml/bukkit/net/minecraft/server/MLProp.java deleted file mode 100644 index e17928d3d0..0000000000 --- a/fml/bukkit/net/minecraft/server/MLProp.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * The FML Forge Mod Loader suite. Copyright (C) 2012 cpw - * - * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -package net.minecraft.server; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; -import static java.lang.annotation.RetentionPolicy.*; -import static java.lang.annotation.ElementType.*; - -/** - * @author cpw - * - */ -@Retention(value = RUNTIME) -@Target(value = FIELD) -public @interface MLProp -{ - /** - * Adds additional help to top of configuration file. - */ -String info() default ""; - - /** - * Maximum value allowed if field is a number. - */ - double max() default Double.MAX_VALUE; - - /** - * Minimum value allowed if field is a number. - */ - double min() default Double.MIN_VALUE; - - /** - * Overrides the field name for property key. - */ -String name() default ""; - -} diff --git a/fml/bukkit/net/minecraft/server/ModLoader.java b/fml/bukkit/net/minecraft/server/ModLoader.java deleted file mode 100644 index 49b059c5cd..0000000000 --- a/fml/bukkit/net/minecraft/server/ModLoader.java +++ /dev/null @@ -1,780 +0,0 @@ -/* - * The FML Forge Mod Loader suite. Copyright (C) 2012 cpw - * - * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -package net.minecraft.server; - -import java.util.List; -import java.util.Map; -import java.util.logging.Logger; - -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.ReflectionHelper; -import cpw.mods.fml.common.modloader.ModLoaderHelper; -import cpw.mods.fml.common.modloader.ModLoaderModContainer; -import cpw.mods.fml.common.registry.FMLRegistry; -import cpw.mods.fml.server.FMLBukkitHandler; - -public class ModLoader -{ - /** - * Not used on the server. - * - * @param achievement - * @param name - * @param description - */ - public static void addAchievementDesc(Achievement achievement, String name, String description) - { - String achName=achievement.getName(); - addLocalization(achName, name); - addLocalization(achName+".desc", description); - } - - /** - * This method is a call in hook from modified external code. Implemented elsewhere. - * - * {@link FMLCommonHandler#fuelLookup(int, int)} - * - * @param id - * @param metadata - * @return - */ - @Deprecated - public static int addAllFuel(int id, int metadata) - { - return 0; - } - - public static void addAllRenderers(Map, Object> renderers) - { - } - - public static void addAnimation(Object anim) - { - } - - /** - * This method is unimplemented in server versions to date. - * - * @param armor - * @return - */ - public static int addArmor(String armor) - { - return 0; - } - - /** - * This method adds the supplied biome to the set of candidate biomes for the default world generator type. - * - * @param biome - */ - public static void addBiome(BiomeBase biome) - { - FMLRegistry.addBiome(biome); - } - - /** - * Add localization for the specified string - * - * @param key - * @param value - */ - public static void addLocalization(String key, String value) - { - addLocalization(key, "en_US", value); - } - - /** - * Add localization for the specified string - * - * @param key - * @param lang - * @param value - */ - public static void addLocalization(String key, String lang, String value) - { - FMLCommonHandler.instance().addStringLocalization(key, lang, value); - } - - /** - * Name the specified minecraft object with the supplied name - * - * @param instance - * @param name - */ - public static void addName(Object instance, String name) - { - addName(instance,"en_US",name); - } - - /** - * Unimplemented on the server as it does not generate names - * - * @param instance - * @param lang - * @param name - */ - public static void addName(Object instance, String lang, String name) - { - FMLCommonHandler.instance().addNameForObject(instance, lang, name); - } - - /** - * Unimplemented on the server as it does not render textures - * - * @param fileToOverride - * @param fileToAdd - * @return - */ - public static int addOverride(String fileToOverride, String fileToAdd) - { - return 0; - } - - /** - * Unimplemented on the server as it does not render textures - * - * @param path - * @param overlayPath - * @param index - */ - public static void addOverride(String path, String overlayPath, int index) - { - // NOOP - } - - /** - * Add a Shaped Recipe - * - * @param output - * @param params - */ - public static void addRecipe(ItemStack output, Object... params) - { - FMLRegistry.addRecipe(output, params); - } - - /** - * Add a shapeless recipe - * - * @param output - * @param params - */ - public static void addShapelessRecipe(ItemStack output, Object... params) - { - FMLRegistry.addShapelessRecipe(output, params); - } - - /** - * Add a new product to be smelted - * - * @param input - * @param output - */ - public static void addSmelting(int input, ItemStack output) - { - FMLRegistry.addSmelting(input, output); - } - - /** - * Add a mob to the spawn list - * - * @param entityClass - * @param weightedProb - * @param min - * @param max - * @param spawnList - */ - public static void addSpawn(Class entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList) - { - FMLRegistry.addSpawn(entityClass, weightedProb, min, max, spawnList, FMLBukkitHandler.instance().getDefaultOverworldBiomes()); - } - - /** - * Add a mob to the spawn list - * @param entityClass - * @param weightedProb - * @param min - * @param max - * @param spawnList - * @param biomes - */ - public static void addSpawn(Class entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeBase... biomes) - { - FMLRegistry.addSpawn(entityClass, weightedProb, min, max, spawnList, biomes); - } - - /** - * Add a mob to the spawn list - * - * @param entityName - * @param weightedProb - * @param min - * @param max - * @param spawnList - */ - public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList) - { - FMLRegistry.addSpawn(entityName, weightedProb, min, max, spawnList, FMLBukkitHandler.instance().getDefaultOverworldBiomes()); - } - - /** - * Add a mob to the spawn list - * @param entityName - * @param weightedProb - * @param min - * @param max - * @param spawnList - * @param biomes - */ - public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeBase... biomes) - { - FMLRegistry.addSpawn(entityName, weightedProb, min, max, spawnList, biomes); - } - - /** - * This method is a call in hook from modified external code. Implemented elsewhere. - * {@link FMLBukkitHandler#tryDispensingEntity(World, double, double, double, byte, byte, ItemStack)} - * - * @param world - * @param x - * @param y - * @param z - * @param xVel - * @param zVel - * @param item - * @return - */ - @Deprecated - public static boolean dispenseEntity(World world, double x, double y, double z, int xVel, int zVel, ItemStack item) - { - return false; - } - - /** - * Remove a container and drop all the items in it on the ground around - * - * @param world - * @param x - * @param y - * @param z - */ - public static void genericContainerRemoval(World world, int x, int y, int z) - { - TileEntity te = world.getTileEntity(x, y, z); - - if (!(te instanceof IInventory)) - { - return; - } - - IInventory inv = (IInventory)te; - - for (int l = 0; l < inv.getSize(); l++) - { - ItemStack itemstack = inv.getItem(l); - - if (itemstack == null) - { - continue; - } - - float f = world.random.nextFloat() * 0.8F + 0.1F; - float f1 = world.random.nextFloat() * 0.8F + 0.1F; - float f2 = world.random.nextFloat() * 0.8F + 0.1F; - - while (itemstack.count > 0) - { - int i1 = world.random.nextInt(21) + 10; - - if (i1 > itemstack.count) - { - i1 = itemstack.count ; - } - - itemstack.count -= i1; - EntityItem entityitem = new EntityItem(world, (float)te.x + f, (float)te.y + f1, (float)te.z + f2, new ItemStack(itemstack.id, i1, itemstack.getData())); - float f3 = 0.05F; - entityitem.motX = (float)world.random.nextGaussian() * f3; - entityitem.motY = (float)world.random.nextGaussian() * f3 + 0.2F; - entityitem.motZ = (float)world.random.nextGaussian() * f3; - - if (itemstack.hasTag()) - { - entityitem.itemStack.setTag((NBTTagCompound)itemstack.getTag().clone()); - } - - world.addEntity(entityitem); - } - } - } - - /** - * Get a list of all BaseMod loaded into the system - * {@link ModLoaderModContainer#findAll} - * - * @return - */ - public static List getLoadedMods() - { - return ModLoaderModContainer.findAll(BaseMod.class); - } - - /** - * Get a logger instance {@link FMLCommonHandler#getFMLLogger()} - * - * @return - */ - public static Logger getLogger() - { - return FMLCommonHandler.instance().getFMLLogger(); - } - - public static Object getMinecraftInstance() - { - return getMinecraftServerInstance(); - } - - /** - * Get the minecraft server instance - * {@link FMLServerHandler#getServer()} - * @return - */ - public static MinecraftServer getMinecraftServerInstance() - { - return FMLBukkitHandler.instance().getServer(); - } - /** - * Get a value from a field using reflection - * {@link ReflectionHelper#getPrivateValue(Class, Object, int)} - * - * @param instanceclass - * @param instance - * @param fieldindex - * @return - */ - public static T getPrivateValue(Class instanceclass, E instance, int fieldindex) - { - return ReflectionHelper.getPrivateValue(instanceclass, instance, fieldindex); - } - - /** - * Get a value from a field using reflection - * {@link ReflectionHelper#getPrivateValue(Class, Object, String)} - * - * @param instanceclass - * @param instance - * @param field - * @return - */ - public static T getPrivateValue(Class instanceclass, E instance, String field) - { - return ReflectionHelper.getPrivateValue(instanceclass, instance, field); - } - - /** - * Stubbed method on the server to return a unique model id - * - */ - public static int getUniqueBlockModelID(BaseMod mod, boolean inventoryRenderer) - { - return -1; - } - - /** - * Get a new unique entity id - * {@link Entity#getNextId()} - * - * @return - */ - public static int getUniqueEntityId() - { - return FMLCommonHandler.instance().nextUniqueEntityListId(); - } - - public static int getUniqueSpriteIndex(String path) - { - return -1; - } - - /** - * To properly implement packet 250 protocol you should always check your - * channel is active prior to sending the packet - * - * @param player - * @param channel - * @return - */ - public static boolean isChannelActive(EntityPlayer player, String channel) - { - return FMLCommonHandler.instance().isChannelActive(channel, player); - } - - public static boolean isGUIOpen(Class gui) - { - return false; - } - - /** - * Is the named mod loaded? - * {@link Loader#isModLoaded(String)} - * - * @param modname - * @return - */ - public static boolean isModLoaded(String modname) - { - return Loader.isModLoaded(modname); - } - - /** - * Implemented elsewhere - */ - @Deprecated - public static void loadConfig() - { - } - - public static Object loadImage(Object renderEngine, String path) throws Exception - { - return null; - } - - /** - * Call in from elsewhere. Unimplemented here. - * @param player - * @param item - */ - @Deprecated - public static void onItemPickup(EntityPlayer player, ItemStack item) - { - } - /** - * Call in from elsewhere. Unimplemented here. - */ - @Deprecated - public static void onTick(float tick, Object game) - { - } - - public static void openGUI(EntityPlayer player, Object gui) - { - // NOOP - } - - @Deprecated - public static void populateChunk(IChunkProvider generator, int chunkX, int chunkZ, World world) - { - } - - /** - * This method is a call in hook from modified external code. Implemented elsewhere. - * {@link FMLBukkitHandler#handlePacket250(Packet250CustomPayload, EntityHuman)} - * - * @param packet - */ - @Deprecated - public static void receivePacket(Packet250CustomPayload packet) - { - } - - @Deprecated - public static Object[] registerAllKeys(Object[] keys) - { - return keys; - } - - @Deprecated - public static void registerAllTextureOverrides(Object cache) - { - } - - /** - * Register a new block - * - * @param block - */ - public static void registerBlock(Block block) - { - FMLRegistry.registerBlock(block); - } - - /** - * Register a new block - * - * @param block - * @param itemclass - */ - public static void registerBlock(Block block, Class itemclass) - { - FMLRegistry.registerBlock(block, itemclass); - } - - /** - * Register a new entity ID - * - * @param entityClass - * @param entityName - * @param id - */ - public static void registerEntityID(Class entityClass, String entityName, int id) - { - FMLRegistry.registerEntityID(entityClass, entityName, id); - } - - /** - * Register a new entity ID - * - * @param entityClass - * @param entityName - * @param id - * @param background - * @param foreground - */ - public static void registerEntityID(Class entityClass, String entityName, int id, int background, int foreground) - { - FMLRegistry.registerEntityID(entityClass, entityName, id, background, foreground); - } - - public static void registerKey(BaseMod mod, Object keyHandler, boolean allowRepeat) - { - // NOOP - } - - /** - * Register the mod for packets on this channel. This only registers the - * channel with Forge Mod Loader, not with clients connecting- use - * BaseMod.onClientLogin to tell them about your custom channel - * {@link FMLCommonHandler#registerChannel(cpw.mods.fml.common.ModContainer, String)} - * - * @param mod - * @param channel - */ - public static void registerPacketChannel(BaseMod mod, String channel) - { - FMLCommonHandler.instance().registerChannel(ModLoaderModContainer.findContainerFor(mod), channel); - } - - /** - * Register a new tile entity class - * - * @param tileEntityClass - * @param id - */ - public static void registerTileEntity(Class tileEntityClass, String id) - { - FMLRegistry.registerTileEntity(tileEntityClass, id); - } - - public static void registerTileEntity(Class tileEntityClass, String id, Object renderer) - { - FMLRegistry.instance().registerTileEntity(tileEntityClass, id); - } - - /** - * Remove a biome from the list of generated biomes - * - * @param biome - */ - public static void removeBiome(BiomeBase biome) - { - FMLRegistry.removeBiome(biome); - } - - /** - * Remove a spawn - * - * @param entityClass - * @param spawnList - */ - public static void removeSpawn(Class entityClass, EnumCreatureType spawnList) - { - FMLRegistry.removeSpawn(entityClass, spawnList, FMLBukkitHandler.instance().getDefaultOverworldBiomes()); - } - - /** - * Remove a spawn - * - * @param entityClass - * @param spawnList - * @param biomes - */ - public static void removeSpawn(Class entityClass, EnumCreatureType spawnList, BiomeBase... biomes) - { - FMLRegistry.removeSpawn(entityClass, spawnList, biomes); - } - - /** - * Remove a spawn - * - * @param entityName - * @param spawnList - */ - public static void removeSpawn(String entityName, EnumCreatureType spawnList) - { - FMLRegistry.removeSpawn(entityName, spawnList, FMLBukkitHandler.instance().getDefaultOverworldBiomes()); - } - - /** - * Remove a spawn - * - * @param entityName - * @param spawnList - * @param biomes - */ - public static void removeSpawn(String entityName, EnumCreatureType spawnList, BiomeBase... biomes) - { - FMLRegistry.removeSpawn(entityName, spawnList, biomes); - } - - @Deprecated - public static boolean renderBlockIsItemFull3D(int modelID) - { - return false; - } - - @Deprecated - public static void renderInvBlock(Object renderer, Block block, int metadata, int modelID) - { - // NOOP - } - - @Deprecated - public static boolean renderWorldBlock(Object renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID) - { - return false; - } - - /** - * Configuration is handled elsewhere - * {@link ModLoaderModContainer} - */ - @Deprecated - public static void saveConfig() - { - } - - /** - * Send a chat message to the server - * {@link FMLServerHandler#handleChatPacket(Packet3Chat, EntityPlayer)} - * - * @param text - */ - @Deprecated - public static void serverChat(String text) - { - //TODO - } - - @Deprecated - public static void serverLogin(Object handler, Packet1Login loginPacket) - { - //TODO - } - - /** - * Indicate that you want to receive ticks - * - * @param mod receiving the events - * @param enable indicates whether you want to recieve them or not - * @param useClock Not used in server side: all ticks are sent on the server side (no render subticks) - */ - public static void setInGameHook(BaseMod mod, boolean enable, boolean useClock) - { - ModLoaderHelper.updateStandardTicks(mod, enable, useClock); - } - - - public static void setInGUIHook(BaseMod mod, boolean enable, boolean useClock) - { - ModLoaderHelper.updateGUITicks(mod, enable, useClock); - } - - /** - * Set a private field to a value using reflection - * {@link ReflectionHelper#setPrivateValue(Class, Object, int, Object)} - * - * @param instanceclass - * @param instance - * @param fieldindex - * @param value - */ - public static void setPrivateValue(Class instanceclass, T instance, int fieldindex, E value) - { - ReflectionHelper.setPrivateValue(instanceclass, instance, fieldindex, value); - } - - /** - * Set a private field to a value using reflection - * {@link ReflectionHelper#setPrivateValue(Class, Object, String, Object)} - * - * @param instanceclass - * @param instance - * @param field - * @param value - */ - public static void setPrivateValue(Class instanceclass, T instance, String field, E value) - { - ReflectionHelper.setPrivateValue(instanceclass, instance, field, value); - } - - /** - * This method is a call in hook from modified external code. Implemented elsewhere. - * {@link FMLBukkitHandler#onItemCrafted(EntityHuman, ItemStack, IInventory)} - * - * @param player - * @param item - * @param matrix - */ - @Deprecated - public static void takenFromCrafting(EntityHuman player, ItemStack item, IInventory matrix) - { - } - - /** - * This method is a call in hook from modified external code. Implemented elsewhere. - * {@link FMLBukkitHandler#onItemSmelted(EntityHuman, ItemStack)} - * - * @param player - * @param item - */ - @Deprecated - public static void takenFromFurnace(EntityHuman player, ItemStack item) - { - } - - /** - * Throw the offered exception. Likely will stop the game. - * {@link FMLBukkitHandler#raiseException(Throwable, String, boolean)} - * @param message - * @param e - */ - public static void throwException(String message, Throwable e) - { - FMLBukkitHandler.instance().raiseException(e, message, true); - } - - /** - * To properly implement packet 250 protocol you should always check your channel - * is active prior to sending the packet - * - * @param player - * @param channel - * @return - */ - public static boolean isChannelActive(EntityHuman player, String channel) - { - return FMLCommonHandler.instance().isChannelActive(channel, player); - } -} \ No newline at end of file diff --git a/fml/bukkit/net/minecraft/server/SidedProxy.java b/fml/bukkit/net/minecraft/server/SidedProxy.java deleted file mode 100644 index 2cda4c4a26..0000000000 --- a/fml/bukkit/net/minecraft/server/SidedProxy.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * The FML Forge Mod Loader suite. - * Copyright (C) 2012 cpw - * - * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraft.server; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * @author cpw - * - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface SidedProxy -{ - /** - * The name of the client side class to load and populate - * @return - */ - String clientSide() default ""; - - /** - * The name of the server side class to load and populate - * @return - */ - String serverSide() default ""; - - /** - * The name of the a special bukkit plugin class to load and populate - */ - String bukkitSide() default ""; -} diff --git a/fml/bukkit/net/minecraft/src/BiomeGenBase.java b/fml/bukkit/net/minecraft/src/BiomeGenBase.java deleted file mode 100644 index bf1a123a3b..0000000000 --- a/fml/bukkit/net/minecraft/src/BiomeGenBase.java +++ /dev/null @@ -1,5 +0,0 @@ -package net.minecraft.src; - -public interface BiomeGenBase { - -} diff --git a/fml/bukkit/net/minecraft/src/Block.java b/fml/bukkit/net/minecraft/src/Block.java deleted file mode 100644 index 4468337600..0000000000 --- a/fml/bukkit/net/minecraft/src/Block.java +++ /dev/null @@ -1,5 +0,0 @@ -package net.minecraft.src; - -public interface Block { - -} diff --git a/fml/bukkit/net/minecraft/src/Entity.java b/fml/bukkit/net/minecraft/src/Entity.java deleted file mode 100644 index 2ffd2feacc..0000000000 --- a/fml/bukkit/net/minecraft/src/Entity.java +++ /dev/null @@ -1,5 +0,0 @@ -package net.minecraft.src; - -public interface Entity { - -} diff --git a/fml/bukkit/net/minecraft/src/EntityLiving.java b/fml/bukkit/net/minecraft/src/EntityLiving.java deleted file mode 100644 index bb0ead9426..0000000000 --- a/fml/bukkit/net/minecraft/src/EntityLiving.java +++ /dev/null @@ -1,5 +0,0 @@ -package net.minecraft.src; - -public interface EntityLiving { - -} diff --git a/fml/bukkit/net/minecraft/src/EnumCreatureType.java b/fml/bukkit/net/minecraft/src/EnumCreatureType.java deleted file mode 100644 index cce43da204..0000000000 --- a/fml/bukkit/net/minecraft/src/EnumCreatureType.java +++ /dev/null @@ -1,5 +0,0 @@ -package net.minecraft.src; - -public interface EnumCreatureType { - -} diff --git a/fml/bukkit/net/minecraft/src/IRecipe.java b/fml/bukkit/net/minecraft/src/IRecipe.java deleted file mode 100644 index eaa3caedc8..0000000000 --- a/fml/bukkit/net/minecraft/src/IRecipe.java +++ /dev/null @@ -1,5 +0,0 @@ -package net.minecraft.src; - -public interface IRecipe { - -} diff --git a/fml/bukkit/net/minecraft/src/ItemBlock.java b/fml/bukkit/net/minecraft/src/ItemBlock.java deleted file mode 100644 index 0ed5ab5b79..0000000000 --- a/fml/bukkit/net/minecraft/src/ItemBlock.java +++ /dev/null @@ -1,5 +0,0 @@ -package net.minecraft.src; - -public interface ItemBlock { - -} diff --git a/fml/bukkit/net/minecraft/src/ItemStack.java b/fml/bukkit/net/minecraft/src/ItemStack.java deleted file mode 100644 index 533c19451d..0000000000 --- a/fml/bukkit/net/minecraft/src/ItemStack.java +++ /dev/null @@ -1,5 +0,0 @@ -package net.minecraft.src; - -public interface ItemStack { - -} diff --git a/fml/bukkit/net/minecraft/src/TileEntity.java b/fml/bukkit/net/minecraft/src/TileEntity.java deleted file mode 100644 index e29d6a48d2..0000000000 --- a/fml/bukkit/net/minecraft/src/TileEntity.java +++ /dev/null @@ -1,5 +0,0 @@ -package net.minecraft.src; - -public interface TileEntity { - -} diff --git a/fml/cleanup_source.py b/fml/cleanup_source.py deleted file mode 100644 index 30b69b4371..0000000000 --- a/fml/cleanup_source.py +++ /dev/null @@ -1,43 +0,0 @@ -import sys -import os, os.path, shutil -import fnmatch -import re - -def main(): - sys.stdout.flush() - for x in range(1, len(sys.argv)): - cleanup_source(sys.argv[x]) - -count = 0 -def cleanup_source(path): - path = os.path.normpath(path) - regex_cases_before = re.compile(r'((case|default).+\r?\n)\r?\n', re.MULTILINE) #Fixes newline after case before case body - regex_cases_after = re.compile(r'\r?\n(\r?\n[ \t]+(case|default))', re.MULTILINE) #Fixes newline after case body before new case - - def updatefile(src_file): - global count - tmp_file = src_file + '.tmp' - count = 0 - with open(src_file, 'r') as fh: - buf = fh.read() - - def fix_cases(match): - global count - count += 1 - return match.group(1) - - buf = regex_cases_before.sub(fix_cases, buf) - buf = regex_cases_after.sub(fix_cases, buf) - if count > 0: - with open(tmp_file, 'w') as fh: - fh.write(buf) - shutil.move(tmp_file, src_file) - - for path, _, filelist in os.walk(path, followlinks=True): - sub_dir = os.path.relpath(path, path) - for cur_file in fnmatch.filter(filelist, '*.java'): - src_file = os.path.normpath(os.path.join(path, cur_file)) - updatefile(src_file) - -if __name__ == '__main__': - main() diff --git a/fml/commands.patch b/fml/commands.patch deleted file mode 100644 index 9b9702de58..0000000000 --- a/fml/commands.patch +++ /dev/null @@ -1,125 +0,0 @@ ---- commands.py -+++ commands.py -@@ -141,6 +141,8 @@ - fieldnames = csvreader.fieldnames - return set(fieldnames) - -+def commands_sanity_check(): -+ print ' Commands patch applied successfully' - - class Commands(object): - """Contains the commands and initialisation for a full mcp run""" -@@ -952,6 +954,8 @@ - binlk = {CLIENT: self.binclient, SERVER: self.binserver} - testlk = {CLIENT: self.testclient, SERVER: self.testserver} - -+ if side == SERVER and not os.path.exists(os.path.join(binlk[side], os.path.normpath(testlk[side] + '.class'))): -+ return self.checkbins(CLIENT) - if not os.path.exists(os.path.join(binlk[side], os.path.normpath(testlk[side] + '.class'))): - return False - return True -@@ -1283,23 +1287,34 @@ - pathbinlk = {CLIENT: self.binclient, SERVER: self.binserver} - pathsrclk = {CLIENT: self.srcclient, SERVER: self.srcserver} - pathlog = {CLIENT: self.clientrecomplog, SERVER: self.serverrecomplog} -+ -+ if side == SERVER: #Warn about server because FML recombines it into client -+ self.logger.info('Server side recompiling might be skipped, this is normal, do not complain to FML/Forge team about server side.') - - if not os.path.exists(pathbinlk[side]): - os.makedirs(pathbinlk[side]) - - # HINT: We create the list of source directories based on the list of packages - # on windows we just pass wildcards, otherwise we pass the full file list -- if self.osname == 'win': -+ if self.osname == 'win' and False == True: #FML: Disable for windows we write to file now - all_files = False - append_pattern = True - else: - all_files = True - append_pattern = False - pkglist = filterdirs(pathsrclk[side], '*.java', append_pattern=append_pattern, all_files=all_files) -+ from tempfile import NamedTemporaryFile - if self.cmdrecompscala: # Compile scala before java as scala scans java files, but not vice-versa - pkglistscala = pkglist[:] - pkglistscala.extend(filterdirs(pathsrclk[side], '*.scala', append_pattern=append_pattern, all_files=all_files)) -- dirs = ' '.join(pkglistscala) -+ f = NamedTemporaryFile(mode='wb', suffix='.txt', prefix ='scala_src_path_', delete=False) #FML: We write to a temporary file just in case the command is to long -+ for line in pkglistscala: -+ if os.sep == '\\': -+ f.write('"%s"\n' % os.path.abspath(line).replace(os.sep, os.sep + os.sep)) -+ else: -+ f.write('"%s"\n' % os.path.abspath(line)) -+ f.close() -+ dirs = '@"%s"' % f.name - classpath = os.pathsep.join(cplk[side]) - forkcmd = self.cmdrecompscala.format(classpath=classpath, sourcepath=pathsrclk[side], outpath=pathbinlk[side], pkgs=dirs) - try: -@@ -1319,7 +1334,15 @@ - self.logger.error('================================') - self.logger.error('') - raise -- dirs = ' '.join(pkglist) -+ os.unlink(f.name) -+ f = NamedTemporaryFile(mode='wb', suffix='.txt', prefix ='java_src_path_', delete=False) #FML: We write to a temporary file just in case the command is to long -+ for line in pkglist: -+ if os.sep == '\\': -+ f.write('"%s"\n' % os.path.abspath(line).replace('\\', '\\\\')) -+ else: -+ f.write('"%s"\n' % os.path.abspath(line)) -+ f.close() -+ dirs = '@"%s"' % f.name - classpath = os.pathsep.join(cplk[side]) - forkcmd = self.cmdrecomp.format(classpath=classpath, sourcepath=pathsrclk[side], outpath=pathbinlk[side], - pkgs=dirs) -@@ -1338,9 +1361,10 @@ - self.logger.error('==================') - self.logger.error('') - raise -+ os.unlink(f.name) - - def startserver(self, mainclass, extraargs): -- classpath = [self.binserver] + self.cpathserver -+ classpath = [self.binclient, self.srcclient] + self.cpathserver + self.cpathclient - classpath = [os.path.join('..', p) for p in classpath] - classpath = os.pathsep.join(classpath) - os.chdir(self.dirjars) -@@ -1705,7 +1729,7 @@ - self.runcmd(forkcmd) - return True - -- def gathermd5s(self, side, reobf=False): -+ def gathermd5s(self, side, reobf=False, skip_fml=False): - if not reobf: - md5lk = {CLIENT: self.md5client, SERVER: self.md5server} - else: -@@ -1720,6 +1744,9 @@ - class_path = '' - else: - class_path += '/' -+ if skip_fml: -+ if class_path.startswith('cpw/'): -+ continue - for class_file in fnmatch.filter(filelist, '*.class'): - class_name = class_path + os.path.splitext(class_file)[0] - bin_file = os.path.normpath(os.path.join(path, class_file)) -@@ -1892,6 +1919,9 @@ - sys.exit(1) - - for entry in newfiles: -+ if 'commands.py' in entry[0]: #FML, Disable updating of Commands.py -+ print 'Update to runtime/commands.py found, but disbled due to using fml' -+ continue - if entry[3] == 'U': - self.logger.info('Retrieving file from server : %s', entry[0]) - cur_file = os.path.normpath(entry[0]) -@@ -1912,6 +1942,9 @@ - md5reoblk = {CLIENT: self.md5reobfclient, SERVER: self.md5reobfserver} - outpathlk = {CLIENT: self.srcmodclient, SERVER: self.srcmodserver} - src = {CLIENT: self.srcclient, SERVER: self.srcserver} -+ -+ if side == SERVER: #Noop out server side stuff -+ return - - # HINT: We need a table for the old md5 and the new ones - md5table = {} diff --git a/fml/decompile.py b/fml/decompile.py deleted file mode 100644 index 33d93d61d2..0000000000 --- a/fml/decompile.py +++ /dev/null @@ -1,24 +0,0 @@ -import urllib -import zipfile -import sys -import os -from optparse import OptionParser - - -if __name__ == '__main__': - parser = OptionParser() - parser.add_option('-g', '--gen-conf', action="store_true", dest='gen_conf', help='Generate merged MCP conf folder', default=False) - parser.add_option('-m', '--mcp-dir', action='store', dest='mcp_dir', help='Path to download/extract MCP to', default=None ) - parser.add_option('-f', '--fml-dir', action='store', dest='fml_dir', help='Path to FML install folder', default=None ) - options, _ = parser.parse_args() - - if options.fml_dir is None or options.mcp_dir is None: - print 'Invalid arguments, must supply mcp folder and fml folder: decompile.py --mcp-dir --fml-dir ' - else: - sys.path.append(os.path.join(options.fml_dir, 'install')) - - from fml import decompile_minecraft, setup_mcp, download_mcp - - download_mcp(fml_dir=options.fml_dir, mcp_dir=options.mcp_dir) - setup_mcp(options.fml_dir, options.mcp_dir, gen_conf=options.gen_conf) - decompile_minecraft(options.fml_dir, options.mcp_dir) diff --git a/fml/fmlbuild.properties-sample b/fml/fmlbuild.properties-sample deleted file mode 100644 index 715c725284..0000000000 --- a/fml/fmlbuild.properties-sample +++ /dev/null @@ -1,2 +0,0 @@ -default.dev.home=/home/cpw/projects/mcworkspace -default.mcp.home=${default.dev.home}/vanillamcp \ No newline at end of file diff --git a/fml/generatechangedfilelist.py b/fml/generatechangedfilelist.py deleted file mode 100644 index a5ddb48673..0000000000 --- a/fml/generatechangedfilelist.py +++ /dev/null @@ -1,43 +0,0 @@ -import sys -import os -import subprocess, shlex - -mcp_root = os.path.abspath(sys.argv[1]) -sys.path.append(os.path.join(mcp_root,"runtime")) -from filehandling.srgshandler import parse_srg - -def cmdsplit(args): - if os.sep == '\\': - args = args.replace('\\', '\\\\') - return shlex.split(args) - -def main(): - list_file = os.path.abspath(sys.argv[2]) - with open(list_file, 'w') as fh: - write_changed(fh, os.path.join(mcp_root,"temp","client.md5"), os.path.join(mcp_root,"temp","client_reobf.md5"), 'minecraft') - write_changed(fh, os.path.join(mcp_root,"temp","server.md5"), os.path.join(mcp_root,"temp","server_reobf.md5"), 'minecraft_server') - -def write_changed(fh, pre, post, name): - if not os.path.isfile(pre) or not os.path.isfile(post): - print 'MD5s Missing! Can not extract %s changed files' % name - return - - cmd = 'diff --unchanged-group-format='' --old-group-format='' --new-group-format=\'%%>\' --changed-group-format=\'%%>\' %s %s' % (pre, post) - process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, bufsize=-1) - difflist,_= process.communicate() - srg_data = parse_srg(os.path.join(mcp_root,"temp","client_rg.srg")) - classes = {} - for row in srg_data['CL']: - classes[row['deobf_name']] = row['obf_name'] - - for diff in difflist.splitlines(): - diffrow=diff.strip().split() - clazz=diffrow[0] - if clazz in classes: - clazz=classes[clazz] - if clazz.startswith("net/minecraft/src/"): - clazz=clazz[len("net/minecraft/src/"):] - fh.write("%s/%s.class\n" %(name,clazz)) - -if __name__ == '__main__': - main() diff --git a/fml/getversion.py b/fml/getversion.py deleted file mode 100644 index a06eb55ae6..0000000000 --- a/fml/getversion.py +++ /dev/null @@ -1,76 +0,0 @@ -import sys -import os -import commands -import fnmatch -import re -import subprocess, shlex - -mcp_home = sys.argv[1] -mcp_dir = os.path.abspath(mcp_home) - -print(mcp_dir) -sys.path.append(mcp_dir) - -from runtime.commands import Commands -Commands._version_config = os.path.join(mcp_dir,Commands._version_config) - -def cmdsplit(args): - if os.sep == '\\': - args = args.replace('\\', '\\\\') - return shlex.split(args) - -def cleanDirs(path): - if not os.path.isdir(path): - return - - files = os.listdir(path) - if len(files): - for f in files: - fullpath = os.path.join(path, f) - if os.path.isdir(fullpath): - cleanDirs(fullpath) - - files = os.listdir(path) - if len(files) == 0: - os.rmdir(path) - -def main(): - print("Obtaining version information from git") - cmd = "git describe --long --match='[^(jenkins)]*'" - try: - process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1) - vers, _ = process.communicate() - except OSError: - print("Git not found") - vers="v1.0-0-deadbeef" - (major,minor,rev,githash)=re.match("v(\d+).(\d+)-(\d+)-(.*)",vers).groups() - - (mcpversion,mcclientversion,mcserverversion) = re.match("[.\w]+ \(data: ([.\w]+), client: ([.\w.]+), server: ([.\w.]+)\)",Commands.fullversion()).groups() - - if os.getenv("GIT_BRANCH") is None: - cmd = "git rev-parse --abbrev-ref HEAD" - try: - process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1) - branch, _ = process.communicate() - branch = branch.strip() - except OSError: - print("Git not found") - branch="master" - else: - branch=os.getenv("GIT_BRANCH").rpartition('/')[2] - if branch == 'HEAD': - branch = "master" - - with open("fmlversion.properties","w") as f: - f.write("%s=%s\n" %("fmlbuild.major.number",major)) - f.write("%s=%s\n" %("fmlbuild.minor.number",minor)) - f.write("%s=%s\n" %("fmlbuild.revision.number",rev)) - f.write("%s=%s\n" %("fmlbuild.githash",githash)) - f.write("%s=%s\n" %("fmlbuild.mcpversion",mcpversion)) - f.write("%s=%s\n" %("fmlbuild.mcversion",mcclientversion)) - f.write("%s=%s\n" %("fmlbuild.branch",branch)) - - print("Version information: FML %s.%s.%s (%s) using MCP %s for minecraft %s" % (major, minor, rev, branch, mcpversion, mcclientversion)) - -if __name__ == '__main__': - main() diff --git a/fml/ignore-git.sh b/fml/ignore-git.sh deleted file mode 100755 index d7b252d31c..0000000000 --- a/fml/ignore-git.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -git update-index --assume-unchanged eclipse/.metadata/.plugins/org.eclipse.core.resources/.root/0.tree diff --git a/fml/install/.gitignore b/fml/install/.gitignore deleted file mode 100644 index a74b07aee4..0000000000 --- a/fml/install/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/*.pyc diff --git a/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/Minecraft/placeholder b/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/Minecraft/placeholder deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.resources/.root/0.tree b/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.resources/.root/0.tree deleted file mode 100644 index 897e2b8479..0000000000 Binary files a/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.resources/.root/0.tree and /dev/null differ diff --git a/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs b/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 466d7f93a1..0000000000 --- a/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Sun Jun 05 18:58:07 CEST 2011 -version=1 -eclipse.preferences.version=1 -refresh.enabled=true diff --git a/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs b/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs deleted file mode 100644 index 94c56761d3..0000000000 --- a/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs +++ /dev/null @@ -1,7 +0,0 @@ -#Sun Jun 05 19:03:53 CEST 2011 -eclipse.preferences.version=1 -org.eclipse.debug.ui.UseContextualLaunch=false -Console.highWaterMark=88000 -org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=\r\n\r\n -org.eclipse.debug.ui.user_view_bindings=\r\n\r\n\r\n\r\n\r\n\r\n -StringVariablePreferencePage=130,107,107,86, diff --git a/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.usagedata.gathering.prefs b/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.usagedata.gathering.prefs deleted file mode 100644 index 333b991531..0000000000 --- a/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.usagedata.gathering.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Sun Jun 05 18:58:07 CEST 2011 -eclipse.preferences.version=1 -org.eclipse.epp.usagedata.gathering.enabled=false diff --git a/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs b/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 12ec368903..0000000000 --- a/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,14 +0,0 @@ -#Sun Sep 18 16:44:39 NZST 2011 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=ignore -org.eclipse.jdt.core.compiler.problem.deprecation=ignore -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore -org.eclipse.jdt.core.compiler.problem.unusedImport=ignore -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs b/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs deleted file mode 100644 index 316ef6f309..0000000000 --- a/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Sun Jun 05 18:58:05 CEST 2011 -spacesForTabs=true -eclipse.preferences.version=1 -overviewRuler_migration=migrated_3.1 diff --git a/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs b/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs deleted file mode 100644 index ae368abb9e..0000000000 --- a/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Sun Jun 05 18:58:07 CEST 2011 -IMPORT_FILES_AND_FOLDERS_MODE=prompt -IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE=prompt -SAVE_ALL_BEFORE_BUILD=true -eclipse.preferences.version=1 -tipsAndTricks=true -platformState=1287081747687 -quickStart=false -PROBLEMS_FILTERS_MIGRATE=true diff --git a/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs b/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs deleted file mode 100644 index cbc59537b0..0000000000 --- a/fml/install/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Sun Jun 05 18:50:08 CEST 2011 -eclipse.preferences.version=1 -showIntro=false diff --git a/fml/install/eclipse/.metadata/.plugins/org.eclipse.debug.core/.launches/Client.launch b/fml/install/eclipse/.metadata/.plugins/org.eclipse.debug.core/.launches/Client.launch deleted file mode 100644 index a010befe10..0000000000 --- a/fml/install/eclipse/.metadata/.plugins/org.eclipse.debug.core/.launches/Client.launch +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/fml/install/eclipse/.metadata/.plugins/org.eclipse.debug.core/.launches/Server.launch b/fml/install/eclipse/.metadata/.plugins/org.eclipse.debug.core/.launches/Server.launch deleted file mode 100644 index 550685c761..0000000000 --- a/fml/install/eclipse/.metadata/.plugins/org.eclipse.debug.core/.launches/Server.launch +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/fml/install/eclipse/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml b/fml/install/eclipse/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml deleted file mode 100644 index 1208f602e5..0000000000 --- a/fml/install/eclipse/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/fml/install/eclipse/Minecraft/.classpath b/fml/install/eclipse/Minecraft/.classpath deleted file mode 100644 index 888245765a..0000000000 --- a/fml/install/eclipse/Minecraft/.classpath +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/fml/install/eclipse/Minecraft/.project b/fml/install/eclipse/Minecraft/.project deleted file mode 100644 index c560983643..0000000000 --- a/fml/install/eclipse/Minecraft/.project +++ /dev/null @@ -1,78 +0,0 @@ - - - Minecraft - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - - - jars - 2 - MCP_LOC/jars - - - src - 2 - MCP_LOC/src/minecraft - - - lib - 2 - MCP_LOC/lib - - - - - 1372126392133 - jars - 13 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-libraries - - - - 1372126392135 - jars - 13 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-versions - - - - 1372126392137 - jars - 26 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-natives - - - - 1372126425043 - jars/libraries - 21 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-*.jar - - - - - - MCP_LOC - $%7BPARENT-1-WORKSPACE_LOC%7D - - - diff --git a/fml/install/fml.py b/fml/install/fml.py deleted file mode 100644 index 9b13ee2492..0000000000 --- a/fml/install/fml.py +++ /dev/null @@ -1,1325 +0,0 @@ -import os, os.path, sys -import urllib, zipfile, json, urllib2 -import shutil, glob, fnmatch -import subprocess, logging, re, shlex -import csv, ConfigParser -from hashlib import md5 # pylint: disable-msg=E0611 -from pprint import pprint -from zipfile import ZipFile -from pprint import pprint -from contextlib import closing - -#========================================================================== -# Utility Functions -#========================================================================== -def config_get_section(config, section): - dict = {} - options = config.options(section) - for option in options: - try: - dict[option] = config.get(section, option) - except: - dict[option] = None - return dict - -def read_mc_versions(fml_dir, version=None, work_dir=None): - ########################################################################################################### - #Read mc_versions.cfg from the fml folder for the specified version, or the default - #version if none is specified. - # - #Should return a dictionary with the following keys: - # 'new_laucher' True if the version uses the new launcher structure for assets/libraries - # 'client_url' URL path to the minecraft client jar - # 'client_md5' MD5 checksum of the client jar - # 'server_url' URL path to the minecraft server jar - # 'server_md5' MD5 checksum of the server jar - # 'json_url' URL path to the json file for this version, or 'None' if new_launcher is false - # 'mcp_ver' Human readable version for MCP to use for this version of Minecraft - # 'mcp_url' URL path for MCP to download, or 'None' if there isn't one avalible - # 'mcp_md5' MD5 checksum of the MCP archive - # 'mcp_file' File path to the MCP archive - # - # If work_dir is specified the following keys also contain values: - # 'natives_dir' File path to native libraries used by Minecraft - # 'library_dir' File path to 'libraries' folder - # if 'new_launcher' is false this points to work_dir/bin/ and will not be used as maven style folder structure - # if 'new_launcher' is true this points to work_dir/libraraies/ and will use the maven style folder structure - # 'client_file' File path for the client minecraft.jar - # 'server_file' File path to the server minecraft jar - # 'json_file' - # if 'new_launcher' is false, this is 'None' - # if 'new_launcher' is true, this is the path to the version json file on disc. - # 'asset_dir' Folder containering all assets/resources used by minecraft - # - # Note: Because a file is give a path it does NOT mean that it exists! So alway check before using - ############################################################################################################################ - - versions_file = os.path.join(fml_dir, 'mc_versions.cfg') - if not os.path.isfile(versions_file): - print 'Could not find mc_versions.cfg in FML directory.' - sys.exit(1) - - config = ConfigParser.ConfigParser() - config.read(versions_file) - - default = config_get_section(config, 'default') - if version is None: - version = default['current_ver'] - - if not config.has_section(version): - print 'Error: Invalid minecraft version, could not find \'%s\' in mc_versions.cfg' % version - sys.exit(1) - - mc_info = config_get_section(config, version) - mc_info['downloads'] = [] - mc_info['version'] = version - if not 'client_url' in mc_info.keys(): - mc_info['new_launcher'] = True - base_url = 'http://s3.amazonaws.com/Minecraft.Download/versions/%s' % version - mc_info['client_url'] = '%s/%s.jar' % (base_url, version) - mc_info['json_url'] = '%s/%s.json' % (base_url, version) - mc_info['server_url'] = '%s/minecraft_server.%s.jar' % (base_url, version) - if not work_dir is None: - version_dir = os.path.join(work_dir, 'versions', version) - mc_info['natives_dir'] = os.path.join(version_dir, '%s-natives' % version) - mc_info['library_dir'] = os.path.join(work_dir, 'libraries') - mc_info['client_file'] = os.path.join(version_dir, '%s.jar' % version) - mc_info['json_file'] = os.path.join(version_dir, '%s.json' % version) - mc_info['server_file'] = os.path.join(work_dir, 'minecraft_server.%s.jar' % version) - mc_info['asset_dir'] = os.path.join(work_dir, 'assets') - else: - mc_info['new_launcher'] = False - mc_info['json_url'] = None - if not work_dir is None: - mc_info['natives_dir'] = os.path.join(work_dir, 'bin', 'natives') - mc_info['library_dir'] = os.path.join(work_dir, 'bin') - mc_info['client_file'] = os.path.join(work_dir, 'bin', 'minecraft.jar') - mc_info['json_file'] = None - mc_info['server_file'] = os.path.join(work_dir, 'minecraft_server.jar') - mc_info['asset_dir'] = os.path.join(work_dir, 'resources') - for lib in default['libraries'].split(' '): - mc_info['libraries'].append({ - 'url' : default['base_url'] + lib, - 'file' : os.path.join(work_dir, 'bin', lib), - 'extract' : None, - 'md5' : None - }) - for native in default['natives'].split(' '): - mc_info['libraries'].append({ - 'url_ex' : default['base_url'] + lib, - 'file' : os.path.join(work_dir, 'bin', lib), - 'extract' : { 'exclude' : ['META-INF/'] }, - 'md5' : None - }) - - if not mc_info['mcp_url'].startswith('http'): - mc_info['mcp_url'] = None - mc_info['mcp_file'] = os.path.join(fml_dir, 'mcp%s.zip' % mc_info['mcp_ver']) - - if not work_dir is None: - for x in ['natives_dir', 'library_dir', 'asset_dir']: - if not os.path.isdir(mc_info[x]): - os.makedirs(mc_info[x]) - for x in ['client_file', 'server_file', 'json_file', 'mcp_file']: - if mc_info[x] is None: - continue - dir = os.path.dirname(mc_info[x]) - if not os.path.isdir(dir): - os.makedirs(dir) - - return mc_info - -def download_file(url, target, md5=None, root=None, prefix=''): - name = os.path.basename(target) - - if not root is None: - name = os.path.abspath(target) - name = name[len(os.path.abspath(root)) + 1:] - - dir = os.path.dirname(target) - if not os.path.isdir(dir): - os.makedirs(dir) - - if os.path.isfile(target) and not md5 == None: - if not get_md5(target) == md5: - print '%s%s Modified, removing' % (prefix, name) - os.remove(target) - - if not os.path.isfile(target): - try: - urllib.urlretrieve(url, target) - if not md5 == None: - if not get_md5(target) == md5: - print '%sDownload of %s failed md5 check, deleting' % (prefix, name) - os.remove(target) - return False - if prefix == '': - print 'Downloaded %s' % name - else: - print '%s%s Done' % (prefix, name) - except Exception as e: - print e - print '%sDownload of %s failed, download it manually from \'%s\' to \'%s\'' % (prefix, target, url, target) - return False - return True - -def get_headers(url): - #Connects to the given URL and requests just the headers, No data - #Used when talking to Minecraft's asset/library server to gather server side MD5's - #Returns a dictionary of all headers - class HeadRequest(urllib2.Request): - def get_method(self): - return 'HEAD' - response = urllib2.urlopen(HeadRequest(url)) - array = [line.rstrip('\r\n') for line in response.info().headers] - dict = {} - for line in array: - pts = line.split(':', 1) - pts[1] = pts[1].strip() - #Strip the first and last "s if the stirng is surrounded with them - if pts[1][0] == '"' and pts[1][-1] == '"': - pts[1] = pts[1][1:-1] - dict[pts[0]] = pts[1] - - return dict - -def get_md5(file): - #Returns the MD5 digest of the specified file, or None if the file doesnt exist - if not os.path.isfile(file): - return None - with closing(open(file, 'rb')) as fh: - return md5(fh.read()).hexdigest() - -def fix_patch(in_file, out_file, find=None, rep=None): - #Fixes the following issues in the patch file if they exist: - # Normalizes the path seperators for the current OS - # Normalizes the line endings - # Returns the path that the file wants to apply to - - in_file = os.path.normpath(in_file) - if out_file is None: - tmp_file = in_file + '.tmp' - else: - out_file = os.path.normpath(out_file) - tmp_file = out_file - dir_name = os.path.dirname(out_file) - if dir_name: - if not os.path.exists(dir_name): - os.makedirs(dir_name) - - file = 'not found' - with open(in_file, 'rb') as inpatch: - with open(tmp_file, 'wb') as outpatch: - for line in inpatch: - line = line.rstrip('\r\n') - if line[:3] in ['+++', '---', 'Onl', 'dif']: - if not find == None and not rep == None: - line = line.replace('\\', '/').replace(find, rep).replace('/', os.sep) - else: - line = line.replace('\\', '/').replace('/', os.sep) - outpatch.write(line + os.linesep) - else: - outpatch.write(line + os.linesep) - if line[:3] == '---': - file = line[line.find(os.sep, line.find(os.sep)+1)+1:] - - if out_file is None: - shutil.move(tmp_file, in_file) - return file - -def apply_patch(patch, target, mcp_dir): - temp = os.path.abspath('temp.patch') - cmd = 'patch -i "%s" ' % temp - - if os.name == 'nt': - applydiff = os.path.abspath(os.path.join(mcp_dir, 'runtime', 'bin', 'applydiff.exe')) - cmd = '"%s" -uf -i "%s"' % (applydiff, temp) - - if os.sep == '\\': - cmd = cmd.replace('\\', '\\\\') - cmd = shlex.split(cmd) - - fix_patch(patch, temp) - - process = subprocess.Popen(cmd, cwd=os.path.join(mcp_dir, 'runtime'), bufsize=-1) - process.communicate() - - if os.path.isfile(temp): - os.remove(temp) - -def file_backup(file, md5=None): - #Takes a backup of the passed in file - #Verifying the md5 sum if it's specified - #At the end of this things should be in one of two states: - # 1) file and file.backup exist, both are valid and match the md5 provided - # 2) neither file or file.backup exist, as they both failed the md5 check - - base = os.path.dirname(file) - name = os.path.basename(file) - bck = os.path.join(base, name + '.backup') - src = os.path.join(base, name) - - if not os.path.isfile(src) and not os.path.isfile(bck): - return - - if os.path.isfile(bck): - if get_md5(bck) == md5 or md5 is None: - if os.path.isfile(src): - os.remove(src) - shutil.move(bck, src) - else: - os.remove(bck) - - if os.path.isfile(src): - if not get_md5(src) == md5 and not md5 is None: - print 'Modified %s detected, removing' % os.path.basename(src) - os.remove(src) - else: - shutil.copy(src, bck) - -def normaliselines(file): - #Normalises the lines of the specified file to linux \n line endings - file = os.path.normpath(file) - tmp = file + '.tmp' - - with open(file, 'rb') as in_file: - with open(tmp, 'wb') as out_file: - out_file.write(in_file.read().replace('\r\n', '\n')) - - shutil.move(tmp, file) - -def load_srg(srg_file, reverse=False): - #Loads a Retroguard .srg file into a dictonary - #If reverse if true, the mappings are reversed - with open(srg_file, 'r') as fh: - lines = fh.readlines() - srg = {'CL:': {}, 'MD:': {}, 'FD:': {}, 'PK:': {}} - - for line in lines: - line = line.strip() - if len(line) == 0: continue - if line[0] == '#': continue - args = line.split(' ') - type = args[0] - - if type == 'PK:' or type == 'CL:' or type == 'FD:': - srg[type][args[1]] = args[2] - elif type == 'MD:': - srg[type][args[1] + ' ' + args[2]] = args[3] + ' ' + args[4] - else: - assert 'Unknown type %s' % line - - if reverse: - for type,map in srg.items(): - srg[type] = dict([[v,k] for k,v in map.items()]) - return srg - -def extract_zip(src, dst, prefix=None, filter=[]): - # Extract a zip rchive to the specified folder, - # Filtering out anything that matches the supplied filters - - def is_filtered(name, excludes): - for ex in excludes: - if name.startswith(ex): - return True - return name.endswith('/') - - zip = ZipFile(src) - for name in zip.namelist(): - if is_filtered(name, filter): - continue - out_file = os.path.join(dst, os.sep.join(name.split('/'))) - - if not os.path.isfile(out_file): - dir = os.path.dirname(out_file) - if not os.path.isdir(dir): - os.makedirs(dir) - - if not prefix is None: - print '%sExtracting %s' % (prefix, name) - out = open(out_file, 'wb') - out.write(zip.read(name)) - out.flush() - out.close() - zip.close() - -def merge_tree(root_src_dir, root_dst_dir, prefix=None): - #Merges the source directory into the dest directory, - #will overwrite anything the currently exists - for src_dir, dirs, files in os.walk(root_src_dir): - dst_dir = src_dir.replace(root_src_dir, root_dst_dir) - clean_dir = src_dir.replace(root_src_dir, '')[1:] - if not os.path.exists(dst_dir): - os.mkdir(dst_dir) - for file_ in files: - src_file = os.path.join(src_dir, file_) - dst_file = os.path.join(dst_dir, file_) - if os.path.exists(dst_file): - os.remove(dst_file) - shutil.copy(src_file, dst_dir) - if not prefix is None: - print('%s%s%s'% (prefix, clean_dir, file_)) - -def read_file(file): - if not os.path.exists(file): - return None - buf = None - with closing(open(file, 'r')) as fh: - buf = fh.read() - return buf - -def runcmd(cmd, echo=True, commands=None): - forklist = cmdsplit(cmd) - process = subprocess.Popen(forklist, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1) - output, _ = process.communicate() - - if echo and not commands is None: - for line in output.splitlines(): - commands.logger.info(line) - - if process.returncode: - if not echo and not commands is None: - for line in output.splitlines(): - commands.logger.info(line) - return False - return True - -def cmdsplit(args): - if os.sep == '\\': - args = args.replace('\\', '\\\\') - return shlex.split(args) - -def kill_signatures(jar_file): - # Removes everything in a jar file's META-INF folder, typically used to remove signature data - dir = os.path.dirname(jar_file) - name = os.path.basename(jar_file) - tmp_jar = os.path.join(dir, '%s.temp' % name) - - if not os.path.isfile(jar_file): - return - - if os.path.isfile(tmp_jar): - os.remove(tmp_jar) - - shutil.move(jar_file, tmp_jar) - - print('Stripping META-INF from %s' % jar_file) - - with closing(zipfile.ZipFile(tmp_jar, mode='a')) as zip_in: - with closing(zipfile.ZipFile(jar_file, 'w', zipfile.ZIP_DEFLATED)) as zip_out: - for i in zip_in.filelist: - if not i.filename.startswith('META-INF'): - c = zip_in.read(i.filename) - zip_out.writestr(i.filename, c) - else: - print(' Skipping: %s' % i.filename) - os.remove(tmp_jar) - -def apply_patches(mcp_dir, patch_dir, target_dir, find=None, rep=None): - # Attempts to apply a directory full of patch files onto a target directory. - sys.path.append(mcp_dir) - - temp = os.path.abspath('temp.patch') - cmd = cmdsplit('patch -p2 -i "%s" ' % temp) - - if os.name == 'nt': - applydiff = os.path.abspath(os.path.join(mcp_dir, 'runtime', 'bin', 'applydiff.exe')) - cmd = cmdsplit('"%s" -uf -p2 -i "%s"' % (applydiff, temp)) - - for path, _, filelist in os.walk(patch_dir, followlinks=True): - for cur_file in fnmatch.filter(filelist, '*.patch'): - patch_file = os.path.normpath(os.path.join(patch_dir, path[len(patch_dir)+1:], cur_file)) - target_file = os.path.join(target_dir, fix_patch(patch_file, temp, find, rep)) - process = subprocess.Popen(cmd, cwd=target_dir, bufsize=-1) - process.communicate() - - if os.path.isfile(temp): - os.remove(temp) - -#Taken from: http://stackoverflow.com/questions/7545299/distutil-shutil-copytree -def _mkdir(newdir): - """works the way a good mkdir should :) - - already exists, silently complete - - regular file in the way, raise an exception - - parent directory(ies) does not exist, make them as well - """ - if os.path.isdir(newdir): - pass - elif os.path.isfile(newdir): - raise OSError("a file with the same name as the desired " \ - "dir, '%s', already exists." % newdir) - else: - head, tail = os.path.split(newdir) - if head and not os.path.isdir(head): - _mkdir(head) - #print "_mkdir %s" % repr(newdir) - if tail: - os.mkdir(newdir) -#Taken from: http://stackoverflow.com/questions/7545299/distutil-shutil-copytree -def copytree(src, dst, verbose=0, symlinks=False): - """Recursively copy a directory tree using copy2(). - - The destination directory must not already exist. - If exception(s) occur, an Error is raised with a list of reasons. - - If the optional symlinks flag is true, symbolic links in the - source tree result in symbolic links in the destination tree; if - it is false, the contents of the files pointed to by symbolic - links are copied. - - XXX Consider this example code rather than the ultimate tool. - - """ - - if verbose == -1: - verbose = len(os.path.abspath(dst)) + 1 - names = os.listdir(src) - # os.makedirs(dst) - _mkdir(dst) # XXX - errors = [] - for name in names: - srcname = os.path.join(src, name) - dstname = os.path.join(dst, name) - try: - if symlinks and os.path.islink(srcname): - linkto = os.readlink(srcname) - os.symlink(linkto, dstname) - elif os.path.isdir(srcname): - copytree(srcname, dstname, verbose, symlinks) - else: - shutil.copy2(srcname, dstname) - if verbose > 0: - print os.path.abspath(dstname)[verbose:] - # XXX What about devices, sockets etc.? - except (IOError, os.error), why: - errors.append((srcname, dstname, str(why))) - # catch the Error from the recursive copytree so that we can - # continue with other files - except Exception, err: - errors.extend(err.args[0]) - try: - shutil.copystat(src, dst) - except WindowsError: - # can't copy file access times on Windows - pass - -#========================================================================== -# MCP Related Functions -#========================================================================== -def download_mcp(fml_dir, mcp_dir, version=None): - if os.path.isfile(os.path.join(mcp_dir, 'runtime', 'commands.py')): - print 'MCP Detected already, not downloading' - return True - - if os.path.isdir(mcp_dir): - print 'Old MCP Directory exists, but MCP was not detected, please delete MCP directory at \'%s\'' % mcp_dir - sys.exit(1) - - mc_info = read_mc_versions(fml_dir, version=version) - - print('Checking MCP zip (may take time to download)') - if not download_file(mc_info['mcp_url'], mc_info['mcp_file'], mc_info['mcp_md5']): - sys.exit(1) - - if not os.path.isdir(mcp_dir): - _mkdir(mcp_dir) - - print 'Extracting MCP to \'%s\'' % mcp_dir - extract_zip(mc_info['mcp_file'], mcp_dir, filter=['eclipse']) #, prefix=' ') - - #If we're not on windows, lets set the executable flag on all shell scripts and astyle-osx - if os.name != 'nt': - for path, _, filelist in os.walk(mcp_dir): - for cur_file in fnmatch.filter(filelist, '*.sh'): - file_name = os.path.join(path, cur_file) - process = subprocess.Popen(cmdsplit('chmod +x "%s"' % file_name), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1) - output, _ = process.communicate() - - process = subprocess.Popen(cmdsplit('chmod +x "%s/runtime/bin/astyle-osx"' % mcp_dir), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1) - output, _ = process.communicate() - - #As a helper to build servers, or people who don't wish to download all libraris and assets every time. - #Copy all data from 'mcp_data' to the mcp directory - data_dir = os.path.join(fml_dir, 'mcp_data') - if os.path.isdir(data_dir): - print 'Moving mcp_data to MCP' - merge_tree(data_dir, mcp_dir)##, prefix=' ') - - return True - -def setup_mcp(fml_dir, mcp_dir, gen_conf=True): - #Modifies MCP to the state FML needs it in for recompile/reobf/etc to work as we intend it. - #Does not decompile minecraft in this stage! - - print('Setting up MCP') - runtime = os.path.join(mcp_dir, 'runtime', 'commands.py') - file_backup(runtime) - - patch = os.path.join(fml_dir, 'commands.patch') - - if not os.path.isfile(patch): - raise Exception('Commands.py patch not found %s' % patch) - return - - print('Patching commands.py') - apply_patch(patch, runtime, mcp_dir=mcp_dir) - - try: - sys.path.append(mcp_dir) - from runtime.commands import commands_sanity_check - commands_sanity_check() - except ImportError as ex: - print('Could not verify commands.py patch integrity, this typically means that you are not in a clean MCP environment.') - print('Download a clean version of MCP %s and try again' % mcp_version) - print(ex) - sys.exit(1) - - mcp_conf = os.path.join(mcp_dir, 'conf') - mcp_conf_bak = os.path.join(mcp_dir, 'conf.bak') - fml_conf = os.path.join(fml_dir, 'conf') - - if gen_conf: - if os.path.isdir(mcp_conf_bak): - print 'Reverting old conf backup folder' - shutil.rmtree(mcp_conf) - os.rename(mcp_conf_bak, mcp_conf) - - create_merged_conf(mcp_dir, fml_dir) - - print 'Backing up MCP Conf' - os.rename(mcp_conf, mcp_conf_bak) - else: - shutil.rmtree(mcp_conf) - - print 'Copying FML conf' - shutil.copytree(fml_conf, mcp_conf) - - create_renamed_conf(mcp_dir, fml_dir) - - #update workspace - if not os.path.isfile(os.path.join(fml_dir, 'fmlbuild.properties-sample')): - mcp_eclipse = os.path.join(mcp_dir, 'eclipse') - - if os.path.isdir(os.path.join(mcp_eclipse, 'Client')) and os.path.isdir(os.path.join(mcp_eclipse, 'Server')): - shutil.rmtree(mcp_eclipse) - - if not os.path.isdir(mcp_eclipse) and os.path.isdir(os.path.join(fml_dir, 'eclipse')): - print 'Fixing MCP Workspace' - copytree(os.path.join(fml_dir, 'eclipse'), mcp_eclipse) - -def whereis(filename, rootdir): - # Snagged from MCP - if not os.path.exists(rootdir): - return [] - #logging.info('> Searching for %s in %s', filename, rootdir) - results = [] - for path, _, filelist in os.walk(rootdir): - if filename in filelist: - results.append(path) - return results - -def find_java(): - # Snagged from MCP so we can gather this info without setting up it's Command object - results = [] - if os.name == 'nt': - if not results: - import _winreg - for flag in [_winreg.KEY_WOW64_64KEY, _winreg.KEY_WOW64_32KEY]: - try: - k = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r'Software\JavaSoft\Java Development Kit', 0, _winreg.KEY_READ | flag) - version, _ = _winreg.QueryValueEx(k, 'CurrentVersion') - k.Close() - k = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r'Software\JavaSoft\Java Development Kit\%s' % version, 0, _winreg.KEY_READ | flag) - path, _ = _winreg.QueryValueEx(k, 'JavaHome') - k.Close() - path = os.path.join(str(path), 'bin') - if (runcmd('"%s" -version' % os.path.join(path, 'javac'))): - results.append(path) - except (OSError): - pass - if not results: - if (runcmd('javac -version')): - results.append('') - if not results and 'ProgramW6432' in os.environ: - results.extend(whereis('javac.exe', os.environ['ProgramW6432'])) - if not results and 'ProgramFiles' in os.environ: - results.extend(whereis('javac.exe', os.environ['ProgramFiles'])) - if not results and 'ProgramFiles(x86)' in os.environ: - results.extend(whereis('javac.exe', os.environ['ProgramFiles(x86)'])) - else: - if not results: - if (runcmd('javac -version')): - results.append('') - if not results: - results.extend(whereis('javac', '/usr/bin')) - if not results: - results.extend(whereis('javac', '/usr/local/bin')) - if not results: - results.extend(whereis('javac', '/opt')) - if not results: - print('Java JDK is not installed ! Please install java JDK from http://java.oracle.com') - sys.exit(1) - - return { - 'javac' : '"%s"' % os.path.join(results[0], 'javac'), - 'java' : '"%s"' % os.path.join(results[0], 'java') - } - -#================================================================================== -# MCP Conf Merger Code -#================================================================================== -def create_merged_conf(mcp_dir, fml_dir): - print('Creating merged conf') - #Creates the merged conf folder from MCP's conf folder to fml_dir/conf - - #Lets grab the files we dont work on - for file in ['version.cfg', 'joined.exc']: - dst_file = os.path.join(fml_dir, 'conf', file) - src_file = os.path.join(mcp_dir, 'conf', file) - if not os.path.isdir(os.path.dirname(dst_file)): - os.makedirs(os.path.dirname(dst_file)) - if os.path.exists(dst_file): - os.remove(dst_file) - shutil.copy(src_file, dst_file) - normaliselines(dst_file) - print(' Copying %s' % os.path.normpath(src_file)) - - print(' Generating merged Retroguard data') - common_srg = create_merged_srg(mcp_dir, fml_dir) - print(' Reading merged MCInjector config') - common_exc = load_merged_exc(mcp_dir, fml_dir) - print(' Gathering list of common searge names') - common_map = create_shared_searge_names(common_srg, common_exc) - - for x in [['fields.csv', 'searge'], ['methods.csv', 'searge'], ['params.csv', 'param']]: - print(' Generating merged csv for %s' % x[0]) - create_merged_csv(common_map, os.path.join(mcp_dir, 'conf', x[0]), os.path.join(fml_dir, 'conf', x[0]), main_key=x[1]) - -def create_merged_srg(mcp_dir, fml_dir): - #Merges two .srg files together to create one master mapping. - # When issues are encountered, they are reported but the client srg is trusted over the server - client_file = os.path.join(mcp_dir, 'conf', 'client.srg') - server_file = os.path.join(mcp_dir, 'conf', 'server.srg') - - if not os.path.isfile(client_file) or not os.path.isfile(server_file): - print(' Could not find client and server srg files in "%s"' % mcp_dir) - return False - - client = load_srg(client_file) - server = load_srg(server_file) - - common = {'PK:': {}, 'CL:': {}, 'FD:': {}, 'MD:': {}} - for type in common: - for key, value in client[type].items(): - if key in server[type]: - if value == server[type][key]: - client[type].pop(key) - server[type].pop(key) - common[type][key] = value - - for type in common: - for key, value in client[type].items(): - common[type][key] = value + ' #C' # Tag the client only entries - - for type in common: - for key, value in server[type].items(): - common[type][key] = value + ' #S' # Tag the server only entries - - if not fml_dir is None: - #Print joined retroguard files - with open(os.path.join(fml_dir, 'conf', 'joined.srg'), 'wb') as f: - for type in ['PK:', 'CL:', 'FD:', 'MD:']: - for key in sorted(common[type]): - f.write('%s %s %s\n' % (type, key, common[type][key])) - - return common - -def load_merged_exc(mcp_dir, fml_dir): - #Reads the exc file into a dictionary - joined = {} - with open(os.path.join(mcp_dir, 'conf', 'joined.exc'), 'r') as fh: - for line in fh: - if not line.startswith('#'): - pts = line.rstrip('\r\n').split('=') - joined[pts[0]] = pts[1] - - return joined - -def create_shared_searge_names(common_srg, common_exc): - #Creates an array of all srg names that are common on both the client and server - field = re.compile(r'field_[0-9]+_[a-zA-Z_]+$') - method = re.compile(r'func_[0-9]+_[a-zA-Z_]+') - param = re.compile(r'p_[\w]+_\d+_') - - searge = [] - - for key, value in common_srg['FD:'].items(): - m = field.search(value) - if not m is None and not '#' in value: - if not m.group(0) in searge: - searge.append(m.group(0)) - - for key, value in common_srg['MD:'].items(): - m = method.search(value) - if not m is None and not '#' in value: - if not m.group(0) in searge: - searge.append(m.group(0)) - - for key, value in common_exc.items(): - m = param.findall(value) - if not m is None: - for p in m: - if not p in searge: - searge.append(p) - - return searge - -def create_merged_csv(common_map, in_file, out_file, main_key='searge'): - #Filter throw the csv and condense 'shared' mappings into one entry of side 2 - fields = [] - data = [] - with closing(open(in_file, 'r')) as fh: - reader = csv.DictReader(fh) - fields = reader.fieldnames - data = [r for r in reader] - - side = [ - [r for r in data if r['side'] == '0' and not r[main_key] in common_map], - [r for r in data if r['side'] == '1' and not r[main_key] in common_map], - sorted([r for r in data if r[main_key] in common_map], key=lambda row: row['side']) - ] - - added = [] - common = [] - for row in side[2]: - if not row[main_key] in added: - row['side'] = '2' - added.append(row[main_key]) - common.append(row) - - with closing(open(out_file, 'wb')) as fh: - writer = csv.DictWriter(fh, fieldnames=fields, lineterminator='\n') - writer.writeheader() - for row in sorted(side[0] + side[1] + common, key=lambda row: row[main_key]): - writer.writerow(row) - -def create_renamed_conf(mcp_dir, fml_dir): - # Creates copies of the joined srg and exec files with the new Packaged names - # Also updates the patches in the conf folder for the new packaged names - print('Creating Repackaged data') - pkg_file = os.path.join(fml_dir, 'conf', 'packages.csv') - - pkgs = {} - if os.path.isfile(pkg_file): - with closing(open(pkg_file)) as fh: - reader = csv.DictReader(fh) - for line in reader: - pkgs[line['class']] = line['package'] - - def repackage_class(pkgs, cls): - if cls.startswith('net/minecraft/src/'): - tmp = cls[18:] - if tmp in pkgs.keys(): - return '%s/%s' % (pkgs[tmp], tmp) - return cls - - for ext in ['srg', 'exc']: - regnms = re.compile(r'net/minecraft/src/(\w+)') - print(' Creating re-packaged %s' % ext) - - buf = read_file(os.path.join(mcp_dir, 'conf', 'joined.%s' % ext)) - def mapname(match): - return repackage_class(pkgs, match.group(0)) - buf = regnms.sub(mapname, buf) - - with closing(open(os.path.join(mcp_dir, 'conf', 'packaged.%s' % ext), 'wb')) as outf: - outf.write(buf) - - print(' Creating re-packaged MCP patches') - - def fix_patches(patch_in, patch_tmp): - regnms = re.compile(r'net\\minecraft\\src\\(\w+)') - with closing(open(patch_in, 'r')) as fh: - buf = fh.read() - def mapname(match): - return repackage_class(pkgs, match.group(0).replace('\\', '/')).replace('/', '\\') - buf = regnms.sub(mapname, buf) - - with closing(open(patch_tmp, 'w')) as fh: - fh.write(buf) - - shutil.move(patch_tmp, patch_in) - - patch_dir = os.path.join(mcp_dir, 'conf', 'patches') - fix_patches(os.path.join(patch_dir, 'minecraft_ff.patch' ), os.path.join(patch_dir, 'tmp.patch')) - fix_patches(os.path.join(patch_dir, 'minecraft_server_ff.patch'), os.path.join(patch_dir, 'tmp.patch')) - -#========================================================================== -# MCP Decompile Process -#========================================================================== -def reset_logger(): - # Resets the logging handlers, if we don't do this, we get multi-prints from MCP - log = logging.getLogger() - while len(log.handlers) > 0: - log.removeHandler(log.handlers[0]) - -count = 0 -def cleanup_source(path): - # We cleanup various things in MCP such as: - # astyle differences: - # newline after case before case body - # newline after case body before new case - # We also assign jad-style names to local variables in decompiled code. - - from rename_vars import rename_class - path = os.path.normpath(path) - regex_cases_before = re.compile(r'((case|default).+\r?\n)\r?\n', re.MULTILINE) #Fixes newline after case before case body - regex_cases_after = re.compile(r'\r?\n(\r?\n[ \t]+(case|default))', re.MULTILINE) #Fixes newline after case body before new case - - def updatefile(src_file): - global count - tmp_file = src_file + '.tmp' - count = 0 - with open(src_file, 'r') as fh: - buf = fh.read() - - def fix_cases(match): - global count - count += 1 - return match.group(1) - - buf = regex_cases_before.sub(fix_cases, buf) - buf = regex_cases_after.sub(fix_cases, buf) - old = buf.replace('\r', '') - buf = rename_class(old, MCP=True) - - if count > 0 or buf != old: - with open(tmp_file, 'w') as fh: - fh.write(buf) - shutil.move(tmp_file, src_file) - - for path, _, filelist in os.walk(path, followlinks=True): - sub_dir = os.path.relpath(path, path) - for cur_file in fnmatch.filter(filelist, '*.java'): - src_file = os.path.normpath(os.path.join(path, cur_file)) - updatefile(src_file) - -compile_tools = True -client_jar = None -def decompile_minecraft(fml_dir, mcp_dir, disable_at=False, disable_merge=False, enable_server=False, disable_client=False, disable_assets=False): - # This is where the bulk of the decompile actually happens - # Its a bit of a pain as we need to hook into MCP's Commands class to inject our transformers at certian times. - global compile_tools - global client_jar - - sys.path.append(mcp_dir) - from runtime.decompile import decompile - from runtime.cleanup import cleanup - from runtime.commands import Commands, CLIENT, SERVER - - fml_dir = os.path.abspath(fml_dir) - - # Make sure the src directroy is dead - src_dir = os.path.join(mcp_dir, 'src') - if os.path.isdir(src_dir): - os.chdir(mcp_dir) - cleanup(None, False, False) - reset_logger() - os.chdir(fml_dir) - - if os.path.isdir(src_dir): - print 'Please make sure to backup your modified files, and say yes when it asks you to do cleanup.' - sys.exit(1) - - compile_tools = True - - # Inject ourselves before RetroGuard if it's used - def applyrg_shunt(self, side, reobf=False, applyrg_real=Commands.applyrg): - transformers_hook(self, side) - self.logger.info('> Really Applying Retroguard') - applyrg_real(self, side, reobf) - # Inject ourselves before SpecialSource if it's used - def applyss_shunt(self, side, reobf=False, srg_names=False, in_jar=None, out_jar=None, keep_lvt=False, keep_generics=False, applyss_real=Commands.applyss): - transformers_hook(self, side) - self.logger.info('> Really Applying SpecialSource') - applyss_real(self, side, reobf=reobf, srg_names=srg_names, in_jar=in_jar, out_jar=out_jar, keep_lvt=keep_lvt, keep_generics=keep_generics) - - # This is our pre-everything hook. - # We do the following: - # Verify if astyle is installed/accessible, if not then exit - # We also compile and run our transformers: - # MCPMerge, This merges the runnable code from the server and client creating a single codebase that is complete. - # AccessTransformer: - # This changes access levels of classes fields and methods based on a configuration map. - # Allows up to keep out base edits down because we don't have to patch the access levels of everything. - def transformers_hook(self, side): - global compile_tools - if not self.has_wine and not self.has_astyle: - self.logger.error('!! Please install either wine or astyle for source cleanup !!') - self.logger.error('!! This is REQUIRED by FML/Forge Cannot proceed !!') - sys.exit(1) - jars = {CLIENT: self.jarclient, SERVER: self.jarserver} - kill_signatures(jars[side]) - - dir_bin = os.path.join(fml_dir, 'bin') - if not os.path.isdir(dir_bin): - os.makedirs(dir_bin) - - class_path = os.pathsep.join([f for f in self.cpathclient + [dir_bin] if not f in jars.values()]) - dir_common = os.path.join(fml_dir, 'common') - dir_trans = os.path.join(dir_common, 'cpw/mods/fml/common/asm/transformers'.replace('/', os.sep)) - java = self.cmdjava.translate(None, '"') - javac = self.cmdjavac.translate(None, '"') - cmd_compile = '"%s" -Xlint:-options -deprecation -g -source 1.6 -target 1.6 -classpath "{classpath}" -sourcepath "{sourcepath}" -d "{outpath}" "{target}"' % javac - cmd_compile = cmd_compile.format(classpath=class_path, sourcepath=dir_common, outpath=dir_bin, target="{target}") - - #Compile AccessTransformer and MCPMerger if we havent already - # Only needs to happen once, but we don't know if were gunna decompile both client and server so cant do it based off side - if compile_tools: - self.logger.info('> Compiling AccessTransformer') - if not runcmd(cmd_compile.format(target=os.path.join(dir_trans, 'AccessTransformer.java')), commands=self, echo=False): - sys.exit(1) - - self.logger.info('> Compiling MCPMerger') - if not runcmd(cmd_compile.format(target=os.path.join(dir_trans, 'MCPMerger.java')), commands=self, echo=False): - sys.exit(1) - - compile_tools = False - - # Merge the client and server jar, only needs to be run once so only do it on the client - if side == CLIENT: - if not disable_merge: - self.logger.info('> Running MCPMerger') - forkcmd = ('"%s" -classpath "{classpath}" cpw.mods.fml.common.asm.transformers.MCPMerger "{mergecfg}" "{client}" "{server}"' % java).format( - classpath=class_path, mergecfg=os.path.join(fml_dir, 'mcp_merge.cfg'), client=jars[CLIENT], server=jars[SERVER]) - - if not runcmd(forkcmd, echo=False, commands=self): - sys.exit(1) - else: - self.logger.info('> MCPMerge disabled') - - apply_ats(fml_dir, mcp_dir, class_path, jars[side], disable_at=disable_at, commands=self) - - #Check the original jars not the transformed jars - def checkjars_shunt(self, side, checkjars_real = Commands.checkjars): - self.jarclient = self.jarclient + '.backup' - self.jarserver = self.jarserver + '.backup' - ret = checkjars_real(self, side) - self.jarclient = self.jarclient[:-7] - self.jarserver = self.jarserver[:-7] - return ret - - try: - pre_decompile(mcp_dir, fml_dir, disable_assets=disable_assets) - - os.chdir(mcp_dir) - Commands.applyrg = applyrg_shunt - Commands.applyss = applyss_shunt - Commands.checkjars = checkjars_shunt - #decompile -d -n -r - # Conf JAD CSV -r -d -a -n -p -o -l -g -c -s --rg --workDir --json(None=compute) --nocopy - decompile(None, False, False, True, True, False, True, False, False, False, False, not disable_client, enable_server, False, os.path.join(mcp_dir,'jars'), None, True) - reset_logger() - os.chdir(fml_dir) - post_decompile(mcp_dir, fml_dir) - - except SystemExit, e: - print 'Decompile Exception: %d ' % e.code - raise e - - if not os.path.isdir(src_dir): - print 'Something went wrong, src folder not found at: %s' % src_dir - sys.exit(1) - - #cleanup_source - cleanup_source(src_dir) - - os.chdir(mcp_dir) - commands = Commands(verify=True,workdir=os.path.join(mcp_dir,'jars')) - - if not disable_client: - updatemd5_side(mcp_dir, commands, CLIENT) - reset_logger() - - if enable_server: - updatemd5_side(mcp_dir, commands, CLIENT) - reset_logger() - - os.chdir(fml_dir) - -def updatemd5_side(mcp_dir, commands, side): - sys.path.append(mcp_dir) - from runtime.mcp import recompile_side, updatemd5_side - from runtime.commands import SIDE_NAME - - recomp = recompile_side(commands, side) - if recomp: - commands.logger.info('> Generating %s md5s', SIDE_NAME[side]) - commands.gathermd5s(side, skip_fml=True) - -def pre_decompile(mcp_dir, fml_dir, disable_assets=False): - download_minecraft(mcp_dir, fml_dir) - - if not disable_assets: - download_assets(mcp_dir) - -def post_decompile(mcp_dir, fml_dir): - if False: - print('hi') - -def apply_fml_patches(fml_dir, mcp_dir, src_dir, copy_files=True): - #Delete /minecraft/cpw to get rid of the Side/SideOnly classes used in decompilation - cpw_mc_dir = os.path.join(src_dir, 'minecraft', 'cpw') - if os.path.isdir(cpw_mc_dir): - shutil.rmtree(cpw_mc_dir) - - #patch files - print('Applying Forge ModLoader patches') - sys.stdout.flush() - - if os.path.isdir(os.path.join(fml_dir, 'patches', 'minecraft')): - apply_patches(mcp_dir, os.path.join(fml_dir, 'patches', 'minecraft'), src_dir) - if copy_files and os.path.isdir(os.path.join(fml_dir, 'client')): - copytree(os.path.join(fml_dir, 'client'), os.path.join(src_dir, 'minecraft')) - if copy_files and os.path.isdir(os.path.join(fml_dir, 'common')): - copytree(os.path.join(fml_dir, 'common'), os.path.join(src_dir, 'minecraft')) - - #delete argo - if os.path.isdir(os.path.join(src_dir, 'minecraft', 'argo')): - shutil.rmtree(os.path.join(src_dir, 'minecraft', 'argo')) - -def finish_setup_fml(fml_dir, mcp_dir, enable_server=False, disable_client=False, disable_rename=False): - sys.path.append(mcp_dir) - from runtime.updatenames import updatenames - from runtime.updatemd5 import updatemd5 - from runtime.updatemcp import updatemcp - - os.chdir(mcp_dir) - if not disable_rename: - updatenames(None, True, not disable_client, enable_server) - reset_logger() - updatemd5(None, True, not disable_client, enable_server) - reset_logger() - os.chdir(fml_dir) -#========================================================================== -# Download Functions! -#========================================================================== -def download_minecraft(mcp_dir, fml_dir, version=None): - mc_info = read_mc_versions(fml_dir, version=version, work_dir=os.path.join(mcp_dir, 'jars')) - - failed = False - - if mc_info['new_launcher']: - if os.path.isdir(os.path.join(fml_dir, 'jsons')): - json_file = os.path.join(fml_dir, 'jsons', '%s-dev.json' % mc_info['version']) - else: - json_file = os.path.join(fml_dir, 'fml.json') - - version_json = None - try: - version_json = json.load(open(json_file)) - except Exception as e: - print 'Failed to load version json: %s' % json_file - sys.exit(1) - - failed = download_libraries(mcp_dir, version_json['libraries'], mc_info['natives_dir']) or failed - if os.path.isfile(mc_info['json_file']): - os.remove(mc_info['json_file']) - shutil.copy(json_file, mc_info['json_file']) - else: - failed = not download_list(mc_info['downloads']) or failed - - # Remove any invalid files - for type in ['client', 'server']: - print("Backing up %s"%type) - file_backup(mc_info['%s_file' % type], mc_info['%s_md5' % type]) - failed = not download_file(mc_info['%s_url' % type], mc_info['%s_file' % type], mc_info['%s_md5' % type]) or failed - file_backup(mc_info['%s_file' % type], mc_info['%s_md5' % type]) - - if failed: - print 'Something failed verifying minecraft files, see log for details.' - sys.exit(1) - -def download_libraries(mcp_dir, libraries, natives_dir): - # Will attempt to download a list of maven style libraries from the default Minecraft website - # or a custom website if the library specifies it - # This list should be in the format of the new launcher's version.json file - # Under the entry 'libraries' - lib_dir = os.path.join(mcp_dir, 'jars', 'libraries') - default_url = 'http://s3.amazonaws.com/Minecraft.Download/libraries' - - downloads = [] - failed = False - - for lib in libraries: - name = lib['name'].split(':') - domain = name[0].split('.') - root = name[1] - version = name[2] - path = domain + [root, version] - extract = None - root_url = default_url - if 'extract' in lib.keys(): - extract = lib['extract'] - if 'url' in lib.keys(): - root_url = lib['url'] - - file_names = ['%s-%s.jar' % (root, version)] - - if 'natives' in lib.keys(): - file_names = [] - for k,v in lib['natives'].items(): - file_names.append('%s-%s-%s.jar' % (root, version, v)) - - if 'children' in lib.keys(): - for child in lib['children']: - file_names.append('%s-%s-%s.jar' % (root, version, child)) - - for file_name in file_names: - url = '%s/%s/%s' % (root_url, '/'.join(path), file_name) - file_path = os.path.join(lib_dir, os.sep.join(path), file_name) - headers = get_headers(url) - if headers is None: - print('Could not retreive headers for library: %s ( %s )' % (lib['name'], url)) - failed = True - else: - md5 = None - if 'ETag' in headers.keys(): # Amazon headers, Mojang's server - md5 = headers['ETag'] - else: # Could be a normal maven repo, check for .md5 file - try: - md5 = urllib2.urlopen(url + '.md5').read().split(' ')[0].replace('\r', '').replace('\n', '') - if not len(md5) == 32: - md5 = None - print('Could not retrieve md5 for library %s ( %s.md5 )' % (file_name, url)) - failed = True - except (HTTPError): - failed = True - pass - downloads.append({ - 'url' : url, - 'file' : file_path, - 'md5' : md5, - 'size' : headers['Content-Length'], - 'extract' : extract - }) - - return download_list(downloads, natives_dir) or failed - -def download_list(list, natives_dir): - #Downloads a list of files and urls. Verifying md5s if avalible. - #Skipping already existing and valid files. - #Also extracts files that are specified to be extracted to the natives folder - missing = [] - for dl in list: - if os.path.isfile(dl['file']): - if dl['md5'] is None or not get_md5(dl['file']) == dl['md5']: - missing.append(dl) - else: - missing.append(dl) - - if len(missing) == 0: - return False - - print 'Downloading %s libraries' % len(missing) - failed = False - for dl in missing: - if download_file(dl['url'], dl['file'], dl['md5'], prefix=' '): - if not dl['extract'] is None: - excludes = [] - if 'exclude' in dl['extract'].keys(): - excludes = dl['extract']['exclude'] - extract_zip(dl['file'], natives_dir, prefix=' ', filter=excludes) - else: - print(' Failed to download %s from %s' % (os.path.basename(dl['file']), dl['url'])) - failed = True - - return failed - -def download_assets(mcp_dir): - from xml.dom.minidom import parse - asset_dir = os.path.join(mcp_dir, 'jars', 'assets') - base_url = 'http://s3.amazonaws.com/Minecraft.Resources' - - print('Gathering assets list from %s' % base_url) - - files = [] - failed = False - - try: - url = urllib.urlopen(base_url) - xml = parse(url) - - def get(xml, key): - return xml.getElementsByTagName(key)[0].firstChild.nodeValue - - for asset in xml.getElementsByTagName('Contents'): - path = get(asset, 'Key') - if path.endswith('/'): - continue - - file = os.path.join(asset_dir, os.sep.join(path.split('/'))) - md5 = get(asset, 'ETag').replace('"', '') - - if os.path.isfile(file): - if get_md5(file) == md5: - continue - - files.append({ - 'file' : file, - 'url' : '%s/%s' % (base_url, path), - 'size' : get(asset, 'Size'), - 'md5' : md5 - }) - except Exception as e: - print 'Error gathering asset list:' - pprint(e) - sys.exit(1) - - if len(files) == 0: - print(' No new assets need to download') - return - - print(' Downloading %s assets' % len(files)) - for file in files: - failed = not download_file(file['url'], file['file'], file['md5'], root=asset_dir, prefix=' ') or failed - - if failed: - print(' Downloading assets failed, please review log for more details') - -#========================================================================== -# Transformers -#========================================================================== -def apply_ats(fml_dir, mcp_dir, class_path, target, disable_at=False, commands=None): - def log(msg): - if commands is None: - print(msg) - else: - commands.logger.info(msg) - - cmds = find_java() - if cmds is None: - log('>Could not run Access Transformer, Java not found!') - sys.exit(1) - - if not disable_at: - log('> Running AccessTransformer') - forkcmd = ('"%s" -classpath "{classpath}" cpw.mods.fml.common.asm.transformers.AccessTransformer "{jar}" "{fmlconfig}"' % cmds['java']).format( - classpath=class_path, jar=target, fmlconfig=os.path.join(fml_dir, 'common', 'fml_at.cfg')) - - forge_cfg = os.path.join(fml_dir, '..', 'common', 'forge_at.cfg') - if os.path.isfile(forge_cfg): - log(' Forge config detected') - forkcmd += ' "%s"' % forge_cfg - - for dirname, dirnames, filenames in os.walk(os.path.join(fml_dir, '..', 'accesstransformers')): - for filename in filenames: - accesstransformer = os.path.join(dirname, filename) - if os.path.isfile(accesstransformer): - log(' Access Transformer "%s" detected' % filename) - forkcmd += ' "%s"' % accesstransformer - - if not runcmd(forkcmd, echo=False, commands=commands): - sys.exit(1) - else: - log('> Access Transformer disabled') diff --git a/fml/install/install.bat b/fml/install/install.bat deleted file mode 100644 index b31f477296..0000000000 --- a/fml/install/install.bat +++ /dev/null @@ -1,4 +0,0 @@ -echo off -@set PATH=%PATH%;%SystemDir%\system32;%SystemRoot%\System32;.\python\ -python_fml install.py %* -pause diff --git a/fml/install/install.py b/fml/install/install.py deleted file mode 100644 index b8216a2550..0000000000 --- a/fml/install/install.py +++ /dev/null @@ -1,56 +0,0 @@ -import os, os.path, sys -from optparse import OptionParser - - -def fml_main(fml_dir, mcp_dir, gen_conf=True, disable_patches=False, disable_at=False, disable_merge=False, enable_server=False, - disable_client=False, disable_rename=False, disable_assets=False, decompile=False): - sys.path.append(fml_dir) - from fml import download_mcp, setup_mcp, decompile_minecraft, apply_fml_patches, finish_setup_fml - print '================ Forge ModLoader Setup Start ===================' - download_mcp(fml_dir, mcp_dir) - setup_mcp(fml_dir, mcp_dir, gen_conf) - if decompile: - decompile_minecraft(fml_dir, mcp_dir, disable_at=disable_at, disable_merge=disable_merge, - enable_server=enable_server, disable_client=disable_client, - disable_assets=disable_assets) - if disable_patches: - print 'Patching disabled' - else: - apply_fml_patches(fml_dir, mcp_dir, os.path.join(mcp_dir, 'src')) - finish_setup_fml(fml_dir, mcp_dir, enable_server=enable_server, disable_client=disable_client, disable_rename=disable_rename) - else: - print 'Decompile free install is on the to-do!' - print '================ Forge ModLoader Setup End ===================' - -if __name__ == '__main__': - parser = OptionParser() - parser.add_option('-m', '--mcp-dir', action='store', dest='mcp_dir', help='Path to download/extract MCP to', default=None ) - parser.add_option('-p', '--no-patch', action="store_true", dest='no_patch', help='Disable application of FML patches', default=False) - parser.add_option('-a', '--no-access', action="store_true", dest='no_access', help='Disable access transformers', default=False) - parser.add_option('-s', '--server', action="store_true", dest='enable_server', help='Enable decompilation of server', default=False) - parser.add_option('-c', '--no-client', action="store_true", dest='no_client', help='Disable decompilation of server', default=False) - parser.add_option('-e', '--no-merge', action="store_true", dest='no_merge', help='Disable merging server code into client', default=False) - parser.add_option('-n', '--no-rename', action="store_true", dest='no_rename', help='Disable running updatenames', default=False) - parser.add_option( '--no-assets', action="store_true", dest='no_assets', help='Disable downloading of assets folder', default=False) - parser.add_option('-d', '--decompile', action="store_true", dest='decompile', help='Decompile minecraft and apply patches', default=True) - options, _ = parser.parse_args() - - fml_dir = os.path.dirname(os.path.abspath(__file__)) - mcp_dir = os.path.abspath('mcp') - - if not options.mcp_dir is None: - mcp_dir = os.path.abspath(options.mcp_dir) - elif os.path.isfile(os.path.join('..', 'runtime', 'commands.py')): - mcp_dir = os.path.abspath('..') - - if options.no_client: - options.no_patch = True - - if options.no_merge: - options.no_patch = True - - fml_main(fml_dir, mcp_dir, disable_patches=options.no_patch, - disable_at=options.no_access, disable_merge=options.no_merge, - enable_server=options.enable_server, disable_client=options.no_client, - disable_rename=options.no_rename, disable_assets=options.no_assets, - decompile=options.decompile, gen_conf=False) \ No newline at end of file diff --git a/fml/install/install.sh b/fml/install/install.sh deleted file mode 100644 index a30da72b6c..0000000000 --- a/fml/install/install.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -python install.py "$@" diff --git a/fml/install/rename_vars.py b/fml/install/rename_vars.py deleted file mode 100644 index 6080f16b9e..0000000000 --- a/fml/install/rename_vars.py +++ /dev/null @@ -1,170 +0,0 @@ -import os, os.path, sys, csv, re, fnmatch, shutil, zipfile, pprint -from optparse import OptionParser -from pprint import pprint - -#This script attempts to rename local variables in a Fernflower decompiled Java source file to jad style names. -#Script originally written by Grum in perl, Converted to Python by monoxide, and bug fixes/cleanup by LexManos - -class VarNamer: - # Seems this is needed to keep these variables confined to the instance - def __init__(self): - self.last = { - 'byte': [0, 0, ['b']], - 'char': [0, 0, ['c']], - 'short': [1, 0, ['short']], - 'int': [0, 1, ['i', 'j', 'k', 'l']], - 'boolean': [0, 1, ['flag']], - 'double': [0, 0, ['d']], - 'float': [0, 1, ['f']], - 'File': [1, 1, ['file']], - 'String': [0, 1, ['s']], - 'Class': [0, 1, ['oclass']], - 'Long': [0, 1, ['olong']], - 'Byte': [0, 1, ['obyte']], - 'Short': [0, 1, ['oshort']], - 'Boolean': [0, 1, ['obool']], - 'Package': [0, 1, ['opackage']] - } - self.remap = { - 'long': 'int', - } - - def get_name(self, type, var): - index = type if self.last.has_key(type) else (self.remap[type] if self.remap.has_key(type) else None) - if (not index) and (re.search('^[A-Z]', type) or re.search(r'(\[|\.\.\.)', type)): - type = type.replace('...', '[]') - while type.find('[][]') != -1: - type = type.replace('[][]', '[]') - - name = type.lower() - skip = 1 - - if re.search(r'\[', type): - skip = 1 - name = "a" + name - name = name.replace('[', '').replace(']', '').replace('...', '') - - self.last[type] = [0, skip, [name]] - index = type - - if not index: - print "No data for type: %s '%s'\n" % (type, var) - return type - - id = self.last[index][0] - skip_zero = self.last[index][1] - data = self.last[index][2] - self.last[index][0] += 1 - - amount = len(data) - - if amount == 1: - return data[0] + ('' if ((not id) and skip_zero) else ('%d' % id)) - else: - num = id / amount - return data[id % amount] + ('' if ((not num) and skip_zero) else ('%d' % num)) - -def rename_file(file, indent='3', MCP=False): - tmp = file + '.tmp' - with open(file, 'rb') as in_file: - data = rename_class(in_file.read().replace('\r', ''), indent, MCP) - with open(tmp, 'wb') as out_file: - out_file.write(data) - shutil.move(tmp, file) - -def rename_class(data, indent='3', MCP=False): - METHOD_REG = r'^ {%s}(\w+\s+\S.*\.*(|static )(?:\{|\);|})$' % indent - CATCH_REG = r'catch \((.*)\) {' - if MCP: - if indent == '3': - indent = '4' - METHOD_REG = r'^ {%s}(\w+\s+\S.*\(.*|static)$' % indent - CATCH_REG = r'catch \((.*)\)$' - - lines = data.split('\n') - output = '' - - inside_method = False - method = '' - method_variables = [] - skip = False - - for line in lines: - line += '\n' - if re.search(METHOD_REG, line) and not re.search('=', line) and not re.search(r'\(.*\(', line): - if re.search(r'\(.+\)', line): - method_variables += [s.strip() for s in re.search(r'\((.+)\)', line).group(1).split(',')] - - method += line - - # Could be a single-line method - skip = True - if not re.search(r'(}|\);|throws .+?;)$', line): - inside_method = True - - elif re.search(r'^ {%s}}$' % indent, line): - inside_method = False - - if inside_method: - if skip: - skip = False - continue - - method += line - - m = re.search(CATCH_REG, line) - if m: - method_variables += [m.group(1)] - else: - method_variables += map(lambda x: x.group(0), filter( - lambda x: not re.match(r'^(return)', x.group(0)) and not re.match(r'^(throw)', x.group(0)), - re.finditer(r'([a-z_$][a-z0-9_\[\]]+ var\d+)', line, re.I))) - - else: - if method: - namer = VarNamer() - todo = map(lambda x: [x, namer.get_name(x.split(' ')[0], x)], method_variables) - - replace = {} - for mapping in todo: - if not ' ' in mapping[0]: - continue - replace[mapping[0].split(' ')[1]] = mapping[1] - - for k in sorted(replace, key=len, reverse=True): - original = k - to = replace[k] - - #Don't rename already renamed things. - if not re.match('var\d+', original): - continue - - method = method.replace(original, to) - - output += method - - method = '' - method_variables = [] - - if skip: - skip = False - continue - - output += line - - return output[:-1] - -def main(options, args): - for arg in args: - for path, _, filelist in os.walk(arg, followlinks=True): - for cur_file in fnmatch.filter(filelist, '*.java'): - file = os.path.normpath(os.path.join(path, cur_file)) - rename_file(file, options.indent, options.mcp) - -if __name__ == '__main__': - parser = OptionParser() - parser.add_option('-m', '--mcp', action='store_true', dest='mcp', help='Use MCP regexs', default=False) - parser.add_option('-i', '--indent', action='store', dest='indent', help='Custom indent to use', default='3') - options, args = parser.parse_args() - - main(options, args) \ No newline at end of file diff --git a/fml/install/sign_jar.py b/fml/install/sign_jar.py deleted file mode 100644 index cd9767b3a9..0000000000 --- a/fml/install/sign_jar.py +++ /dev/null @@ -1,90 +0,0 @@ -import os, os.path, sys, csv, re, fnmatch, shutil, zipfile, pprint -from optparse import OptionParser -from zipfile import ZipFile -from subprocess import Popen, PIPE, STDOUT - -if __name__ == '__main__': - parser = OptionParser() - parser.add_option('-j', '--jar', action='store', dest='jar', help='Jar to sign', default=None) - parser.add_option('-c', '--command', action='store', dest='command', help='Path to jar signer command, will be invoked on temp jar to sign', default=None) - parser.add_option('-a', '--alias', action='store', dest='alias', help='Optional: The keystore alias to use when siging the jar, it will be passed in as para 2 to the command', default='') - #This is kept as a seperate file so that if you integrate this into a build system, you are not publically displaying any private passwords - #Typically the format of this file will be: - # - #jarsigner -keystore my_key_store -storepass key_store_pass -keypass key_pass %1 alias - - #The rest of the parameters are used as regxs to determine what parts of the file will be signed, a file will be signed if it matches ANY of the regexs - options, args = parser.parse_args() - - if options.jar is None: - print 'You must supply the jar to sign using --jar ' - sys.exit(1) - - if options.command is None: - print 'You must supply a command to be called using --command , See the comments in the python for details on this' - sys.exit(1) - - if not os.path.isfile(options.jar): - print 'The specified jar "%s" could not be found' % options.jar - sys.exit(1) - - regs = [] - for reg in args: - regs.append(re.compile(reg)) - - shutil.copy(options.jar, options.jar + '.bak') - tmp_1 = options.jar + '.tmp1' - tmp_2 = options.jar + '.tmp2' - - zip_in = ZipFile(options.jar, mode='r') - zip_tmp_1 = ZipFile(tmp_1, mode='w') - zip_tmp_2 = ZipFile(tmp_2, mode='w') - for i in zip_in.filelist: - matched = False - for reg in regs: - if not reg.match(i.filename) is None: - matched = True - break - - data = zip_in.read(i.filename) - if matched: - print 'Matched: ' + i.filename - zip_tmp_1.writestr(i, data) - else: - if i.filename.startswith('META-INF'): - print 'Detected skipped META-INF File, it will not be copied to new jar, if you wish to keep this data, include it in the signed info: %s' % i.filename - else: - print 'Skipped: ' + i.filename - zip_tmp_2.writestr(i, data) - - zip_in.close() - zip_tmp_1.close() - zip_tmp_2.close() - - try: - process = Popen([options.command, os.path.abspath(tmp_1), options.alias], stdout=PIPE, stderr=STDOUT, bufsize=-1) - out, _ = process.communicate() - print out - except OSError as e: - print "Error creating signed tmp jar: %s" % e.strerror - sys.exit(1) - - os.remove(options.jar) - - zip_out = ZipFile(options.jar, mode='w') - - for tmp in [tmp_1, tmp_2]: - zip_in = ZipFile(tmp, mode='r') - - for i in zip_in.filelist: - zip_out.writestr(i, zip_in.read(i.filename)) - - zip_in.close() - - zip_out.close() - - os.remove(tmp_1) - os.remove(tmp_2) - - print 'Signing jar complete' - \ No newline at end of file diff --git a/fml/install/update_packages.py b/fml/install/update_packages.py deleted file mode 100644 index 90facb5b92..0000000000 --- a/fml/install/update_packages.py +++ /dev/null @@ -1,64 +0,0 @@ -import os, os.path, sys, csv, re, fnmatch, shutil -from optparse import OptionParser - -replaced = 0 - -def main(mcp_dir, targets): - global replaced - packages_csv = os.path.join(mcp_dir, 'conf', 'packages.csv') - - if not os.path.isfile(packages_csv): - print 'Could not find Packages.csv, please specify a location of a MCP directory setup with FML using --mcp-dir ' - sys.exit(1) - - pkgs = {} - with open(packages_csv) as fh: - reader = csv.DictReader(fh) - for line in reader: - pkgs[line['class']] = line['package'] - - if len(targets) == 0: - print 'You must specify atleast one target directory to repackage' - sys.exit(1) - - regnms = re.compile(r'net.minecraft.src.(\w+)') - total_r = 0 - total_f = 0 - - for target in targets: - for path, _, filelist in os.walk(target, followlinks=True): - for cur_file in fnmatch.filter(filelist, '*.java'): - file_name = os.path.join(path, cur_file) - buf = '' - replaced = 0 - - with open(file_name, 'rb') as fh: - data = fh.read() - def mapname(match): - global replaced - cls = match.group(0) - tmp = cls[18:] - if tmp in pkgs.keys(): - replaced += 1 - return ('%s/%s' % (pkgs[tmp], tmp)).replace('/', '.') - return cls - data = regnms.sub(mapname, data) - - if replaced > 0: - total_r += replaced - total_f += 1 - - print '%s: %d' % (os.path.relpath(file_name), replaced) - - with open(file_name + '.tmp', 'wb') as fh: - fh.write(data) - shutil.move(file_name + '.tmp', file_name) - - print 'Fixed %d references in %d files' % (total_r, total_f) - -if __name__ == '__main__': - parser = OptionParser() - parser.add_option('-m', '--mcp-dir', action='store', dest='mcp_dir', help='MCP Directory', default='mcp') - options, args = parser.parse_args() - - main(os.path.abspath(options.mcp_dir), args) \ No newline at end of file diff --git a/fml/lzmabin/xz.exe b/fml/lzmabin/xz.exe deleted file mode 100644 index f42c2bffe6..0000000000 Binary files a/fml/lzmabin/xz.exe and /dev/null differ diff --git a/fml/mc_versions.cfg b/fml/mc_versions.cfg deleted file mode 100644 index 3ace4655ee..0000000000 --- a/fml/mc_versions.cfg +++ /dev/null @@ -1,130 +0,0 @@ -[default] -current_ver = 1.6.4 -base_url = http://s3.amazonaws.com/MinecraftDownload/ -libraries = lwjgl.jar lwjgl_util.jar jinput.jar -natives = windows_natives.jar macosx_natives.jar linux_natives.jar - -[1.4.4] -client_url = http://assets.minecraft.net/1_4_4/minecraft.jar -server_url = http://assets.minecraft.net/1_4_4/minecraft_server.jar -client_md5 = 7aa46c8058cba2f38e9d2ddddcc77c72 -server_md5 = b5feed15df1db87c9aaf78dcefad513d -mcp_ver = 7.21 -mcp_url = http://mcp.ocean-labs.de/files/archive/mcp721.zip -mcp_md5 = 772ecfdac7e4c9491bfb131cee3bbb36 - -[1.4.5] -client_url = http://assets.minecraft.net/1_4_5/minecraft.jar -server_url = http://assets.minecraft.net/1_4_5/minecraft_server.jar -client_md5 = b15e2b2b6b4629f0d99a95b6b44412a0 -server_md5 = 250654ceae7a26ba955a30095d90a475 -mcp_ver = 7.23 -mcp_url = http://mcp.ocean-labs.de/files/archive/mcp723.zip -mcp_md5 = 9fbb5835b437b64bc5ce618fa5a53d1d - -[1.4.6] -client_url = http://assets.minecraft.net/1_4_6/minecraft.jar -server_url = http://assets.minecraft.net/1_4_6/minecraft_server.jar -client_md5 = 48677dc4c2b98c29918722b5ab27b4fd -server_md5 = b0700fa969dbf0ff085082cde87384d2 -mcp_ver = 7.25 -mcp_url = http://mcp.ocean-labs.de/files/archive/mcp725.zip -mcp_md5 = a7276589fca4974d40eb4e27ba41ba16 - -[1.4.7] -client_url = http://assets.minecraft.net/1_4_7/minecraft.jar -server_url = http://assets.minecraft.net/1_4_7/minecraft_server.jar -client_md5 = 8e80fb01b321c6b3c7efca397a3eea35 -server_md5 = f69ac4bfce2dfbce03fe872518f75a05 -mcp_ver = 7.26a -mcp_url = http://mcp.ocean-labs.de/files/archive/mcp726a.zip -mcp_md5 = 5f11fbccd857b43a0f54117253b3e4dd - -[s13w02b] -client_url = http://assets.minecraft.net/13w02b/minecraft.jar -server_url = http://assets.minecraft.net/13w02b/minecraft_server.jar -client_md5 = 13891f6610b6739ac79f40147cca31d5 -server_md5 = b2200cfa5d6535f177d291066d2ed3a8 -mcp_ver = 7.30c -mcp_url = http://mcp.ocean-labs.de/files/archive/mcp730c.zip -mcp_md5 = b25479ba38ca583bb8223c0a0553defe - -[s13w05b] -client_url = http://assets.minecraft.net/13w05b/minecraft.jar -server_url = http://assets.minecraft.net/13w05b/minecraft_server.jar -client_md5 = 496002660846f2eb455cba407cd26818 -server_md5 = e317f8f4f62d0603a8eacbfb2e33549c -mcp_ver = 7.34 -mcp_url = http://files.minecraftforge.net/mcpmirror/mcp734.zip -mcp_md5 = 522dc1a7b66f8265291e1cc2f8f5d247 - -[s13w09c] -client_url = http://assets.minecraft.net/13w09c/minecraft.jar -server_url = http://assets.minecraft.net/13w09c/minecraft_server.jar -client_md5 = d2534381656da5069b96cc89e28158ef -server_md5 = 92f4fd715191c596745c7bbfad9c1aad -mcp_ver = 7.39 -mcp_url = http://mcp.ocean-labs.de/files/archive/mcp739.zip -mcp_md5 = cd4f6f5e6dd7032301aa98a9046201dd - -[1.5] -client_url = http://assets.minecraft.net/1_5/minecraft.jar -server_url = http://assets.minecraft.net/1_5/minecraft_server.jar -client_md5 = fd11cbc5b01aae1d62cff0145171f3d9 -server_md5 = 00035b7842554bdbff95a48169420525 -mcp_ver = 7.42 -mcp_url = http://mcp.ocean-labs.de/files/archive/mcp742.zip -mcp_md5 = ad1a2b86916dd5f71e832181e01bd91a - -[1.5.1] -client_url = http://assets.minecraft.net/1_5_1/minecraft.jar -server_url = http://assets.minecraft.net/1_5_1/minecraft_server.jar -client_md5 = 5c1219d869b87d233de3033688ec7567 -server_md5 = 9d31b969c3f197a1d40381d5620717ea -mcp_ver = 7.44 -mcp_url = http://mcp.ocean-labs.de/files/archive/mcp744.zip -mcp_md5 = 0b9047820bbcb7da32c5e18f60212832 - -[1.5.2] -client_url = http://s3.amazonaws.com/Minecraft.Download/versions/1.5.2/1.5.2.jar -server_url = http://s3.amazonaws.com/Minecraft.Download/versions/1.5.2/minecraft_server.1.5.2.jar -client_md5 = 6897c3287fb971c9f362eb3ab20f5ddd -server_md5 = c4e1bf89e834bd3670c7bf8f13874bc6 -mcp_ver = 7.51 -mcp_url = http://mcp.ocean-labs.de/files/archive/mcp751.zip -mcp_md5 = a8c68db8736227c9e26cbcb0995e5b71 - -[1.6] -client_md5 = 6a64a2136e3a3fe4d29b0a0df30b25fc -server_md5 = 7c03305c8bf97a8e8f3cdb147fc90607 -mcp_ver = 8.01 -mcp_url = -mcp_md5 = 39da81bbb4d73b3f5e2d1f8f5682cdb9 - -[1.6.1] -client_md5 = 3c56fb4b77b1ca37dde69b5eb896fc4d -server_md5 = ff8f81970a5955737c356b534d3aee96 -mcp_ver = 8.03 -mcp_url = http://mcp.ocean-labs.de/files/archive/mcp803.zip -mcp_md5 = 7810c2fba33e15889685b21ac8dc66cf - -[1.6.2] -client_md5 = 1d43cdba8b9752d7f557ab7d3e365964 -server_md5 = 39df9f29e6904ea7b351ffb4fe949881 -mcp_ver = 8.04 -mcp_url = http://mcp.ocean-labs.de/files/archive/mcp804.zip -mcp_md5 = ebcecfa00aae07548e67787044410a11 - -[1.6.3] -client_md5 = 233effe2110d40a0519cf1489e4ccb1c -server_md5 = 8ed981ab6030412f586bfe38ff0aaa82 -mcp_ver = 8.09 -mcp_url = http://mcp.ocean-labs.de/files/archive/mcp809.zip -mcp_md5 = 19133b5915dc26a90d84f587172c6692 - -[1.6.4] -client_md5 = 2e5044f5359e82245551167a237f3167 -server_md5 = ba3145656b1480122bd8759cecd7b7a1 -mcp_ver = 8.11 -mcp_url = http://mcp.ocean-labs.de/files/archive/mcp811.zip -mcp_md5 = 2d7a759309b5cc10ca29caa0b10f3bfc diff --git a/fml/python/PythonLicense.url b/fml/python/PythonLicense.url deleted file mode 100644 index 2789d428f2..0000000000 --- a/fml/python/PythonLicense.url +++ /dev/null @@ -1,5 +0,0 @@ -[{000214A0-0000-0000-C000-000000000046}] -Prop3=19,2 -[InternetShortcut] -URL=http://docs.python.org/2/license.html -IDList= diff --git a/fml/python/_ctypes.pyd b/fml/python/_ctypes.pyd deleted file mode 100644 index d05a84f3d5..0000000000 Binary files a/fml/python/_ctypes.pyd and /dev/null differ diff --git a/fml/python/_elementtree.pyd b/fml/python/_elementtree.pyd deleted file mode 100644 index 7833b6fb5b..0000000000 Binary files a/fml/python/_elementtree.pyd and /dev/null differ diff --git a/fml/python/_hashlib.pyd b/fml/python/_hashlib.pyd deleted file mode 100644 index 9cf823e475..0000000000 Binary files a/fml/python/_hashlib.pyd and /dev/null differ diff --git a/fml/python/_multiprocessing.pyd b/fml/python/_multiprocessing.pyd deleted file mode 100644 index e897254b33..0000000000 Binary files a/fml/python/_multiprocessing.pyd and /dev/null differ diff --git a/fml/python/_socket.pyd b/fml/python/_socket.pyd deleted file mode 100644 index 023564443d..0000000000 Binary files a/fml/python/_socket.pyd and /dev/null differ diff --git a/fml/python/_sqlite3.pyd b/fml/python/_sqlite3.pyd deleted file mode 100644 index 501da27c97..0000000000 Binary files a/fml/python/_sqlite3.pyd and /dev/null differ diff --git a/fml/python/_ssl.pyd b/fml/python/_ssl.pyd deleted file mode 100644 index 0cf8ed73a8..0000000000 Binary files a/fml/python/_ssl.pyd and /dev/null differ diff --git a/fml/python/bz2.pyd b/fml/python/bz2.pyd deleted file mode 100644 index b388111d6a..0000000000 Binary files a/fml/python/bz2.pyd and /dev/null differ diff --git a/fml/python/pyexpat.pyd b/fml/python/pyexpat.pyd deleted file mode 100644 index 3ebd2d0529..0000000000 Binary files a/fml/python/pyexpat.pyd and /dev/null differ diff --git a/fml/python/python27.dll b/fml/python/python27.dll deleted file mode 100644 index e45374fb33..0000000000 Binary files a/fml/python/python27.dll and /dev/null differ diff --git a/fml/python/python27.zip b/fml/python/python27.zip deleted file mode 100644 index 06a1bd104a..0000000000 Binary files a/fml/python/python27.zip and /dev/null differ diff --git a/fml/python/python_fml.exe b/fml/python/python_fml.exe deleted file mode 100644 index f68a605bc8..0000000000 Binary files a/fml/python/python_fml.exe and /dev/null differ diff --git a/fml/python/select.pyd b/fml/python/select.pyd deleted file mode 100644 index 62104e489e..0000000000 Binary files a/fml/python/select.pyd and /dev/null differ diff --git a/fml/python/sqlite3.dll b/fml/python/sqlite3.dll deleted file mode 100644 index 9f0ccf0a7d..0000000000 Binary files a/fml/python/sqlite3.dll and /dev/null differ diff --git a/fml/python/unicodedata.pyd b/fml/python/unicodedata.pyd deleted file mode 100644 index f6a0f52561..0000000000 Binary files a/fml/python/unicodedata.pyd and /dev/null differ diff --git a/fml/python/w9xpopen.exe b/fml/python/w9xpopen.exe deleted file mode 100644 index 9303628363..0000000000 Binary files a/fml/python/w9xpopen.exe and /dev/null differ diff --git a/fml/refactorscripts/INetworkManagerRefactoring.xml b/fml/refactorscripts/INetworkManagerRefactoring.xml deleted file mode 100644 index 09b4685127..0000000000 --- a/fml/refactorscripts/INetworkManagerRefactoring.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/fml/refactorscripts/ITexturePackRefactoring.xml b/fml/refactorscripts/ITexturePackRefactoring.xml deleted file mode 100644 index 2305b259b2..0000000000 --- a/fml/refactorscripts/ITexturePackRefactoring.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/fml/refactorscripts/README.txt b/fml/refactorscripts/README.txt deleted file mode 100644 index 877f47236e..0000000000 --- a/fml/refactorscripts/README.txt +++ /dev/null @@ -1,4 +0,0 @@ -These are some hopefully helpful refactor scripts for eclipse. They will refactor the 1.3.2->1.4 INetworkManager and ITexturePack code changes for your codebase. - -To run you should be able to just "Apply script" the appropriate script on your MCP based mod code and it'll fix up the refs for you. - diff --git a/fml/reobf-fml.py b/fml/reobf-fml.py deleted file mode 100644 index f458c3d7fb..0000000000 --- a/fml/reobf-fml.py +++ /dev/null @@ -1,66 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Created on Fri Apr 8 16:54:36 2011 - -@author: ProfMobius -@version: v1.1-cpw -Modified to fix temporary obfuscation issue -""" - -import sys -import logging -from optparse import OptionParser - -from commands import Commands, CLIENT, SERVER -from mcp import reobfuscate_side - - -def main(): - parser = OptionParser(version='MCP %s' % Commands.fullversion()) - parser.add_option('--client', dest='only_client', action='store_true', help='only process client', default=False) - parser.add_option('--server', dest='only_server', action='store_true', help='only process server', default=False) - parser.add_option('-a', '--all', action='store_true', dest='reobf_all', help='output all classes', default=False) - parser.add_option('-n', '--nolvt', dest='keep_lvt', action='store_false', help='strip local variable table', - default=True) - parser.add_option('-g', '--generics', dest='keep_generics', action='store_true', - help='preserve generics as well as local variables', default=False) - parser.add_option('-c', '--config', dest='config', help='additional configuration file') - parser.add_option('--srgnames', dest='srg_names', action='store_true', help='Obfusicate to MCP unique names', default=False) - options, _ = parser.parse_args() - reobfuscate(options.config, options.reobf_all, options.keep_lvt, options.keep_generics, options.only_client, - options.only_server, options.srg_names) - - -def reobfuscate(conffile, reobf_all, keep_lvt, keep_generics, only_client, only_server, srg_names): - try: - commands = Commands(conffile, verify=True) - - if keep_generics: - keep_lvt = True - - # client or server - process_client = True - process_server = True - if only_client and not only_server: - process_server = False - if only_server and not only_client: - process_client = False - - if srg_names: - commands.logger.info('> Creating Retroguard maping files') - commands.createreobfsrg() - - commands.logger.info('> Creating Retroguard config files') - commands.creatergcfg(reobf=True, keep_lvt=keep_lvt, keep_generics=keep_generics, srg_names=srg_names) - - if process_client: - reobfuscate_side(commands, CLIENT, reobf_all=reobf_all, srg_names=srg_names, force_rg=True) - if process_server: - reobfuscate_side(commands, SERVER, reobf_all=reobf_all, srg_names=srg_names, force_rg=True) - except Exception: # pylint: disable-msg=W0703 - logging.exception('FATAL ERROR') - sys.exit(1) - - -if __name__ == '__main__': - main() diff --git a/fml/server/net/minecraft/src/BaseMod.java b/fml/server/net/minecraft/src/BaseMod.java deleted file mode 100644 index 3a3675ffe6..0000000000 --- a/fml/server/net/minecraft/src/BaseMod.java +++ /dev/null @@ -1,333 +0,0 @@ -/* - * The FML Forge Mod Loader suite. Copyright (C) 2012 cpw - * - * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -package net.minecraft.src; - -import java.util.Map; -import java.util.Random; - -import net.minecraft.server.MinecraftServer; -import cpw.mods.fml.common.IConsoleHandler; -import cpw.mods.fml.common.ICraftingHandler; -import cpw.mods.fml.common.IDispenseHandler; -import cpw.mods.fml.common.INetworkHandler; -import cpw.mods.fml.common.IPickupNotifier; -import cpw.mods.fml.common.IPlayerTracker; -import cpw.mods.fml.common.IWorldGenerator; -import cpw.mods.fml.common.TickType; -import cpw.mods.fml.server.FMLServerHandler; - -public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseModProxy -{ - // CALLBACK MECHANISMS - /** - * @param minecraftInstance - * @return - */ - @Override - public final boolean doTickInGame(TickType tick, boolean tickEnd, Object... data) - { - if (tick==TickType.SERVER && tickEnd) { - return onTickInGame(FMLServerHandler.instance().getServer()); - } else { - return true; - } - } - public final boolean doTickInGUI(TickType tick, boolean tickEnd, Object... data) - { - return false; - } - - - // BASEMOD API - /** - * Override if you wish to provide a fuel item for the furnace and return the fuel value of the item - * - * @param id - * @param metadata - * @return - */ - public int addFuel(int id, int metadata) - { - return 0; - } - - public void addRenderer(Map, Object> renderers) - { - - } - - /** - * Override if you wish to perform some action other than just dispensing the item from the dispenser - * - * @param world - * @param x - * @param y - * @param z - * @param xVel - * @param zVel - * @param item - * @return - */ - public boolean dispenseEntity(World world, double x, double y, double z, int xVel, int zVel, ItemStack item) - { - return false; - } - - /** - * Override if you wish to generate Nether (Hell biome) blocks - * - * @param world - * @param random - * @param chunkX - * @param chunkZ - */ - public void generateNether(World world, Random random, int chunkX, int chunkZ) - { - } - - /** - * Override if you wish to generate Overworld (not hell or the end) blocks - * - * @param world - * @param random - * @param chunkX - * @param chunkZ - */ - public void generateSurface(World world, Random random, int chunkX, int chunkZ) - { - } - - /** - * Return the name of your mod. Defaults to the class name - * - * @return - */ - public String getName() - { - return getClass().getSimpleName(); - } - - /** - * Get your mod priorities - * - * @return - */ - public String getPriorities() - { - return ""; - } - - /** - * Return the version of your mod - * - * @return - */ - public abstract String getVersion(); - - public void keyboardEvent(Object event) - { - - } - - /** - * Load your mod - */ - public abstract void load(); - - /** - * Finish loading your mod - */ - public void modsLoaded() - { - } - - /** - * Handle item pickup - * - * @param player - * @param item - */ - public void onItemPickup(EntityPlayer player, ItemStack item) - { - } - - /** - * Ticked every game tick if you have subscribed to tick events through {@link ModLoader#setInGameHook(BaseMod, boolean, boolean)} - * - * @param minecraftServer the server - * @return true to continue receiving ticks - */ - public boolean onTickInGame(MinecraftServer minecraftServer) - { - return false; - } - - public boolean onTickInGUI(float tick, Object game, Object gui) - { - return false; - } - - /** - * Only implemented on the client side - * {@link #onChatMessageReceived(EntityPlayer, Packet3Chat)} - * - * @param text - */ - public void receiveChatPacket(String text) - { - - } - - /** - * Only called on the client side - * {@link #onPacket250Received(EntityPlayer, Packet250CustomPayload)} - * - * @param packet - */ - public void receiveCustomPacket(Packet250CustomPayload packet) - { - - } - - public void registerAnimation(Object game) - { - - } - - public void renderInvBlock(Object renderer, Block block, int metadata, int modelID) - { - - } - - public boolean renderWorldBlock(Object renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID) - { - return false; - - } - - /** - * Called when someone crafts an item from a crafting table - * - * @param player - * @param item - * @param matrix - */ - public void takenFromCrafting(EntityPlayer player, ItemStack item, IInventory matrix) - { - } - - /** - * Called when someone takes a smelted item from a furnace - * - * @param player - * @param item - */ - public void takenFromFurnace(EntityPlayer player, ItemStack item) - { - } - - /** - * The identifier string for the mod- used in client<->server negotiation - */ - @Override - public String toString() - { - return getName() + " " + getVersion(); - } - - /** - * Called when a 250 packet is received on a channel registered to this mod - * - * @param source - * @param payload - */ - public void onPacket250Received(EntityPlayer source, Packet250CustomPayload payload) - { - } - - /** - * Called when a chat message is received. Return true to stop further processing - * - * @param source - * @param chat - * @return true if you want to consume the message so it is not available for further processing - */ - public boolean onChatMessageReceived(EntityPlayer source, Packet3Chat chat) - { - return false; - } - /** - * Called when a server command is received - * @param command - * @return true if you want to consume the message so it is not available for further processing - */ - public boolean onServerCommand(String command, String sender, ICommandManager listener) - { - return false; - } - - /** - * Called when a new client logs in. - * - * @param player - */ - public void onClientLogin(EntityPlayer player) - { - } - - /** - * Called when a client logs out of the server. - * - * @param player - */ - public void onClientLogout(EntityPlayer player) - { - - } - - /** - * - * Called when a client changes dimensions on the server. - * - * @param player - */ - public void onClientDimensionChanged(EntityPlayer player) - { - - } - - /** - * @param renderers - */ - public void onRenderHarvest(Map renderers) - { - // NOOP - } - - /** - * - */ - public void onRegisterAnimations() - { - // NOOP on server - } - - // Spare client junk - // ------- - // void addRenderer(Map, Render> renderers); - // void registerAnimation(Minecraft game); - // void renderInvBlock(RenderBlocks renderer, Block block, int metadata, int modelID); - // boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID); - // boolean onTickInGUI(float tick, Minecraft game, GuiScreen gui); - // void keyboardEvent(KeyBinding event); -} diff --git a/fml/server/net/minecraft/src/MLProp.java b/fml/server/net/minecraft/src/MLProp.java deleted file mode 100644 index cc7f095ebf..0000000000 --- a/fml/server/net/minecraft/src/MLProp.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * The FML Forge Mod Loader suite. Copyright (C) 2012 cpw - * - * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -package net.minecraft.src; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; -import static java.lang.annotation.RetentionPolicy.*; -import static java.lang.annotation.ElementType.*; - -/** - * @author cpw - * - */ -@Retention(value = RUNTIME) -@Target(value = FIELD) -public @interface MLProp -{ - /** - * Adds additional help to top of configuration file. - */ - String info() default ""; - - /** - * Maximum value allowed if field is a number. - */ - double max() default Double.MAX_VALUE; - - /** - * Minimum value allowed if field is a number. - */ - double min() default Double.MIN_VALUE; - - /** - * Overrides the field name for property key. - */ - String name() default ""; - -} diff --git a/fml/server/net/minecraft/src/ModLoader.java b/fml/server/net/minecraft/src/ModLoader.java deleted file mode 100644 index 507a7c0dc9..0000000000 --- a/fml/server/net/minecraft/src/ModLoader.java +++ /dev/null @@ -1,786 +0,0 @@ -/* - * The FML Forge Mod Loader suite. Copyright (C) 2012 cpw - * - * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -package net.minecraft.src; - -import java.util.EnumSet; -import java.util.List; -import java.util.Map; -import java.util.logging.Logger; - -import net.minecraft.server.MinecraftServer; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.FMLLog; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.ObfuscationReflectionHelper; -import cpw.mods.fml.common.modloader.ModLoaderHelper; -import cpw.mods.fml.common.modloader.ModLoaderModContainer; -import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.network.Player; -import cpw.mods.fml.server.FMLServerHandler; -import cpw.mods.fml.common.registry.EntityRegistry; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.common.registry.LanguageRegistry; - -public class ModLoader -{ - public static final String fmlMarker = "This is an FML marker"; - /** - * Not used on the server. - * - * @param achievement - * @param name - * @param description - */ - public static void addAchievementDesc(Achievement achievement, String name, String description) - { - String achName=achievement.field_75978_a; - addLocalization(achName, name); - addLocalization(achName+".desc", description); - } - - /** - * This method is a call in hook from modified external code. Implemented elsewhere. - * - * {@link FMLCommonHandler#fuelLookup(int, int)} - * - * @param id - * @param metadata - * @return - */ - @Deprecated - public static int addAllFuel(int id, int metadata) - { - return 0; - } - - public static void addAllRenderers(Map, Object> renderers) - { - } - - public static void addAnimation(Object anim) - { - } - - /** - * This method is unimplemented in server versions to date. - * - * @param armor - * @return - */ - public static int addArmor(String armor) - { - return 0; - } - - /** - * This method adds the supplied biome to the set of candidate biomes for the default world generator type. - * - * @param biome - */ - public static void addBiome(BiomeGenBase biome) - { - GameRegistry.addBiome(biome); - } - - /** - * Add localization for the specified string - * - * @param key - * @param value - */ - public static void addLocalization(String key, String value) - { - addLocalization(key, "en_US", value); - } - - /** - * Add localization for the specified string - * - * @param key - * @param lang - * @param value - */ - public static void addLocalization(String key, String lang, String value) - { - LanguageRegistry.instance().addStringLocalization(key, lang, value); - } - - /** - * Name the specified minecraft object with the supplied name - * - * @param instance - * @param name - */ - public static void addName(Object instance, String name) - { - addName(instance,"en_US",name); - } - - /** - * Unimplemented on the server as it does not generate names - * - * @param instance - * @param lang - * @param name - */ - public static void addName(Object instance, String lang, String name) - { - LanguageRegistry.instance().addNameForObject(instance, lang, name); - } - - /** - * Unimplemented on the server as it does not render textures - * - * @param fileToOverride - * @param fileToAdd - * @return - */ - public static int addOverride(String fileToOverride, String fileToAdd) - { - return 0; - } - - /** - * Unimplemented on the server as it does not render textures - * - * @param path - * @param overlayPath - * @param index - */ - public static void addOverride(String path, String overlayPath, int index) - { - // NOOP - } - - /** - * Add a Shaped Recipe - * - * @param output - * @param params - */ - public static void addRecipe(ItemStack output, Object... params) - { - GameRegistry.addRecipe(output, params); - } - - /** - * Add a shapeless recipe - * - * @param output - * @param params - */ - public static void addShapelessRecipe(ItemStack output, Object... params) - { - GameRegistry.addShapelessRecipe(output, params); - } - - /** - * Add a new product to be smelted - * - * @param input - * @param output - */ - public static void addSmelting(int input, ItemStack output) - { - GameRegistry.addSmelting(input, output, 1.0f); - } - - /** - * Add a mob to the spawn list - * - * @param entityClass - * @param weightedProb - * @param min - * @param max - * @param spawnList - */ - public static void addSpawn(Class entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList) - { - EntityRegistry.addSpawn(entityClass, weightedProb, min, max, spawnList, WorldType.base12Biomes); - } - - /** - * Add a mob to the spawn list - * @param entityClass - * @param weightedProb - * @param min - * @param max - * @param spawnList - * @param biomes - */ - public static void addSpawn(Class entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes) - { - EntityRegistry.addSpawn(entityClass, weightedProb, min, max, spawnList, biomes); - } - - /** - * Add a mob to the spawn list - * - * @param entityName - * @param weightedProb - * @param min - * @param max - * @param spawnList - */ - public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList) - { - EntityRegistry.addSpawn(entityName, weightedProb, min, max, spawnList, WorldType.base12Biomes); - } - - /** - * Add a mob to the spawn list - * - * @param entityName - * @param weightedProb - * @param min - * @param max - * @param spawnList - * @param biomes - */ - public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes) - { - EntityRegistry.addSpawn(entityName, weightedProb, min, max, spawnList, biomes); - } - - /** - * This method is a call in hook from modified external code. Implemented elsewhere. - * {@link FMLServerHandler#tryDispensingEntity(World, double, double, double, byte, byte, ItemStack)} - * - * @param world - * @param x - * @param y - * @param z - * @param xVel - * @param zVel - * @param item - * @return - */ - @Deprecated - public static boolean dispenseEntity(World world, double x, double y, double z, int xVel, int zVel, ItemStack item) - { - return false; - } - - /** - * Remove a container and drop all the items in it on the ground around - * - * @param world - * @param x - * @param y - * @param z - */ - public static void genericContainerRemoval(World world, int x, int y, int z) - { -/* TileEntity te = world.func_603_b(x, y, z); - - if (!(te instanceof IInventory)) - { - return; - } - - IInventory inv = (IInventory)te; - - for (int l = 0; l < inv.func_83_a(); l++) - { - ItemStack itemstack = inv.func_82_a(l); - - if (itemstack == null) - { - continue; - } - - float f = world.field_803_m.nextFloat() * 0.8F + 0.1F; - float f1 = world.field_803_m.nextFloat() * 0.8F + 0.1F; - float f2 = world.field_803_m.nextFloat() * 0.8F + 0.1F; - - while (itemstack.field_853_a > 0) - { - int i1 = world.field_803_m.nextInt(21) + 10; - - if (i1 > itemstack.field_853_a) - { - i1 = itemstack.field_853_a ; - } - - itemstack.field_853_a -= i1; - EntityItem entityitem = new EntityItem(world, (float)te.field_478_b + f, (float)te.field_483_c + f1, (float)te.field_482_d + f2, new ItemStack(itemstack.field_855_c, i1, itemstack.func_21125_h())); - float f3 = 0.05F; - entityitem.field_319_o = (float)world.field_803_m.nextGaussian() * f3; - entityitem.field_318_p = (float)world.field_803_m.nextGaussian() * f3 + 0.2F; - entityitem.field_317_q = (float)world.field_803_m.nextGaussian() * f3; - - if (itemstack.func_40608_n()) - { - entityitem.field_429_a.func_40604_d((NBTTagCompound)itemstack.func_40607_o().func_40468_b()); - } - - world.func_526_a(entityitem); - } - } -*/ } - - /** - * Get a list of all BaseMod loaded into the system - * {@link ModLoaderModContainer#findAll} - * - * @return - */ - public static List getLoadedMods() - { - return ModLoaderModContainer.findAll(BaseMod.class); - } - - /** - * Get a logger instance {@link FMLCommonHandler#getFMLLogger()} - * - * @return - */ - public static Logger getLogger() - { - return FMLLog.getLogger(); - } - - public static Object getMinecraftInstance() - { - return getMinecraftServerInstance(); - } - - /** - * Get the minecraft server instance - * {@link FMLServerHandler#getServer()} - * @return - */ - public static MinecraftServer getMinecraftServerInstance() - { - return FMLCommonHandler.instance().getMinecraftServerInstance(); - } - /** - * Get a value from a field using reflection - * {@link ReflectionHelper#getPrivateValue(Class, Object, int)} - * - * @param instanceclass - * @param instance - * @param fieldindex - * @return - */ - public static T getPrivateValue(Class instanceclass, E instance, int fieldindex) - { - return ObfuscationReflectionHelper.getPrivateValue(instanceclass, instance, fieldindex); - } - - /** - * Get a value from a field using reflection - * {@link ObfuscationReflectionHelper#getPrivateValue(Class, Object, String)} - * - * @param instanceclass - * @param instance - * @param field - * @return - */ - public static T getPrivateValue(Class instanceclass, E instance, String field) - { - return ObfuscationReflectionHelper.getPrivateValue(instanceclass, instance, field); - } - - /** - * Stubbed method on the server to return a unique model id - * - */ - public static int getUniqueBlockModelID(BaseMod mod, boolean inventoryRenderer) - { - return -1; - } - - /** - * Get a new unique entity id - * {@link Entity#getNextId()} - * - * @return - */ - public static int getUniqueEntityId() - { - return EntityRegistry.findGlobalUniqueEntityId(); - } - - public static int getUniqueSpriteIndex(String path) - { - return -1; - } - - /** - * To properly implement packet 250 protocol you should always check your - * channel is active prior to sending the packet - * - * @param player - * @param channel - * @return - */ - public static boolean isChannelActive(EntityPlayer player, String channel) - { - return NetworkRegistry.instance().isChannelActive(channel, (Player) player); - } - - public static boolean isGUIOpen(Class gui) - { - return false; - } - - /** - * Is the named mod loaded? - * {@link Loader#isModLoaded(String)} - * - * @param modname - * @return - */ - public static boolean isModLoaded(String modname) - { - return Loader.isModLoaded(modname); - } - - /** - * Implemented elsewhere - */ - @Deprecated - public static void loadConfig() - { - } - - public static Object loadImage(Object renderEngine, String path) throws Exception - { - return null; - } - - /** - * Call in from elsewhere. Unimplemented here. - * @param player - * @param item - */ - @Deprecated - public static void onItemPickup(EntityPlayer player, ItemStack item) - { - } - /** - * Call in from elsewhere. Unimplemented here. - */ - @Deprecated - public static void onTick(float tick, Object game) - { - } - - public static void openGUI(EntityPlayer player, Object gui) - { - // NOOP - } - - @Deprecated - public static void populateChunk(IChunkProvider generator, int chunkX, int chunkZ, World world) - { - } - - /** - * This method is a call in hook from modified external code. Implemented elsewhere. - * {@link FMLServerHandler#handlePacket250(Packet250CustomPayload, EntityPlayer)} - * - * @param packet - */ - @Deprecated - public static void receivePacket(Packet250CustomPayload packet) - { - } - - @Deprecated - public static Object[] registerAllKeys(Object[] keys) - { - return keys; - } - - @Deprecated - public static void registerAllTextureOverrides(Object cache) - { - } - - /** - * Register a new block - * - * @param block - */ - public static void registerBlock(Block block) - { - GameRegistry.registerBlock(block); - } - - /** - * Register a new block - * - * @param block - * @param itemclass - */ - public static void registerBlock(Block block, Class itemclass) - { - GameRegistry.registerBlock(block, itemclass); - } - - /** - * Register a new entity ID - * - * @param entityClass - * @param entityName - * @param id - */ - public static void registerEntityID(Class entityClass, String entityName, int id) - { - EntityRegistry.registerGlobalEntityID(entityClass, entityName, id); - } - - /** - * Register a new entity ID - * - * @param entityClass - * @param entityName - * @param id - * @param background - * @param foreground - */ - public static void registerEntityID(Class entityClass, String entityName, int id, int background, int foreground) - { - EntityRegistry.registerGlobalEntityID(entityClass, entityName, id, background, foreground); - } - - public static void registerKey(BaseMod mod, Object keyHandler, boolean allowRepeat) - { - // NOOP - } - - /** - * Register the mod for packets on this channel. This only registers the - * channel with Forge Mod Loader, not with clients connecting- use - * BaseMod.onClientLogin to tell them about your custom channel - * {@link FMLCommonHandler#registerChannel(cpw.mods.fml.common.ModContainer, String)} - * - * @param mod - * @param channel - */ - public static void registerPacketChannel(BaseMod mod, String channel) - { - NetworkRegistry.instance().registerChannel(ModLoaderHelper.buildPacketHandlerFor(mod), channel); - } - - /** - * Register a new tile entity class - * - * @param tileEntityClass - * @param id - */ - public static void registerTileEntity(Class tileEntityClass, String id) - { - GameRegistry.registerTileEntity(tileEntityClass, id); - } - - public static void registerTileEntity(Class tileEntityClass, String id, Object renderer) - { - GameRegistry.registerTileEntity(tileEntityClass, id); - } - - /** - * Remove a biome from the list of generated biomes - * - * @param biome - */ - public static void removeBiome(BiomeGenBase biome) - { - GameRegistry.removeBiome(biome); - } - - /** - * Remove a spawn - * - * @param entityClass - * @param spawnList - */ - public static void removeSpawn(Class entityClass, EnumCreatureType spawnList) - { - EntityRegistry.removeSpawn(entityClass, spawnList, WorldType.base12Biomes); - } - - /** - * Remove a spawn - * - * @param entityClass - * @param spawnList - * @param biomes - */ - public static void removeSpawn(Class entityClass, EnumCreatureType spawnList, BiomeGenBase... biomes) - { - EntityRegistry.removeSpawn(entityClass, spawnList, biomes); - } - - /** - * Remove a spawn - * - * @param entityName - * @param spawnList - */ - public static void removeSpawn(String entityName, EnumCreatureType spawnList) - { - EntityRegistry.removeSpawn(entityName, spawnList, WorldType.base12Biomes); - } - - /** - * Remove a spawn - * - * @param entityName - * @param spawnList - * @param biomes - */ - public static void removeSpawn(String entityName, EnumCreatureType spawnList, BiomeGenBase... biomes) - { - EntityRegistry.removeSpawn(entityName, spawnList, biomes); - } - - @Deprecated - public static boolean renderBlockIsItemFull3D(int modelID) - { - return false; - } - - @Deprecated - public static void renderInvBlock(Object renderer, Block block, int metadata, int modelID) - { - // NOOP - } - - @Deprecated - public static boolean renderWorldBlock(Object renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID) - { - return false; - } - - /** - * Configuration is handled elsewhere - * {@link ModLoaderModContainer} - */ - @Deprecated - public static void saveConfig() - { - } - - public static void sendPacket(Packet packet) { - // TODO -// FMLClientHandler.instance().sendPacket(packet); - } - /** - * Send a chat message to the server - * {@link FMLServerHandler#handleChatPacket(Packet3Chat, EntityPlayer)} - * - * @param text - */ - @Deprecated - public static void serverChat(String text) - { - //TODO - } - - @Deprecated - public static void serverLogin(Object handler, Packet1Login loginPacket) - { - //TODO - } - - /** - * Indicate that you want to receive ticks - * - * @param mod receiving the events - * @param enable indicates whether you want to recieve them or not - * @param useClock Not used in server side: all ticks are sent on the server side (no render subticks) - */ - public static void setInGameHook(BaseMod mod, boolean enable, boolean useClock) - { - ModLoaderHelper.updateStandardTicks(mod, enable, useClock); - } - - - public static void setInGUIHook(BaseMod mod, boolean enable, boolean useClock) - { - ModLoaderHelper.updateGUITicks(mod, enable, useClock); - } - - /** - * Set a private field to a value using reflection - * {@link ObfuscationReflectionHelper#setPrivateValue(Class, Object, int, Object)} - * - * @param instanceclass - * @param instance - * @param fieldindex - * @param value - */ - public static void setPrivateValue(Class instanceclass, T instance, int fieldindex, E value) - { - ObfuscationReflectionHelper.setPrivateValue(instanceclass, instance, value, fieldindex); - } - - /** - * Set a private field to a value using reflection - * {@link ObfuscationReflectionHelper#setPrivateValue(Class, Object, String, Object)} - * - * @param instanceclass - * @param instance - * @param field - * @param value - */ - public static void setPrivateValue(Class instanceclass, T instance, String field, E value) - { - ObfuscationReflectionHelper.setPrivateValue(instanceclass, instance, value, field); - } - - /** - * This method is a call in hook from modified external code. Implemented elsewhere. - * {@link FMLServerHandler#onItemCrafted(EntityPlayer, ItemStack, IInventory)} - * - * @param player - * @param item - * @param matrix - */ - @Deprecated - public static void takenFromCrafting(EntityPlayer player, ItemStack item, IInventory matrix) - { - } - - /** - * This method is a call in hook from modified external code. Implemented elsewhere. - * {@link FMLServerHandler#onItemSmelted(EntityPlayer, ItemStack)} - * - * @param player - * @param item - */ - @Deprecated - public static void takenFromFurnace(EntityPlayer player, ItemStack item) - { - } - - /** - * Throw the offered exception. Likely will stop the game. - * {@link FMLServerHandler#raiseException(Throwable, String, boolean)} - * - * @param message - * @param e - */ - public static void throwException(String message, Throwable e) - { - FMLCommonHandler.instance().raiseException(e, message, true); - } - - public static void throwException(Throwable e) - { - throwException("Exception in ModLoader", e); - } -} \ No newline at end of file diff --git a/fml/update_packages.py b/fml/update_packages.py deleted file mode 100644 index ae3ee89713..0000000000 --- a/fml/update_packages.py +++ /dev/null @@ -1,115 +0,0 @@ -import os, os.path, sys -import shutil, glob, fnmatch -import csv, re -from pprint import pprint -from zipfile import ZipFile -from optparse import OptionParser -from contextlib import closing - -def get_merged_info(fml_dir, mcp_dir): - joined = os.path.join(mcp_dir, 'conf', 'joined.srg') - values = {'PK:': {}, 'CL:': {}, 'FD:': {}, 'MD:': {}} - - if not os.path.isfile(joined): - sys.path.append(os.path.join(fml_dir, 'install')) - from fml import gen_merged_srg - values = create_merged_srg(mcp_dir, None) - else: - with closing(open(joined, 'r')) as fh: - for line in fh: - pts = line.rstrip('\r\n').split(' ') - if pts[0] == 'MD:': - values[pts[0]][pts[1] + ' ' + pts[2]] = pts[3] + ' ' + pts[4] - else: - values[pts[0]][pts[1]] = pts[2] - return {t:{v.split(' ')[0]:k for k, v in m.items()} for t,m in values.items()} - -def load_suggestions(fml_dir): - map_file = os.path.join(fml_dir, 'map_client.txt') - if not os.path.isfile(map_file): - return None - - map = {} - with closing(open(map_file, 'r')) as fh: - for line in fh: - if line[0] == ' ': - continue - line = line[0:-2].split(' -> ') - map[line[1]] = line[0].rsplit('.', 1)[0] - return map - -def main(): - parser = OptionParser() - parser.add_option('-m', '--mcp-dir', action='store', dest='mcp_dir', help='MCP install folder', default='mcp') - parser.add_option('-f', '--fml-dir', action='store', dest='fml_dir', help='FML instlal folder', default='.') - options, _ = parser.parse_args() - - sys.path.append(os.path.join(options.fml_dir, 'install')) - - from fml import read_mc_versions, load_srg - info = read_mc_versions(options.fml_dir, work_dir=os.path.join(options.mcp_dir, 'jars')) - suggs = load_suggestions(options.fml_dir) - - types = {'client' : [], 'server' : []} - for type in ['client', 'server']: - with closing(ZipFile(info['%s_file' % type])) as zip: - for i in zip.filelist: - if i.filename.endswith('.class') and i.filename.find('/') == -1: - types[type].append(i.filename[:-6]) - - srg = get_merged_info(options.fml_dir, options.mcp_dir) - pkgs = {} - pkg_file = os.path.join('conf', 'packages.csv') - - if os.path.isfile(pkg_file): - with closing(open(pkg_file)) as fh: - reader = csv.DictReader(fh) - for line in reader: - pkgs[line['class']] = line['package'] - - classes = {} - for cls in srg['CL:'].keys(): - if cls.startswith('net/minecraft/src/'): - obf = srg['CL:'][cls] - cls = cls[18:] - classes[cls] = obf - for type in ['server', 'client']: - if obf in types[type]: - types[type].remove(obf) - types[type].append(cls) - - for cls in pkgs.keys(): - if not cls in classes.keys(): - print 'Removed Class: %s/%s' % (pkgs[cls], cls) - pkgs.pop(cls) - - for cls,obf in classes.items(): - if not cls in pkgs.keys(): - sug = '' - if not suggs is None and obf in suggs.keys(): - sug = '_' + suggs[obf].replace('.', '_') - - print 'New Class: %s' % cls - if cls.find('/') == -1: - if cls in types['server'] and cls in types['client']: - pkgs[cls] = 'get_me_out_of_here_shared' + sug - elif cls in types['server']: - pkgs[cls] = 'get_me_out_of_here_server' + sug - elif cls in types['client']: - pkgs[cls] = 'get_me_out_of_here_client' + sug - else: - pkgs[cls] = 'get_me_out_of_here_src' + sug - - tmp=[] - for cls,pkg in pkgs.items(): - tmp.append({'class': cls, 'package': pkg}) - - with closing(open(pkg_file, 'wb')) as fh: - writer = csv.DictWriter(fh, fieldnames=['class', 'package'], lineterminator='\n') - writer.writeheader() - for row in sorted(tmp, key=lambda x: (x['package'], x['class'])): - writer.writerow(row) - -if __name__ == '__main__': - main() - diff --git a/fml/update_patches.bat b/fml/update_patches.bat deleted file mode 100644 index dc15a40a4e..0000000000 --- a/fml/update_patches.bat +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -..\runtime\bin\python\python_mcp update_patches.py .. . diff --git a/fml/update_patches.py b/fml/update_patches.py deleted file mode 100644 index 59aac4665d..0000000000 --- a/fml/update_patches.py +++ /dev/null @@ -1,86 +0,0 @@ -import sys -import os -import commands -import fnmatch -import re -import subprocess, shlex, shutil - -import difflib, time - -def cmdsplit(args): - if os.sep == '\\': - args = args.replace('\\', '\\\\') - return shlex.split(args) - -def cleanDirs(path): - if not os.path.isdir(path): - return - - files = os.listdir(path) - if len(files): - for f in files: - fullpath = os.path.join(path, f) - if os.path.isdir(fullpath): - cleanDirs(fullpath) - - files = os.listdir(path) - if len(files) == 0: - os.rmdir(path) - -def main(): - print("Creating patches") - mcp = os.path.normpath(sys.argv[1]) - fml_dir = os.path.normpath(sys.argv[2]) - patchd = os.path.normpath(os.path.join(fml_dir, 'patches')) - base = os.path.normpath(os.path.join(mcp, 'src-base')) - work = os.path.normpath(os.path.join(mcp, 'src-work')) - - for path, _, filelist in os.walk(work, followlinks=True): - for cur_file in fnmatch.filter(filelist, '*.java'): - file_base = os.path.normpath(os.path.join(base, path[len(work)+1:], cur_file)).replace(os.path.sep, '/') - file_work = os.path.normpath(os.path.join(work, path[len(work)+1:], cur_file)).replace(os.path.sep, '/') - - fromlines = open(file_base, 'U').readlines() - tolines = open(file_work, 'U').readlines() - - patch = ''.join(difflib.unified_diff(fromlines, tolines, '../' + file_base[len(mcp)+1:], '../' + file_work[len(mcp)+1:], '', '', n=3)) - patch_dir = os.path.join(patchd, path[len(work)+1:]) - patch_file = os.path.join(patch_dir, cur_file + '.patch') - - if len(patch) > 0: - print patch_file[len(patchd)+1:] - patch = patch.replace('\r\n', '\n') - - if not os.path.exists(patch_dir): - os.makedirs(patch_dir) - with open(patch_file, 'wb') as fh: - fh.write(patch) - else: - if os.path.isfile(patch_file): - print("Deleting empty patch: %s"%(patch_file)) - os.remove(patch_file) - - - cleanDirs(patchd) - - backup = os.path.join(mcp, 'runtime', 'commands.py.backup') - runtime = os.path.join(mcp, 'runtime', 'commands.py') - patch_file = os.path.join(fml_dir, 'commands.patch') - - if not os.path.exists(backup): - shutil.copy(runtime, backup) - - patch = ''.join(difflib.unified_diff(open(backup, 'U').readlines(), open(runtime, 'U').readlines(), 'commands.py', 'commands.py', '', '', n=3)) - if len(patch) > 0: - print 'Creating commands.py patch' - patch = patch.replace('\r\n', '\n') - - with open(patch_file, 'wb') as fh: - fh.write(patch) - else: - if os.path.isfile(patch_file): - print("Deleting empty commands.py patch") - os.remove(patch_file) - -if __name__ == '__main__': - main() diff --git a/fml/update_patches.sh b/fml/update_patches.sh deleted file mode 100755 index bec1ddecf9..0000000000 --- a/fml/update_patches.sh +++ /dev/null @@ -1 +0,0 @@ -python update_patches.py .. patches diff --git a/fml/updateasmdata.py b/fml/updateasmdata.py deleted file mode 100644 index 4fa2430ede..0000000000 --- a/fml/updateasmdata.py +++ /dev/null @@ -1,107 +0,0 @@ -import os, os.path, sys -import shutil, glob, fnmatch -import csv, re - -ctorsigre = re.compile('\((.*)\)') -ctorparamre = re.compile('(([ZBCSIJFD]|L([\w\/]+);))') - -def get_merged_info(): - mcp_dir = os.path.join(os.getcwd(), 'mcp') - joined = os.path.join(mcp_dir, 'conf', 'joined.srg') - values = {'PK:': {}, 'CL:': {}, 'FD:': {}, 'MD:': {}} - - if not os.path.isfile(joined): - sys.path.append('install') - from fml import gen_merged_srg - values = gen_merged_srg(mcp_dir, None) - else: - with open(joined, 'r') as fh: - for line in fh: - pts = line.rstrip('\r\n').split(' ') - if pts[0] == 'MD:': - values[pts[0]][pts[1] + ' ' + pts[2]] = pts[3] + ' ' + pts[4] - else: - values[pts[0]][pts[1]] = pts[2] - - return {t:{v.split(' ')[0]:k for k, v in m.items()} for t,m in values.items()} - -def process_file(file, srg): - name = os.path.basename(file) - print 'Processing: ' + name - - if name == 'mcp_merge.cfg': - with open(file + '-new','w') as nf: - with open(file) as f: - for line in f: - parts = line.split('#') - target = parts[1].strip() - newpart = '%s%s #%s\n' % (parts[0][0], srg['CL:'][target], target) - nf.write(newpart) - else: - with open(file + '-new', 'wb') as nf: - with open(file) as f: - for line in f: - parts = line.split('#') - if len(parts) < 2: - nf.write(line) - continue - if len(parts[1]) < 4: - nf.write(line) - continue - - typ = parts[1][0:3] - - if not srg.has_key(typ): - nf.write(line) - continue - - name = parts[1][3:].strip() - name = (name if name.startswith('net/minecraft/') else 'net/minecraft/src/' + name) - action = parts[0].split(' ') - - if name.endswith('/*'): - targ = srg['CL:'][name[:-2]] - wildcard = ('.*()' if typ == 'MD:' else '.*') - - newline = '%s %s%s #%s' % (action[0], targ, wildcard, '#'.join(parts[1:])) - nf.write(newline) - - elif name.find('/') >= 0: - targ = srg['CL:'][name[:name.find('/')]] - args = '(' - armatch = ctorsigre.search(name).group(1) - for bit in ctorparamre.findall(armatch): - if len(bit[2]) > 0 and srg['CL:'].has_key(bit[2]): - cl = 'L' + srg['CL:'][bit[2]] + ';' - else: - cl = bit[1] - args += cl - args += ')V' - newline = ('%s %s.%s #%s' % (action[0], targ, args, '#'.join(parts[1:]))) - nf.write(newline) - - else: - if name not in srg[typ]: - nf.write("%s # -- MISSING MAPPING\n" %( line.rstrip() )) - print("%s is missing a mapping"% name) - else: - targ = srg[typ][name] - args = targ.replace('/', '.', 1).replace(' ', '', 1) - newline = ('%s %s #%s' % (action[0], args, '#'.join(parts[1:]))) - nf.write(newline) - -def main(): - srg = get_merged_info() - for arg in sys.argv: - path = os.path.join(os.getcwd(), arg) - - if arg.endswith('_at.cfg') or arg == 'mcp_merge.cfg': - process_file(path, srg) - elif os.path.isdir(path): - for file in os.listdir(path): - if file.endswith('_at.cfg'): - process_file(os.path.join(path, file), srg) - -if __name__ == '__main__': - main() - diff --git a/fml/updatefml.txt b/fml/updatefml.txt deleted file mode 100644 index 6f04bd5670..0000000000 --- a/fml/updatefml.txt +++ /dev/null @@ -1,17 +0,0 @@ -Updating FML: -1. Grab MCP -2. Complete the mc_versions.cfg - add a new entry and update md5s from MCP -3. Copy joined.exc from MCP conf into FML conf. -4. Merge other mcp configuration changes into FML conf. (generally only mcp.cfg should need changing to update md5s) -If obfuscation changed: -5. Run the updateasmdata.py script to refresh the ASM metadata in fml_at.cfg (only -6. Inspect and update mcp_merge.cfg -7. Inspect and update fml_marker.cfg -Always: -8. Merge MCP mcmod.info into mcpmod.info and update the mcp.png graphic if necessary -9. Run ant setupenvironment to try and build the FML environment -10. Fix up any patch rejections -11. Commit the result to git -12. Tag git with a new version: git tag -a vx.y -13. Update jenkins with new MCP and jars -14. Push tags to git followed by the commit itself