{"id":22160201,"url":"https://github.com/nico44yt/liby","last_synced_at":"2026-04-25T11:34:33.606Z","repository":{"id":265559283,"uuid":"867826037","full_name":"Nico44YT/Liby","owner":"Nico44YT","description":"Registration and MultiBlock Library","archived":false,"fork":false,"pushed_at":"2025-03-21T15:35:17.000Z","size":1401,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"fabric-1.21.1","last_synced_at":"2025-03-21T16:42:32.148Z","etag":null,"topics":["fabricmc","library"],"latest_commit_sha":null,"homepage":"https://modrinth.com/mod/liby","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nico44YT.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-04T19:51:27.000Z","updated_at":"2025-03-21T15:35:21.000Z","dependencies_parsed_at":"2024-12-22T22:21:04.893Z","dependency_job_id":"4060193f-59ba-4c7d-b2d2-7267746d7e6d","html_url":"https://github.com/Nico44YT/Liby","commit_stats":{"total_commits":24,"total_committers":1,"mean_commits":24.0,"dds":0.0,"last_synced_commit":"6979ea3ab135776edef95a5dfe6292d8f8c703ff"},"previous_names":["nico44yt/liby"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nico44YT%2FLiby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nico44YT%2FLiby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nico44YT%2FLiby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nico44YT%2FLiby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nico44YT","download_url":"https://codeload.github.com/Nico44YT/Liby/tar.gz/refs/heads/fabric-1.21.1","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245294718,"owners_count":20591909,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fabricmc","library"],"created_at":"2024-12-02T04:06:44.378Z","updated_at":"2026-04-25T11:34:33.542Z","avatar_url":"https://github.com/Nico44YT.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## How to Add Liby to Your Project\n\n**Step 1: Add the CurseMaven Repository**\nTo download Liby from CurseMaven, you first need to add the repository to your ```build.gradle``` file:\n```gradle\nrepositories {\n    maven {\n        url \"https://cursemaven.com\"\n    }\n}\n```\n**Step 2: Add the Liby Dependency**\n1. Find the Correct Maven Snippet:\n- Go to the [CurseForge project page](https://www.curseforge.com/minecraft/mc-mods/liby) for Liby.\n- Navigate to the Files section and find the version compatible with your Minecraft setup.\n- Expand the Curse Maven Snippet for the version you need.\n- Copy the provided Maven snippet.\n\n2. Add the Dependency:\n- After copying the snippet, add it to the dependencies block in your build.gradle. Here’s an example:\n```gradle\ndependencies {\n    // Add the Liby dependency using the Maven snippet\n    modImplementation \"curse.maven:liby-1115157:5783866\"\n\n    // Liby dependency\n    implementation \"org.reflections:reflections:0.10.2\"\n}\n\n```\n\n\n\n\n## How to Use Liby\n\nTo utilize the Liby library for registering your mod's elements, follow these steps:\n\nDefine the Package for Registries: Start by specifying the package where Liby will search for your registries.\n\n\n```java\npackage group.your_fabric_mod;\n\nimport net.fabricmc.api.ModInitializer;\nimport nazario.liby.registry.auto.LibyRegistryLoader;\nimport net.minecraft.util.Identifier;\n\npublic class YourFabricMod implements ModInitializer {\n\n    public static final String MOD_ID = \"your_fabric_mod\";\n\n    @Override\n    public void onInitialize() {\n        LibyRegistryLoader.load(\"group.your_fabric_mod.registry\");\n    }\n\n    public static Identifier id(String name) {\n        return Identifier.of(MOD_ID, name);\n    }\n}\n\n```\n\n**Set Up Your Registry: Next, create a registry for blocks.**\n\n\n```java\npackage group.your_fabric_mod.registry;\n\n//This tells Liby to register this class\n@LibyAutoRegister\npublic class BlockRegistry {\n    public static final LibyBlockRegister REGISTER = new LibyBlockRegister(YourFabricMod.MOD_ID);\n\n    public static Block BASIC_BLOCK = REGISTER.registerBlock(\"basic_block\", new Block(AbstractBlock.Settings.create()));\n    public static Block BLOCK_WITH_ITEM = REGISTER.registerBlock(\"block_with_item\", new Block(AbstractBlock.Settings.create()), new Item.Settings());\n\n    public static void register() {\n     \n    }\n}\n```\n**Registering Items: Register items similarly to blocks.**\n```java\npackage group.your_fabric_mod.registry;\n\n@LibyAutoRegister\npublic class ItemRegistry {\n    public static final LibyItemRegister REGISTER = new LibyItemRegister(YourFabricMod.MOD_ID);\n\n    public static Item BASIC_ITEM = REGISTER.registerItem(\"basic_item\", new Item(new Item.Settings()));\n\n    public static void register() {\n    \n    }\n}\n```\n\n\n**Setting Registration Priority: If you want blocks to register before items, adjust the ```@LibyAutoRegister``` annotation as follows:**\n```java\n@LibyAutoRegister(priority = 1)\n```\nHigher priority values ensure that items are registered after blocks.\n\n\n**Handling Item Groups: Liby has a specific way for managing item groups.**\n```java\n@LibyAutoRegister(priority = 2)\npublic class ItemGroupRegistry {\n\n    public static final LibyItemGroupRegister REGISTER = new LibyItemGroupRegister(ResearchFrontiers.MOD_ID);\n\n    public static final LibyItemGroup ITEM_GROUP = new LibyItemGroup(\"group\", Text.translatable(\"your_fabric_mod.itemGroup\"), new ItemStack(ItemRegistry.BASIC_ITEM));\n\n\n   public static void register() {\n       ITEM_GROUP.addItem(ItemRegistry.BASIC_ITEM, BlockRegistry.BLOCK_WITH_ITEM);\n\n       REGISTER.registerItemGroups(ITEM_GROUP);\n   }\n}\n```\n\nSince the item group has an icon, ensure items are registered first by setting the priority of ```ItemGroupRegistry``` to 2.\n\n\n\n### Additional Information on Registration\n\nIf you prefer not to name each registration method register, you can specify a custom method name directly in the ```@LibyAutoRegister``` annotation. This allows for more descriptive method names that can enhance code readability and organization.\n```java\n@LibyAutoRegister(priority = 2, register = \"registerItemGroup\")\npublic class ItemGroupRegistry {\n    public static void registerItemGroup() {\n        // Registration logic for item groups\n    }\n}\n\n```\n\nIf you prefer to keep all your registrations within your registry package, and you also want to handle client-side registration there, you need to include a ```LibyEntrypoint``` in the ```@LibyAutoRegister``` annotation.\n(The default Entrypoint is ```MAIN```)\n```java\n@LibyAutoRegister(priority = 0, entrypoint = LibyEntrypoints.CLIENT)\npublic class ClientRegistry {\n    public static void register() {\n        \n    }\n}\n```\n\n\n\n### Creating Multiblocks with Liby\n\nLiby provides a simple way for creating multiblocks. To get started, you need to define a BlockEntityRegistry.\n\n**Step 1: Define the Block Entity Registry**\n\nCreate a class for your block entities and use the ```@LibyAutoRegister``` annotation to register it.\n```java\n@LibyAutoRegister(priority = 3)\npublic class BlockEntityRegistry {\n    public static final LibyBlockEntityRegister REGISTER = new LibyBlockEntityRegister(ResearchFrontiers.MOD_ID);\n\n    public static BlockEntityType\u003cWorkbenchBlockEntity\u003e WORKBENCH_BLOCK_ENTITY = \n        REGISTER.registerType(\"workbench\", BlockEntityType.Builder.create(WorkbenchBlockEntity::new, BlockRegistry.WORKBENCH).build());\n\n    public static void register() {\n        // Additional registration logic can be added here\n    }\n}\n```\n**Step 2: Create the Workbench Block**\n\nDefine the ```WorkbenchBlock``` class, which extends ```LibyMultiBlock```. Here, you initialize an array of BlockPos to define the positions that make up the multiblock structure.\n(Due to minecraft limitations on block model sizes 3x3x3, you should consider using GeckoLib for the model)\n```java\npublic class WorkbenchBlock extends LibyMultiBlock {\n    public WorkbenchBlock(Settings settings) {\n        super(settings, new BlockPos[]{\n            new BlockPos(0, 0, 0), // Parent block position\n            new BlockPos(-1, 0, 0)  // Child block position\n        });\n    }\n\n    @Override\n    protected MapCodec\u003c? extends BlockWithEntity\u003e getCodec() {\n        return createCodec(WorkbenchBlock::new);\n    }\n\n    @Override\n    public @Nullable BlockEntity createBlockEntity(BlockPos pos, BlockState state) {\n        return new WorkbenchBlockEntity(pos, state);\n    }\n}\n```\n\n**Step 3: Create the Workbench Block Entity**\n\nNext, implement the ```WorkbenchBlockEntity``` class, which extends ```LibyMultiBlockEntity```. This class represents the block entity associated with the ```WorkbenchBlock```.\n```java\npublic class WorkbenchBlockEntity extends LibyMultiBlockEntity {\n    public WorkbenchBlockEntity(BlockPos pos, BlockState state) {\n        super(BlockEntityRegistry.WORKBENCH, pos, state);\n    }\n}\n```\n**Key Points**\n- In the ```WorkbenchBlock``` class, the BlockPos array specifies the positions of the blocks that make up the multiblock structure. The first entry should always represent the parent block.\n- Multiblock structures are from the start horizontal directional.\n\n**Step 4: Player interactions**\n\nNow we want the player to be able to right click our Workbench, for that you need to override ```onMultiBlockUse```, inside ```WorkbenchBlock```.\n```java\n    @Override\n    public ActionResult onMultiBlockUse(World world, BlockState clickedState, BlockState parentState, BlockPos clickedPos, BlockPos parentPos, PlayerEntity player, BlockHitResult hit) {\n        if(world.isClient) return ActionResult.PASS;\n        \n        player.sendMessage(Text.literal(\"Hello from Workbench!\"));\n        \n        return ActionResult.SUCCESS;\n    }\n```\n\n**Notice**\n\nWhen creating multiblock structures larger than the standard 3x3x3 block model limit in vanilla, you may encounter weird lighting issues. These issues arise because the game’s lighting engine thinks your childs blocks are solid, even tho there are invisible and don't render any model at all. To fix these issues we will tell the game that the childs blocks are transparent like glass, this will stop the light engine from drawing shadows on our model texture.\n\n```java\n    @Override\n    protected int getOpacity(BlockState state, BlockView world, BlockPos pos) {\n        return state.get(PARENT)?super.getOpacity(state, world, pos):0;\n    }\n\n    @Override\n    protected float getAmbientOcclusionLightLevel(BlockState state, BlockView world, BlockPos pos) {\n        return state.get(PARENT)?super.getAmbientOcclusionLightLevel(state, world, pos):1;\n    }\n```\n\n### Networking (Experimental)\n\nIf you have a variable that needs to be synced across all players, Liby provides a simple solution for that.\n\nTo sync a variable over the network, you need to annotate it with ```@LibySyncedValue```. The class inside the parentheses should correspond to the data type of the variable. (Not all variables are supported—generally, all primitive data types are supported, along with ```String```, ```BlockPos```, ```Vec3d```, ```Vec3i```, ```Vec2f```, and ```NbtCompound```.)\n```java\npublic class SyncedBlock extends Block {\n\n    // Annotates the variable to sync its value across the network, specifying Integer as its data type\n    @LibySyncedValue(Integer.class) \n    public int clicksValue;\n\n    public SyncedBlock(Settings settings) {\n        super(settings);\n    }\n\n    // Called when the block is right-clicked by a player\n    @Override\n    protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {\n\n        // Sends a message to the player, showing whether the action occurred on the Client or Server, and displays the current clicksValue\n        player.sendMessage(Text.literal(\"\u003c\" + (world.isClient ? \"Client\" : \"Server\") + \"\u003e Value: \" + clicksValue));\n\n        // Increases the clicksValue by 1 on the server side and syncs the new value across all players\n        if (!world.isClient) {\n            this.clicksValue += 1; // Increment the value\n            LibyNetworker.syncBlock(world, pos, this); // Sync the updated value with all players\n        }\n\n        return super.onUse(state, world, pos, player, hit);\n    }\n}\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnico44yt%2Fliby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnico44yt%2Fliby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnico44yt%2Fliby/lists"}