A lot of missing patches to code re-added. Almost all functionality should now
be restored. ModLoader compatibility is not yet assured, there are some wrapper classes that need re-writing first
This commit is contained in:
parent
fcd4a8e854
commit
5e7cb9106d
|
@ -1,81 +0,0 @@
|
|||
package cpw.mods.fml.client;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import cpw.mods.fml.common.modloader.ModLoaderHelper;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
||||
|
||||
import net.minecraft.src.BaseMod;
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.IBlockAccess;
|
||||
import net.minecraft.src.RenderBlocks;
|
||||
|
||||
public class BlockRenderManager
|
||||
{
|
||||
private static final BlockRenderManager INSTANCE = new BlockRenderManager();
|
||||
|
||||
private HashMap<Integer, BlockRenderInfo> blockModelIds = new HashMap<Integer, BlockRenderInfo>();
|
||||
|
||||
private int nextRenderId = 30;
|
||||
|
||||
public static BlockRenderManager instance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param renderer
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param block
|
||||
* @param modelId
|
||||
* @return
|
||||
*/
|
||||
public boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelId)
|
||||
{
|
||||
if (!blockModelIds.containsKey(modelId)) { return false; }
|
||||
BlockRenderInfo bri = blockModelIds.get(modelId);
|
||||
return bri.renderWorldBlock(world, x, y, z, block, modelId, renderer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param renderer
|
||||
* @param block
|
||||
* @param metadata
|
||||
* @param modelID
|
||||
*/
|
||||
public void renderInventoryBlock(RenderBlocks renderer, Block block, int metadata, int modelID)
|
||||
{
|
||||
if (!blockModelIds.containsKey(modelID)) { return; }
|
||||
BlockRenderInfo bri = blockModelIds.get(modelID);
|
||||
bri.renderInventoryBlock(block, metadata, modelID, renderer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param p_1219_0_
|
||||
* @return
|
||||
*/
|
||||
public boolean renderItemAsFull3DBlock(int modelId)
|
||||
{
|
||||
BlockRenderInfo bri = blockModelIds.get(modelId);
|
||||
if (bri != null) { return bri.shouldRender3DInInventory(); }
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param mod
|
||||
* @param inventoryRenderer
|
||||
* @return
|
||||
*/
|
||||
public int obtainBlockModelIdFor(BaseMod mod, boolean inventoryRenderer)
|
||||
{
|
||||
ModLoaderModContainer mlmc=ModLoaderHelper.registerRenderHelper(mod);
|
||||
int renderId=nextRenderId++;
|
||||
BlockRenderInfo bri=new BlockRenderInfo(renderId, inventoryRenderer, mlmc);
|
||||
blockModelIds.put(renderId, bri);
|
||||
return renderId;
|
||||
}
|
||||
}
|
|
@ -88,6 +88,7 @@ import argo.jdom.JdomParser;
|
|||
import argo.jdom.JsonNode;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.DummyModContainer;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.FMLDummyContainer;
|
||||
|
@ -145,8 +146,6 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
private Minecraft client;
|
||||
|
||||
|
||||
private TexturePackBase fallbackTexturePack;
|
||||
|
||||
private boolean firstTick;
|
||||
/**
|
||||
* Called to start the whole game off from
|
||||
|
@ -220,6 +219,8 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
haltGame("There was a severe problem during mod loading that has caused the game to fail", le);
|
||||
return;
|
||||
}
|
||||
RenderingRegistry.instance().loadEntityRenderers((Map<Class<? extends Entity>, Render>)RenderManager.field_78727_a.field_78729_o);
|
||||
|
||||
// TODO
|
||||
// for (ModContainer mod : Loader.getModList()) {
|
||||
// mod.gatherRenderers(RenderManager.field_1233_a.getRendererList());
|
||||
|
@ -232,28 +233,6 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
// Mark this as a "first tick"
|
||||
firstTick = true;
|
||||
}
|
||||
|
||||
public void onRenderTickStart(float partialTickTime)
|
||||
{
|
||||
if (firstTick)
|
||||
{
|
||||
// TODO
|
||||
// loadTextures(fallbackTexturePack);
|
||||
firstTick = false;
|
||||
}
|
||||
FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.RENDER,TickType.GUI), partialTickTime, client.field_71462_r);
|
||||
}
|
||||
|
||||
public void onRenderTickEnd(float partialTickTime)
|
||||
{
|
||||
if (!guiLoaded)
|
||||
{
|
||||
FMLCommonHandler.instance().rescheduleTicks();
|
||||
FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.GUILOAD), partialTickTime, client.field_71462_r);
|
||||
guiLoaded = true;
|
||||
}
|
||||
FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.RENDER,TickType.GUI), partialTickTime, client.field_71462_r);
|
||||
}
|
||||
/**
|
||||
* Get the server instance
|
||||
*
|
||||
|
@ -345,7 +324,7 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
public Entity spawnEntityIntoClientWorld(Class<? extends Entity> cls, EntitySpawnPacket packet)
|
||||
{
|
||||
WorldClient wc = client.field_71441_e;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
Entity entity = (Entity)(cls.getConstructor(World.class).newInstance(wc));
|
||||
|
@ -371,12 +350,12 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
|
||||
entity.field_70157_k = packet.entityId;
|
||||
entity.func_70056_a(packet.scaledX, packet.scaledY, packet.scaledZ, packet.scaledYaw, packet.scaledPitch, 1);
|
||||
|
||||
|
||||
if (entity instanceof EntityLiving)
|
||||
{
|
||||
((EntityLiving)entity).field_70759_as = packet.scaledHeadYaw;
|
||||
}
|
||||
|
||||
|
||||
if (packet.metadata != null)
|
||||
{
|
||||
entity.func_70096_w().func_75687_a((List)packet.metadata);
|
||||
|
|
|
@ -12,12 +12,13 @@
|
|||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.client;
|
||||
package cpw.mods.fml.client.modloader;
|
||||
|
||||
import net.minecraft.src.BaseMod;
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.IBlockAccess;
|
||||
import net.minecraft.src.RenderBlocks;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
||||
|
||||
|
@ -25,28 +26,30 @@ import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
|||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class BlockRenderInfo
|
||||
public class ModLoaderBlockRendererHandler implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
private int renderId;
|
||||
private boolean render3dInInventory;
|
||||
private ModContainer modContainer;
|
||||
private BaseMod mod;
|
||||
|
||||
/**
|
||||
* @param modContainer
|
||||
*
|
||||
* @param mod
|
||||
*
|
||||
*/
|
||||
public BlockRenderInfo(int renderId, boolean render3dInInventory, ModContainer modContainer)
|
||||
public ModLoaderBlockRendererHandler(int renderId, boolean render3dInInventory, BaseMod mod)
|
||||
{
|
||||
this.renderId=renderId;
|
||||
this.render3dInInventory=render3dInInventory;
|
||||
this.modContainer=modContainer;
|
||||
this.mod=mod;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getRenderId()
|
||||
{
|
||||
return renderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory()
|
||||
{
|
||||
return render3dInInventory;
|
||||
|
@ -61,9 +64,10 @@ public class BlockRenderInfo
|
|||
* @param modelId
|
||||
* @param renderer
|
||||
*/
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
|
||||
{
|
||||
return ((BaseMod)modContainer.getMod()).renderWorldBlock(renderer, world, x, y, z, block, modelId);
|
||||
return mod.renderWorldBlock(renderer, world, x, y, z, block, modelId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,9 +76,10 @@ public class BlockRenderInfo
|
|||
* @param modelID
|
||||
* @param renderer
|
||||
*/
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
((BaseMod)modContainer.getMod()).renderInvBlock(renderer, block, metadata, modelID);
|
||||
mod.renderInvBlock(renderer, block, metadata, modelID);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package cpw.mods.fml.client.modloader;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.BaseMod;
|
||||
import net.minecraft.src.Entity;
|
||||
import net.minecraft.src.Render;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderHelper;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
||||
|
||||
public class ModLoaderClientHelper
|
||||
{
|
||||
|
||||
/**
|
||||
* @param mod
|
||||
* @param inventoryRenderer
|
||||
* @return
|
||||
*/
|
||||
public static int obtainBlockModelIdFor(BaseMod mod, boolean inventoryRenderer)
|
||||
{
|
||||
int renderId=RenderingRegistry.instance().getNextAvailableRenderId();
|
||||
ModLoaderBlockRendererHandler bri=new ModLoaderBlockRendererHandler(renderId, inventoryRenderer, mod);
|
||||
RenderingRegistry.instance().registerBlockHandler(bri);
|
||||
return renderId;
|
||||
}
|
||||
|
||||
|
||||
public static void handleFinishLoadingFor(ModLoaderModContainer mc, Minecraft game)
|
||||
{
|
||||
BaseMod mod = (BaseMod) mc.getMod();
|
||||
|
||||
Map<Class<? extends Entity>, Render> renderers = Maps.newHashMap();
|
||||
|
||||
mod.addRenderer(renderers);
|
||||
|
||||
for (Entry<Class<? extends Entity>, Render> e : renderers.entrySet())
|
||||
{
|
||||
RenderingRegistry.instance().registerEntityRenderingHandler(e.getKey(), e.getValue());
|
||||
}
|
||||
|
||||
mod.registerAnimation(game);
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@
|
|||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.client;
|
||||
package cpw.mods.fml.client.modloader;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class ModLoaderKeyBindingHandler extends KeyBindingRegistry.KeyHandler
|
|||
return;
|
||||
}
|
||||
upArmed = false;
|
||||
if (type.contains(TickType.GUILOAD)|| type.contains(TickType.GAME))
|
||||
if (type.contains(TickType.CLIENT))
|
||||
{
|
||||
downArmed = true;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ public class ModLoaderKeyBindingHandler extends KeyBindingRegistry.KeyHandler
|
|||
return;
|
||||
}
|
||||
downArmed = false;
|
||||
if (type.contains(TickType.GUILOAD)|| type.contains(TickType.GAME))
|
||||
if (type.contains(TickType.CLIENT))
|
||||
{
|
||||
upArmed = true;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public class ModLoaderKeyBindingHandler extends KeyBindingRegistry.KeyHandler
|
|||
@Override
|
||||
public EnumSet<TickType> ticks()
|
||||
{
|
||||
return EnumSet.of(TickType.GAME, TickType.RENDER, TickType.GUILOAD);
|
||||
return EnumSet.of(TickType.CLIENT, TickType.RENDER);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -0,0 +1,16 @@
|
|||
package cpw.mods.fml.client.registry;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.IBlockAccess;
|
||||
import net.minecraft.src.RenderBlocks;
|
||||
|
||||
public interface ISimpleBlockRenderingHandler
|
||||
{
|
||||
public abstract void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer);
|
||||
|
||||
public abstract boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer);
|
||||
|
||||
public abstract boolean shouldRender3DInInventory();
|
||||
|
||||
public abstract int getRenderId();
|
||||
}
|
|
@ -13,6 +13,7 @@ import net.minecraft.src.GameSettings;
|
|||
import net.minecraft.src.KeyBinding;
|
||||
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.Side;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.common.registry.TickRegistry;
|
||||
|
||||
|
@ -73,6 +74,7 @@ public class KeyBindingRegistry
|
|||
|
||||
public static void registerKeyBinding(KeyHandler handler) {
|
||||
keyHandlers.add(handler);
|
||||
TickRegistry.registerTickHandler(handler, Side.CLIENT);
|
||||
}
|
||||
|
||||
public static void uploadKeyBindingsToGame(GameSettings settings)
|
||||
|
|
|
@ -1,18 +1,113 @@
|
|||
package cpw.mods.fml.client.registry;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.ObjectArrays;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.Entity;
|
||||
import net.minecraft.src.IBlockAccess;
|
||||
import net.minecraft.src.Render;
|
||||
import net.minecraft.src.RenderBlocks;
|
||||
import net.minecraft.src.RenderPlayer;
|
||||
import cpw.mods.fml.client.modloader.ModLoaderBlockRendererHandler;
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
|
||||
public class RenderingRegistry
|
||||
{
|
||||
public static int addNewArmourRendererPrefix(String armor)
|
||||
private static final RenderingRegistry INSTANCE = new RenderingRegistry();
|
||||
|
||||
private int nextRenderId = 30;
|
||||
|
||||
private Map<Integer, ISimpleBlockRenderingHandler> blockRenderers = Maps.newHashMap();
|
||||
|
||||
private List<EntityRendererInfo> entityRenderers = Lists.newArrayList();
|
||||
|
||||
public int addNewArmourRendererPrefix(String armor)
|
||||
{
|
||||
RenderPlayer.field_77110_j = ObjectArrays.concat(RenderPlayer.field_77110_j, armor);
|
||||
return RenderPlayer.field_77110_j.length-1;
|
||||
return RenderPlayer.field_77110_j.length - 1;
|
||||
}
|
||||
|
||||
public static RenderingRegistry instance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private class EntityRendererInfo
|
||||
{
|
||||
public EntityRendererInfo(Class<? extends Entity> target, Render renderer)
|
||||
{
|
||||
this.target = target;
|
||||
this.renderer = renderer;
|
||||
}
|
||||
private Class<? extends Entity> target;
|
||||
private Render renderer;
|
||||
}
|
||||
|
||||
public void registerEntityRenderingHandler(Class<? extends Entity> entityClass, Render renderer)
|
||||
{
|
||||
entityRenderers.add(new EntityRendererInfo(entityClass, renderer));
|
||||
}
|
||||
|
||||
public void registerBlockHandler(ISimpleBlockRenderingHandler handler)
|
||||
{
|
||||
blockRenderers.put(handler.getRenderId(), handler);
|
||||
}
|
||||
|
||||
public int getNextAvailableRenderId()
|
||||
{
|
||||
return nextRenderId++;
|
||||
}
|
||||
/**
|
||||
* @param renderer
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param block
|
||||
* @param modelId
|
||||
* @return
|
||||
*/
|
||||
public boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelId)
|
||||
{
|
||||
if (!blockRenderers.containsKey(modelId)) { return false; }
|
||||
ISimpleBlockRenderingHandler bri = blockRenderers.get(modelId);
|
||||
return bri.renderWorldBlock(world, x, y, z, block, modelId, renderer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param renderer
|
||||
* @param block
|
||||
* @param metadata
|
||||
* @param modelID
|
||||
*/
|
||||
public void renderInventoryBlock(RenderBlocks renderer, Block block, int metadata, int modelID)
|
||||
{
|
||||
if (!blockRenderers.containsKey(modelID)) { return; }
|
||||
ISimpleBlockRenderingHandler bri = blockRenderers.get(modelID);
|
||||
bri.renderInventoryBlock(block, metadata, modelID, renderer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param p_1219_0_
|
||||
* @return
|
||||
*/
|
||||
public boolean renderItemAsFull3DBlock(int modelId)
|
||||
{
|
||||
ISimpleBlockRenderingHandler bri = blockRenderers.get(modelId);
|
||||
return bri != null && bri.shouldRender3DInInventory();
|
||||
}
|
||||
|
||||
public void loadEntityRenderers(Map<Class<? extends Entity>, Render> rendererMap)
|
||||
{
|
||||
for (EntityRendererInfo info : entityRenderers)
|
||||
{
|
||||
rendererMap.put(info.target, info.renderer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseModPr
|
|||
Minecraft mc = FMLClientHandler.instance().getClient();
|
||||
boolean hasWorld = true;
|
||||
// World and render ticks
|
||||
if (tickEnd && ( tick==TickType.RENDER || tick==TickType.GAME ) && hasWorld) {
|
||||
if (tickEnd && ( tick==TickType.RENDER || tick==TickType.CLIENT ) && hasWorld) {
|
||||
return onTickInGame((Float) data[0], mc);
|
||||
}
|
||||
return true;
|
||||
|
@ -44,7 +44,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseModPr
|
|||
public final boolean doTickInGUI(TickType tick, boolean tickEnd, Object... data)
|
||||
{
|
||||
Minecraft mc = FMLClientHandler.instance().getClient();
|
||||
if (tickEnd && ( tick==TickType.RENDER || tick==TickType.GAME ) || tick == TickType.GUILOAD) {
|
||||
if (tickEnd && ( tick==TickType.RENDER || tick==TickType.CLIENT)) {
|
||||
return onTickInGUI((Float) data[0], mc, mc.field_71462_r);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -19,9 +19,9 @@ import java.util.List;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import cpw.mods.fml.client.BlockRenderManager;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.TextureFXManager;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
|
@ -76,16 +76,16 @@ public class FMLRenderAccessLibrary
|
|||
|
||||
public static boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelId)
|
||||
{
|
||||
return BlockRenderManager.instance().renderWorldBlock(renderer, world, x, y, z, block, modelId);
|
||||
return RenderingRegistry.instance().renderWorldBlock(renderer, world, x, y, z, block, modelId);
|
||||
}
|
||||
|
||||
public static void renderInventoryBlock(RenderBlocks renderer, Block block, int metadata, int modelID)
|
||||
{
|
||||
BlockRenderManager.instance().renderInventoryBlock(renderer, block, metadata, modelID);
|
||||
RenderingRegistry.instance().renderInventoryBlock(renderer, block, metadata, modelID);
|
||||
}
|
||||
|
||||
public static boolean renderItemAsFull3DBlock(int modelId)
|
||||
{
|
||||
return BlockRenderManager.instance().renderItemAsFull3DBlock(modelId);
|
||||
return RenderingRegistry.instance().renderItemAsFull3DBlock(modelId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,11 +23,11 @@ import java.util.logging.Logger;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
import cpw.mods.fml.client.BlockRenderManager;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.ModLoaderKeyBindingHandler;
|
||||
import cpw.mods.fml.client.SpriteHelper;
|
||||
import cpw.mods.fml.client.TextureFXManager;
|
||||
import cpw.mods.fml.client.modloader.ModLoaderClientHelper;
|
||||
import cpw.mods.fml.client.modloader.ModLoaderKeyBindingHandler;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
@ -96,7 +96,7 @@ public class ModLoader
|
|||
*/
|
||||
public static int addArmor(String armor)
|
||||
{
|
||||
return RenderingRegistry.addNewArmourRendererPrefix(armor);
|
||||
return RenderingRegistry.instance().addNewArmourRendererPrefix(armor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -420,7 +420,7 @@ public class ModLoader
|
|||
*/
|
||||
public static int getUniqueBlockModelID(BaseMod mod, boolean inventoryRenderer)
|
||||
{
|
||||
return BlockRenderManager.instance().obtainBlockModelIdFor(mod, inventoryRenderer);
|
||||
return ModLoaderClientHelper.obtainBlockModelIdFor(mod, inventoryRenderer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -673,19 +673,19 @@ public class ModLoader
|
|||
@Deprecated
|
||||
public static boolean renderBlockIsItemFull3D(int modelID)
|
||||
{
|
||||
return BlockRenderManager.instance().renderItemAsFull3DBlock(modelID);
|
||||
return RenderingRegistry.instance().renderItemAsFull3DBlock(modelID);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void renderInvBlock(RenderBlocks renderer, Block block, int metadata, int modelID)
|
||||
{
|
||||
BlockRenderManager.instance().renderInventoryBlock(renderer, block, metadata, modelID);
|
||||
RenderingRegistry.instance().renderInventoryBlock(renderer, block, metadata, modelID);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID)
|
||||
{
|
||||
return BlockRenderManager.instance().renderWorldBlock(renderer, world, x, y, z, block, modelID);
|
||||
return RenderingRegistry.instance().renderWorldBlock(renderer, world, x, y, z, block, modelID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -77,9 +77,8 @@ public class FMLCommonHandler
|
|||
*/
|
||||
private IFMLSidedHandler sidedDelegate;
|
||||
|
||||
private int uniqueEntityListId = 220;
|
||||
|
||||
private List<IScheduledTickHandler> scheduledTicks = new ArrayList<IScheduledTickHandler>();
|
||||
private List<IScheduledTickHandler> scheduledClientTicks = Lists.newArrayList();
|
||||
private List<IScheduledTickHandler> scheduledServerTicks = Lists.newArrayList();
|
||||
|
||||
public void beginLoading(IFMLSidedHandler handler)
|
||||
{
|
||||
|
@ -89,14 +88,16 @@ public class FMLCommonHandler
|
|||
FMLLog.info("Completed early MinecraftForge initialization");
|
||||
}
|
||||
|
||||
public void rescheduleTicks()
|
||||
public void rescheduleTicks(Side side)
|
||||
{
|
||||
sidedDelegate.profileStart("modTickScheduling");
|
||||
TickRegistry.updateTickQueue(scheduledTicks);
|
||||
TickRegistry.updateTickQueue(side.isClient() ? scheduledClientTicks : scheduledServerTicks, side);
|
||||
sidedDelegate.profileEnd();
|
||||
}
|
||||
public void tickStart(EnumSet<TickType> ticks, Object ... data)
|
||||
public void tickStart(EnumSet<TickType> ticks, Side side, Object ... data)
|
||||
{
|
||||
List<IScheduledTickHandler> scheduledTicks = side.isClient() ? scheduledClientTicks : scheduledServerTicks;
|
||||
|
||||
if (scheduledTicks.size()==0)
|
||||
{
|
||||
return;
|
||||
|
@ -116,8 +117,10 @@ public class FMLCommonHandler
|
|||
sidedDelegate.profileEnd();
|
||||
}
|
||||
|
||||
public void tickEnd(EnumSet<TickType> ticks, Object ... data)
|
||||
public void tickEnd(EnumSet<TickType> ticks, Side side, Object ... data)
|
||||
{
|
||||
List<IScheduledTickHandler> scheduledTicks = side.isClient() ? scheduledClientTicks : scheduledServerTicks;
|
||||
|
||||
if (scheduledTicks.size()==0)
|
||||
{
|
||||
return;
|
||||
|
@ -169,14 +172,6 @@ public class FMLCommonHandler
|
|||
return FMLLog.getLogger();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int nextUniqueEntityListId()
|
||||
{
|
||||
return uniqueEntityListId++;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* @param lang
|
||||
|
@ -295,7 +290,7 @@ public class FMLCommonHandler
|
|||
|
||||
public void onPostServerTick()
|
||||
{
|
||||
tickEnd(EnumSet.of(TickType.GAME));
|
||||
tickEnd(EnumSet.of(TickType.SERVER), Side.SERVER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -303,12 +298,12 @@ public class FMLCommonHandler
|
|||
*/
|
||||
public void onPostWorldTick(Object world)
|
||||
{
|
||||
tickEnd(EnumSet.of(TickType.WORLD), world);
|
||||
tickEnd(EnumSet.of(TickType.WORLD), Side.SERVER, world);
|
||||
}
|
||||
|
||||
public void onPreServerTick()
|
||||
{
|
||||
tickStart(EnumSet.of(TickType.GAME));
|
||||
tickStart(EnumSet.of(TickType.SERVER), Side.SERVER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -316,12 +311,12 @@ public class FMLCommonHandler
|
|||
*/
|
||||
public void onPreWorldTick(Object world)
|
||||
{
|
||||
tickStart(EnumSet.of(TickType.WORLD), world);
|
||||
tickStart(EnumSet.of(TickType.WORLD), Side.SERVER, world);
|
||||
}
|
||||
|
||||
public void onWorldLoadTick()
|
||||
public void onWorldLoadTick(Object world)
|
||||
{
|
||||
tickStart(EnumSet.of(TickType.WORLDLOAD));
|
||||
tickStart(EnumSet.of(TickType.WORLDLOAD), Side.SERVER, world);
|
||||
}
|
||||
|
||||
public void handleServerStarting(MinecraftServer server)
|
||||
|
@ -374,9 +369,31 @@ public class FMLCommonHandler
|
|||
}
|
||||
sidedDelegate.beginServerLoading(dedicatedServer);
|
||||
}
|
||||
|
||||
|
||||
public void onServerStarted()
|
||||
{
|
||||
sidedDelegate.finishServerLoading();
|
||||
}
|
||||
|
||||
|
||||
public void onPreClientTick()
|
||||
{
|
||||
tickStart(EnumSet.of(TickType.CLIENT), Side.CLIENT);
|
||||
|
||||
}
|
||||
|
||||
public void onPostClientTick()
|
||||
{
|
||||
tickEnd(EnumSet.of(TickType.CLIENT), Side.CLIENT);
|
||||
}
|
||||
|
||||
public void onRenderTickStart(float timer)
|
||||
{
|
||||
tickStart(EnumSet.of(TickType.RENDER), Side.CLIENT, timer);
|
||||
}
|
||||
|
||||
public void onRenderTickEnd(float timer)
|
||||
{
|
||||
tickEnd(EnumSet.of(TickType.RENDER), Side.CLIENT, timer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,22 @@
|
|||
*/
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
|
||||
public interface IDispenseHandler
|
||||
{
|
||||
boolean dispense(double x, double y, double z, int xVelocity, int zVelocity, Object... data);
|
||||
|
||||
/**
|
||||
* 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 data
|
||||
* @return
|
||||
*/
|
||||
int dispense(double x, double y, double z, int xVelocity, int zVelocity, World world, ItemStack item);
|
||||
}
|
||||
|
|
|
@ -15,10 +15,13 @@ package cpw.mods.fml.common;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.src.IChunkProvider;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
/**
|
||||
* This is called back during world generation. The {@link #generate(Random, int, int, Object...)} method passes in some additional data that
|
||||
* This is called back during world generation. The {@link #generate(Random, int, int, Object...)} method passes in some additional data that
|
||||
* can be cast into minecraft objects.
|
||||
*
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
|
@ -26,14 +29,14 @@ public interface IWorldGenerator
|
|||
{
|
||||
/**
|
||||
* Generate some world
|
||||
*
|
||||
*
|
||||
* @param random the chunk specific {@link Random}.
|
||||
* @param chunkX the block X coordinate of this chunk.
|
||||
* @param chunkZ the block Z coordinate of this chunk.
|
||||
* @param world : additionalData[0] The minecraft {@link World} we're generating for.
|
||||
* @param generator : additionalData[1] The {@link IChunkProvider} that is generating.
|
||||
* @param chunkProvider : additionalData[2] {@link IChunkProvider} that is requesting the world generation.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public void generate(Random random, int chunkX, int chunkZ, Object...additionalData);
|
||||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider);
|
||||
}
|
||||
|
|
|
@ -34,31 +34,25 @@ public enum TickType {
|
|||
* client side
|
||||
* Fired during the render processing phase if a GUI is open
|
||||
* arg 0 : float "partial render time"
|
||||
* arg 1 : the open gui
|
||||
* arg 1 : the open gui or null if no gui is open
|
||||
*/
|
||||
GUI,
|
||||
/**
|
||||
* client side
|
||||
* Fired during the world evaluation loop if a gui is open
|
||||
* arg 0 : The open gui
|
||||
* Fired during the client evaluation loop
|
||||
* arg 0 : The open gui or null if no gui is open
|
||||
*/
|
||||
WORLDGUI,
|
||||
CLIENTGUI,
|
||||
/**
|
||||
* client side
|
||||
* server side
|
||||
* Fired once as the world loads from disk
|
||||
*/
|
||||
WORLDLOAD,
|
||||
/**
|
||||
* client side
|
||||
* Fired once as the world loads from disk
|
||||
* arg 0 : the open gui
|
||||
* client side only
|
||||
* Fired once per client tick loop.
|
||||
*/
|
||||
GUILOAD,
|
||||
/**
|
||||
* client and server side
|
||||
* Fired once per "global tick loop"
|
||||
*/
|
||||
GAME,
|
||||
CLIENT,
|
||||
/**
|
||||
* client and server side.
|
||||
* Fired whenever the players update loop runs.
|
||||
|
@ -67,11 +61,11 @@ public enum TickType {
|
|||
*/
|
||||
PLAYER,
|
||||
/**
|
||||
* This is a special internal tick type that is
|
||||
* not sent to mods. It resets the scheduler for
|
||||
* the next tick pass.
|
||||
* server side only.
|
||||
* This is the server game tick.
|
||||
* Fired once per tick loop on the server.
|
||||
*/
|
||||
RESETMARKER;
|
||||
SERVER;
|
||||
|
||||
/**
|
||||
* Partner ticks that are also cancelled by returning false from onTickInGame
|
||||
|
@ -80,11 +74,10 @@ public enum TickType {
|
|||
*/
|
||||
public EnumSet<TickType> partnerTicks()
|
||||
{
|
||||
if (this==GAME) return EnumSet.of(RENDER);
|
||||
if (this==RENDER) return EnumSet.of(GAME);
|
||||
if (this==GUI) return EnumSet.of(WORLDGUI, GUILOAD);
|
||||
if (this==WORLDGUI) return EnumSet.of(GUI, GUILOAD);
|
||||
if (this==GUILOAD) return EnumSet.of(GUI, WORLDGUI);
|
||||
if (this==CLIENT) return EnumSet.of(RENDER);
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -60,13 +60,13 @@ public class BaseModTicker implements ITickHandler
|
|||
|
||||
private void tickBaseMod(EnumSet<TickType> types, boolean end, Object... tickData)
|
||||
{
|
||||
if (FMLCommonHandler.instance().getSide().isClient() && ( ticks.contains(TickType.GAME) || ticks.contains(TickType.WORLDLOAD)))
|
||||
if (FMLCommonHandler.instance().getSide().isClient() && ( ticks.contains(TickType.CLIENT) || ticks.contains(TickType.WORLDLOAD)))
|
||||
{
|
||||
EnumSet cTypes=EnumSet.copyOf(types);
|
||||
if ( ( end && types.contains(TickType.GAME)) || types.contains(TickType.WORLDLOAD))
|
||||
if ( ( end && types.contains(TickType.CLIENT)) || types.contains(TickType.WORLDLOAD))
|
||||
{
|
||||
clockTickTrigger = true;
|
||||
cTypes.remove(TickType.GAME);
|
||||
cTypes.remove(TickType.CLIENT);
|
||||
cTypes.remove(TickType.WORLDLOAD);
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class BaseModTicker implements ITickHandler
|
|||
{
|
||||
clockTickTrigger = false;
|
||||
cTypes.remove(TickType.RENDER);
|
||||
cTypes.add(TickType.GAME);
|
||||
cTypes.add(TickType.CLIENT);
|
||||
}
|
||||
|
||||
sendTick(cTypes, end, tickData);
|
||||
|
|
|
@ -50,10 +50,10 @@ public class ModLoaderHelper
|
|||
}
|
||||
// If we're enabled but we want clock ticks, or we're server side we get game ticks
|
||||
if (enable && (useClock || FMLCommonHandler.instance().getSide().isServer())) {
|
||||
ticks.add(TickType.GAME);
|
||||
ticks.add(TickType.CLIENT);
|
||||
ticks.add(TickType.WORLDLOAD);
|
||||
} else {
|
||||
ticks.remove(TickType.GAME);
|
||||
ticks.remove(TickType.CLIENT);
|
||||
ticks.remove(TickType.WORLDLOAD);
|
||||
}
|
||||
}
|
||||
|
@ -65,18 +65,15 @@ public class ModLoaderHelper
|
|||
// If we're enabled and we don't want clock ticks we get render ticks
|
||||
if (enable && !useClock) {
|
||||
ticks.add(TickType.RENDER);
|
||||
ticks.add(TickType.GUILOAD);
|
||||
} else {
|
||||
ticks.remove(TickType.RENDER);
|
||||
}
|
||||
// If we're enabled but we want clock ticks, or we're server side we get world ticks
|
||||
if (enable && useClock) {
|
||||
ticks.add(TickType.GAME);
|
||||
ticks.add(TickType.GUILOAD);
|
||||
ticks.add(TickType.CLIENT);
|
||||
ticks.add(TickType.WORLDLOAD);
|
||||
} else {
|
||||
ticks.remove(TickType.GAME);
|
||||
ticks.remove(TickType.GUILOAD);
|
||||
ticks.remove(TickType.CLIENT);
|
||||
ticks.remove(TickType.WORLDLOAD);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ import cpw.mods.fml.common.Loader;
|
|||
import cpw.mods.fml.common.LoaderException;
|
||||
import cpw.mods.fml.common.LoaderState;
|
||||
import cpw.mods.fml.common.ModClassLoader;
|
||||
import cpw.mods.fml.common.Side;
|
||||
import cpw.mods.fml.common.LoaderState.ModState;
|
||||
import cpw.mods.fml.common.MetadataCollection;
|
||||
import cpw.mods.fml.common.discovery.ASMDataTable;
|
||||
|
@ -515,8 +516,8 @@ public class ModLoaderModContainer implements ModContainer
|
|||
this.guiTickHandler = new BaseModTicker(ticks.clone(), true);
|
||||
this.gameTickHandler.setMod(mod);
|
||||
this.guiTickHandler.setMod(mod);
|
||||
TickRegistry.registerTickHandler(this.gameTickHandler);
|
||||
TickRegistry.registerTickHandler(this.guiTickHandler);
|
||||
TickRegistry.registerTickHandler(this.gameTickHandler, Side.CLIENT);
|
||||
TickRegistry.registerTickHandler(this.guiTickHandler, Side.CLIENT);
|
||||
GameRegistry.registerWorldGenerator(ModLoaderHelper.buildWorldGenHelper(mod));
|
||||
GameRegistry.registerFuelHandler(ModLoaderHelper.buildFuelHelper(mod));
|
||||
GameRegistry.registerCraftingHandler(ModLoaderHelper.buildCraftingHelper(mod));
|
||||
|
|
|
@ -10,11 +10,13 @@ import net.minecraft.src.BiomeGenBase;
|
|||
import net.minecraft.src.CraftingManager;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.FurnaceRecipes;
|
||||
import net.minecraft.src.IChunkProvider;
|
||||
import net.minecraft.src.IInventory;
|
||||
import net.minecraft.src.IRecipe;
|
||||
import net.minecraft.src.ItemBlock;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.src.WorldType;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
|
@ -24,6 +26,7 @@ import com.google.common.collect.Sets;
|
|||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
import cpw.mods.fml.common.IDispenseHandler;
|
||||
import cpw.mods.fml.common.IFuelHandler;
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
import cpw.mods.fml.common.LoaderException;
|
||||
|
@ -37,14 +40,16 @@ public class GameRegistry
|
|||
private static Set<IWorldGenerator> worldGenerators = Sets.newHashSet();
|
||||
private static List<IFuelHandler> fuelHandlers = Lists.newArrayList();
|
||||
private static List<ICraftingHandler> craftingHandlers = Lists.newArrayList();
|
||||
private static List<IDispenseHandler> dispenserHandlers = Lists.newArrayList();
|
||||
|
||||
public static void registerWorldGenerator(IWorldGenerator generator)
|
||||
{
|
||||
worldGenerators.add(generator);
|
||||
}
|
||||
|
||||
public static void generateWorld(int chunkX, int chunkZ, long worldSeed, Object... data)
|
||||
public static void generateWorld(int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
|
||||
{
|
||||
long worldSeed = world.func_72905_C();
|
||||
Random fmlRandom = new Random(worldSeed);
|
||||
long xSeed = fmlRandom.nextLong() >> 2 + 1L;
|
||||
long zSeed = fmlRandom.nextLong() >> 2 + 1L;
|
||||
|
@ -52,11 +57,28 @@ public class GameRegistry
|
|||
|
||||
for (IWorldGenerator generator : worldGenerators)
|
||||
{
|
||||
generator.generate(fmlRandom, chunkX, chunkZ, data);
|
||||
generator.generate(fmlRandom, chunkX, chunkZ, world, chunkGenerator, chunkProvider);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void registerDispenserHandler(IDispenseHandler handler)
|
||||
{
|
||||
dispenserHandlers.add(handler);
|
||||
}
|
||||
|
||||
|
||||
public static int tryDispense(World world, double x, double y, double z, int xVelocity, int zVelocity, ItemStack item)
|
||||
{
|
||||
for (IDispenseHandler handler : dispenserHandlers)
|
||||
{
|
||||
int dispensed = handler.dispense(x, y, z, xVelocity, zVelocity, world, item);
|
||||
if (dispensed>-1)
|
||||
{
|
||||
return dispensed;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public static Object buildBlock(ModContainer container, Class<?> type, Block annotation) throws Exception
|
||||
{
|
||||
Object o = type.getConstructor(int.class).newInstance(findSpareBlockId());
|
||||
|
|
|
@ -2,11 +2,13 @@ package cpw.mods.fml.common.registry;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.PriorityQueue;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import com.google.common.collect.Queues;
|
||||
|
||||
import cpw.mods.fml.common.IScheduledTickHandler;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.Side;
|
||||
import cpw.mods.fml.common.SingleIntervalHandler;
|
||||
|
||||
public class TickRegistry
|
||||
|
@ -16,61 +18,82 @@ public class TickRegistry
|
|||
* We register our delegate here
|
||||
* @param handler
|
||||
*/
|
||||
|
||||
|
||||
public static class TickQueueElement implements Comparable<TickQueueElement>
|
||||
{
|
||||
public static long tickCounter = 0;
|
||||
public TickQueueElement(IScheduledTickHandler ticker)
|
||||
public TickQueueElement(IScheduledTickHandler ticker, long tickCounter)
|
||||
{
|
||||
this.ticker = ticker;
|
||||
update();
|
||||
update(tickCounter);
|
||||
}
|
||||
@Override
|
||||
public int compareTo(TickQueueElement o)
|
||||
{
|
||||
return (int)(next - o.next);
|
||||
}
|
||||
|
||||
public void update()
|
||||
|
||||
public void update(long tickCounter)
|
||||
{
|
||||
next = tickCounter + Math.max(ticker.nextTickSpacing(),1);
|
||||
}
|
||||
|
||||
|
||||
private long next;
|
||||
public IScheduledTickHandler ticker;
|
||||
|
||||
public boolean scheduledNow()
|
||||
|
||||
public boolean scheduledNow(long tickCounter)
|
||||
{
|
||||
return tickCounter >= next;
|
||||
}
|
||||
}
|
||||
|
||||
private static PriorityQueue<TickQueueElement> tickHandlers = Queues.newPriorityQueue();
|
||||
|
||||
public static void registerScheduledTickHandler(IScheduledTickHandler handler)
|
||||
private static PriorityQueue<TickQueueElement> clientTickHandlers = Queues.newPriorityQueue();
|
||||
private static PriorityQueue<TickQueueElement> serverTickHandlers = Queues.newPriorityQueue();
|
||||
|
||||
private static AtomicLong clientTickCounter = new AtomicLong();
|
||||
private static AtomicLong serverTickCounter = new AtomicLong();
|
||||
|
||||
public static void registerScheduledTickHandler(IScheduledTickHandler handler, Side side)
|
||||
{
|
||||
tickHandlers.add(new TickQueueElement(handler));
|
||||
getQueue(side).add(new TickQueueElement(handler, getCounter(side).get()));
|
||||
}
|
||||
|
||||
public static void registerTickHandler(ITickHandler handler)
|
||||
/**
|
||||
* @param side
|
||||
* @return
|
||||
*/
|
||||
private static PriorityQueue<TickQueueElement> getQueue(Side side)
|
||||
{
|
||||
registerScheduledTickHandler(new SingleIntervalHandler(handler));
|
||||
return side.isClient() ? clientTickHandlers : serverTickHandlers;
|
||||
}
|
||||
|
||||
public static void updateTickQueue(List<IScheduledTickHandler> ticks)
|
||||
private static AtomicLong getCounter(Side side)
|
||||
{
|
||||
ticks.clear();
|
||||
TickQueueElement.tickCounter++;
|
||||
while (true)
|
||||
return side.isClient() ? clientTickCounter : serverTickCounter;
|
||||
}
|
||||
public static void registerTickHandler(ITickHandler handler, Side side)
|
||||
{
|
||||
registerScheduledTickHandler(new SingleIntervalHandler(handler), side);
|
||||
}
|
||||
|
||||
public static void updateTickQueue(List<IScheduledTickHandler> ticks, Side side)
|
||||
{
|
||||
synchronized (ticks)
|
||||
{
|
||||
if (tickHandlers.size()==0 || !tickHandlers.peek().scheduledNow())
|
||||
ticks.clear();
|
||||
long tick = getCounter(side).incrementAndGet();
|
||||
PriorityQueue<TickQueueElement> tickHandlers = getQueue(side);
|
||||
|
||||
while (true)
|
||||
{
|
||||
break;
|
||||
if (tickHandlers.size()==0 || !tickHandlers.peek().scheduledNow(tick))
|
||||
{
|
||||
break;
|
||||
}
|
||||
TickRegistry.TickQueueElement tickQueueElement = tickHandlers.poll();
|
||||
tickQueueElement.update(tick);
|
||||
tickHandlers.offer(tickQueueElement);
|
||||
ticks.add(tickQueueElement.ticker);
|
||||
}
|
||||
TickRegistry.TickQueueElement tickQueueElement = tickHandlers.poll();
|
||||
tickQueueElement.update();
|
||||
tickHandlers.offer(tickQueueElement);
|
||||
ticks.add(tickQueueElement.ticker);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ public class mod_testMod extends BaseMod {
|
|||
@Override
|
||||
public EnumSet<TickType> ticks()
|
||||
{
|
||||
return EnumSet.of(TickType.GAME);
|
||||
return EnumSet.of(TickType.CLIENT);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
--- ../src-base/common/net/minecraft/src/BlockDispenser.java
|
||||
+++ ../src-work/common/net/minecraft/src/BlockDispenser.java
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import cpw.mods.fml.common.Side;
|
||||
import cpw.mods.fml.common.asm.SideOnly;
|
||||
+import cpw.mods.fml.common.registry.GameRegistry;
|
||||
+
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockDispenser extends BlockContainer
|
||||
@@ -278,7 +280,11 @@
|
||||
{
|
||||
float var15 = 1.1F;
|
||||
byte var16 = 6;
|
||||
-
|
||||
+ int modDispense = GameRegistry.tryDispense(p_72283_1_, p_72283_9_, p_72283_11_, p_72283_13_, p_72283_7_, p_72283_8_, p_72283_2_);
|
||||
+ if (modDispense > -1)
|
||||
+ {
|
||||
+ return modDispense;
|
||||
+ }
|
||||
if (p_72283_2_.field_77993_c == Item.field_77704_l.field_77779_bT)
|
||||
{
|
||||
EntityArrow var28 = new EntityArrow(p_72283_1_, p_72283_9_, p_72283_11_, p_72283_13_);
|
|
@ -0,0 +1,19 @@
|
|||
--- ../src-base/common/net/minecraft/src/ChunkProviderServer.java
|
||||
+++ ../src-work/common/net/minecraft/src/ChunkProviderServer.java
|
||||
@@ -6,6 +6,8 @@
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
+
|
||||
+import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ChunkProviderServer implements IChunkProvider
|
||||
{
|
||||
@@ -177,6 +179,7 @@
|
||||
if (this.field_73246_d != null)
|
||||
{
|
||||
this.field_73246_d.func_73153_a(p_73153_1_, p_73153_2_, p_73153_3_);
|
||||
+ GameRegistry.generateWorld(p_73153_2_, p_73153_3_, field_73251_h, field_73246_d, p_73153_1_);
|
||||
var4.func_76630_e();
|
||||
}
|
||||
}
|
|
@ -112,18 +112,20 @@
|
|||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
@@ -125,6 +29,10 @@
|
||||
@@ -125,6 +29,12 @@
|
||||
import org.lwjgl.opengl.GLContext;
|
||||
import org.lwjgl.opengl.PixelFormat;
|
||||
import org.lwjgl.util.glu.GLU;
|
||||
+
|
||||
+import cpw.mods.fml.client.FMLClientHandler;
|
||||
+import cpw.mods.fml.common.FMLCommonHandler;
|
||||
+import cpw.mods.fml.common.Side;
|
||||
+import cpw.mods.fml.relauncher.ArgsWrapper;
|
||||
+import cpw.mods.fml.relauncher.FMLRelauncher;
|
||||
|
||||
public abstract class Minecraft implements Runnable, IPlayerUsage
|
||||
{
|
||||
@@ -305,7 +213,7 @@
|
||||
@@ -305,7 +215,7 @@
|
||||
this.func_71357_I();
|
||||
this.field_71466_p = new FontRenderer(this.field_71474_y, "/font/default.png", this.field_71446_o, false);
|
||||
this.field_71464_q = new FontRenderer(this.field_71474_y, "/font/alternate.png", this.field_71446_o, false);
|
||||
|
@ -132,16 +134,50 @@
|
|||
if (this.field_71474_y.field_74363_ab != null)
|
||||
{
|
||||
StringTranslate.func_74808_a().func_74810_a(this.field_71474_y.field_74363_ab);
|
||||
@@ -350,6 +258,8 @@
|
||||
@@ -350,6 +260,8 @@
|
||||
GL11.glViewport(0, 0, this.field_71443_c, this.field_71440_d);
|
||||
this.field_71452_i = new EffectRenderer(this.field_71441_e, this.field_71446_o);
|
||||
|
||||
+ FMLClientHandler.instance().finishMinecraftLoading();
|
||||
+
|
||||
+
|
||||
try
|
||||
{
|
||||
this.field_71430_V = new ThreadDownloadResources(this.field_71412_D, this);
|
||||
@@ -1883,6 +1793,12 @@
|
||||
@@ -738,9 +650,11 @@
|
||||
|
||||
if (!this.field_71454_w)
|
||||
{
|
||||
+ FMLCommonHandler.instance().onRenderTickStart(this.field_71428_T.field_74281_c);
|
||||
this.field_71424_I.func_76318_c("gameRenderer");
|
||||
this.field_71460_t.func_78480_b(this.field_71428_T.field_74281_c);
|
||||
this.field_71424_I.func_76319_b();
|
||||
+ FMLCommonHandler.instance().onRenderTickEnd(this.field_71428_T.field_74281_c);
|
||||
}
|
||||
|
||||
GL11.glFlush();
|
||||
@@ -1261,11 +1175,13 @@
|
||||
|
||||
public void func_71407_l()
|
||||
{
|
||||
+ FMLCommonHandler.instance().rescheduleTicks(Side.CLIENT);
|
||||
if (this.field_71467_ac > 0)
|
||||
{
|
||||
--this.field_71467_ac;
|
||||
}
|
||||
|
||||
+ FMLCommonHandler.instance().onPreClientTick();
|
||||
this.field_71424_I.func_76320_a("stats");
|
||||
this.field_71413_E.func_77449_e();
|
||||
this.field_71424_I.func_76318_c("gui");
|
||||
@@ -1633,6 +1549,7 @@
|
||||
this.field_71453_ak.func_74428_b();
|
||||
}
|
||||
|
||||
+ FMLCommonHandler.instance().onPostClientTick();
|
||||
this.field_71424_I.func_76319_b();
|
||||
this.field_71423_H = func_71386_F();
|
||||
}
|
||||
@@ -1883,6 +1800,12 @@
|
||||
|
||||
public static void main(String[] p_main_0_)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
--- ../src-base/minecraft/net/minecraft/src/GuiCreateWorld.java
|
||||
+++ ../src-work/minecraft/net/minecraft/src/GuiCreateWorld.java
|
||||
@@ -196,7 +196,7 @@
|
||||
var2 = (long)var4.hashCode();
|
||||
}
|
||||
}
|
||||
-
|
||||
+ WorldType.field_77139_a[this.field_73916_E].onGUICreateWorldPress();
|
||||
EnumGameType var9 = EnumGameType.func_77142_a(this.field_73927_m);
|
||||
WorldSettings var6 = new WorldSettings(var2, var9, this.field_73925_n, this.field_73933_r, WorldType.field_77139_a[this.field_73916_E]);
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
--- ../src-base/minecraft/net/minecraft/src/RenderBlocks.java
|
||||
+++ ../src-work/minecraft/net/minecraft/src/RenderBlocks.java
|
||||
@@ -126,7 +126,73 @@
|
||||
{
|
||||
int var5 = p_78612_1_.func_71857_b();
|
||||
p_78612_1_.func_71902_a(this.field_78669_a, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
- return var5 == 0 ? this.func_78570_q(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 31 ? this.func_78581_r(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 4 ? this.func_78621_p(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 13 ? this.func_78584_s(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 1 ? this.func_78620_l(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 19 ? this.func_78603_m(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 23 ? this.func_78566_o(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 6 ? this.func_78614_n(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 2 ? this.func_78572_c(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 3 ? this.func_78590_h(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 5 ? this.func_78589_i(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 8 ? this.func_78576_j(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 7 ? this.func_78601_u(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 9 ? this.func_78586_a((BlockRail)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 10 ? this.func_78565_t(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 27 ? this.func_78618_a((BlockDragonEgg)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 11 ? this.func_78582_a((BlockFence)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 12 ? this.func_78594_e(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 29 ? this.func_78577_f(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 30 ? this.func_78619_g(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 14 ? this.func_78574_w(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 15 ? this.func_78610_x(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 16 ? this.func_78593_b(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_, false) : (var5 == 17 ? this.func_78608_c(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_, true) : (var5 == 18 ? this.func_78592_a((BlockPane)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 20 ? this.func_78598_k(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 21 ? this.func_78580_a((BlockFenceGate)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 24 ? this.func_78615_a((BlockCauldron)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 25 ? this.func_78585_a((BlockBrewingStand)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 26 ? this.func_78567_v(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : (var5 == 28 ? this.func_78616_a((BlockCocoa)p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_) : false))))))))))))))))))))))))))))));
|
||||
+ switch (var5)
|
||||
+ {
|
||||
+ case 0:
|
||||
+ return this.func_78570_q(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 31:
|
||||
+ return this.func_78581_r(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 4:
|
||||
+ return this.func_78621_p(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 13:
|
||||
+ return this.func_78584_s(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 1:
|
||||
+ return this.func_78620_l(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 19:
|
||||
+ return this.func_78603_m(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 23:
|
||||
+ return this.func_78566_o(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 6:
|
||||
+ return this.func_78614_n(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 2:
|
||||
+ return this.func_78572_c(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 3:
|
||||
+ return this.func_78590_h(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 5:
|
||||
+ return this.func_78589_i(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 8:
|
||||
+ return this.func_78576_j(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 7:
|
||||
+ return this.func_78601_u(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 9:
|
||||
+ return this.func_78586_a((BlockRail) p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 10:
|
||||
+ return this.func_78565_t(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 27:
|
||||
+ return this.func_78618_a((BlockDragonEgg) p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 11:
|
||||
+ return this.func_78582_a((BlockFence) p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 12:
|
||||
+ return this.func_78594_e(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 29:
|
||||
+ return this.func_78577_f(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 30:
|
||||
+ return this.func_78619_g(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 14:
|
||||
+ return this.func_78574_w(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 15:
|
||||
+ return this.func_78610_x(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 16:
|
||||
+ return this.func_78593_b(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_, false);
|
||||
+ case 17:
|
||||
+ return this.func_78608_c(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_, true);
|
||||
+ case 18:
|
||||
+ return this.func_78592_a((BlockPane) p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 20:
|
||||
+ return this.func_78598_k(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 21:
|
||||
+ return this.func_78580_a((BlockFenceGate) p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 24:
|
||||
+ return this.func_78615_a((BlockCauldron) p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 25:
|
||||
+ return this.func_78585_a((BlockBrewingStand) p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 26:
|
||||
+ return this.func_78567_v(p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ case 28:
|
||||
+ return this.func_78616_a((BlockCocoa) p_78612_1_, p_78612_2_, p_78612_3_, p_78612_4_);
|
||||
+ default:
|
||||
+ return FMLRenderAccessLibrary.renderWorldBlock(this, field_78669_a, p_78612_2_, p_78612_3_, p_78612_4_, p_78612_1_, var5);
|
||||
+ }
|
||||
}
|
||||
|
||||
public boolean func_78567_v(Block p_78567_1_, int p_78567_2_, int p_78567_3_, int p_78567_4_)
|
||||
@@ -5991,6 +6057,10 @@
|
||||
|
||||
p_78600_1_.func_71905_a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
+ else
|
||||
+ {
|
||||
+ FMLRenderAccessLibrary.renderInventoryBlock(this, p_78600_1_, p_78600_2_, var6);
|
||||
+ }
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -6048,6 +6118,30 @@
|
||||
|
||||
public static boolean func_78597_b(int p_78597_0_)
|
||||
{
|
||||
- return p_78597_0_ == 0 ? true : (p_78597_0_ == 31 ? true : (p_78597_0_ == 13 ? true : (p_78597_0_ == 10 ? true : (p_78597_0_ == 11 ? true : (p_78597_0_ == 27 ? true : (p_78597_0_ == 22 ? true : (p_78597_0_ == 21 ? true : (p_78597_0_ == 16 ? true : p_78597_0_ == 26))))))));
|
||||
+ switch (p_78597_0_)
|
||||
+ {
|
||||
+ case 0:
|
||||
+ return true;
|
||||
+ case 31:
|
||||
+ return true;
|
||||
+ case 13:
|
||||
+ return true;
|
||||
+ case 10:
|
||||
+ return true;
|
||||
+ case 11:
|
||||
+ return true;
|
||||
+ case 27:
|
||||
+ return true;
|
||||
+ case 22:
|
||||
+ return true;
|
||||
+ case 21:
|
||||
+ return true;
|
||||
+ case 16:
|
||||
+ return true;
|
||||
+ case 26:
|
||||
+ return true;
|
||||
+ default:
|
||||
+ return FMLRenderAccessLibrary.renderItemAsFull3DBlock(p_78597_0_);
|
||||
+ }
|
||||
}
|
||||
}
|
|
@ -36,7 +36,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseModPr
|
|||
@Override
|
||||
public final boolean doTickInGame(TickType tick, boolean tickEnd, Object... data)
|
||||
{
|
||||
if (tick==TickType.GAME && tickEnd) {
|
||||
if (tick==TickType.SERVER && tickEnd) {
|
||||
return onTickInGame(FMLServerHandler.instance().getServer());
|
||||
} else {
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue