Skip to content

Commit

Permalink
Fix issue in banner editor where colors were incorrectly changing if …
Browse files Browse the repository at this point in the history
…there were 2 identical layouts

* When attempting to change the color of a layout, if there was another identical one before it, the color of the first layout was changed instead of the one clicked on
  • Loading branch information
Zailer43 committed Jun 23, 2024
1 parent 8dd9a5e commit 4de1ccb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/java/fzmm/zailer/me/builders/BannerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,23 @@ public void removeLayer(BannerPatternsComponent.Layer layer) {
}

public void replaceColor(BannerPatternsComponent.Layer layer, DyeColor color) {
int index = this.layers.indexOf(layer);
// avoid using List#indexOf because what is needed in this case is the reference,
// otherwise you will get the wrong index
int index = this.indexOf(layer);
if (index != -1) {
this.layers.set(index, new BannerPatternsComponent.Layer(layer.pattern(), color));
}
}

private int indexOf(BannerPatternsComponent.Layer layer) {
for (int i = 0; i != this.layers.size(); i++) {
if (this.layers.get(i) == layer) {
return i;
}
}
return -1;
}

public void replaceColors(DyeColor colorToReplace, DyeColor newColor) {
for (int i = 0; i != this.layers.size(); i++) {
if (this.layers.get(i).color() == colorToReplace) {
Expand Down

0 comments on commit 4de1ccb

Please sign in to comment.