diff --git a/src/main/java/resonantinduction/MultipartRI.java b/src/main/java/resonantinduction/MultipartRI.java index a8ae993f..5276de28 100644 --- a/src/main/java/resonantinduction/MultipartRI.java +++ b/src/main/java/resonantinduction/MultipartRI.java @@ -16,9 +16,9 @@ public class MultipartRI implements IPartFactory public MultipartRI() { MultiPartRegistry.registerParts(this, new String[] { "resonant_induction_flat_wire", "resonant_induction_flat_switch_wire", "resonant_induction_multimeter", "resonant_induction_transformer" }); - MultipartGenerator.registerTrait("universalelectricity.api.energy.IConductor", "resonantinduction.wire.part.TraitConductor"); - MultipartGenerator.registerTrait("cofh.api.energy.IEnergyHandler", "resonantinduction.wire.part.TraitEnergyHandler"); - MultipartGenerator.registerTrait("ic2.api.energy.tile.IEnergySink", "resonantinduction.wire.part.TraitEnergySink"); + MultipartGenerator.registerTrait("universalelectricity.api.energy.IConductor", "resonantinduction.wire.trait.TraitConductor"); + MultipartGenerator.registerTrait("cofh.api.energy.IEnergyHandler", "resonantinduction.wire.trait.TraitEnergyHandler"); + MultipartGenerator.registerTrait("ic2.api.energy.tile.IEnergySink", "resonantinduction.wire.trait.TraitEnergySink"); } @Override diff --git a/src/main/java/resonantinduction/battery/RenderBattery.java b/src/main/java/resonantinduction/battery/RenderBattery.java index 607acb62..47a69837 100644 --- a/src/main/java/resonantinduction/battery/RenderBattery.java +++ b/src/main/java/resonantinduction/battery/RenderBattery.java @@ -3,18 +3,17 @@ */ package resonantinduction.battery; -import java.util.Random; - -import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.entity.item.EntityItem; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.AdvancedModelLoader; +import net.minecraftforge.client.model.IModelCustom; import org.lwjgl.opengl.GL11; import resonantinduction.ResonantInduction; import resonantinduction.model.ModelBattery; +import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -29,14 +28,72 @@ public class RenderBattery extends TileEntitySpecialRenderer public static final ResourceLocation TEXTURE_MULTI = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "battery_multi.png"); public static final ModelBattery MODEL = new ModelBattery(); - private EntityItem fakeBattery; - private Random random = new Random(); - protected RenderManager renderManager; + /*public static final Map MODELS; + + static + { + MODELS = CCModel.parseObjModels(new ResourceLocation("resonantinduction", "models/wire.obj"), 7, new InvertX()); + + for (CCModel c : MODELS.values()) + { + c.apply(new Translation(.5, 0, .5)); + c.computeLighting(LightModel.standardLightModel); + c.shrinkUVs(0.0005); + } + + loadBuffer(location, 0, 0, 0, 1); + loadBuffer(specular, 1, 1, 1, 1); + loadBuffer(zero, 0, 0, 0, 0); + loadBuffer(defaultAmbient, 0.4F, 0.4F, 0.4F, 1); + + GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, zero); + + GL11.glLight(GL11.GL_LIGHT3, GL11.GL_SPECULAR, specular); + + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_SPECULAR, specular); + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT, zero); + GL11.glMaterial(GL11.GL_FRONT, GL11.GL_DIFFUSE, zero); + GL11.glMaterialf(GL11.GL_FRONT, GL11.GL_SHININESS, 128f); + + } + + public void renderStatic(TileBattery battery) + { + TextureUtils.bindAtlas(0); + CCRenderState.reset(); + CCRenderState.useModelColours(true); + CCRenderState.setBrightness(battery.worldObj, battery.xCoord, battery.yCoord, battery.zCoord); + renderPart(ForgeDirection.UNKNOWN, wire); + byte renderSides = wire.getAllCurrentConnections(); + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) + { + if (PartWire.connectionMapContainsSide(renderSides, side)) + { + renderSide(side, wire); + } + } + + } + + public void renderPart(Icon icon, CCModel cc, double x, double y, double z, Colour colour) + { + cc.render(0, cc.verts.length, Rotation.sideOrientation(0, Rotation.rotationTo(0, 2)).at(codechicken.lib.vec.Vector3.center).with(new Translation(x, y, z)), new IconTransformation(icon), new ColourMultiplier(colour)); + }*/ + + static IModelCustom advancedmodel = AdvancedModelLoader.loadModel(ResonantInduction.MODEL_DIRECTORY+"battery.obj"); + + public static void render() + { + advancedmodel.renderAll(); + FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderBattery.TEXTURE); + } + @Override public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f) { - GL11.glPushMatrix(); + /*GL11.glPushMatrix(); GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); @@ -50,6 +107,6 @@ public class RenderBattery extends TileEntitySpecialRenderer } MODEL.render(0.0625f); - GL11.glPopMatrix(); + GL11.glPopMatrix();*/ } } diff --git a/src/main/java/resonantinduction/battery/TileBattery.java b/src/main/java/resonantinduction/battery/TileBattery.java index a123c9b6..5047a497 100644 --- a/src/main/java/resonantinduction/battery/TileBattery.java +++ b/src/main/java/resonantinduction/battery/TileBattery.java @@ -53,7 +53,7 @@ public class TileBattery extends TileAdvanced implements IPacketSender, IPacketR { if (!this.worldObj.isRemote) { - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) + /*for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { TileEntity tile = new Vector3(this).modifyPositionFromSide(dir).getTileEntity(this.worldObj); @@ -61,7 +61,7 @@ public class TileBattery extends TileAdvanced implements IPacketSender, IPacketR { this.structure.merge((TileBattery) tile); } - } + }*/ } } diff --git a/src/main/java/resonantinduction/render/BlockRenderingHandler.java b/src/main/java/resonantinduction/render/BlockRenderingHandler.java index d8977c99..8523b182 100644 --- a/src/main/java/resonantinduction/render/BlockRenderingHandler.java +++ b/src/main/java/resonantinduction/render/BlockRenderingHandler.java @@ -66,6 +66,12 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + if (block instanceof BlockBattery) + { + RenderBattery.render(); + return true; + } + return false; }