Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

Cleanup #354

Merged
merged 44 commits into from
Sep 23, 2023
Merged

Cleanup #354

merged 44 commits into from
Sep 23, 2023

Conversation

glowredman
Copy link
Member

  • Update buildscript
  • Remove addon.gradle (functionality already covered by build.gradle)
  • Updated dependencies
  • Updated gradle.properties (-> enabled Jabel and generic injection)
  • Address most warnings
  • Ran deobfParams task
  • Ran selected Eclipse Clean-Up tasks (main reason to merge this after stable!)

- Factorize operands
- Replace (X && Y) || (!X && Z) by X ? Y : Z
- Use '==' or '^' on booleans
- Merge conditions of if/else if/else that have the same blocks
- Pull down common code from if/else statement
- Single 'if' statement rather than duplicate blocks that fall through
- Remove redundant end of block with jump statement
- Remove redundant if condition
- Pull out a duplicate 'if' from an if/else
@glowredman glowredman added the ongoing freeze - don't merge Not just a bug fix and thus affected by a current freeze for a upcoming version label Aug 26, 2023
@glowredman glowredman requested review from a team August 26, 2023 20:30
@github-actions
Copy link

Warning: 2 uncommitted changes
https://github.com/GTNewHorizons/bartworks/pull/355

Co-authored-by: GitHub GTNH Actions <>
@miozune miozune removed the ongoing freeze - don't merge Not just a bug fix and thus affected by a current freeze for a upcoming version label Sep 4, 2023
@Dream-Master
Copy link
Member

@glowredman can you solve the conflicts?

@Dream-Master
Copy link
Member

@glowredman sorry
i merged boubous pr first and it cause more merge conflicts.

}
if (this.waitForPipes()) {
return false;
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove the else to go down 1 more layer of indentation

@@ -198,7 +199,8 @@ private static int getTierOfBlock(Block block, int meta) {
}
if (block == GregTech_API.sBlockMetal5 && meta == 2) {
return 1; // Neutronium
} else if (block == LudicrousBlocks.resource_block && meta == 1) {
}
if (block == LudicrousBlocks.resource_block && meta == 1) {
return 2; // Infinity
} else if (block == GregTech_API.sBlockMetal9) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason you only removed one of the elses? can remove this one too.

Comment on lines 252 to 269
|| GT_OreDictUnificator.getAssociation(itemStack).mMaterial.mMaterial.getDust(1) == null)
return new float[] { 1f, 1f };
else if (OrePrefixes.ore.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.oreNetherrack.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.oreEndstone.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.oreBlackgranite.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.oreRedgranite.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.oreMarble.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.oreBasalt.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix))
return new float[] { 0.5f, 1f };
else if (OrePrefixes.stone.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.stoneBricks.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.stoneChiseled.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.stoneCobble.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.stoneCracked.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.stoneMossy.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.stoneMossyBricks.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.stoneSmooth.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.cobblestone.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix))
return new float[] { 1f, 1.5f };
|| GT_OreDictUnificator.getAssociation(itemStack).mMaterial.mMaterial.getDust(1) == null) {} else
if (OrePrefixes.ore.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.oreNetherrack.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.oreEndstone.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.oreBlackgranite.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.oreRedgranite.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.oreMarble.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.oreBasalt.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix))
return new float[] { 0.5f, 1f };
else if (OrePrefixes.stone.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.stoneBricks.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.stoneChiseled.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.stoneCobble.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.stoneCracked.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.stoneMossy.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.stoneMossyBricks.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.stoneSmooth.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)
|| OrePrefixes.cobblestone.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix))
return new float[] { 1f, 1.5f };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible add brackets to the return statement and actually remove the elses. No need to just remove one of them otherwise...

int aMetaData = aStack.getItemDamage();
Werkstoff werkstoff = werkstoffHashMap.get((short) aMetaData);
if (werkstoff == null) werkstoff = Werkstoff.default_null_Werkstoff;
return ((BW_MetaGenerated_Blocks) block).blockTypeLocalizedName
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can make a variable in the if instead of converting at place

public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileEntity tTileEntity = world.getTileEntity(x, y, z);
if ((tTileEntity instanceof BW_MetaGenerated_Block_TE)) {
if (tTileEntity instanceof BW_MetaGenerated_Block_TE) {
mTemporaryTileEntity.set((BW_MetaGenerated_Block_TE) tTileEntity);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can make a variable at the instance of.

|| aRecipe[i] instanceof ItemData
|| aRecipe[i] instanceof String
|| aRecipe[i] instanceof Character))
else if (aRecipe[i] instanceof Enum) aRecipe[i] = ((Enum<?>) aRecipe[i]).name();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enum could just have a variable on it

