Tweak block rendering organization. Add in worldgen for client.

This commit is contained in:
Christian Weeks 2012-05-10 19:51:15 -04:00
parent 813ad71f13
commit b7861ec04c
10 changed files with 75 additions and 169 deletions

View file

@ -14,36 +14,67 @@
package cpw.mods.fml.client;
import cpw.mods.fml.common.IBlockRenderInfo;
import net.minecraft.src.BaseMod;
import net.minecraft.src.Block;
import net.minecraft.src.IBlockAccess;
import net.minecraft.src.RenderBlocks;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
/**
* @author cpw
*
*/
public class BlockRenderInfo implements IBlockRenderInfo
public class BlockRenderInfo
{
private int renderId;
private boolean forInventory;
private boolean render3dInInventory;
private ModContainer modContainer;
/**
* @param modContainer
*
*/
public BlockRenderInfo(int renderId, boolean forInventory)
public BlockRenderInfo(int renderId, boolean render3dInInventory, ModContainer modContainer)
{
this.renderId=renderId;
this.forInventory=forInventory;
this.render3dInInventory=render3dInInventory;
this.modContainer=modContainer;
}
@Override
public int getRenderId()
{
return renderId;
}
@Override
public boolean getInventoryRendering()
public boolean shouldRender3DInInventory()
{
return forInventory;
return render3dInInventory;
}
/**
* @param world
* @param x
* @param y
* @param z
* @param block
* @param modelId
* @param renderer
*/
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);
}
/**
* @param block
* @param metadata
* @param modelID
* @param renderer
*/
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
{
((BaseMod)modContainer.getMod()).renderInvBlock(renderer, block, metadata, modelID);
}
}

View file

@ -100,7 +100,7 @@ public class FMLClientHandler implements IFMLSidedHandler
// Cached lookups
private static HashMap<String, ArrayList<OverrideInfo>> overrideInfo = new HashMap<String, ArrayList<OverrideInfo>>();
private static HashMap<Integer, ModContainer> blockModelIds = new HashMap<Integer, ModContainer>();
private static HashMap<Integer, BlockRenderInfo> blockModelIds = new HashMap<Integer, BlockRenderInfo>();
private static HashMap<KeyBinding, ModContainer> keyBindings = new HashMap<KeyBinding, ModContainer>();
/**
@ -562,8 +562,8 @@ public class FMLClientHandler implements IFMLSidedHandler
{
ModLoaderModContainer mlmc=ModLoaderHelper.registerRenderHelper(mod);
int renderId=nextRenderId++;
mlmc.addRenderHandler(new BlockRenderInfo(renderId, inventoryRenderer));
blockModelIds.put(renderId, mlmc);
BlockRenderInfo bri=new BlockRenderInfo(renderId, inventoryRenderer, mlmc);
blockModelIds.put(renderId, bri);
return renderId;
}
@ -615,18 +615,16 @@ public class FMLClientHandler implements IFMLSidedHandler
* @param y
* @param z
* @param block
* @param modelID
* @param modelId
* @return
*/
public boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID)
{
ModContainer mod = blockModelIds.get(modelID);
if (mod == null)
public boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelId)
{
if (!blockModelIds.containsKey(modelId)) {
return false;
}
mod.renderWorldBlock(world, x, y, z, block, modelID, renderer);
return ((BaseMod)mod.getMod()).renderWorldBlock(renderer, world, x, y, z, block, modelID);
BlockRenderInfo bri = blockModelIds.get(modelId);
return bri.renderWorldBlock(world, x, y, z, block, modelId, renderer);
}
/**
@ -637,11 +635,11 @@ public class FMLClientHandler implements IFMLSidedHandler
*/
public void renderInventoryBlock(RenderBlocks renderer, Block block, int metadata, int modelID)
{
ModContainer mod = blockModelIds.get(modelID);
if (mod != null)
{
mod.renderInventoryBlock(block, metadata, modelID, renderer);
if (!blockModelIds.containsKey(modelID)) {
return;
}
BlockRenderInfo bri=blockModelIds.get(modelID);
bri.renderInventoryBlock(block, metadata, modelID, renderer);
}
/**
@ -650,6 +648,10 @@ public class FMLClientHandler implements IFMLSidedHandler
*/
public boolean renderItemAsFull3DBlock(int modelId)
{
BlockRenderInfo bri = blockModelIds.get(modelId);
if (bri!=null) {
return bri.shouldRender3DInInventory();
}
return false;
}

View file

@ -132,31 +132,6 @@ public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDisp
{
return false;
}
/**
* @param renderer
* @param block
* @param metadata
* @param modelID
*/
public final void onRenderInventoryBlock(Object renderer, Block block, int metadata, int modelID)
{
renderInvBlock((RenderBlocks)renderer, block, metadata, modelID);
}
/**
* @param world
* @param x
* @param y
* @param z
* @param block
* @param modelID
* @param renderer
*/
public final boolean onRenderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelID, Object renderer)
{
return renderWorldBlock((RenderBlocks)renderer, world, x, y, z, block, modelID);
}
// BASEMOD API
/**
* Override if you wish to provide a fuel item for the furnace and return the fuel value of the item

View file

@ -337,22 +337,4 @@ public class FMLModContainer implements ModContainer
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.ModContainer#renderInventoryBlock(net.minecraft.src.Block, int, int, java.lang.Object)
*/
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, Object renderer)
{
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.ModContainer#renderWorldBlock(net.minecraft.src.IBlockAccess, int, int, int, net.minecraft.src.Block, int, java.lang.Object)
*/
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelID, Object renderer)
{
// TODO Auto-generated method stub
return false;
}
}

