-
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.
Make fiery and freezing more applicable
Fiery now works on counterattack as a new armor modifier Freezing now works on melee and counterattack, replacing sticky Sticky will be fully migrated in a later commit once I decide what I want to do with mattocks and pickadze traits
- Loading branch information
1 parent
99f9f8f
commit 5b495bc
Showing
8 changed files
with
113 additions
and
50 deletions.
There are no files selected for viewing
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
17 changes: 14 additions & 3 deletions
17
...generated/resources/data/tconstruct/recipes/tools/modifiers/salvage/upgrade/freezing.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
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
28 changes: 0 additions & 28 deletions
28
src/generated/resources/data/tconstruct/recipes/tools/modifiers/upgrade/sticky.json
This file was deleted.
Oops, something went wrong.
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
48 changes: 42 additions & 6 deletions
48
src/main/java/slimeknights/tconstruct/tools/modifiers/upgrades/ranged/FreezingModifier.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 |
---|---|---|
@@ -1,31 +1,67 @@ | ||
package slimeknights.tconstruct.tools.modifiers.upgrades.ranged; | ||
|
||
import net.minecraft.world.damagesource.DamageSource; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.EquipmentSlot; | ||
import net.minecraft.world.entity.EquipmentSlot.Type; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.projectile.Projectile; | ||
import net.minecraft.world.phys.EntityHitResult; | ||
import slimeknights.tconstruct.library.modifiers.Modifier; | ||
import slimeknights.tconstruct.library.modifiers.ModifierEntry; | ||
import slimeknights.tconstruct.library.modifiers.TinkerHooks; | ||
import slimeknights.tconstruct.library.modifiers.hook.ProjectileHitModifierHook; | ||
import slimeknights.tconstruct.library.modifiers.hook.combat.DamageTakenModifierHook; | ||
import slimeknights.tconstruct.library.modifiers.hook.combat.MeleeHitModifierHook; | ||
import slimeknights.tconstruct.library.modifiers.util.ModifierHookMap.Builder; | ||
import slimeknights.tconstruct.library.tools.context.EquipmentContext; | ||
import slimeknights.tconstruct.library.tools.context.ToolAttackContext; | ||
import slimeknights.tconstruct.library.tools.helper.ToolDamageUtil; | ||
import slimeknights.tconstruct.library.tools.nbt.IToolStackView; | ||
import slimeknights.tconstruct.library.tools.nbt.ModifierNBT; | ||
import slimeknights.tconstruct.library.tools.nbt.NamespacedNBT; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public class FreezingModifier extends Modifier implements ProjectileHitModifierHook { | ||
public class FreezingModifier extends Modifier implements ProjectileHitModifierHook, MeleeHitModifierHook, DamageTakenModifierHook { | ||
@Override | ||
protected void registerHooks(Builder hookBuilder) { | ||
hookBuilder.addHook(this, TinkerHooks.PROJECTILE_HIT); | ||
hookBuilder.addHook(this, TinkerHooks.MELEE_HIT, TinkerHooks.PROJECTILE_HIT, TinkerHooks.DAMAGE_TAKEN); | ||
} | ||
@Override | ||
public boolean onProjectileHitEntity(ModifierNBT modifiers, NamespacedNBT persistentData, ModifierEntry modifier, Projectile projectile, EntityHitResult hit, @Nullable LivingEntity attacker, @Nullable LivingEntity target) { | ||
|
||
/** Freezes the entity */ | ||
private void apply(int level, @Nullable Entity target) { | ||
if (target != null && target.canFreeze()) { | ||
// freeze them | ||
int level = modifier.getLevel(); | ||
target.setTicksFrozen(Math.max(target.getTicksRequiredToFreeze(), target.getTicksFrozen()) + (level + 1) * 80); | ||
target.setRemainingFireTicks(0); | ||
} | ||
} | ||
|
||
@Override | ||
public void afterMeleeHit(IToolStackView tool, ModifierEntry modifier, ToolAttackContext context, float damageDealt) { | ||
apply(modifier.getLevel(), context.getLivingTarget()); | ||
} | ||
|
||
@Override | ||
public boolean onProjectileHitEntity(ModifierNBT modifiers, NamespacedNBT persistentData, ModifierEntry modifier, Projectile projectile, EntityHitResult hit, @Nullable LivingEntity attacker, @Nullable LivingEntity target) { | ||
apply(modifier.getLevel(), target); | ||
return false; | ||
} | ||
|
||
@Override | ||
public void onDamageTaken(IToolStackView tool, ModifierEntry modifier, EquipmentContext context, EquipmentSlot slotType, DamageSource source, float amount, boolean isDirectDamage) { | ||
// this works like vanilla, damage is capped due to the hurt immunity mechanics, so if multiple pieces apply thorns between us and vanilla, damage is capped at 4 | ||
Entity attacker = source.getEntity(); | ||
if (isDirectDamage && attacker != null && attacker.canFreeze()) { | ||
// 15% chance of working per level, doubled bonus on shields | ||
int level = modifier.getLevel(); | ||
if (slotType.getType() == Type.HAND) { | ||
level *= 2; | ||
} | ||
if (RANDOM.nextFloat() < (level * 0.15f)) { | ||
apply(level, attacker); | ||
ToolDamageUtil.damageAnimated(tool, 1, context.getEntity(), slotType); | ||
} | ||
} | ||
} | ||
} |