Git Product home page Git Product logo

cardinal-components-api's Introduction

Cardinal Components 6.0 is out!

See the migration guide for detailed instructions on how to update your mod.

Cardinal Components API

A components API for Quilt and Fabric that is easy, modular, and extremely fast.

Cardinal Components API is a library for Minecraft mods to create data components that can be attached to various providers. Those components provide a standardized interface for mods to interact with otherwise opaque objects and behaviours, thereby helping both mod creation and compatibility. 1

TL;DR: It allows you to attach data to things

An example

Let's say you want to make to add mana to your mod. You would most likely want to have a number stored on the player, which gets saved alongside it. You may want to display a mana bar on the client, which will require synchronization. You may want your mana to refill slowly over time, which will require ticking. And then you may want to have something like mana batteries in the world, which would require re-implementing all that on a custom block or entity.

Cardinal Components API takes care of it all.

Detailed information is available in the website's wiki. The information below is a condensed form of the latter.
If you have questions or need help with this library, you can also join the Ladysnake Discord.

Features*

  • ๐Ÿ”— Attach your components to a variety of vanilla classes
  • ๐Ÿงฉ Implement once, plug anywhere - your data will be saved automatically
  • ๐Ÿ“ค Synchronize data with a single helper interface
  • ๐Ÿ‘ฅ Choose how your components are copied when a player respawns
  • โฒ๏ธ Tick your components alongside their target
  • ๐Ÿ› ๏ธ Fine-tune everything so that it fits your needs
  • โ˜„๏ธ And enjoy the blazing speed of ASM-generated extensions

*Non-exhaustive, refer to the wiki and javadoc for the full list.

Adding the API to your buildscript:

The following instructions are for versions 6.0 and up. For previous versions, refer to this table on the website.

Latest versions of Cardinal Components API are available on the Ladysnake maven:

repositories {
    maven {
        name = 'Ladysnake Mods'
        url = 'https://maven.ladysnake.org/releases'
    }
}

dependencies {
    // Adds a dependency on the base cardinal components module (required by every other module)
    // Replace modImplementation with modApi if you expose components in your own API
    modImplementation "org.ladysnake.cardinal-components-api:cardinal-components-base:<VERSION>"
    // Adds a dependency on a specific module
    modImplementation "org.ladysnake.cardinal-components-api:<MODULE>:<VERSION>"
    // Includes Cardinal Components API as a Jar-in-Jar dependency (optional)
    include "org.ladysnake.cardinal-components-api:cardinal-components-base:<VERSION>"
    include "org.ladysnake.cardinal-components-api:<MODULE>:<VERSION>"
}

Check out https://ladysnake.org/wiki/cardinal-components-api/dev-install for up-to-date buildscript samples with build.gradle, build.gradle.kts, and libs.versions.toml.

You can find the current version of the API in the releases tab of the repository on Github.

Cardinal Components API is split into several modules. To depend on the all-encompassing master jar, use the dependency string org.ladysnake.cardinal-components-api:cardinal-components-api:<VERSION>. That artifact brings every module to your dev env, but you often do not need all of them for a project. Also note that the maven version of the fat jar is actually empty, so you will have to require users to install it from curseforge or modrinth if you do not bundle all required modules.

[List of individual module names and descriptions]

Example:

// Adds an API dependency on the base cardinal components module (required by every other module)
modApi "org.ladysnake.cardinal-components-api:cardinal-components-base:<VERSION>"
// Adds an implementation dependency on the entity module
modImplementation "org.ladysnake.cardinal-components-api:cardinal-components-entity:<VERSION>"

Basic Usage

To get started, you only need a class implementing Component. It is recommended to have it split into an interface and an implementation, so that internals get properly encapsulated and so that the component itself can be used as an API by other mods.

Minimal code example:

public interface IntComponent extends ComponentV3 {
    int getValue();
}

class RandomIntComponent implements IntComponent {
    private int value = (int) (Math.random() * 20);
    @Override public int getValue() { return this.value; }
    @Override public void readFromNbt(CompoundTag tag) { this.value = tag.getInt("value"); }
    @Override public void writeToNbt(CompoundTag tag) { tag.putInt("value", this.value); }
}

Note: a component class can be reused for several component types

If you want your component to be automatically synchronized with watching clients, you can also add the AutoSyncedComponent interface to your implementation:

class SyncedIntComponent implements IntComponent, AutoSyncedComponent {
    private int value;
    private final Entity provider;  // or World, or whatever you are attaching to

    public SyncedIntComponent(Entity provider) { this.provider = provider; }

    public void setValue(int value) {
        this.value = value;
        MyComponents.MAGIK.sync(this.provider); // assuming MAGIK is the right key for this component
    }
    // implement everything else
}

[More information on component synchronization]

If you want your component to tick alongside its provider, you can add the ServerTickingComponent or ClientTickingComponent (or both) to your component interface (here, IntComponent). If you'd rather add the ticking interface to a single component subclass, you have to use one of the specific methods provided in the individual modules (here something of the form registry.beginRegistration(IntComponent.KEY).impl(IncrementingIntComponent.class).end(IncrementingIntComponent::new)).

class IncrementingIntComponent implements IntComponent, ServerTickingComponent {
    private int value;
    @Override public void serverTick() { this.value++; }
    // implement everything else
}

Serverside ticking is implemented for all providers. Clientside ticking is only implemented for entities, block entities, worlds, and scoreboards/teams.

If you want your component to be notified of its provider being loaded and unloaded, typically for advanced setup or cleanup, you can add the ServerLoadAwareComponent or ClientLoadAwareComponent (or both) and their "Unload" variants to your component interface (here, IntComponent). Just like with ticking, if you'd rather add the (un)load-aware interface to a single component subclass, you have to use one of the specific methods provided in the individual modules.

class IncrementingIntComponent implements IntComponent, ServerLoadAwareComponent {
    private int value;
    @Override public void loadServerside() { this.value++; }
    // implement everything else
}

Serverside load and unload is implemented for entities, block entities, chunks, worlds, and scoreboards. Clientside load and unload is only implemented for entities, block entities, and chunks. This is an experimental feature, any feedback welcome.

The next step is to choose an identifier for your component, and to declare it as a custom property in your mod's metadata:

quilt.mod.json (if you use Quilt)

{
    "schema_version": 1,
    "quilt_loader": {
        "id": "mymod"
    },
    "cardinal-components": [
        "mymod:magik"
    ]
}

fabric.mod.json (if you use Fabric)

{
    "schemaVersion": 1,
    "id": "mymod",

    "custom": {
        "cardinal-components": [
            "mymod:magik"
        ]
    }
}

Components can be provided by objects of various classes, depending on which modules you installed. The most common providers are entities, worlds and chunks, but more are available. To interact with them, you need to register a component key, using ComponentRegistryV3#getOrCreate; the resulting ComponentKey instance has the query methods you need. You will also need to attach your component to some providers (here, to players and worlds):

public final class MyComponents implements EntityComponentInitializer, WorldComponentInitializer {
    public static final ComponentKey<IntComponent> MAGIK = 
        ComponentRegistryV3.INSTANCE.getOrCreate(new Identifier("mymod:magik"), IntComponent.class);
        
    @Override
    public void registerEntityComponentFactories(EntityComponentFactoryRegistry registry) {
        // Add the component to every PlayerEntity instance, and copy it on respawn with keepInventory
        registry.registerForPlayers(MAGIK, player -> new RandomIntComponent(), RespawnCopyStrategy.INVENTORY);
    }
    
    @Override
    public void registerWorldComponentFactories(WorldComponentFactoryRegistry registry) {
        // Add the component to every World instance
        registry.register(MAGIK, world -> new RandomIntComponent());
    }    
}

Do not forget to declare your component initializer as an entrypoint in your mod's metadata:

quilt.mod.json (if you use Quilt)

{
    "quilt_loader": {
        "entrypoints": {
            "cardinal-components": "a.b.c.MyComponents"
        },
    }
}

fabric.mod.json (if you use Fabric)

{
    "entrypoints": {
        "cardinal-components": [
            "a.b.c.MyComponents"
        ]
    },
}

[More information on component registration]

Now, all that is left is to actually use that component. You can access individual instances of your component by using the dedicated getters on your ComponentKey:

public static void useMagik(Entity provider) { // anything will work, as long as a module allows it!
    // Retrieve a provided component
    int magik = provider.getComponent(MAGIK).getValue();
    // Or, if the object is not guaranteed to provide that component:
    int magik = MAGIK.maybeGet(provider).map(IntComponent::getValue).orElse(0);
    // ...
}

Test Mod

A test mod for the API is available in this repository, under src/testmod. It makes uses of most features from the API. Its code is outlined in a secondary readme.

Footnotes

  1. this description has been made exaggeratedly convoluted for comedic effects. โ†ฉ

cardinal-components-api's People

Contributors

ayutac avatar bemk avatar forgetmenot13579 avatar ims212 avatar jab125 avatar lukebemish avatar pyrofab avatar qouteall avatar stuff-stuffs avatar upcraftlp avatar waterpicker avatar zekerzhayard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cardinal-components-api's Issues

Block Entity support

I might be missing something, but there doesn't seem to be an easy way to add components to block entities.

Although block components bounce to the BE if it implements BlockComponentProvider, support does not seem first class in the way it seems to be for e.g. Entities. From what I can tell, attaching mod components to something like vanilla's block entities seems impossible.

Is there a reason that this doesn't exist?

CC Chunk (and maybe Base) have dependency on CC Entity

CC Chunk (and maybe Base) have dependency on CC Entity


Hi, recently you patched a dependency issue with CC Chunk. I've found another one, where it appears to also be dependant on the Entity module. Worlds only load if entity is present.

Crash when starting worlds

Having a problem while trying to start a world with Fabric that relates to this...I think. Any ideas?

---- Minecraft Crash Report ----
// Why did you do that?

Time: 2020-08-26 15:29:10 EDT
Description: Exception in server tick loop

java.lang.NoSuchMethodError: dev.onyxstudios.cca.internal.base.DynamicContainerFactory.create(Ljava/lang/Object;)Lnerdhub/cardinal/components/api/component/ComponentContainer;
at Not Enough Crashes deobfuscated stack trace.(1.16.1+build.21)
at net.minecraft.world.World.handler$bhd000$initComponents(World:3791)
at net.minecraft.world.World.(World:158)
at net.minecraft.server.world.ServerWorld.(ServerWorld:180)
at net.minecraft.server.MinecraftServer.createWorlds(MinecraftServer:368)
at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer:334)
at net.minecraft.server.integrated.IntegratedServer.setupServer(IntegratedServer:69)
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer:647)
at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer:256)
at java.lang.Thread.run(Thread.java:745)

A detailed walkthrough of the error, its code path and all known details is as follows:

-- System Details --
Minecraft Version: 1.16.1
Minecraft Version ID: 1.16.1
Operating System: Mac OS X (x86_64) version 10.15.6
Java Version: 1.8.0_74, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 6341600792 bytes (6047 MB) / 8556380160 bytes (8160 MB) up to 8589934592 bytes (8192 MB)
CPUs: 8
JVM Flags: 8 total; -Xss1M -Xmx8G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M
Suspected Mods: Unknown
Fabric Mods: adorn: Adorn 1.10.1+1.16.1
allure: Allure 1.2.1
angerable-patch: Angerable Patch 1.0.0-1.16.1
artifice: Artifice 0.8.0+1.16-rc1
atmosfera: Atmosfera 1.2.2-1.16
autoconfig1u: Auto Config v1 Updated 3.2.0-unstable
automated_crafting: Automated Crafting 1.3.4+1.16.1
autoswap: Autoswap 1.16-fabric0.13.1-1.0.1
bambootweaks: Bamboo Tweaks unspecified
battletowers: Battle Towers 3.0.3-beta-1.16.1
bedspreads: Bedspreads 1.0.0-1.16.1
betterdroppeditems: Better Dropped Items 1.2.1-1.16
blackstonetools: Blackstone Tools 1.2.0+1.16.1
blue_endless_jankson: jankson +
boot: BootZ 1.3.1
byg: BYG 1.0.13
campanion: Campanion 1.1.13+build.35
can-i-mine-this-block: can i mine this block? 1.0.0
cardinal-components-base: Cardinal Components API (base) 2.5.0
cardinal-components-entity: Cardinal Components API (entities) 2.5.0
cardinal-components-world: Cardinal Components API (worlds) 2.4.0-nightly.1.16-rc1.build.2
chainmail: Chainmail 0.5.0
cinderscapes: Cinderscapes 1.0.7+build.43-1.16.1
cloth-basic-math: Cloth Basic Math 0.5.1
cloth-client-events-v0: Cloth Client Events v0 1.0.5
cloth-config2: Cloth Config v4 4.6.0
controlling: Controlling For Fabric 1.1.2
cotton: Cotton 1.0.7
cotton-cauldron: Cotton Cauldron 1.0.4
cotton-client-commands: Cotton Client Commands 1.0.0+1.15.2
cotton-commons: Cotton Commons 1.0.4
cotton-config: Cotton Config 1.0.0-rc.7
cotton-datapack: Cotton Datapack 1.0.7
cotton-logging: Cotton Logging 1.0.0-rc.4
cotton-player-events: Cotton Player Events 1.0.2
couplings: Couplings 1.3.1
crimsonmoon: Crimson Moon 1.2.2-1.16.1
crookedcrooks: Crooked Crooks 1.2.1+1.16.1
dark-loading-screen: Dark Loading Screen 1.4.2
diggusmaximus: Diggus Maximus 1.3.0-1.16
dishes: Delicious Dishes 1.0.3
dynamicfps: Dynamic FPS 1.1.4
dynamicsoundfilters: Dynamic Sound Filters 1.1.2+1.16.1
earthtojavamobs: Earth2Java 1.1.0+1.16.1
ecotones: Ecotones 0.5.1
endreborn: End: Rebellion 1.7.1
expandedconcrete: Expanded Concrete 0.0.1
expandedstorage: ExpandedStorage 5.5.22
fabric: Fabric API 0.17.0+build.386-1.16.1
fabric-api-base: Fabric API Base 0.1.3+12a8474c7c
fabric-biomes-v1: Fabric Biomes (v1) 0.2.7+059ea86602
fabric-blockrenderlayer-v1: Fabric BlockRenderLayer Registration (v1) 1.1.4+c6a8ea8902
fabric-command-api-v1: Fabric Command API (v1) 1.0.8+5ce5339802
fabric-commands-v0: Fabric Commands (v0) 0.2.0+52d3083602
fabric-containers-v0: Fabric Containers (v0) 0.1.8+045df74f02
fabric-content-registries-v0: Fabric Content Registries (v0) 0.1.9+059ea86602
fabric-crash-report-info-v1: Fabric Crash Report Info (v1) 0.1.2+b7f9825d02
fabric-dimensions-v1: fabric-dimensions-v1 1.0.0+a71b305302
fabric-events-interaction-v0: Fabric Events Interaction (v0) 0.3.3+7066030f02
fabric-events-lifecycle-v0: Fabric Events Lifecycle (v0) 0.2.0+16acbe5b02
fabric-game-rule-api-v1: Fabric Game Rule API (v1) 1.0.0+fe81e12502
fabric-item-api-v1: Fabric Item API (v1) 1.0.0+16acbe5b02
fabric-item-groups-v0: Fabric Item Groups (v0) 0.2.0+438f963602
fabric-key-binding-api-v1: Fabric Key Binding API (v1) 1.0.1+f404f3be02
fabric-keybindings-v0: Fabric Key Bindings (v0) 0.2.0+3fa9f7c502
fabric-language-kotlin: Fabric Language Kotlin 1.3.71+build.1
fabric-lifecycle-events-v1: Fabric Lifecycle Events (v1) 1.2.0+e83e061c02
fabric-loot-tables-v1: Fabric Loot Tables (v1) 1.0.0+386eb69e02
fabric-mining-levels-v0: Fabric Mining Levels (v0) 0.1.2+b764ce9902
fabric-models-v0: Fabric Models (v0) 0.1.0+dfdb52d602
fabric-networking-blockentity-v0: Fabric Networking Block Entity (v0) 0.2.5+b50ffc7b02
fabric-networking-v0: Fabric Networking (v0) 0.1.10+e00ecb5f02
fabric-object-builder-api-v1: Fabric Object Builder API (v1) 1.5.7+2242e77202
fabric-object-builders-v0: Fabric Object Builders (v0) 0.6.1+a2d21ddd02
fabric-particles-v1: fabric-particles-v1 0.2.1+0a6f2a7002
fabric-registry-sync-v0: Fabric Registry Sync (v0) 0.3.8+7dba2d6c02
fabric-renderer-api-v1: Fabric Renderer API (v1) 0.2.13+eae12eb802
fabric-renderer-indigo: Fabric Renderer - Indigo 0.3.4+34d6c87102
fabric-renderer-registries-v1: Fabric Renderer Registries (v1) 2.1.0+be551d3c02
fabric-rendering-data-attachment-v1: Fabric Rendering Data Attachment (v1) 0.1.3+b7f9825d02
fabric-rendering-fluids-v1: Fabric Rendering Fluids (v1) 0.1.8+b7084faa02
fabric-rendering-v0: Fabric Rendering (v0) 1.1.0+5341049002
fabric-rendering-v1: Fabric Rendering (v1) 1.1.2+346247d702
fabric-resource-loader-v0: Fabric Resource Loader (v0) 0.2.6+f41e209802
fabric-screen-handler-api-v1: Fabric Screen Handler API (v1) 1.1.0+97324d1102
fabric-tag-extensions-v0: Fabric Tag Extensions (v0) 0.2.7+a4c57d8e02
fabric-textures-v0: Fabric Textures (v0) 1.0.4+eae12eb802
fabric-tool-attribute-api-v1: Fabric Tool Attribute API (v1) 1.2.1+91fca5cd02
fabricloader: Fabric Loader 0.9.2+build.206
fastbench: FastBench 2.3
fastfurnace: FastFurnace 2.2
fatxporbs: Fat Experience Orbs 0.0.7
fiber: fiber 0.23.0-1
flesh2leather: Flesh2Leather 1.0.0
flonters: Flonters 1.1.0+1.16.1
harvest: Harvest 1.2.12
horseinfo: Horse Info 0.2.2-1.16.1
illuminations: Illuminations 1.0.4
intotheomega: Into the Omega 1.0.3-beta-1.16.1
inventoryprofiles: Inventory Profiles 0.4.2
jankson: Jankson 3.0.0+j1.2.0
kibe: Kibe 1.1.12-BETA
kyrptconfig: Kytpt Config 1.1.0-1.16
libcd: LibCapableData 2.5.0+1.16.1
libgui: LibGui 2.3.0+1.16.1
libstructure: Libstructure 1.3
lightoverlay: Light Overlay 5.4.2
linkedstorage: Linked Storage 1.3.6-1.16
lithium: Lithium 0.5.1
loadcatcher: Entrypoint Catcher 2.0.0
magna: Magna 1.3.2-1.16.1
mambience: MAmbience 2.1.0-1.16
mattocks: Mattocks 1.0.3
mdp: MusicDiscsPlus 1.0.0-FABRIC.1.16.1
mighty_mangoes: Mighty Mangoes 1.0.0
minecraft: Minecraft 1.16.1
mm: Manningham Mills 2.0
mo_glass: Mo Glass 1.3-MC1.16.1
modmenu: Mod Menu 1.14.5+build.30
moreberries: More Berries 1.3.1
morecraftingtables: Oh, How the Crafting Has Tabled! 0.1.0
mostructures: Mo' Structures 1.0.0-pre2+mc.1.16
netheritehorsearmor: Netherite Horse Armor 0.4.2-1.16.1
notenoughcrashes: Not Enough Crashes 2.1.4+1.16.1
org_apache_httpcomponents_httpclient: httpclient 4.5.10
org_apache_httpcomponents_httpcore: httpcore 4.4.12
org_apache_httpcomponents_httpmime: httpmime 4.5.10
org_codehaus_groovy_groovy: groovy 3.0.3
org_codehaus_groovy_groovy-jsr223: groovy-jsr223 3.0.3
org_jetbrains_annotations: annotations 17.0.0
org_jetbrains_kotlin_kotlin-reflect: kotlin-reflect 1.3.71
org_jetbrains_kotlin_kotlin-stdlib: kotlin-stdlib 1.3.71
org_jetbrains_kotlin_kotlin-stdlib-jdk7: kotlin-stdlib-jdk7 1.3.71
org_jetbrains_kotlin_kotlin-stdlib-jdk8: kotlin-stdlib-jdk8 1.3.71
org_jetbrains_kotlinx_kotlinx-coroutines-core: kotlinx-coroutines-core 1.3.5
org_jetbrains_kotlinx_kotlinx-coroutines-jdk8: kotlinx-coroutines-jdk8 1.3.5
origins: Origins 1.16-0.3.4
origins-classes: Origins: Classes 1.16.1-1.0.1
packages: Packages 1.0
packed: Packed Storage 1.0.7
parchment: Parchment 1.0.2+1.15.2
patchouli: Patchouli 1.16-39-FABRIC
petowner: Pet Owner 1.16.1-1.3
phosphor: Phosphor 0.6.0+build.7
playerabilitylib: Pal 1.2.0
portalcrafter: Portal Crafter 1.0.0
pumice: Pumice 0.0.1
reach-entity-attributes: Reach Entity Attribute 1.0.1
repurposed_structures: Repurposed Structures 1.4.6
respawnablepets: Respawnable Pets 4
roughlyenoughitems: Roughly Enough Items 4.12.1
roughlyenoughresources: Roughly Enough Resources 2.0.2
rpgstats: RPGStats 2.1.4+1.16.1
satin: Satin 1.4.0-nightly.1.16-pre5+build.1
secretrooms: Secret Rooms 0.9.1+1.16.1
shapes: Shapes 2.0.0+build.10
shulkerboxtooltip: Shulker Box Tootip 2.1.0+1.16.1
sign_editor: Better Signs & Frames mc-1.16.1-0.6.1
silky_spawners: Silky Spawners 2.0.0+build.1-1.16
simpledrawers: Simple Drawers 1.8.0-1.16.1
simplexterrain: Simplex Terrain 0.6.5
simplyplatinum: Simply Platinum 2.0.0
skinswapper: Minecraft Skin Change Mod 2.0.1
slabhelper: Slab Helper 1.3.2
slight-gui-modifications: 'Slight' GUI Modifications 1.2.0
sodium: Sodium 0.1.0
soulbound: Soulbound 1.0.1
spinnery: Spinnery 3.1.14
staffofbuilding: Staff of Building 1.2.0-1.16
static-content: Static Content 1.0.0-1.16.1
staticdata: Static Data 1.1.2
stonecutter-tweaks: Stonecutter Tweaks 1.1.0-1.16
structure-helpers: Structure Helpers 2.1.0
stuffz: StuffZ 2.2.2
tacocraft: TacoCraft 1.3.1+mc.1.16
terraform: Terraform 2.3.0+build.33
terrestria: Terrestria 2.0.6+build.58
the_bumblezone: The Bumblezone - Fabric 1.16.1-2.1.2
toms_storage: Tom's Simple Storage Mod 1.1.1
tomsfabriclibs: Tom's Fabric Lib 1.0.2
torridvision: Torrid Vision 0.0.1
trash-it: Trash It 1.0.1-1.16.1
traverse: Traverse 2.2.15+build.30
trinkets: Trinkets 2.6.3
umollu_ash: ASH - Another Simple HUD 1.1.9
unlimiteddragoneggs: Unlimited Dragon Eggs 1.0.0
vanilla-hammers: Vanilla Hammers 2.0.4-1.16.1
vanillaexcavators: Vanilla Excavators 1.1.0
villagerhats: Villager Hats fabric-1.16-rc1-1.0.0
waila: Hwyla 1.9.22
wolveswitharmor: Wolves With Armor 1.5.1-1.16.1
woods_and_mires: Woods and Mires 1.0.0+1.16.1
xaeroworldmap: Xaero's World Map 1.10.1
Patchouli open book context: n/a
Player Count: 0 / 8; []
Data Packs: vanilla (incompatible), fabric/kibe (incompatible), fabric/packages, fabric/villagerhats, fabric/mo_glass, fabric/morecraftingtables, fabric/repurposed_structures, fabric/battletowers, fabric/structure-helpers, fabric/mostructures, fabric/origins, fabric/adorn, fabric/the_bumblezone, fabric/toms_storage, fabric/terrestria, fabric/linkedstorage, fabric/expandedconcrete, fabric/vanillaexcavators, fabric/portalcrafter, fabric/netheritehorsearmor, fabric/wolveswitharmor, fabric/ecotones, fabric/bambootweaks, fabric/intotheomega, fabric/woods_and_mires, fabric/cotton-commons, fabric/origins-classes, fabric/packed, fabric/boot, fabric/harvest, fabric/byg, fabric/cinderscapes, fabric/silky_spawners, fabric/staffofbuilding, fabric/rpgstats, fabric/blackstonetools, fabric/respawnablepets, fabric/pumice, fabric/simpledrawers, fabric/tacocraft, fabric/fabric-tool-attribute-api-v1, fabric/endreborn, fabric/expandedstorage, fabric/dishes, fabric/earthtojavamobs, fabric/trash-it, fabric/libcd, fabric/flesh2leather, fabric/vanilla-hammers, fabric/allure, fabric/automated_crafting, fabric/flonters, fabric/campanion, fabric/bedspreads, fabric/traverse, fabric/mdp, fabric/moreberries, fabric/crookedcrooks, fabric/stuffz, fabric/simplyplatinum, fabric/slabhelper, fabric/mattocks, fabric/mighty_mangoes, fabric/secretrooms, global/cotton_generated (incompatible), linkedstorage:enderstorage, secretrooms:server_pack
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fabric'

