Merge branch 'snapshot15'

This commit is contained in:
Christian 2013-03-09 12:19:37 -05:00
commit 9b8c65d3c2
272 changed files with 24846 additions and 20014 deletions

1
fml/.gitignore vendored
View file

@ -11,3 +11,4 @@ fmlbranding.properties
/mcp*.zip /mcp*.zip
/mcp /mcp
/eclipse /eclipse
/deobfuscation_data*.zip

View file

@ -15,6 +15,10 @@ from them. The license to MCP data is not transitive - distribution of this data
third parties requires independent licensing from the MCP team. This data is not third parties requires independent licensing from the MCP team. This data is not
redistributable without permission from the MCP team. redistributable without permission from the MCP team.
=== Sharing ===
License is granted to redistribute the ASM transformer code (common/cpw/mods/fml/common/asm/ and subdirectories)
under any alternative open source license as classified by the OSI (http://opensource.org/licenses)
======== ========
GNU LESSER GENERAL PUBLIC LICENSE GNU LESSER GENERAL PUBLIC LICENSE

View file

@ -16,6 +16,7 @@
</exec> </exec>
<propertyfile file="fmlversion.properties"> <propertyfile file="fmlversion.properties">
<entry key="fmlbuild.build.number" type="int" value="${version.build}"/> <entry key="fmlbuild.build.number" type="int" value="${version.build}"/>
<entry key="fmlbuild.deobfuscation.hash" type="string" value="${deobf.checksum}"/>
</propertyfile> </propertyfile>
</target> </target>
@ -203,7 +204,24 @@
</zip> </zip>
</target> </target>
<target name="build" depends="buildenvsetup,merge-client,merge-common,build-universal,build-source-pack" /> <target name="build-deobf-data" depends="makeversion">
<mkdir dir="build-tmp-deobf"/>
<copy todir="build-tmp-deobf">
<mappedresources>
<fileset dir="${mcp.home}/conf" includes="packaged.srg"/>
<globmapper from="packaged.srg" to="joined.srg"/>
</mappedresources>
</copy>
<touch millis="0" file="build-tmp-deobf/joined.srg"/>
<zip file="deobfuscation_data_${version.minecraft}.zip" encoding="UTF-8">
<fileset dir="build-tmp-deobf" includes="joined.srg"/>
</zip>
<checksum algorithm="SHA1" property="deobf.checksum" file="deobfuscation_data_${version.minecraft}.zip"/>
<antcall target="writeversion"/>
<delete dir="build-tmp-deobf" />
</target>
<target name="build" depends="buildenvsetup,merge-client,merge-common,build-deobf-data,build-universal,build-source-pack" />
<target name="jenkinsbuild" depends="buildenvsetup,jenkinsfmldecompile,patch,build"/> <target name="jenkinsbuild" depends="buildenvsetup,jenkinsfmldecompile,patch,build"/>

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.client;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;

View file

@ -140,7 +140,7 @@ public class FMLClientHandler implements IFMLSidedHandler
loading = true; loading = true;
client = minecraft; client = minecraft;
ObfuscationReflectionHelper.detectObfuscation(World.class); ObfuscationReflectionHelper.detectObfuscation(World.class);
TextureFXManager.instance().setClient(client); // TextureFXManager.instance().setClient(client);
FMLCommonHandler.instance().beginLoading(this); FMLCommonHandler.instance().beginLoading(this);
new ModLoaderClientHelper(client); new ModLoaderClientHelper(client);
try try
@ -244,7 +244,9 @@ public class FMLClientHandler implements IFMLSidedHandler
} }
else else
{ {
TextureFXManager.instance().loadTextures(client.field_71418_C.func_77292_e()); // Force renderengine to reload and re-initialize all textures
client.field_71446_o.func_78352_b();
// TextureFXManager.instance().loadTextures(client.field_71418_C.func_77292_e());
} }
} }
/** /**

View file

@ -1,70 +0,0 @@
/*
* The FML Forge Mod Loader suite.
* Copyright (C) 2012 cpw
*
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package cpw.mods.fml.client;
import java.awt.Dimension;
import java.util.List;
import java.util.logging.Logger;
import net.minecraft.client.renderer.RenderEngine;
import net.minecraft.client.renderer.texturefx.TextureFX;
import net.minecraft.client.texturepacks.ITexturePack;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
public class FMLTextureFX extends TextureFX implements ITextureFX
{
public int tileSizeBase = 16;
public int tileSizeSquare = 256;
public int tileSizeMask = 15;
public int tileSizeSquareMask = 255;
public boolean errored = false;
protected Logger log = FMLLog.getLogger();
public FMLTextureFX(int icon)
{
super(icon);
}
@Override public void setErrored(boolean err){ errored = err; }
@Override public boolean getErrored(){ return errored; }
@Override
public void onTexturePackChanged(RenderEngine engine, ITexturePack texturepack, Dimension dimensions)
{
onTextureDimensionsUpdate(dimensions.width, dimensions.height);
}
@Override
public void onTextureDimensionsUpdate(int width, int height)
{
tileSizeBase = width >> 4;
tileSizeSquare = tileSizeBase * tileSizeBase;
tileSizeMask = tileSizeBase - 1;
tileSizeSquareMask = tileSizeSquare - 1;
setErrored(false);
setup();
}
protected void setup()
{
field_76852_a = new byte[tileSizeSquare << 2];
}
public boolean unregister(RenderEngine engine, List<TextureFX> effects)
{
effects.remove(this);
return true;
}
}

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.client;
import net.minecraft.client.gui.GuiErrorScreen; import net.minecraft.client.gui.GuiErrorScreen;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.client;
import java.io.File; import java.io.File;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.client;
import java.util.List; import java.util.List;

View file

@ -102,7 +102,7 @@ public class GuiModList extends GuiScreen
public int drawLine(String line, int offset, int shifty) public int drawLine(String line, int offset, int shifty)
{ {
this.field_73886_k.func_78276_b(line, offset, shifty, 0xd7edea); int r = this.field_73886_k.func_78276_b(line, offset, shifty, 0xd7edea);
return shifty + 10; return shifty + 10;
} }
@ -116,12 +116,21 @@ public class GuiModList extends GuiScreen
GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_BLEND);
if (!selectedMod.getMetadata().autogenerated) { if (!selectedMod.getMetadata().autogenerated) {
int shifty = 35; int shifty = 35;
if (!selectedMod.getMetadata().logoFile.isEmpty()) String logoFile = selectedMod.getMetadata().logoFile;
if (!logoFile.isEmpty())
{ {
int texture = this.field_73882_e.field_71446_o.func_78341_b(selectedMod.getMetadata().logoFile);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.field_73882_e.field_71446_o.func_78342_b(texture); this.field_73882_e.field_71446_o.func_98187_b(logoFile);
Dimension dim = TextureFXManager.instance().getTextureDimensions(texture); Dimension dim = TextureFXManager.instance().getTextureDimensions(logoFile);
double scaleX = dim.width / 200.0;
double scaleY = dim.height / 65.0;
double scale = 1.0;
if (scaleX > 1 || scaleY > 1)
{
scale = 1.0 / Math.max(scaleX, scaleY);
}
dim.width *= scale;
dim.height *= scale;
int top = 32; int top = 32;
Tessellator tess = Tessellator.field_78398_a; Tessellator tess = Tessellator.field_78398_a;
tess.func_78382_b(); tess.func_78382_b();
@ -144,7 +153,11 @@ public class GuiModList extends GuiScreen
shifty = drawLine(String.format("Authors: %s", selectedMod.getMetadata().getAuthorList()), offset, shifty); shifty = drawLine(String.format("Authors: %s", selectedMod.getMetadata().getAuthorList()), offset, shifty);
shifty = drawLine(String.format("URL: %s", selectedMod.getMetadata().url), offset, shifty); shifty = drawLine(String.format("URL: %s", selectedMod.getMetadata().url), offset, shifty);
shifty = drawLine(selectedMod.getMetadata().childMods.isEmpty() ? "No child mods for this mod" : String.format("Child mods: %s", selectedMod.getMetadata().getChildModList()), offset, shifty); shifty = drawLine(selectedMod.getMetadata().childMods.isEmpty() ? "No child mods for this mod" : String.format("Child mods: %s", selectedMod.getMetadata().getChildModList()), offset, shifty);
this.getFontRenderer().func_78279_b(selectedMod.getMetadata().description, offset, shifty + 10, this.field_73880_f - offset - 20, 0xDDDDDD); int rightSide = this.field_73880_f - offset - 20;
if (rightSide > 20)
{
this.getFontRenderer().func_78279_b(selectedMod.getMetadata().description, offset, shifty + 10, rightSide, 0xDDDDDD);
}
} else { } else {
offset = ( this.listWidth + this.field_73880_f ) / 2; offset = ( this.listWidth + this.field_73880_f ) / 2;
this.func_73732_a(this.field_73886_k, selectedMod.getName(), offset, 35, 0xFFFFFF); this.func_73732_a(this.field_73886_k, selectedMod.getName(), offset, 35, 0xFFFFFF);

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.client;
import net.minecraft.client.gui.GuiErrorScreen; import net.minecraft.client.gui.GuiErrorScreen;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.client;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.client;
import java.util.List; import java.util.List;
@ -252,7 +264,7 @@ public abstract class GuiScrollingList
GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_FOG); GL11.glDisable(GL11.GL_FOG);
Tessellator var18 = Tessellator.field_78398_a; Tessellator var18 = Tessellator.field_78398_a;
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.client.field_71446_o.func_78341_b("/gui/background.png")); this.client.field_71446_o.func_98187_b("/gui/background.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
float var17 = 32.0F; float var17 = 32.0F;
var18.func_78382_b(); var18.func_78382_b();
@ -385,7 +397,7 @@ public abstract class GuiScrollingList
private void overlayBackground(int p_22239_1_, int p_22239_2_, int p_22239_3_, int p_22239_4_) private void overlayBackground(int p_22239_1_, int p_22239_2_, int p_22239_3_, int p_22239_4_)
{ {
Tessellator var5 = Tessellator.field_78398_a; Tessellator var5 = Tessellator.field_78398_a;
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.client.field_71446_o.func_78341_b("/gui/background.png")); this.client.field_71446_o.func_98187_b("/gui/background.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
float var6 = 32.0F; float var6 = 32.0F;
var5.func_78382_b(); var5.func_78382_b();

View file

@ -1,15 +1,13 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.client; package cpw.mods.fml.client;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.client;
import net.minecraft.client.gui.GuiErrorScreen; import net.minecraft.client.gui.GuiErrorScreen;

View file

@ -1,15 +1,13 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.client; package cpw.mods.fml.client;

View file

@ -1,44 +0,0 @@
/*
* The FML Forge Mod Loader suite.
* Copyright (C) 2012 cpw
*
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package cpw.mods.fml.client;
import net.minecraft.client.renderer.texturefx.TextureFX;
class OverrideInfo
{
public String texture;
public String override;
public int index;
public int imageIndex;
public TextureFX textureFX;
public boolean added;
@Override
public boolean equals(Object obj)
{
try {
OverrideInfo inf=(OverrideInfo) obj;
return index==inf.index && imageIndex==inf.imageIndex;
} catch (Exception e) {
return false;
}
}
@Override
public int hashCode()
{
return index+imageIndex;
}
}

View file

@ -1,138 +0,0 @@
/*
* The FML Forge Mod Loader suite.
* Copyright (C) 2012 cpw
*
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package cpw.mods.fml.client;
import java.util.BitSet;
import java.util.HashMap;
import java.util.logging.Level;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
/**
* @author cpw
*
*/
public class SpriteHelper
{
private static HashMap<String, BitSet> spriteInfo = new HashMap<String, BitSet>();
private static void initMCSpriteMaps() {
BitSet slots =
SpriteHelper.toBitSet(
"0000000000000000" +
"0000000000110000" +
"0000000000100000" +
"0000000001100000" +
"0000000000000000" +
"0000000000000000" +
"0000000000000000" +
"0000000000000000" +
"0000000000000000" +
"0000000000000000" +
"0000000000000000" +
"0000000000011111" +
"0000000000000000" +
"0000000001111100" +
"0000000001111000" +
"0000000000000000");
spriteInfo.put("/terrain.png", slots);
slots = SpriteHelper.toBitSet(
"0000000000000000" +
"0000000000000000" +
"0000000000000000" +
"0000000000000000" +
"0000000000000000" +
"0000000000000000" +
"0000000000000000" +
"0000000000000000" +
"0000000000000000" +
"0111110000000000" +
"0111111010000000" +
"0111111110000000" +
"0111111110001000" +
"1111111111111111" +
"0000011111111111" +
"0000000000000000");
spriteInfo.put("/gui/items.png", slots);
}
/**
* Register a sprite map for ModTextureStatic, to allow for other mods to override
* your sprite page.
*
*
*/
public static void registerSpriteMapForFile(String file, String spriteMap) {
if (spriteInfo.size() == 0) {
initMCSpriteMaps();
}
if (spriteInfo.containsKey(file)) {
FMLLog.log("fml.TextureManager", Level.FINE, "Duplicate attempt to register a sprite file %s for overriding -- ignoring",file);
return;
}
spriteInfo.put(file, toBitSet(spriteMap));
}
public static int getUniqueSpriteIndex(String path)
{
if (!spriteInfo.containsKey("/terrain.png"))
{
initMCSpriteMaps();
}
BitSet slots = spriteInfo.get(path);
if (slots == null)
{
Exception ex = new Exception(String.format("Invalid getUniqueSpriteIndex call for texture: %s", path));
FMLLog.log("fml.TextureManager", Level.SEVERE, ex, "A critical error has been detected with sprite overrides");
FMLCommonHandler.instance().raiseException(ex,"Invalid request to getUniqueSpriteIndex",true);
}
int ret = getFreeSlot(slots);
if (ret == -1)
{
Exception ex = new Exception(String.format("No more sprite indicies left for: %s", path));
FMLLog.log("fml.TextureManager", Level.SEVERE, ex, "There are no sprite indicies left for %s", path);
FMLCommonHandler.instance().raiseException(ex,"No more sprite indicies left", true);
}
return ret;
}
public static BitSet toBitSet(String data)
{
BitSet ret = new BitSet(data.length());
for (int x = 0; x < data.length(); x++)
{
ret.set(x, data.charAt(x) == '1');
}
return ret;
}
public static int getFreeSlot(BitSet slots)
{
int next=slots.nextSetBit(0);
slots.clear(next);
return next;
}
public static int freeSlotCount(String textureToOverride)
{
return spriteInfo.get(textureToOverride).cardinality();
}
}

View file

@ -1,303 +1,43 @@
package cpw.mods.fml.client; /*
* 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
*/
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D; package cpw.mods.fml.client;
import static org.lwjgl.opengl.GL11.GL_TEXTURE_BINDING_2D;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import com.google.common.collect.Maps;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderEngine; import net.minecraft.client.renderer.RenderEngine;
import net.minecraft.client.renderer.texturefx.TextureFX;
import net.minecraft.client.texturepacks.ITexturePack;
import net.minecraft.src.ModTextureStatic;
import org.lwjgl.opengl.GL11;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.ModContainer;
public class TextureFXManager public class TextureFXManager
{ {
private static final TextureFXManager INSTANCE = new TextureFXManager(); private static final TextureFXManager INSTANCE = new TextureFXManager();
private class TextureProperties
{
private int textureId;
private Dimension dim;
}
private Map<Integer,TextureProperties> textureProperties = Maps.newHashMap();
private Multimap<String, OverrideInfo> overrideInfo = ArrayListMultimap.create();
private HashSet<OverrideInfo> animationSet = new HashSet<OverrideInfo>();
private List<TextureFX> addedTextureFX = new ArrayList<TextureFX>();
private Minecraft client; private Minecraft client;
private Map<Integer,TextureHolder> texturesById = Maps.newHashMap();
private Map<String, TextureHolder> texturesByName = Maps.newHashMap();
void setClient(Minecraft client) void setClient(Minecraft client)
{ {
this.client = client; this.client = client;
} }
public boolean onUpdateTextureEffect(TextureFX effect)
{
ITextureFX ifx = (effect instanceof ITextureFX ? ((ITextureFX)effect) : null);
if (ifx != null && ifx.getErrored())
{
return false;
}
String name = effect.getClass().getSimpleName();
client.field_71424_I.func_76320_a(name);
try
{
if (!FMLClientHandler.instance().hasOptifine())
{
effect.func_76846_a();
}
}
catch (Exception e)
{
FMLLog.log("fml.TextureManager", Level.WARNING, "Texture FX %s has failed to animate. Likely caused by a texture pack change that they did not respond correctly to", name);
if (ifx != null)
{
ifx.setErrored(true);
}
client.field_71424_I.func_76319_b();
return false;
}
client.field_71424_I.func_76319_b();
if (ifx != null)
{
Dimension dim = getTextureDimensions(effect);
int target = ((dim.width >> 4) * (dim.height >> 4)) << 2;
if (effect.field_76852_a.length != target)
{
FMLLog.log("fml.TextureManager", Level.WARNING, "Detected a texture FX sizing discrepancy in %s (%d, %d)", name, effect.field_76852_a.length, target);
ifx.setErrored(true);
return false;
}
}
return true;
}
//Quick and dirty image scaling, no smoothing or fanciness, meant for speed as it will be called every tick.
public void scaleTextureFXData(byte[] data, ByteBuffer buf, int target, int length)
{
int sWidth = (int)Math.sqrt(data.length / 4);
int factor = target / sWidth;
byte[] tmp = new byte[4];
buf.clear();
if (factor > 1)
{
for (int y = 0; y < sWidth; y++)
{
int sRowOff = sWidth * y;
int tRowOff = target * y * factor;
for (int x = 0; x < sWidth; x++)
{
int sPos = (x + sRowOff) * 4;
tmp[0] = data[sPos + 0];
tmp[1] = data[sPos + 1];
tmp[2] = data[sPos + 2];
tmp[3] = data[sPos + 3];
int tPosTop = (x * factor) + tRowOff;
for (int y2 = 0; y2 < factor; y2++)
{
buf.position((tPosTop + (y2 * target)) * 4);
for (int x2 = 0; x2 < factor; x2++)
{
buf.put(tmp);
}
}
}
}
}
buf.position(0).limit(length);
}
public void onPreRegisterEffect(TextureFX effect)
{
Dimension dim = getTextureDimensions(effect);
if (effect instanceof ITextureFX)
{
((ITextureFX)effect).onTextureDimensionsUpdate(dim.width, dim.height);
}
}
public int getEffectTexture(TextureFX effect)
{
Integer id = effectTextures.get(effect);
if (id != null)
{
return id;
}
int old = GL11.glGetInteger(GL_TEXTURE_BINDING_2D);
effect.func_76845_a(client.field_71446_o);
id = GL11.glGetInteger(GL_TEXTURE_BINDING_2D);
GL11.glBindTexture(GL_TEXTURE_2D, old);
effectTextures.put(effect, id);
effect.field_76848_d = id;
return id;
}
public void onTexturePackChange(RenderEngine engine, ITexturePack texturepack, List<TextureFX> effects)
{
pruneOldTextureFX(texturepack, effects);
for (TextureFX tex : effects)
{
if (tex instanceof ITextureFX)
{
((ITextureFX)tex).onTexturePackChanged(engine, texturepack, getTextureDimensions(tex));
}
}
loadTextures(texturepack);
}
private HashMap<Integer, Dimension> textureDims = new HashMap<Integer, Dimension>();
private IdentityHashMap<TextureFX, Integer> effectTextures = new IdentityHashMap<TextureFX, Integer>();
private ITexturePack earlyTexturePack;
public void setTextureDimensions(int id, int width, int height, List<TextureFX> effects)
{
Dimension dim = new Dimension(width, height);
textureDims.put(id, dim);
for (TextureFX tex : effects)
{
if (getEffectTexture(tex) == id && tex instanceof ITextureFX)
{
((ITextureFX)tex).onTextureDimensionsUpdate(width, height);
}
}
}
public Dimension getTextureDimensions(TextureFX effect)
{
return getTextureDimensions(getEffectTexture(effect));
}
public Dimension getTextureDimensions(int id)
{
return textureDims.get(id);
}
public void addAnimation(TextureFX anim)
{
OverrideInfo info=new OverrideInfo();
info.index=anim.field_76850_b;
info.imageIndex=anim.field_76847_f;
info.textureFX=anim;
if (animationSet.contains(info)) {
animationSet.remove(info);
}
animationSet.add(info);
}
public void loadTextures(ITexturePack texturePack)
{
registerTextureOverrides(client.field_71446_o);
}
public void registerTextureOverrides(RenderEngine renderer) {
for (OverrideInfo animationOverride : animationSet) {
renderer.func_78355_a(animationOverride.textureFX);
addedTextureFX.add(animationOverride.textureFX);
FMLLog.log("fml.TextureManager", Level.FINE, "Registered texture override %d (%d) on %s (%d)", animationOverride.index, animationOverride.textureFX.field_76850_b, animationOverride.textureFX.getClass().getSimpleName(), animationOverride.textureFX.field_76847_f);
}
for (String fileToOverride : overrideInfo.keySet()) {
for (OverrideInfo override : overrideInfo.get(fileToOverride)) {
try
{
BufferedImage image=loadImageFromTexturePack(renderer, override.override);
ModTextureStatic mts=new ModTextureStatic(override.index, 1, override.texture, image);
renderer.func_78355_a(mts);
addedTextureFX.add(mts);
FMLLog.log("fml.TextureManager", Level.FINE, "Registered texture override %d (%d) on %s (%d)", override.index, mts.field_76850_b, override.texture, mts.field_76847_f);
}
catch (IOException e)
{
FMLLog.log("fml.TextureManager", Level.WARNING, e, "Exception occurred registering texture override for %s", fileToOverride);
}
}
}
}
protected void registerAnimatedTexturesFor(ModContainer mod)
{
}
public void onEarlyTexturePackLoad(ITexturePack fallback)
{
if (client==null) {
// We're far too early- let's wait
this.earlyTexturePack = fallback;
} else {
loadTextures(fallback);
}
}
public void pruneOldTextureFX(ITexturePack var1, List<TextureFX> effects)
{
ListIterator<TextureFX> li = addedTextureFX.listIterator();
while (li.hasNext())
{
TextureFX tex = li.next();
if (tex instanceof FMLTextureFX)
{
if (((FMLTextureFX)tex).unregister(client.field_71446_o, effects))
{
li.remove();
}
}
else
{
effects.remove(tex);
li.remove();
}
}
}
public void addNewTextureOverride(String textureToOverride, String overridingTexturePath, int location) {
OverrideInfo info = new OverrideInfo();
info.index = location;
info.override = overridingTexturePath;
info.texture = textureToOverride;
overrideInfo.put(textureToOverride, info);
FMLLog.log("fml.TextureManager", Level.FINE, "Overriding %s @ %d with %s. %d slots remaining",textureToOverride, location, overridingTexturePath, SpriteHelper.freeSlotCount(textureToOverride));
}
public BufferedImage loadImageFromTexturePack(RenderEngine renderEngine, String path) throws IOException public BufferedImage loadImageFromTexturePack(RenderEngine renderEngine, String path) throws IOException
{ {
InputStream image=client.field_71418_C.func_77292_e().func_77532_a(path); InputStream image=client.field_71418_C.func_77292_e().func_77532_a(path);
@ -331,5 +71,35 @@ public class TextureFXManager
} }
} }
} }
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);
}
} }

