Soldering Tools for cable connection
This commit is contained in:
parent
22c2f16509
commit
f96993bd33
7 changed files with 49 additions and 17 deletions
|
@ -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};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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*/}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1718,15 +1718,7 @@ 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 (consumeSolderingMaterial(tPlayer)) {
|
||||
if (canUseElectricItem(aStack, 10000)) {
|
||||
return GT_ModHandler.useElectricItem(aStack, 10000, (EntityPlayer) aPlayer);
|
||||
}
|
||||
|
@ -1734,7 +1726,6 @@ public class GT_ModHandler {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
damageOrDechargeItem(aStack, 1, 1000, aPlayer);
|
||||
return true;
|
||||
|
@ -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?
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue