-
Notifications
You must be signed in to change notification settings - Fork 755
/
ModifierProvider.java
533 lines (508 loc) · 37.1 KB
/
ModifierProvider.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
package slimeknights.tconstruct.tools.data;
import net.minecraft.data.DataGenerator;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobType;
import net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.Tiers;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.LightLayer;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LiquidBlock;
import net.minecraftforge.common.ForgeMod;
import net.minecraftforge.common.ToolActions;
import net.minecraftforge.common.crafting.conditions.IConditionBuilder;
import net.minecraftforge.fluids.FluidType;
import slimeknights.mantle.data.predicate.IJsonPredicate;
import slimeknights.mantle.data.predicate.block.BlockPredicate;
import slimeknights.mantle.data.predicate.block.BlockPropertiesPredicate;
import slimeknights.mantle.data.predicate.damage.DamageSourcePredicate;
import slimeknights.mantle.data.predicate.damage.SourceMessagePredicate;
import slimeknights.mantle.data.predicate.entity.HasEnchantmentEntityPredicate;
import slimeknights.mantle.data.predicate.entity.LivingEntityPredicate;
import slimeknights.mantle.data.predicate.entity.MobTypePredicate;
import slimeknights.mantle.data.predicate.item.ItemPredicate;
import slimeknights.tconstruct.TConstruct;
import slimeknights.tconstruct.common.TinkerTags;
import slimeknights.tconstruct.library.data.tinkering.AbstractModifierProvider;
import slimeknights.tconstruct.library.json.RandomLevelingValue;
import slimeknights.tconstruct.library.json.predicate.TinkerPredicate;
import slimeknights.tconstruct.library.json.predicate.tool.HasModifierPredicate;
import slimeknights.tconstruct.library.json.predicate.tool.ToolContextPredicate;
import slimeknights.tconstruct.library.json.variable.block.BlockVariable;
import slimeknights.tconstruct.library.json.variable.entity.AttributeEntityVariable;
import slimeknights.tconstruct.library.json.variable.entity.ConditionalEntityVariable;
import slimeknights.tconstruct.library.json.variable.entity.EntityEffectLevelVariable;
import slimeknights.tconstruct.library.json.variable.entity.EntityVariable;
import slimeknights.tconstruct.library.json.variable.melee.EntityMeleeVariable;
import slimeknights.tconstruct.library.json.variable.melee.EntityMeleeVariable.WhichEntity;
import slimeknights.tconstruct.library.json.variable.mining.BlockLightVariable;
import slimeknights.tconstruct.library.json.variable.mining.BlockMiningSpeedVariable;
import slimeknights.tconstruct.library.json.variable.stat.EntityConditionalStatVariable;
import slimeknights.tconstruct.library.json.variable.tool.ToolStatVariable;
import slimeknights.tconstruct.library.json.variable.tool.ToolVariable;
import slimeknights.tconstruct.library.modifiers.Modifier;
import slimeknights.tconstruct.library.modifiers.ModifierEntry;
import slimeknights.tconstruct.library.modifiers.ModifierHooks;
import slimeknights.tconstruct.library.modifiers.ModifierId;
import slimeknights.tconstruct.library.modifiers.dynamic.InventoryMenuModifier;
import slimeknights.tconstruct.library.modifiers.impl.BasicModifier.TooltipDisplay;
import slimeknights.tconstruct.library.modifiers.modules.armor.BlockDamageSourceModule;
import slimeknights.tconstruct.library.modifiers.modules.armor.CoverGroundWalkerModule;
import slimeknights.tconstruct.library.modifiers.modules.armor.MobDisguiseModule;
import slimeknights.tconstruct.library.modifiers.modules.armor.ProtectionModule;
import slimeknights.tconstruct.library.modifiers.modules.armor.ReplaceBlockWalkerModule;
import slimeknights.tconstruct.library.modifiers.modules.armor.ToolActionWalkerTransformModule;
import slimeknights.tconstruct.library.modifiers.modules.behavior.AttributeModule;
import slimeknights.tconstruct.library.modifiers.modules.behavior.ConditionalStatModule;
import slimeknights.tconstruct.library.modifiers.modules.behavior.ExtinguishCampfireModule;
import slimeknights.tconstruct.library.modifiers.modules.behavior.ReduceToolDamageModule;
import slimeknights.tconstruct.library.modifiers.modules.behavior.RepairModule;
import slimeknights.tconstruct.library.modifiers.modules.behavior.ShowOffhandModule;
import slimeknights.tconstruct.library.modifiers.modules.behavior.ToolActionTransformModule;
import slimeknights.tconstruct.library.modifiers.modules.build.EnchantmentModule;
import slimeknights.tconstruct.library.modifiers.modules.build.ModifierRequirementsModule;
import slimeknights.tconstruct.library.modifiers.modules.build.ModifierSlotModule;
import slimeknights.tconstruct.library.modifiers.modules.build.RarityModule;
import slimeknights.tconstruct.library.modifiers.modules.build.SetStatModule;
import slimeknights.tconstruct.library.modifiers.modules.build.StatBoostModule;
import slimeknights.tconstruct.library.modifiers.modules.build.SwappableSlotModule;
import slimeknights.tconstruct.library.modifiers.modules.build.VolatileFlagModule;
import slimeknights.tconstruct.library.modifiers.modules.combat.ConditionalMeleeDamageModule;
import slimeknights.tconstruct.library.modifiers.modules.combat.KnockbackModule;
import slimeknights.tconstruct.library.modifiers.modules.combat.LootingModule;
import slimeknights.tconstruct.library.modifiers.modules.combat.MeleeAttributeModule;
import slimeknights.tconstruct.library.modifiers.modules.combat.MobEffectModule;
import slimeknights.tconstruct.library.modifiers.modules.display.DurabilityBarColorModule;
import slimeknights.tconstruct.library.modifiers.modules.fluid.TankModule;
import slimeknights.tconstruct.library.modifiers.modules.mining.ConditionalMiningSpeedModule;
import slimeknights.tconstruct.library.modifiers.modules.util.ModifierCondition;
import slimeknights.tconstruct.library.modifiers.util.ModifierLevelDisplay;
import slimeknights.tconstruct.library.modifiers.util.ModifierLevelDisplay.UniqueForLevels;
import slimeknights.tconstruct.library.tools.SlotType;
import slimeknights.tconstruct.library.tools.item.IModifiable;
import slimeknights.tconstruct.library.tools.item.ModifiableArmorItem;
import slimeknights.tconstruct.library.tools.nbt.IToolContext;
import slimeknights.tconstruct.library.tools.stat.ToolStats;
import slimeknights.tconstruct.tools.TinkerModifiers;
import slimeknights.tconstruct.tools.modifiers.ability.armor.ToolBeltModifier;
import slimeknights.tconstruct.tools.modifiers.slotless.OverslimeModifier;
import slimeknights.tconstruct.tools.modules.TheOneProbeModule;
import static slimeknights.tconstruct.common.TinkerTags.Items.ARMOR;
import static slimeknights.tconstruct.common.TinkerTags.Items.HARVEST;
import static slimeknights.tconstruct.common.TinkerTags.Items.MELEE;
import static slimeknights.tconstruct.common.TinkerTags.Items.WORN_ARMOR;
import static slimeknights.tconstruct.library.json.math.ModifierFormula.LEVEL;
import static slimeknights.tconstruct.library.json.math.ModifierFormula.MULTIPLIER;
import static slimeknights.tconstruct.library.json.math.ModifierFormula.VALUE;
import static slimeknights.tconstruct.library.modifiers.modules.behavior.RepairModule.FACTOR;
import static slimeknights.tconstruct.library.tools.definition.ModifiableArmorMaterial.ARMOR_SLOTS;
public class ModifierProvider extends AbstractModifierProvider implements IConditionBuilder {
public ModifierProvider(DataGenerator generator) {
super(generator);
}
@Override
protected void addModifiers() {
EquipmentSlot[] handSlots = {EquipmentSlot.MAINHAND, EquipmentSlot.OFFHAND};
EquipmentSlot[] armorSlots = ARMOR_SLOTS;
EquipmentSlot[] armorMainHand = {EquipmentSlot.MAINHAND, EquipmentSlot.FEET, EquipmentSlot.LEGS, EquipmentSlot.CHEST, EquipmentSlot.HEAD};
// extra modifier slots
ModifierSlotModule UPGRADE = new ModifierSlotModule(SlotType.UPGRADE);
buildModifier(ModifierIds.writable) .tooltipDisplay(TooltipDisplay.TINKER_STATION).levelDisplay(ModifierLevelDisplay.SINGLE_LEVEL).addModule(UPGRADE);
buildModifier(ModifierIds.recapitated).tooltipDisplay(TooltipDisplay.TINKER_STATION).levelDisplay(ModifierLevelDisplay.SINGLE_LEVEL).addModule(UPGRADE);
buildModifier(ModifierIds.harmonious) .tooltipDisplay(TooltipDisplay.TINKER_STATION).levelDisplay(ModifierLevelDisplay.SINGLE_LEVEL).addModule(UPGRADE);
buildModifier(ModifierIds.resurrected).tooltipDisplay(TooltipDisplay.TINKER_STATION).levelDisplay(ModifierLevelDisplay.SINGLE_LEVEL).addModule(UPGRADE);
buildModifier(ModifierIds.gilded) .tooltipDisplay(TooltipDisplay.TINKER_STATION).levelDisplay(ModifierLevelDisplay.SINGLE_LEVEL).addModule(new ModifierSlotModule(SlotType.UPGRADE, 2));
buildModifier(ModifierIds.draconic) .tooltipDisplay(TooltipDisplay.TINKER_STATION).levelDisplay(ModifierLevelDisplay.SINGLE_LEVEL).addModule(new ModifierSlotModule(SlotType.ABILITY, 1));
buildModifier(ModifierIds.rebalanced)
.tooltipDisplay(TooltipDisplay.TINKER_STATION).levelDisplay(ModifierLevelDisplay.NO_LEVELS)
.addModule(new SwappableSlotModule(1)).addModule(new SwappableSlotModule.BonusSlot(SlotType.ABILITY, SlotType.UPGRADE, -1));
// tier upgrades
// emerald
buildModifier(ModifierIds.emerald)
.levelDisplay(ModifierLevelDisplay.NO_LEVELS)
.addModule(new RarityModule(Rarity.UNCOMMON))
.addModule(StatBoostModule.multiplyBase(ToolStats.DURABILITY).flat(0.5f))
.addModule(RepairModule.builder().flat(0.5f))
// armor
.addModule(StatBoostModule.add(ToolStats.KNOCKBACK_RESISTANCE).flat(0.05f))
// melee harvest
.addModule(StatBoostModule.multiplyConditional(ToolStats.ATTACK_DAMAGE).flat(0.25f))
.addModule(StatBoostModule.multiplyConditional(ToolStats.MINING_SPEED).flat(0.25f))
.addModule(SetStatModule.set(ToolStats.HARVEST_TIER).value(Tiers.IRON))
// ranged
.addModule(StatBoostModule.add(ToolStats.ACCURACY).flat(0.1f));
// diamond
buildModifier(ModifierIds.diamond)
.levelDisplay(ModifierLevelDisplay.NO_LEVELS)
.addModule(new RarityModule(Rarity.UNCOMMON))
.addModule(StatBoostModule.add(ToolStats.DURABILITY).flat(500))
// armor grants less durability boost
.addModule(StatBoostModule.add(ToolStats.DURABILITY).toolItem(ItemPredicate.tag(ARMOR)).flat(-250))
.addModule(StatBoostModule.add(ToolStats.ARMOR).flat(1))
// melee harvest
.addModule(StatBoostModule.add(ToolStats.ATTACK_DAMAGE).flat(0.5f))
.addModule(StatBoostModule.add(ToolStats.MINING_SPEED).flat(2))
.addModule(SetStatModule.set(ToolStats.HARVEST_TIER).value(Tiers.DIAMOND))
// ranged
.addModule(StatBoostModule.add(ToolStats.PROJECTILE_DAMAGE).flat(0.5f));
// netherite
buildModifier(ModifierIds.netherite)
.levelDisplay(ModifierLevelDisplay.NO_LEVELS)
.addModule(ModifierRequirementsModule.builder().modifierKey(ModifierIds.netherite).requireModifier(TinkerTags.Modifiers.GEMS, 1).displayModifier(ModifierIds.diamond, 1).build())
.addModule(new RarityModule(Rarity.RARE))
.addModule(new VolatileFlagModule(IModifiable.INDESTRUCTIBLE_ENTITY))
.addModule(StatBoostModule.multiplyBase(ToolStats.DURABILITY).flat(0.2f))
// armor
.addModule(StatBoostModule.add(ToolStats.ARMOR_TOUGHNESS).flat(1))
.addModule(StatBoostModule.add(ToolStats.KNOCKBACK_RESISTANCE).flat(0.05f))
// melee harvest
.addModule(StatBoostModule.multiplyBase(ToolStats.ATTACK_DAMAGE).flat(0.2f))
.addModule(StatBoostModule.multiplyBase(ToolStats.MINING_SPEED).flat(0.25f))
.addModule(SetStatModule.set(ToolStats.HARVEST_TIER).value(Tiers.NETHERITE))
// ranged
.addModule(StatBoostModule.multiplyBase(ToolStats.VELOCITY).flat(0.1f));
// general
buildModifier(ModifierIds.worldbound).addModule(new VolatileFlagModule(IModifiable.INDESTRUCTIBLE_ENTITY)).addModule(new RarityModule(Rarity.UNCOMMON)).levelDisplay(ModifierLevelDisplay.NO_LEVELS);
buildModifier(ModifierIds.shiny).addModule(new VolatileFlagModule(IModifiable.SHINY)).addModule(new RarityModule(Rarity.EPIC)).levelDisplay(ModifierLevelDisplay.NO_LEVELS);
buildModifier(ModifierIds.offhanded)
.addModule(new VolatileFlagModule(IModifiable.DEFER_OFFHAND))
.addModule(new VolatileFlagModule(IModifiable.NO_INTERACTION, new ModifierCondition<>(ToolContextPredicate.ANY, ModifierEntry.VALID_LEVEL.min(2))))
.levelDisplay(new UniqueForLevels(2));
// general abilities
buildModifier(ModifierIds.reach)
.addModule(AttributeModule.builder(ForgeMod.REACH_DISTANCE.get(), Operation.ADDITION).uniqueFrom(ModifierIds.reach).eachLevel(1))
.addModule(AttributeModule.builder(ForgeMod.ATTACK_RANGE.get(), Operation.ADDITION).uniqueFrom(ModifierIds.reach).eachLevel(1));
IJsonPredicate<IToolContext> noUnbreakable = HasModifierPredicate.hasModifier(TinkerModifiers.unbreakable.getId(), 1).inverted();
buildModifier(ModifierIds.reinforced)
// level 0 to 5: 0.025 * LEVEL * (11 - LEVEL)
.addModule(ReduceToolDamageModule.builder().toolContext(noUnbreakable).maxLevel(5).formula()
.constant(0.025f).variable(LEVEL).multiply() // 0.025 * level
.constant(11).variable(LEVEL).subtract() // 11 - level
.multiply().build())
// level 6+: 0.5 + level * 0.05
.addModule(ReduceToolDamageModule.builder().toolContext(noUnbreakable).minLevel(6).amount(0.5f, 0.05f));
// unbreakable priority is after overslime but before standard modifiers like dense
buildModifier(TinkerModifiers.unbreakable)
.levelDisplay(ModifierLevelDisplay.NO_LEVELS).priority(125)
.addModule(ModifierRequirementsModule.builder().requireModifier(ModifierIds.netherite, 1).requireModifier(ModifierIds.reinforced, 5).modifierKey(TinkerModifiers.unbreakable).build())
.addModule(new DurabilityBarColorModule(0xffffff))
.addModule(ReduceToolDamageModule.builder().flat(1.0f));
buildModifier(ModifierIds.tank).addModule(new TankModule(FluidType.BUCKET_VOLUME, true));
buildModifier(ModifierIds.theOneProbe, modLoaded("theoneprobe")).levelDisplay(ModifierLevelDisplay.NO_LEVELS).addModule(TheOneProbeModule.INSTANCE);
buildModifier(ModifierIds.overforced).addModule(StatBoostModule.add(OverslimeModifier.OVERSLIME_STAT).eachLevel(75));
// harvest
buildModifier(ModifierIds.blasting).addModule(
ConditionalMiningSpeedModule.builder()
.customVariable("resistance", new BlockMiningSpeedVariable(BlockVariable.BLAST_RESISTANCE, 3))
.formula()
.constant(3)
.constant(6).customVariable("resistance").subtract() // (6 - resistance)
.constant(1.5f)
.divide() // above / 1.5
.power() // 3^above
.constant(10).min() // min(above, 10)
.variable(LEVEL).multiply() // above * level
.variable(MULTIPLIER).multiply() // above * multiplier
.variable(VALUE).add() // above + newSpeed
.build());
buildModifier(ModifierIds.hydraulic).addModule(
ConditionalMiningSpeedModule.builder()
.customVariable("bonus", new EntityConditionalStatVariable(new ConditionalEntityVariable(
LivingEntityPredicate.EYES_IN_WATER,
new ConditionalEntityVariable(new HasEnchantmentEntityPredicate(Enchantments.AQUA_AFFINITY), 8, 40),
new ConditionalEntityVariable(LivingEntityPredicate.RAINING, 4, 0)
), 8)).formula()
.variable(MULTIPLIER).customVariable("bonus").multiply()
.variable(LEVEL).multiply()
.variable(VALUE).add()
.build());
buildModifier(ModifierIds.lightspeed).addModule(
ConditionalMiningSpeedModule.builder()
.customVariable("light", new BlockLightVariable(LightLayer.BLOCK, 15))
.formula()
.constant(3)
.customVariable("light").constant(5).subtract()
.constant(5).divide()
.power()
.variable(LEVEL).multiply()
.variable(MULTIPLIER).multiply()
.variable(VALUE).add().build());
// loot
// constant enchants are harvest exclusive as we want to avoid non-harvest acting oddly with armor variant
IJsonPredicate<Item> harvest = ItemPredicate.tag(HARVEST);
IJsonPredicate<Item> armor = ItemPredicate.tag(WORN_ARMOR);
buildModifier(TinkerModifiers.silky).levelDisplay(ModifierLevelDisplay.NO_LEVELS)
.addModule(EnchantmentModule.builder(Enchantments.SILK_TOUCH).toolItem(harvest).constant())
.addModule(EnchantmentModule.builder(Enchantments.SILK_TOUCH).toolItem(armor).armorHarvest(ARMOR_SLOTS));
EnchantmentModule CONSTANT_FORTUNE = EnchantmentModule.builder(Enchantments.BLOCK_FORTUNE).toolItem(harvest).constant();
EnchantmentModule ARMOR_FORTUNE = EnchantmentModule.builder(Enchantments.BLOCK_FORTUNE).toolItem(armor).armorHarvest(ARMOR_SLOTS);
// note chestplates will have both modules, but will get ignored due to setting the looting slot
// the air check on weapon looting is for projectiles which use an item of air in their tool context
LootingModule WEAPON_LOOTING = LootingModule.builder().toolItem(ItemPredicate.or(ItemPredicate.set(Items.AIR), ItemPredicate.tag(MELEE))).weapon();
LootingModule ARMOR_LOOTING = LootingModule.builder().toolItem(armor).armor(ARMOR_SLOTS);
buildModifier(ModifierIds.luck).levelDisplay(new UniqueForLevels(3)).addModules(CONSTANT_FORTUNE, ARMOR_FORTUNE, WEAPON_LOOTING, ARMOR_LOOTING);
buildModifier(ModifierIds.fortune).addModules(CONSTANT_FORTUNE, ARMOR_FORTUNE);
buildModifier(ModifierIds.looting).addModules(WEAPON_LOOTING, ARMOR_LOOTING);
/// attack
buildModifier(TinkerModifiers.knockback)
// do not boost chestplate attacks twice, thats a bit too much knockback for the cost
.addModule(KnockbackModule.builder().toolItem(ItemPredicate.tag(TinkerTags.Items.CHESTPLATES).inverted()).eachLevel(0.5f))
.addModule(AttributeModule.builder(Attributes.ATTACK_KNOCKBACK, Operation.ADDITION).uniqueFrom(TinkerModifiers.knockback.getId()).slots(armorSlots).eachLevel(1));
buildModifier(TinkerModifiers.padded)
.priority(75) // run after knockback
.addModule(KnockbackModule.builder().formula()
.variable(VALUE)
.constant(2).variable(LEVEL).power() // 2^LEVEL
.divide().build()); // KNOCKBACK / 2^LEVEL
buildModifier(ModifierIds.sticky)
.addModule(MobEffectModule.builder(MobEffects.MOVEMENT_SLOWDOWN).level(RandomLevelingValue.perLevel(0, 0.5f)).time(RandomLevelingValue.random(20, 10)).build());
// damage boost
// vanilla give +1, 1.5, 2, 2.5, 3, but that is low
// we instead do +0.75, +1.5, +2.25, +3, +3.75
buildModifier(ModifierIds.sharpness).addModule(StatBoostModule.add(ToolStats.ATTACK_DAMAGE).eachLevel(0.75f)).levelDisplay(new UniqueForLevels(5, true));
buildModifier(ModifierIds.swiftstrike).addModule(StatBoostModule.multiplyBase(ToolStats.ATTACK_SPEED).eachLevel(0.05f)).levelDisplay(new UniqueForLevels(5));
buildModifier(ModifierIds.smite).addModule(ConditionalMeleeDamageModule.builder().target(new MobTypePredicate(MobType.UNDEAD)).eachLevel(2.0f));
buildModifier(ModifierIds.antiaquatic).addModule(ConditionalMeleeDamageModule.builder().target(new MobTypePredicate(MobType.WATER)).eachLevel(2.0f));
buildModifier(ModifierIds.cooling).addModule(ConditionalMeleeDamageModule.builder().target(LivingEntityPredicate.FIRE_IMMUNE).eachLevel(1.6f));
IJsonPredicate<LivingEntity> baneSssssPredicate = LivingEntityPredicate.or(new MobTypePredicate(MobType.ARTHROPOD), LivingEntityPredicate.tag(TinkerTags.EntityTypes.CREEPERS));
buildModifier(ModifierIds.baneOfSssss)
.addModule(ConditionalMeleeDamageModule.builder().target(baneSssssPredicate).eachLevel(2.0f))
.addModule(MobEffectModule.builder(MobEffects.MOVEMENT_SLOWDOWN).level(RandomLevelingValue.flat(4)).time(RandomLevelingValue.random(20, 10)).target(baneSssssPredicate).build(), ModifierHooks.MELEE_HIT);
buildModifier(ModifierIds.killager).addModule(ConditionalMeleeDamageModule.builder().target(LivingEntityPredicate.or(
new MobTypePredicate(MobType.ILLAGER),
LivingEntityPredicate.LOADER.tag(TinkerTags.EntityTypes.VILLAGERS))).eachLevel(2.0f));
buildModifier(ModifierIds.pierce)
// less than sharpness, but pierces 1 armor
.addModule(StatBoostModule.add(ToolStats.ATTACK_DAMAGE).eachLevel(0.5f))
.addModule(MeleeAttributeModule.builder(Attributes.ARMOR, Operation.ADDITION).uniqueFrom(ModifierIds.pierce).eachLevel(-1))
// use a mob effect to make this work on ranged, to ensure it automatically cancels
.addModule(MobEffectModule.builder(TinkerModifiers.pierceEffect.get()).level(RandomLevelingValue.perLevel(0, 1)).time(RandomLevelingValue.flat(2)).build(), ModifierHooks.PROJECTILE_HIT);
// ranged
buildModifier(ModifierIds.power).addModule(StatBoostModule.add(ToolStats.PROJECTILE_DAMAGE).eachLevel(0.5f));
buildModifier(ModifierIds.quickCharge).addModule(StatBoostModule.multiplyBase(ToolStats.DRAW_SPEED).eachLevel(0.25f));
buildModifier(ModifierIds.trueshot).addModule(StatBoostModule.add(ToolStats.ACCURACY).eachLevel(0.1f));
buildModifier(ModifierIds.blindshot).addModule(StatBoostModule.add(ToolStats.ACCURACY).eachLevel(-0.1f));
// armor
buildModifier(TinkerModifiers.golden).addModule(new VolatileFlagModule(ModifiableArmorItem.PIGLIN_NEUTRAL)).levelDisplay(ModifierLevelDisplay.NO_LEVELS);
buildModifier(ModifierIds.wings).addModule(new VolatileFlagModule(ModifiableArmorItem.ELYTRA)).levelDisplay(ModifierLevelDisplay.NO_LEVELS);
buildModifier(ModifierIds.knockbackResistance).addModule(StatBoostModule.add(ToolStats.KNOCKBACK_RESISTANCE).eachLevel(0.1f));
// defense
// TODO: floor?
buildModifier(ModifierIds.revitalizing).addModule(AttributeModule.builder(Attributes.MAX_HEALTH, Operation.ADDITION).uniqueFrom(ModifierIds.revitalizing).slots(armorSlots).eachLevel(2));
// protection
buildModifier(ModifierIds.protection).addModule(ProtectionModule.source(DamageSourcePredicate.CAN_PROTECT).eachLevel(1.25f));
buildModifier(ModifierIds.fireProtection)
.addModule(EnchantmentModule.builder(Enchantments.FIRE_PROTECTION).constant())
.addModule(ProtectionModule.source(DamageSourcePredicate.and(DamageSourcePredicate.CAN_PROTECT, DamageSourcePredicate.FIRE)).subtract(Enchantments.FIRE_PROTECTION).eachLevel(2.5f));
buildModifier(ModifierIds.turtleShell)
.addModule(AttributeModule.builder(ForgeMod.SWIM_SPEED.get(), Operation.MULTIPLY_TOTAL).uniqueFrom(ModifierIds.turtleShell).slots(armorSlots).eachLevel(0.05f))
.addModule(ProtectionModule.source(DamageSourcePredicate.CAN_PROTECT)
.toolItem(ItemPredicate.or(ItemPredicate.tag(TinkerTags.Items.HELMETS), ItemPredicate.tag(TinkerTags.Items.CHESTPLATES)))
.entity(LivingEntityPredicate.EYES_IN_WATER).eachLevel(2.5f))
.addModule(ProtectionModule.source(DamageSourcePredicate.CAN_PROTECT)
.toolItem(ItemPredicate.or(ItemPredicate.tag(TinkerTags.Items.LEGGINGS), ItemPredicate.tag(TinkerTags.Items.BOOTS)))
.entity(LivingEntityPredicate.FEET_IN_WATER).eachLevel(2.5f));
// helmet
buildModifier(ModifierIds.respiration).addModule(EnchantmentModule.builder(Enchantments.RESPIRATION).constant());
buildModifier(ModifierIds.aquaAffinity).addModule(EnchantmentModule.builder(Enchantments.AQUA_AFFINITY).constant()).levelDisplay(ModifierLevelDisplay.NO_LEVELS);
// chestplate
buildModifier(ModifierIds.strength).addModule(AttributeModule.builder(Attributes.ATTACK_DAMAGE, Operation.MULTIPLY_TOTAL).uniqueFrom(ModifierIds.strength).slots(armorSlots).eachLevel(0.1f));
// leggings
addModifier(ModifierIds.pockets, new InventoryMenuModifier(18));
addModifier(ModifierIds.toolBelt, new ToolBeltModifier(new int[] {4, 5, 6, 7, 8, 9}));
buildModifier(ModifierIds.stepUp).addModule(AttributeModule.builder(ForgeMod.STEP_HEIGHT_ADDITION.get(), Operation.ADDITION).uniqueFrom(ModifierIds.stepUp).slots(armorSlots).eachLevel(0.5f));
buildModifier(ModifierIds.speedy).addModule(AttributeModule.builder(Attributes.MOVEMENT_SPEED, Operation.MULTIPLY_TOTAL).uniqueFrom(ModifierIds.speedy).slots(armorMainHand).eachLevel(0.1f));
// boots
buildModifier(ModifierIds.depthStrider).addModule(EnchantmentModule.builder(Enchantments.DEPTH_STRIDER).constant());
buildModifier(ModifierIds.featherFalling).addModule(ProtectionModule.source(DamageSourcePredicate.FALL).eachLevel(3.75f));
buildModifier(ModifierIds.longFall)
.levelDisplay(ModifierLevelDisplay.NO_LEVELS)
.addModule(ModifierRequirementsModule.builder().requireModifier(ModifierIds.featherFalling, 4).modifierKey(ModifierIds.longFall).build())
.addModule(BlockDamageSourceModule.source(DamageSourcePredicate.FALL).build());
buildModifier(ModifierIds.frostWalker)
.levelDisplay(ModifierLevelDisplay.NO_LEVELS)
.addModule(BlockDamageSourceModule.source(new SourceMessagePredicate(DamageSource.HOT_FLOOR)).build())
.addModule(ReplaceBlockWalkerModule.builder().replaceAlways(BlockPropertiesPredicate.block(Blocks.WATER).matches(LiquidBlock.LEVEL, 0).build(), Blocks.FROSTED_ICE.defaultBlockState()).amount(2, 1));
buildModifier(ModifierIds.pathMaker).levelDisplay(ModifierLevelDisplay.NO_LEVELS).addModule(ToolActionWalkerTransformModule.builder(ToolActions.SHOVEL_FLATTEN, SoundEvents.SHOVEL_FLATTEN).amount(0.5f, 1));
buildModifier(ModifierIds.plowing).levelDisplay(ModifierLevelDisplay.NO_LEVELS).addModule(ToolActionWalkerTransformModule.builder(ToolActions.HOE_TILL, SoundEvents.HOE_TILL).amount(0.5f, 1));
buildModifier(ModifierIds.snowdrift).priority(90).levelDisplay(ModifierLevelDisplay.NO_LEVELS).addModule(CoverGroundWalkerModule.block(Blocks.SNOW).amount(0.5f, 1));
// interaction
buildModifier(ModifierIds.pathing)
.levelDisplay(ModifierLevelDisplay.NO_LEVELS)
.addModule(ShowOffhandModule.DISALLOW_BROKEN)
.addModule(ExtinguishCampfireModule.INSTANCE)
.addModule(ToolActionTransformModule.builder(ToolActions.SHOVEL_FLATTEN, SoundEvents.SHOVEL_FLATTEN).requireGround().build());
buildModifier(ModifierIds.stripping)
.addModule(ShowOffhandModule.DISALLOW_BROKEN)
.addModule(ToolActionTransformModule.builder(ToolActions.AXE_STRIP, SoundEvents.AXE_STRIP).build())
.addModule(ToolActionTransformModule.builder(ToolActions.AXE_SCRAPE, SoundEvents.AXE_SCRAPE).eventId(3005).build())
.addModule(ToolActionTransformModule.builder(ToolActions.AXE_WAX_OFF, SoundEvents.AXE_WAX_OFF).eventId(3004).build());
buildModifier(ModifierIds.tilling)
.addModule(ShowOffhandModule.DISALLOW_BROKEN)
.addModule(ToolActionTransformModule.builder(ToolActions.HOE_TILL, SoundEvents.HOE_TILL).build());
// internal
buildModifier(ModifierIds.overslimeFriend).tooltipDisplay(TooltipDisplay.NEVER);
buildModifier(ModifierIds.snowBoots).addModule(new VolatileFlagModule(ModifiableArmorItem.SNOW_BOOTS)).tooltipDisplay(TooltipDisplay.NEVER);
// traits - tier 1
buildModifier(ModifierIds.cultivated).addModule(RepairModule.builder().eachLevel(0.5f));
addModifier(ModifierIds.stringy, new Modifier());
buildModifier(ModifierIds.flexible).addModule(StatBoostModule.add(ToolStats.VELOCITY).eachLevel(0.1f))
.addModule(StatBoostModule.multiplyAll(ToolStats.PROJECTILE_DAMAGE).eachLevel(-0.1f));
// traits - tier 2
buildModifier(ModifierIds.sturdy).addModule(StatBoostModule.multiplyBase(ToolStats.DURABILITY).eachLevel(0.15f));
buildModifier(ModifierIds.scorching).addModule(ConditionalMeleeDamageModule.builder().target(LivingEntityPredicate.ON_FIRE).eachLevel(2f));
buildModifier(ModifierIds.airborne)
// 400% boost means 5x mining speed
.addModule(ConditionalMiningSpeedModule.builder().holder(LivingEntityPredicate.ON_GROUND.inverted()).percent().allowIneffective().flat(4), ModifierHooks.BREAK_SPEED)
// accuracy gets a 0.5 boost under the stricter version of in air (no boost just for being on a ladder)
.addModule(ConditionalStatModule.stat(ToolStats.ACCURACY).holder(TinkerPredicate.AIRBORNE).flat(0.5f));
buildModifier(ModifierIds.antitoxin)
.addModule(ConditionalMeleeDamageModule.builder()
.customVariable("poison", new EntityMeleeVariable(new EntityEffectLevelVariable(MobEffects.POISON), WhichEntity.ATTACKER, 0))
.formula()
// gives 1.5 bonus per level at poison 1, 2.5 at poison 2
.customVariable("poison").constant(0.5f).add().variable(LEVEL).multiply().variable(MULTIPLIER).multiply()
// finally, add in base damage
.variable(VALUE).add().build())
.addModule(ConditionalStatModule.stat(ToolStats.DRAW_SPEED)
.customVariable("poison", new EntityConditionalStatVariable(new EntityEffectLevelVariable(MobEffects.POISON), 0))
.formula()
// gives 0.15 bonus per level at poison 1, .25 at poison 2
.customVariable("poison").constant(0.5f).add().constant(0.1f).multiply().variable(LEVEL).multiply().variable(MULTIPLIER).multiply()
// finally, add in base damage
.variable(VALUE).add().build());
buildModifier(ModifierIds.raging)
.addModule(ConditionalMeleeDamageModule.builder()
.customVariable("health", new EntityMeleeVariable(EntityVariable.HEALTH, WhichEntity.ATTACKER, 0))
.customVariable("max_health", new EntityMeleeVariable(new AttributeEntityVariable(Attributes.MAX_HEALTH), WhichEntity.ATTACKER, 20))
.formula()
.customVariable("health")
// add (10 - max_health) to health, at minimum 0, to account for low max health
.constant(10).customVariable("max_health").subtract().nonNegative().add()
// linear bonus from 2 to 8, max bonus below 2, no bonus above 8
.constant(10).subtractFlipped().constant(8).divide().percentClamp()
// get 3 bonus per level, bring in standard multiplier
.variable(LEVEL).multiply().constant(3).multiply().variable(MULTIPLIER).multiply()
// finally, add in base damage
.variable(VALUE).add().build())
.addModule(ConditionalStatModule.stat(ToolStats.DRAW_SPEED)
.customVariable("health", new EntityConditionalStatVariable(EntityVariable.HEALTH, 0))
.customVariable("max", new EntityConditionalStatVariable(new AttributeEntityVariable(Attributes.MAX_HEALTH), 20))
.formula()
.customVariable("health")
// add (10 - max_health) to health, at minimum 0, to account for low max health
.constant(10).customVariable("max").subtract().nonNegative().add()
// linear bonus from 2 to 8, max bonus below 2, no bonus above 8
.constant(10).subtractFlipped().constant(8).divide().percentClamp()
// get 0.25 bonus per level, bring in standard multiplier
.variable(LEVEL).multiply().constant(0.25f).multiply().variable(MULTIPLIER).multiply()
// finally, add in base damage
.variable(VALUE).add().build());
// traits - tier 2 compat
addModifier(ModifierIds.lustrous, new Modifier());
buildModifier(ModifierIds.sharpweight)
.addModule(StatBoostModule.multiplyBase(ToolStats.MINING_SPEED).eachLevel(0.1f))
.addModule(StatBoostModule.multiplyBase(ToolStats.DRAW_SPEED).eachLevel(0.15f))
.addModule(AttributeModule.builder(Attributes.MOVEMENT_SPEED, Operation.MULTIPLY_BASE).uniqueFrom(ModifierIds.sharpweight).slots(handSlots).eachLevel(-0.1f));
buildModifier(ModifierIds.heavy)
.addModule(StatBoostModule.multiplyBase(ToolStats.ATTACK_DAMAGE).eachLevel(0.1f))
.addModule(StatBoostModule.multiplyBase(ToolStats.PROJECTILE_DAMAGE).eachLevel(0.1f))
.addModule(AttributeModule.builder(Attributes.MOVEMENT_SPEED, Operation.MULTIPLY_BASE).uniqueFrom(ModifierIds.heavy).slots(handSlots).eachLevel(-0.1f));
buildModifier(ModifierIds.featherweight)
.addModule(StatBoostModule.multiplyBase(ToolStats.DRAW_SPEED).eachLevel(0.07f))
.addModule(StatBoostModule.multiplyBase(ToolStats.ACCURACY).eachLevel(0.07f));
buildModifier(ModifierIds.dense)
// from 0 to 5, repair formula is FACTOR * (1 - 0.025 * LEVEL * (11 - LEVEL))
.addModule(RepairModule.builder().maxLevel(5).formula()
.variable(FACTOR)
.constant(1)
.constant(0.025f).variable(LEVEL).multiply()
.constant(11).variable(LEVEL).subtract()
.multiply()
.subtract()
.multiply().build())
// at 6+, repair formula is FACTOR * (0.5 - LEVEL * 0.05), simple formula supports below
.addModule(RepairModule.builder().minLevel(6).amount(-0.5f, -0.05f))
// durability formula is 1 - 1/(1.5^LEVEL)
.addModule(ReduceToolDamageModule.builder().formula()
.constant(1)
.constant(1)
.constant(1.5f).variable(LEVEL).power()
.divide()
.subtract().build());
// traits - tier 3
buildModifier(ModifierIds.overcast)
.addModule(StatBoostModule.add(OverslimeModifier.OVERSLIME_STAT).eachLevel(25))
.addModule(StatBoostModule.multiplyBase(OverslimeModifier.OVERSLIME_STAT).eachLevel(0.5f));
buildModifier(ModifierIds.crumbling).addModule(ConditionalMiningSpeedModule.builder().blocks(BlockPredicate.REQUIRES_TOOL.inverted()).allowIneffective().eachLevel(0.5f));
buildModifier(ModifierIds.enhanced).priority(60).addModule(UPGRADE);
// traits - tier 3 nether
buildModifier(ModifierIds.lightweight)
.addModule(StatBoostModule.multiplyBase(ToolStats.ATTACK_SPEED).eachLevel(0.07f))
.addModule(StatBoostModule.multiplyBase(ToolStats.MINING_SPEED).eachLevel(0.07f))
.addModule(StatBoostModule.multiplyBase(ToolStats.DRAW_SPEED).eachLevel(0.03f))
.addModule(StatBoostModule.multiplyBase(ToolStats.VELOCITY).eachLevel(0.03f));
// traits - tier 3 compat
buildModifier(ModifierIds.ductile)
.addModule(StatBoostModule.multiplyBase(ToolStats.DURABILITY).eachLevel(0.04f))
.addModule(StatBoostModule.multiplyBase(ToolStats.ATTACK_DAMAGE).eachLevel(0.04f))
.addModule(StatBoostModule.multiplyBase(ToolStats.MINING_SPEED).eachLevel(0.04f))
.addModule(StatBoostModule.multiplyBase(ToolStats.VELOCITY).eachLevel(0.03f))
.addModule(StatBoostModule.multiplyBase(ToolStats.PROJECTILE_DAMAGE).eachLevel(0.03f));
buildModifier(ModifierIds.maintained)
.addModule(ConditionalMiningSpeedModule.builder()
.customVariable("durability", ToolVariable.CURRENT_DURABILITY)
.customVariable("max_durability", new ToolStatVariable(ToolStats.DURABILITY))
.formula()
.customVariable("max_durability").constant(0.5f).multiply().duplicate()
.customVariable("durability").subtractFlipped()
.nonNegative().divideFlipped()
.variable(LEVEL).multiply()
.constant(6).multiply()
.variable(MULTIPLIER).multiply()
.variable(VALUE).add().build())
.addModule(ConditionalStatModule.stat(ToolStats.VELOCITY)
.customVariable("durability", ToolVariable.CURRENT_DURABILITY)
.customVariable("max_durability", new ToolStatVariable(ToolStats.DURABILITY))
.formula()
.customVariable("max_durability").constant(0.5f).multiply().duplicate()
.customVariable("durability").subtractFlipped()
.nonNegative().divideFlipped()
.variable(LEVEL).multiply()
.constant(0.05f).multiply()
.variable(MULTIPLIER).multiply()
.variable(VALUE).add().build());
// mob disguise
buildModifier(ModifierIds.creeperDisguise ).addModule(new MobDisguiseModule(EntityType.CREEPER));
buildModifier(ModifierIds.endermanDisguise ).addModule(new MobDisguiseModule(EntityType.ENDERMAN));
buildModifier(ModifierIds.skeletonDisguise ).addModule(new MobDisguiseModule(EntityType.SKELETON));
buildModifier(ModifierIds.strayDisguise ).addModule(new MobDisguiseModule(EntityType.STRAY));
buildModifier(ModifierIds.witherSkeletonDisguise ).addModule(new MobDisguiseModule(EntityType.WITHER_SKELETON));
buildModifier(ModifierIds.spiderDisguise ).addModule(new MobDisguiseModule(EntityType.SPIDER));
buildModifier(ModifierIds.caveSpiderDisguise ).addModule(new MobDisguiseModule(EntityType.CAVE_SPIDER));
buildModifier(ModifierIds.zombieDisguise ).addModule(new MobDisguiseModule(EntityType.ZOMBIE));
buildModifier(ModifierIds.huskDisguise ).addModule(new MobDisguiseModule(EntityType.HUSK));
buildModifier(ModifierIds.drownedDisguise ).addModule(new MobDisguiseModule(EntityType.DROWNED));
buildModifier(ModifierIds.blazeDisguise ).addModule(new MobDisguiseModule(EntityType.BLAZE));
buildModifier(ModifierIds.piglinDisguise ).addModule(new MobDisguiseModule(EntityType.PIGLIN));
buildModifier(ModifierIds.piglinBruteDisguise ).addModule(new MobDisguiseModule(EntityType.PIGLIN_BRUTE));
buildModifier(ModifierIds.zombifiedPiglinDisguise).addModule(new MobDisguiseModule(EntityType.ZOMBIFIED_PIGLIN));
}
@Override
public String getName() {
return "Tinkers' Construct Modifiers";
}
/** Short helper to get a modifier ID */
private static ModifierId id(String name) {
return new ModifierId(TConstruct.MOD_ID, name);
}
}