defeatedcrow / HeatAndClimateLib

Mod necessary for defeatedcrow's mod in 1.9.4+
16 stars 6 forks source link

Can I add a climate smelting recipes that have NBT contained output? #28

Open delta-nos opened 2 years ago

delta-nos commented 2 years ago

I'm making addon for my modpack, I tried to add climate smelting recipes: like ore dust -> metal block. Now, I'm trying to implement very variable output with NBT. I refer to HaC recipe implementation and HaCTweaker source code, but I couldn't. So, I would like to ask if I can do with only HaCLib API? Or Do I need to make my own method? Thanks and sorry for checking my question.

defeatedcrow commented 2 years ago

Hello. Of course, it is not possible to add NBT to the output with HaC alone. It's an unsuitable idea for implementation. HaC's climate smelting output only supports IBlockState.

If you do that with HaCLib, I think it's easier to use Vanilla's BlockUpdate method and provide a block replacement system with your unique method than to use HaC's climate smelting. In that case, getting the coordinate climate is supported by HaCLib. Both ClimateAPI and ClimateSurppliar are available. (ClimateSupplier has a lower load.)

The reasons for not supporting NBT are as follows: Climate smelting is a system for changing blocks on the world. And (as a vanilla spec) a block on the world needs a TileEntity to hold the NBT. Therefore, in order for the output to have an NBT, a server-side action that "creates an instance of the corresponding TileEntity and gives it the required NBT" is required. In this case, there will be a dependency on the mod containing the output target TileEntity to implement the recipe. So it cannot be implemented by HaC alone.

In addition, the following vanilla specifications are obstacles: -When replacing a block with another block, vanilla has the property of erasing the contents of the NBT. To fix this, you need to implement a workaround in the target TileEntity. -Since NBT rewriting occurs on the server side, synchronization processing to the client side is required to reflect the change in appearance. This also requires the TileEntity to have a synchronization process.

supplement: TileEntity is an Entity that exists only on the world. In order for the ItemStack on the inventory to have information, it is necessary to implement compatibility with the NBT of the ItemStack. Therefore, if you want to implement the recipe you want, you need to implement the recipe display support to JEI on your own.