Jump to content

Adding New Materials as Forge Inputs through XML?


Recommended Posts

Hello all,

 

        I am relatively new to XML modding but have down modding in other games such as COD 4 and Halo.  I am looking for a way, if it is possible, to add new input materials to the forge through the XML files so that it is client friendly and requires no additional downloads for them.  I have gotten my new materials to show up in the forge's "available materials" window and added the materials/recipes/items to the XML files but they do not burn in when I place them in the forge.  If I change the "forge_category" of my new materials to iron or lead it smelts in just fine.   I was wondering if that is something that is hard coded in or if I am missing a line of code somewhere to do it.

 

Thanks for any help and if you need more information, please let me know!

 

-alf

Link to post
Share on other sites

An indented paragraph on a forum post?? What madness is this! Lol..

I believe you need a wildcard recipe for it to smelt into an item.
 


<recipe name="resourceClayLump" count="1" tooltip="ttScrapMetalBrass" always_unlocked="true" tags="salvageScrap"> <wildcard_forge_category /> </recipe>

 

Try making the resource you want it to burn into to be where resourceClayLump is. Then the material of the object has to line up with that name in materials.xml, and finally add that material to the item in items.xml. I haven't done this myself, but i remember that being part of it in previous alphas, as well as having to make the UI changes for it to show up.

Link to post
Share on other sites

I apologize for the double post but I can't seem to find the edit post option 😕

 

I tried the above and it was unsuccessful, I'll put all my code below so you can see if I'm missing something I'm not seeing.  I've looked through every XML file for anything relating to the forge and modified what I thought needed it.

 

Thanks!

 

Edit: I guess there is a time limit on editing? xD I forgot to mention that for some reason this code prevents the 2nd input slot from working correctly, the item just sits there and does not burn in.  I tested it on brass and other things.  I'm at a complete loss as to why this happens, so any help with that would be appreciated too!

 

Blocks.XML

Spoiler

    <!-- Add Chromium and Nickel to Forge accepted inputs -->
    <append xpath="/blocks/block[@name='forge']/property[@class='Workstation']/property[@name='InputMaterials']/@value">,chromium,nickel</append>

 

 

 

 

Items.XML

Spoiler

<item name="resourceChromium">
            <property name="HoldType" value="45"/>
            <property name="Tags" value="chromium"/>
            <property name="Meshfile" value="#Other/Items?Misc/sackPrefab.prefab"/>
            <property name="DropMeshfile" value="#Other/Items?Misc/sack_droppedPrefab.prefab"/>
            <property name="Material" value="MresourceChromium"/>
            <property name="Stacknumber" value="1800"/>
            <property name="EconomicValue" value="20"/>
            <property name="EconomicBundleSize" value="10"/>
            <property name="CraftingIngredientTime" value="5"/>
            <property name="Group" value="Resources"/>
            <property name="Weight" value="1"/>
            <property name="CustomIcon" value="resourceSilverNugget"/>
            <property name="CustomIconTint" value="b0b0b0"/>
            <property name="DescriptionKey" value="resourceChromiumDesc"/>
        </item>
            <item name="resourceNickel">
            <property name="HoldType" value="45"/>
            <property name="Tags" value="nickel"/>
            <property name="Meshfile" value="#Other/Items?Misc/sackPrefab.prefab"/>
            <property name="DropMeshfile" value="#Other/Items?Misc/sack_droppedPrefab.prefab"/>
            <property name="Material" value="MresourceNickel"/>
            <property name="Stacknumber" value="800"/>
            <property name="EconomicValue" value="20"/>
            <property name="EconomicBundleSize" value="10"/>
            <property name="CraftingIngredientTime" value="5"/>
            <property name="Group" value="Resources"/>
            <property name="Weight" value="1"/>
            <property name="CustomIcon" value="resourceOilShale"/>
            <property name="CustomIconTint" value="b0b0b0"/>
            <property name="DescriptionKey" value="resourceNickelDesc"/>
        </item>


        <item name="unit_chromium">
            <property name="Extends" value="unit_iron"/>
            <property name="CustomIcon" value="resourceSilverNugget"/>
            <property name="CustomIconTint" value="b0b0b0"/>
            <property name="Material" value="Mbrass"/>
            <property name="MeltTimePerUnit" value="0.4"/>
            <property name="CreativeMode" value="None"/>
        </item>
        <item name="unit_nickel">
            <property name="Extends" value="unit_iron"/>
            <property name="CustomIcon" value="resourceOilShale"/>
            <property name="CustomIconTint" value="b0b0b0"/>
            <property name="Material" value="MresourceNickel"/>
            <property name="MeltTimePerUnit" value="0.4"/>
            <property name="CreativeMode" value="None"/>
        </item>

 

