Change if chains to switches

This commit is contained in:
Shawn Buckley 2015-10-25 09:27:29 -04:00
parent 756e7edc64
commit 46f4473de6
12 changed files with 90 additions and 221 deletions

View file

@ -36,41 +36,19 @@ public class GT_Cover_Conveyor
public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
aCoverVariable = (aCoverVariable + 1) % 12;
if (aCoverVariable == 0) {
GT_Utility.sendChatToPlayer(aPlayer, "Export");
}
if (aCoverVariable == 1) {
GT_Utility.sendChatToPlayer(aPlayer, "Import");
}
if (aCoverVariable == 2) {
GT_Utility.sendChatToPlayer(aPlayer, "Export (conditional)");
}
if (aCoverVariable == 3) {
GT_Utility.sendChatToPlayer(aPlayer, "Import (conditional)");
}
if (aCoverVariable == 4) {
GT_Utility.sendChatToPlayer(aPlayer, "Export (invert cond)");
}
if (aCoverVariable == 5) {
GT_Utility.sendChatToPlayer(aPlayer, "Import (invert cond)");
}
if (aCoverVariable == 6) {
GT_Utility.sendChatToPlayer(aPlayer, "Export allow Input");
}
if (aCoverVariable == 7) {
GT_Utility.sendChatToPlayer(aPlayer, "Import allow Output");
}
if (aCoverVariable == 8) {
GT_Utility.sendChatToPlayer(aPlayer, "Export allow Input (conditional)");
}
if (aCoverVariable == 9) {
GT_Utility.sendChatToPlayer(aPlayer, "Import allow Output (conditional)");
}
if (aCoverVariable == 10) {
GT_Utility.sendChatToPlayer(aPlayer, "Export allow Input (invert cond)");
}
if (aCoverVariable == 11) {
GT_Utility.sendChatToPlayer(aPlayer, "Import allow Output (invert cond)");
switch(aCoverVariable) {
case 0: GT_Utility.sendChatToPlayer(aPlayer, "Export"); break;
case 1: GT_Utility.sendChatToPlayer(aPlayer, "Import"); break;
case 2: GT_Utility.sendChatToPlayer(aPlayer, "Export (conditional)"); break;
case 3: GT_Utility.sendChatToPlayer(aPlayer, "Import (conditional)"); break;
case 4: GT_Utility.sendChatToPlayer(aPlayer, "Export (invert cond)"); break;
case 5: GT_Utility.sendChatToPlayer(aPlayer, "Import (invert cond)"); break;
case 6: GT_Utility.sendChatToPlayer(aPlayer, "Export allow Input"); break;
case 7: GT_Utility.sendChatToPlayer(aPlayer, "Import allow Output"); break;
case 8: GT_Utility.sendChatToPlayer(aPlayer, "Export allow Input (conditional)"); break;
case 9: GT_Utility.sendChatToPlayer(aPlayer, "Import allow Output (conditional)"); break;
case 10: GT_Utility.sendChatToPlayer(aPlayer, "Export allow Input (invert cond)"); break;
case 11: GT_Utility.sendChatToPlayer(aPlayer, "Import allow Output (invert cond)"); break;
}
return aCoverVariable;
}

View file

@ -29,17 +29,11 @@ public class GT_Cover_DoesWork
public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
aCoverVariable = (aCoverVariable + 1) % 4;
if (aCoverVariable == 0) {
GT_Utility.sendChatToPlayer(aPlayer, "Normal");
}
if (aCoverVariable == 1) {
GT_Utility.sendChatToPlayer(aPlayer, "Inverted");
}
if (aCoverVariable == 2) {
GT_Utility.sendChatToPlayer(aPlayer, "Ready to work");
}
if (aCoverVariable == 3) {
GT_Utility.sendChatToPlayer(aPlayer, "Not ready to work");
switch(aCoverVariable) {
case 0: GT_Utility.sendChatToPlayer(aPlayer, "Normal"); break;
case 1: GT_Utility.sendChatToPlayer(aPlayer, "Inverted"); break;
case 2: GT_Utility.sendChatToPlayer(aPlayer, "Ready to work"); break;
case 3: GT_Utility.sendChatToPlayer(aPlayer, "Not ready to work"); break;
}
return aCoverVariable;
}

View file

