Skip to content

Commit

Permalink
Make spilling and wetting work on shields
Browse files Browse the repository at this point in the history
Works like other counterattack modifiers, when blocking but twice as effective as armor
  • Loading branch information
KnightMiner committed Feb 12, 2023
1 parent 0e5d74d commit 58cf79f
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
},
{
"tag": "tconstruct:modifiable/staffs"
},
{
"tag": "tconstruct:modifiable/shields"
}
],
"slots": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@
"tag": "forge:ingots/copper"
}
],
"tools": {
"tag": "tconstruct:modifiable/armor/leggings"
},
"tools": [
{
"tag": "tconstruct:modifiable/armor/leggings"
},
{
"tag": "tconstruct:modifiable/shields"
}
],
"slots": {
"abilities": 1
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
},
{
"tag": "tconstruct:modifiable/staffs"
},
{
"tag": "tconstruct:modifiable/shields"
}
],
"slots": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"type": "tconstruct:modifier_salvage",
"tools": {
"tag": "tconstruct:modifiable/armor/leggings"
},
"tools": [
{
"tag": "tconstruct:modifiable/armor/leggings"
},
{
"tag": "tconstruct:modifiable/shields"
}
],
"slots": {
"abilities": 1
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
},
{
"tag": "tconstruct:modifiable/armor/leggings"
},
{
"tag": "tconstruct:modifiable/shields"
}
],
"slots": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
},
{
"tag": "tconstruct:modifiable/armor/leggings"
},
{
"tag": "tconstruct:modifiable/shields"
}
],
"slots": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ private void addModifierRecipes(Consumer<FinishedRecipe> consumer) {
.addInput(Tags.Items.INGOTS_COPPER)
.addInput(Tags.Items.INGOTS_COPPER)
.setSlots(SlotType.ABILITY, 1)
.setTools(TinkerTags.Items.LEGGINGS)
.setTools(ingredientFromTags(TinkerTags.Items.LEGGINGS, TinkerTags.Items.SHIELDS))
.saveSalvage(consumer, prefix(TinkerModifiers.wetting, abilitySalvage))
.save(consumer, prefix(TinkerModifiers.wetting, abilityFolder));
// boots
Expand Down Expand Up @@ -1205,13 +1205,13 @@ private void addModifierRecipes(Consumer<FinishedRecipe> consumer) {
.addInput(Tags.Items.INGOTS_COPPER)
.addInput(Tags.Items.INGOTS_COPPER)
.setSlots(SlotType.ABILITY, 1)
.setTools(ingredientFromTags(TinkerTags.Items.MELEE, TinkerTags.Items.CHESTPLATES, TinkerTags.Items.STAFFS))
.setTools(ingredientFromTags(TinkerTags.Items.MELEE, TinkerTags.Items.CHESTPLATES, TinkerTags.Items.STAFFS, TinkerTags.Items.SHIELDS))
.saveSalvage(consumer, prefix(TinkerModifiers.spilling, abilitySalvage))
.save(consumer, prefix(TinkerModifiers.spilling, abilityFolder));
ModifierRecipeBuilder.modifier(TinkerModifiers.tank)
.addInput(TinkerTags.Items.TANKS)
.setSlots(SlotType.UPGRADE, 1)
.setTools(ingredientFromTags(TinkerTags.Items.INTERACTABLE, TinkerTags.Items.HELMETS, TinkerTags.Items.CHESTPLATES, TinkerTags.Items.LEGGINGS))
.setTools(ingredientFromTags(TinkerTags.Items.INTERACTABLE, TinkerTags.Items.HELMETS, TinkerTags.Items.CHESTPLATES, TinkerTags.Items.LEGGINGS, TinkerTags.Items.SHIELDS))
.saveSalvage(consumer, prefix(TinkerModifiers.tank, upgradeSalvage))
.save(consumer, prefix(TinkerModifiers.tank, upgradeFolder));
// expanders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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.player.Player;
import net.minecraftforge.fluids.FluidAttributes;
Expand Down Expand Up @@ -48,8 +49,8 @@ protected boolean doesTrigger(DamageSource source, boolean isDirectDamage) {
public void onAttacked(IToolStackView tool, int level, EquipmentContext context, EquipmentSlot slotType, DamageSource source, float amount, boolean isDirectDamage) {
Entity attacker = source.getEntity();
if (doesTrigger(source, isDirectDamage)) {
// 25% chance of working per level
if (RANDOM.nextInt(4) < level) {
// 25% chance of working per level, 50% per level on shields
if (RANDOM.nextInt(slotType.getType() == Type.HAND ? 2 : 4) < level) {
FluidStack fluid = getFluid(tool);
if (!fluid.isEmpty()) {
LivingEntity self = context.getEntity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ public InteractionResult beforeEntityUse(IToolStackView tool, ModifierEntry modi
int numTargets = 1;
int expanded = tool.getModifierLevel(TinkerModifiers.expanded.get());
if (expanded > 0 && !fluid.isEmpty()) {
int rangeSq = expanded * expanded;
for (Entity aoeTarget : player.level.getEntitiesOfClass(Entity.class, target.getBoundingBox().inflate(expanded, 0.25, expanded))) {
float range = expanded * 1.5f;
float rangeSq = range * range;
for (Entity aoeTarget : player.level.getEntitiesOfClass(Entity.class, target.getBoundingBox().inflate(range, 0.25, range))) {
if (aoeTarget != player && aoeTarget != target && !(aoeTarget instanceof ArmorStand stand && stand.isMarker()) && target.distanceToSqr(aoeTarget) < rangeSq) {
numTargets++;
context = new ToolAttackContext(player, player, hand, aoeTarget, aoeTarget instanceof LivingEntity l ? l : null, false, 1.0f, true);
Expand Down

0 comments on commit 58cf79f

Please sign in to comment.