forked from WildBamaBoy/minecraft-comes-alive
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # common/src/main/java/net/mca/entity/ai/brain/tasks/chore/HarvestingTask.java # common/src/main/java/net/mca/entity/ai/brain/tasks/chore/HuntingTask.java
- Loading branch information
Showing
90 changed files
with
1,019 additions
and
448 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
common/src/main/java/net/mca/client/gui/ColorSelector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package net.mca.client.gui; | ||
|
||
import net.mca.client.gui.widget.HorizontalColorPickerWidget; | ||
import net.mca.client.resources.ClientUtils; | ||
|
||
class ColorSelector { | ||
double red, green, blue; | ||
double hue, saturation, brightness; | ||
|
||
public HorizontalColorPickerWidget hueWidget; | ||
public HorizontalColorPickerWidget saturationWidget; | ||
public HorizontalColorPickerWidget brightnessWidget; | ||
|
||
public ColorSelector() { | ||
setHSV(0.5, 0.5, 0.5); | ||
} | ||
|
||
public void setRGB(double red, double green, double blue) { | ||
this.red = red; | ||
this.green = green; | ||
this.blue = blue; | ||
updateHSV(); | ||
} | ||
|
||
public void setHSV(double hue, double saturation, double brightness) { | ||
this.hue = hue; | ||
this.saturation = saturation; | ||
this.brightness = brightness; | ||
updateRGB(); | ||
|
||
if (hueWidget != null) { | ||
hueWidget.setValueX(hue / 360.0); | ||
saturationWidget.setValueX(saturation); | ||
} | ||
if (brightnessWidget != null) { | ||
brightnessWidget.setValueX(brightness); | ||
} | ||
} | ||
|
||
private void updateRGB() { | ||
double[] doubles = ClientUtils.HSV2RGB(hue, saturation, brightness); | ||
this.red = doubles[0]; | ||
this.green = doubles[1]; | ||
this.blue = doubles[2]; | ||
} | ||
|
||
private void updateHSV() { | ||
double[] doubles = ClientUtils.RGB2HSV(red, green, blue); | ||
this.hue = doubles[0]; | ||
this.saturation = doubles[1]; | ||
this.brightness = doubles[2]; | ||
|
||
if (hueWidget != null) { | ||
hueWidget.setValueX(hue / 360.0); | ||
saturationWidget.setValueX(saturation); | ||
} | ||
if (brightnessWidget != null) { | ||
brightnessWidget.setValueX(brightness); | ||
} | ||
} | ||
|
||
public int getRed() { | ||
return (int) (red * 255); | ||
} | ||
|
||
public int getGreen() { | ||
return (int) (green * 255); | ||
} | ||
|
||
public int getBlue() { | ||
return (int) (blue * 255); | ||
} | ||
|
||
public int getColor() { | ||
return 0xFF000000 | getBlue() << 16 | getGreen() << 8 | getRed(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.