New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reworked IO Port to handle StorageChannels better. #3284

Merged
merged 2 commits into from Dec 21, 2017

Conversation

Projects
None yet
2 participants
@yueh
Member

yueh commented Dec 19, 2017

The IO Port is currently limited to items and potentially fluids, but no 3rd party storage channel. Which should be fixed by this PR.

It also introduces a new default method for IStorageChannel to further speed up (or slow down) different machines. Currently only used by the IO Port. The idea is to maintain a mostly equal transfer rate between items and their corresponding other variants. E.g. transfering 1 Bucket of Water (item) should take the same amount of time as transfering it converted to 1 bucket of water (fluid, 1000 mB) and not 1mB in the same time.

Due to being a default method, it should not break backward compatibility, but there might be some issues with forward compatibility should some 3rd party addon make use of it and someone combines it with an earlier AE2 version.

@@ -106,7 +105,7 @@ public TileIOPort()
this.lastRedstoneState = YesNo.UNDECIDED;
final Block ioPortBlock = AEApi.instance().definitions().blocks().iOPort().maybeBlock().get();

This comment has been minimized.

@orod-org

orod-org Dec 19, 2017

MAJOR Call "Optional#isPresent()" before accessing the value. rule

@orod-org

orod-org Dec 19, 2017

MAJOR Call "Optional#isPresent()" before accessing the value. rule

Some updates
Scale energy consumption with the factor to avoid fluid storage requring
1000x as much energy.
Also do not move cell until work finished when using this mode.
if( this.manager.getSetting( Settings.OPERATION_MODE ) == OperationMode.EMPTY )
for( IStorageChannel<? extends IAEStack<?>> c : AEApi.instance().storage().storageChannels() )

This comment has been minimized.

@orod-org

orod-org Dec 20, 2017

CRITICAL Refactor this code to not nest more than 3 if/for/while/switch/try statements. rule

@orod-org

orod-org Dec 20, 2017

CRITICAL Refactor this code to not nest more than 3 if/for/while/switch/try statements. rule

}
return TickRateModulation.URGENT;
if( itemsToMove > 0 && shouldMove && this.moveSlot( x ) )

This comment has been minimized.

@orod-org

orod-org Dec 20, 2017

MAJOR Remove this conditional structure or edit its code blocks so that they're not all the same. rule

@orod-org

orod-org Dec 20, 2017

MAJOR Remove this conditional structure or edit its code blocks so that they're not all the same. rule

