mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 11:29:15 +00:00
Separate sprite handling, fix worldtype
This commit is contained in:
1 parent
b6b5955404
commit
56e7270dee
4 files changed
+184
-110
No files matched your search
@@ -24,6 +24,7 @@ import java.util.logging.Logger;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.SpriteHelper;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer.TickType;
|
||||
@@ -39,7 +40,6 @@ public class ModLoader
|
||||
public String override;
|
||||
public int index;
|
||||
}
|
||||
private static HashMap<String, boolean[]> spriteInfo = new HashMap<String, boolean[]>();
|
||||
private static HashMap<String, ArrayList<OverrideInfo>> overrideInfo = new HashMap<String, ArrayList<OverrideInfo>>();
|
||||
|
||||
/**
|
||||
@@ -72,11 +72,11 @@ public class ModLoader
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void addAllRenderers(Map<Class<? extends Entity>, Render> renderers)
|
||||
public static void addAllRenderers(Map<Class<? extends Entity>, Render> renderers)
|
||||
{
|
||||
}
|
||||
|
||||
static void addAnimation(TextureFX anim)
|
||||
public static void addAnimation(TextureFX anim)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ public class ModLoader
|
||||
*/
|
||||
public static int addOverride(String fileToOverride, String fileToAdd)
|
||||
{
|
||||
int idx = getUniqueSpriteIndex(fileToOverride);
|
||||
int idx = SpriteHelper.getUniqueSpriteIndex(fileToOverride);
|
||||
addOverride(fileToOverride, fileToAdd, idx);
|
||||
return idx;
|
||||
}
|
||||
@@ -387,7 +387,7 @@ public class ModLoader
|
||||
return FMLCommonHandler.instance().getFMLLogger();
|
||||
}
|
||||
|
||||
static Minecraft getMinecraftInstance()
|
||||
public static Minecraft getMinecraftInstance()
|
||||
{
|
||||
return FMLClientHandler.instance().getClient();
|
||||
}
|
||||
@@ -453,93 +453,9 @@ public class ModLoader
|
||||
|
||||
public static int getUniqueSpriteIndex(String path)
|
||||
{
|
||||
boolean[] slots = spriteInfo.get(path);
|
||||
if (slots == null)
|
||||
{
|
||||
if (path.equals("/terrain.png"))
|
||||
{
|
||||
slots = toBooleanArray(
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000011111100" +
|
||||
"0000000011111111" +
|
||||
"0000000011111000" +
|
||||
"0000000111111100" +
|
||||
"0000000111111000" +
|
||||
"0000000000000000");
|
||||
spriteInfo.put("/terrain.png", slots);
|
||||
}
|
||||
else if (path.equals("/gui/items.png"))
|
||||
{
|
||||
slots = toBooleanArray(
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000001000000000" +
|
||||
"0000001110000000" +
|
||||
"0000001000000000" +
|
||||
"1111111010000000" +
|
||||
"1111111010100000" +
|
||||
"1111111111111100" +
|
||||
"1111111111111111" +
|
||||
"1111111111111111" +
|
||||
"1111111111111111" +
|
||||
"0000000000000000");
|
||||
spriteInfo.put("/gui/items.png", slots);
|
||||
}
|
||||
else
|
||||
{
|
||||
Exception ex = new Exception(String.format("Invalid getUniqueSpriteIndex call for texture: %s", path));
|
||||
Loader.log.throwing("ModLoader", "getUniqueSpriteIndex", ex);
|
||||
throwException(ex);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
int ret = getFreeSlot(slots);
|
||||
if (ret == -1)
|
||||
{
|
||||
Exception ex = new Exception(String.format("No more sprite indicies left for: %s", path));
|
||||
Loader.log.throwing("ModLoader", "getUniqueSpriteIndex", ex);
|
||||
throwException(ex);
|
||||
return 0;
|
||||
}
|
||||
return ret;
|
||||
return SpriteHelper.getUniqueSpriteIndex(path);
|
||||
}
|
||||
|
||||
private static boolean[] toBooleanArray(String data)
|
||||
{
|
||||
boolean[] ret = new boolean[data.length()];
|
||||
for (int x = 0; x < data.length(); x++)
|
||||
{
|
||||
ret[x] = data.charAt(x) == '1';
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static int getFreeSlot(boolean[] slots)
|
||||
{
|
||||
for (int x = 0; x < slots.length; x++)
|
||||
{
|
||||
if (slots[x])
|
||||
{
|
||||
slots[x] = false;
|
||||
return x;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* To properly implement packet 250 protocol you should always check your
|
||||
* channel is active prior to sending the packet
|
||||
@@ -553,7 +469,7 @@ public class ModLoader
|
||||
return FMLCommonHandler.instance().isChannelActive(channel, player);
|
||||
}
|
||||
|
||||
static boolean isGUIOpen(Class<? extends GuiScreen> gui)
|
||||
public static boolean isGUIOpen(Class<? extends GuiScreen> gui)
|
||||
{
|
||||
//TODO
|
||||
return false;
|
||||
@@ -574,11 +490,11 @@ public class ModLoader
|
||||
* Implemented elsewhere
|
||||
*/
|
||||
@Deprecated
|
||||
static void loadConfig()
|
||||
public static void loadConfig()
|
||||
{
|
||||
}
|
||||
|
||||
static BufferedImage loadImage(RenderEngine texCache, String path)
|
||||
public static BufferedImage loadImage(RenderEngine texCache, String path)
|
||||
{
|
||||
//TODO
|
||||
return null;
|
||||
@@ -590,16 +506,18 @@ public class ModLoader
|
||||
* @param item
|
||||
*/
|
||||
@Deprecated
|
||||
static void onItemPickup(EntityPlayer player, ItemStack item)
|
||||
public static void onItemPickup(EntityPlayer player, ItemStack item)
|
||||
{
|
||||
}
|
||||
/**
|
||||
* Call in from elsewhere. Unimplemented here.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void onTick(float tick, Minecraft game)
|
||||
{
|
||||
}
|
||||
|
||||
static void onTick(float tick, Minecraft game)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
static void openGUI(EntityPlayer player, GuiScreen gui)
|
||||
public static void openGUI(EntityPlayer player, GuiScreen gui)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user