View file

@ -1,15 +1,13 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.client.modloader; package cpw.mods.fml.client.modloader;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.client.modloader;
import java.util.Collection; import java.util.Collection;
@ -20,7 +32,7 @@ import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import com.google.common.base.Equivalences; import com.google.common.base.Equivalence;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.base.Suppliers; import com.google.common.base.Suppliers;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
@ -73,7 +85,7 @@ public class ModLoaderClientHelper implements IModLoaderSidedHelper
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()); 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, Equivalences.identity()); 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()) for ( Entry<Class<? extends Entity>, Render> e : difference.entriesOnlyOnLeft().entrySet())
{ {

View file

@ -1,15 +1,13 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.client.modloader; package cpw.mods.fml.client.modloader;

View file

@ -1,3 +1,15 @@
/*
* 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.registry; package cpw.mods.fml.client.registry;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;

View file

@ -1,3 +1,15 @@
/*
* 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.registry; package cpw.mods.fml.client.registry;
import net.minecraft.block.Block; import net.minecraft.block.Block;

View file

@ -1,3 +1,15 @@
/*
* 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.registry; package cpw.mods.fml.client.registry;
import java.util.ArrayList; import java.util.ArrayList;

View file

@ -1,3 +1,15 @@
/*
* 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.registry; package cpw.mods.fml.client.registry;
import java.util.List; import java.util.List;
@ -13,7 +25,6 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.ObjectArrays; import com.google.common.collect.ObjectArrays;
import cpw.mods.fml.client.SpriteHelper;
import cpw.mods.fml.client.TextureFXManager; import cpw.mods.fml.client.TextureFXManager;
/** /**
@ -24,7 +35,7 @@ public class RenderingRegistry
{ {
private static final RenderingRegistry INSTANCE = new RenderingRegistry(); private static final RenderingRegistry INSTANCE = new RenderingRegistry();
private int nextRenderId = 36; private int nextRenderId = 40;
private Map<Integer, ISimpleBlockRenderingHandler> blockRenderers = Maps.newHashMap(); private Map<Integer, ISimpleBlockRenderingHandler> blockRenderers = Maps.newHashMap();
@ -90,11 +101,10 @@ public class RenderingRegistry
* @param fileToOverride * @param fileToOverride
* @param fileToAdd * @param fileToAdd
*/ */
@Deprecated
public static int addTextureOverride(String fileToOverride, String fileToAdd) public static int addTextureOverride(String fileToOverride, String fileToAdd)
{ {
int idx = SpriteHelper.getUniqueSpriteIndex(fileToOverride); return -1;
addTextureOverride(fileToOverride, fileToAdd, idx);
return idx;
} }
/** /**
@ -106,7 +116,7 @@ public class RenderingRegistry
*/ */
public static void addTextureOverride(String path, String overlayPath, int index) public static void addTextureOverride(String path, String overlayPath, int index)
{ {
TextureFXManager.instance().addNewTextureOverride(path, overlayPath, index); // TextureFXManager.instance().addNewTextureOverride(path, overlayPath, index);
} }
/** /**
@ -114,9 +124,10 @@ public class RenderingRegistry
* *
* @param path * @param path
*/ */
@Deprecated
public static int getUniqueTextureIndex(String path) public static int getUniqueTextureIndex(String path)
{ {
return SpriteHelper.getUniqueSpriteIndex(path); return -1;
} }
@Deprecated public static RenderingRegistry instance() @Deprecated public static RenderingRegistry instance()

View file

@ -1,15 +1,13 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* 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; package net.minecraft.src;

View file

@ -1,15 +1,13 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* 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; package net.minecraft.src;
@ -22,7 +20,6 @@ import java.util.logging.Logger;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.RenderEngine; import net.minecraft.client.renderer.RenderEngine;
import net.minecraft.client.renderer.texturefx.TextureFX;
import net.minecraft.client.texturepacks.ITexturePack; import net.minecraft.client.texturepacks.ITexturePack;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
@ -56,31 +53,6 @@ public class FMLRenderAccessLibrary
FMLLog.log(level, throwable, message); FMLLog.log(level, throwable, message);
} }
public static void setTextureDimensions(int textureId, int width, int height, List<TextureFX> textureFXList)
{
TextureFXManager.instance().setTextureDimensions(textureId, width, height, textureFXList);
}
public static void preRegisterEffect(TextureFX textureFX)
{
TextureFXManager.instance().onPreRegisterEffect(textureFX);
}
public static boolean onUpdateTextureEffect(TextureFX textureFX)
{
return TextureFXManager.instance().onUpdateTextureEffect(textureFX);
}
public static Dimension getTextureDimensions(TextureFX textureFX)
{
return TextureFXManager.instance().getTextureDimensions(textureFX);
}
public static void onTexturePackChange(RenderEngine engine, ITexturePack texturePack, List<TextureFX> textureFXList)
{
TextureFXManager.instance().onTexturePackChange(engine, texturePack, textureFXList);
}
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelId) public static boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelId)
{ {

View file

@ -28,7 +28,6 @@ import net.minecraft.client.multiplayer.NetClientHandler;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.RenderEngine; import net.minecraft.client.renderer.RenderEngine;
import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.texturefx.TextureFX;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.settings.KeyBinding;
import net.minecraft.command.ICommand; import net.minecraft.command.ICommand;
@ -56,7 +55,6 @@ import net.minecraft.world.WorldType;
import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.chunk.IChunkProvider;
import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.SpriteHelper;
import cpw.mods.fml.client.TextureFXManager; import cpw.mods.fml.client.TextureFXManager;
import cpw.mods.fml.client.modloader.ModLoaderClientHelper; import cpw.mods.fml.client.modloader.ModLoaderClientHelper;
import cpw.mods.fml.client.modloader.ModLoaderKeyBindingHandler; import cpw.mods.fml.client.modloader.ModLoaderKeyBindingHandler;
@ -120,12 +118,6 @@ public class ModLoader
{ {
} }
@SideOnly(CLIENT)
public static void addAnimation(TextureFX anim)
{
TextureFXManager.instance().addAnimation(anim);
}
/** /**
* Adds a new prefix to the armor texture list * Adds a new prefix to the armor texture list
* *
@ -230,6 +222,7 @@ public class ModLoader
* @param fileToAdd The new image * @param fileToAdd The new image
* @return The 'icon index' in the main image that the new image will be applied to * @return The 'icon index' in the main image that the new image will be applied to
*/ */
@Deprecated
@SideOnly(CLIENT) @SideOnly(CLIENT)
public static int addOverride(String fileToOverride, String fileToAdd) public static int addOverride(String fileToOverride, String fileToAdd)
{ {
@ -525,10 +518,11 @@ public class ModLoader
return EntityRegistry.findGlobalUniqueEntityId(); return EntityRegistry.findGlobalUniqueEntityId();
} }
@Deprecated
@SideOnly(CLIENT) @SideOnly(CLIENT)
public static int getUniqueSpriteIndex(String path) public static int getUniqueSpriteIndex(String path)
{ {
return SpriteHelper.getUniqueSpriteIndex(path); return -1;
} }
/** /**

View file

@ -1,141 +0,0 @@
/*
* The FML Forge Mod Loader suite.
* Copyright (C) 2012 cpw
*
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraft.src;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import net.minecraft.client.renderer.RenderEngine;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.FMLTextureFX;
/**
* A texture override for animations, it takes a vertical image of
* texture frames and constantly rotates them in the texture.
*/
public class ModTextureAnimation extends FMLTextureFX
{
private final int tickRate;
private byte[][] images;
private int index = 0;
private int ticks = 0;
private String targetTex = null;
private BufferedImage imgData = null;
public ModTextureAnimation(int icon, int target, BufferedImage image, int tickCount)
{
this(icon, 1, target, image, tickCount);
}
public ModTextureAnimation(int icon, int size, int target, BufferedImage image, int tickCount)
{
this(icon, size, (target == 0 ? "/terrain.png" : "/gui/items.png"), image, tickCount);
}
public ModTextureAnimation(int icon, int size, String target, BufferedImage image, int tickCount)
{
super(icon);
RenderEngine re = FMLClientHandler.instance().getClient().field_71446_o;
targetTex = target;
field_76849_e = size;
field_76847_f = re.func_78341_b(target);
tickRate = tickCount;
ticks = tickCount;
imgData = image;
}
@Override
public void setup()
{
super.setup();
int sWidth = imgData.getWidth();
int sHeight = imgData.getHeight();
int tWidth = tileSizeBase;
int tHeight = tileSizeBase;
int frames = (int)Math.floor((double)(sHeight / sWidth));
if (frames < 1)
{
throw new IllegalArgumentException(String.format("Attempted to create a TextureAnimation with no complete frames: %dx%d", sWidth, sHeight));
}
else
{
images = new byte[frames][];
BufferedImage image = imgData;
if (sWidth != tWidth)
{
BufferedImage b = new BufferedImage(tWidth, tHeight * frames, 6);
Graphics2D g = b.createGraphics();
g.drawImage(imgData, 0, 0, tWidth, tHeight * frames, 0, 0, sWidth, sHeight, (ImageObserver)null);
g.dispose();
image = b;
}
for (int frame = 0; frame < frames; frame++)
{
int[] pixels = new int[tileSizeSquare];
image.getRGB(0, tHeight * frame, tWidth, tHeight, pixels, 0, tWidth);
images[frame] = new byte[tileSizeSquare << 2];
for (int i = 0; i < pixels.length; i++)
{
int i4 = i * 4;
images[frame][i4 + 0] = (byte)(pixels[i] >> 16 & 255);
images[frame][i4 + 1] = (byte)(pixels[i] >> 8 & 255);
images[frame][i4 + 2] = (byte)(pixels[i] >> 0 & 255);
images[frame][i4 + 3] = (byte)(pixels[i] >> 24 & 255);
}
}
}
}
public void func_76846_a()
{
if (++ticks >= tickRate)
{
if (++index >= images.length)
{
index = 0;
}
field_76852_a = images[index];
ticks = 0;
}
}
public void func_76845_a(RenderEngine renderEngine)
{
GL11.glBindTexture(GL11.GL_TEXTURE_2D, field_76847_f);
}
// TODO: REMOVE THIS - just for you dan200
@Deprecated
public void func_783_a()
{
func_76846_a();
}
}

View file

@ -1,183 +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 org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import net.minecraft.client.renderer.RenderEngine;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.FMLTextureFX;
public class ModTextureStatic extends FMLTextureFX
{
private boolean oldanaglyph = false;
private int[] pixels = null;
private String targetTex = null;
private int storedSize;
private BufferedImage overrideData = null;
private int needApply = 10;
public ModTextureStatic(int icon, int target, BufferedImage image)
{
this(icon, 1, target, image);
}
public ModTextureStatic(int icon, int size, int target, BufferedImage image)
{
this(icon, size, (target == 0 ? "/terrain.png" : "/gui/items.png"), image);
}
public ModTextureStatic(int icon, int size, String target, BufferedImage image)
{
super(icon);
RenderEngine re = FMLClientHandler.instance().getClient().field_71446_o;
targetTex = target;
storedSize = size;
field_76849_e = size;
field_76847_f = re.func_78341_b(target);
overrideData = image;
}
@Override
public void setup()
{
super.setup();
int sWidth = overrideData.getWidth();
int sHeight = overrideData.getHeight();
pixels = new int[tileSizeSquare];
if (tileSizeBase == sWidth && tileSizeBase == sHeight)
{
overrideData.getRGB(0, 0, sWidth, sHeight, pixels, 0, sWidth);
}
else
{
BufferedImage tmp = new BufferedImage(tileSizeBase, tileSizeBase, 6);
Graphics2D gfx = tmp.createGraphics();
gfx.drawImage(overrideData, 0, 0, tileSizeBase, tileSizeBase, 0, 0, sWidth, sHeight, (ImageObserver)null);
tmp.getRGB(0, 0, tileSizeBase, tileSizeBase, pixels, 0, tileSizeBase);
gfx.dispose();
}
update();
}
@Override
public void func_76846_a()
{
if (oldanaglyph != field_76851_c)
{
update();
}
// This makes it so we only apply the texture to the target texture when we need to,
//due to the fact that update is called when the Effect is first registered, we actually
//need to wait for the next one.
field_76849_e = (needApply == 0 ? 0 : storedSize);
if (needApply > 0)
{
needApply--;
}
}
@Override
public void func_76845_a(RenderEngine p_76845_1_)
{
GL11.glBindTexture(GL_TEXTURE_2D, p_76845_1_.func_78341_b(targetTex));
}
public void update()
{
needApply = 10;
for (int idx = 0; idx < pixels.length; idx++)
{
int i = idx * 4;
int a = pixels[idx] >> 24 & 255;
int r = pixels[idx] >> 16 & 255;
int g = pixels[idx] >> 8 & 255;
int b = pixels[idx] >> 0 & 255;
if (field_76851_c)
{
r = g = b = (r + g + b) / 3;
}
field_76852_a[i + 0] = (byte)r;
field_76852_a[i + 1] = (byte)g;
field_76852_a[i + 2] = (byte)b;
field_76852_a[i + 3] = (byte)a;
}
oldanaglyph = field_76851_c;
}
//Implementation of http://scale2x.sourceforge.net/algorithm.html
public static BufferedImage scale2x(BufferedImage image)
{
int w = image.getWidth();
int h = image.getHeight();
BufferedImage tmp = new BufferedImage(w * 2, h * 2, 2);
for (int x = 0; x < h; ++x)
{
int x2 = x * 2;
for (int y = 0; y < w; ++y)
{
int y2 = y * 2;
int E = image.getRGB(y, x);
int D = (x == 0 ? E : image.getRGB(y, x - 1));
int B = (y == 0 ? E : image.getRGB(y - 1, x ));
int H = (y >= w - 1 ? E : image.getRGB(y + 1, x ));
int F = (x >= h - 1 ? E : image.getRGB(y, x + 1));
int e0, e1, e2, e3;
if (B != H && D != F)
{
e0 = D == B ? D : E;
e1 = B == F ? F : E;
e2 = D == H ? D : E;
e3 = H == F ? F : E;
}
else
{
e0 = e1 = e2 = e3 = E;
}
tmp.setRGB(y2, x2, e0);
tmp.setRGB(y2 + 1, x2, e1);
tmp.setRGB(y2, x2 + 1, e2);
tmp.setRGB(y2 + 1, x2 + 1, e3);
}
}
return tmp;
}
@Override
public String toString()
{
return String.format("ModTextureStatic %s @ %d", targetTex, field_76850_b);
}
}

View file

@ -1,3 +1,15 @@
/*
* 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; package net.minecraft.src;
/** /**

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
/** /**

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
import java.io.File; import java.io.File;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
import java.io.File; import java.io.File;

View file

@ -1,16 +1,15 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.common; package cpw.mods.fml.common;
import java.util.EnumSet; import java.util.EnumSet;
@ -31,7 +30,9 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager; import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.NetHandler; import net.minecraft.network.packet.NetHandler;
import net.minecraft.network.packet.Packet131MapData; import net.minecraft.network.packet.Packet131MapData;
import net.minecraft.server.*; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.ServerListenThread;
import net.minecraft.server.ThreadMinecraftServer;
import net.minecraft.server.dedicated.DedicatedServer; import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.storage.SaveHandler; import net.minecraft.world.storage.SaveHandler;

View file

@ -1,15 +1,13 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.common; package cpw.mods.fml.common;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
import java.util.logging.Level; import java.util.logging.Level;

View file

@ -105,15 +105,43 @@ public class FMLModContainer implements ModContainer
private boolean fingerprintNotPresent; private boolean fingerprintNotPresent;
private Set<String> sourceFingerprints; private Set<String> sourceFingerprints;
private Certificate certificate; private Certificate certificate;
private String modLanguage;
private ILanguageAdapter languageAdapter;
public static interface ILanguageAdapter {
public Object getNewInstance(FMLModContainer container, Class<?> objectClass, ClassLoader classLoader) throws Exception;
}
public static class ScalaAdapter implements ILanguageAdapter {
@Override
public Object getNewInstance(FMLModContainer container, Class<?> scalaObjectClass, ClassLoader classLoader) throws Exception
{
System.out.println("Scala class : "+ scalaObjectClass);
Class<?> sObjectClass = Class.forName(scalaObjectClass.getName()+"$",true,classLoader);
return sObjectClass.getField("MODULE$").get(null);
}
}
public static class JavaAdapter implements ILanguageAdapter {
@Override
public Object getNewInstance(FMLModContainer container, Class<?> objectClass, ClassLoader classLoader) throws Exception
{
return objectClass.newInstance();
}
}
public FMLModContainer(String className, File modSource, Map<String,Object> modDescriptor) public FMLModContainer(String className, File modSource, Map<String,Object> modDescriptor)
{ {
this.className = className; this.className = className;
this.source = modSource; this.source = modSource;
this.descriptor = modDescriptor; this.descriptor = modDescriptor;
this.modLanguage = (String) modDescriptor.get("modLanguage");
this.languageAdapter = "scala".equals(modLanguage) ? new ScalaAdapter() : new JavaAdapter();
} }
private ILanguageAdapter getLanguageAdapter()
{
return languageAdapter;
}
@Override @Override
public String getModId() public String getModId()
{ {
@ -456,7 +484,7 @@ public class FMLModContainer implements ModContainer
annotations = gatherAnnotations(clazz); annotations = gatherAnnotations(clazz);
isNetworkMod = FMLNetworkHandler.instance().registerNetworkMod(this, clazz, event.getASMHarvestedData()); isNetworkMod = FMLNetworkHandler.instance().registerNetworkMod(this, clazz, event.getASMHarvestedData());
modInstance = clazz.newInstance(); modInstance = getLanguageAdapter().getNewInstance(this,clazz, modClassLoader);
if (fingerprintNotPresent) if (fingerprintNotPresent)
{ {
eventBus.post(new FMLFingerprintViolationEvent(source.isDirectory(), source, ImmutableSet.copyOf(this.sourceFingerprints), expectedFingerprint)); eventBus.post(new FMLFingerprintViolationEvent(source.isDirectory(), source, ImmutableSet.copyOf(this.sourceFingerprints), expectedFingerprint));

View file

@ -0,0 +1,34 @@
/*
* 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;
import org.objectweb.asm.tree.ClassNode;
public interface IASMHook {
/**
* Inject the {@link Mod} class node into this instance. This allows retrieval from custom
* attributes or other artifacts in your mod class
*
* @param modClassNode The mod class
* @return optionally some code generated classes that will be injected into the classloader
*/
ClassNode[] inject(ClassNode modClassNode);
/**
* Allow mods to manipulate classes loaded from this {@link Mod}'s jar file. The {@link Mod}
* class is always guaranteed to be called first.
* The node state should be changed in place.
*
* @param node The class being loaded
*/
void modifyClass(String className, ClassNode node);
}

View file

@ -1,15 +1,13 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.common; package cpw.mods.fml.common;

View file

@ -1,16 +1,15 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.common; package cpw.mods.fml.common;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;

View file

@ -1,48 +0,0 @@
/*
* The FML Forge Mod Loader suite. Copyright (C) 2012 cpw
*
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package cpw.mods.fml.common;
import java.util.Random;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
/**
* Deprecated without replacement, use vanilla DispenserRegistry code
*
* @author cpw
*
*/
@Deprecated
public interface IDispenseHandler
{
/**
* Return -1 if you don't want to dispense anything. the other values seem to have specific meanings
* to blockdispenser.
*
* @param x
* @param y
* @param z
* @param xVelocity
* @param zVelocity
* @param world
* @param item
* @param random
* @param entX
* @param entY
* @param entZ
*/
@Deprecated
int dispense(double x, double y, double z, int xVelocity, int zVelocity, World world, ItemStack item, Random random, double entX, double entY, double entZ);
}

View file

@ -1,33 +0,0 @@
package cpw.mods.fml.common;
import java.util.Random;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
/**
*
* Deprecated without replacement. Use vanilla DispenserRegistry code.
*
* @author cpw
*
*/
@Deprecated
public interface IDispenserHandler
{
/**
* Called to dispense an entity
* @param x
* @param y
* @param z
* @param xVelocity
* @param zVelocity
* @param world
* @param item
* @param random
* @param entX
* @param entY
* @param entZ
*/
int dispense(int x, int y, int z, int xVelocity, int zVelocity, World world, ItemStack item, Random random, double entX, double entY, double entZ);
}

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
public interface IFMLHandledException public interface IFMLHandledException

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
import java.util.List; import java.util.List;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View file

@ -1,16 +1,15 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.common; package cpw.mods.fml.common;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;

View file

@ -1,15 +1,13 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.common; package cpw.mods.fml.common;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
public interface IScheduledTickHandler extends ITickHandler public interface IScheduledTickHandler extends ITickHandler

View file

@ -1,15 +1,13 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.common; package cpw.mods.fml.common;

View file

@ -1,16 +1,15 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.common; package cpw.mods.fml.common;
import java.util.Random; import java.util.Random;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
import java.io.File; import java.io.File;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@ -250,4 +262,9 @@ public class LoadController
boolean hasReachedState(LoaderState state) { boolean hasReachedState(LoaderState state) {
return this.state.ordinal()>=state.ordinal() && this.state!=LoaderState.ERRORED; return this.state.ordinal()>=state.ordinal() && this.state!=LoaderState.ERRORED;
} }
void forceState(LoaderState newState)
{
this.state = newState;
}
} }

