Skip to content

Commit

Permalink
fix(val): Validation and client entity editor fixes
Browse files Browse the repository at this point in the history
- Allow features in add-on validation
- More interlinking work
- Parse IDs of types and recipes in add-ons
- Render Controller and Client Entity Editor work
- Update to 1.21.50 files
  • Loading branch information
mammerla committed Dec 4, 2024
1 parent 43e3af8 commit a82ae14
Show file tree
Hide file tree
Showing 66 changed files with 3,861 additions and 3,473 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
{
"id": "geometries",
"title": "Geometries",
"undefinedIfEmpty": true,
"description": "Lists of geometries that can be used in selection calculations",
"dataType": 28
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
{
"id": "materials",
"title": "Materials",
"undefinedIfEmpty": true,
"description": "Lists of materials that can be used in selection calculations",
"dataType": 28
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
{
"id": "textures",
"title": "Textures",
"undefinedIfEmpty": true,
"description": "Lists of textures that can be used in selection calculations",
"dataType": 28
}
Expand Down
2 changes: 1 addition & 1 deletion app/reslist/packs-preview.resources.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"url": "https://github.com/Mojang/bedrock-samples/archive/acc158ace8d048413c6be79c26584914643c9a12.zip",
"url": "https://github.com/Mojang/bedrock-samples/archive/706bce4c7df169f79f36e0302e1fe9f930e4af3e.zip",
"ignoreFirstFolder": true,
"exclude": [
"documentation/",
Expand Down
2 changes: 1 addition & 1 deletion app/reslist/packs.resources.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"url": "https://github.com/Mojang/bedrock-samples/archive/6e0daa70a8c94130fd04f65295e672f99d7adc6d.zip",
"url": "https://github.com/Mojang/bedrock-samples/archive/5ce65764d3426f2a1f600f4156412f829c178b55.zip",
"ignoreFirstFolder": true,
"exclude": [
"documentation/",
Expand Down
54 changes: 21 additions & 33 deletions app/src/UX/EntityTypeResourceEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ export default class EntityTypeResourceEditor extends Component<
};

this._childPersistables = [];

this._updateManager(true);
}

static getDerivedStateFromProps(props: IEntityTypeResourceEditorProps, state: IEntityTypeResourceEditorState) {
Expand Down Expand Up @@ -110,10 +108,11 @@ export default class EntityTypeResourceEditor extends Component<

componentDidMount(): void {
this._childPersistables = [];
this._updateManager(true);

this._updateManager();
}

async _updateManager(setState: boolean) {
async _updateManager() {
if (this.state !== undefined && this.state.fileToEdit !== undefined) {
if (this.state.fileToEdit !== this._lastFileEdited) {
this._lastFileEdited = this.state.fileToEdit;
Expand All @@ -133,15 +132,15 @@ export default class EntityTypeResourceEditor extends Component<
(this.state.fileToEdit.manager as EntityTypeResourceDefinition).isLoaded &&
!this.state.isLoaded
) {
this._doUpdate(setState);
this._doUpdate();
}
}

_definitionLoaded(defA: EntityTypeResourceDefinition, defB: EntityTypeResourceDefinition) {
this._doUpdate(true);
this._doUpdate();
}

async _doUpdate(setState: boolean) {
async _doUpdate() {
let selItem = this.state.entityTypeResource;

if (selItem === undefined && this.state && this.state.fileToEdit && this.state.fileToEdit.manager) {
Expand Down Expand Up @@ -182,25 +181,14 @@ export default class EntityTypeResourceEditor extends Component<
}
}

if (setState) {
this.setState({
fileToEdit: this.state.fileToEdit,
isLoaded: true,
mode: this.state.mode,
sound: soundEvent,
entityTypeResource: etrd,
renderControllerSets: renderControllerSets,
});
} else {
this.state = {
fileToEdit: this.props.file,
isLoaded: true,
mode: this.state.mode,
sound: soundEvent,
entityTypeResource: etrd,
renderControllerSets: renderControllerSets,
};
}
this.setState({
fileToEdit: this.state.fileToEdit,
isLoaded: true,
mode: this.state.mode,
sound: soundEvent,
entityTypeResource: etrd,
renderControllerSets: renderControllerSets,
});
}

async persist() {
Expand Down Expand Up @@ -275,12 +263,6 @@ export default class EntityTypeResourceEditor extends Component<
this.state.fileToEdit.manager === undefined ||
Database.uxCatalog === null
) {
if (this.state.fileToEdit !== null) {
if (this.state.fileToEdit.manager === undefined) {
this._updateManager(true);
}
}

return <div>Loading...</div>;
}

Expand Down Expand Up @@ -395,6 +377,7 @@ export default class EntityTypeResourceEditor extends Component<
header = (
<div
className="etre-header"
key="etrehd"
style={{
backgroundColor: this.props.theme.siteVariables?.colorScheme.brand.background1,
color: this.props.theme.siteVariables?.colorScheme.brand.foreground2,
Expand Down Expand Up @@ -434,17 +417,19 @@ export default class EntityTypeResourceEditor extends Component<
}

renderControllerHeader = (
<div className="etre-rc-header">
<div className="etre-rc-header" key="rch">
<div className="etre-header-interior">{rcTitle}</div>
<div>{rcDescrip}</div>
</div>
);

let i = 0;
for (const renderControllerSet of this.state.renderControllerSets) {
renderControllerEditors.push(
<RenderControllerSetEditor
theme={this.props.theme}
displayHeader={false}
key={"etrscrc" + i}
heightOffset={this.props.heightOffset}
readOnly={this.props.readOnly}
isInline={true}
Expand All @@ -453,6 +438,7 @@ export default class EntityTypeResourceEditor extends Component<
setActivePersistable={this._handleNewChildPersistable}
/>
);
i++;
}
}

Expand All @@ -464,6 +450,7 @@ export default class EntityTypeResourceEditor extends Component<
<SoundEventSetEditor
readOnly={this.props.readOnly}
displayHeader={false}
key={"sevse"}
typeId={this.state.entityTypeResource?.id}
eventType={SoundEventSetType.entity}
project={this.props.projectItem.project}
Expand All @@ -476,6 +463,7 @@ export default class EntityTypeResourceEditor extends Component<
mainInterior = (
<DataForm
definition={form}
key={"sevdf"}
directObject={resourceData}
readOnly={false}
theme={this.props.theme}
Expand Down
43 changes: 14 additions & 29 deletions app/src/UX/RenderControllerSetEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ export default class RenderControllerSetEditor extends Component<
renderControllerSet: undefined,
form: undefined,
};

this._updateManager(true);
}

static getDerivedStateFromProps(props: IRenderControllerSetEditorProps, state: IRenderControllerSetEditorState) {
Expand All @@ -81,10 +79,10 @@ export default class RenderControllerSetEditor extends Component<
}

componentDidMount(): void {
this._updateManager(true);
this._updateManager();
}

async _updateManager(setState: boolean) {
async _updateManager() {
if (this.state !== undefined && this.state.fileToEdit !== undefined) {
if (this.state.fileToEdit !== this._lastFileEdited) {
this._lastFileEdited = this.state.fileToEdit;
Expand All @@ -100,15 +98,15 @@ export default class RenderControllerSetEditor extends Component<
this.state.fileToEdit.manager instanceof RenderControllerSetDefinition &&
(this.state.fileToEdit.manager as RenderControllerSetDefinition).isLoaded)
) {
this._doUpdate(setState);
this._doUpdate();
}
}

_definitionLoaded(defA: RenderControllerSetDefinition, defB: RenderControllerSetDefinition) {
this._doUpdate(true);
this._doUpdate();
}

async _doUpdate(setState: boolean) {
async _doUpdate() {
let selRenderControllerSet = this.props.renderControllerSet;

if (selRenderControllerSet === undefined && this.state && this.state.fileToEdit && this.state.fileToEdit.manager) {
Expand All @@ -120,28 +118,15 @@ export default class RenderControllerSetEditor extends Component<
const formTextures = await Database.ensureFormLoaded("render_controller_set_textures");
const formGeometry = await Database.ensureFormLoaded("render_controller_set_geometry");
const formMisc = await Database.ensureFormLoaded("render_controller_set_misc");

if (setState) {
this.setState({
fileToEdit: this.props.file,
renderControllerSet: selRenderControllerSet,
form: form,
formMaterials: formMaterials,
formTextures: formTextures,
formGeometry: formGeometry,
formMisc: formMisc,
});
} else {
this.state = {
fileToEdit: this.props.file,
renderControllerSet: selRenderControllerSet,
form: form,
formMaterials: formMaterials,
formTextures: formTextures,
formGeometry: formGeometry,
formMisc: formMisc,
};
}
this.setState({
fileToEdit: this.props.file,
renderControllerSet: selRenderControllerSet,
form: form,
formMaterials: formMaterials,
formTextures: formTextures,
formGeometry: formGeometry,
formMisc: formMisc,
});
}

async persist() {
Expand Down
8 changes: 4 additions & 4 deletions app/src/app/Carto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ export enum CartoMinecraftErrorStatus {
}

export const CartoTargetStrings = [
"Latest Minecraft release",
"Latest Minecraft preview",
"Latest Education Edition",
"Latest Education Edition preview",
"Latest Minecraft Bedrock",
"Latest Minecraft Bedrock preview",
"Latest Minecraft Education",
"Latest Minecraft Education preview",
];

export const SidePaneMaxWidth = 880;
Expand Down
4 changes: 2 additions & 2 deletions app/src/app/IProjectItemData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export enum ProjectItemType {
animationControllerBehaviorJson = 20,
blockTypeBehavior = 21,
blockMaterialsBehaviorJson = 22,
itemTypeBehaviorJson = 23,
itemTypeBehavior = 23,
lootTableBehavior = 24,
biomeResourceJson = 25,
blocksCatalogResourceJson = 26,
Expand All @@ -60,7 +60,7 @@ export enum ProjectItemType {
featureRuleBehaviorJson = 40,
featureBehavior = 41,
functionEventJson = 42,
recipeBehaviorJson = 43,
recipeBehavior = 43,
spawnRuleBehavior = 44,
tradingBehaviorJson = 45,
volumeBehaviorJson = 46,
Expand Down
12 changes: 6 additions & 6 deletions app/src/app/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ export enum FolderContext {

export const ProjectTargetStrings = [
"<default>",
"Latest Minecraft release",
"Latest Minecraft preview",
"Latest Education Edition",
"Latest Education Edition preview",
"Latest Minecraft Bedrock",
"Latest Minecraft Bedrock preview",
"Latest Minecraft Education",
"Latest Minecraft Education preview",
];

export const AUTOGENERATED_CONTENT_TOKEN = "==== AUTOGENERATED";
Expand Down Expand Up @@ -2312,7 +2312,7 @@ export default class Project {
} else if (folderContext === FolderContext.behaviorPack && folderPathLower.indexOf("/dialogue/") >= 0) {
newJsonType = ProjectItemType.dialogueBehaviorJson;
} else if (folderContext === FolderContext.behaviorPack && folderPathLower.indexOf("/recipes/") >= 0) {
newJsonType = ProjectItemType.recipeBehaviorJson;
newJsonType = ProjectItemType.recipeBehavior;
} else if (
folderContext === FolderContext.behaviorPack &&
folderPathLower.indexOf("/spawn_rules/") >= 0
Expand Down Expand Up @@ -2481,7 +2481,7 @@ export default class Project {
) {
newJsonType = ProjectItemType.entityTypeBehavior;
} else if (folderContext === FolderContext.behaviorPack && folderPathLower.indexOf("/items/") >= 0) {
newJsonType = ProjectItemType.itemTypeBehaviorJson;
newJsonType = ProjectItemType.itemTypeBehavior;
} else if (folderContext === FolderContext.behaviorPack && folderPathLower.indexOf("/blocks/") >= 0) {
newJsonType = ProjectItemType.blockTypeBehavior;
} else if (folderContext === FolderContext.docs && baseName === "info") {
Expand Down
4 changes: 2 additions & 2 deletions app/src/app/ProjectItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export default class ProjectItem {
return "behavior/animations/animations.json";
case ProjectItemType.blockTypeBehavior:
return "behavior/blocks/blocks.json";
case ProjectItemType.itemTypeBehaviorJson:
case ProjectItemType.itemTypeBehavior:
return "behavior/items/items.json";
case ProjectItemType.lootTableBehavior:
return "behavior/loot_tables/loot_tables.json";
Expand Down Expand Up @@ -378,7 +378,7 @@ export default class ProjectItem {
return "behavior/feature_rules/feature_rules.json";
case ProjectItemType.functionEventJson:
return "behavior/functions/tick.json";
case ProjectItemType.recipeBehaviorJson:
case ProjectItemType.recipeBehavior:
return "behavior/recipes/recipes.json";
case ProjectItemType.spawnRuleBehavior:
return "behavior/spawn_rules/spawn_rules.json";
Expand Down
Loading

0 comments on commit a82ae14

Please sign in to comment.