-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
282 additions
and
38 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
62 changes: 62 additions & 0 deletions
62
Common/src/main/java/at/petrak/hexcasting/common/loot/AncientCypherManager.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,62 @@ | ||
package at.petrak.hexcasting.common.loot; | ||
|
||
import at.petrak.hexcasting.api.HexAPI; | ||
import at.petrak.hexcasting.api.casting.iota.Iota; | ||
import at.petrak.hexcasting.api.casting.iota.PatternIota; | ||
import at.petrak.hexcasting.api.casting.math.HexPattern; | ||
import com.google.gson.Gson; | ||
import com.google.gson.JsonElement; | ||
import com.mojang.datafixers.util.Pair; | ||
import com.mojang.serialization.JsonOps; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.server.packs.resources.ResourceManager; | ||
import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener; | ||
import net.minecraft.util.RandomSource; | ||
import net.minecraft.util.profiling.ProfilerFiller; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class AncientCypherManager extends SimpleJsonResourceReloadListener { | ||
public static final AncientCypherManager INSTANCE = new AncientCypherManager(); | ||
|
||
private Map<ResourceLocation, List<Iota>> data; | ||
|
||
private AncientCypherManager() { | ||
super(new Gson(), "loot_cyphers"); | ||
} | ||
|
||
@Override | ||
protected Map<ResourceLocation, JsonElement> prepare(ResourceManager $$0, ProfilerFiller $$1) { | ||
return super.prepare($$0, $$1); | ||
} | ||
|
||
@Override | ||
protected void apply(Map<ResourceLocation, JsonElement> map, ResourceManager resourceManager, ProfilerFiller profilerFiller) { | ||
Map<ResourceLocation, List<Iota>> data = new HashMap<>(map.size()); | ||
for (var entry : map.entrySet()) { | ||
var key = entry.getKey(); | ||
try { | ||
var value = entry.getValue().getAsJsonArray(); | ||
var iotaList = new ArrayList<Iota>(value.size()); | ||
for (var elem : value) { | ||
var pattern = HexPattern.CODEC.parse(JsonOps.INSTANCE, elem).resultOrPartial(HexAPI.LOGGER::error).orElseThrow(); | ||
iotaList.add(new PatternIota(pattern)); | ||
} | ||
data.put(key, iotaList); | ||
} catch (Exception e) { | ||
HexAPI.LOGGER.error("Error loading custom loot cypher {}: {}", key, e.getMessage()); | ||
} | ||
} | ||
this.data = data; | ||
} | ||
|
||
public Pair<ResourceLocation, List<Iota>> randomHex(RandomSource rand) { | ||
var map = this.data; | ||
var entries = map.entrySet().stream().toList(); | ||
var entry = entries.get(rand.nextInt(entries.size())); | ||
return Pair.of(entry.getKey(), entry.getValue()); | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
Common/src/main/resources/data/hexcasting/loot_cyphers/ascend.json
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,5 @@ | ||
[ | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "aqaae" }, | ||
{ "start_dir": "WEST", "angles": "qqqqqawwawawd" } | ||
] |
19 changes: 19 additions & 0 deletions
19
Common/src/main/resources/data/hexcasting/loot_cyphers/beckon.json
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,19 @@ | ||
[ | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "EAST", "angles": "aa" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "wa" }, | ||
{ "start_dir": "EAST", "angles": "weaqa" }, | ||
{ "start_dir": "EAST", "angles": "aadaa" }, | ||
{ "start_dir": "EAST", "angles": "dd" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "EAST", "angles": "aa" }, | ||
{ "start_dir": "EAST", "angles": "aawdd" }, | ||
{ "start_dir": "NORTH_WEST", "angles": "wddw" }, | ||
{ "start_dir": "EAST", "angles": "aadaa" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "wqaqw" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "wdedw" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "aqaawa" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "waqaw" }, | ||
{ "start_dir": "SOUTH_WEST", "angles": "awqqqwaqw" } | ||
] |
7 changes: 7 additions & 0 deletions
7
Common/src/main/resources/data/hexcasting/loot_cyphers/blastoff.json
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,7 @@ | ||
[ | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "NORTH_WEST", "angles": "qqqqqew" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "aqaawaa" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "waqaw" }, | ||
{ "start_dir": "SOUTH_WEST", "angles": "awqqqwaqw" } | ||
] |
15 changes: 15 additions & 0 deletions
15
Common/src/main/resources/data/hexcasting/loot_cyphers/blink.json
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,15 @@ | ||
[ | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "EAST", "angles": "aadaa" }, | ||
{ "start_dir": "EAST", "angles": "aa" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "wa" }, | ||
{ "start_dir": "EAST", "angles": "wqaawdd" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "EAST", "angles": "aa" }, | ||
{ "start_dir": "NORTH_WEST", "angles": "wddw" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "wqaqw" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "aqaaw" }, | ||
{ "start_dir": "NORTH_WEST", "angles": "wddw" }, | ||
{ "start_dir": "SOUTH_WEST", "angles": "awqqqwaq" } | ||
] |
6 changes: 6 additions & 0 deletions
6
Common/src/main/resources/data/hexcasting/loot_cyphers/detonate.json
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,6 @@ | ||
[ | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "EAST", "angles": "aa" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "aqaaedwd" }, | ||
{ "start_dir": "EAST", "angles": "ddwddwdd" } | ||
] |
5 changes: 5 additions & 0 deletions
5
Common/src/main/resources/data/hexcasting/loot_cyphers/flight_zone.json
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,5 @@ | ||
[ | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "aqaaq" }, | ||
{ "start_dir": "SOUTH_WEST", "angles": "awawaawq" } | ||
] |
16 changes: 16 additions & 0 deletions
16
Common/src/main/resources/data/hexcasting/loot_cyphers/growth.json
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,16 @@ | ||
[ | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "EAST", "angles": "aa" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "wa" }, | ||
{ "start_dir": "EAST", "angles": "aadadaaw" }, | ||
{ "start_dir": "EAST", "angles": "wqaawdd" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "ddqdd" }, | ||
{ "start_dir": "EAST", "angles": "weddwaa" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "waaw" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "aqaaedwd" }, | ||
{ "start_dir": "EAST", "angles": "aadaadaa" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "wqaqwawqaqw" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "wqaqwawqaqw" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "wqaqwawqaqw" } | ||
] |
12 changes: 12 additions & 0 deletions
12
Common/src/main/resources/data/hexcasting/loot_cyphers/heat_wave.json
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,12 @@ | ||
[ | ||
{ "start_dir": "WEST", "angles": "qqq" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "aaqawawa" }, | ||
{ "start_dir": "EAST", "angles": "eee" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "EAST", "angles": "aa" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "aqaae" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "qqqqqwded" }, | ||
{ "start_dir": "SOUTH_WEST", "angles": "aaqwqaa" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "a" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "dadad" } | ||
] |
12 changes: 12 additions & 0 deletions
12
Common/src/main/resources/data/hexcasting/loot_cyphers/illuminate.json
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,12 @@ | ||
[ | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "EAST", "angles": "aa" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "wa" }, | ||
{ "start_dir": "EAST", "angles": "aadadaaw" }, | ||
{ "start_dir": "EAST", "angles": "wqaawdd" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "ddqdd" }, | ||
{ "start_dir": "EAST", "angles": "weddwaa" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "waaw" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "qqd" } | ||
] |
8 changes: 8 additions & 0 deletions
8
Common/src/main/resources/data/hexcasting/loot_cyphers/kindle.json
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,8 @@ | ||
[ | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "EAST", "angles": "aa" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "wa" }, | ||
{ "start_dir": "EAST", "angles": "wqaawdd" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "aaqawawa" } | ||
] |
8 changes: 8 additions & 0 deletions
8
Common/src/main/resources/data/hexcasting/loot_cyphers/lunge.json
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,8 @@ | ||
[ | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "EAST", "angles": "aadaa" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "wa" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "aqaawa" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "waqaw" }, | ||
{ "start_dir": "SOUTH_WEST", "angles": "awqqqwaqw" } | ||
] |
14 changes: 14 additions & 0 deletions
14
Common/src/main/resources/data/hexcasting/loot_cyphers/radar.json
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,14 @@ | ||
[ | ||
{ "start_dir": "WEST", "angles": "qqq" }, | ||
{ "start_dir": "EAST", "angles": "aadaa" }, | ||
{ "start_dir": "EAST", "angles": "aa" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "aqaawa" }, | ||
{ "start_dir": "SOUTH_WEST", "angles": "ewdqdwe" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "de" }, | ||
{ "start_dir": "EAST", "angles": "eee" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "EAST", "angles": "aa" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "aqaaeaqq" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "qqqqqwdeddwd" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "dadad" } | ||
] |
8 changes: 8 additions & 0 deletions
8
Common/src/main/resources/data/hexcasting/loot_cyphers/shatter.json
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,8 @@ | ||
[ | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "EAST", "angles": "aa" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "wa" }, | ||
{ "start_dir": "EAST", "angles": "wqaawdd" }, | ||
{ "start_dir": "EAST", "angles": "qaqqqqq" } | ||
] |
11 changes: 11 additions & 0 deletions
11
Common/src/main/resources/data/hexcasting/loot_cyphers/shockwave.json
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,11 @@ | ||
[ | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "EAST", "angles": "aa" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "aqaawaa" }, | ||
{ "start_dir": "EAST", "angles": "aadaadaa" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "aqawqadaq" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "aqaaedwd" }, | ||
{ "start_dir": "EAST", "angles": "aawaawaa" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "qqa" }, | ||
{ "start_dir": "EAST", "angles": "qaqqqqq" } | ||
] |
13 changes: 13 additions & 0 deletions
13
Common/src/main/resources/data/hexcasting/loot_cyphers/sidestep.json
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,13 @@ | ||
[ | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "EAST", "angles": "aadaa" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "wa" }, | ||
{ "start_dir": "NORTH_WEST", "angles": "eqqq" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "aqaawd" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "e" }, | ||
{ "start_dir": "NORTH_WEST", "angles": "qqqqqew" }, | ||
{ "start_dir": "SOUTH_WEST", "angles": "eeeeeqw" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "awdd" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "wdedw" }, | ||
{ "start_dir": "SOUTH_WEST", "angles": "awqqqwaqw" } | ||
] |
14 changes: 14 additions & 0 deletions
14
Common/src/main/resources/data/hexcasting/loot_cyphers/wither_wave.json
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,14 @@ | ||
[ | ||
{ "start_dir": "WEST", "angles": "qqq" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "aqaae" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "aqaaw" }, | ||
{ "start_dir": "SOUTH_WEST", "angles": "qqqqqaewawawe" }, | ||
{ "start_dir": "EAST", "angles": "eee" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "qaq" }, | ||
{ "start_dir": "EAST", "angles": "aa" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "aqaae" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "qqqqqwdeddwd" }, | ||
{ "start_dir": "SOUTH_WEST", "angles": "aaqwqaa" }, | ||
{ "start_dir": "SOUTH_EAST", "angles": "a" }, | ||
{ "start_dir": "NORTH_EAST", "angles": "dadad" } | ||
] |
Oops, something went wrong.