Skip to content

Commit

Permalink
Model working
Browse files Browse the repository at this point in the history
I got the rotor mapped to the correct texture and will now spin when
the coil is charging. #2
  • Loading branch information
pauljoda committed Feb 21, 2015
1 parent c0f7315 commit 9c22c2e
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,20 @@ public ModelTeslaBase() {
modelBase = AdvancedModelLoader.loadModel(new ResourceLocation(Constants.MODID + ":models/teslaBase.obj"));
}

public void render() {
modelBase.renderAll();
//Model Names:
//Main : NurbsPath.001_Mesh
//Switch : Cube.007_Cube.010
//Rotor : Cylinder.014_Cylinder.018

public void renderMain() {
modelBase.renderPart("NurbsPath.001_Mesh");
}

public void renderSwitch() {
modelBase.renderPart("Cube.007_Cube.010");
}

public void renderRotor() {
modelBase.renderPart("Cylinder.014_Cylinder.018");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void renderBase(float x, float y, float z, int metaData)
GL11.glTranslatef(x, y, z); //size
GL11.glDisable(GL11.GL_CULL_FACE);

base.render();
base.renderMain();

GL11.glEnable(GL11.GL_CULL_FACE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@

import com.dyonovan.modernalchemy.lib.Constants;
import com.dyonovan.modernalchemy.model.teslacoil.ModelTeslaBase;
import com.dyonovan.modernalchemy.tileentity.teslacoil.TileTeslaBase;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;

public class RenderTeslaBase extends TileEntitySpecialRenderer {

public static final ResourceLocation texture = new ResourceLocation(Constants.MODID + ":textures/models/teslaBase.png");
public static final ResourceLocation textureMain = new ResourceLocation(Constants.MODID + ":textures/models/teslaBase.png");
public static final ResourceLocation textureSwitch = new ResourceLocation(Constants.MODID + ":textures/models/teslaBaseHandle.png");
public static final ResourceLocation textureRotor = new ResourceLocation(Constants.MODID + ":textures/models/teslaBaseMag.png");

private static float rotMod = 0.0F;

private ModelTeslaBase model;

Expand All @@ -19,13 +24,24 @@ public RenderTeslaBase() {

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {

TileTeslaBase base = (TileTeslaBase)tileentity;
GL11.glPushMatrix();

GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);
GL11.glDisable(GL11.GL_CULL_FACE);
this.bindTexture(texture);
this.model.render();

this.bindTexture(textureMain);
this.model.renderMain();

this.bindTexture(textureSwitch);
this.model.renderSwitch();

if(base.isCoilCharging()) {
rotMod += 24.0F;
GL11.glRotatef(rotMod, 0.0f, 1.0F, 0.0F);
}
this.bindTexture(textureRotor);
this.model.renderRotor();
GL11.glEnable(GL11.GL_CULL_FACE);

GL11.glPopMatrix();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cofh.api.energy.EnergyStorage;
import cofh.api.energy.IEnergyHandler;
import com.dyonovan.modernalchemy.handlers.BlockHandler;
import com.dyonovan.modernalchemy.tileentity.BaseTile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
Expand All @@ -16,6 +17,21 @@ public TileTeslaBase() {

}

public boolean isCoilCharging() {
int y = yCoord + 1;
while(!worldObj.isAirBlock(xCoord, y, zCoord)) {
if(worldObj.getBlock(xCoord, y, zCoord) == BlockHandler.blockTeslaStand) {
y++;
continue;
}
else if(worldObj.getBlock(xCoord, y, zCoord) == BlockHandler.blockCoil)
return ((TileTeslaCoil)worldObj.getTileEntity(xCoord, y, zCoord)).isActive();
else
return false;
}
return false;
}

@Override
public void onWrench(EntityPlayer player) {
if(getTileInDirection(ForgeDirection.UP) instanceof TileTeslaStand)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public void searchMachines(EntityPlayer player) {

private boolean doConvert() {
if (energyRF.getEnergyStored() > 0 && energyTank.getEnergyLevel() < energyTank.getMaxCapacity()) {
isActive = true;
int actualRF = Math.min(ConfigHandler.maxCoilGenerate * ConfigHandler.rfPerTesla, energyRF.getEnergyStored());
int actualTesla = Math.min(ConfigHandler.maxCoilGenerate, energyTank.getMaxCapacity() - energyTank.getEnergyLevel());

Expand All @@ -90,6 +91,8 @@ private boolean doConvert() {
}
return true;
}
isActive = false;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
return false;
}

Expand Down

0 comments on commit 9c22c2e

Please sign in to comment.