@@ -1018,11 +903,11 @@ public static ShapedOreRecipe createGTCraftingRecipe(ItemStack aResult, Enchantm

for (byte i = 0; i < aRecipe.length; i++) {
if (aRecipe[i] instanceof IItemContainer) aRecipe[i] = ((IItemContainer) aRecipe[i]).get(1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can make a variable for IItemContantainer instead of converting at place

Comment on lines 122 to 148
if (t != null && !new Coords(C.x, C.y + 1, C.z, wID).equals(Controller)) {
if (t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
}
if (t != null && !new Coords(C.x, C.y + 1, C.z, wID).equals(Controller)
&& t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
t = w.getTileEntity(C.x, C.y - 1, C.z);
if (t != null && !new Coords(C.x, C.y - 1, C.z, wID).equals(Controller)) {
if (t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
}
if (t != null && !new Coords(C.x, C.y - 1, C.z, wID).equals(Controller)
&& t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
t = w.getTileEntity(C.x + 1, C.y, C.z);
if (t != null && !new Coords(C.x + 1, C.y, C.z, wID).equals(Controller)) {
if (t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
}
if (t != null && !new Coords(C.x + 1, C.y, C.z, wID).equals(Controller)
&& t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
t = w.getTileEntity(C.x - 1, C.y, C.z);
if (t != null && !new Coords(C.x - 1, C.y, C.z, wID).equals(Controller)) {
if (t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
}
if (t != null && !new Coords(C.x - 1, C.y, C.z, wID).equals(Controller)
&& t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
t = w.getTileEntity(C.x, C.y, C.z + 1);
if (t != null && !new Coords(C.x, C.y, C.z + 1, wID).equals(Controller)) {
if (t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
}
if (t != null && !new Coords(C.x, C.y, C.z + 1, wID).equals(Controller)
&& t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
t = w.getTileEntity(C.x, C.y, C.z - 1);
if (t != null && !new Coords(C.x, C.y, C.z - 1, wID).equals(Controller)) {
if (t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
}
if (t != null && !new Coords(C.x, C.y, C.z - 1, wID).equals(Controller)
&& t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
} else {
if (n == w.getBlockMetadata(C.x, C.y + 1, C.z)
&& !new Coords(C.x, C.y + 1, C.z, wID).equals(Controller))
return true;
if (n == w.getBlockMetadata(C.x, C.y - 1, C.z)
&& !new Coords(C.x, C.y - 1, C.z, wID).equals(Controller))
if (n == w.getBlockMetadata(C.x, C.y + 1, C.z) && !new Coords(C.x, C.y + 1, C.z, wID).equals(Controller)
|| n == w.getBlockMetadata(C.x, C.y - 1, C.z)
&& !new Coords(C.x, C.y - 1, C.z, wID).equals(Controller))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

every instanceof check could just get a variable... no? and if brackets for what each if is doing.. please. I am barely able to read this

Comment on lines 87 to 109
if (t != null && !new Coords(C.x, C.y + 1, C.z, wID).equals(Controller)) {
if (t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
}
if (t != null && !new Coords(C.x, C.y + 1, C.z, wID).equals(Controller)
&& t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
t = w.getTileEntity(C.x, C.y - 1, C.z);
if (t != null && !new Coords(C.x, C.y - 1, C.z, wID).equals(Controller)) {
if (t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
}
if (t != null && !new Coords(C.x, C.y - 1, C.z, wID).equals(Controller)
&& t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
t = w.getTileEntity(C.x + 1, C.y, C.z);
if (t != null && !new Coords(C.x + 1, C.y, C.z, wID).equals(Controller)) {
if (t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
}
if (t != null && !new Coords(C.x + 1, C.y, C.z, wID).equals(Controller)
&& t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
t = w.getTileEntity(C.x - 1, C.y, C.z);
if (t != null && !new Coords(C.x - 1, C.y, C.z, wID).equals(Controller)) {
if (t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
}
if (t != null && !new Coords(C.x - 1, C.y, C.z, wID).equals(Controller)
&& t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
t = w.getTileEntity(C.x, C.y, C.z + 1);
if (t != null && !new Coords(C.x, C.y, C.z + 1, wID).equals(Controller)) {
if (t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
}
if (t != null && !new Coords(C.x, C.y, C.z + 1, wID).equals(Controller)
&& t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
t = w.getTileEntity(C.x, C.y, C.z - 1);
if (t != null && !new Coords(C.x, C.y, C.z - 1, wID).equals(Controller)) {
if (t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
}
if (t != null && !new Coords(C.x, C.y, C.z - 1, wID).equals(Controller)
&& t instanceof IGregTechTileEntity)
if (((IGregTechTileEntity) t).getMetaTileID() == n) return true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as what i said in ConnectedBlocksChecker

} else if (aMetaTileEntity instanceof LowPowerLaser && ((LowPowerLaser) aMetaTileEntity).isTunnel()) {
if (!((LowPowerLaser) aMetaTileEntity).isConnectedCorrectly(front)) return;
}
} else if (aMetaTileEntity instanceof LowPowerLaser && ((LowPowerLaser) aMetaTileEntity).isTunnel()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can use an instanceof check variable here

Copy link
Member

@BlueWeabo BlueWeabo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for you work.

@glowredman glowredman merged commit f8e8291 into master Sep 23, 2023
1 check passed
@glowredman glowredman deleted the cleanup branch September 23, 2023 11:06
mitchej123 pushed a commit that referenced this pull request Mar 8, 2024
* Fix most `@SuppressWarnings`

* Update buildscript

* Remove dead code

* Add missing `@Override` annotations

* Deobfuscate parameters

* Collapse switch statements

* Fix

* Combine nested if statements in else block to else if

* Reduce indentation when possible

* Convert to switch when reasonable

* Extract increment/decrement from statement

* Pull up assignment

* Simplify lambda expression and method reference syntax

* Deduplicate code

- Factorize operands
- Replace (X && Y) || (!X && Z) by X ? Y : Z
- Use '==' or '^' on booleans
- Merge conditions of if/else if/else that have the same blocks
- Pull down common code from if/else statement
- Single 'if' statement rather than duplicate blocks that fall through
- Remove redundant end of block with jump statement
- Remove redundant if condition
- Pull out a duplicate 'if' from an if/else

* Use pattern matching for instanceof

* Convert String concatenation to Text Block

* Convert to switch expression where possible

* Use diamond operator

* Convert to enhanced 'for' loops

* Always use 'this' qualifier

* Convert fields into local variables if the use is only local

* Use String.replace() instead of String.replaceAll() when possible

* Avoid Object.equals() or String.equalsIgnoreCase() on null objects

* Remove unnecessary casts

* Push down negation

* Remove redundant super() call in constructor

* Remove overridden assignment

* Remove redundant modifiers

* Raise embedded if into parent if

* Create array with curly brrackets when possible

* Remove variable assignment before return

* Remove unnecessary parentheses

* spotlessApply (#355)

Co-authored-by: GitHub GTNH Actions <>

* Update dependencies.gradle

* Update dependencies.gradle

* Update dependencies.gradle

* sa+deps

* add back GG mod in dep file

* Make requested changes

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Martin Robertz <[email protected]>
Former-commit-id: b636a9e208af261b0c17032bb7a0884397846eb6
mitchej123 pushed a commit that referenced this pull request Mar 8, 2024
* Fix most `@SuppressWarnings`

* Update buildscript

* Remove dead code

* Add missing `@Override` annotations

* Deobfuscate parameters

* Collapse switch statements

* Fix

* Combine nested if statements in else block to else if

* Reduce indentation when possible

* Convert to switch when reasonable

* Extract increment/decrement from statement

* Pull up assignment

* Simplify lambda expression and method reference syntax

* Deduplicate code

- Factorize operands
- Replace (X && Y) || (!X && Z) by X ? Y : Z
- Use '==' or '^' on booleans
- Merge conditions of if/else if/else that have the same blocks
- Pull down common code from if/else statement
- Single 'if' statement rather than duplicate blocks that fall through
- Remove redundant end of block with jump statement
- Remove redundant if condition
- Pull out a duplicate 'if' from an if/else

* Use pattern matching for instanceof

* Convert String concatenation to Text Block

* Convert to switch expression where possible

* Use diamond operator

* Convert to enhanced 'for' loops

* Always use 'this' qualifier

* Convert fields into local variables if the use is only local

* Use String.replace() instead of String.replaceAll() when possible

* Avoid Object.equals() or String.equalsIgnoreCase() on null objects

* Remove unnecessary casts

* Push down negation

* Remove redundant super() call in constructor

* Remove overridden assignment

* Remove redundant modifiers

* Raise embedded if into parent if

* Create array with curly brrackets when possible

* Remove variable assignment before return

* Remove unnecessary parentheses

* spotlessApply (#355)

Co-authored-by: GitHub GTNH Actions <>

* Update dependencies.gradle

* Update dependencies.gradle

* Update dependencies.gradle

* sa+deps

* add back GG mod in dep file

* Make requested changes

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Martin Robertz <[email protected]>
Former-commit-id: 11b283613ab93b60bf0e52aad99dbcaf9ace3a1f
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants