First pass : kill modloader, clean up warnings
This commit is contained in:
parent
394cfa940e
commit
a8e44dad47
102 changed files with 169 additions and 4957 deletions
|
@ -5,7 +5,7 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
@ -31,6 +31,8 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
@SideOnly(Side.CLIENT)
|
||||
public abstract class CustomModLoadingErrorDisplayException extends RuntimeException implements IFMLHandledException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Called after the GUI is inited by the parent code. You can do extra stuff here, maybe?
|
||||
*
|
||||
|
|
|
@ -12,11 +12,8 @@
|
|||
*/
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
@ -30,11 +27,8 @@ import net.minecraft.client.multiplayer.NetClientHandler;
|
|||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.resources.FileResourcePack;
|
||||
import net.minecraft.client.resources.FolderResourcePack;
|
||||
import net.minecraft.client.resources.ReloadableResourceManager;
|
||||
import net.minecraft.client.resources.ResourcePack;
|
||||
import net.minecraft.client.resources.SimpleReloadableResourceManager;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
|
@ -50,12 +44,10 @@ import net.minecraft.world.World;
|
|||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.MapDifference;
|
||||
import com.google.common.collect.MapDifference.ValueDifference;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import cpw.mods.fml.client.modloader.ModLoaderClientHelper;
|
||||
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.DummyModContainer;
|
||||
|
@ -76,11 +68,9 @@ import cpw.mods.fml.common.network.EntitySpawnPacket;
|
|||
import cpw.mods.fml.common.network.ModMissingPacket;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
import cpw.mods.fml.common.registry.IThrowableEntity;
|
||||
import cpw.mods.fml.common.registry.ItemData;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.common.toposort.ModSortingException;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
|
@ -118,8 +108,10 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
|
||||
private DummyModContainer optifineContainer;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private boolean guiLoaded;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private boolean serverIsRunning;
|
||||
|
||||
private MissingModsException modsMissing;
|
||||
|
@ -138,6 +130,7 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
|
||||
private List<ResourcePack> resourcePackList;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private ReloadableResourceManager resourceManager;
|
||||
|
||||
private Map<String, ResourcePack> resourcePackMap;
|
||||
|
@ -149,7 +142,8 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
* @param resourcePackList The resource pack list we will populate with mods
|
||||
* @param resourceManager The resource manager
|
||||
*/
|
||||
public void beginMinecraftLoading(Minecraft minecraft, List resourcePackList, ReloadableResourceManager resourceManager)
|
||||
@SuppressWarnings("unchecked")
|
||||
public void beginMinecraftLoading(Minecraft minecraft, @SuppressWarnings("rawtypes") List resourcePackList, ReloadableResourceManager resourceManager)
|
||||
{
|
||||
client = minecraft;
|
||||
this.resourcePackList = resourcePackList;
|
||||
|
@ -162,9 +156,7 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
return;
|
||||
}
|
||||
|
||||
// TextureFXManager.instance().setClient(client);
|
||||
FMLCommonHandler.instance().beginLoading(this);
|
||||
new ModLoaderClientHelper(client);
|
||||
try
|
||||
{
|
||||
Class<?> optifineConfig = Class.forName("Config", false, Loader.instance().getModClassLoader());
|
||||
|
@ -237,7 +229,7 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
* Also initializes key bindings
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressWarnings({ "deprecation", "unchecked" })
|
||||
public void finishMinecraftLoading()
|
||||
{
|
||||
if (modsMissing != null || wrongMC != null || customError!=null || dupesFound!=null || modSorting!=null)
|
||||
|
@ -259,7 +251,7 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
haltGame("There was a severe problem during mod loading that has caused the game to fail", le);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
client.field_71416_A.LOAD_SOUND_SYSTEM = true;
|
||||
// Reload resources
|
||||
client.func_110436_a();
|
||||
|
@ -269,8 +261,10 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
KeyBindingRegistry.instance().uploadKeyBindingsToGame(client.field_71474_y);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void extendModList()
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String,Map<String,String>> modList = (Map<String, Map<String, String>>) Launch.blackboard.get("modList");
|
||||
if (modList != null)
|
||||
{
|
||||
|
@ -398,6 +392,7 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
client.func_71373_a(gui);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Entity spawnEntityIntoClientWorld(EntityRegistration er, EntitySpawnPacket packet)
|
||||
{
|
||||
|
|
|
@ -2,20 +2,19 @@ package cpw.mods.fml.client;
|
|||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import net.minecraft.client.resources.FileResourcePack;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
|
||||
import net.minecraft.client.resources.FileResourcePack;
|
||||
|
||||
public class FMLFileResourcePack extends FileResourcePack {
|
||||
|
||||
private ModContainer container;
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
package cpw.mods.fml.client;
|
||||
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.WrongMinecraftVersionException;
|
||||
|
||||
public class GuiCustomModLoadingErrorScreen extends GuiErrorScreen
|
||||
{
|
||||
|
|
|
@ -16,11 +16,8 @@ import java.io.File;
|
|||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
|
||||
import cpw.mods.fml.common.DuplicateModsFoundException;
|
||||
import cpw.mods.fml.common.MissingModsException;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
|
||||
public class GuiDupesFound extends GuiErrorScreen
|
||||
{
|
||||
|
|
|
@ -18,14 +18,12 @@ import java.util.Map.Entry;
|
|||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiYesNo;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.StringTranslate;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.MapDifference;
|
||||
import com.google.common.collect.MapDifference.ValueDifference;
|
||||
|
||||
import cpw.mods.fml.common.registry.ItemData;
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
|
||||
public class GuiIdMismatchScreen extends GuiYesNo {
|
||||
private List<String> missingIds = Lists.newArrayList();
|
||||
|
@ -43,7 +41,7 @@ public class GuiIdMismatchScreen extends GuiYesNo {
|
|||
for (Entry<Integer, ValueDifference<ItemData>> entry : idDifferences.entriesDiffering().entrySet())
|
||||
{
|
||||
ItemData world = entry.getValue().leftValue();
|
||||
ItemData game = entry.getValue().rightValue();
|
||||
// ItemData game = entry.getValue().rightValue();
|
||||
mismatchedIds.add(String.format("ID %d is mismatched between world and game", world.getItemId()));
|
||||
}
|
||||
this.allowContinue = allowContinue;
|
||||
|
|
|
@ -29,13 +29,10 @@ import net.minecraft.client.gui.GuiScreen;
|
|||
import net.minecraft.client.gui.GuiSmallButton;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureObject;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.resources.ResourcePack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StringTranslate;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
@ -84,6 +81,7 @@ public class GuiModList extends GuiScreen
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void func_73866_w_()
|
||||
{
|
||||
|
|
|
@ -16,7 +16,6 @@ import net.minecraft.client.gui.GuiButton;
|
|||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiSmallButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.StringTranslate;
|
||||
import cpw.mods.fml.common.network.ModMissingPacket;
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
|
||||
|
@ -29,6 +28,7 @@ public class GuiModsMissingForServer extends GuiScreen
|
|||
this.modsMissing = modsMissing;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void func_73866_w_()
|
||||
{
|
||||
|
|
|
@ -104,7 +104,7 @@ public abstract class GuiScrollingList
|
|||
return p_27256_1_ >= var3 && p_27256_1_ <= var4 && var6 >= 0 && var5 >= 0 && var6 < this.getSize() ? var6 : -1;
|
||||
}
|
||||
|
||||
public void registerScrollButtons(List p_22240_1_, int p_22240_2_, int p_22240_3_)
|
||||
public void registerScrollButtons(@SuppressWarnings("rawtypes") List p_22240_1_, int p_22240_2_, int p_22240_3_)
|
||||
{
|
||||
this.scrollUpActionId = p_22240_2_;
|
||||
this.scrollDownActionId = p_22240_3_;
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
package cpw.mods.fml.client;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.toposort.ModSortingException;
|
||||
import cpw.mods.fml.common.toposort.ModSortingException.SortingExceptionData;
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class GuiSortingProblem extends GuiScreen {
|
||||
private ModSortingException modSorting;
|
||||
private SortingExceptionData<ModContainer> failedList;
|
||||
|
||||
public GuiSortingProblem(ModSortingException modSorting)
|
||||
{
|
||||
this.modSorting = modSorting;
|
||||
this.failedList = modSorting.getExceptionData();
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ package cpw.mods.fml.client;
|
|||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.WrongMinecraftVersionException;
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
|
||||
public class GuiWrongMinecraft extends GuiErrorScreen
|
||||
{
|
||||
|
|
|
@ -1,142 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.lwjgl.opengl.ContextCapabilities;
|
||||
import org.lwjgl.opengl.GLContext;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class TextureFXManager
|
||||
{
|
||||
private static final TextureFXManager INSTANCE = new TextureFXManager();
|
||||
|
||||
private Minecraft client;
|
||||
|
||||
private Map<Integer,TextureHolder> texturesById = Maps.newHashMap();
|
||||
private Map<String, TextureHolder> texturesByName = Maps.newHashMap();
|
||||
|
||||
// private TextureHelper helper;
|
||||
|
||||
void setClient(Minecraft client)
|
||||
{
|
||||
this.client = client;
|
||||
}
|
||||
// public BufferedImage loadImageFromTexturePack(RenderEngine renderEngine, String path) throws IOException
|
||||
// {
|
||||
// InputStream image=client.field_71418_C.func_77292_e().func_77532_a(path);
|
||||
// if (image==null) {
|
||||
// throw new RuntimeException(String.format("The requested image path %s is not found",path));
|
||||
// }
|
||||
// BufferedImage result=ImageIO.read(image);
|
||||
// if (result==null)
|
||||
// {
|
||||
// throw new RuntimeException(String.format("The requested image path %s appears to be corrupted",path));
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
public static TextureFXManager instance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public void fixTransparency(BufferedImage loadedImage, String textureName)
|
||||
{
|
||||
if (textureName.matches("^/mob/.*_eyes.*.png$"))
|
||||
{
|
||||
for (int x = 0; x < loadedImage.getWidth(); x++) {
|
||||
for (int y = 0; y < loadedImage.getHeight(); y++) {
|
||||
int argb = loadedImage.getRGB(x, y);
|
||||
if ((argb & 0xff000000) == 0 && argb != 0) {
|
||||
loadedImage.setRGB(x, y, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void bindTextureToName(String name, int index)
|
||||
{
|
||||
TextureHolder holder = new TextureHolder();
|
||||
holder.textureId = index;
|
||||
holder.textureName = name;
|
||||
texturesById.put(index,holder);
|
||||
texturesByName.put(name,holder);
|
||||
}
|
||||
|
||||
public void setTextureDimensions(int index, int j, int k)
|
||||
{
|
||||
TextureHolder holder = texturesById.get(index);
|
||||
if (holder == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
holder.x = j;
|
||||
holder.y = k;
|
||||
}
|
||||
|
||||
private class TextureHolder {
|
||||
private int textureId;
|
||||
private String textureName;
|
||||
private int x;
|
||||
private int y;
|
||||
}
|
||||
|
||||
public Dimension getTextureDimensions(String texture)
|
||||
{
|
||||
return texturesByName.containsKey(texture) ? new Dimension(texturesByName.get(texture).x, texturesByName.get(texture).y) : new Dimension(1,1);
|
||||
}
|
||||
|
||||
|
||||
// public TextureHelper getHelper()
|
||||
// {
|
||||
// if (helper == null)
|
||||
// {
|
||||
// ContextCapabilities capabilities = GLContext.getCapabilities();
|
||||
// boolean has43 = false;
|
||||
// try
|
||||
// {
|
||||
// has43 = capabilities.getClass().getField("GL_ARB_copy_image").getBoolean(capabilities);
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// //e.printStackTrace();
|
||||
// // NOOP - LWJGL needs updating
|
||||
// FMLLog.info("Forge Mod Loader has detected an older LWJGL version, new advanced texture animation features are disabled");
|
||||
// }
|
||||
//// if (has43 && Boolean.parseBoolean(System.getProperty("fml.useGL43","true")))
|
||||
//// {
|
||||
//// FMLLog.info("Using the new OpenGL 4.3 advanced capability for animations");
|
||||
//// helper = new OpenGL43TextureHelper();
|
||||
//// }
|
||||
//// else
|
||||
// {
|
||||
// FMLLog.info("Not using advanced OpenGL 4.3 advanced capability for animations : OpenGL 4.3 is %s", has43 ? "available" : "not available");
|
||||
//// helper = new CopySubimageTextureHelper();
|
||||
// }
|
||||
// }
|
||||
// return helper;
|
||||
// }
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.client.modloader;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.src.BaseMod;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class ModLoaderBlockRendererHandler implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
private int renderId;
|
||||
private boolean render3dInInventory;
|
||||
private BaseMod mod;
|
||||
|
||||
/**
|
||||
* @param mod
|
||||
*
|
||||
*/
|
||||
public ModLoaderBlockRendererHandler(int renderId, boolean render3dInInventory, BaseMod mod)
|
||||
{
|
||||
this.renderId=renderId;
|
||||
this.render3dInInventory=render3dInInventory;
|
||||
this.mod=mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId()
|
||||
{
|
||||
return renderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory()
|
||||
{
|
||||
return render3dInInventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param block
|
||||
* @param modelId
|
||||
* @param renderer
|
||||
*/
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
|
||||
{
|
||||
return mod.renderWorldBlock(renderer, world, x, y, z, block, modelId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param block
|
||||
* @param metadata
|
||||
* @param modelID
|
||||
* @param renderer
|
||||
*/
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
mod.renderInvBlock(renderer, block, metadata, modelID);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,190 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.client.modloader;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.NetHandler;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.src.BaseMod;
|
||||
import net.minecraft.client.*;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.multiplayer.NetClientHandler;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import com.google.common.base.Equivalence;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.MapDifference;
|
||||
import com.google.common.collect.MapDifference.ValueDifference;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Multimaps;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.modloader.BaseModProxy;
|
||||
import cpw.mods.fml.common.modloader.IModLoaderSidedHelper;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderHelper;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
||||
import cpw.mods.fml.common.network.EntitySpawnPacket;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration;
|
||||
|
||||
public class ModLoaderClientHelper implements IModLoaderSidedHelper
|
||||
{
|
||||
public static int obtainBlockModelIdFor(BaseMod mod, boolean inventoryRenderer)
|
||||
{
|
||||
int renderId=RenderingRegistry.getNextAvailableRenderId();
|
||||
ModLoaderBlockRendererHandler bri=new ModLoaderBlockRendererHandler(renderId, inventoryRenderer, mod);
|
||||
RenderingRegistry.registerBlockHandler(bri);
|
||||
return renderId;
|
||||
}
|
||||
|
||||
|
||||
public static void handleFinishLoadingFor(ModLoaderModContainer mc, Minecraft game)
|
||||
{
|
||||
FMLLog.log(mc.getModId(), Level.FINE, "Handling post startup activities for ModLoader mod %s", mc.getModId());
|
||||
BaseMod mod = (BaseMod) mc.getMod();
|
||||
|
||||
Map<Class<? extends Entity>, Render> renderers = Maps.newHashMap(RenderManager.field_78727_a.field_78729_o);
|
||||
|
||||
try
|
||||
{
|
||||
FMLLog.log(mc.getModId(), Level.FINEST, "Requesting renderers from basemod %s", mc.getModId());
|
||||
mod.addRenderer(renderers);
|
||||
FMLLog.log(mc.getModId(), Level.FINEST, "Received %d renderers from basemod %s", renderers.size(), mc.getModId());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log(mc.getModId(), Level.SEVERE, e, "A severe problem was detected with the mod %s during the addRenderer call. Continuing, but expect odd results", mc.getModId());
|
||||
}
|
||||
|
||||
MapDifference<Class<? extends Entity>, Render> difference = Maps.difference(RenderManager.field_78727_a.field_78729_o, renderers, Equivalence.identity());
|
||||
|
||||
for ( Entry<Class<? extends Entity>, Render> e : difference.entriesOnlyOnLeft().entrySet())
|
||||
{
|
||||
FMLLog.log(mc.getModId(), Level.WARNING, "The mod %s attempted to remove an entity renderer %s from the entity map. This will be ignored.", mc.getModId(), e.getKey().getName());
|
||||
}
|
||||
|
||||
for (Entry<Class<? extends Entity>, Render> e : difference.entriesOnlyOnRight().entrySet())
|
||||
{
|
||||
FMLLog.log(mc.getModId(), Level.FINEST, "Registering ModLoader entity renderer %s as instance of %s", e.getKey().getName(), e.getValue().getClass().getName());
|
||||
RenderingRegistry.registerEntityRenderingHandler(e.getKey(), e.getValue());
|
||||
}
|
||||
|
||||
for (Entry<Class<? extends Entity>, ValueDifference<Render>> e : difference.entriesDiffering().entrySet())
|
||||
{
|
||||
FMLLog.log(mc.getModId(), Level.FINEST, "Registering ModLoader entity rendering override for %s as instance of %s", e.getKey().getName(), e.getValue().rightValue().getClass().getName());
|
||||
RenderingRegistry.registerEntityRenderingHandler(e.getKey(), e.getValue().rightValue());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
mod.registerAnimation(game);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log(mc.getModId(), Level.SEVERE, e, "A severe problem was detected with the mod %s during the registerAnimation call. Continuing, but expect odd results", mc.getModId());
|
||||
}
|
||||
}
|
||||
|
||||
public ModLoaderClientHelper(Minecraft client)
|
||||
{
|
||||
this.client = client;
|
||||
ModLoaderHelper.sidedHelper = this;
|
||||
keyBindingContainers = Multimaps.newMultimap(Maps.<ModLoaderModContainer, Collection<ModLoaderKeyBindingHandler>>newHashMap(), new Supplier<Collection<ModLoaderKeyBindingHandler>>()
|
||||
{
|
||||
@Override
|
||||
public Collection<ModLoaderKeyBindingHandler> get()
|
||||
{
|
||||
return Collections.singleton(new ModLoaderKeyBindingHandler());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Minecraft client;
|
||||
private static Multimap<ModLoaderModContainer, ModLoaderKeyBindingHandler> keyBindingContainers;
|
||||
|
||||
@Override
|
||||
public void finishModLoading(ModLoaderModContainer mc)
|
||||
{
|
||||
handleFinishLoadingFor(mc, client);
|
||||
}
|
||||
|
||||
|
||||
public static void registerKeyBinding(BaseModProxy mod, KeyBinding keyHandler, boolean allowRepeat)
|
||||
{
|
||||
ModLoaderModContainer mlmc = (ModLoaderModContainer) Loader.instance().activeModContainer();
|
||||
ModLoaderKeyBindingHandler handler = Iterables.getOnlyElement(keyBindingContainers.get(mlmc));
|
||||
handler.setModContainer(mlmc);
|
||||
handler.addKeyBinding(keyHandler, allowRepeat);
|
||||
KeyBindingRegistry.registerKeyBinding(handler);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getClientGui(BaseModProxy mod, EntityPlayer player, int ID, int x, int y, int z)
|
||||
{
|
||||
return ((net.minecraft.src.BaseMod)mod).getContainerGUI((EntityClientPlayerMP) player, ID, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Entity spawnEntity(BaseModProxy mod, EntitySpawnPacket input, EntityRegistration er)
|
||||
{
|
||||
return ((net.minecraft.src.BaseMod)mod).spawnEntity(er.getModEntityId(), client.field_71441_e, input.scaledX, input.scaledY, input.scaledZ);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendClientPacket(BaseModProxy mod, Packet250CustomPayload packet)
|
||||
{
|
||||
((net.minecraft.src.BaseMod)mod).clientCustomPayload(client.field_71439_g.field_71174_a, packet);
|
||||
}
|
||||
|
||||
private Map<INetworkManager,NetHandler> managerLookups = new MapMaker().weakKeys().weakValues().makeMap();
|
||||
@Override
|
||||
public void clientConnectionOpened(NetHandler netClientHandler, INetworkManager manager, BaseModProxy mod)
|
||||
{
|
||||
managerLookups.put(manager, netClientHandler);
|
||||
((BaseMod)mod).clientConnect((NetClientHandler)netClientHandler);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean clientConnectionClosed(INetworkManager manager, BaseModProxy mod)
|
||||
{
|
||||
if (managerLookups.containsKey(manager))
|
||||
{
|
||||
((BaseMod)mod).clientDisconnect((NetClientHandler) managerLookups.get(manager));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.client.modloader;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import com.google.common.collect.ObjectArrays;
|
||||
import com.google.common.primitives.Booleans;
|
||||
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class ModLoaderKeyBindingHandler extends KeyBindingRegistry.KeyHandler
|
||||
{
|
||||
private ModLoaderModContainer modContainer;
|
||||
private List<KeyBinding> helper;
|
||||
private boolean[] active = new boolean[0];
|
||||
private boolean[] mlRepeats = new boolean[0];
|
||||
private boolean[] armed = new boolean[0];
|
||||
|
||||
public ModLoaderKeyBindingHandler()
|
||||
{
|
||||
super(new KeyBinding[0], new boolean[0]);
|
||||
}
|
||||
|
||||
void setModContainer(ModLoaderModContainer modContainer)
|
||||
{
|
||||
this.modContainer = modContainer;
|
||||
}
|
||||
|
||||
public void fireKeyEvent(KeyBinding kb)
|
||||
{
|
||||
((net.minecraft.src.BaseMod)modContainer.getMod()).keyboardEvent(kb);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyDown(EnumSet<TickType> type, KeyBinding kb, boolean end, boolean repeats)
|
||||
{
|
||||
if (!end)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int idx = helper.indexOf(kb);
|
||||
if (type.contains(TickType.CLIENT))
|
||||
{
|
||||
armed[idx] = true;
|
||||
}
|
||||
if (armed[idx] && type.contains(TickType.RENDER) && (!active[idx] || mlRepeats[idx]))
|
||||
{
|
||||
fireKeyEvent(kb);
|
||||
active[idx] = true;
|
||||
armed[idx] = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyUp(EnumSet<TickType> type, KeyBinding kb, boolean end)
|
||||
{
|
||||
if (!end)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int idx = helper.indexOf(kb);
|
||||
active[idx] = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks()
|
||||
{
|
||||
return EnumSet.of(TickType.CLIENT, TickType.RENDER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel()
|
||||
{
|
||||
return modContainer.getModId() +" KB "+keyBindings[0].field_74512_d;
|
||||
}
|
||||
|
||||
void addKeyBinding(KeyBinding binding, boolean repeats)
|
||||
{
|
||||
this.keyBindings = ObjectArrays.concat(this.keyBindings, binding);
|
||||
this.repeatings = new boolean[this.keyBindings.length];
|
||||
Arrays.fill(this.repeatings, true);
|
||||
this.active = new boolean[this.keyBindings.length];
|
||||
this.armed = new boolean[this.keyBindings.length];
|
||||
this.mlRepeats = Booleans.concat(this.mlRepeats, new boolean[] { repeats });
|
||||
this.keyDown = new boolean[this.keyBindings.length];
|
||||
this.helper = Arrays.asList(this.keyBindings);
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
@ -20,9 +20,9 @@ import net.minecraft.tileentity.TileEntity;
|
|||
public class ClientRegistry
|
||||
{
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Utility method for registering a tile entity and it's renderer at once - generally you should register them separately
|
||||
*
|
||||
*
|
||||
* @param tileEntityClass
|
||||
* @param id
|
||||
* @param specialRenderer
|
||||
|
@ -32,7 +32,8 @@ public class ClientRegistry
|
|||
GameRegistry.registerTileEntity(tileEntityClass, id);
|
||||
bindTileEntitySpecialRenderer(tileEntityClass, specialRenderer);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void bindTileEntitySpecialRenderer(Class <? extends TileEntity> tileEntityClass, TileEntitySpecialRenderer specialRenderer)
|
||||
{
|
||||
TileEntityRenderer.field_76963_a.field_76966_m.put(tileEntityClass, specialRenderer);
|
||||
|
|
|
@ -17,7 +17,9 @@ import java.util.Map;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.entity.*;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderBiped;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
|
@ -25,8 +27,6 @@ import com.google.common.collect.Lists;
|
|||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.ObjectArrays;
|
||||
|
||||
import cpw.mods.fml.client.TextureFXManager;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
@ -13,13 +13,12 @@
|
|||
package cpw.mods.fml.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.SetMultimap;
|
||||
|
||||
public class DuplicateModsFoundException extends LoaderException {
|
||||
|
||||
public SetMultimap<ModContainer,File> dupes;
|
||||
private static final long serialVersionUID = 1L;
|
||||
public SetMultimap<ModContainer,File> dupes;
|
||||
|
||||
public DuplicateModsFoundException(SetMultimap<ModContainer, File> dupes) {
|
||||
this.dupes = dupes;
|
||||
|
|
|
@ -15,7 +15,6 @@ package cpw.mods.fml.common;
|
|||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -232,7 +231,7 @@ public class FMLCommonHandler
|
|||
{
|
||||
if (brandings == null)
|
||||
{
|
||||
Builder brd = ImmutableList.<String>builder();
|
||||
Builder<String> brd = ImmutableList.<String>builder();
|
||||
brd.add(Loader.instance().getMCVersionString());
|
||||
brd.add(Loader.instance().getMCPVersionString());
|
||||
brd.add("FML v"+Loader.instance().getFMLVersionString());
|
||||
|
|
|
@ -31,7 +31,6 @@ import cpw.mods.fml.client.FMLFileResourcePack;
|
|||
import cpw.mods.fml.client.FMLFolderResourcePack;
|
||||
import cpw.mods.fml.common.asm.FMLSanityChecker;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.ItemData;
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
@ -15,6 +15,7 @@ package cpw.mods.fml.common;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public class FMLLog
|
||||
{
|
||||
private static cpw.mods.fml.relauncher.FMLRelaunchLog coreLog = cpw.mods.fml.relauncher.FMLRelaunchLog.log;
|
||||
|
|
|
@ -27,10 +27,8 @@ import java.util.Set;
|
|||
import java.util.logging.Level;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
|
@ -40,17 +38,14 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableList.Builder;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
import cpw.mods.fml.common.Mod.CustomProperty;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.Mod.Metadata;
|
||||
import cpw.mods.fml.common.discovery.ASMDataTable;
|
||||
|
@ -58,9 +53,9 @@ import cpw.mods.fml.common.discovery.ASMDataTable.ASMData;
|
|||
import cpw.mods.fml.common.discovery.ModCandidate;
|
||||
import cpw.mods.fml.common.event.FMLConstructionEvent;
|
||||
import cpw.mods.fml.common.event.FMLEvent;
|
||||
import cpw.mods.fml.common.event.FMLFingerprintViolationEvent;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
|
||||
import cpw.mods.fml.common.event.FMLFingerprintViolationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
|
||||
|
@ -68,7 +63,6 @@ import cpw.mods.fml.common.event.FMLServerStartedEvent;
|
|||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
|
||||
import cpw.mods.fml.common.event.FMLStateEvent;
|
||||
import cpw.mods.fml.common.network.FMLNetworkHandler;
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
|
||||
|
@ -77,7 +71,6 @@ import cpw.mods.fml.common.versioning.VersionRange;
|
|||
|
||||
public class FMLModContainer implements ModContainer
|
||||
{
|
||||
private Mod modDescriptor;
|
||||
private Object modInstance;
|
||||
private File source;
|
||||
private ModMetadata modMetadata;
|
||||
|
@ -322,6 +315,7 @@ public class FMLModContainer implements ModContainer
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Method gatherAnnotations(Class<?> clazz) throws Exception
|
||||
{
|
||||
Method factoryMethod = null;
|
||||
|
@ -498,6 +492,7 @@ public class FMLModContainer implements ModContainer
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Map<String,Object>> props = (List<Map<String, Object>>) descriptor.get("customProperties");
|
||||
if (props != null)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,6 @@ import java.lang.reflect.InvocationTargetException;
|
|||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public interface ILanguageAdapter {
|
||||
|
|
|
@ -15,12 +15,10 @@ package cpw.mods.fml.common;
|
|||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.google.common.base.Functions;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.BiMap;
|
||||
|
@ -51,7 +49,6 @@ public class LoadController
|
|||
private LoaderState state;
|
||||
private Multimap<String, ModState> modStates = ArrayListMultimap.create();
|
||||
private Multimap<String, Throwable> errors = ArrayListMultimap.create();
|
||||
private Map<String, ModContainer> modList;
|
||||
private List<ModContainer> activeModList = Lists.newArrayList();
|
||||
private ModContainer activeContainer;
|
||||
private BiMap<ModContainer, Object> modObjectList;
|
||||
|
@ -70,7 +67,6 @@ public class LoadController
|
|||
@Subscribe
|
||||
public void buildModList(FMLLoadEvent event)
|
||||
{
|
||||
this.modList = loader.getIndexedModList();
|
||||
Builder<String, EventBus> eventBus = ImmutableMap.builder();
|
||||
|
||||
for (ModContainer mod : loader.getModList())
|
||||
|
@ -80,7 +76,7 @@ public class LoadController
|
|||
Logger modLogger = Logger.getLogger(mod.getModId());
|
||||
Logger eventLog = Logger.getLogger(EventBus.class.getName() + "." + mod.getModId());
|
||||
eventLog.setParent(modLogger);
|
||||
|
||||
|
||||
EventBus bus = new EventBus(mod.getModId());
|
||||
boolean isActive = mod.registerBus(bus, this);
|
||||
if (isActive)
|
||||
|
|
|
@ -13,49 +13,36 @@
|
|||
package cpw.mods.fml.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.crash.CallableMinecraftVersion;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.google.common.base.CharMatcher;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Joiner.MapJoiner;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableListMultimap;
|
||||
import com.google.common.collect.ImmutableListMultimap.Builder;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMultiset;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.LinkedHashMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.collect.Multiset.Entry;
|
||||
import com.google.common.collect.Multisets;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.common.collect.Sets.SetView;
|
||||
import com.google.common.collect.Table;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.collect.TreeMultimap;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
import cpw.mods.fml.common.LoaderState.ModState;
|
||||
import cpw.mods.fml.common.discovery.ModDiscoverer;
|
||||
|
@ -63,7 +50,6 @@ import cpw.mods.fml.common.event.FMLInterModComms;
|
|||
import cpw.mods.fml.common.event.FMLLoadEvent;
|
||||
import cpw.mods.fml.common.functions.ArtifactVersionNameFunction;
|
||||
import cpw.mods.fml.common.functions.ModIdFunction;
|
||||
import cpw.mods.fml.common.modloader.BaseModProxy;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import cpw.mods.fml.common.toposort.ModSorter;
|
||||
import cpw.mods.fml.common.toposort.ModSortingException;
|
||||
|
@ -138,14 +124,6 @@ public class Loader
|
|||
* The canonical configuration directory
|
||||
*/
|
||||
private File canonicalConfigDir;
|
||||
/**
|
||||
* The canonical minecraft directory
|
||||
*/
|
||||
private File canonicalMinecraftDir;
|
||||
/**
|
||||
* The captured error
|
||||
*/
|
||||
private Exception capturedError;
|
||||
private File canonicalModsDir;
|
||||
private LoadController modController;
|
||||
private MinecraftDummyContainer minecraft;
|
||||
|
@ -166,6 +144,7 @@ public class Loader
|
|||
return instance;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void injectData(Object... data)
|
||||
{
|
||||
major = (String) data[0];
|
||||
|
@ -409,7 +388,6 @@ public class Loader
|
|||
|
||||
try
|
||||
{
|
||||
canonicalMinecraftDir = minecraftDir.getCanonicalFile();
|
||||
canonicalModsPath = modsDir.getCanonicalPath();
|
||||
canonicalConfigPath = configDir.getCanonicalPath();
|
||||
canonicalConfigDir = configDir.getCanonicalFile();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
@ -15,7 +15,6 @@ package cpw.mods.fml.common;
|
|||
import com.google.common.base.Throwables;
|
||||
|
||||
import cpw.mods.fml.common.event.FMLConstructionEvent;
|
||||
import cpw.mods.fml.common.event.FMLEvent;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
|
@ -50,6 +49,7 @@ public enum LoaderState
|
|||
|
||||
|
||||
private Class<? extends FMLStateEvent> eventClass;
|
||||
@SuppressWarnings("unused")
|
||||
private String name;
|
||||
|
||||
private LoaderState(String name, Class<? extends FMLStateEvent> event)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
@ -29,6 +29,7 @@ public class MetadataCollection
|
|||
{
|
||||
private static JdomParser parser = new JdomParser();
|
||||
private Map<String, ModMetadata> metadatas = Maps.newHashMap();
|
||||
@SuppressWarnings("unused")
|
||||
private int metadataVersion = 1;
|
||||
|
||||
public static MetadataCollection from(InputStream inputStream, String sourceName)
|
||||
|
|
|
@ -5,15 +5,13 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.VersionParser;
|
||||
import cpw.mods.fml.common.versioning.VersionRange;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
@ -14,13 +14,11 @@ package cpw.mods.fml.common;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Sets.SetView;
|
||||
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
|
||||
public class MissingModsException extends RuntimeException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
public Set<ArtifactVersion> missingMods;
|
||||
|
||||
public MissingModsException(Set<ArtifactVersion> missingMods)
|
||||
|
|
|
@ -19,21 +19,18 @@ import java.lang.annotation.Target;
|
|||
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
|
||||
import cpw.mods.fml.common.event.FMLEvent;
|
||||
import cpw.mods.fml.common.event.FMLFingerprintViolationEvent;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStartedEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
|
||||
import cpw.mods.fml.common.event.FMLStateEvent;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package cpw.mods.fml.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.security.acl.Owner;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -25,6 +22,7 @@ import cpw.mods.fml.common.versioning.VersionParser;
|
|||
|
||||
public class ModAPIManager {
|
||||
public static final ModAPIManager INSTANCE = new ModAPIManager();
|
||||
@SuppressWarnings("unused")
|
||||
private ModAPITransformer transformer;
|
||||
private ASMDataTable dataTable;
|
||||
private Map<String,APIContainer> apiContainers;
|
||||
|
|
|
@ -26,11 +26,8 @@ import net.minecraft.launchwrapper.LaunchClassLoader;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import cpw.mods.fml.common.asm.ASMTransformer;
|
||||
import cpw.mods.fml.common.asm.transformers.AccessTransformer;
|
||||
import cpw.mods.fml.common.asm.transformers.ModAPITransformer;
|
||||
import cpw.mods.fml.common.discovery.ASMDataTable;
|
||||
import cpw.mods.fml.common.modloader.BaseModProxy;
|
||||
|
||||
/**
|
||||
* A simple delegating class loader used to load mods into the system
|
||||
|
@ -84,26 +81,6 @@ public class ModClassLoader extends URLClassLoader
|
|||
return STANDARD_LIBRARIES;
|
||||
}
|
||||
|
||||
public Class<? extends BaseModProxy> loadBaseModClass(String modClazzName) throws Exception
|
||||
{
|
||||
AccessTransformer accessTransformer = null;
|
||||
for (IClassTransformer transformer : mainClassLoader.getTransformers())
|
||||
{
|
||||
if (transformer instanceof AccessTransformer)
|
||||
{
|
||||
accessTransformer = (AccessTransformer) transformer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (accessTransformer == null)
|
||||
{
|
||||
FMLLog.log(Level.SEVERE, "No access transformer found");
|
||||
throw new LoaderException();
|
||||
}
|
||||
accessTransformer.ensurePublicAccessFor(modClazzName);
|
||||
return (Class<? extends BaseModProxy>) Class.forName(modClazzName, true, this);
|
||||
}
|
||||
|
||||
public void clearNegativeCacheFor(Set<String> classList)
|
||||
{
|
||||
mainClassLoader.clearNegativeEntries(classList);
|
||||
|
|
|
@ -20,7 +20,6 @@ import org.objectweb.asm.Type;
|
|||
import cpw.mods.fml.common.discovery.ModCandidate;
|
||||
import cpw.mods.fml.common.discovery.asm.ASMModParser;
|
||||
import cpw.mods.fml.common.discovery.asm.ModAnnotation;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
||||
|
||||
public class ModContainerFactory
|
||||
{
|
||||
|
@ -34,8 +33,8 @@ public class ModContainerFactory
|
|||
String className = modParser.getASMType().getClassName();
|
||||
if (modParser.isBaseMod(container.getRememberedBaseMods()) && modClass.matcher(className).find())
|
||||
{
|
||||
FMLLog.fine("Identified a BaseMod type mod %s", className);
|
||||
return new ModLoaderModContainer(className, modSource, modParser.getBaseModProperties());
|
||||
FMLLog.severe("Found a BaseMod type mod %s", className);
|
||||
FMLLog.severe("This will not be loaded and will be ignored. ModLoader mechanisms are no longer available.");
|
||||
}
|
||||
else if (modClass.matcher(className).find())
|
||||
{
|
||||
|
|
|
@ -28,7 +28,6 @@ import argo.jdom.JsonStringNode;
|
|||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
@ -89,6 +88,7 @@ public class ModMetadata
|
|||
public List<ArtifactVersion> dependants;
|
||||
public boolean autogenerated;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ModMetadata(JsonNode node)
|
||||
{
|
||||
Map<JsonStringNode, Object> processedFields = Maps.transformValues(node.getFields(), new JsonStringConverter());
|
||||
|
@ -117,6 +117,7 @@ public class ModMetadata
|
|||
{
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends Collection<ArtifactVersion>> T processReferences(Object refs, Class<? extends T> retType)
|
||||
{
|
||||
T res = null;
|
||||
|
|
|
@ -28,7 +28,6 @@ import cpw.mods.fml.relauncher.ReflectionHelper.UnableToFindFieldException;
|
|||
*/
|
||||
public class ObfuscationReflectionHelper
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, int fieldIndex)
|
||||
{
|
||||
try
|
||||
|
@ -53,7 +52,7 @@ public class ObfuscationReflectionHelper
|
|||
}
|
||||
return mappedNames;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, String... fieldNames)
|
||||
{
|
||||
try
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
@ -14,7 +14,7 @@ package cpw.mods.fml.common;
|
|||
|
||||
public class WrongMinecraftVersionException extends RuntimeException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
public ModContainer mod;
|
||||
|
||||
public WrongMinecraftVersionException(ModContainer mod)
|
||||
|
|
|
@ -12,33 +12,15 @@
|
|||
|
||||
package cpw.mods.fml.common.asm;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.ObjectInputStream.GetField;
|
||||
import java.io.StringReader;
|
||||
import java.net.JarURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.CodeSource;
|
||||
import java.security.cert.CertPath;
|
||||
import java.security.cert.CertPathValidator;
|
||||
import java.security.cert.Certificate;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.PKIXCertPathValidatorResult;
|
||||
import java.security.cert.PKIXParameters;
|
||||
import java.security.cert.TrustAnchor;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
|
@ -129,7 +111,7 @@ public class FMLSanityChecker implements IFMLCallHook
|
|||
int certCount = 0;
|
||||
try
|
||||
{
|
||||
Class cbr = Class.forName("net.minecraft.client.ClientBrandRetriever",false, cl);
|
||||
Class<?> cbr = Class.forName("net.minecraft.client.ClientBrandRetriever",false, cl);
|
||||
codeSource = cbr.getProtectionDomain().getCodeSource();
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -173,7 +155,7 @@ public class FMLSanityChecker implements IFMLCallHook
|
|||
{
|
||||
if (mcJarFile != null)
|
||||
{
|
||||
try
|
||||
try
|
||||
{
|
||||
mcJarFile.close();
|
||||
}
|
||||
|
|
|
@ -17,9 +17,7 @@ import net.minecraft.launchwrapper.IClassTransformer;
|
|||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.commons.RemappingClassAdapter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
|
||||
import cpw.mods.fml.common.asm.transformers.deobf.FMLRemappingAdapter;
|
||||
|
|
|
@ -1,659 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.asm.transformers;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.tree.AnnotationNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class MCPMerger
|
||||
{
|
||||
private static Hashtable<String, ClassInfo> clients = new Hashtable<String, ClassInfo>();
|
||||
private static Hashtable<String, ClassInfo> shared = new Hashtable<String, ClassInfo>();
|
||||
private static Hashtable<String, ClassInfo> servers = new Hashtable<String, ClassInfo>();
|
||||
private static HashSet<String> copyToServer = new HashSet<String>();
|
||||
private static HashSet<String> copyToClient = new HashSet<String>();
|
||||
private static HashSet<String> dontAnnotate = new HashSet<String>();
|
||||
private static HashSet<String> dontProcess = new HashSet<String>();
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
if (args.length != 3)
|
||||
{
|
||||
System.out.println("Usage: MCPMerger <MapFile> <minecraft.jar> <minecraft_server.jar>");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
File map_file = new File(args[0]);
|
||||
File client_jar = new File(args[1]);
|
||||
File server_jar = new File(args[2]);
|
||||
File client_jar_tmp = new File(args[1] + ".backup_merge");
|
||||
File server_jar_tmp = new File(args[2] + ".backup_merge");
|
||||
|
||||
if (client_jar_tmp.exists() && !client_jar_tmp.delete())
|
||||
{
|
||||
System.out.println("Could not delete temp file: " + client_jar_tmp);
|
||||
}
|
||||
|
||||
if (server_jar_tmp.exists() && !server_jar_tmp.delete())
|
||||
{
|
||||
System.out.println("Could not delete temp file: " + server_jar_tmp);
|
||||
}
|
||||
|
||||
if (!client_jar.exists())
|
||||
{
|
||||
System.out.println("Could not find minecraft.jar: " + client_jar);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
if (!server_jar.exists())
|
||||
{
|
||||
System.out.println("Could not find minecraft_server.jar: " + server_jar);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
if (!client_jar.renameTo(client_jar_tmp))
|
||||
{
|
||||
System.out.println("Could not rename file: " + client_jar + " -> " + client_jar_tmp);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
if (!server_jar.renameTo(server_jar_tmp))
|
||||
{
|
||||
System.out.println("Could not rename file: " + server_jar + " -> " + server_jar_tmp);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
if (!readMapFile(map_file))
|
||||
{
|
||||
System.out.println("Could not read map file: " + map_file);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
processJar(client_jar_tmp, server_jar_tmp, client_jar, server_jar);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
if (!client_jar_tmp.delete())
|
||||
{
|
||||
System.out.println("Could not delete temp file: " + client_jar_tmp);
|
||||
}
|
||||
|
||||
if (!server_jar_tmp.delete())
|
||||
{
|
||||
System.out.println("Could not delete temp file: " + server_jar_tmp);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean readMapFile(File mapFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
FileInputStream fstream = new FileInputStream(mapFile);
|
||||
DataInputStream in = new DataInputStream(fstream);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
||||
|
||||
String line;
|
||||
while ((line = br.readLine()) != null)
|
||||
{
|
||||
line = line.split("#")[0];
|
||||
char cmd = line.charAt(0);
|
||||
line = line.substring(1).trim();
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case '!': dontAnnotate.add(line); break;
|
||||
case '<': copyToClient.add(line); break;
|
||||
case '>': copyToServer.add(line); break;
|
||||
case '^': dontProcess.add(line); break;
|
||||
}
|
||||
}
|
||||
|
||||
in.close();
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("Error: " + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void processJar(File clientInFile, File serverInFile, File clientOutFile, File serverOutFile) throws IOException
|
||||
{
|
||||
ZipFile cInJar = null;
|
||||
ZipFile sInJar = null;
|
||||
ZipOutputStream cOutJar = null;
|
||||
ZipOutputStream sOutJar = null;
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
cInJar = new ZipFile(clientInFile);
|
||||
sInJar = new ZipFile(serverInFile);
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
throw new FileNotFoundException("Could not open input file: " + e.getMessage());
|
||||
}
|
||||
try
|
||||
{
|
||||
cOutJar = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(clientOutFile)));
|
||||
sOutJar = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(serverOutFile)));
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
throw new FileNotFoundException("Could not open output file: " + e.getMessage());
|
||||
}
|
||||
Hashtable<String, ZipEntry> cClasses = getClassEntries(cInJar, cOutJar);
|
||||
Hashtable<String, ZipEntry> sClasses = getClassEntries(sInJar, sOutJar);
|
||||
HashSet<String> cAdded = new HashSet<String>();
|
||||
HashSet<String> sAdded = new HashSet<String>();
|
||||
|
||||
for (Entry<String, ZipEntry> entry : cClasses.entrySet())
|
||||
{
|
||||
String name = entry.getKey();
|
||||
ZipEntry cEntry = entry.getValue();
|
||||
ZipEntry sEntry = sClasses.get(name);
|
||||
|
||||
if (sEntry == null)
|
||||
{
|
||||
if (!copyToServer.contains(name))
|
||||
{
|
||||
copyClass(cInJar, cEntry, cOutJar, null, true);
|
||||
cAdded.add(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (DEBUG)
|
||||
{
|
||||
System.out.println("Copy class c->s : " + name);
|
||||
}
|
||||
copyClass(cInJar, cEntry, cOutJar, sOutJar, true);
|
||||
cAdded.add(name);
|
||||
sAdded.add(name);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
sClasses.remove(name);
|
||||
ClassInfo info = new ClassInfo(name);
|
||||
shared.put(name, info);
|
||||
|
||||
byte[] cData = readEntry(cInJar, entry.getValue());
|
||||
byte[] sData = readEntry(sInJar, sEntry);
|
||||
byte[] data = processClass(cData, sData, info);
|
||||
|
||||
ZipEntry newEntry = new ZipEntry(cEntry.getName());
|
||||
cOutJar.putNextEntry(newEntry);
|
||||
cOutJar.write(data);
|
||||
sOutJar.putNextEntry(newEntry);
|
||||
sOutJar.write(data);
|
||||
cAdded.add(name);
|
||||
sAdded.add(name);
|
||||
}
|
||||
|
||||
for (Entry<String, ZipEntry> entry : sClasses.entrySet())
|
||||
{
|
||||
if (DEBUG)
|
||||
{
|
||||
System.out.println("Copy class s->c : " + entry.getKey());
|
||||
}
|
||||
copyClass(sInJar, entry.getValue(), cOutJar, sOutJar, false);
|
||||
}
|
||||
|
||||
for (String name : new String[]{SideOnly.class.getName(), Side.class.getName()})
|
||||
{
|
||||
String eName = name.replace(".", "/");
|
||||
byte[] data = getClassBytes(name);
|
||||
ZipEntry newEntry = new ZipEntry(name.replace(".", "/").concat(".class"));
|
||||
if (!cAdded.contains(eName))
|
||||
{
|
||||
cOutJar.putNextEntry(newEntry);
|
||||
cOutJar.write(data);
|
||||
}
|
||||
if (!sAdded.contains(eName))
|
||||
{
|
||||
sOutJar.putNextEntry(newEntry);
|
||||
sOutJar.write(data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (cInJar != null)
|
||||
{
|
||||
try { cInJar.close(); } catch (IOException e){}
|
||||
}
|
||||
|
||||
if (sInJar != null)
|
||||
{
|
||||
try { sInJar.close(); } catch (IOException e) {}
|
||||
}
|
||||
if (cOutJar != null)
|
||||
{
|
||||
try { cOutJar.close(); } catch (IOException e){}
|
||||
}
|
||||
|
||||
if (sOutJar != null)
|
||||
{
|
||||
try { sOutJar.close(); } catch (IOException e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyClass(ZipFile inJar, ZipEntry entry, ZipOutputStream outJar, ZipOutputStream outJar2, boolean isClientOnly) throws IOException
|
||||
{
|
||||
ClassReader reader = new ClassReader(readEntry(inJar, entry));
|
||||
ClassNode classNode = new ClassNode();
|
||||
|
||||
reader.accept(classNode, 0);
|
||||
|
||||
if (!dontAnnotate.contains(classNode.name))
|
||||
{
|
||||
if (classNode.visibleAnnotations == null) classNode.visibleAnnotations = new ArrayList<AnnotationNode>();
|
||||
classNode.visibleAnnotations.add(getSideAnn(isClientOnly));
|
||||
}
|
||||
|
||||
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
classNode.accept(writer);
|
||||
byte[] data = writer.toByteArray();
|
||||
|
||||
ZipEntry newEntry = new ZipEntry(entry.getName());
|
||||
if (outJar != null)
|
||||
{
|
||||
outJar.putNextEntry(newEntry);
|
||||
outJar.write(data);
|
||||
}
|
||||
if (outJar2 != null)
|
||||
{
|
||||
outJar2.putNextEntry(newEntry);
|
||||
outJar2.write(data);
|
||||
}
|
||||
}
|
||||
|
||||
private static AnnotationNode getSideAnn(boolean isClientOnly)
|
||||
{
|
||||
AnnotationNode ann = new AnnotationNode(Type.getDescriptor(SideOnly.class));
|
||||
ann.values = new ArrayList<Object>();
|
||||
ann.values.add("value");
|
||||
ann.values.add(new String[]{ Type.getDescriptor(Side.class), (isClientOnly ? "CLIENT" : "SERVER")});
|
||||
return ann;
|
||||
}
|
||||
|
||||
private static Hashtable<String, ZipEntry> getClassEntries(ZipFile inFile, ZipOutputStream outFile) throws IOException
|
||||
{
|
||||
Hashtable<String, ZipEntry> ret = new Hashtable<String, ZipEntry>();
|
||||
for (ZipEntry entry : Collections.list(inFile.entries()))
|
||||
{
|
||||
if (entry.isDirectory())
|
||||
{
|
||||
outFile.putNextEntry(entry);
|
||||
continue;
|
||||
}
|
||||
|
||||
String entryName = entry.getName();
|
||||
|
||||
boolean filtered = false;
|
||||
for (String filter : dontProcess)
|
||||
{
|
||||
if (entryName.startsWith(filter))
|
||||
{
|
||||
filtered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (filtered || !entryName.endsWith(".class") || entryName.startsWith("."))
|
||||
{
|
||||
ZipEntry newEntry = new ZipEntry(entry.getName());
|
||||
outFile.putNextEntry(newEntry);
|
||||
outFile.write(readEntry(inFile, entry));
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.put(entryName.replace(".class", ""), entry);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
private static byte[] readEntry(ZipFile inFile, ZipEntry entry) throws IOException
|
||||
{
|
||||
return readFully(inFile.getInputStream(entry));
|
||||
}
|
||||
private static byte[] readFully(InputStream stream) throws IOException
|
||||
{
|
||||
byte[] data = new byte[4096];
|
||||
ByteArrayOutputStream entryBuffer = new ByteArrayOutputStream();
|
||||
int len;
|
||||
do
|
||||
{
|
||||
len = stream.read(data);
|
||||
if (len > 0)
|
||||
{
|
||||
entryBuffer.write(data, 0, len);
|
||||
}
|
||||
} while (len != -1);
|
||||
|
||||
return entryBuffer.toByteArray();
|
||||
}
|
||||
private static class ClassInfo
|
||||
{
|
||||
public String name;
|
||||
public ArrayList<FieldNode> cField = new ArrayList<FieldNode>();
|
||||
public ArrayList<FieldNode> sField = new ArrayList<FieldNode>();
|
||||
public ArrayList<MethodNode> cMethods = new ArrayList<MethodNode>();
|
||||
public ArrayList<MethodNode> sMethods = new ArrayList<MethodNode>();
|
||||
public ClassInfo(String name){ this.name = name; }
|
||||
public boolean isSame() { return (cField.size() == 0 && sField.size() == 0 && cMethods.size() == 0 && sMethods.size() == 0); }
|
||||
}
|
||||
|
||||
public static byte[] processClass(byte[] cIn, byte[] sIn, ClassInfo info)
|
||||
{
|
||||
ClassNode cClassNode = getClassNode(cIn);
|
||||
ClassNode sClassNode = getClassNode(sIn);
|
||||
|
||||
processFields(cClassNode, sClassNode, info);
|
||||
processMethods(cClassNode, sClassNode, info);
|
||||
|
||||
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
cClassNode.accept(writer);
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
private static ClassNode getClassNode(byte[] data)
|
||||
{
|
||||
ClassReader reader = new ClassReader(data);
|
||||
ClassNode classNode = new ClassNode();
|
||||
reader.accept(classNode, 0);
|
||||
return classNode;
|
||||
}
|
||||
|
||||
private static void processFields(ClassNode cClass, ClassNode sClass, ClassInfo info)
|
||||
{
|
||||
List<FieldNode> cFields = cClass.fields;
|
||||
List<FieldNode> sFields = sClass.fields;
|
||||
|
||||
int sI = 0;
|
||||
for (int x = 0; x < cFields.size(); x++)
|
||||
{
|
||||
FieldNode cF = cFields.get(x);
|
||||
if (sI < sFields.size())
|
||||
{
|
||||
if (!cF.name.equals(sFields.get(sI).name))
|
||||
{
|
||||
boolean serverHas = false;
|
||||
for (int y = sI + 1; y < sFields.size(); y++)
|
||||
{
|
||||
if (cF.name.equals(sFields.get(y).name))
|
||||
{
|
||||
serverHas = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (serverHas)
|
||||
{
|
||||
boolean clientHas = false;
|
||||
FieldNode sF = sFields.get(sI);
|
||||
for (int y = x + 1; y < cFields.size(); y++)
|
||||
{
|
||||
if (sF.name.equals(cFields.get(y).name))
|
||||
{
|
||||
clientHas = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!clientHas)
|
||||
{
|
||||
if (sF.visibleAnnotations == null) sF.visibleAnnotations = new ArrayList<AnnotationNode>();
|
||||
sF.visibleAnnotations.add(getSideAnn(false));
|
||||
cFields.add(x++, sF);
|
||||
info.sField.add(sF);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cF.visibleAnnotations == null) cF.visibleAnnotations = new ArrayList<AnnotationNode>();
|
||||
cF.visibleAnnotations.add(getSideAnn(true));
|
||||
sFields.add(sI, cF);
|
||||
info.cField.add(cF);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cF.visibleAnnotations == null) cF.visibleAnnotations = new ArrayList<AnnotationNode>();
|
||||
cF.visibleAnnotations.add(getSideAnn(true));
|
||||
sFields.add(sI, cF);
|
||||
info.cField.add(cF);
|
||||
}
|
||||
sI++;
|
||||
}
|
||||
if (sFields.size() != cFields.size())
|
||||
{
|
||||
for (int x = cFields.size(); x < sFields.size(); x++)
|
||||
{
|
||||
FieldNode sF = sFields.get(x);
|
||||
if (sF.visibleAnnotations == null) sF.visibleAnnotations = new ArrayList<AnnotationNode>();
|
||||
sF.visibleAnnotations.add(getSideAnn(true));
|
||||
cFields.add(x++, sF);
|
||||
info.sField.add(sF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class MethodWrapper
|
||||
{
|
||||
private MethodNode node;
|
||||
public boolean client;
|
||||
public boolean server;
|
||||
public MethodWrapper(MethodNode node)
|
||||
{
|
||||
this.node = node;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj == null || !(obj instanceof MethodWrapper)) return false;
|
||||
MethodWrapper mw = (MethodWrapper) obj;
|
||||
boolean eq = Objects.equal(node.name, mw.node.name) && Objects.equal(node.desc, mw.node.desc);
|
||||
if (eq)
|
||||
{
|
||||
mw.client = this.client | mw.client;
|
||||
mw.server = this.server | mw.server;
|
||||
this.client = this.client | mw.client;
|
||||
this.server = this.server | mw.server;
|
||||
if (DEBUG)
|
||||
{
|
||||
System.out.printf(" eq: %s %s\n", this, mw);
|
||||
}
|
||||
}
|
||||
return eq;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hashCode(node.name, node.desc);
|
||||
}
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return Objects.toStringHelper(this).add("name", node.name).add("desc",node.desc).add("server",server).add("client",client).toString();
|
||||
}
|
||||
}
|
||||
private static void processMethods(ClassNode cClass, ClassNode sClass, ClassInfo info)
|
||||
{
|
||||
List<MethodNode> cMethods = (List<MethodNode>)cClass.methods;
|
||||
List<MethodNode> sMethods = (List<MethodNode>)sClass.methods;
|
||||
LinkedHashSet<MethodWrapper> allMethods = Sets.newLinkedHashSet();
|
||||
|
||||
int cPos = 0;
|
||||
int sPos = 0;
|
||||
int cLen = cMethods.size();
|
||||
int sLen = sMethods.size();
|
||||
String clientName = "";
|
||||
String lastName = clientName;
|
||||
String serverName = "";
|
||||
while (cPos < cLen || sPos < sLen)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (sPos>=sLen)
|
||||
{
|
||||
break;
|
||||
}
|
||||
MethodNode sM = sMethods.get(sPos);
|
||||
serverName = sM.name;
|
||||
if (!serverName.equals(lastName) && cPos != cLen)
|
||||
{
|
||||
if (DEBUG)
|
||||
{
|
||||
System.out.printf("Server -skip : %s %s %d (%s %d) %d [%s]\n", sClass.name, clientName, cLen - cPos, serverName, sLen - sPos, allMethods.size(), lastName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
MethodWrapper mw = new MethodWrapper(sM);
|
||||
mw.server = true;
|
||||
allMethods.add(mw);
|
||||
if (DEBUG)
|
||||
{
|
||||
System.out.printf("Server *add* : %s %s %d (%s %d) %d [%s]\n", sClass.name, clientName, cLen - cPos, serverName, sLen - sPos, allMethods.size(), lastName);
|
||||
}
|
||||
sPos++;
|
||||
}
|
||||
while (sPos < sLen);
|
||||
do
|
||||
{
|
||||
if (cPos>=cLen)
|
||||
{
|
||||
break;
|
||||
}
|
||||
MethodNode cM = cMethods.get(cPos);
|
||||
lastName = clientName;
|
||||
clientName = cM.name;
|
||||
if (!clientName.equals(lastName) && sPos != sLen)
|
||||
{
|
||||
if (DEBUG)
|
||||
{
|
||||
System.out.printf("Client -skip : %s %s %d (%s %d) %d [%s]\n", cClass.name, clientName, cLen - cPos, serverName, sLen - sPos, allMethods.size(), lastName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
MethodWrapper mw = new MethodWrapper(cM);
|
||||
mw.client = true;
|
||||
allMethods.add(mw);
|
||||
if (DEBUG)
|
||||
{
|
||||
System.out.printf("Client *add* : %s %s %d (%s %d) %d [%s]\n", cClass.name, clientName, cLen - cPos, serverName, sLen - sPos, allMethods.size(), lastName);
|
||||
}
|
||||
cPos++;
|
||||
}
|
||||
while (cPos < cLen);
|
||||
}
|
||||
|
||||
cMethods.clear();
|
||||
sMethods.clear();
|
||||
|
||||
for (MethodWrapper mw : allMethods)
|
||||
{
|
||||
if (DEBUG)
|
||||
{
|
||||
System.out.println(mw);
|
||||
}
|
||||
cMethods.add(mw.node);
|
||||
sMethods.add(mw.node);
|
||||
if (mw.server && mw.client)
|
||||
{
|
||||
// no op
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mw.node.visibleAnnotations == null) mw.node.visibleAnnotations = Lists.newArrayListWithExpectedSize(1);
|
||||
mw.node.visibleAnnotations.add(getSideAnn(mw.client));
|
||||
if (mw.client)
|
||||
{
|
||||
info.sMethods.add(mw.node);
|
||||
}
|
||||
else
|
||||
{
|
||||
info.cMethods.add(mw.node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] getClassBytes(String name) throws IOException
|
||||
{
|
||||
InputStream classStream = null;
|
||||
try
|
||||
{
|
||||
classStream = MCPMerger.class.getResourceAsStream("/" + name.replace('.', '/').concat(".class"));
|
||||
return readFully(classStream);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (classStream != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
classStream.close();
|
||||
}
|
||||
catch (IOException e){}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +1,15 @@
|
|||
package cpw.mods.fml.common.asm.transformers;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
|
@ -18,16 +17,12 @@ import com.google.common.collect.ArrayListMultimap;
|
|||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModAPIManager;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.discovery.ASMDataTable;
|
||||
import cpw.mods.fml.common.discovery.ASMDataTable.ASMData;
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
public class ModAPITransformer implements IClassTransformer {
|
||||
|
||||
private static final boolean logDebugInfo = Boolean.valueOf(System.getProperty("fml.debugAPITransformer", "true"));
|
||||
|
@ -133,6 +128,7 @@ public class ModAPITransformer implements IClassTransformer {
|
|||
Set<ASMData> result = Sets.newHashSet();
|
||||
for (ASMData data : packedInterfaces)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Map<String,Object>> packedList = (List<Map<String,Object>>) data.getAnnotationInfo().get("value");
|
||||
for (Map<String,Object> packed : packedList)
|
||||
{
|
||||
|
|
|
@ -17,46 +17,39 @@ import java.io.FileInputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.commons.Remapper;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldNode;
|
||||
|
||||
import com.google.common.base.CharMatcher;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import com.google.common.collect.ImmutableBiMap.Builder;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.collect.ImmutableBiMap.Builder;
|
||||
import com.google.common.io.CharStreams;
|
||||
import com.google.common.io.InputSupplier;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.patcher.ClassPatchManager;
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldNode;
|
||||
|
||||
public class FMLDeobfuscatingRemapper extends Remapper {
|
||||
public static final FMLDeobfuscatingRemapper INSTANCE = new FMLDeobfuscatingRemapper();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
@ -13,7 +13,6 @@
|
|||
package cpw.mods.fml.common.asm.transformers.deobf;
|
||||
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.commons.Remapper;
|
||||
import org.objectweb.asm.commons.RemappingClassAdapter;
|
||||
|
||||
public class FMLRemappingAdapter extends RemappingClassAdapter {
|
||||
|
|
|
@ -14,8 +14,6 @@ package cpw.mods.fml.common.asm.transformers.deobf;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import LZMA.LzmaInputStream;
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSetMultimap;
|
||||
|
|
|
@ -19,8 +19,6 @@ import java.util.logging.Level;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
|
@ -29,7 +27,6 @@ import cpw.mods.fml.common.FMLLog;
|
|||
import cpw.mods.fml.common.LoaderException;
|
||||
import cpw.mods.fml.common.ModClassLoader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.asm.transformers.ModAPITransformer;
|
||||
import cpw.mods.fml.relauncher.CoreModManager;
|
||||
|
||||
public class ModDiscoverer
|
||||
|
|
|
@ -19,8 +19,6 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.src.BaseMod;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
|
|
|
@ -27,8 +27,9 @@ public class ModAnnotation
|
|||
{
|
||||
public class EnumHolder
|
||||
{
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private String desc;
|
||||
@SuppressWarnings("unused")
|
||||
private String value;
|
||||
|
||||
public EnumHolder(String desc, String value)
|
||||
|
@ -43,9 +44,7 @@ public class ModAnnotation
|
|||
String member;
|
||||
Map<String,Object> values = Maps.newHashMap();
|
||||
private ArrayList<Object> arrayList;
|
||||
private Object array;
|
||||
private String arrayName;
|
||||
private ModAnnotation parent;
|
||||
public ModAnnotation(AnnotationType type, Type asmType, String member)
|
||||
{
|
||||
this.type = type;
|
||||
|
@ -57,7 +56,6 @@ public class ModAnnotation
|
|||
{
|
||||
this.type = type;
|
||||
this.asmType = asmType;
|
||||
this.parent = parent;
|
||||
}
|
||||
@Override
|
||||
public String toString()
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
@ -19,6 +19,7 @@ public class ModAnnotationVisitor extends AnnotationVisitor
|
|||
{
|
||||
private ASMModParser discoverer;
|
||||
private boolean array;
|
||||
@SuppressWarnings("unused")
|
||||
private String name;
|
||||
private boolean isSubAnnotation;
|
||||
|
||||
|
@ -27,7 +28,7 @@ public class ModAnnotationVisitor extends AnnotationVisitor
|
|||
super(Opcodes.ASM4);
|
||||
this.discoverer = discoverer;
|
||||
}
|
||||
|
||||
|
||||
public ModAnnotationVisitor(ASMModParser discoverer, String name)
|
||||
{
|
||||
this(discoverer);
|
||||
|
@ -47,13 +48,13 @@ public class ModAnnotationVisitor extends AnnotationVisitor
|
|||
{
|
||||
discoverer.addAnnotationProperty(key, value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void visitEnum(String name, String desc, String value)
|
||||
{
|
||||
discoverer.addAnnotationEnumProperty(name, desc, value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitArray(String name)
|
||||
{
|
||||
|
@ -72,7 +73,7 @@ public class ModAnnotationVisitor extends AnnotationVisitor
|
|||
{
|
||||
discoverer.endArray();
|
||||
}
|
||||
|
||||
|
||||
if (isSubAnnotation)
|
||||
{
|
||||
discoverer.endSubAnnotation();
|
||||
|
|
|
@ -12,14 +12,11 @@
|
|||
|
||||
package cpw.mods.fml.common.discovery.asm;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.objectweb.asm.AnnotationVisitor;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.FieldVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
public class ModClassVisitor extends ClassVisitor
|
||||
{
|
||||
|
@ -55,13 +52,6 @@ public class ModClassVisitor extends ClassVisitor
|
|||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions)
|
||||
{
|
||||
if (discoverer.isBaseMod(Collections.<String>emptyList()) && name.equals("getPriorities") && desc.equals(Type.getMethodDescriptor(Type.getType(String.class))))
|
||||
{
|
||||
return new ModLoaderPropertiesMethodVisitor(name, discoverer);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ModMethodVisitor(name, desc, discoverer);
|
||||
}
|
||||
return new ModMethodVisitor(name, desc, discoverer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.discovery.asm;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.objectweb.asm.Label;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class ModLoaderPropertiesMethodVisitor extends MethodVisitor
|
||||
{
|
||||
|
||||
private ASMModParser discoverer;
|
||||
private boolean inCode;
|
||||
private LinkedList<Label> labels = Lists.newLinkedList();
|
||||
private String foundProperties;
|
||||
private boolean validProperties;
|
||||
|
||||
public ModLoaderPropertiesMethodVisitor(String name, ASMModParser discoverer)
|
||||
{
|
||||
super(Opcodes.ASM4);
|
||||
this.discoverer = discoverer;
|
||||
}
|
||||
@Override
|
||||
public void visitCode()
|
||||
{
|
||||
labels.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLdcInsn(Object cst)
|
||||
{
|
||||
if (cst instanceof String && labels.size() == 1)
|
||||
{
|
||||
foundProperties = (String) cst;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void visitInsn(int opcode)
|
||||
{
|
||||
if (Opcodes.ARETURN == opcode && labels.size() == 1 && foundProperties != null)
|
||||
{
|
||||
validProperties = true;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void visitLabel(Label label)
|
||||
{
|
||||
labels.push(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitEnd()
|
||||
{
|
||||
if (validProperties)
|
||||
{
|
||||
discoverer.setBaseModProperties(foundProperties);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
@ -13,7 +13,6 @@
|
|||
package cpw.mods.fml.common.event;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
|
|
@ -12,21 +12,11 @@
|
|||
|
||||
package cpw.mods.fml.common.event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Functions;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableListMultimap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimaps;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
@ -34,8 +24,6 @@ import cpw.mods.fml.common.Loader;
|
|||
import cpw.mods.fml.common.LoaderState;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.Mod.Init;
|
||||
import cpw.mods.fml.common.Mod.PostInit;
|
||||
|
||||
/**
|
||||
* Simple intermod communications to receive simple messages directed at you
|
||||
|
|
|
@ -5,14 +5,13 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.event;
|
||||
|
||||
import cpw.mods.fml.common.LoaderState;
|
||||
import cpw.mods.fml.common.LoaderState.ModState;
|
||||
|
||||
public class FMLServerStoppedEvent extends FMLStateEvent {
|
||||
|
|
|
@ -3,42 +3,35 @@ package cpw.mods.fml.common.launcher;
|
|||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import joptsimple.ArgumentAcceptingOptionSpec;
|
||||
import joptsimple.NonOptionArgumentSpec;
|
||||
import joptsimple.OptionParser;
|
||||
import joptsimple.OptionSet;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.ObjectArrays;
|
||||
import com.google.common.primitives.Ints;
|
||||
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
|
||||
import net.minecraft.launchwrapper.ITweaker;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
|
||||
public class FMLTweaker implements ITweaker {
|
||||
@SuppressWarnings("unused")
|
||||
private List<String> args;
|
||||
private File gameDir;
|
||||
@SuppressWarnings("unused")
|
||||
private File assetsDir;
|
||||
@SuppressWarnings("unused")
|
||||
private String profile;
|
||||
private File gameDir;
|
||||
private Map<String, String> launchArgs;
|
||||
private List<String> standaloneArgs;
|
||||
private static URI jarLocation;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile)
|
||||
{
|
||||
|
@ -159,6 +152,7 @@ public class FMLTweaker implements ITweaker {
|
|||
|
||||
public void injectCascadingTweak(String tweakClassName)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> tweakClasses = (List<String>) Launch.blackboard.get("TweakClasses");
|
||||
tweakClasses.add(tweakClassName);
|
||||
}
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.NetServerHandler;
|
||||
import net.minecraft.network.packet.NetHandler;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
*
|
||||
* Marker interface for BaseMod
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public interface BaseModProxy
|
||||
{
|
||||
void modsLoaded();
|
||||
|
||||
void load();
|
||||
|
||||
String getName();
|
||||
|
||||
String getPriorities();
|
||||
|
||||
String getVersion();
|
||||
|
||||
boolean doTickInGUI(TickType type, boolean end, Object... tickData);
|
||||
boolean doTickInGame(TickType type, boolean end, Object... tickData);
|
||||
void generateSurface(World w, Random random, int i, int j);
|
||||
void generateNether(World w, Random random, int i, int j);
|
||||
int addFuel(int itemId, int damage);
|
||||
void takenFromCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix);
|
||||
void takenFromFurnace(EntityPlayer player, ItemStack item);
|
||||
|
||||
public abstract void onClientLogout(INetworkManager manager);
|
||||
|
||||
public abstract void onClientLogin(EntityPlayer player);
|
||||
|
||||
public abstract void serverDisconnect();
|
||||
|
||||
public abstract void serverConnect(NetHandler handler);
|
||||
|
||||
public abstract void receiveCustomPacket(Packet250CustomPayload packet);
|
||||
|
||||
public abstract void clientChat(String text);
|
||||
|
||||
public abstract void onItemPickup(EntityPlayer player, ItemStack item);
|
||||
|
||||
public abstract void serverCustomPayload(NetServerHandler handler, Packet250CustomPayload packet);
|
||||
|
||||
public abstract void serverChat(NetServerHandler source, String message);
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class BaseModTicker implements ITickHandler
|
||||
{
|
||||
|
||||
private BaseModProxy mod;
|
||||
private EnumSet<TickType> ticks;
|
||||
private boolean clockTickTrigger;
|
||||
private boolean sendGuiTicks;
|
||||
|
||||
|
||||
BaseModTicker(BaseModProxy mod, boolean guiTicker)
|
||||
{
|
||||
this.mod = mod;
|
||||
this.ticks = EnumSet.of(TickType.WORLDLOAD);
|
||||
this.sendGuiTicks = guiTicker;
|
||||
}
|
||||
|
||||
BaseModTicker(EnumSet<TickType> ticks, boolean guiTicker)
|
||||
{
|
||||
this.ticks = ticks;
|
||||
this.sendGuiTicks = guiTicker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> types, Object... tickData)
|
||||
{
|
||||
tickBaseMod(types, false, tickData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickEnd(EnumSet<TickType> types, Object... tickData)
|
||||
{
|
||||
tickBaseMod(types, true, tickData);
|
||||
}
|
||||
|
||||
private void tickBaseMod(EnumSet<TickType> types, boolean end, Object... tickData)
|
||||
{
|
||||
if (FMLCommonHandler.instance().getSide().isClient() && ( ticks.contains(TickType.CLIENT) || ticks.contains(TickType.WORLDLOAD)))
|
||||
{
|
||||
EnumSet cTypes=EnumSet.copyOf(types);
|
||||
if ( ( end && types.contains(TickType.CLIENT)) || types.contains(TickType.WORLDLOAD))
|
||||
{
|
||||
clockTickTrigger = true;
|
||||
cTypes.remove(TickType.CLIENT);
|
||||
cTypes.remove(TickType.WORLDLOAD);
|
||||
}
|
||||
|
||||
if (end && clockTickTrigger && types.contains(TickType.RENDER))
|
||||
{
|
||||
clockTickTrigger = false;
|
||||
cTypes.remove(TickType.RENDER);
|
||||
cTypes.add(TickType.CLIENT);
|
||||
}
|
||||
|
||||
sendTick(cTypes, end, tickData);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendTick(types, end, tickData);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendTick(EnumSet<TickType> types, boolean end, Object... tickData)
|
||||
{
|
||||
for (TickType type : types)
|
||||
{
|
||||
if (!ticks.contains(type))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean keepTicking=true;
|
||||
if (sendGuiTicks)
|
||||
{
|
||||
keepTicking = mod.doTickInGUI(type, end, tickData);
|
||||
}
|
||||
else
|
||||
{
|
||||
keepTicking = mod.doTickInGame(type, end, tickData);
|
||||
}
|
||||
if (!keepTicking) {
|
||||
ticks.remove(type);
|
||||
ticks.removeAll(type.partnerTicks());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks()
|
||||
{
|
||||
return (clockTickTrigger ? EnumSet.of(TickType.RENDER) : ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel()
|
||||
{
|
||||
return mod.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public void setMod(BaseModProxy mod)
|
||||
{
|
||||
this.mod = mod;
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.NetHandler;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import cpw.mods.fml.common.network.EntitySpawnPacket;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration;
|
||||
|
||||
public interface IModLoaderSidedHelper
|
||||
{
|
||||
|
||||
void finishModLoading(ModLoaderModContainer mc);
|
||||
|
||||
Object getClientGui(BaseModProxy mod, EntityPlayer player, int iD, int x, int y, int z);
|
||||
|
||||
Entity spawnEntity(BaseModProxy mod, EntitySpawnPacket input, EntityRegistration registration);
|
||||
|
||||
void sendClientPacket(BaseModProxy mod, Packet250CustomPayload packet);
|
||||
|
||||
void clientConnectionOpened(NetHandler netClientHandler, INetworkManager manager, BaseModProxy mod);
|
||||
|
||||
boolean clientConnectionClosed(INetworkManager manager, BaseModProxy mod);
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import net.minecraft.network.NetServerHandler;
|
||||
import net.minecraft.network.packet.*;
|
||||
import cpw.mods.fml.common.network.IChatListener;
|
||||
|
||||
public class ModLoaderChatListener implements IChatListener
|
||||
{
|
||||
|
||||
private BaseModProxy mod;
|
||||
|
||||
public ModLoaderChatListener(BaseModProxy mod)
|
||||
{
|
||||
this.mod = mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet3Chat serverChat(NetHandler handler, Packet3Chat message)
|
||||
{
|
||||
mod.serverChat((NetServerHandler)handler, message.field_73476_b);
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet3Chat clientChat(NetHandler handler, Packet3Chat message)
|
||||
{
|
||||
mod.clientChat(message.field_73476_b);
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.NetLoginHandler;
|
||||
import net.minecraft.network.packet.NetHandler;
|
||||
import net.minecraft.network.packet.Packet1Login;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import cpw.mods.fml.common.network.IConnectionHandler;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
|
||||
public class ModLoaderConnectionHandler implements IConnectionHandler
|
||||
{
|
||||
private BaseModProxy mod;
|
||||
|
||||
public ModLoaderConnectionHandler(BaseModProxy mod)
|
||||
{
|
||||
this.mod = mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager)
|
||||
{
|
||||
mod.onClientLogin((EntityPlayer)player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager)
|
||||
{
|
||||
ModLoaderHelper.sidedHelper.clientConnectionOpened(netClientHandler, manager, mod);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionClosed(INetworkManager manager)
|
||||
{
|
||||
if (ModLoaderHelper.sidedHelper==null || !ModLoaderHelper.sidedHelper.clientConnectionClosed(manager, mod))
|
||||
{
|
||||
mod.serverDisconnect();
|
||||
mod.onClientLogout(manager);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientLoggedIn(NetHandler nh, INetworkManager manager, Packet1Login login)
|
||||
{
|
||||
mod.serverConnect(nh);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionOpened(NetHandler netClientHandler, MinecraftServer server, INetworkManager manager)
|
||||
{
|
||||
ModLoaderHelper.sidedHelper.clientConnectionOpened(netClientHandler, manager, mod);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
|
||||
public class ModLoaderCraftingHelper implements ICraftingHandler
|
||||
{
|
||||
|
||||
private BaseModProxy mod;
|
||||
|
||||
public ModLoaderCraftingHelper(BaseModProxy mod)
|
||||
{
|
||||
this.mod = mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix)
|
||||
{
|
||||
mod.takenFromCrafting(player, item, craftMatrix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSmelting(EntityPlayer player, ItemStack item)
|
||||
{
|
||||
mod.takenFromFurnace(player, item);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.network.EntitySpawnPacket;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration;
|
||||
|
||||
public class ModLoaderEntitySpawnCallback implements Function<EntitySpawnPacket, Entity>
|
||||
{
|
||||
|
||||
private BaseModProxy mod;
|
||||
private EntityRegistration registration;
|
||||
private boolean isAnimal;
|
||||
|
||||
public ModLoaderEntitySpawnCallback(BaseModProxy mod, EntityRegistration er)
|
||||
{
|
||||
this.mod = mod;
|
||||
this.registration = er;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity apply(EntitySpawnPacket input)
|
||||
{
|
||||
return ModLoaderHelper.sidedHelper.spawnEntity(mod, input, registration);
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.IFuelHandler;
|
||||
|
||||
public class ModLoaderFuelHelper implements IFuelHandler
|
||||
{
|
||||
|
||||
private BaseModProxy mod;
|
||||
|
||||
public ModLoaderFuelHelper(BaseModProxy mod)
|
||||
{
|
||||
this.mod = mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBurnTime(ItemStack fuel)
|
||||
{
|
||||
return mod.addFuel(fuel.field_77993_c, fuel.func_77960_j());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
||||
public class ModLoaderGuiHelper implements IGuiHandler
|
||||
{
|
||||
|
||||
private BaseModProxy mod;
|
||||
private Set<Integer> ids;
|
||||
private Container container;
|
||||
private int currentID;
|
||||
|
||||
ModLoaderGuiHelper(BaseModProxy mod)
|
||||
{
|
||||
this.mod = mod;
|
||||
this.ids = Sets.newHashSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
return container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
return ModLoaderHelper.getClientSideGui(mod, player, ID, x, y, z);
|
||||
}
|
||||
|
||||
public void injectContainerAndID(Container container, int ID)
|
||||
{
|
||||
this.container = container;
|
||||
this.currentID = ID;
|
||||
}
|
||||
|
||||
public Object getMod()
|
||||
{
|
||||
return mod;
|
||||
}
|
||||
|
||||
public void associateId(int additionalID)
|
||||
{
|
||||
this.ids.add(additionalID);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,224 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.passive.IAnimals;
|
||||
import net.minecraft.entity.boss.EntityDragon;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.src.BaseMod;
|
||||
import net.minecraft.src.TradeEntry;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
import cpw.mods.fml.common.IFuelHandler;
|
||||
import cpw.mods.fml.common.IPickupNotifier;
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.common.network.IChatListener;
|
||||
import cpw.mods.fml.common.network.IConnectionHandler;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration;
|
||||
import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler;
|
||||
import cpw.mods.fml.common.registry.VillagerRegistry;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ModLoaderHelper
|
||||
{
|
||||
public static IModLoaderSidedHelper sidedHelper;
|
||||
|
||||
private static Map<BaseModProxy, ModLoaderGuiHelper> guiHelpers = Maps.newHashMap();
|
||||
private static Map<Integer, ModLoaderGuiHelper> guiIDs = Maps.newHashMap();
|
||||
|
||||
public static void updateStandardTicks(BaseModProxy mod, boolean enable, boolean useClock)
|
||||
{
|
||||
ModLoaderModContainer mlmc = (ModLoaderModContainer) Loader.instance().getReversedModObjectList().get(mod);
|
||||
if (mlmc==null)
|
||||
{
|
||||
mlmc = (ModLoaderModContainer) Loader.instance().activeModContainer();
|
||||
}
|
||||
if (mlmc == null)
|
||||
{
|
||||
FMLLog.severe("Attempted to register ModLoader ticking for invalid BaseMod %s",mod);
|
||||
return;
|
||||
}
|
||||
BaseModTicker ticker = mlmc.getGameTickHandler();
|
||||
EnumSet<TickType> ticks = ticker.ticks();
|
||||
// If we're enabled we get render ticks
|
||||
if (enable && !useClock) {
|
||||
ticks.add(TickType.RENDER);
|
||||
} else {
|
||||
ticks.remove(TickType.RENDER);
|
||||
}
|
||||
// If we're enabled but we want clock ticks, or we're server side we get game ticks
|
||||
if (enable && (useClock || FMLCommonHandler.instance().getSide().isServer())) {
|
||||
ticks.add(TickType.CLIENT);
|
||||
ticks.add(TickType.WORLDLOAD);
|
||||
} else {
|
||||
ticks.remove(TickType.CLIENT);
|
||||
ticks.remove(TickType.WORLDLOAD);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateGUITicks(BaseModProxy mod, boolean enable, boolean useClock)
|
||||
{
|
||||
ModLoaderModContainer mlmc = (ModLoaderModContainer) Loader.instance().getReversedModObjectList().get(mod);
|
||||
if (mlmc==null)
|
||||
{
|
||||
mlmc = (ModLoaderModContainer) Loader.instance().activeModContainer();
|
||||
}
|
||||
if (mlmc == null)
|
||||
{
|
||||
FMLLog.severe("Attempted to register ModLoader ticking for invalid BaseMod %s",mod);
|
||||
return;
|
||||
}
|
||||
EnumSet<TickType> ticks = mlmc.getGUITickHandler().ticks();
|
||||
// If we're enabled and we don't want clock ticks we get render ticks
|
||||
if (enable && !useClock) {
|
||||
ticks.add(TickType.RENDER);
|
||||
} else {
|
||||
ticks.remove(TickType.RENDER);
|
||||
}
|
||||
// If we're enabled but we want clock ticks, or we're server side we get world ticks
|
||||
if (enable && useClock) {
|
||||
ticks.add(TickType.CLIENT);
|
||||
ticks.add(TickType.WORLDLOAD);
|
||||
} else {
|
||||
ticks.remove(TickType.CLIENT);
|
||||
ticks.remove(TickType.WORLDLOAD);
|
||||
}
|
||||
}
|
||||
|
||||
public static IPacketHandler buildPacketHandlerFor(BaseModProxy mod)
|
||||
{
|
||||
return new ModLoaderPacketHandler(mod);
|
||||
}
|
||||
|
||||
public static IWorldGenerator buildWorldGenHelper(BaseModProxy mod)
|
||||
{
|
||||
return new ModLoaderWorldGenerator(mod);
|
||||
}
|
||||
|
||||
public static IFuelHandler buildFuelHelper(BaseModProxy mod)
|
||||
{
|
||||
return new ModLoaderFuelHelper(mod);
|
||||
}
|
||||
|
||||
public static ICraftingHandler buildCraftingHelper(BaseModProxy mod)
|
||||
{
|
||||
return new ModLoaderCraftingHelper(mod);
|
||||
}
|
||||
|
||||
public static void finishModLoading(ModLoaderModContainer mc)
|
||||
{
|
||||
if (sidedHelper != null)
|
||||
{
|
||||
sidedHelper.finishModLoading(mc);
|
||||
}
|
||||
}
|
||||
|
||||
public static IConnectionHandler buildConnectionHelper(BaseModProxy mod)
|
||||
{
|
||||
return new ModLoaderConnectionHandler(mod);
|
||||
}
|
||||
|
||||
public static IPickupNotifier buildPickupHelper(BaseModProxy mod)
|
||||
{
|
||||
return new ModLoaderPickupNotifier(mod);
|
||||
}
|
||||
|
||||
public static void buildGuiHelper(BaseModProxy mod, int id)
|
||||
{
|
||||
ModLoaderGuiHelper handler = guiHelpers.get(mod);
|
||||
if (handler == null)
|
||||
{
|
||||
handler = new ModLoaderGuiHelper(mod);
|
||||
guiHelpers.put(mod,handler);
|
||||
NetworkRegistry.instance().registerGuiHandler(mod, handler);
|
||||
}
|
||||
handler.associateId(id);
|
||||
guiIDs.put(id, handler);
|
||||
}
|
||||
|
||||
public static void openGui(int id, EntityPlayer player, Container container, int x, int y, int z)
|
||||
{
|
||||
ModLoaderGuiHelper helper = guiIDs.get(id);
|
||||
helper.injectContainerAndID(container, id);
|
||||
player.openGui(helper.getMod(), id, player.field_70170_p, x, y, z);
|
||||
}
|
||||
|
||||
public static Object getClientSideGui(BaseModProxy mod, EntityPlayer player, int ID, int x, int y, int z)
|
||||
{
|
||||
if (sidedHelper != null)
|
||||
{
|
||||
return sidedHelper.getClientGui(mod, player, ID, x, y, z);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void buildEntityTracker(BaseModProxy mod, Class<? extends Entity> entityClass, int entityTypeId, int updateRange, int updateInterval,
|
||||
boolean sendVelocityInfo)
|
||||
{
|
||||
EntityRegistration er = EntityRegistry.registerModLoaderEntity(mod, entityClass, entityTypeId, updateRange, updateInterval, sendVelocityInfo);
|
||||
er.setCustomSpawning(new ModLoaderEntitySpawnCallback(mod, er), EntityDragon.class.isAssignableFrom(entityClass) || IAnimals.class.isAssignableFrom(entityClass));
|
||||
}
|
||||
|
||||
private static ModLoaderVillageTradeHandler[] tradeHelpers = new ModLoaderVillageTradeHandler[6];
|
||||
|
||||
public static void registerTrade(int profession, TradeEntry entry)
|
||||
{
|
||||
assert profession < tradeHelpers.length : "The profession is out of bounds";
|
||||
if (tradeHelpers[profession] == null)
|
||||
{
|
||||
tradeHelpers[profession] = new ModLoaderVillageTradeHandler();
|
||||
VillagerRegistry.instance().registerVillageTradeHandler(profession, tradeHelpers[profession]);
|
||||
}
|
||||
|
||||
tradeHelpers[profession].addTrade(entry);
|
||||
}
|
||||
|
||||
public static void addCommand(ICommand command)
|
||||
{
|
||||
ModLoaderModContainer mlmc = (ModLoaderModContainer) Loader.instance().activeModContainer();
|
||||
if (mlmc!=null)
|
||||
{
|
||||
mlmc.addServerCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
public static IChatListener buildChatListener(BaseModProxy mod)
|
||||
{
|
||||
return new ModLoaderChatListener(mod);
|
||||
}
|
||||
}
|
|
@ -1,644 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.security.cert.Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.command.ICommand;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.ILanguageAdapter;
|
||||
import cpw.mods.fml.common.LoadController;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.LoaderException;
|
||||
import cpw.mods.fml.common.MetadataCollection;
|
||||
import cpw.mods.fml.common.ModClassLoader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.ModMetadata;
|
||||
import cpw.mods.fml.common.ProxyInjector;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.common.discovery.ASMDataTable;
|
||||
import cpw.mods.fml.common.discovery.ASMDataTable.ASMData;
|
||||
import cpw.mods.fml.common.discovery.ContainerType;
|
||||
import cpw.mods.fml.common.event.FMLConstructionEvent;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||
import cpw.mods.fml.common.network.FMLNetworkHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.TickRegistry;
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.VersionRange;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class ModLoaderModContainer implements ModContainer
|
||||
{
|
||||
public BaseModProxy mod;
|
||||
private File modSource;
|
||||
public Set<ArtifactVersion> requirements = Sets.newHashSet();
|
||||
public ArrayList<ArtifactVersion> dependencies = Lists.newArrayList();
|
||||
public ArrayList<ArtifactVersion> dependants = Lists.newArrayList();
|
||||
private ContainerType sourceType;
|
||||
private ModMetadata metadata;
|
||||
private ProxyInjector sidedProxy;
|
||||
private BaseModTicker gameTickHandler;
|
||||
private BaseModTicker guiTickHandler;
|
||||
private String modClazzName;
|
||||
private String modId;
|
||||
private EventBus bus;
|
||||
private LoadController controller;
|
||||
private boolean enabled = true;
|
||||
private String sortingProperties;
|
||||
private ArtifactVersion processedVersion;
|
||||
private boolean isNetworkMod;
|
||||
private List<ICommand> serverCommands = Lists.newArrayList();
|
||||
|
||||
public ModLoaderModContainer(String className, File modSource, String sortingProperties)
|
||||
{
|
||||
this.modClazzName = className;
|
||||
this.modSource = modSource;
|
||||
this.modId = className.contains(".") ? className.substring(className.lastIndexOf('.')+1) : className;
|
||||
this.sortingProperties = Strings.isNullOrEmpty(sortingProperties) ? "" : sortingProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* We only instantiate this for "not mod mods"
|
||||
* @param instance
|
||||
*/
|
||||
ModLoaderModContainer(BaseModProxy instance) {
|
||||
this.mod=instance;
|
||||
this.gameTickHandler = new BaseModTicker(instance, false);
|
||||
this.guiTickHandler = new BaseModTicker(instance, true);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void configureMod(Class<? extends BaseModProxy> modClazz, ASMDataTable asmData)
|
||||
{
|
||||
File configDir = Loader.instance().getConfigDir();
|
||||
File modConfig = new File(configDir, String.format("%s.cfg", getModId()));
|
||||
Properties props = new Properties();
|
||||
|
||||
boolean existingConfigFound = false;
|
||||
boolean mlPropFound = false;
|
||||
|
||||
if (modConfig.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
FMLLog.fine("Reading existing configuration file for %s : %s", getModId(), modConfig.getName());
|
||||
FileReader configReader = new FileReader(modConfig);
|
||||
props.load(configReader);
|
||||
configReader.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log(Level.SEVERE, e, "Error occured reading mod configuration file %s", modConfig.getName());
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
existingConfigFound = true;
|
||||
}
|
||||
|
||||
StringBuffer comments = new StringBuffer();
|
||||
comments.append("MLProperties: name (type:default) min:max -- information\n");
|
||||
|
||||
|
||||
List<ModProperty> mlPropFields = Lists.newArrayList();
|
||||
try
|
||||
{
|
||||
for (ASMData dat : Sets.union(asmData.getAnnotationsFor(this).get("net.minecraft.src.MLProp"), asmData.getAnnotationsFor(this).get("MLProp")))
|
||||
{
|
||||
if (dat.getClassName().equals(modClazzName))
|
||||
{
|
||||
try
|
||||
{
|
||||
mlPropFields.add(new ModProperty(modClazz.getDeclaredField(dat.getObjectName()), dat.getAnnotationInfo()));
|
||||
FMLLog.finest("Found an MLProp field %s in %s", dat.getObjectName(), getModId());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log(Level.WARNING, e, "An error occured trying to access field %s in mod %s", dat.getObjectName(), getModId());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ModProperty property : mlPropFields)
|
||||
{
|
||||
if (!Modifier.isStatic(property.field().getModifiers()))
|
||||
{
|
||||
FMLLog.info("The MLProp field %s in mod %s appears not to be static", property.field().getName(), getModId());
|
||||
continue;
|
||||
}
|
||||
FMLLog.finest("Considering MLProp field %s", property.field().getName());
|
||||
Field f = property.field();
|
||||
String propertyName = !Strings.nullToEmpty(property.name()).isEmpty() ? property.name() : f.getName();
|
||||
String propertyValue = null;
|
||||
Object defaultValue = null;
|
||||
|
||||
try
|
||||
{
|
||||
defaultValue = f.get(null);
|
||||
propertyValue = props.getProperty(propertyName, extractValue(defaultValue));
|
||||
Object currentValue = parseValue(propertyValue, property, f.getType(), propertyName);
|
||||
FMLLog.finest("Configuration for %s.%s found values default: %s, configured: %s, interpreted: %s", modClazzName, propertyName, defaultValue, propertyValue, currentValue);
|
||||
|
||||
if (currentValue != null && !currentValue.equals(defaultValue))
|
||||
{
|
||||
FMLLog.finest("Configuration for %s.%s value set to: %s", modClazzName, propertyName, currentValue);
|
||||
f.set(null, currentValue);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log(Level.SEVERE, e, "Invalid configuration found for %s in %s", propertyName, modConfig.getName());
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
comments.append(String.format("MLProp : %s (%s:%s", propertyName, f.getType().getName(), defaultValue));
|
||||
|
||||
if (property.min() != Double.MIN_VALUE)
|
||||
{
|
||||
comments.append(",>=").append(String.format("%.1f", property.min()));
|
||||
}
|
||||
|
||||
if (property.max() != Double.MAX_VALUE)
|
||||
{
|
||||
comments.append(",<=").append(String.format("%.1f", property.max()));
|
||||
}
|
||||
|
||||
comments.append(")");
|
||||
|
||||
if (!Strings.nullToEmpty(property.info()).isEmpty())
|
||||
{
|
||||
comments.append(" -- ").append(property.info());
|
||||
}
|
||||
|
||||
if (propertyValue != null)
|
||||
{
|
||||
props.setProperty(propertyName, extractValue(propertyValue));
|
||||
}
|
||||
comments.append("\n");
|
||||
}
|
||||
mlPropFound = true;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!mlPropFound && !existingConfigFound)
|
||||
{
|
||||
FMLLog.fine("No MLProp configuration for %s found or required. No file written", getModId());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mlPropFound && existingConfigFound)
|
||||
{
|
||||
File mlPropBackup = new File(modConfig.getParent(),modConfig.getName()+".bak");
|
||||
FMLLog.fine("MLProp configuration file for %s found but not required. Attempting to rename file to %s", getModId(), mlPropBackup.getName());
|
||||
boolean renamed = modConfig.renameTo(mlPropBackup);
|
||||
if (renamed)
|
||||
{
|
||||
FMLLog.fine("Unused MLProp configuration file for %s renamed successfully to %s", getModId(), mlPropBackup.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLLog.fine("Unused MLProp configuration file for %s renamed UNSUCCESSFULLY to %s", getModId(), mlPropBackup.getName());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
FileWriter configWriter = new FileWriter(modConfig);
|
||||
props.store(configWriter, comments.toString());
|
||||
configWriter.close();
|
||||
FMLLog.fine("Configuration for %s written to %s", getModId(), modConfig.getName());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLLog.log(Level.SEVERE, e, "Error trying to write the config file %s", modConfig.getName());
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Object parseValue(String val, ModProperty property, Class<?> type, String propertyName)
|
||||
{
|
||||
if (type.isAssignableFrom(String.class))
|
||||
{
|
||||
return (String)val;
|
||||
}
|
||||
else if (type.isAssignableFrom(Boolean.TYPE) || type.isAssignableFrom(Boolean.class))
|
||||
{
|
||||
return Boolean.parseBoolean(val);
|
||||
}
|
||||
else if (Number.class.isAssignableFrom(type) || type.isPrimitive())
|
||||
{
|
||||
Number n = null;
|
||||
|
||||
if (type.isAssignableFrom(Double.TYPE) || Double.class.isAssignableFrom(type))
|
||||
{
|
||||
n = Double.parseDouble(val);
|
||||
}
|
||||
else if (type.isAssignableFrom(Float.TYPE) || Float.class.isAssignableFrom(type))
|
||||
{
|
||||
n = Float.parseFloat(val);
|
||||
}
|
||||
else if (type.isAssignableFrom(Long.TYPE) || Long.class.isAssignableFrom(type))
|
||||
{
|
||||
n = Long.parseLong(val);
|
||||
}
|
||||
else if (type.isAssignableFrom(Integer.TYPE) || Integer.class.isAssignableFrom(type))
|
||||
{
|
||||
n = Integer.parseInt(val);
|
||||
}
|
||||
else if (type.isAssignableFrom(Short.TYPE) || Short.class.isAssignableFrom(type))
|
||||
{
|
||||
n = Short.parseShort(val);
|
||||
}
|
||||
else if (type.isAssignableFrom(Byte.TYPE) || Byte.class.isAssignableFrom(type))
|
||||
{
|
||||
n = Byte.parseByte(val);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException(String.format("MLProp declared on %s of type %s, an unsupported type",propertyName, type.getName()));
|
||||
}
|
||||
|
||||
double dVal = n.doubleValue();
|
||||
if ((property.min()!=Double.MIN_VALUE && dVal < property.min()) || (property.max()!=Double.MAX_VALUE && dVal > property.max()))
|
||||
{
|
||||
FMLLog.warning("Configuration for %s.%s found value %s outside acceptable range %s,%s", modClazzName,propertyName, n, property.min(), property.max());
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(String.format("MLProp declared on %s of type %s, an unsupported type",propertyName, type.getName()));
|
||||
}
|
||||
private String extractValue(Object value)
|
||||
{
|
||||
if (String.class.isInstance(value))
|
||||
{
|
||||
return (String)value;
|
||||
}
|
||||
else if (Number.class.isInstance(value) || Boolean.class.isInstance(value))
|
||||
{
|
||||
return String.valueOf(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("MLProp declared on non-standard type");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return mod != null ? mod.getName() : modId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSortingRules()
|
||||
{
|
||||
return sortingProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object mod)
|
||||
{
|
||||
return this.mod == mod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all the BaseMods in the system
|
||||
* @param <A>
|
||||
*/
|
||||
public static <A extends BaseModProxy> List<A> findAll(Class<A> clazz)
|
||||
{
|
||||
ArrayList<A> modList = new ArrayList<A>();
|
||||
|
||||
for (ModContainer mc : Loader.instance().getActiveModList())
|
||||
{
|
||||
if (mc instanceof ModLoaderModContainer && mc.getMod()!=null)
|
||||
{
|
||||
modList.add((A)((ModLoaderModContainer)mc).mod);
|
||||
}
|
||||
}
|
||||
|
||||
return modList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getSource()
|
||||
{
|
||||
return modSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMod()
|
||||
{
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ArtifactVersion> getRequirements()
|
||||
{
|
||||
return requirements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArtifactVersion> getDependants()
|
||||
{
|
||||
return dependants;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArtifactVersion> getDependencies()
|
||||
{
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return modId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModMetadata getMetadata()
|
||||
{
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion()
|
||||
{
|
||||
if (mod == null || mod.getVersion() == null)
|
||||
{
|
||||
return "Not available";
|
||||
}
|
||||
return mod.getVersion();
|
||||
}
|
||||
|
||||
public BaseModTicker getGameTickHandler()
|
||||
{
|
||||
return this.gameTickHandler;
|
||||
}
|
||||
|
||||
public BaseModTicker getGUITickHandler()
|
||||
{
|
||||
return this.guiTickHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModId()
|
||||
{
|
||||
return modId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindMetadata(MetadataCollection mc)
|
||||
{
|
||||
Map<String, Object> dummyMetadata = ImmutableMap.<String,Object>builder().put("name", modId).put("version", "1.0").build();
|
||||
this.metadata = mc.getMetadataForId(modId, dummyMetadata);
|
||||
Loader.instance().computeDependencies(sortingProperties, getRequirements(), getDependencies(), getDependants());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabledState(boolean enabled)
|
||||
{
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerBus(EventBus bus, LoadController controller)
|
||||
{
|
||||
if (this.enabled)
|
||||
{
|
||||
FMLLog.fine("Enabling mod %s", getModId());
|
||||
this.bus = bus;
|
||||
this.controller = controller;
|
||||
bus.register(this);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Lifecycle mod events
|
||||
|
||||
@Subscribe
|
||||
public void constructMod(FMLConstructionEvent event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ModClassLoader modClassLoader = event.getModClassLoader();
|
||||
modClassLoader.addFile(modSource);
|
||||
EnumSet<TickType> ticks = EnumSet.noneOf(TickType.class);
|
||||
this.gameTickHandler = new BaseModTicker(ticks, false);
|
||||
this.guiTickHandler = new BaseModTicker(ticks.clone(), true);
|
||||
Class<? extends BaseModProxy> modClazz = (Class<? extends BaseModProxy>) modClassLoader.loadBaseModClass(modClazzName);
|
||||
configureMod(modClazz, event.getASMHarvestedData());
|
||||
isNetworkMod = FMLNetworkHandler.instance().registerNetworkMod(this, modClazz, event.getASMHarvestedData());
|
||||
ModLoaderNetworkHandler dummyHandler = null;
|
||||
if (!isNetworkMod)
|
||||
{
|
||||
FMLLog.fine("Injecting dummy network mod handler for BaseMod %s", getModId());
|
||||
dummyHandler = new ModLoaderNetworkHandler(this);
|
||||
FMLNetworkHandler.instance().registerNetworkMod(dummyHandler);
|
||||
}
|
||||
Constructor<? extends BaseModProxy> ctor = modClazz.getConstructor();
|
||||
ctor.setAccessible(true);
|
||||
mod = modClazz.newInstance();
|
||||
if (dummyHandler != null)
|
||||
{
|
||||
dummyHandler.setBaseMod(mod);
|
||||
}
|
||||
ProxyInjector.inject(this, event.getASMHarvestedData(), FMLCommonHandler.instance().getSide(), new ILanguageAdapter.JavaAdapter());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
controller.errorOccurred(this, e);
|
||||
Throwables.propagateIfPossible(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.gameTickHandler.setMod(mod);
|
||||
this.guiTickHandler.setMod(mod);
|
||||
TickRegistry.registerTickHandler(this.gameTickHandler, Side.CLIENT);
|
||||
TickRegistry.registerTickHandler(this.guiTickHandler, Side.CLIENT);
|
||||
GameRegistry.registerWorldGenerator(ModLoaderHelper.buildWorldGenHelper(mod));
|
||||
GameRegistry.registerFuelHandler(ModLoaderHelper.buildFuelHelper(mod));
|
||||
GameRegistry.registerCraftingHandler(ModLoaderHelper.buildCraftingHelper(mod));
|
||||
GameRegistry.registerPickupHandler(ModLoaderHelper.buildPickupHelper(mod));
|
||||
NetworkRegistry.instance().registerChatListener(ModLoaderHelper.buildChatListener(mod));
|
||||
NetworkRegistry.instance().registerConnectionHandler(ModLoaderHelper.buildConnectionHelper(mod));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
controller.errorOccurred(this, e);
|
||||
Throwables.propagateIfPossible(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void init(FMLInitializationEvent event)
|
||||
{
|
||||
try
|
||||
{
|
||||
mod.load();
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
controller.errorOccurred(this, t);
|
||||
Throwables.propagateIfPossible(t);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void postInit(FMLPostInitializationEvent event)
|
||||
{
|
||||
try
|
||||
{
|
||||
mod.modsLoaded();
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
controller.errorOccurred(this, t);
|
||||
Throwables.propagateIfPossible(t);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void loadComplete(FMLLoadCompleteEvent complete)
|
||||
{
|
||||
ModLoaderHelper.finishModLoading(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void serverStarting(FMLServerStartingEvent evt)
|
||||
{
|
||||
for (ICommand cmd : serverCommands)
|
||||
{
|
||||
evt.registerServerCommand(cmd);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ArtifactVersion getProcessedVersion()
|
||||
{
|
||||
if (processedVersion == null)
|
||||
{
|
||||
processedVersion = new DefaultArtifactVersion(modId, getVersion());
|
||||
}
|
||||
return processedVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isImmutable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNetworkMod()
|
||||
{
|
||||
return this.isNetworkMod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayVersion()
|
||||
{
|
||||
return metadata!=null ? metadata.version : getVersion();
|
||||
}
|
||||
|
||||
public void addServerCommand(ICommand command)
|
||||
{
|
||||
serverCommands .add(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionRange acceptableMinecraftVersionRange()
|
||||
{
|
||||
return Loader.instance().getMinecraftModContainer().getStaticVersionRange();
|
||||
}
|
||||
@Override
|
||||
public Certificate getSigningCertificate()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getCustomModProperties()
|
||||
{
|
||||
return EMPTY_PROPERTIES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getCustomResourcePackClass()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Map<String, String> getSharedModDescriptor()
|
||||
{
|
||||
Map<String,String> descriptor = Maps.newHashMap();
|
||||
descriptor.put("modsystem", "ModLoader");
|
||||
descriptor.put("id", getModId());
|
||||
descriptor.put("version",getDisplayVersion());
|
||||
descriptor.put("name", getName());
|
||||
descriptor.put("url", metadata.url);
|
||||
descriptor.put("authors", metadata.getAuthorList());
|
||||
descriptor.put("description", metadata.description);
|
||||
return descriptor;
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.discovery.ASMDataTable;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import cpw.mods.fml.common.network.NetworkModHandler;
|
||||
|
||||
public class ModLoaderNetworkHandler extends NetworkModHandler
|
||||
{
|
||||
|
||||
private BaseModProxy baseMod;
|
||||
public ModLoaderNetworkHandler(ModLoaderModContainer mlmc)
|
||||
{
|
||||
super(mlmc, null);
|
||||
}
|
||||
|
||||
public void setBaseMod(BaseModProxy baseMod)
|
||||
{
|
||||
this.baseMod = baseMod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresClientSide()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresServerSide()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptVersion(String version)
|
||||
{
|
||||
return baseMod.getVersion().equals(version);
|
||||
}
|
||||
@Override
|
||||
public boolean isNetworkMod()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
|
||||
public class ModLoaderPacketHandler implements IPacketHandler
|
||||
{
|
||||
private BaseModProxy mod;
|
||||
|
||||
public ModLoaderPacketHandler(BaseModProxy mod)
|
||||
{
|
||||
this.mod = mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player)
|
||||
{
|
||||
if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
mod.serverCustomPayload(((EntityPlayerMP)player).field_71135_a, packet);
|
||||
}
|
||||
else
|
||||
{
|
||||
ModLoaderHelper.sidedHelper.sendClientPacket(mod, packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import cpw.mods.fml.common.IPickupNotifier;
|
||||
|
||||
public class ModLoaderPickupNotifier implements IPickupNotifier
|
||||
{
|
||||
|
||||
private BaseModProxy mod;
|
||||
|
||||
public ModLoaderPickupNotifier(BaseModProxy mod)
|
||||
{
|
||||
this.mod = mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyPickup(EntityItem item, EntityPlayer player)
|
||||
{
|
||||
mod.onItemPickup(player, item.func_92059_d());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.src.TradeEntry;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
import cpw.mods.fml.common.registry.VillagerRegistry;
|
||||
import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler;
|
||||
|
||||
public class ModLoaderVillageTradeHandler implements IVillageTradeHandler
|
||||
{
|
||||
private List<TradeEntry> trades = Lists.newArrayList();
|
||||
|
||||
@Override
|
||||
public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random)
|
||||
{
|
||||
for (TradeEntry ent : trades)
|
||||
{
|
||||
if (ent.buying)
|
||||
{
|
||||
VillagerRegistry.addEmeraldBuyRecipe(villager, recipeList, random, Item.field_77698_e[ent.id], ent.chance, ent.min, ent.max);
|
||||
}
|
||||
else
|
||||
{
|
||||
VillagerRegistry.addEmeraldSellRecipe(villager, recipeList, random, Item.field_77698_e[ent.id], ent.chance, ent.min, ent.max);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addTrade(TradeEntry entry)
|
||||
{
|
||||
trades.add(entry);
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.ChunkProviderGenerate;
|
||||
import net.minecraft.world.gen.ChunkProviderHell;
|
||||
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
|
||||
public class ModLoaderWorldGenerator implements IWorldGenerator
|
||||
{
|
||||
private BaseModProxy mod;
|
||||
|
||||
public ModLoaderWorldGenerator(BaseModProxy mod)
|
||||
{
|
||||
this.mod = mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
|
||||
{
|
||||
if (chunkGenerator instanceof ChunkProviderGenerate)
|
||||
{
|
||||
mod.generateSurface(world, random, chunkX << 4, chunkZ << 4);
|
||||
}
|
||||
else if (chunkGenerator instanceof ChunkProviderHell)
|
||||
{
|
||||
mod.generateNether(world, random, chunkX << 4, chunkZ << 4);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class ModProperty
|
||||
{
|
||||
private String info;
|
||||
private double min;
|
||||
private double max;
|
||||
private String name;
|
||||
private Field field;
|
||||
|
||||
public ModProperty(Field f, String info, Double min, Double max, String name)
|
||||
{
|
||||
this.field = f;
|
||||
this.info = info;
|
||||
this.min = min != null ? min : Double.MIN_VALUE;
|
||||
this.max = max != null ? max : Double.MAX_VALUE;
|
||||
this.name = name;
|
||||
}
|
||||
public ModProperty(Field field, Map<String, Object> annotationInfo)
|
||||
{
|
||||
this(field, (String)annotationInfo.get("info"), (Double)annotationInfo.get("min"), (Double)annotationInfo.get("max"), (String)annotationInfo.get("name"));
|
||||
}
|
||||
|
||||
public String name()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public double min()
|
||||
{
|
||||
return min;
|
||||
}
|
||||
|
||||
public double max()
|
||||
{
|
||||
return max;
|
||||
}
|
||||
|
||||
public String info()
|
||||
{
|
||||
return info;
|
||||
}
|
||||
|
||||
public Field field()
|
||||
{
|
||||
return field;
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
@ -49,6 +49,7 @@ public class EntitySpawnPacket extends FMLPacket
|
|||
public float scaledYaw;
|
||||
public float scaledPitch;
|
||||
public float scaledHeadYaw;
|
||||
@SuppressWarnings("rawtypes")
|
||||
public List metadata;
|
||||
public int throwerId;
|
||||
public double speedScaledX;
|
||||
|
@ -191,6 +192,7 @@ public class EntitySpawnPacket extends FMLPacket
|
|||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
Entity entity = FMLCommonHandler.instance().spawnEntityIntoClientWorld(registration, this);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
@ -14,6 +14,7 @@ package cpw.mods.fml.common.network;
|
|||
|
||||
public class FMLNetworkException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public FMLNetworkException(Exception e)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
@ -108,6 +108,7 @@ public abstract class FMLPacket
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private Type type;
|
||||
|
||||
public static byte[][] makePacketSet(Type type, Object... data)
|
||||
|
|
|
@ -5,19 +5,22 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.network;
|
||||
|
||||
import static cpw.mods.fml.common.network.FMLPacket.Type.MOD_IDMAP;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.BitSet;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.NetHandler;
|
||||
|
||||
|
@ -25,16 +28,12 @@ import com.google.common.collect.MapDifference;
|
|||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.primitives.Bytes;
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.google.common.primitives.UnsignedBytes;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.ItemData;
|
||||
import static cpw.mods.fml.common.network.FMLPacket.Type.MOD_IDMAP;
|
||||
|
||||
public class ModIdMapPacket extends FMLPacket {
|
||||
private byte[][] partials;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
@ -13,9 +13,9 @@
|
|||
package cpw.mods.fml.common.network;
|
||||
|
||||
import static cpw.mods.fml.common.network.FMLPacket.Type.MOD_IDENTIFIERS;
|
||||
import static cpw.mods.fml.common.network.FMLPacket.Type.MOD_IDMAP;
|
||||
import static cpw.mods.fml.common.network.FMLPacket.Type.MOD_LIST_RESPONSE;
|
||||
import static cpw.mods.fml.common.network.FMLPacket.Type.MOD_MISSING;
|
||||
import static cpw.mods.fml.common.network.FMLPacket.Type.MOD_IDMAP;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -23,8 +23,10 @@ import java.util.Map.Entry;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.*;
|
||||
import net.minecraft.network.packet.*;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.NetLoginHandler;
|
||||
import net.minecraft.network.packet.NetHandler;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
@ -36,7 +38,6 @@ import cpw.mods.fml.common.FMLLog;
|
|||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ModListResponsePacket extends FMLPacket
|
||||
{
|
||||
|
@ -51,7 +52,9 @@ public class ModListResponsePacket extends FMLPacket
|
|||
@Override
|
||||
public byte[] generatePacket(Object... data)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String,String> modVersions = (Map<String, String>) data[0];
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> missingMods = (List<String>) data[1];
|
||||
ByteArrayDataOutput dat = ByteStreams.newDataOutput();
|
||||
dat.writeInt(modVersions.size());
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
@ -47,7 +47,9 @@ public class ModMissingPacket extends FMLPacket
|
|||
{
|
||||
ByteArrayDataOutput dat = ByteStreams.newDataOutput();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> missing = (List<String>) data[0];
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> badVersion = (List<String>) data[1];
|
||||
|
||||
dat.writeInt(missing.size());
|
||||
|
|
|
@ -16,8 +16,6 @@ import java.lang.reflect.Method;
|
|||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
|
|
@ -3,17 +3,12 @@ package cpw.mods.fml.common.patcher;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.security.CodeSource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.JarInputStream;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.jar.Pack200;
|
||||
|
@ -21,11 +16,9 @@ import java.util.logging.Level;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
import LZMA.LzmaInputStream;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
|
@ -35,7 +28,6 @@ import com.google.common.io.ByteArrayDataInput;
|
|||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
import cpw.mods.fml.common.launcher.FMLTweaker;
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.repackage.com.nothome.delta.GDiffPatcher;
|
||||
|
|
|
@ -3,7 +3,6 @@ package cpw.mods.fml.common.patcher;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.jar.JarEntry;
|
||||
|
@ -11,8 +10,6 @@ import java.util.jar.JarFile;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
@ -16,7 +16,6 @@ import java.util.BitSet;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -34,14 +33,12 @@ import com.google.common.collect.HashBiMap;
|
|||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.primitives.UnsignedBytes;
|
||||
import com.google.common.primitives.UnsignedInteger;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.network.EntitySpawnPacket;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration;
|
||||
|
||||
public class EntityRegistry
|
||||
{
|
||||
|
@ -151,6 +148,7 @@ public class EntityRegistry
|
|||
instance().doModEntityRegistration(entityClass, entityName, id, mod, trackingRange, updateFrequency, sendsVelocityUpdates);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void doModEntityRegistration(Class<? extends Entity> entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates)
|
||||
{
|
||||
ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod);
|
||||
|
@ -275,6 +273,7 @@ public class EntityRegistry
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes)
|
||||
{
|
||||
Class <? extends Entity > entityClazz = (Class<? extends Entity>) EntityList.field_75625_b.get(entityName);
|
||||
|
@ -303,13 +302,14 @@ public class EntityRegistry
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void removeSpawn(String entityName, EnumCreatureType spawnList, BiomeGenBase... biomes)
|
||||
{
|
||||
Class <? extends Entity > entityClazz = (Class<? extends Entity>) EntityList.field_75625_b.get(entityName);
|
||||
|
||||
if (EntityLiving.class.isAssignableFrom(entityClazz))
|
||||
{
|
||||
removeSpawn((Class <? extends EntityLiving >) entityClazz, spawnList, biomes);
|
||||
removeSpawn((Class <? extends EntityLiving>) entityClazz, spawnList, biomes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ package cpw.mods.fml.common.registry;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
@ -23,7 +22,6 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockSand;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -32,20 +30,20 @@ import net.minecraft.nbt.NBTTagList;
|
|||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.base.Joiner.MapJoiner;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.HashBasedTable;
|
||||
import com.google.common.collect.ImmutableListMultimap;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableTable;
|
||||
import com.google.common.collect.ImmutableTable.Builder;
|
||||
import com.google.common.collect.MapDifference;
|
||||
import com.google.common.collect.Tables;
|
||||
import com.google.common.collect.MapDifference.ValueDifference;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.collect.Table;
|
||||
import com.google.common.collect.Table.Cell;
|
||||
import com.google.common.collect.Tables;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
|
@ -29,23 +28,16 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.MapDifference;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Multimaps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.collect.Sets.SetView;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
|
@ -56,9 +48,8 @@ import cpw.mods.fml.common.IWorldGenerator;
|
|||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.LoaderException;
|
||||
import cpw.mods.fml.common.LoaderState;
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import cpw.mods.fml.common.Mod.Block;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
|
||||
public class GameRegistry
|
||||
{
|
||||
|
@ -104,30 +95,6 @@ public class GameRegistry
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method for creating an @Block instance
|
||||
* @param container
|
||||
* @param type
|
||||
* @param annotation
|
||||
* @throws Exception
|
||||
*/
|
||||
public static Object buildBlock(ModContainer container, Class<?> type, Block annotation) throws Exception
|
||||
{
|
||||
Object o = type.getConstructor(int.class).newInstance(findSpareBlockId());
|
||||
registerBlock((net.minecraft.block.Block) o);
|
||||
return o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Private and not yet working properly
|
||||
*
|
||||
* @return a block id
|
||||
*/
|
||||
private static int findSpareBlockId()
|
||||
{
|
||||
return BlockTracker.nextBlockId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an item with the item registry with a custom name : this allows for easier server->client resolution
|
||||
*
|
||||
|
@ -250,6 +217,7 @@ public class GameRegistry
|
|||
CraftingManager.func_77594_a().func_77596_b(output, params);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void addRecipe(IRecipe recipe)
|
||||
{
|
||||
CraftingManager.func_77594_a().func_77592_b().add(recipe);
|
||||
|
@ -276,7 +244,7 @@ public class GameRegistry
|
|||
public static void registerTileEntityWithAlternatives(Class<? extends TileEntity> tileEntityClass, String id, String... alternatives)
|
||||
{
|
||||
TileEntity.func_70306_a(tileEntityClass, id);
|
||||
Map<String,Class> teMappings = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "70326_a", "field_70326_a", "a");
|
||||
Map<String,Class<?>> teMappings = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "70326_a", "field_70326_a", "a");
|
||||
for (String s: alternatives)
|
||||
{
|
||||
if (!teMappings.containsKey(s))
|
||||
|
|
|
@ -21,6 +21,10 @@ import java.util.Map;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
@ -28,12 +32,6 @@ import cpw.mods.fml.common.FMLLog;
|
|||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StringTranslate;
|
||||
|
||||
public class LanguageRegistry
|
||||
{
|
||||
private static final LanguageRegistry INSTANCE = new LanguageRegistry();
|
||||
|
@ -122,7 +120,8 @@ public class LanguageRegistry
|
|||
instance().addNameForObject(objectToName, "en_US", name);
|
||||
}
|
||||
|
||||
public void loadLanguageTable(Map field_135032_a, String lang)
|
||||
@SuppressWarnings("unchecked")
|
||||
public void loadLanguageTable(@SuppressWarnings("rawtypes") Map field_135032_a, String lang)
|
||||
{
|
||||
Properties usPack=modLanguageData.get("en_US");
|
||||
if (usPack!=null) {
|
||||
|
|
|
@ -87,7 +87,7 @@ public class VillagerRegistry
|
|||
* @param p4
|
||||
* @param p5
|
||||
*/
|
||||
Object buildComponent(StructureVillagePieceWeight villagePiece, ComponentVillageStartPiece startPiece, List pieces, Random random, int p1,
|
||||
Object buildComponent(StructureVillagePieceWeight villagePiece, ComponentVillageStartPiece startPiece, @SuppressWarnings("rawtypes") List pieces, Random random, int p1,
|
||||
int p2, int p3, int p4, int p5);
|
||||
}
|
||||
|
||||
|
@ -205,8 +205,9 @@ public class VillagerRegistry
|
|||
}
|
||||
}
|
||||
|
||||
public static void addExtraVillageComponents(ArrayList components, Random random, int i)
|
||||
public static void addExtraVillageComponents(@SuppressWarnings("rawtypes") ArrayList components, Random random, int i)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<StructureVillagePieceWeight> parts = components;
|
||||
for (IVillageCreationHandler handler : instance().villageCreationHandlers.values())
|
||||
{
|
||||
|
@ -214,29 +215,31 @@ public class VillagerRegistry
|
|||
}
|
||||
}
|
||||
|
||||
public static Object getVillageComponent(StructureVillagePieceWeight villagePiece, ComponentVillageStartPiece startPiece, List pieces, Random random,
|
||||
public static Object getVillageComponent(StructureVillagePieceWeight villagePiece, ComponentVillageStartPiece startPiece, @SuppressWarnings("rawtypes") List pieces, Random random,
|
||||
int p1, int p2, int p3, int p4, int p5)
|
||||
{
|
||||
return instance().villageCreationHandlers.get(villagePiece.field_75090_a).buildComponent(villagePiece, startPiece, pieces, random, p1, p2, p3, p4, p5);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void addEmeraldBuyRecipe(EntityVillager villager, MerchantRecipeList list, Random random, Item item, float chance, int min, int max)
|
||||
{
|
||||
if (min > 0 && max > 0)
|
||||
{
|
||||
EntityVillager.field_70958_bB.put(item.field_77779_bT, new Tuple(min, max));
|
||||
}
|
||||
villager.func_70948_a(list, item.func_77612_l(), random, chance);
|
||||
EntityVillager.func_70948_a(list, item.func_77612_l(), random, chance);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void addEmeraldSellRecipe(EntityVillager villager, MerchantRecipeList list, Random random, Item item, float chance, int min, int max)
|
||||
{
|
||||
if (min > 0 && max > 0)
|
||||
{
|
||||
EntityVillager.field_70960_bC.put(item.field_77779_bT, new Tuple(min, max));
|
||||
}
|
||||
villager.func_70949_b(list, item.func_77612_l(), random, chance);
|
||||
EntityVillager.func_70949_b(list, item.func_77612_l(), random, chance);
|
||||
}
|
||||
|
||||
public static void applyRandomTrade(EntityVillager villager, Random rand)
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import cpw.mods.fml.common.DummyModContainer;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
@ -16,6 +16,8 @@ import java.util.Set;
|
|||
|
||||
public class ModSortingException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public class SortingExceptionData<T>
|
||||
{
|
||||
public SortingExceptionData(T node, Set<T> visitedNodes)
|
||||
|
@ -37,17 +39,18 @@ public class ModSortingException extends RuntimeException
|
|||
}
|
||||
}
|
||||
|
||||
private SortingExceptionData sortingExceptionData;
|
||||
private SortingExceptionData<?> sortingExceptionData;
|
||||
|
||||
public <T> ModSortingException(String string, T node, Set<T> visitedNodes)
|
||||
{
|
||||
super(string);
|
||||
this.sortingExceptionData = new SortingExceptionData(node, visitedNodes);
|
||||
this.sortingExceptionData = new SortingExceptionData<T>(node, visitedNodes);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> SortingExceptionData<T> getExceptionData()
|
||||
{
|
||||
return sortingExceptionData;
|
||||
return (SortingExceptionData<T>) sortingExceptionData;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
@ -266,6 +266,11 @@ public class ComparableVersion
|
|||
extends ArrayList<Item>
|
||||
implements Item
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public int getType()
|
||||
{
|
||||
return LIST_ITEM;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
@ -36,9 +36,10 @@ package cpw.mods.fml.common.versioning;
|
|||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
*/
|
||||
public class InvalidVersionSpecificationException
|
||||
extends Exception
|
||||
public class InvalidVersionSpecificationException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InvalidVersionSpecificationException( String message )
|
||||
{
|
||||
super( message );
|
||||
|
|
|
@ -334,11 +334,6 @@ public class CoreModManager {
|
|||
}
|
||||
}
|
||||
|
||||
private static void injectTweakWrapper(FMLPluginWrapper wrapper)
|
||||
{
|
||||
loadPlugins.add(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mcDir
|
||||
* the minecraft home directory
|
||||
|
@ -452,6 +447,7 @@ public class CoreModManager {
|
|||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static void sortCoreMods()
|
||||
{
|
||||
TopologicalSort.DirectedGraph<FMLPluginWrapper> sortGraph = new TopologicalSort.DirectedGraph<FMLPluginWrapper>();
|
||||
|
@ -496,6 +492,7 @@ public class CoreModManager {
|
|||
|
||||
public static void injectCoreModTweaks(FMLInjectionAndSortingTweaker fmlInjectionAndSortingTweaker)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<ITweaker> tweakers = (List<ITweaker>) Launch.blackboard.get("Tweaks");
|
||||
// Add the sorting tweaker first- it'll appear twice in the list
|
||||
tweakers.add(0, fmlInjectionAndSortingTweaker);
|
||||
|
@ -509,6 +506,7 @@ public class CoreModManager {
|
|||
|
||||
public static void sortTweakList()
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<ITweaker> tweakers = (List<ITweaker>) Launch.blackboard.get("Tweaks");
|
||||
Collections.sort(tweakers, new Comparator<ITweaker>() {
|
||||
@Override
|
||||
|
|
|
@ -16,13 +16,6 @@ import java.util.Map;
|
|||
|
||||
public class FMLCorePlugin implements IFMLLoadingPlugin
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public String[] getLibraryRequestClass()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getASMTransformerClass()
|
||||
{
|
||||
|
|
|
@ -15,10 +15,8 @@ package cpw.mods.fml.relauncher;
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.logging.ConsoleHandler;
|
||||
import java.util.logging.FileHandler;
|
||||
|
|
|
@ -27,13 +27,6 @@ import java.util.Map;
|
|||
*/
|
||||
public interface IFMLLoadingPlugin
|
||||
{
|
||||
/**
|
||||
* Return a list of classes that implement the ILibrarySet interface
|
||||
*
|
||||
* @return a list of classes that implement the ILibrarySet interface
|
||||
*/
|
||||
@Deprecated
|
||||
String[] getLibraryRequestClass();
|
||||
/**
|
||||
* Return a list of classes that implements the IClassTransformer interface
|
||||
* @return a list of classes that implements the IClassTransformer interface
|
||||
|
|
|
@ -24,6 +24,8 @@ public class ReflectionHelper
|
|||
{
|
||||
public static class UnableToFindMethodException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@SuppressWarnings("unused")
|
||||
private String[] methodNames;
|
||||
|
||||
public UnableToFindMethodException(String[] methodNames, Exception failed)
|
||||
|
@ -36,6 +38,8 @@ public class ReflectionHelper
|
|||
|
||||
public static class UnableToFindClassException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@SuppressWarnings("unused")
|
||||
private String[] classNames;
|
||||
|
||||
public UnableToFindClassException(String[] classNames, Exception err)
|
||||
|
@ -48,7 +52,8 @@ public class ReflectionHelper
|
|||
|
||||
public static class UnableToAccessFieldException extends RuntimeException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@SuppressWarnings("unused")
|
||||
private String[] fieldNameList;
|
||||
|
||||
public UnableToAccessFieldException(String[] fieldNames, Exception e)
|
||||
|
@ -60,6 +65,8 @@ public class ReflectionHelper
|
|||
|
||||
public static class UnableToFindFieldException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@SuppressWarnings("unused")
|
||||
private String[] fieldNameList;
|
||||
public UnableToFindFieldException(String[] fieldNameList, Exception e)
|
||||
{
|
||||
|
@ -141,6 +148,7 @@ public class ReflectionHelper
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Class<? super Object> getClass(ClassLoader loader, String... classNames)
|
||||
{
|
||||
Exception err = null;
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
package cpw.mods.fml.relauncher;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
public class ServerLaunchWrapper {
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ package cpw.mods.fml.server;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -23,11 +22,6 @@ import java.util.regex.Pattern;
|
|||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.MapDifference;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.NetHandler;
|
||||
|
@ -35,19 +29,20 @@ import net.minecraft.network.packet.Packet;
|
|||
import net.minecraft.network.packet.Packet131MapData;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.StringTranslate;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.MapDifference;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.IFMLSidedHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import cpw.mods.fml.common.network.EntitySpawnAdjustmentPacket;
|
||||
import cpw.mods.fml.common.network.EntitySpawnPacket;
|
||||
import cpw.mods.fml.common.network.ModMissingPacket;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.ItemData;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
|
|
@ -1,498 +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 static cpw.mods.fml.relauncher.Side.CLIENT;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.*;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.multiplayer.NetClientHandler;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.NetServerHandler;
|
||||
import net.minecraft.network.packet.NetHandler;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
/**
|
||||
* Bye bye ModLoader. Deprecated without direct replacement
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseModProxy
|
||||
{
|
||||
// CALLBACK MECHANISMS
|
||||
|
||||
@Deprecated
|
||||
public final boolean doTickInGame(TickType tick, boolean tickEnd, Object... data)
|
||||
{
|
||||
Minecraft mc = FMLClientHandler.instance().getClient();
|
||||
boolean hasWorld = mc.field_71441_e != null;
|
||||
// World and render ticks
|
||||
if (tickEnd && ( tick==TickType.RENDER || tick==TickType.CLIENT ) && hasWorld) {
|
||||
return onTickInGame((Float) data[0], mc);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public final boolean doTickInGUI(TickType tick, boolean tickEnd, Object... data)
|
||||
{
|
||||
Minecraft mc = FMLClientHandler.instance().getClient();
|
||||
|
||||
boolean hasWorld = mc.field_71441_e != null;
|
||||
|
||||
if (tickEnd && ( tick==TickType.RENDER || ( tick==TickType.CLIENT && hasWorld))) {
|
||||
return onTickInGUI((Float) data[0], mc, mc.field_71462_r);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
public final void onRenderHarvest(Map renderers)
|
||||
{
|
||||
addRenderer((Map<Class<? extends Entity>,Render>)renderers);
|
||||
}
|
||||
|
||||
public final void onRegisterAnimations()
|
||||
{
|
||||
registerAnimation(FMLClientHandler.instance().getClient());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onCrafting(Object... craftingParameters)
|
||||
{
|
||||
takenFromCrafting((EntityPlayer)craftingParameters[0], (ItemStack)craftingParameters[1], (IInventory)craftingParameters[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onSmelting(Object... smeltingParameters)
|
||||
{
|
||||
takenFromFurnace((EntityPlayer)smeltingParameters[0], (ItemStack)smeltingParameters[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean dispense(double x, double y, double z, int xVelocity, int zVelocity, Object... data)
|
||||
{
|
||||
return dispenseEntity((World)data[0], x, y, z, xVelocity, zVelocity, (ItemStack)data[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onChat(Object... data)
|
||||
{
|
||||
receiveChatPacket(((Packet3Chat)data[0]).field_73476_b);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final void onServerLogin(Object handler) {
|
||||
serverConnect((NetClientHandler) handler);
|
||||
}
|
||||
|
||||
public final void onServerLogout() {
|
||||
serverDisconnect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onPlayerLogin(Object player)
|
||||
{
|
||||
onClientLogin((EntityPlayer) player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onPlayerLogout(Object player)
|
||||
{
|
||||
onClientLogout((EntityPlayer)player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onPlayerChangedDimension(Object player)
|
||||
{
|
||||
onClientDimensionChanged((EntityPlayer)player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onPacket250Packet(Object... data)
|
||||
{
|
||||
receiveCustomPacket((Packet250CustomPayload)data[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void notifyPickup(Object... pickupData)
|
||||
{
|
||||
EntityItem item = (EntityItem) pickupData[0];
|
||||
EntityPlayer player = (EntityPlayer) pickupData[1];
|
||||
onItemPickup(player, item.field_70294_a);
|
||||
}
|
||||
|
||||
@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 ChunkProviderGenerate)
|
||||
{
|
||||
generateSurface(w, random, chunkX << 4, chunkZ << 4);
|
||||
}
|
||||
else if (cp instanceof ChunkProviderHell)
|
||||
{
|
||||
generateNether(w, random, chunkX << 4, chunkZ << 4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean handleCommand(String command, 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
|
||||
*/
|
||||
@Deprecated
|
||||
public int addFuel(int id, int metadata)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@SideOnly(CLIENT)
|
||||
@Deprecated
|
||||
public void addRenderer(Map<Class<? extends Entity>, Render> renderers)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Override if you wish to generate Nether (Hell biome) blocks
|
||||
*
|
||||
* @param world
|
||||
* @param random
|
||||
* @param chunkX
|
||||
* @param chunkZ
|
||||
*/
|
||||
@Deprecated
|
||||
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
|
||||
*/
|
||||
@Deprecated
|
||||
public void generateSurface(World world, Random random, int chunkX, int chunkZ)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to return a gui screen to display
|
||||
* @param player
|
||||
* @param containerID
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
*/
|
||||
@Deprecated
|
||||
@SideOnly(CLIENT)
|
||||
public GuiContainer getContainerGUI(EntityClientPlayerMP player, int containerID, int x, int y, int z)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of your mod. Defaults to the class name
|
||||
*/
|
||||
@Deprecated
|
||||
public String getName()
|
||||
{
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get your mod priorities
|
||||
*/
|
||||
@Deprecated
|
||||
public String getPriorities()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the version of your mod
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract String getVersion();
|
||||
|
||||
@SideOnly(CLIENT)
|
||||
@Deprecated
|
||||
public void keyboardEvent(KeyBinding event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load your mod
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void load();
|
||||
|
||||
/**
|
||||
* Finish loading your mod
|
||||
*/
|
||||
@Deprecated
|
||||
public void modsLoaded()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle item pickup
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
@Deprecated
|
||||
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 time the rendering subtick time (0.0-1.0)
|
||||
* @param minecraftInstance the client
|
||||
* @return true to continue receiving ticks
|
||||
*/
|
||||
@Deprecated
|
||||
@SideOnly(CLIENT)
|
||||
public boolean onTickInGame(float time, Minecraft minecraftInstance)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean onTickInGame(MinecraftServer minecraftServer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@SideOnly(CLIENT)
|
||||
public boolean onTickInGUI(float tick, Minecraft game, GuiScreen gui)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only implemented on the client side
|
||||
* {@link #serverChat(NetServerHandler, String)}
|
||||
*
|
||||
* @param text
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void clientChat(String text)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a client connects
|
||||
* @param handler
|
||||
*/
|
||||
@SideOnly(CLIENT)
|
||||
@Deprecated
|
||||
public void clientConnect(NetClientHandler handler)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the client disconnects
|
||||
* @param handler
|
||||
*/
|
||||
@SideOnly(CLIENT)
|
||||
@Deprecated
|
||||
public void clientDisconnect(NetClientHandler handler)
|
||||
{
|
||||
|
||||
}
|
||||
/**
|
||||
* Called client side to receive a custom payload for this mod
|
||||
*
|
||||
* NOTE: this method is not provided in Risugami's implementation of BaseMod!
|
||||
*
|
||||
* @param packet
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void receiveCustomPacket(Packet250CustomPayload packet)
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(CLIENT)
|
||||
@Deprecated
|
||||
public void registerAnimation(Minecraft game)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@SideOnly(CLIENT)
|
||||
@Deprecated
|
||||
public void renderInvBlock(RenderBlocks renderer, Block block, int metadata, int modelID)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@SideOnly(CLIENT)
|
||||
@Deprecated
|
||||
public boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID)
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
/*
|
||||
* NOTE: this method is not provided in Risugami's implementation of BaseMod!
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void serverConnect(NetHandler handler) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void serverCustomPayload(NetServerHandler handler, Packet250CustomPayload packet)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* NOTE: this method is not provided in Risugami's implementation of BaseMod!
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void serverDisconnect() {
|
||||
|
||||
}
|
||||
/**
|
||||
* Called when someone crafts an item from a crafting table
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
* @param matrix
|
||||
*/
|
||||
@Deprecated
|
||||
public void takenFromCrafting(EntityPlayer player, ItemStack item, IInventory matrix)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when someone takes a smelted item from a furnace
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
@Deprecated
|
||||
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 chat message is received. Return true to stop further processing
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void serverChat(NetServerHandler source, String message)
|
||||
{
|
||||
}
|
||||
/**
|
||||
* Called when a new client logs in.
|
||||
*
|
||||
* NOTE: this method is not provided in Risugami's implementation of BaseMod!
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void onClientLogin(EntityPlayer player)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a client logs out of the server.
|
||||
*
|
||||
* NOTE: this method is not provided in Risugami's implementation of BaseMod!
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void onClientLogout(INetworkManager mgr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn the entity of the supplied type, if it is your mod's
|
||||
*/
|
||||
@SideOnly(CLIENT)
|
||||
@Deprecated
|
||||
public Entity spawnEntity(int entityId, World world, double scaledX, double scaledY, double scaledZ)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@SideOnly(CLIENT)
|
||||
@Deprecated
|
||||
public void clientCustomPayload(NetClientHandler handler, Packet250CustomPayload packet)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package net.minecraft.src;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
|
||||
@Deprecated
|
||||
public class EntityRendererProxy extends EntityRenderer
|
||||
{
|
||||
public static final String fmlMarker = "This is an FML marker";
|
||||
private Minecraft game;
|
||||
|
||||
@Deprecated
|
||||
public EntityRendererProxy(Minecraft minecraft)
|
||||
{
|
||||
super(minecraft);
|
||||
game = minecraft;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void func_78480_b(float tick)
|
||||
{
|
||||
super.func_78480_b(tick);
|
||||
//This is where ModLoader does all of it's ticking
|
||||
}
|
||||
}
|
|
@ -12,16 +12,12 @@
|
|||
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import cpw.mods.fml.client.TextureFXManager;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
|
|
|
@ -1,54 +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 static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(value = RUNTIME)
|
||||
@Target(value = FIELD)
|
||||
@Deprecated
|
||||
public @interface MLProp
|
||||
{
|
||||
/**
|
||||
* Adds additional help to top of configuration file.
|
||||
*/
|
||||
@Deprecated
|
||||
String info() default "";
|
||||
|
||||
/**
|
||||
* Maximum value allowed if field is a number.
|
||||
*/
|
||||
@Deprecated
|
||||
double max() default Double.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* Minimum value allowed if field is a number.
|
||||
*/
|
||||
@Deprecated
|
||||
double min() default Double.MIN_VALUE;
|
||||
|
||||
/**
|
||||
* Overrides the field name for property key.
|
||||
*/
|
||||
@Deprecated
|
||||
String name() default "";
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue