17
17
import net .minecraft .loot .context .*;
18
18
import net .minecraft .loot .entry .*;
19
19
import net .minecraft .loot .provider .number .*;
20
+ import net .minecraft .predicate .*;
20
21
import net .minecraft .predicate .entity .*;
21
22
import net .minecraft .registry .*;
22
23
import net .minecraft .registry .entry .*;
@@ -220,20 +221,21 @@ public static void setup() {
220
221
}
221
222
222
223
private static RegistryEntry .Reference <Enchantment > getTreasureHunter (RegistryWrapper .WrapperLookup wrapperLookup ) {
223
- RegistryEntry .Reference <Enchantment > enchant ;
224
- RegistryWrapper .Impl <Enchantment > registryWrapper = wrapperLookup .getWrapperOrThrow (RegistryKeys .ENCHANTMENT );
225
- enchant = registryWrapper .getOrThrow (SpectrumEnchantments .TREASURE_HUNTER );
226
- return enchant ;
224
+ RegistryWrapper .Impl <Enchantment > wrapper = wrapperLookup .getWrapperOrThrow (RegistryKeys .ENCHANTMENT );
225
+ return wrapper .getOrThrow (SpectrumEnchantments .TREASURE_HUNTER );
227
226
}
228
227
229
- public static LootCondition .Builder Lootconditionbuilder (RegistryEntry .Reference <Enchantment > enchantment , float chance ) {
230
- return () -> new RandomChanceWithEnchantedBonusLootCondition (chance , new EnchantmentLevelBasedValue .Linear (chance , chance ), enchantment );
228
+ public static LootCondition .Builder treasureHunter (RegistryEntry .Reference <Enchantment > enchantment , float chance ) {
229
+ return AnyOfLootCondition .builder (
230
+ DamageSourcePropertiesLootCondition .builder (DamageSourcePredicate .Builder .create ().tag (TagPredicate .expected (SpectrumDamageTypeTags .ALWAYS_DROPS_MOB_HEAD ))),
231
+ () -> new RandomChanceWithEnchantedBonusLootCondition (0.0F , new EnchantmentLevelBasedValue .Linear (chance + chance , chance ), enchantment )
232
+ );
231
233
}
232
234
233
235
private static LootPool getLootPool (RegistryEntry .Reference <Enchantment > enchantment , TreasureHunterDropDefinition dropDefinition ) {
234
236
return new LootPool .Builder ()
235
237
.rolls (ConstantLootNumberProvider .create (1 ))
236
- .conditionally (Lootconditionbuilder (enchantment , dropDefinition .chancePerLevel ).build ())
238
+ .conditionally (treasureHunter (enchantment , dropDefinition .chancePerLevel ).build ())
237
239
.apply (GrantAdvancementLootFunction .builder (LootContext .EntityTarget .ATTACKING_PLAYER , List .of (SpectrumCommon .locate ("mob_head" ), dropDefinition .advancementUnlockId )))
238
240
.with (ItemEntry .builder (dropDefinition .drop ).build ())
239
241
.build ();
@@ -242,7 +244,7 @@ private static LootPool getLootPool(RegistryEntry.Reference<Enchantment> enchant
242
244
private static LootPool getFoxLootPool (RegistryEntry .Reference <Enchantment > enchantment , FoxEntity .Type foxType , TreasureHunterDropDefinition dropDefinition ) {
243
245
return new LootPool .Builder ()
244
246
.rolls (ConstantLootNumberProvider .create (1 ))
245
- .conditionally (Lootconditionbuilder (enchantment , dropDefinition .chancePerLevel ).build ())
247
+ .conditionally (treasureHunter (enchantment , dropDefinition .chancePerLevel ).build ())
246
248
.conditionally (EntityPropertiesLootCondition .builder (LootContext .EntityTarget .THIS , EntityPredicate .Builder .create ().typeSpecific (EntitySubPredicateTypes .FOX .createPredicate (foxType )).build ()).build ())
247
249
.apply (GrantAdvancementLootFunction .builder (LootContext .EntityTarget .ATTACKING_PLAYER , List .of (SpectrumCommon .locate ("mob_head" ), dropDefinition .advancementUnlockId )))
248
250
.with (ItemEntry .builder (dropDefinition .drop ).build ())
@@ -252,7 +254,7 @@ private static LootPool getFoxLootPool(RegistryEntry.Reference<Enchantment> ench
252
254
private static LootPool getMooshroomLootPool (RegistryEntry .Reference <Enchantment > enchantment , MooshroomEntity .Type mooshroomType , TreasureHunterDropDefinition dropDefinition ) {
253
255
return new LootPool .Builder ()
254
256
.rolls (ConstantLootNumberProvider .create (1 ))
255
- .conditionally (Lootconditionbuilder (enchantment , dropDefinition .chancePerLevel ).build ())
257
+ .conditionally (treasureHunter (enchantment , dropDefinition .chancePerLevel ).build ())
256
258
.conditionally (EntityPropertiesLootCondition .builder (LootContext .EntityTarget .THIS , EntityPredicate .Builder .create ().typeSpecific (EntitySubPredicateTypes .MOOSHROOM .createPredicate (mooshroomType )).build ()).build ())
257
259
.apply (GrantAdvancementLootFunction .builder (LootContext .EntityTarget .ATTACKING_PLAYER , List .of (SpectrumCommon .locate ("mob_head" ), dropDefinition .advancementUnlockId )))
258
260
.with (ItemEntry .builder (dropDefinition .drop ).build ())
@@ -262,7 +264,7 @@ private static LootPool getMooshroomLootPool(RegistryEntry.Reference<Enchantment
262
264
private static LootPool getShulkerLootPool (RegistryEntry .Reference <Enchantment > enchantment , @ Nullable DyeColor dyeColor , TreasureHunterDropDefinition dropDefinition ) {
263
265
return new LootPool .Builder ()
264
266
.rolls (ConstantLootNumberProvider .create (1 ))
265
- .conditionally (Lootconditionbuilder (enchantment , dropDefinition .chancePerLevel ).build ())
267
+ .conditionally (treasureHunter (enchantment , dropDefinition .chancePerLevel ).build ())
266
268
.conditionally (EntityPropertiesLootCondition .builder (LootContext .EntityTarget .THIS , EntityPredicate .Builder .create ().typeSpecific (new ShulkerPredicate (Optional .ofNullable (dyeColor ))).build ()).build ())
267
269
.apply (GrantAdvancementLootFunction .builder (LootContext .EntityTarget .ATTACKING_PLAYER , List .of (SpectrumCommon .locate ("mob_head" ), dropDefinition .advancementUnlockId )))
268
270
.with (ItemEntry .builder (dropDefinition .drop ).build ())
@@ -272,7 +274,7 @@ private static LootPool getShulkerLootPool(RegistryEntry.Reference<Enchantment>
272
274
private static LootPool getLizardLootPool (RegistryEntry .Reference <Enchantment > enchantment , InkColor linkColor , TreasureHunterDropDefinition dropDefinition ) {
273
275
return new LootPool .Builder ()
274
276
.rolls (ConstantLootNumberProvider .create (1 ))
275
- .conditionally (Lootconditionbuilder (enchantment , dropDefinition .chancePerLevel ).build ())
277
+ .conditionally (treasureHunter (enchantment , dropDefinition .chancePerLevel ).build ())
276
278
.conditionally (EntityPropertiesLootCondition .builder (LootContext .EntityTarget .THIS , EntityPredicate .Builder .create ().typeSpecific (new LizardPredicate (Optional .of (linkColor ), Optional .empty (), Optional .empty ())).build ()).build ())
277
279
.apply (GrantAdvancementLootFunction .builder (LootContext .EntityTarget .ATTACKING_PLAYER , List .of (SpectrumCommon .locate ("mob_head" ), dropDefinition .advancementUnlockId )))
278
280
.with (ItemEntry .builder (dropDefinition .drop ).build ())
@@ -282,7 +284,7 @@ private static LootPool getLizardLootPool(RegistryEntry.Reference<Enchantment> e
282
284
private static LootPool getAxolotlLootPool (RegistryEntry .Reference <Enchantment > enchantment , AxolotlEntity .Variant variant , TreasureHunterDropDefinition dropDefinition ) {
283
285
return new LootPool .Builder ()
284
286
.rolls (ConstantLootNumberProvider .create (1 ))
285
- .conditionally (Lootconditionbuilder (enchantment , dropDefinition .chancePerLevel ).build ())
287
+ .conditionally (treasureHunter (enchantment , dropDefinition .chancePerLevel ).build ())
286
288
.conditionally (EntityPropertiesLootCondition .builder (LootContext .EntityTarget .THIS , EntityPredicate .Builder .create ().typeSpecific (EntitySubPredicateTypes .AXOLOTL .createPredicate (variant )).build ()).build ())
287
289
.apply (GrantAdvancementLootFunction .builder (LootContext .EntityTarget .ATTACKING_PLAYER , List .of (SpectrumCommon .locate ("mob_head" ), dropDefinition .advancementUnlockId )))
288
290
.with (ItemEntry .builder (dropDefinition .drop ).build ())
@@ -294,7 +296,7 @@ private static LootPool getFrogLootPool(RegistryEntry.Reference<Enchantment> enc
294
296
295
297
return new LootPool .Builder ()
296
298
.rolls (ConstantLootNumberProvider .create (1 ))
297
- .conditionally (Lootconditionbuilder (enchantment , dropDefinition .chancePerLevel ).build ())
299
+ .conditionally (treasureHunter (enchantment , dropDefinition .chancePerLevel ).build ())
298
300
.conditionally (EntityPropertiesLootCondition .builder (LootContext .EntityTarget .THIS , EntityPredicate .Builder .create ().typeSpecific (EntitySubPredicateTypes .FROG .createPredicate (RegistryEntryList .of (entry ))).build ()).build ())
299
301
.apply (GrantAdvancementLootFunction .builder (LootContext .EntityTarget .ATTACKING_PLAYER , List .of (SpectrumCommon .locate ("mob_head" ), dropDefinition .advancementUnlockId )))
300
302
.with (ItemEntry .builder (dropDefinition .drop ).build ())
@@ -304,7 +306,7 @@ private static LootPool getFrogLootPool(RegistryEntry.Reference<Enchantment> enc
304
306
private static LootPool getParrotLootPool (RegistryEntry .Reference <Enchantment > enchantment , ParrotEntity .Variant variant , TreasureHunterDropDefinition dropDefinition ) {
305
307
return new LootPool .Builder ()
306
308
.rolls (ConstantLootNumberProvider .create (1 ))
307
- .conditionally (Lootconditionbuilder (enchantment , dropDefinition .chancePerLevel ).build ())
309
+ .conditionally (treasureHunter (enchantment , dropDefinition .chancePerLevel ).build ())
308
310
.conditionally (EntityPropertiesLootCondition .builder (LootContext .EntityTarget .THIS , EntityPredicate .Builder .create ().typeSpecific (EntitySubPredicateTypes .PARROT .createPredicate (variant )).build ()).build ())
309
311
.apply (GrantAdvancementLootFunction .builder (LootContext .EntityTarget .ATTACKING_PLAYER , List .of (SpectrumCommon .locate ("mob_head" ), dropDefinition .advancementUnlockId )))
310
312
.with (ItemEntry .builder (dropDefinition .drop ).build ())
0 commit comments