public void computeInventory() { ItemStack primaryCable = inventory.getStackInSlot(TransformerContainer.primaryCableSlotId); ItemStack secondaryCable = inventory.getStackInSlot(TransformerContainer.secondaryCableSlotId); ItemStack core = inventory.getStackInSlot(TransformerContainer.ferromagneticSlotId); ElectricalCableDescriptor primaryCableDescriptor = null, secondaryCableDescriptor = null; // tranformerProcess.setEnable(primaryCable != null && core != null && secondaryCable != null); if (primaryCable != null) { primaryCableDescriptor = (ElectricalCableDescriptor) Eln.sixNodeItem.getDescriptor(primaryCable); } if (secondaryCable != null) { secondaryCableDescriptor = (ElectricalCableDescriptor) Eln.sixNodeItem.getDescriptor(secondaryCable); } if (primaryCableDescriptor != null) voltagePrimaryWatchdog.setUNominal(primaryCableDescriptor.electricalNominalVoltage); else voltagePrimaryWatchdog.setUNominal(1000000); if (secondaryCableDescriptor != null) voltageSecondaryWatchdog.setUNominal(secondaryCableDescriptor.electricalNominalVoltage); else voltageSecondaryWatchdog.setUNominal(1000000); double coreFactor = 1; if (core != null) { FerromagneticCoreDescriptor coreDescriptor = (FerromagneticCoreDescriptor) FerromagneticCoreDescriptor.getDescriptor(core); coreFactor = coreDescriptor.cableMultiplicator; } if (primaryCable == null || core == null) { primaryLoad.highImpedance(); primaryMaxCurrent = 0; } else { primaryCableDescriptor.applyTo(primaryLoad, coreFactor); primaryMaxCurrent = (float) primaryCableDescriptor.electricalMaximalCurrent; } if (secondaryCable == null || core == null) { secondaryLoad.highImpedance(); secondaryMaxCurrent = 0; } else { secondaryCableDescriptor.applyTo(secondaryLoad, coreFactor); secondaryMaxCurrent = (float) secondaryCableDescriptor.electricalMaximalCurrent; } if (primaryCable != null && secondaryCable != null) { interSystemProcess.setRatio(1.0 * secondaryCable.stackSize / primaryCable.stackSize); /* * tranformerProcess.setIMax( 2 * primaryCableDescriptor.electricalNominalPower / primaryCableDescriptor.electricalNominalVoltage, 2 * secondaryCableDescriptor.electricalNominalPower / secondaryCableDescriptor.electricalNominalVoltage); */ } else { interSystemProcess.setRatio(1); // tranformerProcess.setIMax( } }
@Override public void networkSerialize(DataOutputStream stream) { super.networkSerialize(stream); try { if (inventory.getStackInSlot(0) == null) stream.writeByte(0); else stream.writeByte(inventory.getStackInSlot(0).stackSize); if (inventory.getStackInSlot(1) == null) stream.writeByte(0); else stream.writeByte(inventory.getStackInSlot(1).stackSize); Utils.serialiseItemStack( stream, inventory.getStackInSlot(TransformerContainer.ferromagneticSlotId)); Utils.serialiseItemStack( stream, inventory.getStackInSlot(TransformerContainer.primaryCableSlotId)); Utils.serialiseItemStack( stream, inventory.getStackInSlot(TransformerContainer.secondaryCableSlotId)); node.lrduCubeMask.getTranslate(front.down()).serialize(stream); } catch (IOException e) { e.printStackTrace(); } }