Worked out client side rendering for addons
I was doing it wrong just to be short. Long story though when calling for the addon to render you can't do any of the normal GL11 call for changing the location, scale, etc., or at least not the way i was doing it. Only thing the addon creator should need to do is call for the part of the model to render connected to the pipe core.
This commit is contained in:
parent
da813ace2d
commit
67454a0a29
4 changed files with 38 additions and 24 deletions
|
@ -7,6 +7,8 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
import fluidmech.client.model.ModelLargePipe;
|
||||
import fluidmech.client.render.pipeextentions.IPipeExtentionRender;
|
||||
import fluidmech.common.FluidMech;
|
||||
|
@ -47,19 +49,20 @@ public class RenderPipe extends TileEntitySpecialRenderer
|
|||
try
|
||||
{
|
||||
ob = extention.getExtentionRenderClass().newInstance();
|
||||
|
||||
if (ob instanceof IPipeExtentionRender)
|
||||
{
|
||||
IPipeExtentionRender render = (IPipeExtentionRender) ob;
|
||||
if (render != null)
|
||||
|
||||
if (ob instanceof IPipeExtentionRender)
|
||||
{
|
||||
render.renderAModelAt(pipe, d, d1, d2, f, ForgeDirection.getOrientation(i));
|
||||
IPipeExtentionRender render = (IPipeExtentionRender) ob;
|
||||
if (render != null)
|
||||
{
|
||||
System.out.println("Rendering Pipe Addon side " + i);
|
||||
render.renderAModelAt(this, pipe, new Vector3(0, 0, 0), f, ForgeDirection.getOrientation(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.print("Failed to render a pipe extention");
|
||||
System.out.println("Failed to render a pipe extention");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +73,11 @@ public class RenderPipe extends TileEntitySpecialRenderer
|
|||
|
||||
}
|
||||
|
||||
public void bindTextureForPipe(String texture)
|
||||
{
|
||||
this.bindTextureByName(texture);
|
||||
}
|
||||
|
||||
public static String getPipeTexture(int meta)
|
||||
{
|
||||
return FluidMech.MODEL_TEXTURE_DIRECTORY + "pipes/" + ColorCode.get(meta).getName() + "Pipe.png";
|
||||
|
|
|
@ -7,6 +7,8 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
import fluidmech.client.model.ModelLargePipe;
|
||||
import fluidmech.client.render.pipeextentions.IPipeExtentionRender;
|
||||
import fluidmech.common.FluidMech;
|
||||
|
@ -24,14 +26,12 @@ public class RenderPipeWindow implements IPipeExtentionRender
|
|||
SixPipe = new ModelLargePipe();
|
||||
}
|
||||
|
||||
public void renderAModelAt(TileEntityPipe pipe, double d, double d1, double d2, float size, ForgeDirection facingDirection)
|
||||
@Override
|
||||
public void renderAModelAt(RenderPipe renderPipe, TileEntityPipe pipe, Vector3 location, float size, ForgeDirection facingDirection)
|
||||
{
|
||||
// Texture file
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
|
||||
GL11.glScalef(1.1F, -1.1F, -1.1F);
|
||||
renderPipe.bindTextureForPipe(renderPipe.getPipeTexture(0));
|
||||
this.render(facingDirection.ordinal());
|
||||
GL11.glPopMatrix();
|
||||
System.out.println("Rendered Window Pipe");
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package fluidmech.client.render.pipeextentions;
|
||||
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import fluidmech.client.render.RenderPipe;
|
||||
import fluidmech.common.machines.pipes.TileEntityPipe;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
|
@ -15,12 +18,14 @@ public interface IPipeExtentionRender
|
|||
{
|
||||
/**
|
||||
* Renders the pipe extension just like a normal tileEntity render however this is called and
|
||||
* process threw the RenderPipe.class
|
||||
* process threw the RenderPipe.class so you don't need to do all the GL11 calls for scaling,
|
||||
* translation, etc
|
||||
*
|
||||
* @param renderPipe - render instance that is calling this method
|
||||
* @param pipe - TileEntity this extension is attached too
|
||||
* @param xPos yPos zPos position too be rendered from the players plane
|
||||
* @param location - position too be rendered from the players plane
|
||||
* @param size - This should be the size of the render, correct me if wrong
|
||||
* @param facingDirection - Facing direction of the extension in relation to its pipe frame
|
||||
*/
|
||||
public void renderAModelAt(TileEntityPipe pipe, double xPos, double yPos, double zPos, float size, ForgeDirection facingDirection);
|
||||
public void renderAModelAt(RenderPipe renderPipe, TileEntityPipe pipe, Vector3 location, float size, ForgeDirection facingDirection);
|
||||
}
|
||||
|
|
|
@ -65,13 +65,13 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
public void initiate()
|
||||
{
|
||||
this.updateAdjacentConnections();
|
||||
if (this.subEntities[0] == null)
|
||||
{
|
||||
this.addNewExtention(0, TileEntityPipeWindow.class);
|
||||
}
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (this.subEntities[0] == null)
|
||||
{
|
||||
this.subEntities[0] = new TileEntityPipeWindow();
|
||||
this.initSubTile(0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
TileEntity entity = (TileEntity) this.subEntities[i];
|
||||
|
@ -110,7 +110,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
IPipeExtention extention = subEntities[i];
|
||||
if (this.ticks % extention.updateTick() == 0)
|
||||
{
|
||||
System.out.println("Updating addon " + (worldObj.isRemote ? "Client" : "Server") + " on side " + i);
|
||||
//System.out.println("Updating addon " + (worldObj.isRemote ? "Client" : "Server") + " on side " + i);
|
||||
((TileEntity) extention).updateEntity();
|
||||
if (extention.shouldSendPacket(!this.worldObj.isRemote) && extention.getExtentionPacketData(!this.worldObj.isRemote) != null)
|
||||
{
|
||||
|
@ -215,7 +215,8 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
TileEntity tile = partClass.newInstance();
|
||||
if (tile instanceof IPipeExtention)
|
||||
{
|
||||
|
||||
this.subEntities[side] = (IPipeExtention) tile;
|
||||
this.initSubTile(side);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
Loading…
Reference in a new issue