From 307d3252e60c6a53a8e292cdf8bed5ab5e903616 Mon Sep 17 00:00:00 2001 From: Daggerhound Date: Sun, 6 Oct 2024 02:25:55 -0300 Subject: [PATCH 1/7] Hot Swapping Cables & Wires --- .../implementations/MTECable.java | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java b/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java index ef1a3fe96b2..8944fd5552d 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java @@ -12,9 +12,13 @@ import java.util.HashSet; import java.util.List; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.util.*; +import gregtech.common.blocks.ItemMachines; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -49,12 +53,6 @@ import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.objects.GTCoverNone; import gregtech.api.render.TextureFactory; -import gregtech.api.util.CoverBehavior; -import gregtech.api.util.CoverBehaviorBase; -import gregtech.api.util.GTGCCompat; -import gregtech.api.util.GTModHandler; -import gregtech.api.util.GTUtility; -import gregtech.api.util.ISerializableObject; import gregtech.common.GTClient; import gregtech.common.covers.CoverInfo; import gregtech.common.covers.CoverSolarPanel; @@ -262,6 +260,25 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { && (!GTMod.gregtechproxy.gt6Cable || mCheckConnections)) { checkConnections(); } + System.out.printf("Still kicking! %f %d %d`\n", this.mThickNess, this.mAmperage, this.mVoltage); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, float aX, float aY, float aZ) { + final ItemStack handItem = aPlayer.inventory.getCurrentItem(); + System.out.println(this.getThickNess() + ": success 1"); + IMetaTileEntity meta = ItemMachines.getMetaTileEntity(handItem); + if (meta instanceof MTECable a) { + World world = this.getBaseMetaTileEntity().getWorld(); + // world.getBlock((int) aX, (int) aY, (int) aZ) + world.setBlock( + this.getBaseMetaTileEntity().getXCoord(), + this.getBaseMetaTileEntity().getYCoord(), + this.getBaseMetaTileEntity().getZCoord(), + Blocks.air); + System.out.print("Success 2 !"); + } + return super.onRightclick(aBaseMetaTileEntity, aPlayer, side, aX, aY, aZ); } @Override From a0425f32864193ea3fdf610ed06ecf25fea045ee Mon Sep 17 00:00:00 2001 From: Daggerhound Date: Tue, 8 Oct 2024 10:38:57 -0300 Subject: [PATCH 2/7] Cleaner replacement & mConnections fix --- .../implementations/MTECable.java | 87 +++++++++++++++---- 1 file changed, 70 insertions(+), 17 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java b/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java index 8944fd5552d..afff820b66a 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java @@ -13,8 +13,11 @@ import java.util.List; import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.*; import gregtech.api.util.*; +import gregtech.common.blocks.BlockMachines; import gregtech.common.blocks.ItemMachines; +import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -31,10 +34,6 @@ import cofh.api.energy.IEnergyReceiver; import gregtech.GTMod; import gregtech.api.GregTechAPI; -import gregtech.api.enums.Dyes; -import gregtech.api.enums.Materials; -import gregtech.api.enums.TextureSet; -import gregtech.api.enums.Textures; import gregtech.api.graphs.Node; import gregtech.api.graphs.NodeList; import gregtech.api.graphs.PowerNode; @@ -64,6 +63,7 @@ import ic2.api.reactor.IReactorChamber; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; +import org.lwjgl.input.Keyboard; public class MTECable extends MetaPipeEntity implements IMetaTileEntityCable { @@ -260,23 +260,76 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { && (!GTMod.gregtechproxy.gt6Cable || mCheckConnections)) { checkConnections(); } - System.out.printf("Still kicking! %f %d %d`\n", this.mThickNess, this.mAmperage, this.mVoltage); +// System.out.printf("Still kicking! %f %d %d`\n", this.mThickNess, this.mAmperage, this.mVoltage); } @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, float aX, float aY, float aZ) { - final ItemStack handItem = aPlayer.inventory.getCurrentItem(); - System.out.println(this.getThickNess() + ": success 1"); - IMetaTileEntity meta = ItemMachines.getMetaTileEntity(handItem); - if (meta instanceof MTECable a) { - World world = this.getBaseMetaTileEntity().getWorld(); - // world.getBlock((int) aX, (int) aY, (int) aZ) + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, float aX, float aY, float aZ) throws NullPointerException{ + if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { + final ItemStack handItem = aPlayer.inventory.getCurrentItem(); + IMetaTileEntity meta = ItemMachines.getMetaTileEntity(handItem); + + // public MTECable(String aName, float aThickNess, Materials aMaterial, long aCableLossPerMeter, long aAmperage, + // long aVoltage, boolean aInsulated, boolean aCanShock) + + World world = aBaseMetaTileEntity.getWorld(); world.setBlock( - this.getBaseMetaTileEntity().getXCoord(), - this.getBaseMetaTileEntity().getYCoord(), - this.getBaseMetaTileEntity().getZCoord(), - Blocks.air); - System.out.print("Success 2 !"); + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + Blocks.air + ); + + MTECable b; + byte temp; +// MTECable a = (MTECable) this.newMetaEntity(ItemMachines.getMetaTileEntity(handItem).getBaseMetaTileEntity()); + if (meta instanceof MTECable a) { + temp = ((BaseMetaPipeEntity) aBaseMetaTileEntity).mConnections; + aBaseMetaTileEntity.setMetaTileEntity( + b = new MTECable( + a.mName, + a.mThickNess, + a.mMaterial, + a.mCableLossPerMeter, + a.mAmperage, + a.mVoltage, + a.mInsulated, + a.mCanShock + ) + ); + b.mCheckConnections = true; + b.checkConnections(); + } + + //.get(1L).tryPlaceItemIntoWorld() +// System.out.println(this.getThickNess() + ": success 1"); +// +// IGregTechTileEntity gtte = this.getBaseMetaTileEntity(); +// IMetaTileEntity meta = ItemMachines.getMetaTileEntity(handItem); +// Block block = BlockMachines.getBlockFromItem(handItem.getItem()); +// +// byte temp = this.mConnections; +// +// if (meta instanceof MTECable a) { +// World world = gtte.getWorld(); +// // world.getBlock((int) aX, (int) aY, (int) aZ) +// this.markDirty(); +// +// world.setBlock( +// gtte.getXCoord(), +// gtte.getYCoord(), +// gtte.getZCoord(), +// block, +// handItem.getItemDamage(), +// 0b11); +// +// a.mConnections = temp; +// a.mCheckConnections = false; +// gtte.setMetaTileEntity(meta); +// +// System.out.print("Success 2 !"); +// } + } return super.onRightclick(aBaseMetaTileEntity, aPlayer, side, aX, aY, aZ); } From a0eacd2199f1e4f9c8dab1ba35b28b6e8f763c8b Mon Sep 17 00:00:00 2001 From: Daggerhound Date: Fri, 11 Oct 2024 06:16:09 -0300 Subject: [PATCH 3/7] Clean hotswap, mConnections full fix, MODKEY set to LCONTROL, spotless apply --- .../implementations/MTECable.java | 148 ++++++++---------- 1 file changed, 62 insertions(+), 86 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java b/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java index afff820b66a..05d70626e2e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java @@ -12,12 +12,6 @@ import java.util.HashSet; import java.util.List; -import cpw.mods.fml.common.registry.GameRegistry; -import gregtech.api.enums.*; -import gregtech.api.util.*; -import gregtech.common.blocks.BlockMachines; -import gregtech.common.blocks.ItemMachines; -import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -31,9 +25,12 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import org.lwjgl.input.Keyboard; + import cofh.api.energy.IEnergyReceiver; import gregtech.GTMod; import gregtech.api.GregTechAPI; +import gregtech.api.enums.*; import gregtech.api.graphs.Node; import gregtech.api.graphs.NodeList; import gregtech.api.graphs.PowerNode; @@ -52,7 +49,9 @@ import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.objects.GTCoverNone; import gregtech.api.render.TextureFactory; +import gregtech.api.util.*; import gregtech.common.GTClient; +import gregtech.common.blocks.ItemMachines; import gregtech.common.covers.CoverInfo; import gregtech.common.covers.CoverSolarPanel; import ic2.api.energy.EnergyNet; @@ -63,7 +62,6 @@ import ic2.api.reactor.IReactorChamber; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; -import org.lwjgl.input.Keyboard; public class MTECable extends MetaPipeEntity implements IMetaTileEntityCable { @@ -75,7 +73,7 @@ public class MTECable extends MetaPipeEntity implements IMetaTileEntityCable { public int mTransferredAmperage = 0; public MTECable(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, - long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) { + long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) { super(aID, aName, aNameRegional, 0); mThickNess = aThickNess; mMaterial = aMaterial; @@ -87,7 +85,7 @@ public MTECable(int aID, String aName, String aNameRegional, float aThickNess, M } public MTECable(String aName, float aThickNess, Materials aMaterial, long aCableLossPerMeter, long aAmperage, - long aVoltage, boolean aInsulated, boolean aCanShock) { + long aVoltage, boolean aInsulated, boolean aCanShock) { super(aName, 0); mThickNess = aThickNess; mMaterial = aMaterial; @@ -118,7 +116,7 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { @Override public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, - int facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + int facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { if (!mInsulated) return new ITexture[] { TextureFactory .of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], Dyes.getModulation(colorIndex, mMaterial.mRGBa)) }; if (active) { @@ -227,13 +225,13 @@ public long injectEnergyUnits(ForgeDirection side, long voltage, long amperage) @Override @Deprecated public long transferElectricity(ForgeDirection side, long aVoltage, long aAmperage, - ArrayList aAlreadyPassedTileEntityList) { + ArrayList aAlreadyPassedTileEntityList) { return transferElectricity(side, aVoltage, aAmperage, new HashSet<>(aAlreadyPassedTileEntityList)); } @Override public long transferElectricity(ForgeDirection side, long voltage, long amperage, - HashSet alreadyPassedSet) { + HashSet alreadyPassedSet) { if (!getBaseMetaTileEntity().isServerSide() || !isConnectedAtSide(side) && side != ForgeDirection.UNKNOWN) return 0; final BaseMetaPipeEntity tBase = (BaseMetaPipeEntity) getBaseMetaTileEntity(); @@ -260,83 +258,61 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { && (!GTMod.gregtechproxy.gt6Cable || mCheckConnections)) { checkConnections(); } -// System.out.printf("Still kicking! %f %d %d`\n", this.mThickNess, this.mAmperage, this.mVoltage); } @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, float aX, float aY, float aZ) throws NullPointerException{ + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, + float aX, float aY, float aZ) { if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { final ItemStack handItem = aPlayer.inventory.getCurrentItem(); IMetaTileEntity meta = ItemMachines.getMetaTileEntity(handItem); - // public MTECable(String aName, float aThickNess, Materials aMaterial, long aCableLossPerMeter, long aAmperage, - // long aVoltage, boolean aInsulated, boolean aCanShock) + if (!(meta instanceof MTECable handCable)) { + return false; + } + MTECable newCable; World world = aBaseMetaTileEntity.getWorld(); + + getBaseMetaTileEntity().setMetaTileEntity( + newCable = new MTECable( + handCable.mName, + handCable.mThickNess, + handCable.mMaterial, + handCable.mCableLossPerMeter, + handCable.mAmperage, + handCable.mVoltage, + handCable.mInsulated, + handCable.mCanShock)); + world.setBlock( aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord(), - Blocks.air - ); - - MTECable b; - byte temp; -// MTECable a = (MTECable) this.newMetaEntity(ItemMachines.getMetaTileEntity(handItem).getBaseMetaTileEntity()); - if (meta instanceof MTECable a) { - temp = ((BaseMetaPipeEntity) aBaseMetaTileEntity).mConnections; - aBaseMetaTileEntity.setMetaTileEntity( - b = new MTECable( - a.mName, - a.mThickNess, - a.mMaterial, - a.mCableLossPerMeter, - a.mAmperage, - a.mVoltage, - a.mInsulated, - a.mCanShock - ) - ); - b.mCheckConnections = true; - b.checkConnections(); - } + Blocks.air); - //.get(1L).tryPlaceItemIntoWorld() -// System.out.println(this.getThickNess() + ": success 1"); -// -// IGregTechTileEntity gtte = this.getBaseMetaTileEntity(); -// IMetaTileEntity meta = ItemMachines.getMetaTileEntity(handItem); -// Block block = BlockMachines.getBlockFromItem(handItem.getItem()); -// -// byte temp = this.mConnections; -// -// if (meta instanceof MTECable a) { -// World world = gtte.getWorld(); -// // world.getBlock((int) aX, (int) aY, (int) aZ) -// this.markDirty(); -// -// world.setBlock( -// gtte.getXCoord(), -// gtte.getYCoord(), -// gtte.getZCoord(), -// block, -// handItem.getItemDamage(), -// 0b11); -// -// a.mConnections = temp; -// a.mCheckConnections = false; -// gtte.setMetaTileEntity(meta); -// -// System.out.print("Success 2 !"); -// } + handItem.tryPlaceItemIntoWorld( + aPlayer, + world, + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + ForgeDirection.UNKNOWN.ordinal(), + aX, + aY, + aZ); + newCable.mCheckConnections = true; + newCable.onPostTick(aBaseMetaTileEntity, 20); + + return true; } return super.onRightclick(aBaseMetaTileEntity, aPlayer, side, aX, aY, aZ); } @Override public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, - float aX, float aY, float aZ) { + float aX, float aY, float aZ) { if (GTMod.gregtechproxy.gt6Cable && GTModHandler.damageOrDechargeItem(aPlayer.inventory.getCurrentItem(), 1, 500, aPlayer)) { if (isConnectedAtSide(wrenchingSide)) { @@ -353,7 +329,7 @@ public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrench @Override public boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, - float aX, float aY, float aZ) { + float aX, float aY, float aZ) { if (GTMod.gregtechproxy.gt6Cable && GTModHandler.damageOrDechargeItem(aPlayer.inventory.getCurrentItem(), 1, 500, aPlayer)) { if (isConnectedAtSide(wrenchingSide)) { @@ -370,25 +346,25 @@ public boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wre @Override public boolean letsIn(CoverBehavior coverBehavior, ForgeDirection side, int aCoverID, int aCoverVariable, - ICoverable aTileEntity) { + ICoverable aTileEntity) { return coverBehavior.letsEnergyIn(side, aCoverID, aCoverVariable, aTileEntity); } @Override public boolean letsOut(CoverBehavior coverBehavior, ForgeDirection side, int aCoverID, int aCoverVariable, - ICoverable aTileEntity) { + ICoverable aTileEntity) { return coverBehavior.letsEnergyOut(side, aCoverID, aCoverVariable, aTileEntity); } @Override public boolean letsIn(CoverBehaviorBase coverBehavior, ForgeDirection side, int aCoverID, - ISerializableObject aCoverVariable, ICoverable aTileEntity) { + ISerializableObject aCoverVariable, ICoverable aTileEntity) { return coverBehavior.letsEnergyIn(side, aCoverID, aCoverVariable, aTileEntity); } @Override public boolean letsOut(CoverBehaviorBase coverBehavior, ForgeDirection side, int aCoverID, - ISerializableObject aCoverVariable, ICoverable aTileEntity) { + ISerializableObject aCoverVariable, ICoverable aTileEntity) { return coverBehavior.letsEnergyOut(side, aCoverID, aCoverVariable, aTileEntity); } @@ -411,8 +387,8 @@ public boolean canConnect(ForgeDirection side, TileEntity tileEntity) { // GT Machine handling if ((tileEntity instanceof PowerLogicHost powerLogic && powerLogic.getPowerLogic(oppositeSide) != null) || ((tileEntity instanceof IEnergyConnected energyConnected) - && (energyConnected.inputEnergyFrom(oppositeSide, false) - || energyConnected.outputsEnergyTo(oppositeSide, false)))) + && (energyConnected.inputEnergyFrom(oppositeSide, false) + || energyConnected.outputsEnergyTo(oppositeSide, false)))) return true; // Solar Panel Compat @@ -435,7 +411,7 @@ public boolean canConnect(ForgeDirection side, TileEntity tileEntity) { else ic2Energy = (tileEntity == null || tileEntity instanceof IEnergyTile || EnergyNet.instance == null) ? tileEntity : EnergyNet.instance - .getTileEntity(tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); + .getTileEntity(tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); // IC2 Sink Compat if ((ic2Energy instanceof IEnergySink) @@ -465,13 +441,13 @@ public boolean getGT6StyleConnection() { @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { + ItemStack aStack) { return false; } @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { + ItemStack aStack) { return false; } @@ -624,7 +600,7 @@ private AxisAlignedBB getActualCollisionBoundingBoxFromPool(World aWorld, int aX @Override public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, - List outputAABB, Entity collider) { + List outputAABB, Entity collider) { super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); if (GTMod.instance.isClientSide() && (GTClient.hideValue & 0x2) != 0) { final AxisAlignedBB aabb = getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); @@ -643,12 +619,12 @@ public boolean shouldJoinIc2Enet() { final TileEntity tTileEntity = baseMeta.getTileEntityAtSide(side); final TileEntity tEmitter = (tTileEntity == null || tTileEntity instanceof IEnergyTile || EnergyNet.instance == null) - ? tTileEntity - : EnergyNet.instance.getTileEntity( - tTileEntity.getWorldObj(), - tTileEntity.xCoord, - tTileEntity.yCoord, - tTileEntity.zCoord); + ? tTileEntity + : EnergyNet.instance.getTileEntity( + tTileEntity.getWorldObj(), + tTileEntity.xCoord, + tTileEntity.yCoord, + tTileEntity.zCoord); if (tEmitter instanceof IEnergyEmitter) return true; } @@ -694,7 +670,7 @@ public void reloadLocks() { @Override public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { + IWailaConfigHandler config) { currenttip.add( StatCollector.translateToLocal("GT5U.item.cable.max_voltage") + ": " From 6acca7d688e2928267126ddac25b40d4feaf5d49 Mon Sep 17 00:00:00 2001 From: Daggerhound Date: Fri, 11 Oct 2024 06:34:12 -0300 Subject: [PATCH 4/7] spotless reapply --- .../implementations/MTECable.java | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java b/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java index 05d70626e2e..0b71dade860 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java @@ -73,7 +73,7 @@ public class MTECable extends MetaPipeEntity implements IMetaTileEntityCable { public int mTransferredAmperage = 0; public MTECable(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, - long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) { + long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) { super(aID, aName, aNameRegional, 0); mThickNess = aThickNess; mMaterial = aMaterial; @@ -85,7 +85,7 @@ public MTECable(int aID, String aName, String aNameRegional, float aThickNess, M } public MTECable(String aName, float aThickNess, Materials aMaterial, long aCableLossPerMeter, long aAmperage, - long aVoltage, boolean aInsulated, boolean aCanShock) { + long aVoltage, boolean aInsulated, boolean aCanShock) { super(aName, 0); mThickNess = aThickNess; mMaterial = aMaterial; @@ -116,7 +116,7 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { @Override public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, - int facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + int facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { if (!mInsulated) return new ITexture[] { TextureFactory .of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], Dyes.getModulation(colorIndex, mMaterial.mRGBa)) }; if (active) { @@ -225,13 +225,13 @@ public long injectEnergyUnits(ForgeDirection side, long voltage, long amperage) @Override @Deprecated public long transferElectricity(ForgeDirection side, long aVoltage, long aAmperage, - ArrayList aAlreadyPassedTileEntityList) { + ArrayList aAlreadyPassedTileEntityList) { return transferElectricity(side, aVoltage, aAmperage, new HashSet<>(aAlreadyPassedTileEntityList)); } @Override public long transferElectricity(ForgeDirection side, long voltage, long amperage, - HashSet alreadyPassedSet) { + HashSet alreadyPassedSet) { if (!getBaseMetaTileEntity().isServerSide() || !isConnectedAtSide(side) && side != ForgeDirection.UNKNOWN) return 0; final BaseMetaPipeEntity tBase = (BaseMetaPipeEntity) getBaseMetaTileEntity(); @@ -262,7 +262,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, - float aX, float aY, float aZ) { + float aX, float aY, float aZ) { if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { final ItemStack handItem = aPlayer.inventory.getCurrentItem(); IMetaTileEntity meta = ItemMachines.getMetaTileEntity(handItem); @@ -312,7 +312,7 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye @Override public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, - float aX, float aY, float aZ) { + float aX, float aY, float aZ) { if (GTMod.gregtechproxy.gt6Cable && GTModHandler.damageOrDechargeItem(aPlayer.inventory.getCurrentItem(), 1, 500, aPlayer)) { if (isConnectedAtSide(wrenchingSide)) { @@ -329,7 +329,7 @@ public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrench @Override public boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, - float aX, float aY, float aZ) { + float aX, float aY, float aZ) { if (GTMod.gregtechproxy.gt6Cable && GTModHandler.damageOrDechargeItem(aPlayer.inventory.getCurrentItem(), 1, 500, aPlayer)) { if (isConnectedAtSide(wrenchingSide)) { @@ -346,25 +346,25 @@ public boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wre @Override public boolean letsIn(CoverBehavior coverBehavior, ForgeDirection side, int aCoverID, int aCoverVariable, - ICoverable aTileEntity) { + ICoverable aTileEntity) { return coverBehavior.letsEnergyIn(side, aCoverID, aCoverVariable, aTileEntity); } @Override public boolean letsOut(CoverBehavior coverBehavior, ForgeDirection side, int aCoverID, int aCoverVariable, - ICoverable aTileEntity) { + ICoverable aTileEntity) { return coverBehavior.letsEnergyOut(side, aCoverID, aCoverVariable, aTileEntity); } @Override public boolean letsIn(CoverBehaviorBase coverBehavior, ForgeDirection side, int aCoverID, - ISerializableObject aCoverVariable, ICoverable aTileEntity) { + ISerializableObject aCoverVariable, ICoverable aTileEntity) { return coverBehavior.letsEnergyIn(side, aCoverID, aCoverVariable, aTileEntity); } @Override public boolean letsOut(CoverBehaviorBase coverBehavior, ForgeDirection side, int aCoverID, - ISerializableObject aCoverVariable, ICoverable aTileEntity) { + ISerializableObject aCoverVariable, ICoverable aTileEntity) { return coverBehavior.letsEnergyOut(side, aCoverID, aCoverVariable, aTileEntity); } @@ -387,8 +387,8 @@ public boolean canConnect(ForgeDirection side, TileEntity tileEntity) { // GT Machine handling if ((tileEntity instanceof PowerLogicHost powerLogic && powerLogic.getPowerLogic(oppositeSide) != null) || ((tileEntity instanceof IEnergyConnected energyConnected) - && (energyConnected.inputEnergyFrom(oppositeSide, false) - || energyConnected.outputsEnergyTo(oppositeSide, false)))) + && (energyConnected.inputEnergyFrom(oppositeSide, false) + || energyConnected.outputsEnergyTo(oppositeSide, false)))) return true; // Solar Panel Compat @@ -411,7 +411,7 @@ public boolean canConnect(ForgeDirection side, TileEntity tileEntity) { else ic2Energy = (tileEntity == null || tileEntity instanceof IEnergyTile || EnergyNet.instance == null) ? tileEntity : EnergyNet.instance - .getTileEntity(tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); + .getTileEntity(tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); // IC2 Sink Compat if ((ic2Energy instanceof IEnergySink) @@ -441,13 +441,13 @@ public boolean getGT6StyleConnection() { @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { + ItemStack aStack) { return false; } @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { + ItemStack aStack) { return false; } @@ -600,7 +600,7 @@ private AxisAlignedBB getActualCollisionBoundingBoxFromPool(World aWorld, int aX @Override public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, - List outputAABB, Entity collider) { + List outputAABB, Entity collider) { super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); if (GTMod.instance.isClientSide() && (GTClient.hideValue & 0x2) != 0) { final AxisAlignedBB aabb = getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); @@ -619,12 +619,12 @@ public boolean shouldJoinIc2Enet() { final TileEntity tTileEntity = baseMeta.getTileEntityAtSide(side); final TileEntity tEmitter = (tTileEntity == null || tTileEntity instanceof IEnergyTile || EnergyNet.instance == null) - ? tTileEntity - : EnergyNet.instance.getTileEntity( - tTileEntity.getWorldObj(), - tTileEntity.xCoord, - tTileEntity.yCoord, - tTileEntity.zCoord); + ? tTileEntity + : EnergyNet.instance.getTileEntity( + tTileEntity.getWorldObj(), + tTileEntity.xCoord, + tTileEntity.yCoord, + tTileEntity.zCoord); if (tEmitter instanceof IEnergyEmitter) return true; } @@ -670,7 +670,7 @@ public void reloadLocks() { @Override public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { + IWailaConfigHandler config) { currenttip.add( StatCollector.translateToLocal("GT5U.item.cable.max_voltage") + ": " From 142dbdfadf8b40b10f76630c5dcc1cde7f55c17f Mon Sep 17 00:00:00 2001 From: Daggerhound Date: Fri, 11 Oct 2024 11:48:03 -0300 Subject: [PATCH 5/7] fair trade, spotless apply --- .../implementations/MTECable.java | 69 ++++++++++++------- 1 file changed, 44 insertions(+), 25 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java b/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java index 0b71dade860..26a7e0f34d4 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java @@ -73,7 +73,7 @@ public class MTECable extends MetaPipeEntity implements IMetaTileEntityCable { public int mTransferredAmperage = 0; public MTECable(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, - long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) { + long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) { super(aID, aName, aNameRegional, 0); mThickNess = aThickNess; mMaterial = aMaterial; @@ -85,7 +85,7 @@ public MTECable(int aID, String aName, String aNameRegional, float aThickNess, M } public MTECable(String aName, float aThickNess, Materials aMaterial, long aCableLossPerMeter, long aAmperage, - long aVoltage, boolean aInsulated, boolean aCanShock) { + long aVoltage, boolean aInsulated, boolean aCanShock) { super(aName, 0); mThickNess = aThickNess; mMaterial = aMaterial; @@ -116,7 +116,7 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { @Override public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, - int facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + int facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { if (!mInsulated) return new ITexture[] { TextureFactory .of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], Dyes.getModulation(colorIndex, mMaterial.mRGBa)) }; if (active) { @@ -225,13 +225,13 @@ public long injectEnergyUnits(ForgeDirection side, long voltage, long amperage) @Override @Deprecated public long transferElectricity(ForgeDirection side, long aVoltage, long aAmperage, - ArrayList aAlreadyPassedTileEntityList) { + ArrayList aAlreadyPassedTileEntityList) { return transferElectricity(side, aVoltage, aAmperage, new HashSet<>(aAlreadyPassedTileEntityList)); } @Override public long transferElectricity(ForgeDirection side, long voltage, long amperage, - HashSet alreadyPassedSet) { + HashSet alreadyPassedSet) { if (!getBaseMetaTileEntity().isServerSide() || !isConnectedAtSide(side) && side != ForgeDirection.UNKNOWN) return 0; final BaseMetaPipeEntity tBase = (BaseMetaPipeEntity) getBaseMetaTileEntity(); @@ -262,7 +262,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, - float aX, float aY, float aZ) { + float aX, float aY, float aZ) { if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { final ItemStack handItem = aPlayer.inventory.getCurrentItem(); IMetaTileEntity meta = ItemMachines.getMetaTileEntity(handItem); @@ -274,6 +274,25 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye MTECable newCable; World world = aBaseMetaTileEntity.getWorld(); + aPlayer.inventory.addItemStackToInventory( + new ItemStack( + ItemMachines.getItemFromBlock( + world.getBlock( + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord())), + 1, + world + .getBlock( + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord()) + .getDamageValue( + world, + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord()))); + getBaseMetaTileEntity().setMetaTileEntity( newCable = new MTECable( handCable.mName, @@ -312,7 +331,7 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye @Override public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, - float aX, float aY, float aZ) { + float aX, float aY, float aZ) { if (GTMod.gregtechproxy.gt6Cable && GTModHandler.damageOrDechargeItem(aPlayer.inventory.getCurrentItem(), 1, 500, aPlayer)) { if (isConnectedAtSide(wrenchingSide)) { @@ -329,7 +348,7 @@ public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrench @Override public boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, - float aX, float aY, float aZ) { + float aX, float aY, float aZ) { if (GTMod.gregtechproxy.gt6Cable && GTModHandler.damageOrDechargeItem(aPlayer.inventory.getCurrentItem(), 1, 500, aPlayer)) { if (isConnectedAtSide(wrenchingSide)) { @@ -346,25 +365,25 @@ public boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wre @Override public boolean letsIn(CoverBehavior coverBehavior, ForgeDirection side, int aCoverID, int aCoverVariable, - ICoverable aTileEntity) { + ICoverable aTileEntity) { return coverBehavior.letsEnergyIn(side, aCoverID, aCoverVariable, aTileEntity); } @Override public boolean letsOut(CoverBehavior coverBehavior, ForgeDirection side, int aCoverID, int aCoverVariable, - ICoverable aTileEntity) { + ICoverable aTileEntity) { return coverBehavior.letsEnergyOut(side, aCoverID, aCoverVariable, aTileEntity); } @Override public boolean letsIn(CoverBehaviorBase coverBehavior, ForgeDirection side, int aCoverID, - ISerializableObject aCoverVariable, ICoverable aTileEntity) { + ISerializableObject aCoverVariable, ICoverable aTileEntity) { return coverBehavior.letsEnergyIn(side, aCoverID, aCoverVariable, aTileEntity); } @Override public boolean letsOut(CoverBehaviorBase coverBehavior, ForgeDirection side, int aCoverID, - ISerializableObject aCoverVariable, ICoverable aTileEntity) { + ISerializableObject aCoverVariable, ICoverable aTileEntity) { return coverBehavior.letsEnergyOut(side, aCoverID, aCoverVariable, aTileEntity); } @@ -387,8 +406,8 @@ public boolean canConnect(ForgeDirection side, TileEntity tileEntity) { // GT Machine handling if ((tileEntity instanceof PowerLogicHost powerLogic && powerLogic.getPowerLogic(oppositeSide) != null) || ((tileEntity instanceof IEnergyConnected energyConnected) - && (energyConnected.inputEnergyFrom(oppositeSide, false) - || energyConnected.outputsEnergyTo(oppositeSide, false)))) + && (energyConnected.inputEnergyFrom(oppositeSide, false) + || energyConnected.outputsEnergyTo(oppositeSide, false)))) return true; // Solar Panel Compat @@ -411,7 +430,7 @@ public boolean canConnect(ForgeDirection side, TileEntity tileEntity) { else ic2Energy = (tileEntity == null || tileEntity instanceof IEnergyTile || EnergyNet.instance == null) ? tileEntity : EnergyNet.instance - .getTileEntity(tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); + .getTileEntity(tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); // IC2 Sink Compat if ((ic2Energy instanceof IEnergySink) @@ -441,13 +460,13 @@ public boolean getGT6StyleConnection() { @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { + ItemStack aStack) { return false; } @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { + ItemStack aStack) { return false; } @@ -600,7 +619,7 @@ private AxisAlignedBB getActualCollisionBoundingBoxFromPool(World aWorld, int aX @Override public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, - List outputAABB, Entity collider) { + List outputAABB, Entity collider) { super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); if (GTMod.instance.isClientSide() && (GTClient.hideValue & 0x2) != 0) { final AxisAlignedBB aabb = getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); @@ -619,12 +638,12 @@ public boolean shouldJoinIc2Enet() { final TileEntity tTileEntity = baseMeta.getTileEntityAtSide(side); final TileEntity tEmitter = (tTileEntity == null || tTileEntity instanceof IEnergyTile || EnergyNet.instance == null) - ? tTileEntity - : EnergyNet.instance.getTileEntity( - tTileEntity.getWorldObj(), - tTileEntity.xCoord, - tTileEntity.yCoord, - tTileEntity.zCoord); + ? tTileEntity + : EnergyNet.instance.getTileEntity( + tTileEntity.getWorldObj(), + tTileEntity.xCoord, + tTileEntity.yCoord, + tTileEntity.zCoord); if (tEmitter instanceof IEnergyEmitter) return true; } @@ -670,7 +689,7 @@ public void reloadLocks() { @Override public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { + IWailaConfigHandler config) { currenttip.add( StatCollector.translateToLocal("GT5U.item.cable.max_voltage") + ": " From d209cb2ed82ef3f52bbdb182013cdcaf3e0164d8 Mon Sep 17 00:00:00 2001 From: Daggerhound Date: Fri, 11 Oct 2024 11:51:04 -0300 Subject: [PATCH 6/7] lil better code, spotless reapply --- .../implementations/MTECable.java | 76 +++++++++---------- 1 file changed, 36 insertions(+), 40 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java b/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java index 26a7e0f34d4..662572bb39b 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java @@ -12,6 +12,7 @@ import java.util.HashSet; import java.util.List; +import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -73,7 +74,7 @@ public class MTECable extends MetaPipeEntity implements IMetaTileEntityCable { public int mTransferredAmperage = 0; public MTECable(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, - long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) { + long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) { super(aID, aName, aNameRegional, 0); mThickNess = aThickNess; mMaterial = aMaterial; @@ -85,7 +86,7 @@ public MTECable(int aID, String aName, String aNameRegional, float aThickNess, M } public MTECable(String aName, float aThickNess, Materials aMaterial, long aCableLossPerMeter, long aAmperage, - long aVoltage, boolean aInsulated, boolean aCanShock) { + long aVoltage, boolean aInsulated, boolean aCanShock) { super(aName, 0); mThickNess = aThickNess; mMaterial = aMaterial; @@ -116,7 +117,7 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { @Override public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, - int facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + int facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { if (!mInsulated) return new ITexture[] { TextureFactory .of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], Dyes.getModulation(colorIndex, mMaterial.mRGBa)) }; if (active) { @@ -225,13 +226,13 @@ public long injectEnergyUnits(ForgeDirection side, long voltage, long amperage) @Override @Deprecated public long transferElectricity(ForgeDirection side, long aVoltage, long aAmperage, - ArrayList aAlreadyPassedTileEntityList) { + ArrayList aAlreadyPassedTileEntityList) { return transferElectricity(side, aVoltage, aAmperage, new HashSet<>(aAlreadyPassedTileEntityList)); } @Override public long transferElectricity(ForgeDirection side, long voltage, long amperage, - HashSet alreadyPassedSet) { + HashSet alreadyPassedSet) { if (!getBaseMetaTileEntity().isServerSide() || !isConnectedAtSide(side) && side != ForgeDirection.UNKNOWN) return 0; final BaseMetaPipeEntity tBase = (BaseMetaPipeEntity) getBaseMetaTileEntity(); @@ -262,7 +263,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, - float aX, float aY, float aZ) { + float aX, float aY, float aZ) { if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { final ItemStack handItem = aPlayer.inventory.getCurrentItem(); IMetaTileEntity meta = ItemMachines.getMetaTileEntity(handItem); @@ -273,25 +274,20 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye MTECable newCable; World world = aBaseMetaTileEntity.getWorld(); + Block block = world.getBlock( + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord()); aPlayer.inventory.addItemStackToInventory( new ItemStack( - ItemMachines.getItemFromBlock( - world.getBlock( - aBaseMetaTileEntity.getXCoord(), - aBaseMetaTileEntity.getYCoord(), - aBaseMetaTileEntity.getZCoord())), + ItemMachines.getItemFromBlock(block), 1, - world - .getBlock( - aBaseMetaTileEntity.getXCoord(), - aBaseMetaTileEntity.getYCoord(), - aBaseMetaTileEntity.getZCoord()) - .getDamageValue( - world, - aBaseMetaTileEntity.getXCoord(), - aBaseMetaTileEntity.getYCoord(), - aBaseMetaTileEntity.getZCoord()))); + block.getDamageValue( + world, + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord()))); getBaseMetaTileEntity().setMetaTileEntity( newCable = new MTECable( @@ -331,7 +327,7 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye @Override public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, - float aX, float aY, float aZ) { + float aX, float aY, float aZ) { if (GTMod.gregtechproxy.gt6Cable && GTModHandler.damageOrDechargeItem(aPlayer.inventory.getCurrentItem(), 1, 500, aPlayer)) { if (isConnectedAtSide(wrenchingSide)) { @@ -348,7 +344,7 @@ public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrench @Override public boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, - float aX, float aY, float aZ) { + float aX, float aY, float aZ) { if (GTMod.gregtechproxy.gt6Cable && GTModHandler.damageOrDechargeItem(aPlayer.inventory.getCurrentItem(), 1, 500, aPlayer)) { if (isConnectedAtSide(wrenchingSide)) { @@ -365,25 +361,25 @@ public boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wre @Override public boolean letsIn(CoverBehavior coverBehavior, ForgeDirection side, int aCoverID, int aCoverVariable, - ICoverable aTileEntity) { + ICoverable aTileEntity) { return coverBehavior.letsEnergyIn(side, aCoverID, aCoverVariable, aTileEntity); } @Override public boolean letsOut(CoverBehavior coverBehavior, ForgeDirection side, int aCoverID, int aCoverVariable, - ICoverable aTileEntity) { + ICoverable aTileEntity) { return coverBehavior.letsEnergyOut(side, aCoverID, aCoverVariable, aTileEntity); } @Override public boolean letsIn(CoverBehaviorBase coverBehavior, ForgeDirection side, int aCoverID, - ISerializableObject aCoverVariable, ICoverable aTileEntity) { + ISerializableObject aCoverVariable, ICoverable aTileEntity) { return coverBehavior.letsEnergyIn(side, aCoverID, aCoverVariable, aTileEntity); } @Override public boolean letsOut(CoverBehaviorBase coverBehavior, ForgeDirection side, int aCoverID, - ISerializableObject aCoverVariable, ICoverable aTileEntity) { + ISerializableObject aCoverVariable, ICoverable aTileEntity) { return coverBehavior.letsEnergyOut(side, aCoverID, aCoverVariable, aTileEntity); } @@ -406,8 +402,8 @@ public boolean canConnect(ForgeDirection side, TileEntity tileEntity) { // GT Machine handling if ((tileEntity instanceof PowerLogicHost powerLogic && powerLogic.getPowerLogic(oppositeSide) != null) || ((tileEntity instanceof IEnergyConnected energyConnected) - && (energyConnected.inputEnergyFrom(oppositeSide, false) - || energyConnected.outputsEnergyTo(oppositeSide, false)))) + && (energyConnected.inputEnergyFrom(oppositeSide, false) + || energyConnected.outputsEnergyTo(oppositeSide, false)))) return true; // Solar Panel Compat @@ -430,7 +426,7 @@ public boolean canConnect(ForgeDirection side, TileEntity tileEntity) { else ic2Energy = (tileEntity == null || tileEntity instanceof IEnergyTile || EnergyNet.instance == null) ? tileEntity : EnergyNet.instance - .getTileEntity(tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); + .getTileEntity(tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); // IC2 Sink Compat if ((ic2Energy instanceof IEnergySink) @@ -460,13 +456,13 @@ public boolean getGT6StyleConnection() { @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { + ItemStack aStack) { return false; } @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { + ItemStack aStack) { return false; } @@ -619,7 +615,7 @@ private AxisAlignedBB getActualCollisionBoundingBoxFromPool(World aWorld, int aX @Override public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, - List outputAABB, Entity collider) { + List outputAABB, Entity collider) { super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); if (GTMod.instance.isClientSide() && (GTClient.hideValue & 0x2) != 0) { final AxisAlignedBB aabb = getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); @@ -638,12 +634,12 @@ public boolean shouldJoinIc2Enet() { final TileEntity tTileEntity = baseMeta.getTileEntityAtSide(side); final TileEntity tEmitter = (tTileEntity == null || tTileEntity instanceof IEnergyTile || EnergyNet.instance == null) - ? tTileEntity - : EnergyNet.instance.getTileEntity( - tTileEntity.getWorldObj(), - tTileEntity.xCoord, - tTileEntity.yCoord, - tTileEntity.zCoord); + ? tTileEntity + : EnergyNet.instance.getTileEntity( + tTileEntity.getWorldObj(), + tTileEntity.xCoord, + tTileEntity.yCoord, + tTileEntity.zCoord); if (tEmitter instanceof IEnergyEmitter) return true; } @@ -689,7 +685,7 @@ public void reloadLocks() { @Override public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { + IWailaConfigHandler config) { currenttip.add( StatCollector.translateToLocal("GT5U.item.cable.max_voltage") + ": " From 7927838143cb4dc3636e6e3137bfcd92583347ad Mon Sep 17 00:00:00 2001 From: Daggerhound Date: Fri, 11 Oct 2024 12:09:43 -0300 Subject: [PATCH 7/7] a lot more readable, got rid of stupid .* imports from spotless, spotless apply --- .../implementations/MTECable.java | 54 ++++++++----------- 1 file changed, 21 insertions(+), 33 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java b/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java index 662572bb39b..12f20ab8711 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTECable.java @@ -31,7 +31,10 @@ import cofh.api.energy.IEnergyReceiver; import gregtech.GTMod; import gregtech.api.GregTechAPI; -import gregtech.api.enums.*; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TextureSet; +import gregtech.api.enums.Textures; import gregtech.api.graphs.Node; import gregtech.api.graphs.NodeList; import gregtech.api.graphs.PowerNode; @@ -50,7 +53,12 @@ import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.objects.GTCoverNone; import gregtech.api.render.TextureFactory; -import gregtech.api.util.*; +import gregtech.api.util.CoverBehavior; +import gregtech.api.util.CoverBehaviorBase; +import gregtech.api.util.GTGCCompat; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTUtility; +import gregtech.api.util.ISerializableObject; import gregtech.common.GTClient; import gregtech.common.blocks.ItemMachines; import gregtech.common.covers.CoverInfo; @@ -268,26 +276,19 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye final ItemStack handItem = aPlayer.inventory.getCurrentItem(); IMetaTileEntity meta = ItemMachines.getMetaTileEntity(handItem); - if (!(meta instanceof MTECable handCable)) { - return false; - } + if (!(meta instanceof MTECable handCable)) return false; + + // Coordinates of block being replaced + int x = aBaseMetaTileEntity.getXCoord(); + int y = aBaseMetaTileEntity.getYCoord(); + int z = aBaseMetaTileEntity.getZCoord(); MTECable newCable; World world = aBaseMetaTileEntity.getWorld(); - Block block = world.getBlock( - aBaseMetaTileEntity.getXCoord(), - aBaseMetaTileEntity.getYCoord(), - aBaseMetaTileEntity.getZCoord()); + Block block = world.getBlock(x, y, z); aPlayer.inventory.addItemStackToInventory( - new ItemStack( - ItemMachines.getItemFromBlock(block), - 1, - block.getDamageValue( - world, - aBaseMetaTileEntity.getXCoord(), - aBaseMetaTileEntity.getYCoord(), - aBaseMetaTileEntity.getZCoord()))); + new ItemStack(ItemMachines.getItemFromBlock(block), 1, block.getDamageValue(world, x, y, z))); getBaseMetaTileEntity().setMetaTileEntity( newCable = new MTECable( @@ -300,22 +301,9 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye handCable.mInsulated, handCable.mCanShock)); - world.setBlock( - aBaseMetaTileEntity.getXCoord(), - aBaseMetaTileEntity.getYCoord(), - aBaseMetaTileEntity.getZCoord(), - Blocks.air); - - handItem.tryPlaceItemIntoWorld( - aPlayer, - world, - aBaseMetaTileEntity.getXCoord(), - aBaseMetaTileEntity.getYCoord(), - aBaseMetaTileEntity.getZCoord(), - ForgeDirection.UNKNOWN.ordinal(), - aX, - aY, - aZ); + world.setBlock(x, y, z, Blocks.air); + + handItem.tryPlaceItemIntoWorld(aPlayer, world, x, y, z, ForgeDirection.UNKNOWN.ordinal(), aX, aY, aZ); newCable.mCheckConnections = true; newCable.onPostTick(aBaseMetaTileEntity, 20);