fix(D-01/A): V2 bind/collar resistance completely broken (CRITICAL)
PlayerEquipment.getCurrentBindResistance/setCurrentBindResistance and getCurrentCollarResistance/setCurrentCollarResistance all checked instanceof ItemBind/ItemCollar — V2 DataDrivenBondageItem silently returned 0, making V2 items escapable in 1 struggle roll. Fix: use instanceof IHasResistance which both V1 and V2 implement. Also fix StruggleCollar.tighten() to read ResistanceComponent directly for V2 collars instead of IHasResistance.getBaseResistance(entity) which triggers the singleton MAX-scan across all equipped items. Note: isItemLocked() dead code in StruggleState is a PRE-EXISTING bug (x10 locked penalty never applied) — tracked for separate fix.
This commit is contained in:
@@ -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 ==========
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user