Archive crane render & model classes

Since i don't plan to work on the crane right now i'll archive all the
model & renderers for later use.
This commit is contained in:
DarkGuardsman 2013-09-21 17:00:37 -04:00
parent 7abe19e96d
commit 15e169a120
7 changed files with 131 additions and 0 deletions

View file

@ -0,0 +1,71 @@
package dark.assembly.client.render;
import static org.lwjgl.opengl.GL11.GL_LIGHTING;
import static org.lwjgl.opengl.GL11.glEnable;
import static org.lwjgl.opengl.GL11.glPopMatrix;
import static org.lwjgl.opengl.GL11.glPushMatrix;
import static org.lwjgl.opengl.GL11.glRotatef;
import static org.lwjgl.opengl.GL11.glTranslated;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.assembly.client.model.ModelCraneController;
import dark.assembly.common.AssemblyLine;
import dark.assembly.common.machine.crane.CraneHelper;
import dark.assembly.common.machine.crane.TileEntityCraneController;
import dark.core.prefab.ModPrefab;
@SideOnly(Side.CLIENT)
public class RenderCraneController extends RenderImprintable
{
public static final String TEXTURE = "crane_controller_off.png";
public static final String TEXTURE_VALID = "crane_controller_on.png";
public static final ModelCraneController MODEL = new ModelCraneController();
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f)
{
if (tileEntity != null && tileEntity instanceof TileEntityCraneController)
{
ResourceLocation name = new ResourceLocation(AssemblyLine.instance.DOMAIN, ModPrefab.MODEL_DIRECTORY + (((TileEntityCraneController) tileEntity).isCraneValid() ? TEXTURE_VALID : TEXTURE));
func_110628_a(name);
ForgeDirection front = ForgeDirection.getOrientation(tileEntity.worldObj.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
ForgeDirection right = CraneHelper.rotateClockwise(front);
float angle = 0f;
switch (front)
{
case NORTH:
{
angle = 90f;
break;
}
case SOUTH:
{
angle = 270f;
break;
}
case EAST:
{
angle = 180f;
break;
}
}
int tX, tY, tZ;
tX = tileEntity.xCoord;
tY = tileEntity.yCoord;
tZ = tileEntity.zCoord;
boolean connectFront = CraneHelper.canFrameConnectTo(tileEntity, tX + front.offsetX, tY, tZ + front.offsetZ, front.getOpposite());
boolean connectRight = CraneHelper.canFrameConnectTo(tileEntity, tX + right.offsetX, tY, tZ + right.offsetZ, right.getOpposite());
glPushMatrix();
glTranslated(x + 0.5, y + 1.5, z + 0.5);
glRotatef(180f, 0f, 0f, 1f);
glRotatef(angle, 0f, 1f, 0f);
glEnable(GL_LIGHTING);
MODEL.render(0.0625f, connectRight, connectFront);
glPopMatrix();
}
}
}

View file

@ -0,0 +1,60 @@
package dark.assembly.client.render;
import static org.lwjgl.opengl.GL11.GL_LIGHTING;
import static org.lwjgl.opengl.GL11.glEnable;
import static org.lwjgl.opengl.GL11.glPopMatrix;
import static org.lwjgl.opengl.GL11.glPushMatrix;
import static org.lwjgl.opengl.GL11.glRotatef;
import static org.lwjgl.opengl.GL11.glTranslated;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.assembly.client.model.ModelCraneRail;
import dark.assembly.common.AssemblyLine;
import dark.assembly.common.machine.crane.CraneHelper;
import dark.assembly.common.machine.crane.TileEntityCraneRail;
import dark.core.prefab.ModPrefab;
@SideOnly(Side.CLIENT)
public class RenderCraneFrame extends TileEntitySpecialRenderer
{
public static final String TEXTURE = "crane_frame.png";
public static final ModelCraneRail MODEL = new ModelCraneRail();
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f)
{
if (tileEntity != null && tileEntity instanceof TileEntityCraneRail)
{
int tX, tY, tZ;
tX = tileEntity.xCoord;
tY = tileEntity.yCoord;
tZ = tileEntity.zCoord;
boolean renderUp = CraneHelper.canFrameConnectTo(tileEntity, tX, tY + 1, tZ, ForgeDirection.DOWN);
boolean renderDown = CraneHelper.canFrameConnectTo(tileEntity, tX, tY - 1, tZ, ForgeDirection.UP);
// EAST, X-
boolean renderLeft = CraneHelper.canFrameConnectTo(tileEntity, tX - 1, tY, tZ, ForgeDirection.EAST);
// WAST, X+
boolean renderRight = CraneHelper.canFrameConnectTo(tileEntity, tX + 1, tY, tZ, ForgeDirection.WEST);
// SOUTH, Z-
boolean renderFront = CraneHelper.canFrameConnectTo(tileEntity, tX, tY, tZ - 1, ForgeDirection.SOUTH);
// NORTH, Z+
boolean renderBack = CraneHelper.canFrameConnectTo(tileEntity, tX, tY, tZ + 1, ForgeDirection.NORTH);
boolean renderFoot = tileEntity.worldObj.isBlockSolidOnSide(tX, tY - 1, tZ, ForgeDirection.UP);
if ((renderLeft && renderRight) || (renderFront && renderBack))
renderFoot = false;
ResourceLocation name = new ResourceLocation(AssemblyLine.instance.DOMAIN, ModPrefab.MODEL_DIRECTORY + TEXTURE);
func_110628_a(name);
glPushMatrix();
glTranslated(x + 0.5, y + 1.5, z + 0.5);
glRotatef(180f, 0f, 0f, 1f);
glEnable(GL_LIGHTING);
MODEL.render(renderUp, renderDown && !renderFoot, renderLeft, renderRight, renderFront, renderBack, renderFoot);
glPopMatrix();
}
}
}