Add in some more stuff for handling key bindings, rendering
This commit is contained in:
parent
0438fbd47e
commit
7846f10c74
16 changed files with 450 additions and 59 deletions
49
fml/client/cpw/mods/fml/client/BlockRenderInfo.java
Normal file
49
fml/client/cpw/mods/fml/client/BlockRenderInfo.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* 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 cpw.mods.fml.common.IBlockRenderInfo;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class BlockRenderInfo implements IBlockRenderInfo
|
||||
{
|
||||
private int renderId;
|
||||
private boolean forInventory;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public BlockRenderInfo(int renderId, boolean forInventory)
|
||||
{
|
||||
this.renderId=renderId;
|
||||
this.forInventory=forInventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId()
|
||||
{
|
||||
return renderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getInventoryRendering()
|
||||
{
|
||||
return forInventory;
|
||||
}
|
||||
|
||||
}
|
|
@ -12,13 +12,19 @@
|
|||
*/
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.BaseMod;
|
||||
import net.minecraft.src.BiomeGenBase;
|
||||
|
@ -26,21 +32,27 @@ import net.minecraft.src.ClientRegistry;
|
|||
import net.minecraft.src.CommonRegistry;
|
||||
import net.minecraft.src.EntityItem;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.GuiScreen;
|
||||
import net.minecraft.src.IChunkProvider;
|
||||
import net.minecraft.src.IInventory;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.KeyBinding;
|
||||
import net.minecraft.src.NetworkManager;
|
||||
import net.minecraft.src.Packet1Login;
|
||||
import net.minecraft.src.Packet250CustomPayload;
|
||||
import net.minecraft.src.Packet3Chat;
|
||||
import net.minecraft.src.RenderEngine;
|
||||
import net.minecraft.src.RenderPlayer;
|
||||
import net.minecraft.src.StringTranslate;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.src.WorldType;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.IFMLSidedHandler;
|
||||
import cpw.mods.fml.common.IKeyHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.ModContainer.TickType;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderHelper;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
||||
|
||||
/**
|
||||
|
@ -74,13 +86,15 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
*/
|
||||
private Minecraft client;
|
||||
|
||||
private boolean preInitializationComplete;
|
||||
|
||||
/**
|
||||
* A handy list of the default overworld biomes
|
||||
*/
|
||||
private BiomeGenBase[] defaultOverworldBiomes;
|
||||
|
||||
private int nextRenderId;
|
||||
|
||||
private static HashMap<String, ArrayList<OverrideInfo>> overrideInfo = new HashMap<String, ArrayList<OverrideInfo>>();
|
||||
|
||||
/**
|
||||
* Called to start the whole game off from
|
||||
* {@link MinecraftServer#startServer}
|
||||
|
@ -121,17 +135,28 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
FMLCommonHandler.instance().registerSidedDelegate(this);
|
||||
CommonRegistry.registerRegistry(new ClientRegistry());
|
||||
Loader.instance().loadMods();
|
||||
preInitializationComplete=true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called a bit later on during server initialization to finish loading mods
|
||||
* Called a bit later on during initialization to finish loading mods
|
||||
* Also initializes key bindings
|
||||
*
|
||||
*/
|
||||
public void onLoadComplete()
|
||||
{
|
||||
Loader.instance().initializeMods();
|
||||
client.field_6304_y.loadModKeySettings(harvestKeyBindings());
|
||||
}
|
||||
|
||||
public KeyBinding[] harvestKeyBindings() {
|
||||
List<IKeyHandler> allKeys=FMLCommonHandler.instance().gatherKeyBindings();
|
||||
KeyBinding[] keys=new KeyBinding[allKeys.size()];
|
||||
int i=0;
|
||||
for (IKeyHandler key : allKeys) {
|
||||
keys[i++]=(KeyBinding)key.getKeyBinding();
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
/**
|
||||
* Every tick just before world and other ticks occur
|
||||
*/
|
||||
|
@ -526,4 +551,79 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
{
|
||||
return StringTranslate.func_20162_a().func_44024_c();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param armor
|
||||
* @return
|
||||
*/
|
||||
public int addNewArmourRendererPrefix(String armor)
|
||||
{
|
||||
return RenderPlayer.addNewArmourPrefix(armor);
|
||||
}
|
||||
|
||||
public void addNewTextureOverride(String textureToOverride, String overridingTexturePath, int location) {
|
||||
if (!overrideInfo.containsKey(textureToOverride))
|
||||
{
|
||||
overrideInfo.put(textureToOverride, new ArrayList<OverrideInfo>());
|
||||
}
|
||||
ArrayList<OverrideInfo> list = overrideInfo.get(textureToOverride);
|
||||
OverrideInfo info = new OverrideInfo();
|
||||
info.index = location;
|
||||
info.override = overridingTexturePath;
|
||||
info.texture = textureToOverride;
|
||||
list.add(info);
|
||||
}
|
||||
/**
|
||||
* @param mod
|
||||
* @param inventoryRenderer
|
||||
* @return
|
||||
*/
|
||||
public int obtainBlockModelIdFor(BaseMod mod, boolean inventoryRenderer)
|
||||
{
|
||||
ModLoaderModContainer mlmc=ModLoaderHelper.registerRenderHelper(mod);
|
||||
int renderId=nextRenderId++;
|
||||
mlmc.addRenderHandler(new BlockRenderInfo(renderId, inventoryRenderer));
|
||||
return renderId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param renderEngine
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
public BufferedImage loadImageFromTexturePack(RenderEngine renderEngine, String path) throws IOException
|
||||
{
|
||||
InputStream image=renderEngine.getTexturePackList().field_6534_a.func_6481_a(path);
|
||||
if (image==null) {
|
||||
throw new RuntimeException(String.format("The requested image path %s is not found",path));
|
||||
}
|
||||
BufferedImage result=ImageIO.read(image);
|
||||
if (result==null)
|
||||
{
|
||||
throw new RuntimeException(String.format("The requested image path %s appears to be corrupted",path));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param gui
|
||||
*/
|
||||
public void displayGuiScreen(EntityPlayer player, GuiScreen gui)
|
||||
{
|
||||
if (client.field_22009_h==player && gui != null) {
|
||||
client.func_6272_a(gui);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mod
|
||||
* @param keyHandler
|
||||
* @param allowRepeat
|
||||
*/
|
||||
public void registerKeyHandler(BaseMod mod, KeyBinding keyHandler, boolean allowRepeat)
|
||||
{
|
||||
ModLoaderModContainer mlmc=ModLoaderHelper.registerKeyHelper(mod);
|
||||
mlmc.addKeyHandler(new KeyBindingHandler(keyHandler, allowRepeat));
|
||||
}
|
||||
}
|
||||
|
|
46
fml/client/cpw/mods/fml/client/KeyBindingHandler.java
Normal file
46
fml/client/cpw/mods/fml/client/KeyBindingHandler.java
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* 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.src.KeyBinding;
|
||||
import cpw.mods.fml.common.IKeyHandler;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class KeyBindingHandler implements IKeyHandler
|
||||
{
|
||||
|
||||
private boolean shouldRepeat;
|
||||
private KeyBinding keyBinding;
|
||||
|
||||
/**
|
||||
* @param keyHandler
|
||||
* @param allowRepeat
|
||||
*/
|
||||
public KeyBindingHandler(KeyBinding keyHandler, boolean allowRepeat)
|
||||
{
|
||||
this.keyBinding=keyHandler;
|
||||
this.shouldRepeat=allowRepeat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKeyBinding()
|
||||
{
|
||||
return this.keyBinding;
|
||||
}
|
||||
|
||||
}
|
22
fml/client/cpw/mods/fml/client/OverrideInfo.java
Normal file
22
fml/client/cpw/mods/fml/client/OverrideInfo.java
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
class OverrideInfo
|
||||
{
|
||||
public String texture;
|
||||
public String override;
|
||||
public int index;
|
||||
}
|
|
@ -84,13 +84,13 @@ public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDisp
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerLogout(Object player)
|
||||
public final void onPlayerLogout(Object player)
|
||||
{
|
||||
onClientLogout((EntityPlayer) player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerChangedDimension(Object player)
|
||||
public final void onPlayerChangedDimension(Object player)
|
||||
{
|
||||
onClientDimensionChanged((EntityPlayer) player);
|
||||
}
|
||||
|
|
|
@ -14,9 +14,7 @@ package net.minecraft.src;
|
|||
*/
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -34,14 +32,6 @@ import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
|||
|
||||
public class ModLoader
|
||||
{
|
||||
private static class OverrideInfo
|
||||
{
|
||||
public String texture;
|
||||
public String override;
|
||||
public int index;
|
||||
}
|
||||
private static HashMap<String, ArrayList<OverrideInfo>> overrideInfo = new HashMap<String, ArrayList<OverrideInfo>>();
|
||||
|
||||
/**
|
||||
* Not used on the server.
|
||||
*
|
||||
|
@ -88,8 +78,7 @@ public class ModLoader
|
|||
*/
|
||||
public static int addArmor(String armor)
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
return FMLClientHandler.instance().addNewArmourRendererPrefix(armor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -183,16 +172,7 @@ public class ModLoader
|
|||
*/
|
||||
public static void addOverride(String path, String overlayPath, int index)
|
||||
{
|
||||
if (!overrideInfo.containsKey(path))
|
||||
{
|
||||
overrideInfo.put(path, new ArrayList<OverrideInfo>());
|
||||
}
|
||||
ArrayList<OverrideInfo> list = overrideInfo.get(path);
|
||||
OverrideInfo info = new OverrideInfo();
|
||||
info.index = index;
|
||||
info.override = overlayPath;
|
||||
info.texture = path;
|
||||
list.add(info);
|
||||
FMLClientHandler.instance().addNewTextureOverride(path, overlayPath, index);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -435,10 +415,9 @@ public class ModLoader
|
|||
* Stubbed method on the server to return a unique model id
|
||||
*
|
||||
*/
|
||||
public static int getUniqueBlockModelID(BaseMod mod, boolean flag)
|
||||
public static int getUniqueBlockModelID(BaseMod mod, boolean inventoryRenderer)
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
return FMLClientHandler.instance().obtainBlockModelIdFor(mod, inventoryRenderer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -471,8 +450,7 @@ public class ModLoader
|
|||
|
||||
public static boolean isGUIOpen(Class<? extends GuiScreen> gui)
|
||||
{
|
||||
//TODO
|
||||
return false;
|
||||
return FMLClientHandler.instance().getClient().field_6313_p!=null && FMLClientHandler.instance().getClient().field_6313_p.equals(gui);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -494,10 +472,9 @@ public class ModLoader
|
|||
{
|
||||
}
|
||||
|
||||
public static BufferedImage loadImage(RenderEngine texCache, String path)
|
||||
public static BufferedImage loadImage(RenderEngine renderEngine, String path) throws Exception
|
||||
{
|
||||
//TODO
|
||||
return null;
|
||||
return FMLClientHandler.instance().loadImageFromTexturePack(renderEngine, path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -519,7 +496,7 @@ public class ModLoader
|
|||
|
||||
public static void openGUI(EntityPlayer player, GuiScreen gui)
|
||||
{
|
||||
//TODO
|
||||
FMLClientHandler.instance().displayGuiScreen(player, gui);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
@ -539,15 +516,15 @@ public class ModLoader
|
|||
{
|
||||
}
|
||||
|
||||
static KeyBinding[] registerAllKeys(KeyBinding[] keys)
|
||||
@Deprecated
|
||||
public static KeyBinding[] registerAllKeys(KeyBinding[] keys)
|
||||
{
|
||||
//TODO
|
||||
return keys;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
static void registerAllTextureOverrides(RenderEngine cache)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -597,9 +574,9 @@ public class ModLoader
|
|||
CommonRegistry.registerEntityID(entityClass, entityName, id, background, foreground);
|
||||
}
|
||||
|
||||
static void registerKey(BaseMod mod, KeyBinding keyHandler, boolean allowRepeat)
|
||||
public static void registerKey(BaseMod mod, KeyBinding keyHandler, boolean allowRepeat)
|
||||
{
|
||||
//TODO
|
||||
FMLClientHandler.instance().registerKeyHandler(mod, keyHandler, allowRepeat);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -116,6 +116,19 @@ public class FMLCommonHandler
|
|||
mod.tickEnd(type, data);
|
||||
}
|
||||
}
|
||||
|
||||
public List<IKeyHandler> gatherKeyBindings() {
|
||||
List<IKeyHandler> allKeys=new ArrayList<IKeyHandler>();
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
allKeys.addAll(mod.getKeys());
|
||||
}
|
||||
for (ModContainer mod : extraTickers)
|
||||
{
|
||||
allKeys.addAll(mod.getKeys());
|
||||
}
|
||||
return allKeys;
|
||||
}
|
||||
/**
|
||||
* @return the instance
|
||||
*/
|
||||
|
|
|
@ -306,4 +306,13 @@ public class FMLModContainer implements ModContainer
|
|||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#getKeys()
|
||||
*/
|
||||
@Override
|
||||
public List<IKeyHandler> getKeys()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
25
fml/common/cpw/mods/fml/common/IBlockRenderInfo.java
Normal file
25
fml/common/cpw/mods/fml/common/IBlockRenderInfo.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public interface IBlockRenderInfo
|
||||
{
|
||||
public int getRenderId();
|
||||
public boolean getInventoryRendering();
|
||||
}
|
26
fml/common/cpw/mods/fml/common/IKeyHandler.java
Normal file
26
fml/common/cpw/mods/fml/common/IKeyHandler.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public interface IKeyHandler
|
||||
{
|
||||
|
||||
Object getKeyBinding();
|
||||
|
||||
}
|
|
@ -173,4 +173,6 @@ public interface ModContainer
|
|||
public enum TickType {
|
||||
WORLD, RENDER, GUI, WORLDGUI;
|
||||
}
|
||||
|
||||
List<IKeyHandler> getKeys();
|
||||
}
|
||||
|
|
|
@ -28,18 +28,11 @@ import cpw.mods.fml.common.ModContainer.TickType;
|
|||
*/
|
||||
public class ModLoaderHelper
|
||||
{
|
||||
private static Map<BaseMod, ModLoaderModContainer> tickers=new HashMap<BaseMod, ModLoaderModContainer>();
|
||||
private static Map<BaseMod, ModLoaderModContainer> notModCallbacks=new HashMap<BaseMod, ModLoaderModContainer>();
|
||||
|
||||
public static void updateStandardTicks(BaseMod mod, boolean enable, boolean useClock)
|
||||
{
|
||||
ModLoaderModContainer mlmc=(ModLoaderModContainer) ModLoaderModContainer.findContainerFor(mod);
|
||||
if (mlmc==null) {
|
||||
mlmc=tickers.get(mod);
|
||||
if (mlmc==null) {
|
||||
mlmc=new ModLoaderModContainer(mod);
|
||||
tickers.put(mod, mlmc);
|
||||
}
|
||||
}
|
||||
ModLoaderModContainer mlmc = findOrBuildModContainer(mod);
|
||||
EnumSet<TickType> ticks = mlmc.getTickTypes();
|
||||
// If we're enabled and we don't want clock ticks we get render ticks
|
||||
if (enable && !useClock && FMLCommonHandler.instance().isClient()) {
|
||||
|
@ -57,14 +50,7 @@ public class ModLoaderHelper
|
|||
|
||||
public static void updateGUITicks(BaseMod mod, boolean enable, boolean useClock)
|
||||
{
|
||||
ModLoaderModContainer mlmc=(ModLoaderModContainer) ModLoaderModContainer.findContainerFor(mod);
|
||||
if (mlmc==null) {
|
||||
mlmc=tickers.get(mod);
|
||||
if (mlmc==null) {
|
||||
mlmc=new ModLoaderModContainer(mod);
|
||||
tickers.put(mod, mlmc);
|
||||
}
|
||||
}
|
||||
ModLoaderModContainer mlmc = findOrBuildModContainer(mod);
|
||||
EnumSet<TickType> ticks = mlmc.getTickTypes();
|
||||
// If we're enabled and we don't want clock ticks we get render ticks
|
||||
if (enable && !useClock && FMLCommonHandler.instance().isClient()) {
|
||||
|
@ -79,4 +65,36 @@ public class ModLoaderHelper
|
|||
ticks.remove(TickType.WORLDGUI);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mod
|
||||
* @return
|
||||
*/
|
||||
private static ModLoaderModContainer findOrBuildModContainer(BaseMod mod)
|
||||
{
|
||||
ModLoaderModContainer mlmc=(ModLoaderModContainer) ModLoaderModContainer.findContainerFor(mod);
|
||||
if (mlmc==null) {
|
||||
mlmc=notModCallbacks.get(mod);
|
||||
if (mlmc==null) {
|
||||
mlmc=new ModLoaderModContainer(mod);
|
||||
notModCallbacks.put(mod, mlmc);
|
||||
}
|
||||
}
|
||||
return mlmc;
|
||||
}
|
||||
|
||||
public static ModLoaderModContainer registerRenderHelper(BaseMod mod) {
|
||||
ModLoaderModContainer mlmc=findOrBuildModContainer(mod);
|
||||
return mlmc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mod
|
||||
* @return
|
||||
*/
|
||||
public static ModLoaderModContainer registerKeyHelper(BaseMod mod)
|
||||
{
|
||||
ModLoaderModContainer mlmc=findOrBuildModContainer(mod);
|
||||
return mlmc;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.io.FileWriter;
|
|||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.AbstractCollection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
|
@ -33,9 +34,11 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
|||
import cpw.mods.fml.common.IConsoleHandler;
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
import cpw.mods.fml.common.IDispenseHandler;
|
||||
import cpw.mods.fml.common.IKeyHandler;
|
||||
import cpw.mods.fml.common.INetworkHandler;
|
||||
import cpw.mods.fml.common.IPickupNotifier;
|
||||
import cpw.mods.fml.common.IPlayerTracker;
|
||||
import cpw.mods.fml.common.IBlockRenderInfo;
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.LoaderException;
|
||||
|
@ -51,6 +54,9 @@ public class ModLoaderModContainer implements ModContainer
|
|||
private ArrayList<String> dependencies;
|
||||
private ArrayList<String> preDependencies;
|
||||
private ArrayList<String> postDependencies;
|
||||
private ArrayList<IBlockRenderInfo> blockRenderInfos;
|
||||
private ArrayList<IKeyHandler> keyHandlers;
|
||||
|
||||
public ModLoaderModContainer(Class <? extends BaseMod > modClazz, File modSource)
|
||||
{
|
||||
this.modClazz = modClazz;
|
||||
|
@ -551,4 +557,28 @@ public class ModLoaderModContainer implements ModContainer
|
|||
{
|
||||
return ticks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param renderId
|
||||
* @param inventoryRenderer
|
||||
*/
|
||||
public void addRenderHandler(IBlockRenderInfo handler)
|
||||
{
|
||||
blockRenderInfos.add(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param keyHandler
|
||||
* @param allowRepeat
|
||||
*/
|
||||
public void addKeyHandler(IKeyHandler handler)
|
||||
{
|
||||
keyHandlers.add(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IKeyHandler> getKeys()
|
||||
{
|
||||
return keyHandlers;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
--- ../src-base/minecraft/net/minecraft/src/GameSettings.java 0000-00-00 00:00:00.000000000 -0000
|
||||
+++ ../src-work/minecraft/net/minecraft/src/GameSettings.java 0000-00-00 00:00:00.000000000 -0000
|
||||
@@ -5,6 +5,9 @@
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.PrintWriter;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.List;
|
||||
+
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
@@ -477,4 +480,18 @@
|
||||
{
|
||||
return this.field_1580_e < 2 && this.field_40445_l;
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
+ * @param harvestKeyBindings
|
||||
+ */
|
||||
+ public void loadModKeySettings(KeyBinding[] modKeyBindings)
|
||||
+ {
|
||||
+ KeyBinding[] allKeys=new KeyBinding[field_1564_t.length+modKeyBindings.length];
|
||||
+ System.arraycopy(field_1564_t, 0, allKeys, 0, field_1564_t.length);
|
||||
+ System.arraycopy(modKeyBindings, 0, allKeys, field_1564_t.length, modKeyBindings.length);
|
||||
+ field_1564_t=allKeys;
|
||||
+
|
||||
+ // Reload settings with mod keys in place
|
||||
+ func_6519_a();
|
||||
+ }
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
--- ../src-base/minecraft/net/minecraft/src/RenderEngine.java 0000-00-00 00:00:00.000000000 -0000
|
||||
+++ ../src-work/minecraft/net/minecraft/src/RenderEngine.java 0000-00-00 00:00:00.000000000 -0000
|
||||
@@ -635,4 +635,8 @@
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, p_1076_1_);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ public TexturePackList getTexturePackList() {
|
||||
+ return field_6527_k;
|
||||
+ }
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
--- ../src-base/minecraft/net/minecraft/src/RenderPlayer.java 0000-00-00 00:00:00.000000000 -0000
|
||||
+++ ../src-work/minecraft/net/minecraft/src/RenderPlayer.java 0000-00-00 00:00:00.000000000 -0000
|
||||
@@ -1,5 +1,8 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
+import java.util.Arrays;
|
||||
+import java.util.List;
|
||||
+
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -8,7 +11,7 @@
|
||||
private ModelBiped field_209_f;
|
||||
private ModelBiped field_208_g;
|
||||
private ModelBiped field_207_h;
|
||||
- private static final String[] field_206_i = new String[] {"cloth", "chain", "iron", "diamond", "gold"};
|
||||
+ private static String[] field_206_i = new String[] {"cloth", "chain", "iron", "diamond", "gold"};
|
||||
|
||||
public RenderPlayer()
|
||||
{
|
||||
@@ -407,4 +410,11 @@
|
||||
{
|
||||
this.func_188_a((EntityPlayer)p_147_1_, p_147_2_, p_147_4_, p_147_6_, p_147_8_, p_147_9_);
|
||||
}
|
||||
+
|
||||
+ public static int addNewArmourPrefix(String prefix) {
|
||||
+ List<String> armours=Arrays.asList(field_206_i);
|
||||
+ armours.add(prefix);
|
||||
+ field_206_i=armours.toArray(new String[0]);
|
||||
+ return armours.indexOf(prefix);
|
||||
+ }
|
||||
}
|
Loading…
Reference in a new issue