Do not expose mcdev annotation dependency to downstream consumers

The mcdev annotations are marked as api in build.gradle, meaning that any downstream users also get the dependency.

This is causing build warnings in Botania that look like warning: unknown enum constant Env.CLIENT reason: class file for com.demonwav.mcdev.annotations.Env not found.

Since these annotations are for static analysis, it would be better to let consumers of the library decide whether they want to opt into this system, in which case the consumer would add its own dependency on the annotation library.

I propose changing the dep to be declared with compileOnly or at least implementation instead.
(Though I'm not sure if this will fix my issue at hand)

1.16.1 Crashes on Startup

Cardinal-Components-API v2.4.2 will crash if the game is started with Optifabric also enabled. Disabling either 1 or the other will enable the game to boot correctly, but not together. Issue repeatable with versions 2.4.0, 2.4.1 & 2.4.2

Cardinal Components Expects ClientWorld Class in all Environments

Very minor bug, but Cardinal Components attempts to mixin into net.minecraft.client.world.ClientWorld, even though that class does not exist on dedicated servers.

This results in a Error loading class: net/minecraft/class_638 (java.lang.ClassNotFoundException: net/minecraft/class_638) printed to the server log. This has absolutely no impact on gameplay or the functionality of any mods, it just results in a bit of spam to server logs that would be great to fix.

Ideally, there would be some kind of check, and disable loading that mixin if the current environment is a dedicated server. Thanks for taking the time to read this, and for creating this API!

Need fast methods to check if item has components and compare CCA item stacks.

My request is for some kind of performant utility that tests if an ItemStack contains any non-empty component information.

CCA item components are problematic for Facility/Fluidity because Facility needs to compare potentially many thousands of items within a single storage system when doing any sort of search operation. Facility item stores do not use ItemStack internally because ItemStack is a bad abstraction for uniquely identifying stored items.

A better abstraction would be Item, SpecificItem (item with or without a Tag), and SpecificItemWithQuantity.

The most valuable abstraction would be SpecificItem because finding/comparing Items and tracking quantities are otherwise trivial. But ItemStack obscures the concept of SpecificItem and makes comparison unnecessarily complicated.

ItemStack is at least workable because 1) the class is final and 2) all information other than Item and quantity are stored in a nullable CompoundTag.

The vast majority of items are simple items with no tag. For these, Fluidity can take a shortcut and rely on Item == comparison and avoid expensive NBT traversal operations.

CCA breaks this scheme by 1) adding a component store outside of Tag and 2) making that store - even the existence of it - undiscoverable except by specifically querying individual components per ItemStack instance.

This means a large-scale storage mod must retain ItemStack instances internally for each stored item and also force the use of ItemStack instances as input parameters for all storage operations in order to use the CCA-modified version of ItemStack.areTagsEqual.

The easiest way out of this is to make Facility not store item stacks with embedded CCA components. However, there seems to be no way to determine what these are. So for now I'm adding a black list configuration so server admins can prevent problems like this one.

I'd like to retain simple comparison logic for most items but once this check is available I will probably find a way to make Fluidity/Facility compatible with CCA items for storage and transport. But that will be a non-trivial change and is unlikely to happen soon.

[Question/Crash] ComponentKey Class not found

Hi, I just ran my mod normally today and get this error. The mod runs smoothly last time I built it.

