feature/d01-component-system #5
@@ -4,6 +4,9 @@ import com.tiedup.remake.v2.BodyRegionV2;
|
|||||||
import com.tiedup.remake.v2.bondage.IV2BondageEquipment;
|
import com.tiedup.remake.v2.bondage.IV2BondageEquipment;
|
||||||
import com.tiedup.remake.v2.bondage.V2BondageItems;
|
import com.tiedup.remake.v2.bondage.V2BondageItems;
|
||||||
import com.tiedup.remake.v2.bondage.capability.V2EquipmentHelper;
|
import com.tiedup.remake.v2.bondage.capability.V2EquipmentHelper;
|
||||||
|
import com.tiedup.remake.v2.bondage.component.ComponentHolder;
|
||||||
|
import com.tiedup.remake.v2.bondage.component.ComponentType;
|
||||||
|
import com.tiedup.remake.v2.bondage.component.IItemComponent;
|
||||||
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;
|
||||||
@@ -257,6 +260,53 @@ public class DataDrivenBondageItem extends AbstractV2BondageItem {
|
|||||||
return Component.literal(def.displayName());
|
return Component.literal(def.displayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===== COMPONENT LIFECYCLE DELEGATION =====
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEquipped(ItemStack stack, LivingEntity entity) {
|
||||||
|
ComponentHolder holder = DataDrivenItemRegistry.getComponents(stack);
|
||||||
|
if (holder != null) {
|
||||||
|
holder.onEquipped(stack, entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUnequipped(ItemStack stack, LivingEntity entity) {
|
||||||
|
ComponentHolder holder = DataDrivenItemRegistry.getComponents(stack);
|
||||||
|
if (holder != null) {
|
||||||
|
holder.onUnequipped(stack, entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUnequip(ItemStack stack, LivingEntity entity) {
|
||||||
|
ComponentHolder holder = DataDrivenItemRegistry.getComponents(stack);
|
||||||
|
if (holder != null && holder.blocksUnequip(stack, entity)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return super.canUnequip(stack, entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a specific component from a data-driven item stack.
|
||||||
|
*
|
||||||
|
* @param stack the ItemStack to inspect
|
||||||
|
* @param type the component type to look up
|
||||||
|
* @param clazz the expected component class
|
||||||
|
* @param <T> the component type
|
||||||
|
* @return the component, or null if the item is not data-driven or lacks this component
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public static <T extends IItemComponent> T getComponent(
|
||||||
|
ItemStack stack,
|
||||||
|
ComponentType type,
|
||||||
|
Class<T> clazz
|
||||||
|
) {
|
||||||
|
ComponentHolder holder = DataDrivenItemRegistry.getComponents(stack);
|
||||||
|
if (holder == null) return null;
|
||||||
|
return holder.get(type, clazz);
|
||||||
|
}
|
||||||
|
|
||||||
// ===== FACTORY =====
|
// ===== FACTORY =====
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user