mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-08 11:50:36 +01:00
palette inlining
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
920bf62699
commit
09aea3c8d4
@ -51,8 +51,7 @@ final class AdaptivePalette implements Palette {
|
|||||||
if (x < 0 || y < 0 || z < 0) {
|
if (x < 0 || y < 0 || z < 0) {
|
||||||
throw new IllegalArgumentException("Coordinates must be positive");
|
throw new IllegalArgumentException("Coordinates must be positive");
|
||||||
}
|
}
|
||||||
Palette palette = switchFlexible();
|
flexiblePalette().set(x, y, z, value);
|
||||||
palette.set(x, y, z, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -72,14 +71,12 @@ final class AdaptivePalette implements Palette {
|
|||||||
if (x < 0 || y < 0 || z < 0) {
|
if (x < 0 || y < 0 || z < 0) {
|
||||||
throw new IllegalArgumentException("Coordinates must be positive");
|
throw new IllegalArgumentException("Coordinates must be positive");
|
||||||
}
|
}
|
||||||
Palette palette = switchFlexible();
|
flexiblePalette().replace(x, y, z, operator);
|
||||||
palette.replace(x, y, z, operator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void replaceAll(@NotNull EntryFunction function) {
|
public void replaceAll(@NotNull EntryFunction function) {
|
||||||
Palette palette = switchFlexible();
|
flexiblePalette().replaceAll(function);
|
||||||
palette.replaceAll(function);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -135,8 +132,8 @@ final class AdaptivePalette implements Palette {
|
|||||||
return currentPalette;
|
return currentPalette;
|
||||||
}
|
}
|
||||||
|
|
||||||
Palette switchFlexible() {
|
Palette flexiblePalette() {
|
||||||
var currentPalette = this.palette;
|
SpecializedPalette currentPalette = this.palette;
|
||||||
if (currentPalette instanceof FilledPalette filledPalette) {
|
if (currentPalette instanceof FilledPalette filledPalette) {
|
||||||
currentPalette = new FlexiblePalette(this);
|
currentPalette = new FlexiblePalette(this);
|
||||||
currentPalette.fill(filledPalette.value());
|
currentPalette.fill(filledPalette.value());
|
||||||
|
Loading…
Reference in New Issue
Block a user