editor icon indicating copy to clipboard operation
editor copied to clipboard

TemplateContext.player.create() does not work in custom item components

Open SIsilicon opened this issue 2 years ago • 1 comments

Summary Within custom item components' template function, is a template context parameter. This parameter has a player property that allows you to modify the player definition files. However it's create() method does not work.

To Reproduce Steps to reproduce the behavior:

  1. Create a new project. Be sure to enable Holiday Creator Features, and include player.json.
  2. Create a new item. You can use the Blank Item preset.
  3. Create a new custom item component.
  4. Add this code to the component file.
export default defineComponent(({ name, template, schema }) => {
	name('test:test_component')
	schema({})

	template((_, { player }) => {
		player.create({
			'tag:you_should_see_this': {}
		}, 'minecraft:entity/components')
	})
})
  1. Add test:test_component to the custom item.
  2. Forcefully Save everything (including the player.json to be sure)
  3. View the compiler output for player.json

Observed behavior Nothing about player.json has changed in the output.

Expected behavior After every existing component (in this case below minecraft:environment_sensor) the component tag:you_should_see_this should appear.

Platform:

  • OS: Windows 11
  • App Version: v2.2.13

Additional context I haven't tested the other methods of TemplateContext.player, but I'd assume they wouldn't work. Someone would need to confirm this.

SIsilicon avatar Jun 29 '22 01:06 SIsilicon

Update on this: It seems like the player context functions, so animationController, animation and create are all broken. The content that should be in the player file end up in the item file for animationController and animation image

Joelant05 avatar Sep 05 '22 13:09 Joelant05