Thaumic Energistics

Thaumic Energistics

14M Downloads

Distillation patterns OC integration

repo-alt opened this issue ยท 5 comments

commented

Distillation encoded patterns when accessed from OC via me_controller.getCraftables() do not provide any information as to what essentia they encode in the item stack description.
image
Can it be fixed on your side, or some changes on OC side are required?

commented

Which aspect is being crafted is within the NBT tag on the item.
Key: "Aspect", Name of the aspect

commented

Well, unfortunately NBT is not available from LUA interface. I wonder where AE2 crafting/interface terminals get the names for these recipes?

commented

They can see the aspect name because the getUnlocalizedName() function on the item examines the NBT data for the aspect.

getUnlocalizedName() is defined here

Call chain:

getUnlocalizedName
-> ItemCraftingAspect.getAspect( stack )
-> getAspect( itemStack.getTagCompound() )
-> return Aspect.getAspect( tag.getString( NBTKEY_ASPECT ) )

Additional information about the aspect, such as its color and description, are retrieved from the addInformation() function, as defined here

commented

I was doing some digging to see if I could help you out, however I do not know how deep the integration goes with AE, nor have I worked with OC before, so I am doing some guess work.

From your screenshot I see that you are calling getCraftables() which is defined here:

  • Line 100 new NetworkControl.Craftable(tile, aeCraftItem) returns a aeCraftItem

aeCraftItem is defined here:

  • It implements IAEItemStack

IAEItemStack is from AE2, and is defined for 1.7.10 here:

  • It implements IAEStack

IAEStack is defined here:

  • It has a function getTagCompound() that returns IAETagCompound

IAETagCompound is defined here:

  • It has a function getNBTTagCompoundCopy() which returns NBTTagCompound

NBTTagCompound is the minecraft class for complex NBT data

So, given that aeCraftItem implements IAEItemStack which implements IAEStack, aeCraftItem should also have the function getTagCompound(). Calling that function would give you the AE compound tag, from there calling its getNBTTagCompoundCopy() should give you the NBT tag. With the tag, you could call getString(KEY) where KEY is "Aspect" as I defined it here

Putting all of this together, I would think that you could do:

m = component.me_controller
c = m.getCraftables()
aeTag = c[1].getTagCompound()
mcTag = aeTag.getNBTTagCompoundCopy()
aspectID = mcTag.getString("Aspect")

Now, if all of that works, the last caveat is that aspectID is Thaumcrafts internal aspect name, not the name displayed on the item. For example, the aspect "Terra" might be called "earth" internally.
Most names match pretty closely, but some experimentation will be needed to figure them all out.

Let me know how far you can get with this!

commented

Thanks for looking into this. Unfortunately, as I said NBT is not exposed to LUA interface.
As you can see in https://github.com/MightyPirates/OpenComputers/blob/e91b8c0971be399d8b7a4cdd299a52109823cef2/src/main/scala/li/cil/oc/integration/appeng/NetworkControl.scala#L182 only 2 fields are marked with "@callback" annotation - this is all that is visible from LUA. It seems that integration should be added from OC side, perhaps a separate enumeration for the aspect crafting patterns, similar to NetworkControl.getCraftables but with tweaked "Craftable". I'll add a change request in OC repository.