I run with 2.7.9 CCA. I refreshed dependencies.

[21:51:32] [main/WARN] (mixin) Error loading class: dev/onyxstudios/cca/api/v3/component/ComponentKey (java.lang.ClassNotFoundException: dev/onyxstudios/cca/api/v3/component/ComponentKey)
Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:226)
        at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:141)
        at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:27)
        at net.fabricmc.devlaunchinjector.Main.main(Main.java:86)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:224)
        ... 3 more
Caused by: org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError: An unexpected critical error was encountered
        at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:363)
        at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:208)
        at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClassBytes(MixinTransformer.java:178)
        at org.spongepowered.asm.mixin.transformer.FabricMixinTransformerProxy.transformClassBytes(FabricMixinTransformerProxy.java:23)
        at net.fabricmc.loader.launch.knot.KnotClassDelegate.getPostMixinClassByteArray(KnotClassDelegate.java:157)
        at net.fabricmc.loader.launch.knot.KnotClassLoader.loadClass(KnotClassLoader.java:150)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at net.minecraft.client.main.Main.main(Main.java:118)
        ... 8 more
Caused by: org.spongepowered.asm.mixin.transformer.throwables.MixinPreProcessorException: Attach error for elt.mixins.json:MixinPlayerEntity during activity: [Transform -> Method update(Lorg/spongepowered/asm/mixin/injection/callback/CallbackInfo;)V -> INVOKEVIRTUAL -> dev/onyxstudios/cca/api/v3/component/ComponentKey::get(Ljava/lang/Object;)Lnerdhub/cardinal/components/api/component/Component;]
        at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.attach(MixinPreProcessorStandard.java:300)
        at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.createContextFor(MixinPreProcessorStandard.java:264)
        at org.spongepowered.asm.mixin.transformer.MixinInfo.createContextFor(MixinInfo.java:1272)
        at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.apply(MixinApplicatorStandard.java:287)
        at org.spongepowered.asm.mixin.transformer.TargetClassContext.applyMixins(TargetClassContext.java:345)
        at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:569)
        at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:351)
        ... 15 more
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: dev.onyxstudios.cca.api.v3.component.ComponentKey
        at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.transformMemberReference(MixinPreProcessorStandard.java:768)
        at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.transformMethod(MixinPreProcessorStandard.java:754)
        at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.transform(MixinPreProcessorStandard.java:720)
        at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.attach(MixinPreProcessorStandard.java:294)
        ... 21 more
Caused by: java.lang.ClassNotFoundException: dev.onyxstudios.cca.api.v3.component.ComponentKey
        ... 25 more

FAILURE: Build failed with an exception.

Codebase is here:
https://github.com/MoegTech/EnergyLevelTransition/tree/dev/yuesha

Component equality is ingored when merging itemstacks.

Component data is ignored when merging stacks inside the inventory. This bug happens, if we attached a component to an item that can stack.
If 2 with the same id but different data are given to the player it merges. The data from the stack that was in the slot we inject into is copied to the items you add to it, even if a new stack is created (from an overflow)

Video:
https://cdn.discordapp.com/attachments/742703385584730183/784955984392486982/cardinal-item-bug.mp4

How do you interact with value after registering it

I have my component interface and implementation, I have the entrypoint set up and the NBT data appears in game, but how do I interact with my component implementation class in order to change and read the value stored there?

Any reason on why giving up V2 API?

Currently I am looking at V3 API and it seems to be much more harder to learn than the V2 API. I am not degrading your effort, I am just curious what drives you to move?

Talking about the static data, I also feel kind of weird on why V3 API require static data while V2 don't. What's the advantage of it?

Thank you for your nice work, of course.

Item module causes malformed input on dedicated servers

Cardinal-Components-Item will not let clients join a dedicated server. Attempting to do so results in a malformed input error. It seems likely that this stems from MixinPacketByteBuffer, although I can't pinpoint what it's doing that causes this (besides reading a bad packet).

To replicate, create a blank project and include cardinal-components-item, then run a client and server with online-mode turned off. Connecting to the server will fail, resulting in this:

image

Until then, mods using Cardinal-Components-Item seemingly won't work in multiplayer.

MIT License for Cardinal Components not included when using Jar in Jar

Hi

I was following the instructions to use cardinal components on my mod. When I built the JAR with this on build.gradle

repositories {
	maven {
		name = "Ladysnake Libs"
		url = "https://dl.bintray.com/ladysnake/libs"
	}
}
   ...
// Cardinal Components
modImplementation "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-base:${project.cardinal_components_version}"
include "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-base:${project.cardinal_components_version}"
modImplementation "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-entity:${project.cardinal_components_version}"
include "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-entity:${project.cardinal_components_version}"
modImplementation "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-world:${project.cardinal_components_version}"
include "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-world:${project.cardinal_components_version}"

three jars were included on the build on the /META-INF/jars/ path of my mod jar. Cardinal Components Base, Cardinal Components Entity, and Cardinal Components World. When I checked each of the jars, none of them had the MIT license of cardinal components included on their jars. I'm using the version 2.7.3 of cardinal components, but a few previous versions and later versions also don't include the license in them.

Usually, when mods are included Jar in Jar, each library used includes the library license in the jar themselves.

Cardinal Components has too much global state

Right now, all Cardinal Components registries are completely global and only populated once. It's a simple model, but it very quickly becomes limiting.

I'm currently working on a server side-only mod that should only register components on the server (integrated server if SP). Cardinal Components only calls my entrypoint once and any components added to that registry are loaded on both the MinecraftClient and IntegratedServer. I've talked to @Pyrofab about this, and right now the best solution is to simply make your component nonfunctional on the client. But what if there was a better solution?

What if you were able to register components seperately, per client/server? What if your entrypoint wasn't just called once, but whenever a new instance sprung up with fresh registries? When the client starts, sure, but also whenever a new server starts? I present to you local state.

I believe Cardinal Components should migrate to this local state rather than global state. Registries become per-server or per-client, and your entrypoint gets called whenever a fresh registry wants data. Entrypoints can query properties on the registry to know where they are being called, and adjust their behavior accordingly. There is less forbidden sharing of data between the integrated server and Minecraft client.

Server side-only mods can opt out of registering their components on the client, while still supporting the integrated server, and not having to worry about their code being called from the wrong side. The public-facing API doesn't even need to change; you can just add new methods to the registries and clarify that the entrypoint is not called only once.

This would not only improve my development experience, but also the experience of many others who have had to deal with this problem of supporting singleplayer with single side-only mods. Your mod will rely less on static data and stay firmly planted in what matters - the server or client.

This is a tracking issue, but also a request for comment. Any feedback would be greatly appreciated.

Wiki codes out-of-date?

MC version: 1.16.1
Cardinal Components Version: 2.4.2

Hi I tried the wiki example to register a component. I have a question regarding this.

public class Handler_Components implements EntityComponentInitializer {

    public static final ComponentType<IComponentFloat> FLOAT_COMPONENT_TYPE =
            ComponentRegistry.INSTANCE.registerIfAbsent(new Identifier("eltcore:float"), IComponentFloat.class);

    @Override
    public void registerEntityComponentFactories(EntityComponentFactoryRegistry registry) {
        registry.register(FLOAT_COMPONENT_TYPE, IComponentFloat::new);
    }
}

