Soldering Tools for cable connection

This commit is contained in:
Antifluxfield 2017-10-30 10:03:28 +08:00
parent 22c2f16509
commit f96993bd33
7 changed files with 49 additions and 17 deletions

View file

@ -281,6 +281,7 @@ public class GT_Mod implements IGT_Mod {
gregtechproxy.enableGCOres = GregTech_API.sWorldgenFile.get("general", "enableGCOres", gregtechproxy.enableGCOres);
gregtechproxy.enableUBOres = GregTech_API.sWorldgenFile.get("general", "enableUBOres", gregtechproxy.enableUBOres);
gregtechproxy.gt6Pipe = tMainConfig.get("general", "GT6StyledPipesAndWiresConnection", true).getBoolean(true);
gregtechproxy.costlyCableConnection = tMainConfig.get("general", "CableConnectionRequiresSolderingMaterial", true).getBoolean(true);
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};

View file

@ -825,7 +825,10 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
}
if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList)) {
if (GT_ModHandler.useSolderingIron(tCurrentItem, aPlayer)) {
if (mMetaTileEntity.onSolderingToolRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) {
GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 500, aPlayer);
GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord);
} else if (GT_ModHandler.useSolderingIron(tCurrentItem, aPlayer)) {
mStrongRedstone ^= (1 << tSide);
GT_Utility.sendChatToPlayer(aPlayer, trans("091","Redstone Output at Side ") + tSide + trans("092"," set to: ") + ((mStrongRedstone & (1 << tSide)) != 0 ? trans("093","Strong") : trans("094","Weak")));
GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(103), 3.0F, -1, xCoord, yCoord, zCoord);

View file

@ -209,6 +209,10 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable {
return false;
}
public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
return false;
}
@Override
public void onExplosion() {/*Do nothing*/}

View file

@ -16,6 +16,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.BaseMetaPipeEntity;
import gregtech.api.metatileentity.MetaPipeEntity;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Utility;
import gregtech.common.GT_Client;
import ic2.api.energy.tile.IEnergySink;
@ -253,10 +254,21 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile
@Override
public boolean onWireCutterRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
return onConnectionToolRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ);
}
@Override
public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
return onConnectionToolRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ);
}
private boolean onConnectionToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
if (GT_Mod.gregtechproxy.gt6Pipe) {
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;
connect(tSide);
}
else
disconnect(tSide);
return true;

View file

@ -1718,21 +1718,12 @@ public class GT_ModHandler {
EntityPlayer tPlayer = (EntityPlayer) aPlayer;
if (tPlayer.capabilities.isCreativeMode) return true;
if (isElectricItem(aStack) && ic2.api.item.ElectricItem.manager.getCharge(aStack) > 1000.0d) {
for (int i = 0; i < tPlayer.inventory.mainInventory.length; i++) {
if (GT_Utility.isStackInList(tPlayer.inventory.mainInventory[i], GregTech_API.sSolderingMetalList)) {
if (tPlayer.inventory.mainInventory[i].stackSize < 1) return false;
if (tPlayer.inventory.mainInventory[i].stackSize == 1) {
tPlayer.inventory.mainInventory[i] = null;
} else {
tPlayer.inventory.mainInventory[i].stackSize--;
}
if (tPlayer.inventoryContainer != null) tPlayer.inventoryContainer.detectAndSendChanges();
if (canUseElectricItem(aStack, 10000)) {
return GT_ModHandler.useElectricItem(aStack, 10000, (EntityPlayer) aPlayer);
}
GT_ModHandler.useElectricItem(aStack, (int) ic2.api.item.ElectricItem.manager.getCharge(aStack), (EntityPlayer) aPlayer);
return false;
if (consumeSolderingMaterial(tPlayer)) {
if (canUseElectricItem(aStack, 10000)) {
return GT_ModHandler.useElectricItem(aStack, 10000, (EntityPlayer) aPlayer);
}
GT_ModHandler.useElectricItem(aStack, (int) ic2.api.item.ElectricItem.manager.getCharge(aStack), (EntityPlayer) aPlayer);
return false;
}
}
} else {
@ -1743,6 +1734,26 @@ public class GT_ModHandler {
return false;
}
/**
* Simply consumes some soldering material
*/
public static boolean consumeSolderingMaterial(EntityPlayer aPlayer) {
if (aPlayer.capabilities.isCreativeMode) return true;
for (int i = 0; i < aPlayer.inventory.mainInventory.length; i++) {
if (GT_Utility.isStackInList(aPlayer.inventory.mainInventory[i], GregTech_API.sSolderingMetalList)) {
if (aPlayer.inventory.mainInventory[i].stackSize < 1) return false;
if (aPlayer.inventory.mainInventory[i].stackSize == 1) {
aPlayer.inventory.mainInventory[i] = null;
} else {
aPlayer.inventory.mainInventory[i].stackSize--;
}
if (aPlayer.inventoryContainer != null) aPlayer.inventoryContainer.detectAndSendChanges();
return true;
}
}
return false;
}
/**
* Is this an electric Item, which can charge other Items?
*/

View file

@ -354,7 +354,7 @@ public class GT_Client extends GT_Proxy
TileEntity aTileEntity = aEvent.player.worldObj.getTileEntity(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ);
try {
Class.forName("codechicken.lib.vec.Rotation");
if (((aTileEntity instanceof BaseMetaPipeEntity)) && (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.target.sideHit) == 0) && ((GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCovers.keySet())) || (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCrowbarList)) || (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sScrewdriverList)) || (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWireCutterList)))) {
if (((aTileEntity instanceof BaseMetaPipeEntity)) && (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.target.sideHit) == 0) && ((GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCovers.keySet())) || (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCrowbarList)) || (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sScrewdriverList)) || (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWireCutterList)) || (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sSolderingToolList)))) {
drawGrid(aEvent);
return;
}

View file

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