content: package mods.eln.sixnode.resistor;
  
  import mods.eln.Eln;
  import mods.eln.misc.*;
  import mods.eln.node.six.SixNodeDescriptor;
  import mods.eln.wiki.Data;
  import net.minecraft.entity.player.EntityPlayer;
  import net.minecraft.inventory.IInventory;
  import net.minecraft.item.ItemStack;
  import net.minecraftforge.client.IItemRenderer;
  import org.jetbrains.annotations.NotNull;
  import org.jetbrains.annotations.Nullable;
  import org.lwjgl.opengl.GL11;
  
  import java.util.List;
  
  import static mods.eln.i18n.I18N.tr;
  
  /**
   * Created by svein on 05/08/15.
   */
  public class ResistorDescriptor extends SixNodeDescriptor {
  
      public final boolean isRheostat;
      public double thermalCoolLimit = -100;
      public double thermalWarmLimit = Eln.cableWarmLimit;
      public double thermalMaximalPowerDissipated = 1000;
      public double thermalNominalHeatTime = 120;
      public double thermalConductivityTao = Eln.cableThermalConductionTao;
      public double tempCoef;
      Obj3D.Obj3DPart ResistorBaseExtension, ResistorCore, ResistorTrack, ResistorWiper, Base, Cables;
      IFunction series;
      private Obj3D obj;
  
  
      public ResistorDescriptor(String name,
                                Obj3D obj,
                                IFunction series,
                                double tempCoef,
                                boolean isRheostat) {
          super(name, ResistorElement.class, ResistorRender.class);
          this.obj = obj;
          this.series = series;
          this.tempCoef = tempCoef;
          this.isRheostat = isRheostat;
          if (obj != null) {
              ResistorBaseExtension = obj.getPart("ResistorBaseExtention");
              ResistorCore = obj.getPart("ResistorCore");
              ResistorTrack = obj.getPart("ResistorTrack");
              ResistorWiper = obj.getPart("ResistorWiper");
              Base = obj.getPart("Base");
              Cables = obj.getPart("CapacitorCables");
          }
          voltageLevelColor = VoltageLevelColor.Neutral;
      }
  
      public double getRsValue(IInventory inventory) {
          ItemStack core = inventory.getStackInSlot(ResistorContainer.coreId);
  
          if (core == null) return series.getValue(0);
          return series.getValue(core.stackSize);
      }
  
      @Override
      public void setParent(net.minecraft.item.Item item, int damage) {
          super.setParent(item, damage);
          Data.addEnergy(newItemStack());
      }
  
      void draw(float wiperPos) {
          //UtilsClient.disableCulling();
          //UtilsClient.disableTexture();
          //GL11.glRotatef(90, 1, 0, 0);
  
  
          if (null != Base) Base.draw();
          if (null != ResistorBaseExtension) ResistorBaseExtension.draw();
          if (null != ResistorCore) ResistorCore.draw();
          if (null != Cables) Cables.draw();
  
          if (isRheostat) {
              final float wiperSpread = 0.238f;
              wiperPos = (wiperPos - 0.5f) * wiperSpread * 2;
              ResistorTrack.draw();
              GL11.glTranslatef(0, 0, wiperPos);
              ResistorWiper.draw();
              // GL11.glTranslatef(-wiperPos, 0, 0);
          }
      }
  
      @Override
      public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) {
          return type != ItemRenderType.INVENTORY;
      }
  
      @Override
      public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) {
          return true;
      }
  
      @Override
      public void renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) {
          if (type != ItemRenderType.INVENTORY) {
              GL11.glTranslatef(0.0f, 0.0f, -0.2f);
              GL11.glScalef(1.25f, 1.25f, 1.25f);
              GL11.glRotatef(-90.f, 0.f, 1.f, 0.f);
              draw(0);
          } else {
              super.renderItem(type, item, data);
          }
      }
  
      @Nullable
      @Override
      public LRDU getFrontFromPlace(@NotNull Direction side, @NotNull EntityPlayer player) {
          return super.getFrontFromPlace(side, player).left();
      }
  
  
      @Override
      public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List<String> list, boolean par4) {
          super.addInformation(itemStack, entityPlayer, list, par4);
          list.add(tr("It's a resistor"));
      }
  
      @Override
      public RealisticEnum addRealismContext(List<String> list) {
          super.addRealismContext(list);
          return RealisticEnum.REALISTIC;
      }
  }
  