This method does not work because it requires three components.
registry.register(FLOAT_COMPONENT_TYPE, IComponentFloat::new);
And my entry point is added.

"entrypoints": {
    "cardinal-components-entity": [
      "net.moeg.eltcore.handlers.Handler_Components"
    ]
  },

I saw in the source saying that many of these above methods are experimental or scheduled to be removed. Can you recommend a stable version to use Cardinal-Components-API? I like the mod's utility very much.

PlayerEntity ComponentProvider supplying same component for all players

Hi again!
Hopefully I'm not being as dumb as last time, but I'm trying to implement 'claiming' functionality into my mod using components (that store the owner UUID and a hex code for their colour).
There are some strange behaviours that I've noticed:

  • At world load, it creates two components: one for an unnamed ServerPlayerEntity, and one for an unnamed ClientPlayerEntity, each has different UUIDs. It does not create a component for any named player that joins the server.
  • When I try to retrieve the component for a player, it always returns the same component, with the unnamed ServerPlayerEntity's UUID, and the colour that was set up for that. This persists between different players and I don't know why. Have I messed up registration somehow?
  • This single component that is returned is created at world creation-ish time, and persists across every player that joins the server. It never changes.

Here's my repo for reproduction of the issue:
https://github.com/Nosrick/momcraft-fabric

I register my components in a class called "ModComponents" in dependency/cardinalcomponents.
I attempt to access my components in BlockResearchAltar, in the block package. I've tried several methods for accessing these components, and they all result in the same thing: a singular component being returned.

Hopefully I'm not being horrifically stupid!

EDIT: I'm using v2.4.2, btw.

ItemStack have no components when picked up

When you try to recollected a dropped ItemStack any components are not copied over.

This is caused by Minecraft copying ItemStacks in a non-standard way, inside PlayerInventory, when ItemEntities are picked up. Instead of using ItemStack.copy() they make a new ItemStack and copy the tag from from the old.

My stack trace ending with the method in question
stack

Presumably, this is also why /give also gives ItemStacks without components

Creative inventory

Any vanilla items and blocks are missing from creative inventory

I have tried :

  1. clean install (no mods) + cardinal, working fine
  2. modded + cardinal, missing items and blocks
  3. modded without cardinal, working fine

Here is my mod list (from console)
https://pastebin.com/1iBhgzfC

In-game screenshot
image

Cannot Fetch Dependencies

How to use Cardinal Components API as a whole in dependencies? The provided dependencies string does not work.

Game Crash on World Load

Game Crash on World Load

Whenever I load a world in a dev environment while working on my mod (it uses the V3 API), I recieve the following crash: https://controlc.com/ee04be1d


Reproduction Steps

Unfortunately, as my mod is not production ready as of yet, I am not ready to share the source code. I don't know what causes the crash


System Info

OS: Bedrock Linux
CC Version: 2.5.2
Modules in use: Base, Chunk
MC Version: 1.16.2
All other details can be extracted from the crash report

Allow use of BlockEntityType for registering components on block entities.

Currently CCA uses the block entity class to identify a block entity for registering components. However this has some issues due to limiting the types of supported block entities.

In one of my mods, I have moved to a builder system to create a block entity and it's corresponding blocks and items so I do not have a mess registering stuff. Simply I have two block entity implementations, one with an inventory and one without. This is preferable to me atleast since I can avoid having 20+ classes just for each type of block entity when the changes are anything but visual changes or changes in ticking logic which I can easily abstract.

A solution to this would be adding a parallel registration pipeline which allows for use of block entity types for attaching components to block entity instances.

Minecraft-aware versioning

With the 1.15 snapshots coming out, we will have to support functionally identical versions that are only compatible with some Minecraft versions. As such, a way to tell the target game version from the mod's own version becomes necessary.
Ideally, the chosen versioning should abide Semantic Versioning.

Prior art:

  • Forge's recommended versioning uses a versioning scheme completely separate from SemVer. This is far from ideal, as both Fabric Loader and Gradle rely on proper semantic versioning for dependency resolution.
  • Sponge's versioning is similar to Forge. (related issue)
  • Prospector's Mod Menu uses regular versions (implied 1.14) for the stable channel, and appends -unstable.19wXX to versions targeting snapshots. This breaks when updates are released for 2 stable versions of the game (eg. 1.14 and 1.15), as it forces one of the two to be considered beta.
  • Fabric API appends the Minecraft version to the build metadata (eg. 0.3.2+19w35a). This is proper semantic versioning, and is retrocompatible with the current versioning scheme. It also avoids locking a specific CCA version to the Minecraft version it was built on. (related issue)

I'd be partial to Fabric's versioning scheme, as it is the least invasive. Depending on a specific minecraft version can now be done better by depending on the appropriate intrinsic mod container.

[1.15.2] Concurrent Modification Exception when placing a boat

I'm using Winged (it embeds Cardinal Components as a library).
Here's the crash report, in short:

java.util.ConcurrentModificationException

at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1226)
at nerdhub.cardinal.components.internal.CardinalEntityInternals.getEntityContainerFactory(CardinalEntityInternals.java:71)
at net.minecraft.class_1297.handler$zjj001$initDataTracker(class_1297.java:4538)
at net.minecraft.class_1297.<init>(class_1297.java:256)
at net.minecraft.class_1690.<init>(class_1690.java:91)
at net.minecraft.class_1690.<init>(class_1690.java:96)
at net.minecraft.class_1749.method_7836(class_1749.java:53)
at net.minecraft.class_1799.method_7913(class_1799.java:206)
at net.minecraft.class_636.method_2919(class_636.java:348)
at net.minecraft.class_310.method_1583(class_310.java:1383)
at net.minecraft.class_310.method_1508(class_310.java:1598)
at net.minecraft.class_310.method_1574(class_310.java:1445)
at net.minecraft.class_310.method_1523(class_310.java:964)
at net.minecraft.class_310.method_1514(class_310.java:619)
at net.minecraft.client.main.Main.main(Main.java:204)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:192)
at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:140)
at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:26)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:196)
at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:231)
at org.multimc.EntryPoint.listen(EntryPoint.java:143)
at org.multimc.EntryPoint.main(EntryPoint.java:34)

Wiki has incorrect maven coordinate

The installation for developers page lists this dependencies block:

dependencies {
    // Replace modImplementation with modApi if you expose components in your own API
    modImplementation "io.github.onyxstudios:Cardinal-Components-API:<MODULE>:<VERSION>"
    // Includes Cardinal Components API as a Jar-in-Jar dependency (optional but recommended)
    include "io.github.onyxstudios:Cardinal-Components-API:<MODULE>:<VERSION>"
}

This is incorrect, the first : in both strings should be a .:

dependencies {
    // Replace modImplementation with modApi if you expose components in your own API
    modImplementation "io.github.onyxstudios.Cardinal-Components-API:<MODULE>:<VERSION>"
    // Includes Cardinal Components API as a Jar-in-Jar dependency (optional but recommended)
    include "io.github.onyxstudios.Cardinal-Components-API:<MODULE>:<VERSION>"
}

Instant crash on 20w19a using 2.4.0-nightly.20w06a

Message:

