Another config to control wire connections, and disable them by default.

This commit is contained in:
Antifluxfield 2017-10-30 19:17:00 +08:00
parent 1e8189e5f9
commit 78aa11bd38
4 changed files with 24 additions and 9 deletions

View file

@ -280,8 +280,9 @@ public class GT_Mod implements IGT_Mod {
gregtechproxy.enableBasaltOres = GregTech_API.sWorldgenFile.get("general", "enableBasaltOres", gregtechproxy.enableBasaltOres); gregtechproxy.enableBasaltOres = GregTech_API.sWorldgenFile.get("general", "enableBasaltOres", gregtechproxy.enableBasaltOres);
gregtechproxy.enableGCOres = GregTech_API.sWorldgenFile.get("general", "enableGCOres", gregtechproxy.enableGCOres); gregtechproxy.enableGCOres = GregTech_API.sWorldgenFile.get("general", "enableGCOres", gregtechproxy.enableGCOres);
gregtechproxy.enableUBOres = GregTech_API.sWorldgenFile.get("general", "enableUBOres", gregtechproxy.enableUBOres); gregtechproxy.enableUBOres = GregTech_API.sWorldgenFile.get("general", "enableUBOres", gregtechproxy.enableUBOres);
gregtechproxy.gt6Pipe = tMainConfig.get("general", "GT6StyledPipesAndWiresConnection", true).getBoolean(true); gregtechproxy.gt6Pipe = tMainConfig.get("general", "GT6StyledPipesConnection", true).getBoolean(true);
gregtechproxy.costlyCableConnection = tMainConfig.get("general", "CableConnectionRequiresSolderingMaterial", true).getBoolean(true); gregtechproxy.gt6Cable = tMainConfig.get("general", "GT6StyledWiresConnection", false).getBoolean(false);
gregtechproxy.costlyCableConnection = tMainConfig.get("general", "CableConnectionRequiresSolderingMaterial", false).getBoolean(false);
Materials[] tDisableOres = new Materials[]{Materials.Chrome, Materials.Naquadria, Materials.Silicon, Materials.Cobalt, Materials.Cadmium, Materials.Indium, Materials.Tungsten, Materials[] tDisableOres = new Materials[]{Materials.Chrome, Materials.Naquadria, Materials.Silicon, Materials.Cobalt, Materials.Cadmium, Materials.Indium, Materials.Tungsten,
Materials.Adamantium, Materials.Mithril, Materials.DarkIron, Materials.Rutile, Materials.Alduorite, Materials.Magnesium, Materials.Nikolite}; Materials.Adamantium, Materials.Mithril, Materials.DarkIron, Materials.Rutile, Materials.Alduorite, Materials.Magnesium, Materials.Nikolite};

View file

@ -1,7 +1,7 @@
package gregtech.api.interfaces.metatileentity; package gregtech.api.interfaces.metatileentity;
/** /**
* For pipes, wires, and other MetaTiles which should be decided whether they should connect to the block at each side. * For pipes, wires, and other MetaTiles which need to be decided whether they should connect to the block at each side.
*/ */
public interface IConnectable { public interface IConnectable {
/** /**

View file

@ -44,7 +44,7 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile
public long mTransferredAmperage = 0, mTransferredAmperageLast20 = 0, mTransferredVoltageLast20 = 0; public long mTransferredAmperage = 0, mTransferredAmperageLast20 = 0, mTransferredVoltageLast20 = 0;
public long mRestRF; public long mRestRF;
public short mOverheat; public short mOverheat;
private boolean mCheckConnections = !GT_Mod.gregtechproxy.gt6Pipe; private boolean mCheckConnections = !GT_Mod.gregtechproxy.gt6Cable;
public GT_MetaPipeEntity_Cable(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) { public GT_MetaPipeEntity_Cable(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) {
super(aID, aName, aNameRegional, 0); super(aID, aName, aNameRegional, 0);
@ -247,7 +247,7 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile
for (byte i = 0; i < 6; i++) { for (byte i = 0; i < 6; i++) {
if ((mCheckConnections || (mConnections & (1 << i)) != 0) && connect(i) <= 0) disconnect(i); if ((mCheckConnections || (mConnections & (1 << i)) != 0) && connect(i) <= 0) disconnect(i);
} }
if (GT_Mod.gregtechproxy.gt6Pipe) mCheckConnections = false; if (GT_Mod.gregtechproxy.gt6Cable) mCheckConnections = false;
} }
}else if(aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected==4) aBaseMetaTileEntity.issueTextureUpdate(); }else if(aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected==4) aBaseMetaTileEntity.issueTextureUpdate();
} }
@ -263,7 +263,7 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile
} }
private boolean onConnectionToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { private boolean onConnectionToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
if (GT_Mod.gregtechproxy.gt6Pipe) { if (GT_Mod.gregtechproxy.gt6Cable) {
byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ);
if ((mConnections & (1 << tSide)) == 0) { if ((mConnections & (1 << tSide)) == 0) {
if (GT_Mod.gregtechproxy.costlyCableConnection && !GT_ModHandler.consumeSolderingMaterial(aPlayer)) return false; if (GT_Mod.gregtechproxy.costlyCableConnection && !GT_ModHandler.consumeSolderingMaterial(aPlayer)) return false;
@ -308,6 +308,19 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile
return rConnect; return rConnect;
} }
@Override
public void disconnect(byte aSide) {
if (aSide >= 6) return;
mConnections &= ~(1 << aSide);
if (GT_Mod.gregtechproxy.gt6Cable) {
byte tSide = GT_Utility.getOppositeSide(aSide);
IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSide(aSide);
IMetaTileEntity tPipe = tTileEntity == null ? null : tTileEntity.getMetaTileEntity();
if (this.getClass().isInstance(tPipe) && (((MetaPipeEntity) tPipe).mConnections & (1 << tSide)) != 0)
((MetaPipeEntity) tPipe).disconnect(tSide);
}
}
@Override @Override
public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
return false; return false;
@ -335,13 +348,13 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile
@Override @Override
public void saveNBTData(NBTTagCompound aNBT) { public void saveNBTData(NBTTagCompound aNBT) {
if (GT_Mod.gregtechproxy.gt6Pipe) if (GT_Mod.gregtechproxy.gt6Cable)
aNBT.setByte("mConnections", mConnections); aNBT.setByte("mConnections", mConnections);
} }
@Override @Override
public void loadNBTData(NBTTagCompound aNBT) { public void loadNBTData(NBTTagCompound aNBT) {
if (GT_Mod.gregtechproxy.gt6Pipe) { if (GT_Mod.gregtechproxy.gt6Cable) {
if (!aNBT.hasKey("mConnections")) if (!aNBT.hasKey("mConnections"))
mCheckConnections = true; mCheckConnections = true;
mConnections = aNBT.getByte("mConnections"); mConnections = aNBT.getByte("mConnections");

View file

@ -202,7 +202,8 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
public boolean enableGCOres = true; public boolean enableGCOres = true;
public boolean enableUBOres = true; public boolean enableUBOres = true;
public boolean gt6Pipe = true; public boolean gt6Pipe = true;
public boolean costlyCableConnection = true; public boolean gt6Cable = false;
public boolean costlyCableConnection = false;
public GT_Proxy() { public GT_Proxy() {
GameRegistry.registerFuelHandler(this); GameRegistry.registerFuelHandler(this);