-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Done via a generic module for granting effect immunity, so you can now make a modifier to make the player immune to any effect you wish easily
- Loading branch information
1 parent
b498ddc
commit 587465c
Showing
8 changed files
with
102 additions
and
37 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
src/generated/resources/data/tconstruct/tinkering/modifiers/mithridatism.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 @@ | ||
{ | ||
"type": "tconstruct:composable", | ||
"level_display": "tconstruct:no_levels", | ||
"modules": [ | ||
{ | ||
"type": "tconstruct:effect_immunity", | ||
"effect": "minecraft:poison" | ||
} | ||
], | ||
"tooltip_display": "always" | ||
} |
68 changes: 68 additions & 0 deletions
68
...in/java/slimeknights/tconstruct/library/modifiers/modules/armor/EffectImmunityModule.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,68 @@ | ||
package slimeknights.tconstruct.library.modifiers.modules.armor; | ||
|
||
import com.google.common.collect.HashMultiset; | ||
import com.google.common.collect.Multiset; | ||
import net.minecraft.world.effect.MobEffect; | ||
import slimeknights.mantle.data.loadable.Loadables; | ||
import slimeknights.mantle.data.loadable.record.RecordLoadable; | ||
import slimeknights.tconstruct.TConstruct; | ||
import slimeknights.tconstruct.common.TinkerTags; | ||
import slimeknights.tconstruct.library.modifiers.ModifierEntry; | ||
import slimeknights.tconstruct.library.modifiers.ModifierHooks; | ||
import slimeknights.tconstruct.library.modifiers.hook.armor.EquipmentChangeModifierHook; | ||
import slimeknights.tconstruct.library.modifiers.modules.ModifierModule; | ||
import slimeknights.tconstruct.library.modifiers.modules.technical.ArmorLevelModule; | ||
import slimeknights.tconstruct.library.modifiers.modules.util.ModifierCondition; | ||
import slimeknights.tconstruct.library.modifiers.modules.util.ModifierCondition.ConditionalModule; | ||
import slimeknights.tconstruct.library.module.HookProvider; | ||
import slimeknights.tconstruct.library.module.ModuleHook; | ||
import slimeknights.tconstruct.library.tools.capability.TinkerDataCapability.ComputableDataKey; | ||
import slimeknights.tconstruct.library.tools.context.EquipmentChangeContext; | ||
import slimeknights.tconstruct.library.tools.nbt.IToolStackView; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Module for armor modifiers that makes the wearer immune to a mob effect | ||
*/ | ||
public record EffectImmunityModule(MobEffect effect, ModifierCondition<IToolStackView> condition) implements ModifierModule, EquipmentChangeModifierHook, ConditionalModule<IToolStackView> { | ||
private static final List<ModuleHook<?>> DEFAULT_HOOKS = HookProvider.<MobDisguiseModule>defaultHooks(ModifierHooks.EQUIPMENT_CHANGE); | ||
public static final ComputableDataKey<Multiset<MobEffect>> EFFECT_IMMUNITY = TConstruct.createKey("effect_immunity", HashMultiset::create); | ||
public static final RecordLoadable<EffectImmunityModule> LOADER = RecordLoadable.create( | ||
Loadables.MOB_EFFECT.requiredField("effect", EffectImmunityModule::effect), | ||
ModifierCondition.TOOL_FIELD, | ||
EffectImmunityModule::new); | ||
|
||
public EffectImmunityModule(MobEffect effect) { | ||
this(effect, ModifierCondition.ANY_TOOL); | ||
} | ||
|
||
@Override | ||
public RecordLoadable<EffectImmunityModule> getLoader() { | ||
return LOADER; | ||
} | ||
|
||
@Override | ||
public List<ModuleHook<?>> getDefaultHooks() { | ||
return DEFAULT_HOOKS; | ||
} | ||
|
||
@Override | ||
public void onEquip(IToolStackView tool, ModifierEntry modifier, EquipmentChangeContext context) { | ||
if (!tool.isBroken() && ArmorLevelModule.validSlot(tool, context.getChangedSlot(), TinkerTags.Items.HELD_ARMOR) && condition.matches(tool, modifier)) { | ||
context.getTinkerData().ifPresent(data -> data.computeIfAbsent(EFFECT_IMMUNITY).add(effect)); | ||
} | ||
} | ||
|
||
@Override | ||
public void onUnequip(IToolStackView tool, ModifierEntry modifier, EquipmentChangeContext context) { | ||
if (!tool.isBroken() && ArmorLevelModule.validSlot(tool, context.getChangedSlot(), TinkerTags.Items.HELD_ARMOR) && condition.matches(tool, modifier)) { | ||
context.getTinkerData().ifPresent(data -> { | ||
Multiset<MobEffect> effects = data.get(EFFECT_IMMUNITY); | ||
if (effects != null) { | ||
effects.remove(effect); | ||
} | ||
}); | ||
} | ||
} | ||
} |
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
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
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
34 changes: 0 additions & 34 deletions
34
src/main/java/slimeknights/tconstruct/tools/modifiers/traits/skull/MithridatismModifier.java
This file was deleted.
Oops, something went wrong.