Skip to content

Commit

Permalink
Translate MC item names, for voxel-food. Substitute unknown
Browse files Browse the repository at this point in the history
TODO: maybe adopt the MC names instead of having this translation layer?
Although we still want to detect unsupported items - now show as a
'missing block' texture (even though really should be 'missing item', oh
well)
  • Loading branch information
deathcap committed Feb 8, 2016
1 parent 30b7790 commit 3612e9a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 12 deletions.
11 changes: 6 additions & 5 deletions clientmc.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,12 @@ ClientMC.prototype._newItemPile = function(mcName, count, tags) {

let ourName;

if (mcData.mcBlockName2Voxel[mcName]) {
ourName = mcData.mcBlockName2Voxel[mcName];
} else {
ourName = mcName; // TODO: translate items too
} // TODO: substitute unrecognized
ourName = mcData.mcBlockName2Voxel[mcName];
if (!ourName) ourName = mcData.mcItemName2Voxel[mcName];
if (!ourName) {
console.warn(`Unrecognized/unsupported MC item: ${mcName}`);
ourName = 'missing';
}

return new ItemPile(ourName, count);
}
Expand Down
41 changes: 34 additions & 7 deletions mcdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ const inertItemProps = {
//apple: {itemTexture: 'items/apple', displayName: 'Apple'}, // voxel-food
armor_stand: {itemTexture: 'items/wooden_armorstand', displayName: 'Armor Stand'},
arrow: {itemTexture: 'items/arrow', displayName: 'Arrow'},
baked_potato: {itemTexture: 'items/potato_baked', displayName: 'Baked Potato'},
//baked_potato: {itemTexture: 'items/potato_baked', displayName: 'Baked Potato'},
bed: {itemTexture: 'items/bed', displayName: 'Bed'},
beef: {itemTexture: 'items/beef_raw', displayName: 'Raw Beef'},
//beef: {itemTexture: 'items/beef_raw', displayName: 'Raw Beef'},
birch_door: {itemTexture: 'items/door_birch', displayName: 'Birch Door'},
blaze_powder: {itemTexture: 'items/blaze_powder', displayName: 'Blaze Powder'},
blaze_rod: {itemTexture: 'items/blaze_rod', displayName: 'Blaze Rod'},
Expand All @@ -230,13 +230,13 @@ const inertItemProps = {
chainmail_helmet: {itemTexture: 'items/chainmail_helmet', displayName: 'Chain Helmet'},
chainmail_leggings: {itemTexture: 'items/chainmail_leggings', displayName: 'Chain Leggings'},
chest_minecart: {itemTexture: 'items/minecart_chest', displayName: 'Minecart with Chest'},
chicken: {itemTexture: 'items/chicken_raw', displayName: 'Raw Chicken'},
//chicken: {itemTexture: 'items/chicken_raw', displayName: 'Raw Chicken'},
clay_ball: {itemTexture: 'items/clay_ball', displayName: 'Clay'},
coal: {itemTexture: 'items/coal', displayName: 'Coal'},
command_block_minecart: {itemTexture: 'items/minecart_command_block', displayName: 'Minecart with Command Block'},
comparator: {itemTexture: 'items/comparator', displayName: 'Redstone Comparator'},
cooked_beef: {itemTexture: 'items/beef_cooked', displayName: 'Steak'},
cooked_chicken: {itemTexture: 'items/chicken_cooked', displayName: 'Cooked Chicken'},
//cooked_beef: {itemTexture: 'items/beef_cooked', displayName: 'Steak'},
//cooked_chicken: {itemTexture: 'items/chicken_cooked', displayName: 'Cooked Chicken'},
cooked_mutton: {itemTexture: 'items/mutton_cooked', displayName: 'Cooked Mutton'},
cooked_porkchop: {itemTexture: 'items/porkchop_cooked', displayName: 'Cooked Porkchop'},
cooked_rabbit: {itemTexture: 'items/rabbit_cooked', displayName: 'Cooked Rabbit'},
Expand Down Expand Up @@ -275,10 +275,10 @@ const inertItemProps = {
glowstone_dust: {itemTexture: 'items/glowstone_dust', displayName: 'Glowstone Dust'},
gold_ingot: {itemTexture: 'items/gold_ingot', displayName: 'Gold Ingot'},
gold_nugget: {itemTexture: 'items/gold_nugget', displayName: 'Gold Nugget'},
golden_apple: {itemTexture: 'items/apple_golden', displayName: 'Golden Apple'},
//golden_apple: {itemTexture: 'items/apple_golden', displayName: 'Golden Apple'},
golden_axe: {itemTexture: 'items/gold_axe', displayName: 'Golden Axe'},
golden_boots: {itemTexture: 'items/gold_boots', displayName: 'Golden Boots'},
golden_carrot: {itemTexture: 'items/carrot_golden', displayName: 'Golden Carrot'},
//golden_carrot: {itemTexture: 'items/carrot_golden', displayName: 'Golden Carrot'},
golden_chestplate: {itemTexture: 'items/gold_chestplate', displayName: 'Golden Chestplate'},
golden_helmet: {itemTexture: 'items/gold_helmet', displayName: 'Golden Helmet'},
golden_hoe: {itemTexture: 'items/gold_hoe', displayName: 'Golden Hoe'},
Expand Down Expand Up @@ -416,11 +416,38 @@ function readItemTextures() {
readItemTextures();
*/

const mcItemName2Voxel = {
// voxel-food
apple: 'apple',
baked_potato: 'potatoBaked',
beef: 'beefRaw',
bread: 'bread',
cake: 'cake',
carrot: 'carrot',
golden_apple: 'appleGolden',
golden_carrot: 'carrotGolden',
chicken: 'chickenRaw',
cooked_beef: 'beefCooked',
cooked_chicken: 'chickenCooked',
cookie: 'cookie',
melon: 'melon',
pumpkin_pie: 'pumpkinPie',
spider_eye: 'spiderEye',
// note: appended with inertItemProps below
};

Object.keys(inertItemProps).forEach((mcName) => {
const ourName = mcName;

mcItemName2Voxel[mcName] = ourName;
});

module.exports = {
mcBlockName2Voxel,
mcBlockID2Voxel,
inertBlockProps,
inertItemProps,
mcItemName2Voxel,
};


0 comments on commit 3612e9a

Please sign in to comment.