Skip to content

Commit 5fc0319

Browse files
r1tsuuclaude
andcommitted
feat: add glass block and update default hotbar (plan 45)
Add a translucent, collidable glass block with self-occlusion so adjacent glass faces remain visible. Replace brick with glass in hotbar slot 9 and remove sand from slot 6, leaving it empty. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a6d4d22 commit 5fc0319

12 files changed

Lines changed: 341 additions & 28 deletions

File tree

apps/cli/src/default-voxel-tile-sources.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,21 @@ const createGoldOrePixel = (x: number, y: number): Rgba =>
331331
const createDiamondOrePixel = (x: number, y: number): Rgba =>
332332
createOrePixel(x, y, 0x31dd9a, rgba(92, 230, 230), 2)
333333

334+
const createGlassPixel = (x: number, y: number): Rgba => {
335+
const isBorder = x === 0 || y === 0 || x === 15 || y === 15
336+
if (isBorder) {
337+
return rgba(195, 224, 240, 230)
338+
}
339+
const noise = hash2d(x, y, 0x3be8f1)
340+
const tintAmount = ((noise & 0x3) - 1) * 3
341+
return rgba(
342+
clampColor(200 + tintAmount),
343+
clampColor(230 + tintAmount),
344+
clampColor(245 + tintAmount),
345+
28,
346+
)
347+
}
348+
334349
const createArmPixel = (x: number, y: number): Rgba => {
335350
const base = rgba(195, 155, 120)
336351
const noise = hash2d(x, y, 0x7a3c1e)
@@ -357,6 +372,7 @@ const DEFAULT_TILE_PIXEL_FACTORIES: Record<AtlasTileId, (x: number, y: number) =
357372
'gold-ore': createGoldOrePixel,
358373
'diamond-ore': createDiamondOrePixel,
359374
arm: createArmPixel,
375+
glass: createGlassPixel,
360376
}
361377

362378
export const buildDefaultVoxelTilePixels = (tileId: AtlasTileId): Uint8Array => {
251 Bytes
Loading
165 Bytes
Loading

packages/core/src/world/atlas.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export type AtlasTileId =
2424
| 'gold-ore'
2525
| 'diamond-ore'
2626
| 'arm'
27+
| 'glass'
2728

2829
export interface AtlasTileCoord {
2930
x: number
@@ -57,6 +58,7 @@ export const AtlasTiles: Record<AtlasTileId, AtlasTileCoord> = {
5758
'gold-ore': { x: 0, y: 4 },
5859
'diamond-ore': { x: 1, y: 4 },
5960
arm: { x: 2, y: 4 },
61+
glass: { x: 3, y: 4 },
6062
}
6163

6264
export const ATLAS_TILE_IDS = Object.keys(AtlasTiles) as AtlasTileId[]

packages/core/src/world/content-id-lock.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"ironOre": 14,
1818
"goldOre": 15,
1919
"diamondOre": 16,
20-
"playerArm": 17
20+
"playerArm": 17,
21+
"glass": 18
2122
},
2223
"items": {
2324
"empty": 0,
@@ -34,6 +35,7 @@
3435
"coalOre": 111,
3536
"ironOre": 112,
3637
"goldOre": 113,
37-
"diamondOre": 114
38+
"diamondOre": 114,
39+
"glass": 115
3840
}
3941
}

packages/core/src/world/content-spec.ts

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,23 @@ export const AUTHORED_BLOCK_SPECS = [
323323
side: 'diamond-ore',
324324
},
325325
},
326+
{
327+
key: 'glass',
328+
name: 'glass',
329+
collidable: true,
330+
breakable: true,
331+
occlusion: 'self',
332+
renderPass: 'translucent',
333+
dropItemKey: 'glass',
334+
emittedLightLevel: 0,
335+
durability: 600,
336+
color: [0.85, 0.93, 0.98],
337+
tiles: {
338+
top: 'glass',
339+
bottom: 'glass',
340+
side: 'glass',
341+
},
342+
},
326343
{
327344
key: 'playerArm',
328345
name: 'player arm',
@@ -463,6 +480,14 @@ export const AUTHORED_ITEM_SPECS = [
463480
placesBlockKey: 'diamondOre',
464481
renderBlockKey: 'diamondOre',
465482
},
483+
{
484+
key: 'glass',
485+
name: 'glass',
486+
color: [0.85, 0.93, 0.98],
487+
maxStackSize: 64,
488+
placesBlockKey: 'glass',
489+
renderBlockKey: 'glass',
490+
},
466491
] as const satisfies readonly AuthoredItemSpec[]
467492

