Cardinal Components API

Cardinal Components API

21M Downloads

How do you interact with value after registering it

Eilux opened this issue ยท 7 comments

commented

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?

commented

Usually that is accomplished by invoking one of the many get*() methods on your registered ComponentKey.

commented

for the get() method what argument should you input?

commented

if you attached your component to players, you do KEY.get(player), if you attached it to chunks you do KEY.get(chunk), etc.

commented

I'm defiantly doing something wrong here the game crashes whenever I run this line:
Components.MODE_KEY.get(client.player).incrementPlaceMode();

commented

Could you post a crash report ? You may have forgotten to add your registration class as an entrypoint.
Wiki page: https://github.com/OnyxStudios/Cardinal-Components-API/wiki/Registering-and-using-a-component#3-attaching-your-component

commented

Sorry for the delay in reply I did some poking around and fixed the crash but now I'm facing a new problem I need to read and write the NBT data for my component but I don't know what argument it expects for readFromNBT() and writeToNBT()

commented

(Further answers in the Fabric discord, TL;DR needs some client->server packets)