Jump to content

Recommended Posts

Posted

I've found that a lot of base game shapes force pre-set textures. So i'm not sure how you get around this issue. For example I'm working on Chopped Flower

 

code:

{
	code: "rawcatmint",
	maxstacksize: 64,
	variantgroups: [
		{ code: "type", states: ["chopped", "dried" ] },
	],
	attributes: {
                defaultType: "dried",		
                onDisplayTransform: {
			        origin: { x: 0.5, y: 0, z: 0.5 },
			        scale: 0.58
		},
		displaycaseable: true,
		shelvable: true,
	},
    shape: { base: "game:item/resource/haybundle" },
	texturesByType: {
	 	"chopped": { base: "block/hay/normal-side" },
        "dried": { base: "block/hay/normal-side" }
	},
	creativeinventory: { "general": ["*"], "items": ["*"] },
	nutritionPropsByType: {
	 	"chopped": { satiety: 1000, health: 0, foodcategory: "Protein" },
	 	"dried": { satiety: 800, health: 0, foodcategory: "Protein" }
	},
	transitionablePropsByType: {
		"chopped": [{
			type: "Perish",
			freshHours: { avg: 66 },
			transitionHours: { avg: 18 },
			transitionedStack: { type: "item", code: "rot" },
			transitionRatio: 4
		},	{
				type: "Dry",
				freshHours: { avg: 0 },
				transitionHours: { avg: 48 },
				transitionedStack: { type: "item", code: "catmint-dried" },
				transitionRatio: 1
			}
		],
		"dried": [{
			type: "Perish",
			freshHours: { avg: 1000 },
			transitionHours: { avg: 48 },
			transitionedStack: { type: "item", code: "rot" },
			transitionRatio: 4
		}],
	},
	guiTransform: {
		translation: { x: 0, y: 0, z: 0 },
		rotation: { x: 120, y: 41, z: 7 },
		origin: { x: 0.5, y: 0.11, z: 0.47 },
		scale: 2.15
	},
	fpHandTransform: {
		translation: { x: 0, y: 0, z: 0 },
		rotation: { x: 40, y: 91, z: 15 },
		origin: { x: 0.8, y: 0.4, z: 0 },
		scale: 1.47
	},
	groundTransform: {
		translation: { x: 0, y: 0, z: 0 },
		rotation: { x: 180, y: 33, z: -180 },
		origin: { x: 0.5, y: 0, z: 0.5 },
		scale: 2.5
	},
	tpHandTransform: {
		translation: { x: 0, y: 0, z: 0 },
		rotation: { x: 5, y: 41, z: -31 },
		origin: { x: 0.16, y: 0.05, z: 0.08 },
		scale: 0.44
	}
}

I've been fighting this thing all night. I just want to use the games shape and use my own texture. Honestly why is this so hard? I told it to use the games shape and my texture via code. Not sure I understand the issue 

Posted (edited)
5 hours ago, Micah Holmes said:

Not sure I understand the issue

You are using byType incorrectly. Have a look at this wiki tutorial to see the correct syntax.

Edited by Brady_The
Posted

This is confusing or rather does not tell the full story

 

Sample suggested:

"texturesbytype": {
	"*-good": {
		"all": { "base": "block/shiny{type}texture" }
	},
	"*-used": {
		"all": { "base": "block/shiny{type}texture-damaged" }
	}
},

This sample does not show where "good" or "used" came from via code. Does not show you where the variable or "variant" was declared. It also does not show you where {type} is declared.  I understand the concept the tut is attempting to share but its not giving the full picture nor is it giving the full code sample. 

 

I did alter my code to be more like this code but now get errors related to the texture path. 

code:

