Skip to content

Commit

Permalink
Add support for generic container types
Browse files Browse the repository at this point in the history
  • Loading branch information
Sp3rick committed Jul 25, 2024
1 parent 2458691 commit 14a94c0
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 28 deletions.
Binary file added client/public/windows/generic_9x1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/public/windows/generic_9x2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/public/windows/generic_9x3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/public/windows/generic_9x4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/public/windows/generic_9x5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/public/windows/generic_9x6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
137 changes: 111 additions & 26 deletions client/scripts/generateWindowsCoordinates.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,57 @@ const main = async () => {
const outputFilePath = path.join(__dirname, '..', 'public', 'windows', 'coordinates.json')

const windowSlotsCoords = {
'generic_9x1': {},
'generic_9x2': {},
'generic_9x3': {},
'generic_9x4': {},
'generic_9x5': {},
'generic_9x6': {},
'generic_9x7': {},
'generic_9x8': {},
'generic_9x9': {},
inventory: {},
chest: {},
'large-chest': {},
'crafting-table': {},
furnace: {}
}

windowSlotsCoords.inventory = {
// Crafting slots
0: [307, 55],
1: [195, 35],
2: [231, 35],
3: [195, 71],
4: [231, 71],

5: [15, 15], // Helmet
9: [15, 167], // Inventory
18: [15, 203], // Inventory
27: [15, 239], // Inventory
36: [15, 283], // Tool bar
45: [153, 123] // Left hand
windowSlotsCoords['generic_9x1'] = {
// Container slots
0: [15, 35],
// Inventory slots
9: [15, 97],
18: [15, 133],
27: [15, 169],
// Tool bar slots
36: [15, 213],
}
// Add armor slots (5 - 8)
for (let i = 5 + 1; i <= 8; i++) {
windowSlotsCoords.inventory[i] = [windowSlotsCoords.inventory[i - 1][0], windowSlotsCoords.inventory[i - 1][1] + 36]
for (let i = 0; i < 5 * 9; i += 9) {
for (let j = 1; j <= 8; j++) {
windowSlotsCoords['generic_9x1'][i + j] = [windowSlotsCoords['generic_9x1'][i][0] + 36 * j, windowSlotsCoords['generic_9x1'][i][1]]
}
}
// Add inventory and tool bar slots
for (let i = 9; i < 5 * 9; i += 9) {

windowSlotsCoords['generic_9x2'] = {
// Container slots
0: [15, 35],
9: [15, 71],
// Inventory slots
18: [15, 133],
27: [15, 169],
36: [15, 205],
// Tool bar slots
45: [15, 249]
}
for (let i = 0; i < 6 * 9; i += 9) {
for (let j = 1; j <= 8; j++) {
windowSlotsCoords.inventory[i + j] = [windowSlotsCoords.inventory[i][0] + 36 * j, windowSlotsCoords.inventory[i][1]]
windowSlotsCoords['generic_9x2'][i + j] = [windowSlotsCoords['generic_9x2'][i][0] + 36 * j, windowSlotsCoords['generic_9x2'][i][1]]
}
}

windowSlotsCoords.chest = {
// Chest slots
windowSlotsCoords['generic_9x3'] = {
// Container slots
0: [15, 35],
9: [15, 71],
18: [15, 107],
Expand All @@ -52,12 +68,51 @@ const main = async () => {
}
for (let i = 0; i < 7 * 9; i += 9) {
for (let j = 1; j <= 8; j++) {
windowSlotsCoords.chest[i + j] = [windowSlotsCoords.chest[i][0] + 36 * j, windowSlotsCoords.chest[i][1]]
windowSlotsCoords['generic_9x3'][i + j] = [windowSlotsCoords['generic_9x3'][i][0] + 36 * j, windowSlotsCoords['generic_9x3'][i][1]]
}
}

windowSlotsCoords['large-chest'] = {
// Chest slots
windowSlotsCoords['generic_9x4'] = {
// Container slots
0: [15, 35],
9: [15, 71],
18: [15, 107],
27: [15, 143],
// Inventory slots
36: [15, 205],
45: [15, 241],
54: [15, 277],
// Tool bar slots
63: [15, 321]
}
for (let i = 0; i < 8 * 9; i += 9) {
for (let j = 1; j <= 8; j++) {
windowSlotsCoords['generic_9x4'][i + j] = [windowSlotsCoords['generic_9x4'][i][0] + 36 * j, windowSlotsCoords['generic_9x4'][i][1]]
}
}

windowSlotsCoords['generic_9x5'] = {
// Container slots
0: [15, 35],
9: [15, 71],
18: [15, 107],
27: [15, 143],
36: [15, 179],
// Inventory slots
45: [15, 241],
54: [15, 277],
63: [15, 313],
// Tool bar slots
72: [15, 357]
}
for (let i = 0; i < 9 * 9; i += 9) {
for (let j = 1; j <= 8; j++) {
windowSlotsCoords['generic_9x5'][i + j] = [windowSlotsCoords['generic_9x5'][i][0] + 36 * j, windowSlotsCoords['generic_9x5'][i][1]]
}
}

windowSlotsCoords['generic_9x6'] = {
// Container slots
0: [15, 35],
9: [15, 71],
18: [15, 107],
Expand All @@ -73,10 +128,40 @@ const main = async () => {
}
for (let i = 0; i < 10 * 9; i += 9) {
for (let j = 1; j <= 8; j++) {
windowSlotsCoords['large-chest'][i + j] = [windowSlotsCoords['large-chest'][i][0] + 36 * j, windowSlotsCoords['large-chest'][i][1]]
windowSlotsCoords['generic_9x6'][i + j] = [windowSlotsCoords['generic_9x6'][i][0] + 36 * j, windowSlotsCoords['generic_9x6'][i][1]]
}
}

windowSlotsCoords.inventory = {
// Crafting slots
0: [307, 55],
1: [195, 35],
2: [231, 35],
3: [195, 71],
4: [231, 71],

5: [15, 15], // Helmet
9: [15, 167], // Inventory
18: [15, 203], // Inventory
27: [15, 239], // Inventory
36: [15, 283], // Tool bar
45: [153, 123] // Left hand
}
// Add armor slots (5 - 8)
for (let i = 5 + 1; i <= 8; i++) {
windowSlotsCoords.inventory[i] = [windowSlotsCoords.inventory[i - 1][0], windowSlotsCoords.inventory[i - 1][1] + 36]
}
// Add inventory and tool bar slots
for (let i = 9; i < 5 * 9; i += 9) {
for (let j = 1; j <= 8; j++) {
windowSlotsCoords.inventory[i + j] = [windowSlotsCoords.inventory[i][0] + 36 * j, windowSlotsCoords.inventory[i][1]]
}
}

windowSlotsCoords.chest = windowSlotsCoords['generic_9x3'];

windowSlotsCoords['large-chest'] = windowSlotsCoords["generic_9x6"];

windowSlotsCoords['crafting-table'] = {
0: [239, 61], // Output slot
1: [59, 33], // Input slots
Expand Down
10 changes: 8 additions & 2 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ const fs = require('fs')
const rawMcData = require('minecraft-data')

const windowNamesOrig = {
'generic_9x1': ['minecraft:generic_9x1'],
'generic_9x2': ['minecraft:generic_9x2'],
'generic_9x3': ['minecraft:generic_9x3'],
'generic_9x4': ['minecraft:generic_9x4'],
'generic_9x5': ['minecraft:generic_9x5'],
'generic_9x6': ['minecraft:generic_9x6'],
inventory: ['minecraft:inventory'],
chest: ['minecraft:generic_9x3', 'minecraft:chest'],
chest: ['minecraft:chest'],
'crafting-table': ['minecraft:crafting', 'minecraft:crafting_table'],
furnace: ['minecraft:furnace'],
'large-chest': ['minecraft:generic_9x6', 'minecraft:chest']
'large-chest': ['minecraft:chest']
}
const windowNames = windowNamesOrig

Expand Down

0 comments on commit 14a94c0

Please sign in to comment.