-
Notifications
You must be signed in to change notification settings - Fork 755
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce shulking modifier, new defense modifier from shulker shells
- Loading branch information
1 parent
4a52a52
commit fd2e480
Showing
15 changed files
with
145 additions
and
5 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/generated/resources/data/tconstruct/recipes/tools/modifiers/defense/shulking.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,18 @@ | ||
{ | ||
"type": "tconstruct:incremental_modifier", | ||
"input": { | ||
"item": "minecraft:shulker_shell" | ||
}, | ||
"amount_per_item": 1, | ||
"needed_per_level": 5, | ||
"tools": { | ||
"tag": "tconstruct:modifiable/armor" | ||
}, | ||
"slots": { | ||
"defense": 1 | ||
}, | ||
"result": { | ||
"name": "tconstruct:shulking", | ||
"level": 1 | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...generated/resources/data/tconstruct/recipes/tools/modifiers/salvage/defense/shulking.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:modifier_salvage", | ||
"tools": { | ||
"tag": "tconstruct:modifiable/armor" | ||
}, | ||
"slots": { | ||
"defense": 1 | ||
}, | ||
"modifier": "tconstruct:shulking", | ||
"min_level": 1 | ||
} |
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 |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
"level": 1 | ||
}, | ||
{ | ||
"name": "tconstruct:protection", | ||
"name": "tconstruct:shulking", | ||
"level": 1 | ||
} | ||
] | ||
|
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
60 changes: 60 additions & 0 deletions
60
src/main/java/slimeknights/tconstruct/tools/modifiers/defense/ShulkingModifier.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,60 @@ | ||
package slimeknights.tconstruct.tools.modifiers.defense; | ||
|
||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.damagesource.DamageSource; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.EquipmentSlot; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.TooltipFlag; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.event.entity.living.LivingHurtEvent; | ||
import net.minecraftforge.eventbus.api.EventPriority; | ||
import slimeknights.tconstruct.TConstruct; | ||
import slimeknights.tconstruct.library.tools.capability.TinkerDataCapability; | ||
import slimeknights.tconstruct.library.tools.capability.TinkerDataCapability.TinkerDataKey; | ||
import slimeknights.tconstruct.library.tools.context.EquipmentContext; | ||
import slimeknights.tconstruct.library.tools.nbt.IToolStackView; | ||
import slimeknights.tconstruct.library.utils.TooltipKey; | ||
import slimeknights.tconstruct.tools.logic.ModifierMaxLevel; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.List; | ||
|
||
public class ShulkingModifier extends AbstractProtectionModifier<ModifierMaxLevel> { | ||
private static final TinkerDataKey<ModifierMaxLevel> KEY = TConstruct.createKey("shulking"); | ||
public ShulkingModifier() { | ||
super(KEY); | ||
MinecraftForge.EVENT_BUS.addListener(EventPriority.NORMAL, false, LivingHurtEvent.class, ShulkingModifier::onAttack); | ||
} | ||
|
||
@Override | ||
protected ModifierMaxLevel createData() { | ||
return new ModifierMaxLevel(); | ||
} | ||
|
||
@Override | ||
public float getProtectionModifier(IToolStackView tool, int level, EquipmentContext context, EquipmentSlot slotType, DamageSource source, float modifierValue) { | ||
if (context.getEntity().isCrouching() && !source.isBypassMagic() && !source.isBypassInvul()) { | ||
modifierValue += getScaledLevel(tool, level) * 1.5; | ||
} | ||
return modifierValue; | ||
} | ||
|
||
@Override | ||
public void addInformation(IToolStackView tool, int level, @Nullable Player player, List<Component> tooltip, TooltipKey tooltipKey, TooltipFlag tooltipFlag) { | ||
AbstractProtectionModifier.addResistanceTooltip(this, tool, level, 1.5f, tooltip); | ||
} | ||
|
||
private static void onAttack(LivingHurtEvent event) { | ||
// if the attacker is crouching, deal less damage | ||
Entity attacker = event.getSource().getEntity(); | ||
if (attacker != null && attacker.isCrouching()) { | ||
attacker.getCapability(TinkerDataCapability.CAPABILITY).ifPresent(data -> { | ||
ModifierMaxLevel max = data.get(KEY); | ||
if (max != null) { | ||
event.setAmount(event.getAmount() * (1 - (max.getMax() * 0.1f))); | ||
} | ||
}); | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -9,6 +9,6 @@ | |
"5 Upgrade Slots", | ||
"0 Defense Slots", | ||
"1 Ability Slot", | ||
"Protection I" | ||
"Shulking I" | ||
] | ||
} |
16 changes: 16 additions & 0 deletions
16
...main/resources/assets/tconstruct/book/encyclopedia/en_us/defense/protection/shulking.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,16 @@ | ||
{ | ||
"modifier_id": "tconstruct:shulking", | ||
"text": [ | ||
{ | ||
"text": "Grants +6% resistance while sneaking. Caps at 80% across the whole set, or 14 levels." | ||
}, | ||
{ | ||
"text": "Decreases attack damage while sneaking by 10% per level of the highest level piece.", "paragraph": true | ||
} | ||
], | ||
"more_text_space": true, | ||
"effects": [ | ||
"Can apply levels incrementally", | ||
"Requires 1 defense slot" | ||
] | ||
} |
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
14 changes: 14 additions & 0 deletions
14
...n/resources/assets/tconstruct/book/mighty_smelting/en_us/defense/protection/shulking.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,14 @@ | ||
{ | ||
"modifier_id": "tconstruct:shulking", | ||
"text": [ | ||
{ | ||
"text": "Home is where the shell is." | ||
} | ||
], | ||
"effects": [ | ||
"Reduces damage given and received while sneaking", | ||
"Multiple levels, each level further increases effect", | ||
"Can apply levels incrementally", | ||
"Requires 1 defense slot" | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,6 @@ | |
"No Armor or Defense Slots", | ||
"5 Upgrade Slots", | ||
"1 Ability Slot", | ||
"Protection" | ||
"Shulking" | ||
] | ||
} |
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