feature/d01-branch-a-bridge #6

Merged
NotEvil merged 11 commits from feature/d01-branch-a-bridge into develop 2026-04-14 15:19:21 +00:00
2 changed files with 36 additions and 18 deletions
Showing only changes of commit a75b89929f - Show all commits

View File

@@ -320,10 +320,12 @@ public class PlayerEquipment {
player, player,
BodyRegionV2.ARMS BodyRegionV2.ARMS
); );
if ( if (stack.isEmpty()) return 0;
stack.isEmpty() || !(stack.getItem() instanceof ItemBind bind) // V1 and V2 both implement IHasResistance
) return 0; if (stack.getItem() instanceof com.tiedup.remake.items.base.IHasResistance resistance) {
return bind.getCurrentResistance(stack, player); return resistance.getCurrentResistance(stack, player);
}
return 0;
} }
/** /**
@@ -334,10 +336,11 @@ public class PlayerEquipment {
player, player,
BodyRegionV2.ARMS BodyRegionV2.ARMS
); );
if ( if (stack.isEmpty()) return;
stack.isEmpty() || !(stack.getItem() instanceof ItemBind bind) // V1 and V2 both implement IHasResistance
) return; if (stack.getItem() instanceof com.tiedup.remake.items.base.IHasResistance resistanceItem) {
bind.setCurrentResistance(stack, resistance); resistanceItem.setCurrentResistance(stack, resistance);
}
} }
/** /**
@@ -348,10 +351,12 @@ public class PlayerEquipment {
player, player,
BodyRegionV2.NECK BodyRegionV2.NECK
); );
if ( if (stack.isEmpty()) return 0;
stack.isEmpty() || !(stack.getItem() instanceof ItemCollar collar) // V1 and V2 both implement IHasResistance
) return 0; if (stack.getItem() instanceof com.tiedup.remake.items.base.IHasResistance resistance) {
return collar.getCurrentResistance(stack, player); return resistance.getCurrentResistance(stack, player);
}
return 0;
} }
/** /**
@@ -362,10 +367,11 @@ public class PlayerEquipment {
player, player,
BodyRegionV2.NECK BodyRegionV2.NECK
); );
if ( if (stack.isEmpty()) return;
stack.isEmpty() || !(stack.getItem() instanceof ItemCollar collar) // V1 and V2 both implement IHasResistance
) return; if (stack.getItem() instanceof com.tiedup.remake.items.base.IHasResistance resistanceItem) {
collar.setCurrentResistance(stack, resistance); resistanceItem.setCurrentResistance(stack, resistance);
}
} }
// ========== Helper Methods ========== // ========== Helper Methods ==========

View File

@@ -9,6 +9,9 @@ import com.tiedup.remake.state.PlayerBindState;
import com.tiedup.remake.v2.BodyRegionV2; import com.tiedup.remake.v2.BodyRegionV2;
import com.tiedup.remake.v2.bondage.CollarHelper; import com.tiedup.remake.v2.bondage.CollarHelper;
import com.tiedup.remake.v2.bondage.capability.V2EquipmentHelper; import com.tiedup.remake.v2.bondage.capability.V2EquipmentHelper;
import com.tiedup.remake.v2.bondage.component.ComponentType;
import com.tiedup.remake.v2.bondage.component.ResistanceComponent;
import com.tiedup.remake.v2.bondage.datadriven.DataDrivenBondageItem;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@@ -227,9 +230,18 @@ public class StruggleCollar extends StruggleState {
return; return;
} }
// Get resistance (V1 and V2 via IHasResistance) // Get resistance — V2: read ResistanceComponent directly (avoids MAX-scan bug),
// V1: use IHasResistance.getBaseResistance()
if (!(collar.getItem() instanceof IHasResistance resistanceItem)) return; if (!(collar.getItem() instanceof IHasResistance resistanceItem)) return;
int baseResistance = resistanceItem.getBaseResistance(target); int baseResistance;
ResistanceComponent comp = DataDrivenBondageItem.getComponent(
collar, ComponentType.RESISTANCE, ResistanceComponent.class
);
if (comp != null) {
baseResistance = comp.getBaseResistance();
} else {
baseResistance = resistanceItem.getBaseResistance(target);
}
int currentResistance = resistanceItem.getCurrentResistance(collar, target); int currentResistance = resistanceItem.getCurrentResistance(collar, target);
// Only tighten if current resistance is lower than base // Only tighten if current resistance is lower than base