From 5252da6ccbe8494a5a790f6c29ad4c5d0958faa0 Mon Sep 17 00:00:00 2001 From: Vijfhoek Date: Wed, 16 Jun 2021 23:25:55 +0200 Subject: [PATCH] Add oak planks and oak logs --- src/hud/hotbar_hud.rs | 4 ++-- src/texture.rs | 5 ++++- src/world/block.rs | 24 ++++++++++++++---------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/hud/hotbar_hud.rs b/src/hud/hotbar_hud.rs index 51a914f..edde130 100644 --- a/src/hud/hotbar_hud.rs +++ b/src/hud/hotbar_hud.rs @@ -25,8 +25,8 @@ impl HotbarHud { None, Some(BlockType::Grass), Some(BlockType::Cobblestone), - None, - None, + Some(BlockType::OakPlanks), + Some(BlockType::OakLog), None, ]; diff --git a/src/texture.rs b/src/texture.rs index e8f5b25..55809b8 100644 --- a/src/texture.rs +++ b/src/texture.rs @@ -114,7 +114,7 @@ impl Texture { } } -pub const TEXTURE_COUNT: usize = 40; +pub const TEXTURE_COUNT: usize = 43; pub struct TextureManager { pub bind_group_layout: wgpu::BindGroupLayout, @@ -186,6 +186,9 @@ impl TextureManager { let path = format!("assets/water_still_plains/frame-{}.png", i); self.load(render_context, &path)?; // 8 - 39 } + self.load(render_context, "assets/block/oak_log.png")?; // 40 + self.load(render_context, "assets/block/oak_log_top.png")?; // 41 + self.load(render_context, "assets/block/oak_planks.png")?; // 42 assert_eq!(TEXTURE_COUNT, self.textures.len()); let texture_array = render_context diff --git a/src/world/block.rs b/src/world/block.rs index ccd9aaf..d52816c 100644 --- a/src/world/block.rs +++ b/src/world/block.rs @@ -5,14 +5,16 @@ use serde_repr::{Deserialize_repr, Serialize_repr}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize_repr, Deserialize_repr)] #[repr(u8)] pub enum BlockType { - Cobblestone = 1, - Dirt = 2, - Stone = 3, - Grass = 4, - Bedrock = 5, - Sand = 6, - Gravel = 7, - Water = 8, + Cobblestone, + Dirt, + Stone, + Grass, + Bedrock, + Sand, + Gravel, + Water, + OakLog, + OakPlanks, } impl BlockType { @@ -22,11 +24,13 @@ impl BlockType { BlockType::Cobblestone => ( 0, 0, 0, 0, 0, 0), BlockType::Dirt => ( 1, 1, 1, 1, 1, 1), BlockType::Stone => ( 2, 2, 2, 2, 2, 2), - BlockType::Grass => ( 4, 4, 4, 4, 2, 3), + BlockType::Grass => ( 4, 4, 4, 4, 1, 3), BlockType::Bedrock => ( 5, 5, 5, 5, 5, 5), BlockType::Sand => ( 6, 6, 6, 6, 6, 6), BlockType::Gravel => ( 7, 7, 7, 7, 7, 7), - BlockType::Water => ( 8, 8, 8, 8, 8, 8), // up to 71 + BlockType::Water => ( 8, 8, 8, 8, 8, 8), // up to 39 + BlockType::OakLog => (40, 40, 40, 40, 41, 41), + BlockType::OakPlanks => (42, 42, 42, 42, 42, 42), } }