Jump to content

Recommended Posts

Posted

Working on my first VS shape. I got everything working kind of ..... Having a issue where I cant rotate my block and its bleeding through on sides. Not sure how to fix this issue

 

Block code:


{
	code: "workbench",
	class: "Block",
	maxstacksize: 64,
	variantgroups: [
		{ code:"type", states: ["fired"] },
	],
	attributes: { mapColorCode: "settlement" },
	shape: { base: "workbench" },
	//drawtype: "Cube",
	blockmaterial: "Soil",
	creativeinventory: { "general": ["*-fired"], "decorative": ["*-fired"] },
	replaceable: 700,
	resistance: 3,
	lightAbsorption: 99,
	// Must declare textures so they get added to the block texture atlas
	textures: {
		"back": { base: "game:block/wood/workbench/back" },
		"sideleft": { base: "game:block/wood/workbench/left" },
		"sideright": { base: "game:block/wood/workbench/right" },
		"bottom": { base: "game:block/wood/workbench/bottom" },
		"top": { base: "game:block/wood/workbench/top" },
		"fdoor": { base: "game:block/wood/workbench/bottom" }
	},
	drops: [ {
		type: "block",
		code: "workbench-fired",
		quantity: { avg: 0.85, var: 0 }
	} ],
	sounds: {
		place: "game:block/dirt",
		break: "game:block/dirt",
		hit: "game:block/dirt"
	},
	fertility: 3,
	heldTpIdleAnimation: "holdbothhandslarge", heldRightReadyAnimation: "heldblockready", heldTpUseAnimation: "twohandplaceblock",
	tpHandTransform: {
		translation: { x: -1.23, y: -0.91, z: -0.8 },
		rotation: { x: -2, y: 25, z: -78 },
		scale: 0.4
	}
}

Not a finalized version of the block code just a placeholder until i get it all adjusted.

 

shape code:

{
	"editor": {
		"allAngles": false,
		"entityTextureMode": false
	},
	"textureWidth": 16,
	"textureHeight": 16,
	"textureSizes": {
	},
	"textures": {
	},
	"elements": [
		{
			"name": "Back",
			"from": [ 0.0, 0.0, 0.0 ],
			"to": [ 16.0, 16.0, 1.0 ],
			"faces": {
				"north": { "texture": "#back", "uv": [ 0.0, 0.0, 16.0, 16.0 ] },
				"east": { "texture": "#back", "uv": [ 0.0, 0.0, 1.0, 16.0 ] },
				"south": { "texture": "#back", "uv": [ 0.0, 0.0, 16.0, 16.0 ] },
				"west": { "texture": "#back", "uv": [ 0.0, 0.0, 1.0, 16.0 ] },
				"up": { "texture": "#back", "uv": [ 0.0, 0.0, 16.0, 1.0 ] },
				"down": { "texture": "#back", "uv": [ 0.0, 0.0, 16.0, 1.0 ] }
			}
		},
		{
			"name": "side1",
			"from": [ 0.0, 0.0, 1.0 ],
			"to": [ 1.0, 12.0, 16.0 ],
			"rotationOrigin": [ 0.0, 0.0, 1.0 ],
			"faces": {
				"north": { "texture": "#sideleft", "uv": [ 0.0, 0.0, 1.0, 12.0 ] },
				"east": { "texture": "#sideleft", "uv": [ 0.0, 0.0, 15.0, 12.0 ] },
				"south": { "texture": "#sideleft", "uv": [ 0.0, 0.0, 1.0, 12.0 ] },
				"west": { "texture": "#sideleft", "uv": [ 0.0, 0.0, 15.0, 12.0 ] },
				"up": { "texture": "#sideleft", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
				"down": { "texture": "#sideleft", "uv": [ 0.0, 0.0, 1.0, 15.0 ] }
			}
		},
		{
			"name": "side2",
			"from": [ 15.0, 0.0, 1.0 ],
			"to": [ 16.0, 12.0, 16.0 ],
			"rotationOrigin": [ 15.0, 0.0, 1.0 ],
			"faces": {
				"north": { "texture": "#sideright", "uv": [ 0.0, 0.0, 1.0, 12.0 ] },
				"east": { "texture": "#sideright", "uv": [ 0.0, 0.0, 15.0, 12.0 ] },
				"south": { "texture": "#sideright", "uv": [ 0.0, 0.0, 1.0, 12.0 ] },
				"west": { "texture": "#sideright", "uv": [ 0.0, 0.0, 15.0, 12.0 ] },
				"up": { "texture": "#sideright", "uv": [ 0.0, 0.0, 1.0, 15.0 ] },
				"down": { "texture": "#sideright", "uv": [ 0.0, 0.0, 1.0, 15.0 ] }
			}
		},
		{
			"name": "bottom",
			"from": [ 1.0, 0.0, 1.0 ],
			"to": [ 15.0, 1.0, 16.0 ],
			"rotationOrigin": [ 1.0, 0.0, 1.0 ],
			"faces": {
				"north": { "texture": "#bottom", "uv": [ 0.0, 0.0, 10.0, 1.0 ], "autoUv": false },
				"east": { "texture": "#bottom", "uv": [ 0.0, 0.0, 15.0, 1.0 ] },
				"south": { "texture": "#bottom", "uv": [ 0.0, 0.0, 14.0, 1.0 ] },
				"west": { "texture": "#bottom", "uv": [ 0.0, 0.0, 15.0, 1.0 ] },
				"up": { "texture": "#bottom", "uv": [ 0.0, 0.0, 14.0, 15.0 ] },
				"down": { "texture": "#bottom", "uv": [ 0.0, 0.0, 14.0, 15.0 ] }
			}
		},
		{
			"name": "Top",
			"from": [ 0.0, 12.0, 1.0 ],
			"to": [ 16.0, 14.0, 16.0 ],
			"rotationOrigin": [ 0.0, 12.0, 1.0 ],
			"faces": {
				"north": { "texture": "#top", "uv": [ 1.0, 8.5, 17.0, 10.5 ] },
				"east": { "texture": "#top", "uv": [ 0.5, 10.5, 15.5, 12.5 ] },
				"south": { "texture": "#top", "uv": [ 0.0, 3.5, 16.0, 5.5 ] },
				"west": { "texture": "#top", "uv": [ 0.5, 4.5, 15.5, 6.5 ] },
				"up": { "texture": "#top", "uv": [ 0.0, 0.0, 16.0, 15.0 ] },
				"down": { "texture": "#top", "uv": [ 0.0, 0.5, 16.0, 15.5 ] }
			}
		},
		{
			"name": "Door",
			"from": [ 1.0, 1.0, 14.0 ],
			"to": [ 15.0, 12.0, 16.0 ],
			"rotationOrigin": [ 1.0, 1.0, 14.0 ],
			"faces": {
				"north": { "texture": "#fdoor", "uv": [ 0.0, 0.0, 14.0, 11.0 ] },
				"east": { "texture": "#fdoor", "uv": [ 5.5, 3.0, 7.5, 14.0 ] },
				"south": { "texture": "#fdoor", "uv": [ 0.0, 2.0, 14.0, 13.0 ] },
				"west": { "texture": "#fdoor", "uv": [ 2.5, 2.5, 4.5, 13.5 ] },
				"up": { "texture": "#fdoor", "uv": [ 0.0, 0.0, 14.0, 2.0 ] },
				"down": { "texture": "#fdoor", "uv": [ 0.0, 12.0, 14.0, 14.0 ] }
			}
		}
	]}

image.thumb.png.a6f3122803989a23c7ea7f0f00a24a1e.png

Posted

It's bleeding through the sides because you didn't define `sidesolid` and `sideopaque` and you can't rotate it because you didn't add any logic for rotation... this is normally done either through a BlockEntity with custom logic for it or through variants (the latter means it creates a separate block for each orientation)

So you'd end up with something like this:

{
  "code": "workbench",
  "class": "Block",
  "maxstacksize": 64,
  "variantgroups": [
    {
      "code": "type",
      "states": [ "fired" ]
    },

    //Add the extra orientations
    {
      "code": "side",
      "loadFromProperties": "game:abstract/horizontalorientation"
    }
  ],

  //Add behavior to handle logic for selecting the correct orientation to place
  "behaviors": [ { "name": "HorizontalOrientable" } ],

  "attributes": { "mapColorCode": "settlement" },
  "shape": {
    "base": "workbench",

    //Set orientation on shape for each orientation variant
    "rotateYByType": {
      "*-north": 180,
      "*-east": 90,
      "*-south": 0,
      "*-west": 270
    }
  },
  //drawtype: "Cube",
  "blockmaterial": "Soil",
  "creativeinventory": {
    "general": [ "*-fired-north" ],
    "decorative": [ "*-fired-north" ]
  },
  "replaceable": 700,
  "resistance": 3,
  "lightAbsorption": 99,
  // Must declare textures so they get added to the block texture atlas
  "textures": {
    "back": { "base": "game:block/wood/workbench/back" },
    "sideleft": { "base": "game:block/wood/workbench/left" },
    "sideright": { "base": "game:block/wood/workbench/right" },
    "bottom": { "base": "game:block/wood/workbench/bottom" },
    "top": { "base": "game:block/wood/workbench/top" },
    "fdoor": { "base": "game:block/wood/workbench/bottom" }
  },
  "drops": [
    {
      "type": "block",
      "code": "workbench-fired-north",
      "quantity": {
        "avg": 0.85,
        "var": 0
      }
    }
  ],
  "sounds": {
    "place": "game:block/dirt",
    "break": "game:block/dirt",
    "hit": "game:block/dirt"
  },

  //These should be defined to prevent it from assuming the sides are solid and thereby not render the sides of blocks next to it. (aka the bleeding through)
  "sidesolid": { "all": false },
  "sideopaque": { "all": false },

  "fertility": 3,
  "heldTpIdleAnimation": "holdbothhandslarge",
  "heldRightReadyAnimation": "heldblockready",
  "heldTpUseAnimation": "twohandplaceblock",
  "tpHandTransform": {
    "translation": {
      "x": -1.23,
      "y": -0.91,
      "z": -0.8
    },
    "rotation": {
      "x": -2,
      "y": 25,
      "z": -78
    },
    "scale": 0.4
  }
}

 

Posted (edited)

@The Insanity God

Thank you very much. i did a massive code update. Rotating with wrench not working but places in correct directions now. 

New code:

{
	code: "workbench",
	behaviors: [{name: "HorizontalOrientable"}],
	variantgroups: [ { code:"side", loadFromProperties: "game:abstract/horizontalorientation" } ],
	creativeinventory: { "general": ["workbench-north"], "decorative": ["workbench-north"] },
	shapeByType: {
		"*-north": { base: "workbench", rotateY:0 },
		"*-east": { base: "workbench", rotateY:270 },
		"*-south": { base: "workbench", rotateY:180 }, 
		"*-west": { base: "workbench", rotateY:90 }
	},
	replaceable: 500,
	resistance: 1.5,
	lightAbsorption: 99,
	sidesolid: { all: false },
	sideopaque: { all: false },
	textures: {
		"top": { base: "game:block/wood/workbench/top" },
		"bottom": { base: "game:block/wood/workbench/bottom" },
		"fdoor": { base: "game:block/wood/workbench/bottom" },
		"back": { base: "game:block/wood/workbench/back" },
		"sideleft": { base: "game:block/wood/workbench/left" },
		"sideright": { base: "game:block/wood/workbench/right" }
	},
	heldTpIdleAnimation: "holdbothhandslarge", heldRightReadyAnimation: "heldblockready", heldTpUseAnimation: "twohandplaceblock",
	tpHandTransform: {
		translation: { x: -1.23, y: -0.91, z: -0.8 },
		rotation: { x: -2, y: 25, z: -78 },
		scale: 0.4
	}
}

 

Edited by Micah Holmes
Posted (edited)

If you want it to be rotatable with a wrench then you need to add the "WrenchOrientable" behavior:

{
	code: "workbench",
	behaviors: [
      {name: "HorizontalOrientable"},
      {
        name: "WrenchOrientable",
        properties: { basecode: "yourmoddomain:workbench" }
      }
    ],
	variantgroups: [ { code:"side", loadFromProperties: "game:abstract/horizontalorientation" } ],
	creativeinventory: { "general": ["workbench-north"], "decorative": ["workbench-north"] },
	shapeByType: {
		"*-north": { base: "workbench", rotateY:0 },
		"*-east": { base: "workbench", rotateY:270 },
		"*-south": { base: "workbench", rotateY:180 }, 
		"*-west": { base: "workbench", rotateY:90 }
	},
	replaceable: 500,
	resistance: 1.5,
	lightAbsorption: 99,
	sidesolid: { all: false },
	sideopaque: { all: false },
	textures: {
		"top": { base: "game:block/wood/workbench/top" },
		"bottom": { base: "game:block/wood/workbench/bottom" },
		"fdoor": { base: "game:block/wood/workbench/bottom" },
		"back": { base: "game:block/wood/workbench/back" },
		"sideleft": { base: "game:block/wood/workbench/left" },
		"sideright": { base: "game:block/wood/workbench/right" }
	},
	heldTpIdleAnimation: "holdbothhandslarge", heldRightReadyAnimation: "heldblockready", heldTpUseAnimation: "twohandplaceblock",
	tpHandTransform: {
		translation: { x: -1.23, y: -0.91, z: -0.8 },
		rotation: { x: -2, y: 25, z: -78 },
		scale: 0.4
	}
}

note: the content of "basecode" doesn't actually matter it just needs to be unique. (the game uses it as a key/identifier to group the blocks by)

Edited by The Insanity God
Posted

Not to worried about wrench now that i got position working ish. I'll circle back to it later. I added storage to this block but having issues getting textures to work now.

 

code:

{
	code: "workbench",
	class: "BlockGenericTypedContainer",
	entityclass: "GenericTypedContainer",
	behaviors: [{name: "HorizontalOrientable"}],
	variantgroups: [ { code:"side", loadFromProperties: "game:abstract/horizontalorientation" } ],
	creativeinventory: { "general": ["workbench-north"], "decorative": ["workbench-north"] },
	textures: {
		"top": { base: "game:block/wood/workbench/top" },
		"bottom": { base: "game:block/wood/workbench/bottom" },
		"fdoor": { base: "game:block/wood/workbench/bottom" },
		"back": { base: "game:block/wood/workbench/back" },
		"sideleft": { base: "game:block/wood/workbench/left" },
		"sideright": { base: "game:block/wood/workbench/right" }
	},
	attributes: {
		inventoryClassName: "chest",
		defaultType: "normal-generic",
		types: ["normal-generic"],
		handbook: {
			groupBy: ["workbench-*"]
		},
		rotatatableInterval: { "normal-generic": "22.5degnot45deg" },	
		storageType: { "normal-generic": 189 },
		retrieveOnly: { "normal-generic": false },
		shape: { "normal-generic": "workbench" },//does not load textures but places correctly and rotates correctly
		//shape: { base: "workbench" },//loads textures but does not rotate or place correctly
		typedOpenSound: { "normal-generic": "game:sounds/block/largechestopen" },
		typedCloseSound: { "normal-generic": "game:sounds/block/largechestclose" },
		variantByGroup: "side",
		variantByGroupInventory: null
	},
	behaviors: [
		{ name: "Lockable" }, 
		{ name: "Container"}, 
		{ name: "BoatableGenericTypedContainer" }
	],
	shapeInventory: { base: "workbench", rotateY: 270 },
	shapeByType: {
		"*-north": { base: "workbench", rotateY:0 },
		"*-east": { base: "workbench", rotateY:270 },
		"*-south": { base: "workbench", rotateY:180 }, 
		"*-west": { base: "workbench", rotateY:90 }
	},
	replaceable: 500,
	resistance: 1.5,
	lightAbsorption: 99,
	sidesolid: { all: false },
	sideopaque: { all: false },
	textures: {
		"top": { base: "game:block/wood/workbench/top" },
		"bottom": { base: "game:block/wood/workbench/bottom" },
		"fdoor": { base: "game:block/wood/workbench/bottom" },
		"back": { base: "game:block/wood/workbench/back" },
		"sideleft": { base: "game:block/wood/workbench/left" },
		"sideright": { base: "game:block/wood/workbench/right" }
	},
	heldTpIdleAnimation: "holdbothhandslarge", heldRightReadyAnimation: "heldblockready", heldTpUseAnimation: "twohandplaceblock",
	tpHandTransform: {
		translation: { x: -1.23, y: -0.91, z: -0.8 },
		rotation: { x: -2, y: 25, z: -78 },
		scale: 0.4
	}
}

 

I was using chest as a my sample code but I might switch over to a storage vessel. I'm running into a issue I think with shape. Its a damned if you do damned if you don't situation.

 

shape: { "normal-generic": "workbench" },//does not load textures but places correctly and rotates correctly
		//shape: { base: "workbench" },//loads textures but does not rotate or place correctly

The normal generic I think is what I need to use based on chest script. But that breaks my texture settings and does not want to apply my textures. Not sure why. However, If I use the non generic shape it loads my textures but does not place correctly and I don't think storage works. Kind of a weird issue. Not sure how or why shape would have any effect on logic. 

Posted

So remember how earlier I said "this is normally done either through a BlockEntity with custom logic for it or through variants" well the `GenericTypedContainer` would be one of the base game BlockEntities with rotation logic... meaning you now have 2 rotation systems trying to interfere with each other. I know the base game chest also has this but in their case it's to provide legacy support (you can only place down the `east` variant now and it fully uses the BlockEntity rotation)

the reason why the textures don't work is because `GenericTypedContainer` is designed for creating variants through attributes instead of the standard variants system and to achieve this they altered the way textures are defined.
 

{
  "code": "workbench",
  "class": "BlockGenericTypedContainer",
  "entityclass": "GenericTypedContainer",
  "behaviors": [
    { "name": "Lockable" },
    { "name": "Container" },
    { "name": "BoatableGenericTypedContainer" }
  ],
  "creativeinventory": {
    "general": [ "workbench" ],
    "decorative": [ "workbench" ]
  },
  "attributes": {
    "inventoryClassName": "chest",
    "defaultType": "normal-generic",
    "types": [ "normal-generic" ],
    "handbook": {
      "groupBy": [ "workbench" ]
    },
    "rotatatableInterval": { "normal-generic": "22.5degnot45deg" },
    "storageType": { "normal-generic": 189 },
    "retrieveOnly": { "normal-generic": false },
    "shape": { "normal-generic": "workbench" },
    "typedOpenSound": { "normal-generic": "game:sounds/block/largechestopen" },
    "typedCloseSound": { "normal-generic": "game:sounds/block/largechestclose" },
    "variantByGroup": "side",
    "variantByGroupInventory": null
  },
  "shapeInventory": {
    "base": "workbench",
    "rotateY": 270
  },
  //Texture identifiers are prefixed with the type
  "textures": {
    "normal-generic-top": { "base": "game:block/wood/workbench/top" },
    "normal-generic-bottom": { "base": "game:block/wood/workbench/bottom" },
    "normal-generic-fdoor": { "base": "game:block/wood/workbench/bottom" },
    "normal-generic-back": { "base": "game:block/wood/workbench/back" },
    "normal-generic-sideleft": { "base": "game:block/wood/workbench/left" },
    "normal-generic-sideright": { "base": "game:block/wood/workbench/right" }
  },
  "replaceable": 500,
  "resistance": 1.5,
  "lightAbsorption": 99,
  "sidesolid": { "all": false },
  "sideopaque": { "all": false },
  "heldTpIdleAnimation": "holdbothhandslarge",
  "heldRightReadyAnimation": "heldblockready",
  "heldTpUseAnimation": "twohandplaceblock",
  "tpHandTransform": {
    "translation": {
      "x": -1.23,
      "y": -0.91,
      "z": -0.8
    },
    "rotation": {
      "x": -2,
      "y": 25,
      "z": -78
    },
    "scale": 0.4
  }
}

image.thumb.png.567a7d84f07568849dbca96e1ea94116.png

×
×
  • 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.