Materials.XML

Spoiler

            <material id="MresourceChromium">
                <property name="damage_category" value="metal"/>
                <property name="surface_category" value="metal"/>
                <property name="forge_category" value="chromium"/>
                <property name="Experience" value="25"/>
            </material>
            <material id="MresourceNickel">
                <property name="damage_category" value="metal"/>
                <property name="surface_category" value="metal"/>
                <property name="forge_category" value="nickel"/>
                <property name="Experience" value="40"/>
            </material>

 

Recipes.XML

Spoiler

<!-- Add Wildcard Forge Recipes for Chromium and Nickel -->
        <recipe name="resourceChromium" count="1" tooltip="ttScrapMetalBrass" always_unlocked="true" tags="salvageScrap"> <wildcard_forge_category /> </recipe>
        <recipe name="resourceNickel" count="1" tooltip="ttScrapMetalBrass" always_unlocked="true" tags="salvageScrap"> <wildcard_forge_category /> </recipe>

 

        <!-- Add Forge empyting Recipes for Chromium and Nickel -->
        <recipe name="resourceChromium" count="1" material_based="true" craft_area="forge" craft_time="1" craft_exp_gain="0" always_unlocked="true" use_ingredient_modifier="false">
            <ingredient name="unit_chromium" count="1"/>
        </recipe>
        <recipe name="resourceNickel" count="1" material_based="true" craft_area="forge" craft_time="1" craft_exp_gain="0" always_unlocked="true" use_ingredient_modifier="false">
            <ingredient name="unit_nickel" count="1"/>
        </recipe>

 

in the XUI folder, windows.XML

Spoiler

    <append xpath="/windows/window[@name='windowForgeInput']/@materials_accepted">,chromium,nickel</append>
    <set xpath="/windows/window[@name='windowForgeInput']/rect[@name='content2']/grid/@rows">8</set>

 

Edited by alffr0mm3lmac
Adding in a small bug? that happens with the above code (see edit history)
Link to post
Share on other sites
1 hour ago, alffr0mm3lmac said:

I apologize for the double post but I can't seem to find the edit post option 😕

 

I tried the above and it was unsuccessful, I'll put all my code below so you can see if I'm missing something I'm not seeing.  I've looked through every XML file for anything relating to the forge and modified what I thought needed it.

 

Thanks!

 

Edit: I guess there is a time limit on editing? xD I forgot to mention that for some reason this code prevents the 2nd input slot from working correctly, the item just sits there and does not burn in.  I tested it on brass and other things.  I'm at a complete loss as to why this happens, so any help with that would be appreciated too!

 

Blocks.XML

  Reveal hidden contents

    <!-- Add Chromium and Nickel to Forge accepted inputs -->
    <append xpath="/blocks/block[@name='forge']/property[@class='Workstation']/property[@name='InputMaterials']/@value">,chromium,nickel</append>

 

 

 

 

Items.XML

  Reveal hidden contents

<item name="resourceChromium">
            <property name="HoldType" value="45"/>
            <property name="Tags" value="chromium"/>
            <property name="Meshfile" value="#Other/Items?Misc/sackPrefab.prefab"/>
            <property name="DropMeshfile" value="#Other/Items?Misc/sack_droppedPrefab.prefab"/>
            <property name="Material" value="MresourceChromium"/>
            <property name="Stacknumber" value="1800"/>
            <property name="EconomicValue" value="20"/>
            <property name="EconomicBundleSize" value="10"/>
            <property name="CraftingIngredientTime" value="5"/>
            <property name="Group" value="Resources"/>
            <property name="Weight" value="1"/>
            <property name="CustomIcon" value="resourceSilverNugget"/>
            <property name="CustomIconTint" value="b0b0b0"/>
            <property name="DescriptionKey" value="resourceChromiumDesc"/>
        </item>
            <item name="resourceNickel">
            <property name="HoldType" value="45"/>
            <property name="Tags" value="nickel"/>
            <property name="Meshfile" value="#Other/Items?Misc/sackPrefab.prefab"/>
            <property name="DropMeshfile" value="#Other/Items?Misc/sack_droppedPrefab.prefab"/>
            <property name="Material" value="MresourceNickel"/>
            <property name="Stacknumber" value="800"/>
            <property name="EconomicValue" value="20"/>
            <property name="EconomicBundleSize" value="10"/>
            <property name="CraftingIngredientTime" value="5"/>
            <property name="Group" value="Resources"/>
            <property name="Weight" value="1"/>
            <property name="CustomIcon" value="resourceOilShale"/>
            <property name="CustomIconTint" value="b0b0b0"/>
            <property name="DescriptionKey" value="resourceNickelDesc"/>
        </item>


        <item name="unit_chromium">
            <property name="Extends" value="unit_iron"/>
            <property name="CustomIcon" value="resourceSilverNugget"/>
            <property name="CustomIconTint" value="b0b0b0"/>
            <property name="Material" value="Mbrass"/>
            <property name="MeltTimePerUnit" value="0.4"/>
            <property name="CreativeMode" value="None"/>
        </item>
        <item name="unit_nickel">
            <property name="Extends" value="unit_iron"/>
            <property name="CustomIcon" value="resourceOilShale"/>
            <property name="CustomIconTint" value="b0b0b0"/>
            <property name="Material" value="MresourceNickel"/>
            <property name="MeltTimePerUnit" value="0.4"/>
            <property name="CreativeMode" value="None"/>
        </item>

 

Materials.XML

  Reveal hidden contents

            <material id="MresourceChromium">
                <property name="damage_category" value="metal"/>
                <property name="surface_category" value="metal"/>
                <property name="forge_category" value="chromium"/>
                <property name="Experience" value="25"/>
            </material>
            <material id="MresourceNickel">
                <property name="damage_category" value="metal"/>
                <property name="surface_category" value="metal"/>
                <property name="forge_category" value="nickel"/>
                <property name="Experience" value="40"/>
            </material>

 

Recipes.XML

  Reveal hidden contents

<!-- Add Wildcard Forge Recipes for Chromium and Nickel -->
        <recipe name="resourceChromium" count="1" tooltip="ttScrapMetalBrass" always_unlocked="true" tags="salvageScrap"> <wildcard_forge_category /> </recipe>
        <recipe name="resourceNickel" count="1" tooltip="ttScrapMetalBrass" always_unlocked="true" tags="salvageScrap"> <wildcard_forge_category /> </recipe>

 

        <!-- Add Forge empyting Recipes for Chromium and Nickel -->
        <recipe name="resourceChromium" count="1" material_based="true" craft_area="forge" craft_time="1" craft_exp_gain="0" always_unlocked="true" use_ingredient_modifier="false">
            <ingredient name="unit_chromium" count="1"/>
        </recipe>
        <recipe name="resourceNickel" count="1" material_based="true" craft_area="forge" craft_time="1" craft_exp_gain="0" always_unlocked="true" use_ingredient_modifier="false">
            <ingredient name="unit_nickel" count="1"/>
        </recipe>

 

in the XUI folder, windows.XML

  Reveal hidden contents

    <append xpath="/windows/window[@name='windowForgeInput']/@materials_accepted">,chromium,nickel</append>
    <set xpath="/windows/window[@name='windowForgeInput']/rect[@name='content2']/grid/@rows">8</set>

 

 

 

Hi alffr0mm3lmac

 

 

I have checked the files and there are some changes you can make and see if it works, be sure to back up your files.

 

1- Blocks.xml goes like this:

 

<set xpath = "/ blocks / block [@ name = 'forge'] / property [@ class = 'Workstation'] / property [@ name = 'InputMaterials'] / @ value"> iron, brass, lead, glass, stone, clay, chromium, nickel </set>

 

2-In items.xml unit_chromium should have Material = MresourceChromium and should not have this code <property name = "MeltTimePerUnit" value = "0.4" />.
You also have to add another material because resourceChromium and Nickel have the same material as unit_chromium and nickel, you can change it to MresourceChromiumFragment and MresourceNickelFragment, add the new material in Materials.xml and change it to resources.

 

Example:
 <material id = "MresourceChromiumFragment">
    <property name = "damage_category" value = "metal" />
    <property name = "surface_category" value = "metal" />
    <property name = "forge_category" value = "chromium" />
    <property name = "Hardness" type = "float" value = "1" />
    <property name = "stepsound" value = "metal" />
    <property name = "stability_glue" value = "120" />
    <property name = "Mass" type = "int" value = "10" />
    <property name = "MaxDamage" value = "500" />
</material>

 

3-In XUi.xml it goes like this:

<set xpath = "/ windows / window [@ name = 'windowForgeInput'] / @ materials_accepted"> iron, brass, lead, glass, stone, clay, chromium, nickel </set>

 

I hope I have explained myself in the best way and that it helps you.
Regards

 

P. D.    In the right corner of your post (above) there are 3 white points, press and it will give you the option to edit.

Edited by Gouki (see edit history)
Link to post
Share on other sites
2 hours ago, Gouki said:

<set xpath = "/ blocks / block [@ name = 'forge'] / property [@ class = 'Workstation'] / property [@ name = 'InputMaterials'] / @ value"> iron, brass, lead, glass, stone, clay, chromium, nickel </set>

 

3-In XUi.xml it goes like this:

<set xpath = "/ windows / window [@ name = 'windowForgeInput'] / @ materials_accepted"> iron, brass, lead, glass, stone, clay, chromium, nickel </set>

 

I believe these are logically the same end result as what I had, I tried it this way and still to no avail.

 

2 hours ago, Gouki said:

2-In items.xml unit_chromium should have Material = MresourceChromium and should not have this code <property name = "MeltTimePerUnit" value = "0.4" />.
You also have to add another material because resourceChromium and Nickel have the same material as unit_chromium and nickel, you can change it to MresourceChromiumFragment and MresourceNickelFragment, add the new material in Materials.xml and change it to resources.

 

Example:
 <material id = "MresourceChromiumFragment">
    <property name = "damage_category" value = "metal" />
    <property name = "surface_category" value = "metal" />
    <property name = "forge_category" value = "chromium" />
    <property name = "Hardness" type = "float" value = "1" />
    <property name = "stepsound" value = "metal" />
    <property name = "stability_glue" value = "120" />
    <property name = "Mass" type = "int" value = "10" />
    <property name = "MaxDamage" value = "500" />
</material>

 

I'm a little confused why I would need a second material as MresourceClayLump is used for both unit_clay and resourceClayLump.  I tried to add a second material for each regardless and still no dice :( Thanks for the help though!! 

 

Maybe my issue is related to the forge only having one usable input when I do the above code 🤔

 

Edit: Just for giggles, I removed stone and clay from the accepted inputs and put the grid back to 6 and it cooks in the chromium and nickel so I'm not sure what is missing lol

 

Edit 2: Everything burns out correctly too 🤔

Edited by alffr0mm3lmac
did a small test (see edit history)
Link to post
Share on other sites
13 minutes ago, bdubyah said:

This is something I haven't done personally, so I can't help. But this is a link to a mod that added new resources to the forges and stuff. Could maybe take a look at it and see how it did it. Was for A18 but it should still be current.

 

 

oh sweet!  I looked through some mods on here but didn't find anything.  I narrowed down the "only one smelter input" working thing to this line - "<append xpath="/blocks/block[@name='forge']/property[@class='Workstation']/property[@name='InputMaterials']/@value">,chromium,nickel</append> " adding the two extra materials here seems to mess it up

Link to post
Share on other sites
7 minutes ago, alffr0mm3lmac said:

oh sweet!  I looked through some mods on here but didn't find anything.  I narrowed down the "only one smelter input" working thing to this line - "<append xpath="/blocks/block[@name='forge']/property[@class='Workstation']/property[@name='InputMaterials']/@value">,chromium,nickel</append> " adding the two extra materials here seems to mess it up

Hello!  I’m currently maintaining this modlet. I don’t remember but I think some updates (small) were made to get this to work in a19.x. I really haven’t looked at the XML other than adding others patches. Once a20 drops I’ll be in there fixing/commenting/ etc.

 