View file

@ -1,16 +1,15 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.common; package cpw.mods.fml.common;
import java.io.File; import java.io.File;
@ -56,6 +55,7 @@ import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLLoadEvent; import cpw.mods.fml.common.event.FMLLoadEvent;
import cpw.mods.fml.common.functions.ModIdFunction; import cpw.mods.fml.common.functions.ModIdFunction;
import cpw.mods.fml.common.modloader.BaseModProxy; 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.ModSorter;
import cpw.mods.fml.common.toposort.ModSortingException; import cpw.mods.fml.common.toposort.ModSortingException;
import cpw.mods.fml.common.toposort.TopologicalSort; import cpw.mods.fml.common.toposort.TopologicalSort;
@ -675,6 +675,8 @@ public class Loader
// Mod controller should be in the initialization state here // Mod controller should be in the initialization state here
modController.distributeStateMessage(LoaderState.INITIALIZATION); modController.distributeStateMessage(LoaderState.INITIALIZATION);
modController.transition(LoaderState.POSTINITIALIZATION); modController.transition(LoaderState.POSTINITIALIZATION);
// Construct the "mod object table" so mods can refer to it in IMC and postinit
GameData.buildModObjectTable();
modController.distributeStateMessage(FMLInterModComms.IMCEvent.class); modController.distributeStateMessage(FMLInterModComms.IMCEvent.class);
modController.distributeStateMessage(LoaderState.POSTINITIALIZATION); modController.distributeStateMessage(LoaderState.POSTINITIALIZATION);
modController.transition(LoaderState.AVAILABLE); modController.transition(LoaderState.AVAILABLE);
@ -777,7 +779,15 @@ public class Loader
public void serverStopped() public void serverStopped()
{ {
modController.distributeStateMessage(LoaderState.SERVER_STOPPED); modController.distributeStateMessage(LoaderState.SERVER_STOPPED);
try
{
modController.transition(LoaderState.SERVER_STOPPED); modController.transition(LoaderState.SERVER_STOPPED);
}
catch (LoaderException e)
{
modController.forceState(LoaderState.SERVER_STOPPED);
// Discard any exceptions here - they mask other, real, exceptions
}
modController.transition(LoaderState.AVAILABLE); modController.transition(LoaderState.AVAILABLE);
} }

View file

@ -1,16 +1,15 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.common; package cpw.mods.fml.common;
public class LoaderException extends RuntimeException public class LoaderException extends RuntimeException

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
import com.google.common.eventbus.EventBus; import com.google.common.eventbus.EventBus;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
import java.io.InputStream; import java.io.InputStream;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
import cpw.mods.fml.common.versioning.ArtifactVersion; import cpw.mods.fml.common.versioning.ArtifactVersion;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
import java.util.Set; import java.util.Set;

View file

@ -1,16 +1,15 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.common; package cpw.mods.fml.common;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
@ -111,6 +110,21 @@ public @interface Mod
* @return A certificate fingerprint that is expected for this mod. * @return A certificate fingerprint that is expected for this mod.
*/ */
String certificateFingerprint() default ""; String certificateFingerprint() default "";
/**
* The language the mod is authored in. This will be used to control certain libraries being downloaded.
* Valid values are currently "java", "scala"
*
* @return The language the mod is authored in
*/
String modLanguage() default "java";
/**
* An optional ASM hook class, that can be used to apply ASM to classes loaded from this mod. It is also given
* the ASM tree of the class declaring {@link Mod} to with what it will.
*
* @return The name of a class to be loaded and executed. Must implement {@link IASMHook}.
*/
String asmHookClass() default "";
/** /**
* Mark the designated method as to be called at if there is something wrong with the certificate fingerprint of * Mark the designated method as to be called at if there is something wrong with the certificate fingerprint of
* the mod's jar, or it is missing, or otherwise a problem. * the mod's jar, or it is missing, or otherwise a problem.

View file

@ -1,16 +1,15 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.common; package cpw.mods.fml.common;
import java.io.File; import java.io.File;

View file

@ -1,16 +1,15 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.common; package cpw.mods.fml.common;
import java.io.File; import java.io.File;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
import java.io.File; import java.io.File;

View file

@ -1,15 +1,13 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.common; package cpw.mods.fml.common;

View file

@ -1,15 +1,13 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.common; package cpw.mods.fml.common;

View file

@ -1,15 +1,13 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.common; package cpw.mods.fml.common;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
import java.util.EnumSet; import java.util.EnumSet;

View file

@ -1,15 +1,13 @@
/* /*
* The FML Forge Mod Loader suite. * Forge Mod Loader
* Copyright (C) 2012 cpw * 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
* *
* 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 * Contributors:
* Software Foundation; either version 2.1 of the License, or any later version. * cpw - implementation
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
package cpw.mods.fml.common; package cpw.mods.fml.common;
@ -30,16 +28,6 @@ public enum TickType {
* arg 0 : float "partial render time" * arg 0 : float "partial render time"
*/ */
RENDER, RENDER,
/**
* Not fired
*/
@Deprecated
GUI,
/**
* Not fired
*/
@Deprecated
CLIENTGUI,
/** /**
* server side * server side
* Fired once as the world loads from disk * Fired once as the world loads from disk
@ -71,8 +59,6 @@ public enum TickType {
{ {
if (this==CLIENT) return EnumSet.of(RENDER); if (this==CLIENT) return EnumSet.of(RENDER);
if (this==RENDER) return EnumSet.of(CLIENT); if (this==RENDER) return EnumSet.of(CLIENT);
if (this==GUI) return EnumSet.of(CLIENTGUI);
if (this==CLIENTGUI) return EnumSet.of(GUI);
return EnumSet.noneOf(TickType.class); return EnumSet.noneOf(TickType.class);
} }
} }

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
import java.util.Map; import java.util.Map;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common;
public class WrongMinecraftVersionException extends RuntimeException public class WrongMinecraftVersionException extends RuntimeException

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common.asm;
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
@ -12,7 +24,7 @@ import cpw.mods.fml.relauncher.IClassTransformer;
public class ASMTransformer implements IClassTransformer public class ASMTransformer implements IClassTransformer
{ {
@Override @Override
public byte[] transform(String name, byte[] bytes) public byte[] transform(String name,String transformedName, byte[] bytes)
{ {
if ("net.minecraft.src.Block".equals(name)) if ("net.minecraft.src.Block".equals(name))
{ {

View file

@ -1,6 +1,19 @@
/*
* 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; package cpw.mods.fml.common.asm;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.ObjectInputStream.GetField; import java.io.ObjectInputStream.GetField;
import java.io.StringReader; import java.io.StringReader;
@ -27,7 +40,8 @@ import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
import cpw.mods.fml.common.CertificateHelper; import cpw.mods.fml.common.CertificateHelper;
import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
import cpw.mods.fml.relauncher.FMLRelaunchLog;
import cpw.mods.fml.relauncher.IFMLCallHook; import cpw.mods.fml.relauncher.IFMLCallHook;
import cpw.mods.fml.relauncher.RelaunchClassLoader; import cpw.mods.fml.relauncher.RelaunchClassLoader;
@ -72,17 +86,17 @@ public class FMLSanityChecker implements IFMLCallHook
String fingerprint = CertificateHelper.getFingerprint(cert); String fingerprint = CertificateHelper.getFingerprint(cert);
if (fingerprint.equals(FMLFINGERPRINT)) if (fingerprint.equals(FMLFINGERPRINT))
{ {
FMLLog.info("Found valid fingerprint for FML. Certificate fingerprint %s", fingerprint); FMLRelaunchLog.info("Found valid fingerprint for FML. Certificate fingerprint %s", fingerprint);
goodFML = true; goodFML = true;
} }
else if (fingerprint.equals(FORGEFINGERPRINT)) else if (fingerprint.equals(FORGEFINGERPRINT))
{ {
FMLLog.info("Found valid fingerprint for Minecraft Forge. Certificate fingerprint %s", fingerprint); FMLRelaunchLog.info("Found valid fingerprint for Minecraft Forge. Certificate fingerprint %s", fingerprint);
goodFML = true; goodFML = true;
} }
else else
{ {
FMLLog.severe("Found invalid fingerprint for FML: %s", fingerprint); FMLRelaunchLog.severe("Found invalid fingerprint for FML: %s", fingerprint);
} }
} }
} }
@ -93,7 +107,7 @@ public class FMLSanityChecker implements IFMLCallHook
} }
if (!goodFML) if (!goodFML)
{ {
FMLLog.severe("FML appears to be missing any signature data. This is not a good thing"); FMLRelaunchLog.severe("FML appears to be missing any signature data. This is not a good thing");
} }
byte[] mlClass = cl.getClassBytes("ModLoader"); byte[] mlClass = cl.getClassBytes("ModLoader");
// Only care in obfuscated env // Only care in obfuscated env
@ -124,6 +138,7 @@ public class FMLSanityChecker implements IFMLCallHook
public void injectData(Map<String, Object> data) public void injectData(Map<String, Object> data)
{ {
cl = (RelaunchClassLoader) data.get("classLoader"); cl = (RelaunchClassLoader) data.get("classLoader");
FMLDeobfuscatingRemapper.INSTANCE.setup((File)data.get("mcLocation"), cl, (String) data.get("deobfuscationFileName"));
} }
} }

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common.asm;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common.asm.transformers;
import static org.objectweb.asm.Opcodes.ACC_FINAL; import static org.objectweb.asm.Opcodes.ACC_FINAL;
@ -35,6 +47,7 @@ import com.google.common.collect.Multimap;
import com.google.common.io.LineProcessor; import com.google.common.io.LineProcessor;
import com.google.common.io.Resources; import com.google.common.io.Resources;
import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
import cpw.mods.fml.relauncher.IClassTransformer; import cpw.mods.fml.relauncher.IClassTransformer;
public class AccessTransformer implements IClassTransformer public class AccessTransformer implements IClassTransformer
@ -143,15 +156,37 @@ public class AccessTransformer implements IClassTransformer
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public byte[] transform(String name, byte[] bytes) public byte[] transform(String name, String transformedName, byte[] bytes)
{ {
if (bytes == null) { return null; } if (bytes == null) { return null; }
if (!modifiers.containsKey(name)) { return bytes; } boolean makeAllPublic = FMLDeobfuscatingRemapper.INSTANCE.isRemappedClass(name);
if (!makeAllPublic && !modifiers.containsKey(name)) { return bytes; }
ClassNode classNode = new ClassNode(); ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes); ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0); classReader.accept(classNode, 0);
if (makeAllPublic)
{
// class
Modifier m = new Modifier();
m.targetAccess = ACC_PUBLIC;
m.modifyClassVisibility = true;
modifiers.put(name,m);
// fields
m = new Modifier();
m.targetAccess = ACC_PUBLIC;
m.name = "*";
modifiers.put(name,m);
// methods
m = new Modifier();
m.targetAccess = ACC_PUBLIC;
m.name = "*";
m.desc = "";
modifiers.put(name,m);
}
Collection<Modifier> mods = modifiers.get(name); Collection<Modifier> mods = modifiers.get(name);
for (Modifier m : mods) for (Modifier m : mods)
{ {
@ -375,7 +410,7 @@ public class AccessTransformer implements IClassTransformer
for (AccessTransformer trans : transformers) for (AccessTransformer trans : transformers)
{ {
entryData = trans.transform(name, entryData); entryData = trans.transform(name, name, entryData);
} }
} }

View file

@ -0,0 +1,54 @@
/*
* 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 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;
import cpw.mods.fml.relauncher.IClassNameTransformer;
import cpw.mods.fml.relauncher.IClassTransformer;
public class DeobfuscationTransformer implements IClassTransformer, IClassNameTransformer {
@Override
public byte[] transform(String name, String transformedName, byte[] bytes)
{
if (bytes == null)
{
return null;
}
ClassReader classReader = new ClassReader(bytes);
ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS);
RemappingClassAdapter remapAdapter = new FMLRemappingAdapter(classWriter);
classReader.accept(remapAdapter, ClassReader.EXPAND_FRAMES);
return classWriter.toByteArray();
}
@Override
public String remapClassName(String name)
{
return FMLDeobfuscatingRemapper.INSTANCE.map(name.replace('.','/')).replace('/', '.');
}
@Override
public String unmapClassName(String name)
{
return FMLDeobfuscatingRemapper.INSTANCE.unmap(name.replace('.', '/')).replace('/','.');
}
}

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common.asm.transformers;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common.asm.transformers;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
@ -87,7 +99,7 @@ public class MarkerTransformer implements IClassTransformer
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public byte[] transform(String name, byte[] bytes) public byte[] transform(String name, String transformedName, byte[] bytes)
{ {
if (bytes == null) { return null; } if (bytes == null) { return null; }
if (!markers.containsKey(name)) { return bytes; } if (!markers.containsKey(name)) { return bytes; }
@ -240,7 +252,7 @@ public class MarkerTransformer implements IClassTransformer
for (MarkerTransformer trans : transformers) for (MarkerTransformer trans : transformers)
{ {
entryData = trans.transform(name, entryData); entryData = trans.transform(name, name, entryData);
} }
} }

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common.asm.transformers;
import java.util.Iterator; import java.util.Iterator;
@ -21,7 +33,7 @@ public class SideTransformer implements IClassTransformer
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public byte[] transform(String name, byte[] bytes) public byte[] transform(String name, String transformedName, byte[] bytes)
{ {
if (bytes == null) { return null; } if (bytes == null) { return null; }

View file

@ -0,0 +1,300 @@
/*
* 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.deobf;
import java.io.File;
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.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.commons.Remapper;
import com.google.common.base.CharMatcher;
import com.google.common.base.Charsets;
import com.google.common.base.Splitter;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
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.relauncher.FMLRelaunchLog;
import cpw.mods.fml.relauncher.RelaunchClassLoader;
public class FMLDeobfuscatingRemapper extends Remapper {
public static final FMLDeobfuscatingRemapper INSTANCE = new FMLDeobfuscatingRemapper();
private BiMap<String, String> classNameBiMap;
private BiMap<String, String> mcpNameBiMap;
private Map<String,Map<String,String>> rawFieldMaps;
private Map<String,Map<String,String>> rawMethodMaps;
private Map<String,Map<String,String>> fieldNameMaps;
private Map<String,Map<String,String>> methodNameMaps;
private RelaunchClassLoader classLoader;
private FMLDeobfuscatingRemapper()
{
classNameBiMap=ImmutableBiMap.of();
mcpNameBiMap=ImmutableBiMap.of();
}
public void setup(File mcDir, RelaunchClassLoader classLoader, String deobfFileName)
{
this.classLoader = classLoader;
try
{
File libDir = new File(mcDir, "lib");
File mapData = new File(libDir, deobfFileName);
ZipFile mapZip = new ZipFile(mapData);
ZipEntry classData = mapZip.getEntry("joined.srg");
ZipInputSupplier zis = new ZipInputSupplier(mapZip, classData);
InputSupplier<InputStreamReader> srgSupplier = CharStreams.newReaderSupplier(zis,Charsets.UTF_8);
List<String> srgList = CharStreams.readLines(srgSupplier);
rawMethodMaps = Maps.newHashMap();
rawFieldMaps = Maps.newHashMap();
Builder<String, String> builder = ImmutableBiMap.<String,String>builder();
Builder<String, String> mcpBuilder = ImmutableBiMap.<String,String>builder();
Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults();
for (String line : srgList)
{
String[] parts = Iterables.toArray(splitter.split(line),String.class);
String typ = parts[0];
if ("CL".equals(typ))
{
parseClass(builder, parts);
parseMCPClass(mcpBuilder,parts);
}
else if ("MD".equals(typ))
{
parseMethod(parts);
}
else if ("FD".equals(typ))
{
parseField(parts);
}
}
classNameBiMap = builder.build();
// Special case some mappings for modloader mods
mcpBuilder.put("BaseMod","net/minecraft/src/BaseMod");
mcpBuilder.put("ModLoader","net/minecraft/src/ModLoader");
mcpBuilder.put("EntityRendererProxy","net/minecraft/src/EntityRendererProxy");
mcpBuilder.put("MLProp","net/minecraft/src/MLProp");
mcpBuilder.put("TradeEntry","net/minecraft/src/TradeEntry");
mcpNameBiMap = mcpBuilder.build();
}
catch (IOException ioe)
{
FMLRelaunchLog.log(Level.SEVERE, ioe, "An error occurred loading the deobfuscation map data");
}
methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size());
fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size());
}
public boolean isRemappedClass(String className)
{
return classNameBiMap.containsKey(className) || mcpNameBiMap.containsKey(className);
}
private void parseField(String[] parts)
{
String oldSrg = parts[1];
int lastOld = oldSrg.lastIndexOf('/');
String cl = oldSrg.substring(0,lastOld);
String oldName = oldSrg.substring(lastOld+1);
String newSrg = parts[2];
int lastNew = newSrg.lastIndexOf('/');
String newName = newSrg.substring(lastNew+1);
if (!rawFieldMaps.containsKey(cl))
{
rawFieldMaps.put(cl, Maps.<String,String>newHashMap());
}
rawFieldMaps.get(cl).put(oldName, newName);
}
private void parseClass(Builder<String, String> builder, String[] parts)
{
builder.put(parts[1],parts[2]);
}
private void parseMCPClass(Builder<String, String> builder, String[] parts)
{
int clIdx = parts[2].lastIndexOf('/');
builder.put("net/minecraft/src/"+parts[2].substring(clIdx+1),parts[2]);
}
private void parseMethod(String[] parts)
{
String oldSrg = parts[1];
int lastOld = oldSrg.lastIndexOf('/');
String cl = oldSrg.substring(0,lastOld);
String oldName = oldSrg.substring(lastOld+1);
String sig = parts[2];
String newSrg = parts[3];
int lastNew = newSrg.lastIndexOf('/');
String newName = newSrg.substring(lastNew+1);
if (!rawMethodMaps.containsKey(cl))
{
rawMethodMaps.put(cl, Maps.<String,String>newHashMap());
}
rawMethodMaps.get(cl).put(oldName+sig, newName);
}
@Override
public String mapFieldName(String owner, String name, String desc)
{
if (classNameBiMap == null || classNameBiMap.isEmpty())
{
return name;
}
Map<String, String> fieldMap = getFieldMap(owner);
return fieldMap!=null && fieldMap.containsKey(name) ? fieldMap.get(name) : name;
}
@Override
public String map(String typeName)
{
if (classNameBiMap == null || classNameBiMap.isEmpty())
{
return typeName;
}
String result = classNameBiMap.containsKey(typeName) ? classNameBiMap.get(typeName) : mcpNameBiMap.containsKey(typeName) ? mcpNameBiMap.get(typeName) : typeName;
// System.out.printf("Mapping %s=>%s\n",typeName,result);
return result;
}
public String unmap(String typeName)
{
if (classNameBiMap == null)
{
return typeName;
}
String result = classNameBiMap.containsValue(typeName) ? classNameBiMap.inverse().get(typeName) : mcpNameBiMap.containsValue(typeName) ? mcpNameBiMap.inverse().get(typeName) : typeName;
// System.out.printf("Unmapping %s=>%s\n",typeName,result);
return result;
}
@Override
public String mapMethodName(String owner, String name, String desc)
{
if (classNameBiMap==null || classNameBiMap.isEmpty())
{
return name;
}
Map<String, String> methodMap = getMethodMap(owner);
String methodDescriptor = name+desc;
return methodMap!=null && methodMap.containsKey(methodDescriptor) ? methodMap.get(methodDescriptor) : name;
}
private Map<String,String> getFieldMap(String className)
{
if (!fieldNameMaps.containsKey(className))
{
findAndMergeSuperMaps(className);
}
return fieldNameMaps.get(className);
}
private Map<String,String> getMethodMap(String className)
{
if (!methodNameMaps.containsKey(className))
{
findAndMergeSuperMaps(className);
}
return methodNameMaps.get(className);
}
private void findAndMergeSuperMaps(String name)
{
try
{
byte[] classBytes = classLoader.getClassBytes(name);
if (classBytes == null)
{
return;
}
ClassReader cr = new ClassReader(classBytes);
String superName = cr.getSuperName();
String[] interfaces = cr.getInterfaces();
if (interfaces == null)
{
interfaces = new String[0];
}
mergeSuperMaps(name, superName, interfaces);
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void mergeSuperMaps(String name, String superName, String[] interfaces)
{
if (classNameBiMap == null || classNameBiMap.isEmpty())
{
return;
}
List<String> allParents = ImmutableList.<String>builder().add(superName).addAll(Arrays.asList(interfaces)).build();
for (String parentThing : allParents)
{
if (superName != null && classNameBiMap.containsKey(superName) && !methodNameMaps.containsKey(superName))
{
findAndMergeSuperMaps(superName);
}
}
Map<String, String> methodMap = Maps.<String,String>newHashMap();
Map<String, String> fieldMap = Maps.<String,String>newHashMap();
for (String parentThing : allParents)
{
if (methodNameMaps.containsKey(parentThing))
{
methodMap.putAll(methodNameMaps.get(parentThing));
}
if (fieldNameMaps.containsKey(parentThing))
{
fieldMap.putAll(fieldNameMaps.get(parentThing));
}
}
if (rawMethodMaps.containsKey(name))
{
methodMap.putAll(rawMethodMaps.get(name));
}
if (rawFieldMaps.containsKey(name))
{
fieldMap.putAll(rawFieldMaps.get(name));
}
methodNameMaps.put(name, ImmutableMap.copyOf(methodMap));
fieldNameMaps.put(name, ImmutableMap.copyOf(fieldMap));
}
}

View file

@ -0,0 +1,35 @@
/*
* 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.deobf;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.commons.Remapper;
import org.objectweb.asm.commons.RemappingClassAdapter;
public class FMLRemappingAdapter extends RemappingClassAdapter {
public FMLRemappingAdapter(ClassVisitor cv)
{
super(cv, FMLDeobfuscatingRemapper.INSTANCE);
}
@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces)
{
if (interfaces == null)
{
interfaces = new String[0];
}
FMLDeobfuscatingRemapper.INSTANCE.mergeSuperMaps(name, superName, interfaces);
super.visit(version, access, name, signature, superName, interfaces);
}
}

View file

@ -0,0 +1,38 @@
/*
* 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.deobf;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import com.google.common.io.InputSupplier;
public class ZipInputSupplier implements InputSupplier<InputStream> {
private ZipFile zipFile;
private ZipEntry zipEntry;
public ZipInputSupplier(ZipFile zip, ZipEntry entry)
{
this.zipFile = zip;
this.zipEntry = entry;
}
@Override
public InputStream getInput() throws IOException
{
return zipFile.getInputStream(zipEntry);
}
}

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common.discovery;
import java.util.List; import java.util.List;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common.discovery;
import java.util.List; import java.util.List;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common.discovery;
import java.io.File; import java.io.File;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common.discovery;
import java.util.List; import java.util.List;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common.discovery;
import java.util.Collections; import java.util.Collections;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common.discovery;
import java.io.File; import java.io.File;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common.discovery;
import java.io.File; import java.io.File;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common.discovery.asm;
import java.io.IOException; import java.io.IOException;
@ -116,7 +128,7 @@ public class ASMModParser
public boolean isBaseMod(List<String> rememberedTypes) public boolean isBaseMod(List<String> rememberedTypes)
{ {
return getASMSuperType().equals(Type.getType(BaseMod.class)) || rememberedTypes.contains(getASMSuperType().getClassName()); return getASMSuperType().equals(Type.getType("LBaseMod;")) || getASMSuperType().equals(Type.getType("Lnet/minecraft/src/BaseMod;"))|| rememberedTypes.contains(getASMSuperType().getClassName());
} }
public void setBaseModProperties(String foundProperties) public void setBaseModProperties(String foundProperties)

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common.discovery.asm;
import java.util.ArrayList; import java.util.ArrayList;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common.discovery.asm;
import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.AnnotationVisitor;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common.discovery.asm;
import java.util.Collections; import java.util.Collections;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common.discovery.asm;
import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.AnnotationVisitor;

View file

@ -1,3 +1,15 @@
/*
* 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; package cpw.mods.fml.common.discovery.asm;
import java.util.LinkedList; import java.util.LinkedList;

View file

@ -1,3 +1,15 @@
/*
* 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.event; package cpw.mods.fml.common.event;
import cpw.mods.fml.common.LoaderState.ModState; import cpw.mods.fml.common.LoaderState.ModState;

Some files were not shown because too many files have changed in this diff Show more