feat(D-01): implement ResistanceComponent, improve stack-aware resistance lookup
This commit is contained in:
@@ -2,11 +2,31 @@ package com.tiedup.remake.v2.bondage.component;
|
|||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component: struggle resistance for data-driven items.
|
||||||
|
*
|
||||||
|
* JSON config: {@code "resistance": {"base": 150}}
|
||||||
|
*/
|
||||||
public class ResistanceComponent implements IItemComponent {
|
public class ResistanceComponent implements IItemComponent {
|
||||||
|
|
||||||
private ResistanceComponent() {}
|
private final int baseResistance;
|
||||||
|
|
||||||
|
private ResistanceComponent(int baseResistance) {
|
||||||
|
this.baseResistance = baseResistance;
|
||||||
|
}
|
||||||
|
|
||||||
public static IItemComponent fromJson(JsonObject config) {
|
public static IItemComponent fromJson(JsonObject config) {
|
||||||
return new ResistanceComponent();
|
int base = 100;
|
||||||
|
if (config != null && config.has("base")) {
|
||||||
|
base = config.get("base").getAsInt();
|
||||||
|
}
|
||||||
|
return new ResistanceComponent(base);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the base resistance for this item.
|
||||||
|
*/
|
||||||
|
public int getBaseResistance() {
|
||||||
|
return baseResistance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.tiedup.remake.v2.bondage.capability.V2EquipmentHelper;
|
|||||||
import com.tiedup.remake.v2.bondage.component.ComponentHolder;
|
import com.tiedup.remake.v2.bondage.component.ComponentHolder;
|
||||||
import com.tiedup.remake.v2.bondage.component.ComponentType;
|
import com.tiedup.remake.v2.bondage.component.ComponentType;
|
||||||
import com.tiedup.remake.v2.bondage.component.IItemComponent;
|
import com.tiedup.remake.v2.bondage.component.IItemComponent;
|
||||||
|
import com.tiedup.remake.v2.bondage.component.ResistanceComponent;
|
||||||
import com.tiedup.remake.v2.bondage.items.AbstractV2BondageItem;
|
import com.tiedup.remake.v2.bondage.items.AbstractV2BondageItem;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -150,6 +151,21 @@ public class DataDrivenBondageItem extends AbstractV2BondageItem {
|
|||||||
.entrySet()) {
|
.entrySet()) {
|
||||||
ItemStack stack = entry.getValue();
|
ItemStack stack = entry.getValue();
|
||||||
if (stack.getItem() == this) {
|
if (stack.getItem() == this) {
|
||||||
|
// Try component first (stack-aware, fixes I-03)
|
||||||
|
ResistanceComponent comp = DataDrivenBondageItem
|
||||||
|
.getComponent(
|
||||||
|
stack,
|
||||||
|
ComponentType.RESISTANCE,
|
||||||
|
ResistanceComponent.class
|
||||||
|
);
|
||||||
|
if (comp != null) {
|
||||||
|
maxDifficulty = Math.max(
|
||||||
|
maxDifficulty,
|
||||||
|
comp.getBaseResistance()
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Fallback: read from definition directly
|
||||||
DataDrivenItemDefinition def =
|
DataDrivenItemDefinition def =
|
||||||
DataDrivenItemRegistry.get(stack);
|
DataDrivenItemRegistry.get(stack);
|
||||||
if (def != null) {
|
if (def != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user