the “latest” a19.x version of it is here:

https://github.com/doughphunghus/MeanCloud_7DtD


Edit: I do believe there are some “bugs” I have found while playing it. I made issues on GitHub to track them for fixing in a20. One that you may want to consider is the “cannot empty forge of zinc and copper”.  I don’t know if it’s fixable or just needs to be added as a “forge recipe”.

Edited by doughphunghus (see edit history)
Link to post
Share on other sites

I looked through the files and noticed there was a file called mining.unity3d.  Do you know if this is where it changes the max input materials from 6?  I already have done what is done in this mod other than this one file (and the icons and prefabs I'm not counting since I didn't make any new ones)

 

Edit: If it is done using that unity file I'll probably just add a second forge type workstation that only does my new resources, should work fine, but it'd be really sweet if it all could be in one :)

 

Edit 2: I tried all the files except the unity file and get a smorgasbord of errors xD I suppose it is necessary :(

Edited by alffr0mm3lmac (see edit history)
Link to post
Share on other sites
1 hour ago, alffr0mm3lmac said:

I looked through the files and noticed there was a file called mining.unity3d.  Do you know if this is where it changes the max input materials from 6?  I already have done what is done in this mod other than this one file (and the icons and prefabs I'm not counting since I didn't make any new ones)

 

Edit: If it is done using that unity file I'll probably just add a second forge type workstation that only does my new resources, should work fine, but it'd be really sweet if it all could be in one :)

 

Edit 2: I tried all the files except the unity file and get a smorgasbord of errors xD I suppose it is necessary :(

I actually don’t know if this file is literally required for the forge.  My guess would be that it’s for the mining machines in the mod.  I don’t have the source for the unity files so I would have to have help disassembling and reassembling them. The mod author seemed like he was “done” with the game so I’m going to try to maintain it as long as possible without the source files for the unity files :(.  If you just removed that file and loaded the mod it would likely error quite a bit.  If you can’t get your mod working I can look into it this weekend to see what I can figure out. 

Edited by doughphunghus (see edit history)
Link to post
Share on other sites
2 hours ago, doughphunghus said:

I actually don’t know if this file is literally required for the forge.  My guess would be that it’s for the mining machines in the mod.  I don’t have the source for the unity files so I would have to have help disassembling and reassembling them. The mod author seemed like he was “done” with the game so I’m going to try to maintain it as long as possible without the source files for the unity files :(.  If you just removed that file and loaded the mod it would likely error quite a bit.  If you can’t get your mod working I can look into it this weekend to see what I can figure out. 

I hope I didn't get you too worried 😕 I'm not 100% sure what I did differently this time (I think maybe I had the unit_nickel and resourceNickel materials backwords) but it is working correctly now! Thank you so much!!

 

7 hours ago, Gouki said:

You also have to add another material because resourceChromium and Nickel have the same material as unit_chromium and nickel, you can change it to MresourceChromiumFragment and MresourceNickelFragment, add the new material in Materials.xml and change it to resources.

 

Example:
 <material id = "MresourceChromiumFragment">
    <property name = "damage_category" value = "metal" />
    <property name = "surface_category" value = "metal" />
    <property name = "forge_category" value = "chromium" />
    <property name = "Hardness" type = "float" value = "1" />
    <property name = "stepsound" value = "metal" />
    <property name = "stability_glue" value = "120" />
    <property name = "Mass" type = "int" value = "10" />
    <property name = "MaxDamage" value = "500" />
</material>

 

 

 

You were right about this part I believe, I think the issue was I had them named incorrectly when I tried it the first time, but thank you for the help!!

Link to post
Share on other sites

doughphunghus, to get copper and zinc back out of the Meancloud Mining forge, add the following code to recipes.xml:

 

    <recipe name="resourceCopper" count="1" material_based="true" craft_area="forge" craft_time="1" craft_exp_gain="0" always_unlocked="true" use_ingredient_modifier="false">
        <ingredient name="unit_copper" count="5"/>
    </recipe>

    <recipe name="resourceZinc" count="1" material_based="true" craft_area="forge" craft_time="1" craft_exp_gain="0" always_unlocked="true" use_ingredient_modifier="false">
        <ingredient name="unit_zinc" count="5"/>
    </recipe>

 

That's worked for me in A18 and A19.

 

alffr0mm3lmac, it looks like windows.xml in the XUi folder has the code that you need for going above 6 material inputs for the forge. The comments are very helpful.

 

<MeanCloud_Mining>
  <!-- add 3rd input slot -->
  <set xpath="/windows/window[@name='windowForgeInput']/@height">279</set>
  <set xpath="/windows/window[@name='windowForgeInput']/sprite[@name='backgroundMain']/@height">228</set>
  <set xpath="/windows/window[@name='windowForgeInput']/rect[@name='content']/@height">223</set>
  <set xpath="/windows/window[@name='windowForgeInput']/rect[@name='content']/grid/@rows">3</set>

  <!-- add copper and zinc to accepted forge materials -->
  <!--<append xpath="/windows/window[@name='windowForgeInput']/@materials_accepted">,copper,zinc</append>-->
  <set xpath="/windows/window[@name='windowForgeInput']/@materials_accepted">iron,brass,lead,glass,stone,clay,copper,zinc</set>
  <set xpath="/windows/window[@name='windowForgeInput']/rect[@name='content2']/@height">223</set>
  <set xpath="/windows/window[@name='windowForgeInput']/rect[@name='content2']/grid/@rows">8</set>
  <set xpath="/windows/window[@name='windowForgeInput']/rect[@name='content2']/grid/@cell_height">28</set>

	<append xpath="/windows">
		<!-- 1 extra crafting queue slot -->
		<window name="queue5CraftingQueue" width="397" height="78" panel="Left" cursor_area="true">
			<rect depth="0" pos="19,0" width="378" controller="CraftingQueue">
				<grid name="queue" rows="1" cols="5" pos="3,-13" cell_width="75" cell_height="75" repeat_content="true">
					<recipe_stack name="0"/>
				</grid>
			</rect>
		</window>
		<!-- 6 extra crafting queue slots -->
		<window name="queue10CraftingQueue" width="397" height="78" panel="Left" cursor_area="true">
			<rect depth="0" pos="9,36" width="378" controller="CraftingQueue">
				<grid name="queue" rows="2" cols="5" pos="3,3" cell_width="75" cell_height="75" repeat_content="true">
					<recipe_stack name="0"/>
				</grid>
			</rect>
		</window>
	</append>
</MeanCloud_Mining>

 

I believe the second block of code might be what you're looking for:

  <set xpath="/windows/window[@name='windowForgeInput']/rect[@name='content2']/grid/@rows">8</set>

That matches the 8 materials required once copper and zinc were added to the mix.

 

Edited by Cranberry Monster
added as code for readability (see edit history)
Link to post
Share on other sites
17 hours ago, Cranberry Monster said:

I believe the second block of code might be what you're looking for:

  <set xpath="/windows/window[@name='windowForgeInput']/rect[@name='content2']/grid/@rows">8</set>

That matches the 8 materials required once copper and zinc were added to the mix.

 

Thanks for the idea :) I had done this already and while it did prevent an index out of bounds error they still didn't burn in and my 2nd smelting slot was not usable xD I think it had to do with having two different materials set for each new items, one for unit and one for scrap, oddly enough

Link to post
Share on other sites
On 6/10/2021 at 10:40 PM, Cranberry Monster said:

doughphunghus, to get copper and zinc back out of the Meancloud Mining forge, add the following code to recipes.xml:

 


    <recipe name="resourceCopper" count="1" material_based="true" craft_area="forge" craft_time="1" craft_exp_gain="0" always_unlocked="true" use_ingredient_modifier="false">
        <ingredient name="unit_copper" count="5"/>
    </recipe>

    <recipe name="resourceZinc" count="1" material_based="true" craft_area="forge" craft_time="1" craft_exp_gain="0" always_unlocked="true" use_ingredient_modifier="false">
        <ingredient name="unit_zinc" count="5"/>
    </recipe>

 

That's worked for me in A18 and A19.

@Cranberry Monster: Thanks for the recipes!  I also tried to give/document/credit where it's due when/where I can :).

I have updated the mod on github with this and another bugfix: doughphunghus/MeanCloud_7DtD 's mods

 

  • Like 1
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...