-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: TheSilkMiner <thesilkminer@outlook.com>
- Loading branch information
1 parent
12c56d6
commit f1777de
Showing
23 changed files
with
2,117 additions
and
2 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
Common/src/main/java/com/blamejared/contenttweaker/core/api/zen/util/Color.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,56 @@ | ||
package com.blamejared.contenttweaker.core.api.zen.util; | ||
|
||
import com.blamejared.contenttweaker.core.api.ContentTweakerConstants; | ||
import com.blamejared.contenttweaker.core.api.zen.ContentTweakerZenConstants; | ||
import com.blamejared.crafttweaker.api.annotation.ZenRegister; | ||
import org.openzen.zencode.java.ZenCodeType; | ||
|
||
@ZenCodeType.Name(ContentTweakerZenConstants.UTIL_PACKAGE + ".Color") | ||
@ZenRegister(loaders = ContentTweakerConstants.CONTENT_LOADER_ID) | ||
public final class Color { | ||
private final int color; | ||
|
||
private Color(final int color) { | ||
this.color = color; | ||
} | ||
|
||
@ZenCodeType.Method("packedRgba") | ||
public static Color packedRgba(final int color) { | ||
return new Color(color); | ||
} | ||
|
||
@ZenCodeType.Method("packedRgb") | ||
public static Color packedRgb(final int color) { | ||
return packedRgba((color << 8) | 0xFF); | ||
} | ||
|
||
@ZenCodeType.Method("rgba") | ||
public static Color rgba(final int r, final int g, final int b, final int a) { | ||
return packedRgba(((r & 0xFF) << 24) | ((g & 0xFF) << 16) | ((b & 0xFF) << 8) | (a & 0xFF)); | ||
} | ||
|
||
@ZenCodeType.Method("rgb") | ||
public static Color rgb(final int r, final int g, final int b) { | ||
return rgba(r, g, b, 0xFF); | ||
} | ||
|
||
@ZenCodeType.Getter("r") | ||
public int r() { | ||
return (this.color >> 24) & 0xFF; | ||
} | ||
|
||
@ZenCodeType.Getter("g") | ||
public int g() { | ||
return (this.color >> 16) & 0xFF; | ||
} | ||
|
||
@ZenCodeType.Getter("b") | ||
public int b() { | ||
return (this.color >> 8) & 0xFF; | ||
} | ||
|
||
@ZenCodeType.Getter("a") | ||
public int a() { | ||
return this.color & 0xFF; | ||
} | ||
} |
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.