summaryrefslogtreecommitdiff
path: root/src/main/java/ihl/flexible_cable/IHLCable.java
blob: e47621e19b7a2417cb1e920c36f3675cb8342fe0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package ihl.flexible_cable;

import ihl.metallurgy.constants.ElectricConductor;
import net.minecraft.nbt.NBTTagCompound;

public class IHLCable {

	public final int chainUID;
	public final int fullLength;
	public final int length;
	public final String material;
	public final int transverseSection;
	public final String insulationMaterial;
	public final int insulationThickness;
	public final int maxVoltage;
	public final int connectorX1;
	public final int connectorY1;
	public final int connectorZ1;
	public final int connectorDimensionId1;
	public final short connectorFacing1;
	public final int connectorX;
	public final int connectorY;
	public final int connectorZ;
	public final int connectorDimensionId;
	public final short connectorFacing;

	public IHLCable(int chainUIDIn, int fullLengthIn, int lengthIn, String materialIn, int transverseSectionIn,
			String insulationMaterialIn, int insulationThicknessIn, int maxVoltageIn, int connectorX1In,
			int connectorY1In, int connectorZ1In, int connectorDimensionId1In, short connectorFacing1In,
			int connectorXIn, int connectorYIn, int connectorZIn, int connectorDimensionIdIn, short connectorFacingIn) {
		chainUID = chainUIDIn;
		fullLength = fullLengthIn;
		length = lengthIn;
		material = materialIn;
		transverseSection = transverseSectionIn;
		insulationMaterial = insulationMaterialIn;
		insulationThickness = insulationThicknessIn;
		maxVoltage = maxVoltageIn;
		connectorX1 = connectorX1In;
		connectorY1 = connectorY1In;
		connectorZ1 = connectorZ1In;
		connectorDimensionId1 = connectorDimensionId1In;
		connectorFacing1 = connectorFacing1In;
		connectorX = connectorXIn;
		connectorY = connectorYIn;
		connectorZ = connectorZIn;
		connectorDimensionId = connectorDimensionIdIn;
		connectorFacing = connectorFacingIn;
	}

	public static IHLCable fromNBT(NBTTagCompound tag) {
		return new IHLCable(tag.getInteger("chainUID"),
		tag.getInteger("fullLength"),
		tag.getInteger("length"),
		tag.getString("material"),
		tag.getInteger("transverseSection"),
		tag.getString("insulationMaterial"),
		tag.getInteger("insulationThickness"),
		tag.getInteger("maxVoltage"),
		tag.getInteger("connectorX1"),
		tag.getInteger("connectorY1"),
		tag.getInteger("connectorZ1"),
		tag.getInteger("connectorDimensionId1"),
		tag.getShort("connectorFacing1"),
		tag.getInteger("connectorX"),
		tag.getInteger("connectorY"),
		tag.getInteger("connectorZ"),
		tag.getInteger("connectorDimensionId"),
		tag.getShort("connectorFacing"));
	}

	public NBTTagCompound toNBT() {
		NBTTagCompound tag = new NBTTagCompound();
		tag.setInteger("fullLength", fullLength);
		tag.setInteger("length", length);
		tag.setString("material", material);
		tag.setInteger("transverseSection", transverseSection);
		tag.setString("insulationMaterial", insulationMaterial);
		tag.setInteger("insulationThickness", insulationThickness);
		tag.setInteger("maxVoltage", maxVoltage);
		tag.setInteger("connectorX1",connectorX1);
		tag.setInteger("connectorY1",connectorY1);
		tag.setInteger("connectorZ1",connectorZ1);
		tag.setInteger("connectorDimensionId1",connectorDimensionId1);
		tag.setShort("connectorFacing1",connectorFacing1);
		tag.setInteger("connectorX",connectorX);
		tag.setInteger("connectorY",connectorY);
		tag.setInteger("connectorZ",connectorZ);
		tag.setInteger("connectorDimensionId",connectorDimensionId);
		tag.setShort("connectorFacing",connectorFacing);
		return tag;
	}

	@Override
	public int hashCode() {
		return chainUID;
	}

	@Override
	public boolean equals(Object o) {
		if (!(o instanceof IHLCable))
			return false;
		IHLCable otherCable = (IHLCable) o;
		return otherCable.chainUID == this.chainUID;
	}
	
	public long getResistance(){
		return ElectricConductor.getResistivity(material) * 100L / transverseSection;
	}

}