feature/d01-component-system #5

Merged
NotEvil merged 20 commits from feature/d01-component-system into develop 2026-04-14 00:54:17 +00:00
Showing only changes of commit caeb4469b1 - Show all commits

View File

@@ -1,12 +1,42 @@
package com.tiedup.remake.v2.bondage.component;
import com.google.gson.JsonObject;
import com.tiedup.remake.items.base.ILockable;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
/**
* Component: lockable behavior for data-driven items.
* Delegates lock checks to ILockable on the item.
*
* JSON config:
* {@code "lockable": true} or {@code "lockable": {"lock_resistance": 300}}
*/
public class LockableComponent implements IItemComponent {
private LockableComponent() {}
private final int lockResistance;
private LockableComponent(int lockResistance) {
this.lockResistance = lockResistance;
}
public static IItemComponent fromJson(JsonObject config) {
return new LockableComponent();
int resistance = 250; // default
if (config != null && config.has("lock_resistance")) {
resistance = config.get("lock_resistance").getAsInt();
}
return new LockableComponent(resistance);
}
public int getLockResistance() {
return lockResistance;
}
@Override
public boolean blocksUnequip(ItemStack stack, LivingEntity entity) {
if (stack.getItem() instanceof ILockable lockable) {
return lockable.isLocked(stack);
}
return false;
}
}