468493
export const DEFAULT_STARTER_INVENTORY_STACK_SPECS = [
@@ -496,11 +521,6 @@ export const DEFAULT_STARTER_INVENTORY_STACK_SPECS = [
496521
itemKey: 'leaves',
497522
count: 64,
498523
},
499-
{
500-
slot: 6,
501-
itemKey: 'sand',
502-
count: 64,
503-
},
504524
{
505525
slot: 7,
506526
itemKey: 'planks',
@@ -513,7 +533,7 @@ export const DEFAULT_STARTER_INVENTORY_STACK_SPECS = [
513533
},
514534
{
515535
slot: 9,
516-
itemKey: 'brick',
536+
itemKey: 'glass',
517537
count: 64,
518538
},
519539
] as const satisfies readonly StarterInventoryStackSpec[]

packages/core/src/world/generated/content-ids.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const BLOCK_IDS = {
2020
goldOre: 15,
2121
diamondOre: 16,
2222
playerArm: 17,
23+
glass: 18,
2324
} as const;
2425

2526
export const ITEM_IDS = {
@@ -38,6 +39,7 @@ export const ITEM_IDS = {
3839
ironOre: 112,
3940
goldOre: 113,
4041
diamondOre: 114,
42+
glass: 115,
4143
} as const;
4244

4345
export type BlockKey = keyof typeof BLOCK_IDS;
@@ -46,5 +48,5 @@ export type ItemKey = keyof typeof ITEM_IDS;
4648
export type BlockId = (typeof BLOCK_IDS)[BlockKey];
4749
export type ItemId = (typeof ITEM_IDS)[ItemKey];
4850

49-
export const BLOCK_ID_VALUES = [BLOCK_IDS.air, BLOCK_IDS.grass, BLOCK_IDS.dirt, BLOCK_IDS.stone, BLOCK_IDS.log, BLOCK_IDS.leaves, BLOCK_IDS.sand, BLOCK_IDS.planks, BLOCK_IDS.cobblestone, BLOCK_IDS.brick, BLOCK_IDS.bedrock, BLOCK_IDS.glowstone, BLOCK_IDS.water, BLOCK_IDS.coalOre, BLOCK_IDS.ironOre, BLOCK_IDS.goldOre, BLOCK_IDS.diamondOre, BLOCK_IDS.playerArm] as const;
50-
export const ITEM_ID_VALUES = [ITEM_IDS.empty, ITEM_IDS.grass, ITEM_IDS.dirt, ITEM_IDS.stone, ITEM_IDS.log, ITEM_IDS.leaves, ITEM_IDS.sand, ITEM_IDS.planks, ITEM_IDS.cobblestone, ITEM_IDS.brick, ITEM_IDS.glowstone, ITEM_IDS.coalOre, ITEM_IDS.ironOre, ITEM_IDS.goldOre, ITEM_IDS.diamondOre] as const;
51+
export const BLOCK_ID_VALUES = [BLOCK_IDS.air, BLOCK_IDS.grass, BLOCK_IDS.dirt, BLOCK_IDS.stone, BLOCK_IDS.log, BLOCK_IDS.leaves, BLOCK_IDS.sand, BLOCK_IDS.planks, BLOCK_IDS.cobblestone, BLOCK_IDS.brick, BLOCK_IDS.bedrock, BLOCK_IDS.glowstone, BLOCK_IDS.water, BLOCK_IDS.coalOre, BLOCK_IDS.ironOre, BLOCK_IDS.goldOre, BLOCK_IDS.diamondOre, BLOCK_IDS.playerArm, BLOCK_IDS.glass] as const;
52+
export const ITEM_ID_VALUES = [ITEM_IDS.empty, ITEM_IDS.grass, ITEM_IDS.dirt, ITEM_IDS.stone, ITEM_IDS.log, ITEM_IDS.leaves, ITEM_IDS.sand, ITEM_IDS.planks, ITEM_IDS.cobblestone, ITEM_IDS.brick, ITEM_IDS.glowstone, ITEM_IDS.coalOre, ITEM_IDS.ironOre, ITEM_IDS.goldOre, ITEM_IDS.diamondOre, ITEM_IDS.glass] as const;

packages/core/src/world/generated/content-registry.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,23 @@ export const GENERATED_BLOCK_DEFINITIONS = {
324324
side: "diamond-ore",
325325
},
326326
},
327+
[BLOCK_IDS.glass]: {
328+
id: BLOCK_IDS.glass,
329+
name: "glass",
330+
collidable: true,
331+
breakable: true,
332+
occlusion: "self",
333+
renderPass: "translucent",
334+
dropItemId: ITEM_IDS.glass,
335+
emittedLightLevel: 0,
336+
durability: 600,
337+
color: [0.85, 0.93, 0.98],
338+
tiles: {
339+
top: "glass",
340+
bottom: "glass",
341+
side: "glass",
342+
},
343+
},
327344
[BLOCK_IDS.playerArm]: {
328345
id: BLOCK_IDS.playerArm,
329346
name: "player arm",
@@ -464,6 +481,14 @@ export const GENERATED_ITEM_DEFINITIONS = {
464481
placesBlockId: BLOCK_IDS.diamondOre,
465482
renderBlockId: BLOCK_IDS.diamondOre,
466483
},
484+
[ITEM_IDS.glass]: {
485+
id: ITEM_IDS.glass,
486+
name: "glass",
487+
color: [0.85, 0.93, 0.98],
488+
maxStackSize: 64,
489+
placesBlockId: BLOCK_IDS.glass,
490+
renderBlockId: BLOCK_IDS.glass,
491+
},
467492
} as const satisfies Record<ItemId, GeneratedItemDefinition>;
468493

469494
export const STARTER_INVENTORY_STACKS = [
@@ -473,8 +498,7 @@ export const STARTER_INVENTORY_STACKS = [
473498
{ slot: 3, itemId: ITEM_IDS.stone, count: 64 },
474499
{ slot: 4, itemId: ITEM_IDS.log, count: 64 },
475500
{ slot: 5, itemId: ITEM_IDS.leaves, count: 64 },
476-
{ slot: 6, itemId: ITEM_IDS.sand, count: 64 },
477501
{ slot: 7, itemId: ITEM_IDS.planks, count: 64 },
478502
{ slot: 8, itemId: ITEM_IDS.cobblestone, count: 64 },
479-
{ slot: 9, itemId: ITEM_IDS.brick, count: 64 },
503+
{ slot: 9, itemId: ITEM_IDS.glass, count: 64 },
480504
] as const satisfies readonly StarterInventoryStackDefinition[];

0 commit comments

Comments
 (0)