Mixin apply failed mixins.cardinal_components_world.json:common.world.MixinWorld -> net.minecraft.world.World: org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException Invalid descriptor on mixins.cardinal_components_world.json:common.world.MixinWorld->@Inject::initComponents(Lnet/minecraft/world/level/LevelProperties;Lnet/minecraft/world/dimension/DimensionType;Ljava/util/function/BiFunction;Ljava/util/function/Supplier;ZLorg/spongepowered/asm/mixin/injection/callback/CallbackInfo;)V! Expected (Lnet/minecraft/class_5269;Lnet/minecraft/world/dimension/DimensionType;Ljava/util/function/BiFunction;Ljava/util/function/Supplier;ZLorg/spongepowered/asm/mixin/injection/callback/CallbackInfo;)V but found (Lnet/minecraft/world/level/LevelProperties;Lnet/minecraft/world/dimension/DimensionType;Ljava/util/function/BiFunction;Ljava/util/function/Supplier;ZLorg/spongepowered/asm/mixin/injection/callback/CallbackInfo;)V [INJECT Applicator Phase -> mixins.cardinal_components_world.json:common.world.MixinWorld -> Apply Injections ->  -> Inject -> mixins.cardinal_components_world.json:common.world.MixinWorld->@Inject::initComponents(Lnet/minecraft/world/level/LevelProperties;Lnet/minecraft/world/dimension/DimensionType;Ljava/util/function/BiFunction;Ljava/util/function/Supplier;ZLorg/spongepowered/asm/mixin/injection/callback/CallbackInfo;)V]

Full log: https://paste.ee/p/NWIbO

Newer versions won't launch. They have <=1.16 constraint

Some confusion about how syncing works

So I'm trying to sync some values I have tried several different kinds but I always get the same error message:
Caused by: java.lang.ClassCastException: class <classpath of whatever I tried syncing> cannot be cast to class dev.onyxstudios.cca.api.v3.component.ComponentProvider The code for my component is:

interface PlaceModeComponent extends Component {
    void incrementPlaceMode();
    SlabPlaceMode getPlaceMode();
}

public class PlaceModeComponentImpl implements PlaceModeComponent, AutoSyncedComponent {
    private SlabPlaceMode mode;

    public PlaceModeComponentImpl(){
        this.mode = SlabPlaceMode.ALL;
    }

    @Override
    public void incrementPlaceMode() {
        this.mode = this.mode.next();
        Components.MODE_KEY.sync(this.mode);
    }

    @Override
    public SlabPlaceMode getPlaceMode() {
        return this.mode;
    }

