2015-11-30 08:12:20 -08:00
|
|
|
package amidst.fragment.colorprovider;
|
2015-11-30 05:12:53 -08:00
|
|
|
|
2015-12-09 10:39:39 -08:00
|
|
|
import amidst.documentation.ThreadSafe;
|
2015-12-05 02:24:32 -08:00
|
|
|
import amidst.fragment.Fragment;
|
2016-01-05 08:00:25 -08:00
|
|
|
import amidst.gui.main.viewer.BiomeSelection;
|
2016-01-12 15:11:40 -08:00
|
|
|
import amidst.mojangapi.world.Dimension;
|
2015-12-16 10:16:07 -08:00
|
|
|
import amidst.mojangapi.world.biome.BiomeColor;
|
2016-02-15 10:40:17 -08:00
|
|
|
import amidst.settings.biomeprofile.BiomeProfileSelection;
|
2015-11-30 05:12:53 -08:00
|
|
|
|
2015-12-09 10:39:39 -08:00
|
|
|
@ThreadSafe
|
2015-11-30 05:12:53 -08:00
|
|
|
public class BiomeColorProvider implements ColorProvider {
|
2015-12-01 09:17:59 -08:00
|
|
|
private final BiomeSelection biomeSelection;
|
2016-02-15 10:40:17 -08:00
|
|
|
private final BiomeProfileSelection biomeProfileSelection;
|
2015-11-30 05:12:53 -08:00
|
|
|
|
2015-12-04 14:21:31 -08:00
|
|
|
public BiomeColorProvider(BiomeSelection biomeSelection,
|
2016-02-15 10:40:17 -08:00
|
|
|
BiomeProfileSelection biomeProfileSelection) {
|
2015-12-01 09:17:59 -08:00
|
|
|
this.biomeSelection = biomeSelection;
|
2016-02-15 10:40:17 -08:00
|
|
|
this.biomeProfileSelection = biomeProfileSelection;
|
2015-11-30 05:12:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-01-12 15:11:40 -08:00
|
|
|
public int getColorAt(Dimension dimension, Fragment fragment, long cornerX,
|
|
|
|
long cornerY, int x, int y) {
|
2015-11-30 05:12:53 -08:00
|
|
|
return getColor(fragment.getBiomeDataAt(x, y));
|
|
|
|
}
|
|
|
|
|
2015-12-16 09:36:40 -08:00
|
|
|
private int getColor(int biomeIndex) {
|
|
|
|
if (biomeSelection.isSelected(biomeIndex)) {
|
|
|
|
return getBiomeColor(biomeIndex).getRGB();
|
2015-11-30 05:12:53 -08:00
|
|
|
} else {
|
2015-12-16 09:36:40 -08:00
|
|
|
return getBiomeColor(biomeIndex).getDeselectRGB();
|
2015-11-30 05:12:53 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-16 09:36:40 -08:00
|
|
|
private BiomeColor getBiomeColor(int biomeIndex) {
|
2016-02-15 10:40:17 -08:00
|
|
|
return biomeProfileSelection.getBiomeColorOrUnknown(biomeIndex);
|
2015-11-30 05:12:53 -08:00
|
|
|
}
|
|
|
|
}
|