@ -59,23 +59,13 @@ public class GT_Cover_Drain
public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
aCoverVariable = (aCoverVariable + 1) % 6;
if (aCoverVariable == 0) {
GT_Utility.sendChatToPlayer(aPlayer, "Import");
}
if (aCoverVariable == 1) {
GT_Utility.sendChatToPlayer(aPlayer, "Import (conditional)");
}
if (aCoverVariable == 2) {
GT_Utility.sendChatToPlayer(aPlayer, "Import (invert cond)");
}
if (aCoverVariable == 3) {
GT_Utility.sendChatToPlayer(aPlayer, "Keep Liquids Away");
}
if (aCoverVariable == 4) {
GT_Utility.sendChatToPlayer(aPlayer, "Keep Liquids Away (conditional)");
}
if (aCoverVariable == 5) {
GT_Utility.sendChatToPlayer(aPlayer, "Keep Liquids Away (invert cond)");
switch(aCoverVariable) {
case 0: GT_Utility.sendChatToPlayer(aPlayer, "Import"); break;
case 1: GT_Utility.sendChatToPlayer(aPlayer, "Import (conditional)"); break;
case 2: GT_Utility.sendChatToPlayer(aPlayer, "Import (invert cond)"); break;
case 3: GT_Utility.sendChatToPlayer(aPlayer, "Keep Liquids Away"); break;
case 4: GT_Utility.sendChatToPlayer(aPlayer, "Keep Liquids Away (conditional)"); break;
case 5: GT_Utility.sendChatToPlayer(aPlayer, "Keep Liquids Away (invert cond)"); break;
}
return aCoverVariable;
}

View file

@ -92,41 +92,19 @@ public class GT_Cover_EUMeter
public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
aCoverVariable = (aCoverVariable + 1) % 12;
if (aCoverVariable == 0) {
GT_Utility.sendChatToPlayer(aPlayer, "Normal Universal Storage");
}
if (aCoverVariable == 1) {
GT_Utility.sendChatToPlayer(aPlayer, "Inverted Universal Storage");
}
if (aCoverVariable == 2) {
GT_Utility.sendChatToPlayer(aPlayer, "Normal Electricity Storage");
}
if (aCoverVariable == 3) {
GT_Utility.sendChatToPlayer(aPlayer, "Inverted Electricity Storage");
}
if (aCoverVariable == 4) {
GT_Utility.sendChatToPlayer(aPlayer, "Normal Steam Storage");
}
if (aCoverVariable == 5) {
GT_Utility.sendChatToPlayer(aPlayer, "Inverted Steam Storage");
}
if (aCoverVariable == 6) {
GT_Utility.sendChatToPlayer(aPlayer, "Normal Average Electric Input");
}
if (aCoverVariable == 7) {
GT_Utility.sendChatToPlayer(aPlayer, "Inverted Average Electric Input");
}
if (aCoverVariable == 8) {
GT_Utility.sendChatToPlayer(aPlayer, "Normal Average Electric Output");
}
if (aCoverVariable == 9) {
GT_Utility.sendChatToPlayer(aPlayer, "Inverted Average Electric Output");
}
if (aCoverVariable == 10) {
GT_Utility.sendChatToPlayer(aPlayer, "Normal Electricity Storage(Including Batterys)");
}
if (aCoverVariable == 11) {
GT_Utility.sendChatToPlayer(aPlayer, "Inverted Electricity Storage(Including Batterys)");
switch(aCoverVariable) {
case 0: GT_Utility.sendChatToPlayer(aPlayer, "Normal Universal Storage"); break;
case 1: GT_Utility.sendChatToPlayer(aPlayer, "Inverted Universal Storage"); break;
case 2: GT_Utility.sendChatToPlayer(aPlayer, "Normal Electricity Storage"); break;
case 3: GT_Utility.sendChatToPlayer(aPlayer, "Inverted Electricity Storage"); break;
case 4: GT_Utility.sendChatToPlayer(aPlayer, "Normal Steam Storage"); break;
case 5: GT_Utility.sendChatToPlayer(aPlayer, "Inverted Steam Storage"); break;
case 6: GT_Utility.sendChatToPlayer(aPlayer, "Normal Average Electric Input"); break;
case 7: GT_Utility.sendChatToPlayer(aPlayer, "Inverted Average Electric Input"); break;
case 8: GT_Utility.sendChatToPlayer(aPlayer, "Normal Average Electric Output"); break;
case 9: GT_Utility.sendChatToPlayer(aPlayer, "Inverted Average Electric Output"); break;
case 10: GT_Utility.sendChatToPlayer(aPlayer, "Normal Electricity Storage(Including Batteries)"); break;
case 11: GT_Utility.sendChatToPlayer(aPlayer, "Inverted Electricity Storage(Including Batteries)"); break;
}
return aCoverVariable;
}