View file

@ -1,25 +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;
/**
* @author cpw
*
*/
public interface IBlockRenderInfo
{
public int getRenderId();
public boolean getInventoryRendering();
}

View file

@ -203,22 +203,4 @@ public interface ModContainer
}
List<IKeyHandler> getKeys();
/**
* @param block
* @param metadata
* @param modelID
* @param renderer
*/
void renderInventoryBlock(Block block, int metadata, int modelID, Object renderer);
/**
* @param world
* @param x
* @param y
* @param z
* @param block
* @param modelID
* @param renderer
* @return
*/
boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelID, Object renderer);
}

View file

@ -42,7 +42,6 @@ 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;
@ -59,7 +58,6 @@ 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;
private ModState state;
@ -592,18 +590,6 @@ public class ModLoaderModContainer implements ModContainer
return ticks;
}
/**
* @param renderId
* @param inventoryRenderer
*/
public void addRenderHandler(IBlockRenderInfo handler)
{
if (blockRenderInfos==null) {
blockRenderInfos=new ArrayList<IBlockRenderInfo>();
}
blockRenderInfos.add(handler);
}
/**
* @param keyHandler
* @param allowRepeat
@ -624,24 +610,4 @@ public class ModLoaderModContainer implements ModContainer
}
return keyHandlers;
}
/**
* @param block
* @param metadata
* @param modelID
* @param renderer
*/
public void renderInventoryBlock(Block block, int metadata, int modelID, Object renderer)
{
mod.onRenderInventoryBlock(renderer, block, metadata, modelID);
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.ModContainer#renderWorldBlock(net.minecraft.src.IBlockAccess, int, int, int, net.minecraft.src.Block, int, java.lang.Object)
*/
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelID, Object renderer)
{
return mod.onRenderWorldBlock(world, x, y, z, block, modelID, renderer);
}
}

View file

@ -1,4 +1,3 @@
LexicalSortingAction.isChecked=true
content_assist_favorite_static_members=
content_assist_lru_history=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><history maxLHS\="100" maxRHS\="10"><lhs name\="net.minecraft.src.IMinecraftRegistry"><rhs name\="net.minecraft.src.ServerRegistry"/></lhs><lhs name\="java.lang.ClassLoader"><rhs name\="java.net.URLClassLoader"/></lhs><lhs name\="java.util.logging.Level"><rhs name\="java.util.logging.Level"/></lhs></history>
content_assist_number_of_computers=13

View file

@ -0,0 +1,19 @@
--- ../src-base/minecraft/net/minecraft/src/ChunkProvider.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src-work/minecraft/net/minecraft/src/ChunkProvider.java 0000-00-00 00:00:00.000000000 -0000
@@ -6,6 +6,8 @@
import java.util.List;
import java.util.Set;
+import cpw.mods.fml.client.FMLClientHandler;
+
public class ChunkProvider implements IChunkProvider
{
private Set field_28065_a = new HashSet();
@@ -162,6 +164,7 @@
if (this.field_28070_c != null)
{
this.field_28070_c.func_534_a(p_534_1_, p_534_2_, p_534_3_);
+ FMLClientHandler.instance().onChunkPopulate(p_534_1_, p_534_2_, p_534_3_, field_28066_g, field_28070_c);
var4.func_1006_f();
}
}

View file

@ -122,31 +122,6 @@ public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDisp
{
return onServerCommand(command, (String)data[0], (ICommandListener)data[1]);
}
/**
* @param renderer
* @param block
* @param metadata
* @param modelID
*/
public final void onRenderInventoryBlock(Object renderer, Block block, int metadata, int modelID)
{
// NOOP
}
/**
* @param world
* @param x
* @param y
* @param z
* @param block
* @param modelID
* @param renderer
*/
public final boolean onRenderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelID, Object renderer)
{
return false;
}
// BASEMOD API
/**
* Override if you wish to provide a fuel item for the furnace and return the fuel value of the item