Skip to content

Commit 0b03f81

Browse files
authored
Merge pull request #3734 from ewanhowell5195/fix-bedrock-display-defaults
2 parents c1d241d + 82b5700 commit 0b03f81

2 files changed

Lines changed: 23 additions & 15 deletions

File tree

‎js/display_mode/display_mode.js‎

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -979,12 +979,26 @@ DisplayMode.updateDisplayBase = function(slot) {
979979
}
980980

981981

982+
// Extracted from a Bedrock 1.26.50.27 APK
983+
DisplayMode.bedrock_defaults = {
984+
gui: { translation: [0, 0, 0], rotation: [30, 45, 0], scale: [0.625, 0.625, 0.625], fit_to_frame: true },
985+
firstperson_righthand: { translation: [0, 0, 0], rotation: [0, 45, 0], scale: [0.4, 0.4, 0.4] },
986+
firstperson_lefthand: { translation: [0, 0, 0], rotation: [0, -135, 0], scale: [0.4, 0.4, 0.4] },
987+
thirdperson_righthand: { translation: [0, 2.5, 0], rotation: [70, 45, 0], scale: [0.375, 0.375, 0.375] },
988+
thirdperson_lefthand: { translation: [0, 2.5, 0], rotation: [70, 45, 0], scale: [0.375, 0.375, 0.375] },
989+
ground: { translation: [0, 3, 0], rotation: [0, 0, 0], scale: [0.25, 0.25, 0.25] },
990+
fixed: { translation: [0, 0, 0], rotation: [0, 0, 0], scale: [0.5, 0.5, 0.5] },
991+
head: { translation: [0, 0, 0], rotation: [0, 0, 0], scale: [1, 1, 1] },
992+
embedded: { translation: [0, 0, 0], rotation: [0, 0, 0], scale: [0.75, 0.75, 0.75] },
993+
on_shelf: { translation: [0, 0, 0], rotation: [0, 0, 0], scale: [0.5, 0.5, 0.5] },
994+
}
982995
DisplayMode.applyPreset = function(preset, all) {
983996
if (preset == undefined) return;
997+
let areas = (preset.id == 'block' && Format.id == 'bedrock_block') ? DisplayMode.bedrock_defaults : preset.areas;
984998
var slots = [DisplayMode.display_slot];
985999
if (all) {
9861000
slots = displayReferenceObjects.slots
987-
} else if (preset.areas[DisplayMode.display_slot] == undefined) {
1001+
} else if (areas[DisplayMode.display_slot] == undefined) {
9881002
Blockbench.showQuickMessage('message.preset_no_info')
9891003
return;
9901004
};
@@ -993,23 +1007,22 @@ DisplayMode.applyPreset = function(preset, all) {
9931007
if (!Project.display_settings[sl]) {
9941008
Project.display_settings[sl] = new DisplaySlot(sl)
9951009
}
996-
let preset_values = preset.areas[sl];
1010+
let preset_values = areas[sl];
9971011
if (preset_values) {
9981012
if (!preset_values.rotation_pivot) Project.display_settings[sl].rotation_pivot.replace([0, 0, 0]);
9991013
if (!preset_values.scale_pivot) Project.display_settings[sl].scale_pivot.replace([0, 0, 0]);
1000-
Project.display_settings[sl].extend(preset.areas[sl]);
1001-
if (preset.id == 'block' && Format.id == 'bedrock_block' && sl == 'gui') {
1002-
Project.display_settings[sl].rotation[1] = 45;
1003-
}
1014+
Project.display_settings[sl].extend(preset_values);
10041015
}
10051016
})
10061017
DisplayMode.updateDisplayBase()
10071018
Undo.finishEdit('Apply display preset')
10081019
}
1009-
DisplayMode.loadJSON = function(data) {
1010-
for (var slot in data) {
1020+
DisplayMode.loadJSON = function(data, defaults) {
1021+
for (let slot in data) {
10111022
if (displayReferenceObjects.slots.includes(slot)) {
1012-
Project.display_settings[slot] = new DisplaySlot(slot).extend(data[slot])
1023+
let display_slot = new DisplaySlot(slot);
1024+
if (defaults && defaults[slot]) display_slot.extend(defaults[slot]);
1025+
Project.display_settings[slot] = display_slot.extend(data[slot]);
10131026
}
10141027
}
10151028
}

‎js/formats/bedrock/bedrock.js‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -885,12 +885,7 @@ window.calculateVisibleBox = calculateVisibleBox;
885885
}
886886

887887
if (data.object.item_display_transforms !== undefined) {
888-
DisplayMode.loadJSON(data.object.item_display_transforms)
889-
if (data.object.item_display_transforms.gui) {
890-
if (data.object.item_display_transforms.gui.fit_to_frame == undefined) {
891-
Project.display_settings.gui.fit_to_frame = true;
892-
}
893-
}
888+
DisplayMode.loadJSON(data.object.item_display_transforms, DisplayMode.bedrock_defaults)
894889
}
895890

896891
var bones = {}

0 commit comments

Comments
 (0)