{
	code: "rawcatmint",
	maxstacksize: 64,
	variantgroups: [
		{ code: "type", states: ["-chopped", "-dried" ] },
	],
	attributes: {		
                onDisplayTransform: {
			        origin: { x: 0.5, y: 0, z: 0.5 },
			        scale: 0.58
		},
		displaycaseable: true,
		shelvable: true,
	},
    shape: { base: "game:item/resource/haybundle" },
	texturesByType: {
	 	"*-chopped": { base: "block/hay/normal-side" },
        "*-dried": { base: "block/hay/normal-side" }
	},
	creativeinventory: { "general": ["*"], "items": ["*"] },
	nutritionPropsByType: {
	 	"*-chopped": { satiety: 1000, health: 0, foodcategory: "Protein" },
	 	"*-dried": { satiety: 800, health: 0, foodcategory: "Protein" }
	},
	transitionablePropsByType: {
		"*-chopped": [{
			type: "Perish",
			freshHours: { avg: 66 },
			transitionHours: { avg: 18 },
			transitionedStack: { type: "item", code: "rot" },
			transitionRatio: 4
		},	{
				type: "Dry",
				freshHours: { avg: 0 },
				transitionHours: { avg: 48 },
				transitionedStack: { type: "item", code: "catmint-dried" },
				transitionRatio: 1
			}
		],
		"*-dried": [{
			type: "Perish",
			freshHours: { avg: 1000 },
			transitionHours: { avg: 48 },
			transitionedStack: { type: "item", code: "rot" },
			transitionRatio: 4
		}],
	},
	guiTransform: {
		translation: { x: 0, y: 0, z: 0 },
		rotation: { x: 120, y: 41, z: 7 },
		origin: { x: 0.5, y: 0.11, z: 0.47 },
		scale: 2.15
	},
	fpHandTransform: {
		translation: { x: 0, y: 0, z: 0 },
		rotation: { x: 40, y: 91, z: 15 },
		origin: { x: 0.8, y: 0.4, z: 0 },
		scale: 1.47
	},
	groundTransform: {
		translation: { x: 0, y: 0, z: 0 },
		rotation: { x: 180, y: 33, z: -180 },
		origin: { x: 0.5, y: 0, z: 0.5 },
		scale: 2.5
	},
	tpHandTransform: {
		translation: { x: 0, y: 0, z: 0 },
		rotation: { x: 5, y: 41, z: -31 },
		origin: { x: 0.16, y: 0.05, z: 0.08 },
		scale: 0.44
	}
}

My current objective is to simply use or set the texture the object will use based on "state" or "variant". Here is the original code this object is based on:

code:

{
	code: "pemmican",
	enabled: true,
	maxstacksize: 64,
	variantgroups: [
		{ code: "state", states: ["raw-basic", "raw-salted", "dried-basic", "dried-salted" ] },
	],
	attributes: {
		onDisplayTransform: {
			origin: { x: 0.5, y: 0, z: 0.5 },
			scale: 0.58
		},
		displaycaseable: true,
		shelvable: true,
	},
	shape: { base: "item/food/pemmican" },
	texturesByType: {
	 	"*-dried-*": { 
			"pemmican": {base: "item/food/pemmican-dried"}
		}
	},
	creativeinventory: { "general": ["*"], "items": ["*"] },
	nutritionPropsByType: {
	 	"*-raw-*": { satiety: 1000, health: 0, foodcategory: "Protein" },
	 	"*-dried-*": { satiety: 800, health: 0, foodcategory: "Protein" }
	},
	transitionablePropsByType: {
		"*-raw-basic": [{
			type: "Perish",
			freshHours: { avg: 66 },
			transitionHours: { avg: 18 },
			transitionedStack: { type: "item", code: "rot" },
			transitionRatio: 4
		},	{
				type: "Dry",
				freshHours: { avg: 0 },
				transitionHours: { avg: 48 },
				transitionedStack: { type: "item", code: "pemmican-dried-basic" },
				transitionRatio: 1
			}
		],
		"*-raw-salted": [{
			type: "Perish",
			freshHours: { avg: 96 },
			transitionHours: { avg: 24 },
			transitionedStack: { type: "item", code: "rot" },
			transitionRatio: 2
		},	{
				type: "Dry",
				freshHours: { avg: 0 },
				transitionHours: { avg: 48 },
				transitionedStack: { type: "item", code: "pemmican-dried-salted" },
				transitionRatio: 1
			}
		],
		"*-dried-basic": [{
			type: "Perish",
			freshHours: { avg: 1000 },
			transitionHours: { avg: 48 },
			transitionedStack: { type: "item", code: "rot" },
			transitionRatio: 4
		}],
		"*-dried-salted": [{
			type: "Perish",
			freshHours: { avg: 2000 },
			transitionHours: { avg: 96 },
			transitionedStack: { type: "item", code: "rot" },
			transitionRatio: 2
		}],
	},
	guiTransform: {
		translation: { x: 2, y: 0, z: 0 },
		rotation: { x: 149, y: -36, z: 0 },
		origin: { x: 0.5, y: 0.1, z: 0.5 },
		scale: 2.7
	},
	fpHandTransform: {
		translation: { x: 0, y: 0.1, z: 0 },
		rotation: { x: 65, y: 21, z: -6 },
		origin: { x: 0.5, y: 0.1, z: 0.5 },
		scale: 2.15
	},
	tpHandTransform: {
		translation: { x: -0.77, y: -0.15, z: -0.64 },
		rotation: { x: 0, y: -21, z: 18 },
		origin: { x: 0.5, y: 0.1, z: 0.5 },
		scale: 0.75
	},
	groundTransform: {
		translation: { x: 0, y: 0, z: 0 },
		rotation: { x: 0, y: 0, z: 0 },
		origin: { x: 0.5, y: 0, z: 0.5 },
		scale: 3.3
	}
}

My objective for this object is ultimately to do two things: make a item that is "dryable" and ability to use a different texture when dried. However, I do appreciate the help i am getting on here but if you want to help, please just point out the issues with answers to my logic issues. Yes totally asking for spoon feed answer. But there is no answers online to research unfortunately to self help. We really need a dedicated forum section to Mod development for Q&A directly related to development (code). 

Posted (edited)

Here is the working code:

{
	code: "rawcatmint",
	maxstacksize: 64,
	variantgroups: [
		{ code: "type", states: ["cut", "dried" ] },
	],
	attributes: {		
                onDisplayTransform: {
			        origin: { x: 0.5, y: 0, z: 0.5 },
			        scale: 0.58
		},
		displaycaseable: true,
		shelvable: true,
	},
    shape: { base: "game:item/resource/haybundle" },
	texturesByType: {
	 	"*cut":{"bundle": { base: "block/rawcatmint/cut" }},
        "*dried": {"bundle":{ base: "block/rawcatmint/dried" }}
	},
	creativeinventory: { "general": ["*"], "items": ["*"] },
	nutritionPropsByType: {
	 	"*cut": { satiety: 20, health: 0, foodcategory: "Vegetable" },
	 	"*dried": { satiety: 10, health: 0, foodcategory: "Vegetable" }
	},
	transitionablePropsByType: {
		"*cut": [{
			type: "Perish",
			freshHours: { avg: 66 },
			transitionHours: { avg: 18 },
			transitionedStack: { type: "item", code: "rot" },
			transitionRatio: 4
		},	{
				type: "Dry",
				freshHours: { avg: 0 },
				transitionHours: { avg: 48 },
				transitionedStack: { type: "item", code: "catmint-dried" },
				transitionRatio: 1
			}
		],
		"*dried": [{
			type: "Perish",
			freshHours: { avg: 1000 },
			transitionHours: { avg: 48 },
			transitionedStack: { type: "item", code: "rot" },
			transitionRatio: 4
		}],
	},
	guiTransform: {
		translation: { x: 0, y: 0, z: 0 },
		rotation: { x: 120, y: 41, z: 7 },
		origin: { x: 0.5, y: 0.11, z: 0.47 },
		scale: 2.15
	},
	fpHandTransform: {
		translation: { x: 0, y: 0, z: 0 },
		rotation: { x: 40, y: 91, z: 15 },
		origin: { x: 0.8, y: 0.4, z: 0 },
		scale: 1.47
	},
	groundTransform: {
		translation: { x: 0, y: 0, z: 0 },
		rotation: { x: 180, y: 33, z: -180 },
		origin: { x: 0.5, y: 0, z: 0.5 },
		scale: 2.5
	},
	tpHandTransform: {
		translation: { x: 0, y: 0, z: 0 },
		rotation: { x: 5, y: 41, z: -31 },
		origin: { x: 0.16, y: 0.05, z: 0.08 },
		scale: 0.44
	}
}

 

 

Couple things I want to point out for others. I used hay bundle for my shape. If you opent he logic for that shape, you will see two texture options.

shape: { base: "game:item/resource/haybundle" },

If you look at my code and look at the hay bundle shape logic you will see how I adjusted mine but used their base names when defining my version of the texture to use:

texturesByType: {
	 	"*cut":{"bundle": { base: "block/rawcatmint/cut" }},
        "*dried": {"bundle":{ base: "block/rawcatmint/dried" }}

Key word here is "bundle". I did not know this is how you use base game shapes to give them different textures (Live and Learn). This is something to keep in mind to prevent your self from having mental meltdowns. Hope this helps. 

Edited by Micah Holmes
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.