6
6
import at .petrak .hexcasting .api .pigment .FrozenPigment ;
7
7
import at .petrak .hexcasting .api .player .Sentinel ;
8
8
import at .petrak .hexcasting .xplat .IXplatAbstractions ;
9
+
9
10
import com .google .common .base .Suppliers ;
11
+
10
12
import net .minecraft .ChatFormatting ;
11
13
import net .minecraft .network .chat .Component ;
12
14
import net .minecraft .resources .ResourceKey ;
16
18
import net .minecraft .sounds .SoundEvents ;
17
19
import net .minecraft .world .entity .Entity ;
18
20
import net .minecraft .world .entity .EntityType ;
19
- import net .minecraft .world .entity .EquipmentSlot ;
20
21
import net .minecraft .world .entity .Mob ;
21
22
import net .minecraft .world .entity .player .Player ;
22
23
import net .minecraft .world .item .ArmorItem ;
23
24
import net .minecraft .world .item .ArmorMaterial ;
24
25
import net .minecraft .world .item .ItemStack ;
25
26
import net .minecraft .world .item .crafting .Ingredient ;
26
27
import net .minecraft .world .phys .Vec3 ;
28
+
27
29
import org .apache .logging .log4j .LogManager ;
28
30
import org .apache .logging .log4j .Logger ;
29
31
import org .jetbrains .annotations .NotNull ;
@@ -36,23 +38,27 @@ public interface HexAPI {
36
38
String MOD_ID = "hexcasting" ;
37
39
Logger LOGGER = LogManager .getLogger (MOD_ID );
38
40
39
- Supplier <HexAPI > INSTANCE = Suppliers .memoize (() -> {
40
- try {
41
- return (HexAPI ) Class .forName ("at.petrak.hexcasting.common.impl.HexAPIImpl" )
42
- .getDeclaredConstructor ().newInstance ();
43
- } catch (ReflectiveOperationException e ) {
44
- LogManager .getLogger ().warn ("Unable to find HexAPIImpl, using a dummy" );
45
- return new HexAPI () {
46
- };
47
- }
48
- });
41
+ Supplier <HexAPI > INSTANCE =
42
+ Suppliers .memoize (
43
+ () -> {
44
+ try {
45
+ return (HexAPI )
46
+ Class .forName ("at.petrak.hexcasting.common.impl.HexAPIImpl" )
47
+ .getDeclaredConstructor ()
48
+ .newInstance ();
49
+ } catch (ReflectiveOperationException e ) {
50
+ LogManager .getLogger ().warn ("Unable to find HexAPIImpl, using a dummy" );
51
+ return new HexAPI () {};
52
+ }
53
+ });
49
54
50
55
/**
51
56
* Return the localization key for the given action.
52
- * <p>
53
- * Note we're allowed to have action <em>resource keys</em> on the client, just no actual actions.
54
- * <p>
55
- * Special handlers should be calling {@link SpecialHandler#getName()}
57
+ *
58
+ * <p>Note we're allowed to have action <em>resource keys</em> on the client, just no actual
59
+ * actions.
60
+ *
61
+ * <p>Special handlers should be calling {@link SpecialHandler#getName()}
56
62
*/
57
63
default String getActionI18nKey (ResourceKey <ActionRegistryEntry > action ) {
58
64
return "hexcasting.action.%s" .formatted (action .location ().toString ());
@@ -63,37 +69,40 @@ default String getSpecialHandlerI18nKey(ResourceKey<SpecialHandler.Factory<?>> a
63
69
}
64
70
65
71
/**
66
- * Currently introspection/retrospection/consideration are hardcoded, but at least their names won't be
72
+ * Currently introspection/retrospection/consideration are hardcoded, but at least their names
73
+ * won't be
67
74
*/
68
75
default String getRawHookI18nKey (ResourceLocation name ) {
69
76
return "hexcasting.rawhook.%s" .formatted (name );
70
77
}
71
78
72
79
default Component getActionI18n (ResourceKey <ActionRegistryEntry > key , boolean isGreat ) {
73
80
return Component .translatable (getActionI18nKey (key ))
74
- .withStyle (isGreat ? ChatFormatting .GOLD : ChatFormatting .LIGHT_PURPLE );
81
+ .withStyle (isGreat ? ChatFormatting .GOLD : ChatFormatting .LIGHT_PURPLE );
75
82
}
76
83
77
84
default Component getSpecialHandlerI18n (ResourceKey <SpecialHandler .Factory <?>> key ) {
78
85
return Component .translatable (getSpecialHandlerI18nKey (key ))
79
- .withStyle (ChatFormatting .LIGHT_PURPLE );
86
+ .withStyle (ChatFormatting .LIGHT_PURPLE );
80
87
}
81
88
82
89
default Component getRawHookI18n (ResourceLocation name ) {
83
- return Component .translatable (getRawHookI18nKey (name )).withStyle (ChatFormatting .LIGHT_PURPLE );
90
+ return Component .translatable (getRawHookI18nKey (name ))
91
+ .withStyle (ChatFormatting .LIGHT_PURPLE );
84
92
}
85
93
86
94
/**
87
- * Register an entity with the given ID to have its velocity as perceived by OpEntityVelocity be different
88
- * than it's "normal" velocity
95
+ * Register an entity with the given ID to have its velocity as perceived by OpEntityVelocity be
96
+ * different than it's "normal" velocity
89
97
*/
90
98
// Should be OK to use the type directly as the key as they're singleton identity objects
91
- default <T extends Entity > void registerSpecialVelocityGetter (EntityType < T > key , EntityVelocityGetter < T > getter ) {
92
- }
99
+ default <T extends Entity > void registerSpecialVelocityGetter (
100
+ EntityType < T > key , EntityVelocityGetter < T > getter ) { }
93
101
94
102
/**
95
- * If the entity has had a special getter registered with {@link HexAPI#registerSpecialVelocityGetter} then
96
- * return that, otherwise return its normal delta movement
103
+ * If the entity has had a special getter registered with {@link
104
+ * HexAPI#registerSpecialVelocityGetter} then return that, otherwise return its normal delta
105
+ * movement
97
106
*/
98
107
default Vec3 getEntityVelocitySpecial (Entity entity ) {
99
108
return entity .getDeltaMovement ();
@@ -106,36 +115,34 @@ interface EntityVelocityGetter<T extends Entity> {
106
115
107
116
/**
108
117
* Register an entity type to have a custom behavior when getting brainswept.
109
- * <p>
110
- * This knocks out the normal behavior; if you want that behavior you should call
118
+ *
119
+ * <p> This knocks out the normal behavior; if you want that behavior you should call
111
120
*/
112
- default <T extends Mob > void registerCustomBrainsweepingBehavior (EntityType < T > key , Consumer < T > hook ) {
113
- }
121
+ default <T extends Mob > void registerCustomBrainsweepingBehavior (
122
+ EntityType < T > key , Consumer < T > hook ) { }
114
123
115
124
/**
116
125
* The default behavior when an entity gets brainswept.
117
- * <p>
118
- * Something registered with {@link HexAPI#registerCustomBrainsweepingBehavior} doesn't call this automatically;
119
- * you can use this to add things on top of the default behavior
126
+ *
127
+ * <p> Something registered with {@link HexAPI#registerCustomBrainsweepingBehavior} doesn't call
128
+ * this automatically; you can use this to add things on top of the default behavior
120
129
*/
121
130
default Consumer <Mob > defaultBrainsweepingBehavior () {
122
- return mob -> {
123
- };
131
+ return mob -> {};
124
132
}
125
133
126
134
/**
127
- * If something special's been returned with {@link HexAPI#registerCustomBrainsweepingBehavior}, return that,
128
- * otherwise return the default behavior
135
+ * If something special's been returned with {@link HexAPI#registerCustomBrainsweepingBehavior},
136
+ * return that, otherwise return the default behavior
129
137
*/
130
138
default <T extends Mob > Consumer <T > getBrainsweepBehavior (EntityType <T > mobType ) {
131
- return mob -> {
132
- };
139
+ return mob -> {};
133
140
}
134
141
135
142
/**
136
143
* Brainsweep (flay the mind of) the given mob.
137
- * <p>
138
- * This ignores the unbrainsweepable tag.
144
+ *
145
+ * <p> This ignores the unbrainsweepable tag.
139
146
*/
140
147
default void brainsweep (Mob mob ) {
141
148
var type = (EntityType <? extends Mob >) mob .getType ();
@@ -165,61 +172,59 @@ default FrozenPigment getColorizer(Player player) {
165
172
return FrozenPigment .DEFAULT .get ();
166
173
}
167
174
168
- ArmorMaterial DUMMY_ARMOR_MATERIAL = new ArmorMaterial () {
169
- @ Override
170
- public int getDurabilityForType (ArmorItem .Type type ) {
171
- return 0 ;
172
- }
173
-
174
- @ Override
175
- public int getDefenseForType (ArmorItem .Type type ) {
176
- return 0 ;
177
- }
178
-
179
- @ Override
180
- public int getEnchantmentValue () {
181
- return 0 ;
182
- }
183
-
184
- @ NotNull
185
- @ Override
186
- public SoundEvent getEquipSound () {
187
- return SoundEvents .ARMOR_EQUIP_LEATHER ;
188
- }
189
-
190
- @ NotNull
191
- @ Override
192
- public Ingredient getRepairIngredient () {
193
- return Ingredient .EMPTY ;
194
- }
195
-
196
- @ Override
197
- public String getName () {
198
- return "missingno" ;
199
- }
200
-
201
- @ Override
202
- public float getToughness () {
203
- return 0 ;
204
- }
205
-
206
- @ Override
207
- public float getKnockbackResistance () {
208
- return 0 ;
209
- }
210
- };
175
+ ArmorMaterial DUMMY_ARMOR_MATERIAL =
176
+ new ArmorMaterial () {
177
+ @ Override
178
+ public int getDurabilityForType (ArmorItem .Type type ) {
179
+ return 0 ;
180
+ }
181
+
182
+ @ Override
183
+ public int getDefenseForType (ArmorItem .Type type ) {
184
+ return 0 ;
185
+ }
186
+
187
+ @ Override
188
+ public int getEnchantmentValue () {
189
+ return 0 ;
190
+ }
191
+
192
+ @ NotNull
193
+ @ Override
194
+ public SoundEvent getEquipSound () {
195
+ return SoundEvents .ARMOR_EQUIP_LEATHER ;
196
+ }
197
+
198
+ @ NotNull
199
+ @ Override
200
+ public Ingredient getRepairIngredient () {
201
+ return Ingredient .EMPTY ;
202
+ }
203
+
204
+ @ Override
205
+ public String getName () {
206
+ return "missingno" ;
207
+ }
208
+
209
+ @ Override
210
+ public float getToughness () {
211
+ return 0 ;
212
+ }
213
+
214
+ @ Override
215
+ public float getKnockbackResistance () {
216
+ return 0 ;
217
+ }
218
+ };
211
219
212
220
default ArmorMaterial robesMaterial () {
213
221
return DUMMY_ARMOR_MATERIAL ;
214
222
}
215
223
216
- /**
217
- * Location in the userdata of the ravenmind
218
- */
224
+ /** Location in the userdata of the ravenmind */
219
225
String RAVENMIND_USERDATA = modLoc ("ravenmind" ).toString ();
220
- /**
221
- * Location in the userdata of the number of ops executed
222
- */
226
+
227
+ /** Location in the userdata of the number of ops executed */
223
228
String OP_COUNT_USERDATA = modLoc ("op_count" ).toString ();
224
229
225
230
String MARKED_MOVED_USERDATA = modLoc ("impulsed" ).toString ();
0 commit comments