-
Notifications
You must be signed in to change notification settings - Fork 35
API Documentation v4 Examples
Exopandora edited this page Jun 10, 2026
·
1 revision
public class ExamplePlugin implements IShoulderSurfingPlugin {
@Override
public void register(IShoulderSurfingRegistrar registrar) {
// Register simple ItemStack predicate via helper method
registrar.registerAdaptiveItemCallback(itemStack -> itemStack.is(Items.APPLE));
// Register another one
registrar.registerAdaptiveItemCallback(itemStack -> itemStack.is(Items.GOLDEN_APPLE));
// Use static helper functions to create callback
registrar.registerAdaptiveItemCallback(IAdaptiveItemCallback.anyHandMatches(Items.APPLE));
registrar.registerAdaptiveItemCallback(IAdaptiveItemCallback.mainHandMatches(Items.APPLE));
registrar.registerAdaptiveItemCallback(IAdaptiveItemCallback.offHandMatches(Items.APPLE));
// Register a full callback as inner class
registrar.registerAdaptiveItemCallback(new IAdaptiveItemCallback() {
@Override
public boolean isHoldingAdaptiveItem(Minecraft minecraft, LivingEntity entity) {
for(ItemStack stack : entity.getHandSlots()) {
if(stack.is(Items.APPLE)) {
return true;
}
}
return false;
}
});
// Register a full callback as lambda
registrar.registerAdaptiveItemCallback((minecraft, entity) -> {
for(ItemStack stack : entity.getHandSlots()) {
if(stack.is(Items.APPLE)) {
return true;
}
}
return false;
});
}
}