1
1
package at .petrak .hexcasting .common .loot ;
2
2
3
- import at .petrak .hexcasting .api .casting .iota .PatternIota ;
4
3
import at .petrak .hexcasting .api .casting .iota .IotaType ;
5
- import at .petrak .hexcasting .api .casting .math .HexDir ;
6
- import at .petrak .hexcasting .api .casting .math .HexPattern ;
7
- import at .petrak .hexcasting .api .mod .HexConfig ;
8
- import at .petrak .hexcasting .api .utils .HexUtils ;
9
4
import at .petrak .hexcasting .api .item .VariantItem ;
10
5
import at .petrak .hexcasting .api .misc .MediaConstants ;
11
6
import at .petrak .hexcasting .common .items .magic .ItemAncientCypher ;
7
+ import at .petrak .hexcasting .common .items .magic .ItemPackagedHex ;
12
8
import at .petrak .hexcasting .common .lib .HexLootFunctions ;
13
9
import com .google .gson .JsonDeserializationContext ;
14
10
import com .google .gson .JsonObject ;
22
18
import net .minecraft .world .level .storage .loot .functions .LootItemFunctionType ;
23
19
import net .minecraft .world .level .storage .loot .predicates .LootItemCondition ;
24
20
25
- import java .util .List ;
26
- import com .mojang .datafixers .util .Pair ;
27
-
28
21
/**
29
22
* Add a random preset hex to the ancient cypher, and select a random variant.
30
23
* <p>
@@ -40,20 +33,18 @@ public AddHexToAncientCypherFunc(LootItemCondition[] lootItemConditions) {
40
33
* This doesn't actually have any params so extract behaviour out for the benefit of forge
41
34
*/
42
35
public static ItemStack doStatic (ItemStack stack , RandomSource rand ) {
43
- var hex = LOOT_HEXES . get ( rand . nextInt ( LOOT_HEXES . size ()) );
36
+ var hex = AncientCypherManager . INSTANCE . randomHex ( rand );
44
37
var patsTag = new ListTag ();
45
- for (var patString : hex .getSecond ()){
46
- var pieces = patString .split (" " );
47
- var pat = HexPattern .fromAngles (pieces [1 ],HexDir .fromString (pieces [0 ]));
48
- patsTag .add (IotaType .serialize (new PatternIota (pat )));
38
+ for (var pat : hex .getSecond ()){
39
+ patsTag .add (IotaType .serialize (pat ));
49
40
}
50
41
51
42
var tag = new CompoundTag ();
52
- tag .putString (ItemAncientCypher .TAG_HEX_NAME , hex .getFirst ());
43
+ tag .putString (ItemAncientCypher .TAG_HEX_NAME , "hexcasting.loot_hex." + hex .getFirst ());
53
44
tag .putLong (ItemAncientCypher .TAG_MEDIA , 32 *MediaConstants .SHARD_UNIT );
54
45
tag .putLong (ItemAncientCypher .TAG_MAX_MEDIA , 32 *MediaConstants .SHARD_UNIT );
55
46
tag .putInt (VariantItem .TAG_VARIANT , rand .nextInt (8 ));
56
- tag .put (ItemAncientCypher . TAG_PATTERNS , patsTag );
47
+ tag .put (ItemPackagedHex . TAG_PROGRAM , patsTag );
57
48
stack .getOrCreateTag ().merge (tag );
58
49
59
50
return stack ;
@@ -81,24 +72,4 @@ public AddHexToAncientCypherFunc deserialize(JsonObject object, JsonDeserializat
81
72
return new AddHexToAncientCypherFunc (conditions );
82
73
}
83
74
}
84
-
85
- // TODO: make this datapackable
86
- private static final List <Pair <String , String []>> LOOT_HEXES = List .of (
87
- new Pair <>("hexcasting.loot_hex.shatter" , new String [] {"NORTH_EAST qaq" ,"EAST aa" ,"NORTH_EAST qaq" ,"NORTH_EAST wa" ,"EAST wqaawdd" ,"EAST qaqqqqq" }),
88
- new Pair <>("hexcasting.loot_hex.kindle" , new String [] {"NORTH_EAST qaq" ,"EAST aa" ,"NORTH_EAST qaq" ,"NORTH_EAST wa" ,"EAST wqaawdd" ,"SOUTH_EAST aaqawawa" }),
89
- new Pair <>("hexcasting.loot_hex.illuminate" , new String [] {"NORTH_EAST qaq" ,"EAST aa" ,"NORTH_EAST qaq" ,"NORTH_EAST wa" ,"EAST aadadaaw" ,"EAST wqaawdd" ,"NORTH_EAST ddqdd" ,"EAST weddwaa" ,"NORTH_EAST waaw" ,"NORTH_EAST qqd" }),
90
- new Pair <>("hexcasting.loot_hex.growth" , new String [] {"NORTH_EAST qaq" ,"EAST aa" ,"NORTH_EAST qaq" ,"NORTH_EAST wa" ,"EAST aadadaaw" ,"EAST wqaawdd" ,"NORTH_EAST ddqdd" ,"EAST weddwaa" ,"NORTH_EAST waaw" ,"SOUTH_EAST aqaaedwd" ,"EAST aadaadaa" ,"NORTH_EAST wqaqwawqaqw" ,"NORTH_EAST wqaqwawqaqw" ,"NORTH_EAST wqaqwawqaqw" }),
91
- new Pair <>("hexcasting.loot_hex.lunge" , new String [] {"NORTH_EAST qaq" ,"EAST aadaa" ,"NORTH_EAST wa" ,"SOUTH_EAST aqaawa" ,"SOUTH_EAST waqaw" ,"SOUTH_WEST awqqqwaqw" }),
92
- new Pair <>("hexcasting.loot_hex.sidestep" , new String [] {"NORTH_EAST qaq" ,"EAST aadaa" ,"NORTH_EAST wa" ,"NORTH_WEST eqqq" ,"SOUTH_EAST aqaawd" ,"SOUTH_EAST e" ,"NORTH_WEST qqqqqew" ,"SOUTH_WEST eeeeeqw" ,"SOUTH_EAST awdd" ,"NORTH_EAST wdedw" ,"SOUTH_WEST awqqqwaqw" }),
93
- new Pair <>("hexcasting.loot_hex.ascend" , new String [] {"NORTH_EAST qaq" ,"SOUTH_EAST aqaae" ,"WEST qqqqqawwawawd" }),
94
- new Pair <>("hexcasting.loot_hex.blink" , new String [] {"NORTH_EAST qaq" ,"EAST aadaa" ,"EAST aa" ,"NORTH_EAST qaq" ,"NORTH_EAST wa" ,"EAST wqaawdd" ,"NORTH_EAST qaq" ,"EAST aa" ,"NORTH_WEST wddw" ,"NORTH_EAST wqaqw" ,"SOUTH_EAST aqaaw" ,"NORTH_WEST wddw" ,"SOUTH_WEST awqqqwaq" }),
95
- new Pair <>("hexcasting.loot_hex.blastoff" , new String [] {"NORTH_EAST qaq" ,"NORTH_WEST qqqqqew" ,"SOUTH_EAST aqaawaa" ,"SOUTH_EAST waqaw" ,"SOUTH_WEST awqqqwaqw" }),
96
- new Pair <>("hexcasting.loot_hex.radar" , new String [] {"WEST qqq" ,"EAST aadaa" ,"EAST aa" ,"SOUTH_EAST aqaawa" ,"SOUTH_WEST ewdqdwe" ,"NORTH_EAST de" ,"EAST eee" ,"NORTH_EAST qaq" ,"EAST aa" ,"SOUTH_EAST aqaaeaqq" ,"SOUTH_EAST qqqqqwdeddwd" ,"NORTH_EAST dadad" }),
97
- new Pair <>("hexcasting.loot_hex.beckon" , new String [] {"NORTH_EAST qaq" ,"EAST aa" ,"NORTH_EAST qaq" ,"NORTH_EAST wa" ,"EAST weaqa" ,"EAST aadaa" ,"EAST dd" ,"NORTH_EAST qaq" ,"EAST aa" ,"EAST aawdd" ,"NORTH_WEST wddw" ,"EAST aadaa" ,"NORTH_EAST wqaqw" ,"NORTH_EAST wdedw" ,"SOUTH_EAST aqaawa" ,"SOUTH_EAST waqaw" ,"SOUTH_WEST awqqqwaqw" }),
98
- new Pair <>("hexcasting.loot_hex.detonate" , new String [] {"NORTH_EAST qaq" ,"EAST aa" ,"SOUTH_EAST aqaaedwd" ,"EAST ddwddwdd" }),
99
- new Pair <>("hexcasting.loot_hex.shockwave" , new String [] {"NORTH_EAST qaq" ,"EAST aa" ,"SOUTH_EAST aqaawaa" ,"EAST aadaadaa" ,"SOUTH_EAST aqawqadaq" ,"SOUTH_EAST aqaaedwd" ,"EAST aawaawaa" ,"NORTH_EAST qqa" ,"EAST qaqqqqq" }),
100
- new Pair <>("hexcasting.loot_hex.heat_wave" , new String [] {"WEST qqq" ,"SOUTH_EAST aaqawawa" ,"EAST eee" ,"NORTH_EAST qaq" ,"EAST aa" ,"SOUTH_EAST aqaae" ,"SOUTH_EAST qqqqqwded" ,"SOUTH_WEST aaqwqaa" ,"SOUTH_EAST a" ,"NORTH_EAST dadad" }),
101
- new Pair <>("hexcasting.loot_hex.wither_wave" , new String [] {"WEST qqq" ,"SOUTH_EAST aqaae" ,"SOUTH_EAST aqaaw" ,"SOUTH_WEST qqqqqaewawawe" ,"EAST eee" ,"NORTH_EAST qaq" ,"EAST aa" ,"SOUTH_EAST aqaae" ,"SOUTH_EAST qqqqqwdeddwd" ,"SOUTH_WEST aaqwqaa" ,"SOUTH_EAST a" ,"NORTH_EAST dadad" }),
102
- new Pair <>("hexcasting.loot_hex.flight_zone" , new String [] {"NORTH_EAST qaq" ,"SOUTH_EAST aqaaq" ,"SOUTH_WEST awawaawq" })
103
- );
104
75
}
0 commit comments