{
ItemsToMove = this.transferContents( energy, fluidNet, fluidInv, ItemsToMove,
AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
ret = TickRateModulation.IDLE;

This comment has been minimized.

@orod-org

orod-org Dec 20, 2017

MAJOR Remove this useless assignment to local variable "ret". rule

@orod-org

orod-org Dec 20, 2017

MAJOR Remove this useless assignment to local variable "ret". rule

}
else
{
ret = TickRateModulation.URGENT;

This comment has been minimized.

@orod-org

orod-org Dec 20, 2017

MAJOR Remove this useless assignment to local variable "ret". rule

@orod-org

orod-org Dec 20, 2017

MAJOR Remove this useless assignment to local variable "ret". rule

final double availablePower = energy.extractAEPower( stored, Actionable.SIMULATE, PowerMultiplier.CONFIG );
final int energyFactor = Math.min( 1, input.getChannel().transferFactor() );
final double availablePower = energy.extractAEPower( stored / energyFactor, Actionable.SIMULATE, PowerMultiplier.CONFIG );

This comment has been minimized.

@orod-org

orod-org Dec 20, 2017

MINOR Cast one of the operands of this division operation to a "double". rule

@orod-org

orod-org Dec 20, 2017

MINOR Cast one of the operands of this division operation to a "double". rule

final long itemToAdd = Math.min( (long) ( availablePower + 0.9 ), stored );
if( itemToAdd > 0 )
{
energy.extractAEPower( stored, Actionable.MODULATE, PowerMultiplier.CONFIG );
energy.extractAEPower( stored / energyFactor, Actionable.MODULATE, PowerMultiplier.CONFIG );

This comment has been minimized.

@orod-org

orod-org Dec 20, 2017

MINOR Cast one of the operands of this division operation to a "double". rule

@orod-org

orod-org Dec 20, 2017

MINOR Cast one of the operands of this division operation to a "double". rule

@orod-org

This comment has been minimized.

Show comment
Hide comment
@orod-org

orod-org Dec 20, 2017

SonarQube analysis reported 16 issues

  • BLOCKER 1 blocker
  • CRITICAL 1 critical
  • MAJOR 9 major
  • MINOR 5 minor

Watch the comments in this conversation to review them.

9 extra issues

Note: The following issues were found on lines that were not modified in the pull request. Because these issues can't be reported as line comments, they are summarized here:

  1. BLOCKER Platform.java#L1409: Refactor this method to not always return the same value. rule
  2. MAJOR Platform.java#L576: Remove this useless assignment to local variable "itemStack". rule
  3. MAJOR Platform.java#L621: Remove this useless assignment to local variable "itemStack". rule
  4. MAJOR Platform.java#L1415: Call "Optional#isPresent()" before accessing the value. rule
  5. MAJOR Platform.java#L1419: Call "Optional#isPresent()" before accessing the value. rule
  6. MAJOR Platform.java#L1614: This block of commented-out lines of code should be removed. rule
  7. MINOR Platform.java#L433: Remove this use of "getDrops"; it is deprecated. rule
  8. MINOR Platform.java#L1034: Remove this use of "getBlockReachDistance"; it is deprecated. rule
  9. MINOR Platform.java#L1188: Remove this unnecessary cast to "T". rule

orod-org commented Dec 20, 2017

SonarQube analysis reported 16 issues

  • BLOCKER 1 blocker
  • CRITICAL 1 critical
  • MAJOR 9 major
  • MINOR 5 minor

Watch the comments in this conversation to review them.

9 extra issues

Note: The following issues were found on lines that were not modified in the pull request. Because these issues can't be reported as line comments, they are summarized here:

  1. BLOCKER Platform.java#L1409: Refactor this method to not always return the same value. rule
  2. MAJOR Platform.java#L576: Remove this useless assignment to local variable "itemStack". rule
  3. MAJOR Platform.java#L621: Remove this useless assignment to local variable "itemStack". rule
  4. MAJOR Platform.java#L1415: Call "Optional#isPresent()" before accessing the value. rule
  5. MAJOR Platform.java#L1419: Call "Optional#isPresent()" before accessing the value. rule
  6. MAJOR Platform.java#L1614: This block of commented-out lines of code should be removed. rule
  7. MINOR Platform.java#L433: Remove this use of "getDrops"; it is deprecated. rule
  8. MINOR Platform.java#L1034: Remove this use of "getBlockReachDistance"; it is deprecated. rule
  9. MINOR Platform.java#L1188: Remove this unnecessary cast to "T". rule
@yueh

This comment has been minimized.

Show comment
Hide comment
@yueh

yueh Dec 21, 2017

Member

There is still a small issue with EC2 fluid cells, which will be moved to the output after the first type was transfered. Only happens when set to when done and exporting to the network.

But this seems to be an EC2 bug, as it fails on extracting the item from their handler.

Member

yueh commented Dec 21, 2017

There is still a small issue with EC2 fluid cells, which will be moved to the output after the first type was transfered. Only happens when set to when done and exporting to the network.

But this seems to be an EC2 bug, as it fails on extracting the item from their handler.

@yueh yueh merged commit 7956872 into rv5-1.12 Dec 21, 2017

3 of 4 checks passed

sonarqube SonarQube reported 16 issues, with 1 critical and 1 blocker
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
jenkins Success
Details

@yueh yueh deleted the feature-io-port-rework branch Jan 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment