generated from QuiltMC/quilt-template-mod
-
Notifications
You must be signed in to change notification settings - Fork 12
Move shard type loading to datapacks #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5fe5e60
groundwork
acikek d582112
make it work
acikek 39ac0a6
fix server crash
acikek 5e478c0
use stringifiedTranslatable when necessary
acikek 79598b1
move respacks to top-level
acikek 491245f
comment out shard type saving in persistentstate
acikek 656a1ef
new ShardType json schema, move codecs to camelcase, misc fixes
falkreon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,6 @@ | ||
| { | ||
| "shard_type.bc23.visitor.description": "Visitor Shard", | ||
| "shard_type.bc23.challenge.description": "Challenge Shard", | ||
| "shard_type.bc23.secret.description": "Secret Shard", | ||
| "shard_type.bc23.missing.description": "Missing Shard" | ||
| } |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains hidden or 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,31 @@ | ||
| { | ||
| "bc23:visitor": { | ||
| "text_color": "#6de851", | ||
| "glow_color": "#00ff48", | ||
| "collect_particle": "minecraft:totem_of_undying", | ||
| "collect_sound": { | ||
| "sound_id": "scattered_shards:collect_visitor" | ||
| }, | ||
| "list_order": 1 | ||
| }, | ||
|
|
||
| "bc23:challenge": { | ||
| "text_color": "#5174e8", | ||
| "glow_color": "#0026ff", | ||
| "collect_particle": "minecraft:glow", | ||
| "collect_sound": { | ||
| "sound_id": "scattered_shards:collect_challenge" | ||
| }, | ||
| "list_order": 2 | ||
| }, | ||
|
|
||
| "bc23:secret": { | ||
| "text_color": "#eb4034", | ||
| "glow_color": "#f08", | ||
| "collect_particle": "minecraft:witch", | ||
| "collect_sound": { | ||
| "sound_id": "scattered_shards:collect_secret" | ||
| }, | ||
| "list_order": 3 | ||
| } | ||
| } |
This file contains hidden or 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,6 @@ | ||
| { | ||
| "pack": { | ||
| "pack_format": 10, | ||
| "description": "Scattered Shards assets used at BlanketCon '23" | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
59 changes: 59 additions & 0 deletions
59
src/main/java/net/modfest/scatteredshards/api/impl/ColorCodec.java
This file contains hidden or 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,59 @@ | ||
| package net.modfest.scatteredshards.api.impl; | ||
|
|
||
| import com.mojang.serialization.Codec; | ||
|
|
||
| public class ColorCodec { | ||
|
|
||
| public static Codec<Integer> CODEC = Codec.STRING.xmap(ColorCodec::parseColor, ColorCodec::valueOf); | ||
|
|
||
| public static int parseColor(String str) { | ||
| if (str.startsWith("#")) str = str.substring(1); | ||
| if (str.length() == 3) { | ||
| int r = hexDigit(str.charAt(0)); r = r | (r << 4); | ||
| int g = hexDigit(str.charAt(1)); g = g | (g << 4); | ||
| int b = hexDigit(str.charAt(2)); b = b | (b << 4); | ||
| return (r << 16) | (g << 8) | b; | ||
| } else if (str.length() == 6) { | ||
| int r = hexDigit(str.charAt(0)) << 4 | hexDigit(str.charAt(1)); | ||
| int g = hexDigit(str.charAt(2)) << 4 | hexDigit(str.charAt(3)); | ||
| int b = hexDigit(str.charAt(4)) << 4 | hexDigit(str.charAt(5)); | ||
| return (r << 16) | (g << 8) | b; | ||
| } else { | ||
| return 0xFFFFFF; | ||
| } | ||
| } | ||
|
|
||
| public static String valueOf(int col) { | ||
| col = col & 0xFFFFFF; | ||
| int r = (col >> 16) & 0xFF; | ||
| int g = (col >> 8) & 0xFF; | ||
| int b = col & 0xFF; | ||
|
|
||
| String rs = Integer.toHexString(r); | ||
| String gs = Integer.toHexString(g); | ||
| String bs = Integer.toHexString(b); | ||
| while (rs.length()<2) rs = "0" + rs; | ||
| while (gs.length()<2) gs = "0" + gs; | ||
| while (bs.length()<2) bs = "0" + bs; | ||
|
|
||
| boolean shortR = (rs.charAt(0) == rs.charAt(1)); | ||
| boolean shortG = (gs.charAt(0) == gs.charAt(1)); | ||
| boolean shortB = (bs.charAt(0) == bs.charAt(1)); | ||
| if (shortR && shortG && shortB) { | ||
| return "#" + rs.charAt(0) + gs.charAt(0) + bs.charAt(0); | ||
| } else { | ||
| return "#" + rs + gs + bs; | ||
| } | ||
| } | ||
|
|
||
| private static final char[] HEX_DIGITS = { | ||
| '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' | ||
| }; | ||
| private static final int hexDigit(char ch) { | ||
| ch = Character.toLowerCase(ch); | ||
| for(int i=0; i<HEX_DIGITS.length; i++) { | ||
| if (HEX_DIGITS[i] == ch) return i; | ||
| } | ||
| return 0; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.