Civcraft / Citadel

Do not open issues here; open them on the maintained fork @ DevotedMC
https://github.com/DevotedMC/Citadel
BSD 3-Clause "New" or "Revised" License
6 stars 23 forks source link

Fixed /ctr Not Consuming Reinforcement Material #162

Closed Scuwr closed 8 years ago

Scuwr commented 8 years ago

Issue There was a vexing bug in Citadel where, exclusively when using /ctr and a block reinforcement, if you have 2 or more stacks of Stone (or any block-type reinf material) in your hotbar, and select the right-most stack of stone, and go into Reinforcement mode (/ctr) you will not consume any stone. If you only have a single stack in your hotbar, it works as expected (stone is consumed).

Identified Culprit At line 114 in Utility.java, there is a series of conditional statements to check if the player it reinforcing a block with the same item in their hand, if there are multiple stacks of reinforcements in the inventory,and if that item is the left-most slot for the chosen reinforcement. If all true, the requirements variable decrements. This was part of the bug fix for the /ctf resource consumption bug, however, this addition had the unintended consequence of conflicting with /ctr mode, whereby requirement = 1. When the player had satisfied all the conditions of the statement beginning on line 114, requirement would decrement, causing the inventory updating logic to break from its for-loop without changing the inventory.

Resolution The addition of an extra check for which mode the player was in, was sufficient to resolve this bug. The addition can be seen below.

PlayerState.get(player).getMode() == ReinforcementMode.REINFOREMENT_FORTIFICATION

Additional Changes

CivcraftBot commented 8 years ago

Can one of the admins verify this patch? Type 'ok to test' to test.

rourke750 commented 8 years ago

ok to test

rourke750 commented 8 years ago

So, everything now works as expected? All tested and good?

Scuwr commented 8 years ago

Yes, everything seems to be good now.

Scuwr commented 8 years ago

I tested it specifically under the cases of /ctf and /ctr with multiple reinforcement stacks and varying the slots in the toolbar.

ProgrammerDan commented 8 years ago

Thanks for tackling this, Scuwr.