From ed1724170e24a4693510f777f2a07d779220e988 Mon Sep 17 00:00:00 2001 From: JannisX11 Date: Thu, 27 Oct 2022 20:43:32 +0200 Subject: [PATCH] Add invisible item frame display reference --- js/display_mode.js | 58 ++++++++++++++++++++++++++++------------------ lang/en.json | 1 + 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/js/display_mode.js b/js/display_mode.js index 8d2ca18c..8929ed1c 100644 --- a/js/display_mode.js +++ b/js/display_mode.js @@ -201,12 +201,12 @@ if (localStorage.getItem('display_presets') != null) { class refModel { - constructor(id) { + constructor(id, options = 0) { var scope = this; this.model = new THREE.Object3D(); this.name = tl('display.reference.'+id); this.id = id; - this.icon = id; + this.icon = options.icon || id; this.initialized = false; this.pose_angles = {}; @@ -293,6 +293,16 @@ class refModel { setDisplayArea(side*9.039, -8.318, 20.8, 0, 0, 0, 1,1,1) } break; + case 'frame': + this.updateBasePosition = function() { + setDisplayArea(8, 8, -1, 0, 0, 0, 0.5, 0.5, 0.5) + } + break; + case 'frame_invisible': + this.updateBasePosition = function() { + setDisplayArea(8, 8, 0.0, 0, 0, 0, 0.5, 0.5, 0.5) + } + break; case 'bow': this.updateBasePosition = function() { var side = display_slot.includes('left') ? -1 : 1; @@ -421,6 +431,7 @@ class refModel { case 'crossbow': this.buildMonitor(); break; case 'block': this.buildBlock(); break; case 'frame': this.buildFrame(); break; + case 'frame_invisible': this.buildFrameInvisible(); break; } this.initialized = true; } @@ -1059,22 +1070,28 @@ class refModel { {"size": [10,1,1], "pos": [8, 2.5, -0.5], "origin": [0, 0, 0], "north":{"uv":[3,13,13,14]},"east":{"uv":[3,13,13,14]},"south":{"uv":[3,13,13,14]},"west":{"uv":[3,13,13,14]},"up":{"uv":[3,13,13,14]},"down":{"uv":[3,13,13,14]}} ]`), 'assets/item_frame.png') } + buildFrameInvisible() { + this.buildModel(JSON.parse(`[ + {"size": [16,16,16], "pos": [8, 8, 8], "origin": [0, 0, 0], "north":{"uv":[0,0,16,16]},"east":{"uv":[0,0,16,16]},"south":{"uv":[0,0,16,16]},"west":{"uv":[0,0,16,16]},"up":{"uv":[0,0,16,16]},"down":{"uv":[0,0,16,16]}} + ]`), 'assets/missing.png') + } } window.displayReferenceObjects = { refmodels: { - player: new refModel('player'), - zombie: new refModel('zombie'), - armor_stand: new refModel('armor_stand'), - baby_zombie: new refModel('baby_zombie'), - armor_stand_small: new refModel('armor_stand_small'), - monitor: new refModel('monitor'), - bow: new refModel('bow'), - crossbow: new refModel('crossbow'), - block: new refModel('block'), - frame: new refModel('frame'), - inventory_nine: new refModel('inventory_nine'), - inventory_full: new refModel('inventory_full'), - hud: new refModel('hud') + player: new refModel('player', {icon: 'icon-player'}), + zombie: new refModel('zombie', {icon: 'icon-zombie'}), + armor_stand: new refModel('armor_stand', {icon: 'icon-armor_stand'}), + baby_zombie: new refModel('baby_zombie', {icon: 'icon-baby_zombie'}), + armor_stand_small: new refModel('armor_stand_small', {icon: 'icon-armor_stand_small'}), + monitor: new refModel('monitor', {icon: 'fa-asterisk'}), + bow: new refModel('bow', {icon: 'icon-bow'}), + crossbow: new refModel('crossbow', {icon: 'icon-crossbow'}), + block: new refModel('block', {icon: 'fa-cube'}), + frame: new refModel('frame', {icon: 'filter_frames'}), + frame_invisible: new refModel('frame_invisible', {icon: 'visibility_off'}), + inventory_nine: new refModel('inventory_nine', {icon: 'icon-inventory_nine'}), + inventory_full: new refModel('inventory_full', {icon: 'icon-inventory_full'}), + hud: new refModel('hud', {icon: 'icon-hud'}) }, active: '', bar: function(buttons) { @@ -1091,19 +1108,16 @@ window.displayReferenceObjects = { var i = 0; while (i < buttons.length) { var ref = this.refmodels[buttons[i]] - var icon = 'icon-'+ref.icon - switch (icon) { - case 'icon-monitor': icon = 'fa fa-asterisk'; break; - } + let icon = Blockbench.getIconNode(ref.icon); var button = $( `
` ) + button.find('> label.tool').append(icon); $('#display_ref_bar').append(button) if (i === displayReferenceObjects.ref_indexes[display_slot]) { ref.load(i) @@ -1439,8 +1453,7 @@ DisplayMode.loadFixed = function() { //Loader position: [-24, 18, -50], target: [0, 1, -5] }) - setDisplayArea(8, 8, -0.5, 0, 0, 0, 0.5, 0.5, 0.5) - displayReferenceObjects.bar(['frame']) + displayReferenceObjects.bar(['frame', 'frame_invisible']) } DisplayMode.load = function(slot) { switch (slot) { @@ -1547,7 +1560,6 @@ window.changeDisplaySkin = function() { } function updateDisplaySkin() { var val = settings.display_skin.value - var source; function setPSkin(skin, slim) { if (!displayReferenceObjects.refmodels.player.material) { return; diff --git a/lang/en.json b/lang/en.json index 7d5ae786..468ffa8e 100644 --- a/lang/en.json +++ b/lang/en.json @@ -1859,6 +1859,7 @@ "display.reference.crossbow": "Crossbow", "display.reference.block": "Block", "display.reference.frame": "Item Frame", + "display.reference.frame_invisible": "Item Frame (Invisible)", "display.reference.inventory_nine": "3x3", "display.reference.inventory_full": "Inventory", "display.reference.hud": "HUD",