diff --git a/src/main/java/com/dyonovan/modernalchemy/model/teslacoil/ModelTeslaBase.java b/src/main/java/com/dyonovan/modernalchemy/model/teslacoil/ModelTeslaBase.java index 6017c75..3f38b44 100644 --- a/src/main/java/com/dyonovan/modernalchemy/model/teslacoil/ModelTeslaBase.java +++ b/src/main/java/com/dyonovan/modernalchemy/model/teslacoil/ModelTeslaBase.java @@ -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"); } } diff --git a/src/main/java/com/dyonovan/modernalchemy/renderer/teslacoil/ItemRenderTeslaBase.java b/src/main/java/com/dyonovan/modernalchemy/renderer/teslacoil/ItemRenderTeslaBase.java index ab34dbe..f461db5 100644 --- a/src/main/java/com/dyonovan/modernalchemy/renderer/teslacoil/ItemRenderTeslaBase.java +++ b/src/main/java/com/dyonovan/modernalchemy/renderer/teslacoil/ItemRenderTeslaBase.java @@ -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); diff --git a/src/main/java/com/dyonovan/modernalchemy/renderer/teslacoil/RenderTeslaBase.java b/src/main/java/com/dyonovan/modernalchemy/renderer/teslacoil/RenderTeslaBase.java index 5053df2..1dba9bb 100644 --- a/src/main/java/com/dyonovan/modernalchemy/renderer/teslacoil/RenderTeslaBase.java +++ b/src/main/java/com/dyonovan/modernalchemy/renderer/teslacoil/RenderTeslaBase.java @@ -2,6 +2,7 @@ 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; @@ -9,7 +10,11 @@ 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; @@ -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(); diff --git a/src/main/java/com/dyonovan/modernalchemy/tileentity/teslacoil/TileTeslaBase.java b/src/main/java/com/dyonovan/modernalchemy/tileentity/teslacoil/TileTeslaBase.java index 2de6fbf..3cedb45 100644 --- a/src/main/java/com/dyonovan/modernalchemy/tileentity/teslacoil/TileTeslaBase.java +++ b/src/main/java/com/dyonovan/modernalchemy/tileentity/teslacoil/TileTeslaBase.java @@ -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; @@ -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) diff --git a/src/main/java/com/dyonovan/modernalchemy/tileentity/teslacoil/TileTeslaCoil.java b/src/main/java/com/dyonovan/modernalchemy/tileentity/teslacoil/TileTeslaCoil.java index 5c69ffa..4d0fae9 100644 --- a/src/main/java/com/dyonovan/modernalchemy/tileentity/teslacoil/TileTeslaCoil.java +++ b/src/main/java/com/dyonovan/modernalchemy/tileentity/teslacoil/TileTeslaCoil.java @@ -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()); @@ -90,6 +91,8 @@ private boolean doConvert() { } return true; } + isActive = false; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); return false; }