    @Override
    public void readFromNbt(CompoundTag compoundTag) {
        try{
            this.mode = SlabPlaceMode.fromString(compoundTag.getString("placemode"));
            Components.MODE_KEY.sync(this.mode);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void writeToNbt(CompoundTag compoundTag) {
        compoundTag.putString("placemode", SlabPlaceMode.toString(this.mode));
    }
}

Components doesn't work with Swords

It seems like my cca component doesn't apply to swords, everything else works for my empty packet item.
The sword supplies the component, but when I try write data it doesn't work, but it works for my empty packet item.

If you need anymore information just tell me!
(btw there is nothing in my logs)
image

Chunk components are useless

CloneableComponent#newInstance does not give any reference to the new provider, preventing it from instantiating normally any component that needs it. This makes Chunk components almost useless, as they cannot access the world they are in. This also means a CloneableComponent cannot use most SyncedComponent helper implementations.
On the surface, this issue can be circumvented by using NativeCloneableComponent. However, this will share the previous chunk reference with the cloned component, making it still unable to access the new chunk.

Item Components disappearing on 2.4.0-nightly.1.16-rc1.build.2

I'm using 2.4.0-nightly.1.16-rc1.build.2 with Universal Components 0.7.2+1.16-pre2 on 1.16 release. Upon dropping my item, which uses a UC InventoryComponent (and picking it back up), the data is wiped. The only change between my old mod version (working) and the new version (not working) was going from CCA 2.4.0-nightly.1.16-pre2 to 2.4.0-nightly.1.16-rc1.build.2 (UC stayed on the same version).

This occurs in production and in dev. I'm pulling both dependencies like this:

// bob's cardinal components 2
modCompile "io.github.cottonmc:UniversalComponents:${project.universal_components_version}"
include "io.github.cottonmc:UniversalComponents:${project.universal_components_version}"

// go cornmit jij
modCompile "io.github.OnyxStudios:Cardinal-Components-API:${project.cardinal_components_version}"
universal_components_version=0.7.2+1.16-pre2
cardinal_components_version=2.4.0-nightly.1.16-rc1.build.2

I asked in the UC channel and bob said it was most likely CCA. I tried to step around with the debugger, but I couldn't find any leads on the issue.

maven does not contain current releases

while this error makes sense due to the breakouts happening after version 1.2.1, the main readme shows that including the base API jar should work via buildscript.
additionally, the item component is only at version 2.3.0 and does not contain some critical fixes between 2.3.0 and 2.3.4

Adding the repository and dependency clauses to the build script using the current version (2.3.4) in releases gives the error:

`A problem occurred configuring root project 'LivingItems'.

Could not resolve all dependencies for configuration ':modImplementation'.
Could not find com.github.NerdHubMC:Cardinal-Components-API:2.3.4.
Searched in the following locations:
- https://libraries.minecraft.net/com/github/NerdHubMC/Cardinal-Components-API/2.3.4/Cardinal-Components-API-2.3.4.pom
- https://libraries.minecraft.net/com/github/NerdHubMC/Cardinal-Components-API/2.3.4/Cardinal-Components-API-2.3.4.jar
- https://maven.onyxstudios.dev/com/github/NerdHubMC/Cardinal-Components-API/2.3.4/Cardinal-Components-API-2.3.4.pom
- https://maven.onyxstudios.dev/com/github/NerdHubMC/Cardinal-Components-API/2.3.4/Cardinal-Components-API-2.3.4.jar
- file:/C:/Users/User/.gradle/caches/fabric-loom/Cardinal-Components-API-2.3.4.jar
- file:/C:/Users/User/.gradle/caches/fabric-loom/Cardinal-Components-API.jar
- file:/C:/Users/User/source/fabric_minecraft/LivingItems/build/loom-cache/Cardinal-Components-API-2.3.4.jar
- file:/C:/Users/User/source/fabric_minecraft/LivingItems/build/loom-cache/Cardinal-Components-API.jar
- file:/C:/Users/User/source/fabric_minecraft/LivingItems/.gradle/loom-cache/remapped_mods/Cardinal-Components-API-2.3.4.jar
- file:/C:/Users/User/source/fabric_minecraft/LivingItems/.gradle/loom-cache/remapped_mods/Cardinal-Components-API.jar
- https://maven.fabricmc.net/com/github/NerdHubMC/Cardinal-Components-API/2.3.4/Cardinal-Components-API-2.3.4.pom
- https://maven.fabricmc.net/com/github/NerdHubMC/Cardinal-Components-API/2.3.4/Cardinal-Components-API-2.3.4.jar
- https://repo.maven.apache.org/maven2/com/github/NerdHubMC/Cardinal-Components-API/2.3.4/Cardinal-Components-API-2.3.4.pom
- https://repo.maven.apache.org/maven2/com/github/NerdHubMC/Cardinal-Components-API/2.3.4/Cardinal-Components-API-2.3.4.jar
- https://jcenter.bintray.com/com/github/NerdHubMC/Cardinal-Components-API/2.3.4/Cardinal-Components-API-2.3.4.pom
- https://jcenter.bintray.com/com/github/NerdHubMC/Cardinal-Components-API/2.3.4/Cardinal-Components-API-2.3.4.jar
Required by:
project :
Could not find com.github.NerdHubMC.Cardinal-Components-API:cardinal-components-item:2.3.4.
Searched in the following locations:
- https://libraries.minecraft.net/com/github/NerdHubMC/Cardinal-Components-API/cardinal-components-item/2.3.4/cardinal-components-item-2.3.4.pom
- https://libraries.minecraft.net/com/github/NerdHubMC/Cardinal-Components-API/cardinal-components-item/2.3.4/cardinal-components-item-2.3.4.jar
- https://maven.onyxstudios.dev/com/github/NerdHubMC/Cardinal-Components-API/cardinal-components-item/2.3.4/cardinal-components-item-2.3.4.pom
- https://maven.onyxstudios.dev/com/github/NerdHubMC/Cardinal-Components-API/cardinal-components-item/2.3.4/cardinal-components-item-2.3.4.jar
- file:/C:/Users/User/.gradle/caches/fabric-loom/cardinal-components-item-2.3.4.jar
- file:/C:/Users/User/.gradle/caches/fabric-loom/cardinal-components-item.jar
- file:/C:/Users/User/source/fabric_minecraft/LivingItems/build/loom-cache/cardinal-components-item-2.3.4.jar
- file:/C:/Users/User/source/fabric_minecraft/LivingItems/build/loom-cache/cardinal-components-item.jar
- file:/C:/Users/User/source/fabric_minecraft/LivingItems/.gradle/loom-cache/remapped_mods/cardinal-components-item-2.3.4.jar
- file:/C:/Users/User/source/fabric_minecraft/LivingItems/.gradle/loom-cache/remapped_mods/cardinal-components-item.jar
- https://maven.fabricmc.net/com/github/NerdHubMC/Cardinal-Components-API/cardinal-components-item/2.3.4/cardinal-components-item-2.3.4.pom
- https://maven.fabricmc.net/com/github/NerdHubMC/Cardinal-Components-API/cardinal-components-item/2.3.4/cardinal-components-item-2.3.4.jar
- https://repo.maven.apache.org/maven2/com/github/NerdHubMC/Cardinal-Components-API/cardinal-components-item/2.3.4/cardinal-components-item-2.3.4.pom
- https://repo.maven.apache.org/maven2/com/github/NerdHubMC/Cardinal-Components-API/cardinal-components-item/2.3.4/cardinal-components-item-2.3.4.jar
- https://jcenter.bintray.com/com/github/NerdHubMC/Cardinal-Components-API/cardinal-components-item/2.3.4/cardinal-components-item-2.3.4.pom
- https://jcenter.bintray.com/com/github/NerdHubMC/Cardinal-Components-API/cardinal-components-item/2.3.4/cardinal-components-item-2.3.4.jar
Required by:
project :
Possible solution:
` - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

Lil issue.

This is printed multiple times.

[23:57:26] [ForkJoinPool-1-worker-2/WARN]: The mod "cardinal-components-base" contains invalid entries in its mod json:

  • Unsupported root entry "side" at line 8 column 11
    [23:57:26] [ForkJoinPool-1-worker-7/WARN]: The mod "cardinal-components-entity" contains invalid entries in its mod json:
  • Unsupported root entry "side" at line 8 column 11
    [23:57:26] [ForkJoinPool-1-worker-6/WARN]: The mod "cardinal-components-base" contains invalid entries in its mod json:
  • Unsupported root entry "side" at line 8 column 11
    [23:57:26] [ForkJoinPool-1-worker-6/WARN]: The mod "cardinal-components-entity" contains invalid entries in its mod json:
  • Unsupported root entry "side" at line 8 column 11
    [23:57:27] [ForkJoinPool-1-worker-7/WARN]: The mod "cardinal-components-base" contains invalid entries in its mod json:
  • Unsupported root entry "side" at line 8 column 11
    [23:57:27] [ForkJoinPool-1-worker-7/WARN]: The mod "cardinal-components-world" contains invalid entries in its mod json:
  • Unsupported root entry "side" at line 8 column 11
    [23:57:27] [ForkJoinPool-1-worker-7/WARN]: The mod "cardinal-components-base" contains invalid entries in its mod json:
  • Unsupported root entry "side" at line 8 column 11
    [23:57:27] [ForkJoinPool-1-worker-7/WARN]: The mod "cardinal-components-entity" contains invalid entries in its mod json:
  • Unsupported root entry "side" at line 8 column 11
    [23:57:27] [ForkJoinPool-1-worker-1/WARN]: The mod "cardinal-components-base" contains invalid entries in its mod json:
  • Unsupported root entry "side" at line 8 column 11
    [23:57:27] [ForkJoinPool-1-worker-1/WARN]: The mod "cardinal-components-entity" contains invalid entries in its mod json:
  • Unsupported root entry "side" at line 8 column 11
    [23:57:27] [ForkJoinPool-1-worker-1/WARN]: The mod "cardinal-components-world" contains invalid entries in its mod json:
  • Unsupported root entry "side" at line 8 column 11
    [23:57:27] [ForkJoinPool-1-worker-1/WARN]: The mod "cardinal-components-chunk" contains invalid entries in its mod json:
  • Unsupported root entry "side" at line 8 column 11
    [23:57:27] [ForkJoinPool-1-worker-3/WARN]: The mod "cardinal-components-base" contains invalid entries in its mod json:
  • Unsupported root entry "side" at line 8 column 11
    [23:57:27] [ForkJoinPool-1-worker-4/WARN]: The mod "cardinal-components-entity" contains invalid entries in its mod json:
  • Unsupported root entry "side" at line 8 column 11
    [23:57:27] [ForkJoinPool-1-worker-7/WARN]: The mod "cardinal-components-base" contains invalid entries in its mod json:
  • Unsupported root entry "side" at line 8 column 11

Mixin conflicts with Immersive Portals

Static Components Feedback

#23 added statically declared components as an experimental feature. This issue is for sharing observations and thoughts about that new system.

Annotations

Update: annotations are no more

What is your stance on magical annotations to declare component factories ? Would you rather declare them entirely in fabric.mod.json ?

For example, replacing

{
    "custom": {
        "cardinal-components-api:component-factories": [
            "io.github.mymod.MyComponents"
        ]
    }
}
    @EntityComponentFactory(value = "mymod:mycomponent", target = LivingEntity.class)
    public static MyComponent create(LivingEntity e /* optional arg */) {
        return new MyEntityComponent(e);
    }

with

{
    "custom": {
        "cardinal-components-api:component-factories": [
            {
                "type": "entity",
                "target": "net.minecraft.class_1309",
                "factory": "io.github.mymod.MyComponents::create"
             }
        ]
    }
}
    public static MyComponent create(LivingEntity e /* optional arg */) {
        return new MyEntityComponent(e);
    }

Attempting to create an ItemStack while registering an ItemStack component crashes the game

Minecraft Version: 1.16.3
CCA Version: 2.6.0
CCA Modules: base, item

Attempting to create an ItemStack while registering an ItemStack component crashes the game with the following error https://paste.ee/p/exs70

This can occur non-deliberately by loading a class that, for example, attempts to build an ItemGroup in <clinit> which results in
Caused by: java.lang.NullPointerException at net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder.build(FabricItemGroupBuilder.java:100) at the bottom of the previously linked error

I have created what appears to be the minimum required to reproduce at https://github.com/P03W/CCA_Crash

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.