View file

@ -11,14 +11,10 @@ public class GT_Cover_EnergyOnly
extends GT_CoverBehavior {
public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
aCoverVariable = (aCoverVariable + 1) % 3;
if (aCoverVariable == 0) {
GT_Utility.sendChatToPlayer(aPlayer, "Allow");
}
if (aCoverVariable == 1) {
GT_Utility.sendChatToPlayer(aPlayer, "Allow (conditional)");
}
if (aCoverVariable == 2) {
GT_Utility.sendChatToPlayer(aPlayer, "Disallow (conditional)");
switch(aCoverVariable) {
case 0: GT_Utility.sendChatToPlayer(aPlayer, "Allow"); break;
case 1: GT_Utility.sendChatToPlayer(aPlayer, "Allow (conditional)"); break;
case 2: GT_Utility.sendChatToPlayer(aPlayer, "Disallow (conditional)"); break;
}
return aCoverVariable;
}

View file

@ -38,12 +38,10 @@ public class GT_Cover_ItemMeter
public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
aCoverVariable = (aCoverVariable + 1) % (2 + aTileEntity.getSizeInventory());
if (aCoverVariable == 0) {
GT_Utility.sendChatToPlayer(aPlayer, "Normal");
} else if (aCoverVariable == 1) {
GT_Utility.sendChatToPlayer(aPlayer, "Inverted");
} else {
GT_Utility.sendChatToPlayer(aPlayer, "Slot: " + (aCoverVariable - 2));
switch(aCoverVariable) {
case 0: GT_Utility.sendChatToPlayer(aPlayer, "Normal"); break;
case 1: GT_Utility.sendChatToPlayer(aPlayer, "Inverted"); break;
default: GT_Utility.sendChatToPlayer(aPlayer, "Slot: " + (aCoverVariable - 2)); break;
}
return aCoverVariable;
}

View file

@ -45,35 +45,17 @@ public class GT_Cover_NeedMaintainance extends GT_CoverBehavior {
public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
aCoverVariable = (aCoverVariable + 1) % 10;
if (aCoverVariable == 0) {
GT_Utility.sendChatToPlayer(aPlayer, "Emit if 1 Maintainance Needed");
}
if (aCoverVariable == 1) {
GT_Utility.sendChatToPlayer(aPlayer, "Emit if 1 Maintainance Needed(inverted)");
}
if (aCoverVariable == 2) {
GT_Utility.sendChatToPlayer(aPlayer, "Emit if 2 Maintainance Needed");
}
if (aCoverVariable == 3) {
GT_Utility.sendChatToPlayer(aPlayer, "Emit if 2 Maintainance Needed(inverted)");
}
if (aCoverVariable == 4) {
GT_Utility.sendChatToPlayer(aPlayer, "Emit if 3 Maintainance Needed");
}
if (aCoverVariable == 5) {
GT_Utility.sendChatToPlayer(aPlayer, "Emit if 3 Maintainance Needed(inverted)");
}
if (aCoverVariable == 6) {
GT_Utility.sendChatToPlayer(aPlayer, "Emit if 4 Maintainance Needed");
}
if (aCoverVariable == 7) {
GT_Utility.sendChatToPlayer(aPlayer, "Emit if 4 Maintainance Needed(inverted)");
}
if (aCoverVariable == 8) {
GT_Utility.sendChatToPlayer(aPlayer, "Emit if 5 Maintainance Needed");
}
if (aCoverVariable == 9) {
GT_Utility.sendChatToPlayer(aPlayer, "Emit if 5 Maintainance Needed(inverted)");
switch(aCoverVariable) {
case 0: GT_Utility.sendChatToPlayer(aPlayer, "Emit if 1 Maintenance Needed"); break;
case 1: GT_Utility.sendChatToPlayer(aPlayer, "Emit if 1 Maintenance Needed(inverted)"); break;
case 2: GT_Utility.sendChatToPlayer(aPlayer, "Emit if 2 Maintenance Needed"); break;
case 3: GT_Utility.sendChatToPlayer(aPlayer, "Emit if 2 Maintenance Needed(inverted)"); break;
case 4: GT_Utility.sendChatToPlayer(aPlayer, "Emit if 3 Maintenance Needed"); break;
case 5: GT_Utility.sendChatToPlayer(aPlayer, "Emit if 3 Maintenance Needed(inverted)"); break;
case 6: GT_Utility.sendChatToPlayer(aPlayer, "Emit if 4 Maintenance Needed"); break;
case 7: GT_Utility.sendChatToPlayer(aPlayer, "Emit if 4 Maintenance Needed(inverted)"); break;
case 8: GT_Utility.sendChatToPlayer(aPlayer, "Emit if 5 Maintenance Needed"); break;
case 9: GT_Utility.sendChatToPlayer(aPlayer, "Emit if 5 Maintenance Needed(inverted)"); break;
}
return aCoverVariable;
}

View file

@ -54,14 +54,10 @@ public class GT_Cover_PlayerDetector extends GT_CoverBehavior {
public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
aCoverVariable = (aCoverVariable + 1) % 3;
if (aCoverVariable == 0) {
GT_Utility.sendChatToPlayer(aPlayer, "Emit if any Player is close");
}
if (aCoverVariable == 1) {
GT_Utility.sendChatToPlayer(aPlayer, "Emit if you are close");
}
if (aCoverVariable == 2) {
GT_Utility.sendChatToPlayer(aPlayer, "Emit if other player is close");
switch(aCoverVariable) {
case 0: GT_Utility.sendChatToPlayer(aPlayer, "Emit if any Player is close"); break;
case 1: GT_Utility.sendChatToPlayer(aPlayer, "Emit if you are close"); break;
case 2: GT_Utility.sendChatToPlayer(aPlayer, "Emit if other player is close"); break;
}
return aCoverVariable;
}

View file

@ -69,41 +69,19 @@ public class GT_Cover_Pump
public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
aCoverVariable = (aCoverVariable + 1) % 12;
if (aCoverVariable == 0) {
GT_Utility.sendChatToPlayer(aPlayer, "Export");
}
if (aCoverVariable == 1) {
GT_Utility.sendChatToPlayer(aPlayer, "Import");
}
if (aCoverVariable == 2) {
GT_Utility.sendChatToPlayer(aPlayer, "Export (conditional)");
}
if (aCoverVariable == 3) {
GT_Utility.sendChatToPlayer(aPlayer, "Import (conditional)");
}
if (aCoverVariable == 4) {
GT_Utility.sendChatToPlayer(aPlayer, "Export (invert cond)");
}
if (aCoverVariable == 5) {
GT_Utility.sendChatToPlayer(aPlayer, "Import (invert cond)");
}
if (aCoverVariable == 6) {
GT_Utility.sendChatToPlayer(aPlayer, "Export allow Input");
}
if (aCoverVariable == 7) {
GT_Utility.sendChatToPlayer(aPlayer, "Import allow Output");
}
if (aCoverVariable == 8) {
GT_Utility.sendChatToPlayer(aPlayer, "Export allow Input (conditional)");
}
if (aCoverVariable == 9) {
GT_Utility.sendChatToPlayer(aPlayer, "Import allow Output (conditional)");
}
if (aCoverVariable == 10) {
GT_Utility.sendChatToPlayer(aPlayer, "Export allow Input (invert cond)");
}
if (aCoverVariable == 11) {
GT_Utility.sendChatToPlayer(aPlayer, "Import allow Output (invert cond)");
switch(aCoverVariable) {
case 0: GT_Utility.sendChatToPlayer(aPlayer, "Export"); break;
case 1: GT_Utility.sendChatToPlayer(aPlayer, "Import"); break;
case 2: GT_Utility.sendChatToPlayer(aPlayer, "Export (conditional)"); break;
case 3: GT_Utility.sendChatToPlayer(aPlayer, "Import (conditional)"); break;
case 4: GT_Utility.sendChatToPlayer(aPlayer, "Export (invert cond)"); break;
case 5: GT_Utility.sendChatToPlayer(aPlayer, "Import (invert cond)"); break;
case 6: GT_Utility.sendChatToPlayer(aPlayer, "Export allow Input"); break;
case 7: GT_Utility.sendChatToPlayer(aPlayer, "Import allow Output"); break;
case 8: GT_Utility.sendChatToPlayer(aPlayer, "Export allow Input (conditional)"); break;
case 9: GT_Utility.sendChatToPlayer(aPlayer, "Import allow Output (conditional)"); break;
case 10: GT_Utility.sendChatToPlayer(aPlayer, "Export allow Input (invert cond)"); break;
case 11: GT_Utility.sendChatToPlayer(aPlayer, "Import allow Output (invert cond)"); break;
}
return aCoverVariable;
}

View file

@ -20,26 +20,13 @@ public class GT_Cover_RedstoneConductor
public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
aCoverVariable = (aCoverVariable + 1) % 7;
switch (aCoverVariable) {
case 0:
GT_Utility.sendChatToPlayer(aPlayer, "Conducts strongest Input");
break;
case 1:
GT_Utility.sendChatToPlayer(aPlayer, "Conducts from bottom Input");
break;
case 2:
GT_Utility.sendChatToPlayer(aPlayer, "Conducts from top Input");
break;
case 3:
GT_Utility.sendChatToPlayer(aPlayer, "Conducts from north Input");
break;
case 4:
GT_Utility.sendChatToPlayer(aPlayer, "Conducts from south Input");
break;
case 5:
GT_Utility.sendChatToPlayer(aPlayer, "Conducts from west Input");
break;
case 6:
GT_Utility.sendChatToPlayer(aPlayer, "Conducts from east Input");
case 0: GT_Utility.sendChatToPlayer(aPlayer, "Conducts strongest Input"); break;
case 1: GT_Utility.sendChatToPlayer(aPlayer, "Conducts from bottom Input"); break;
case 2: GT_Utility.sendChatToPlayer(aPlayer, "Conducts from top Input"); break;
case 3: GT_Utility.sendChatToPlayer(aPlayer, "Conducts from north Input"); break;
case 4: GT_Utility.sendChatToPlayer(aPlayer, "Conducts from south Input"); break;
case 5: GT_Utility.sendChatToPlayer(aPlayer, "Conducts from west Input"); break;
case 6: GT_Utility.sendChatToPlayer(aPlayer, "Conducts from east Input"); break;
}
return aCoverVariable;
}

View file

@ -11,12 +11,10 @@ public class GT_Cover_RedstoneSignalizer
extends GT_CoverBehavior {
public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
aCoverVariable = (aCoverVariable + 1) % 48;
if (aCoverVariable / 16 == 0) {
GT_Utility.sendChatToPlayer(aPlayer, "Signal = " + (aCoverVariable & 0xF));
} else if (aCoverVariable / 16 == 1) {
GT_Utility.sendChatToPlayer(aPlayer, "Conditional Signal = " + (aCoverVariable & 0xF));
} else if (aCoverVariable / 16 == 2) {
GT_Utility.sendChatToPlayer(aPlayer, "Inverted Conditional Signal = " + (aCoverVariable & 0xF));
switch(aCoverVariable / 16) {
case 0: GT_Utility.sendChatToPlayer(aPlayer, "Signal = " + (aCoverVariable & 0xF)); break;
case 1: GT_Utility.sendChatToPlayer(aPlayer, "Conditional Signal = " + (aCoverVariable & 0xF)); break;
case 2: GT_Utility.sendChatToPlayer(aPlayer, "Inverted Conditional Signal = " + (aCoverVariable & 0xF)); break;
}
return aCoverVariable;
}

View file

@ -15,17 +15,11 @@ public class GT_Cover_Shutter
public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) {
aCoverVariable = (aCoverVariable + 1) % 4;
if (aCoverVariable == 0) {
GT_Utility.sendChatToPlayer(aPlayer, "Open if work enabled");
}
if (aCoverVariable == 1) {
GT_Utility.sendChatToPlayer(aPlayer, "Open if work disabled");
}
if (aCoverVariable == 2) {
GT_Utility.sendChatToPlayer(aPlayer, "Only Output allowed");
}
if (aCoverVariable == 3) {
GT_Utility.sendChatToPlayer(aPlayer, "Only Input allowed");
switch(aCoverVariable) {
case 0: GT_Utility.sendChatToPlayer(aPlayer, "Open if work enabled"); break;
case 1: GT_Utility.sendChatToPlayer(aPlayer, "Open if work disabled"); break;
case 2: GT_Utility.sendChatToPlayer(aPlayer, "Only Output allowed"); break;
case 3: GT_Utility.sendChatToPlayer(aPlayer, "Only Input allowed"); break;
}
return aCoverVariable;
}