fix(D-01/A): adversarial review fixes — 4 logic bugs

1. NECK region explicitly blocked in interactLivingEntity() — prevents
   V2 collars equipping without ownership setup (latent, no JSONs yet)

2. Swap rollback safety: if re-equip fails after swap failure, drop the
   old bind as item entity instead of losing it silently

3. GaggingComponent: cache GagMaterial at construction time — eliminates
   valueOf() log spam on every chat message with misconfigured material

4. Dual-bind prevention: check both V1 isTiedUp() AND V2 region occupied
   in TyingInteractionHelper and PacketSelfBondage to prevent equipping
   V2 bind on top of V1 bind
This commit is contained in:
NotEvil
2026-04-14 16:48:50 +02:00
parent b97bdf367e
commit df56ebb6bc
4 changed files with 35 additions and 18 deletions

View File

@@ -23,11 +23,14 @@ import org.jetbrains.annotations.Nullable;
public class GaggingComponent implements IItemComponent {
private final @Nullable String material;
private final @Nullable GagMaterial cachedMaterial;
private final double comprehensionOverride;
private final double rangeOverride;
private GaggingComponent(@Nullable String material, double comprehensionOverride, double rangeOverride) {
private GaggingComponent(@Nullable String material, @Nullable GagMaterial cachedMaterial,
double comprehensionOverride, double rangeOverride) {
this.material = material;
this.cachedMaterial = cachedMaterial;
this.comprehensionOverride = comprehensionOverride;
this.rangeOverride = rangeOverride;
}
@@ -47,7 +50,16 @@ public class GaggingComponent implements IItemComponent {
range = Math.max(0.0, config.get("range").getAsDouble());
}
}
return new GaggingComponent(material, comprehension, range);
// Resolve and cache GagMaterial at load time to avoid valueOf() on every chat message
GagMaterial resolved = null;
if (material != null) {
try {
resolved = GagMaterial.valueOf(material.toUpperCase());
} catch (IllegalArgumentException e) {
TiedUpMod.LOGGER.warn("[GaggingComponent] Unknown gag material '{}' — using defaults", material);
}
}
return new GaggingComponent(material, resolved, comprehension, range);
}
/** How much of the gagged speech is comprehensible (0.0 = nothing, 1.0 = full). */
@@ -66,15 +78,9 @@ public class GaggingComponent implements IItemComponent {
return 10.0;
}
/** The gag material enum, or null if not configured or invalid. */
/** The gag material enum, or null if not configured or invalid. Cached at load time. */
public @Nullable GagMaterial getMaterial() {
if (material == null) return null;
try {
return GagMaterial.valueOf(material.toUpperCase());
} catch (IllegalArgumentException e) {
TiedUpMod.LOGGER.warn("[GaggingComponent] Unknown gag material: {}", material);
return null;
}
return cachedMaterial;
}
/** The raw material string from JSON, or null. */