ldtteam / StorageRacks

GNU General Public License v3.0
4 stars 2 forks source link

Controllers now allow the number of advertised racks #15

Closed jzisser9 closed 2 years ago

jzisser9 commented 2 years ago

Previously, controllers would not allow players to place the final rack they should be able to - i.e. for a stone controller, on placing the 20th rack, an error would display that they're over the capacity.

This is because of the logic in EventManager that calculates how many racks the player has placed down already. It stores this in a HashSet called posSet, but the HashSet also includes the controller in the Set, which explains why the max is offset by 1.

This feature accounts for the controller by subtracting 1 from posSet.size(). So in the above example:

Player is placing down their 20th rack
posSet.size() will return 21
stone controller tier is 1

21 - 1 > 1 * 20
20 > 20
false

So no error will be displayed. If they tried to place their 21st rack:

22 - 1 > 1 * 20
21 > 20
true

So an error would display.

This fixes #14.

CLAassistant commented 2 years ago

CLA assistant check
All committers have signed the CLA.

jzisser9 commented 2 years ago

Ignore the branch name - at first I thought this only affected stone controllers.

Raycoms commented 2 years ago

Thanks for the contribution, will merge an upload the fixed version later

jzisser9 commented 2 years ago

My pleasure! Thank you for a great mod!