I admit it -- I don't get it.
The minion code creates new blocks:
from the following assets, OreonCrop.prefab
and OreonPlant0.block
Then attempts to work with the block later on, but the block is either missing a BlockComponent nor LocationComponent or it will not update properties on OreonCropComponent.
So I added to the prefab the following, hoping unrealistically that this would make a difference (as I'm not sure why defining these on a prefab would magically cause them to get populated rather than being intrinsic components of the block or prefab)
Still not much help.
When I start a new game and try this out,
I only get
However, changes to 114's OreonCropComponent properties are never saved, even when using cropEntity.save(cropComponent);
If I save the game and reload, I suddenly have two of these:
113 will save changes to the cropComponent properties, but never has a BlockComponent or LocationComponent.
114 won't save changes to the properties, but always has the components.
113 seems to be created by
and 114 by the following line of code
I've been trying to debug this for several hours, so my apologies if some of my data is wrong or swapped or incomplete. What I do know is that the current setup does not have both a location-providing component entity and a modifiable crop component entity at the same time. At times, I seemed to have actually found a couple more odd variations of the entity being created, but I did not save that information.
No doubt there is something lacking in my understanding of blocks and prefabs.
The minion code creates new blocks:
Code:
Block newBlock = blockManager.getBlock("miniion:OreonPlant0");
worldProvider.setBlock(new Vector3i(currentTarget.x, y + 1, currentTarget.z), newBlock);
Code:
{
"OreonCrop" = {
"stages" = 7
}
}
Code:
{
"author" : "overdhose",
"basedOn" : "core:plant",
"entity" : {
"prefab" : "miniion:OreonCrop",
"mode" : "persistent"
}
}
So I added to the prefab the following, hoping unrealistically that this would make a difference (as I'm not sure why defining these on a prefab would magically cause them to get populated rather than being intrinsic components of the block or prefab)
Code:
,
LocationComponent : {},
BlockComponent : {}
When I start a new game and try this out,
Code:
for (EntityRef cropEntity : entityManager.getEntitiesWith(OreonCropComponent.class)){
Code:
EntityRef{id = 114, prefab = 'Miniion:OreonCrop'}
If I save the game and reload, I suddenly have two of these:
Code:
EntityRef{id = 113, netId = 0, prefab = 'engine:blockType'}
EntityRef{id = 114, prefab = 'Miniion:OreonCrop'}
114 won't save changes to the properties, but always has the components.
113 seems to be created by
Code:
Block newBlock = blockManager.getBlock("miniion:OreonPlant0");
Code:
worldProvider.setBlock(new Vector3i(currentTarget.x, y + 1, currentTarget.z), newBlock);
No doubt there is something lacking in my understanding of blocks and prefabs.