diff options
| author | daoge <3523206925@qq.com> | 2026-03-03 03:04:10 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-03 03:04:10 +0800 |
| commit | b3feddfef372618c8a9d7a0abcaf18cfad866c18 (patch) | |
| tree | 267761c3bb39241ba5c347bfbe2254d06686e287 /Minecraft.World/EnchantmentTableTile.cpp | |
| parent | 84c31a2331f7a0ec85b9d438992e244f60e5020f (diff) | |
feat: TU19 (Dec 2014) Features & Content (#155)
* try to resolve merge conflict
* feat: TU19 (Dec 2014) Features & Content (#32)
* December 2014 files
* Working release build
* Fix compilation issues
* Add sound to Windows64Media
* Add DLC content and force Tutorial DLC
* Revert "Add DLC content and force Tutorial DLC"
This reverts commit 97a43994725008e35fceb984d5549df9c8cea470.
* Disable broken light packing
* Disable breakpoint during DLC texture map load
Allows DLC loading but the DLC textures are still broken
* Fix post build not working
* ...
* fix vs2022 build
* fix cmake build
---------
Co-authored-by: Loki <lokirautio@gmail.com>
Diffstat (limited to 'Minecraft.World/EnchantmentTableTile.cpp')
| -rw-r--r-- | Minecraft.World/EnchantmentTableTile.cpp | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/Minecraft.World/EnchantmentTableTile.cpp b/Minecraft.World/EnchantmentTableTile.cpp index 70c127ba..d50fe5f5 100644 --- a/Minecraft.World/EnchantmentTableTile.cpp +++ b/Minecraft.World/EnchantmentTableTile.cpp @@ -9,10 +9,10 @@ const wstring EnchantmentTableTile::TEXTURE_SIDE = L"enchantment_side"; const wstring EnchantmentTableTile::TEXTURE_TOP = L"enchantment_top"; const wstring EnchantmentTableTile::TEXTURE_BOTTOM = L"enchantment_bottom"; -EnchantmentTableTile::EnchantmentTableTile(int id) : EntityTile(id, Material::stone, isSolidRender()) +EnchantmentTableTile::EnchantmentTableTile(int id) : BaseEntityTile(id, Material::stone, isSolidRender()) { updateDefaultShape(); - setLightBlock(0); + setLightBlock(0); iconTop = NULL; iconBottom = NULL; @@ -21,7 +21,7 @@ EnchantmentTableTile::EnchantmentTableTile(int id) : EntityTile(id, Material::st // 4J Added override void EnchantmentTableTile::updateDefaultShape() { - setShape(0, 0, 0, 1, 12 / 16.0f, 1); + setShape(0, 0, 0, 1, 12 / 16.0f, 1); } bool EnchantmentTableTile::isCubeShaped() @@ -31,28 +31,28 @@ bool EnchantmentTableTile::isCubeShaped() void EnchantmentTableTile::animateTick(Level *level, int x, int y, int z, Random *random) { - EntityTile::animateTick(level, x, y, z, random); + BaseEntityTile::animateTick(level, x, y, z, random); - for (int xx = x - 2; xx <= x + 2; xx++) + for (int xx = x - 2; xx <= x + 2; xx++) { - for (int zz = z - 2; zz <= z + 2; zz++) + for (int zz = z - 2; zz <= z + 2; zz++) { - if (xx > x - 2 && xx < x + 2 && zz == z - 1) + if (xx > x - 2 && xx < x + 2 && zz == z - 1) { - zz = z + 2; - } - if (random->nextInt(16) != 0) continue; - for (int yy = y; yy <= y + 1; yy++) + zz = z + 2; + } + if (random->nextInt(16) != 0) continue; + for (int yy = y; yy <= y + 1; yy++) { - if (level->getTile(xx, yy, zz) == Tile::bookshelf_Id) + if (level->getTile(xx, yy, zz) == Tile::bookshelf_Id) { - if (!level->isEmptyTile((xx - x) / 2 + x, yy, (zz - z) / 2 + z)) break; + if (!level->isEmptyTile((xx - x) / 2 + x, yy, (zz - z) / 2 + z)) break; - level->addParticle(eParticleType_enchantmenttable, x + 0.5, y + 2.0, z + 0.5, xx - x + random->nextFloat() - 0.5, yy - y - random->nextFloat() - 1, zz - z + random->nextFloat() - 0.5); - } - } - } - } + level->addParticle(eParticleType_enchantmenttable, x + 0.5, y + 2.0, z + 0.5, xx - x + random->nextFloat() - 0.5, yy - y - random->nextFloat() - 1, zz - z + random->nextFloat() - 0.5); + } + } + } + } } bool EnchantmentTableTile::isSolidRender(bool isServerLevel) @@ -76,12 +76,22 @@ bool EnchantmentTableTile::use(Level *level, int x, int y, int z, shared_ptr<Pla { if(soundOnly) return false; - if (level->isClientSide) + if (level->isClientSide) { - return true; - } - player->startEnchanting(x, y, z); - return true; + return true; + } + shared_ptr<EnchantmentTableEntity> table = dynamic_pointer_cast<EnchantmentTableEntity>( level->getTileEntity(x, y, z) ); + player->startEnchanting(x, y, z, table->hasCustomName() ? table->getName() : L""); + return true; +} + +void EnchantmentTableTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr<LivingEntity> by, shared_ptr<ItemInstance> itemInstance) +{ + BaseEntityTile::setPlacedBy(level, x, y, z, by, itemInstance); + if (itemInstance->hasCustomHoverName()) + { + dynamic_pointer_cast<EnchantmentTableEntity>( level->getTileEntity(x, y, z))->setCustomName(itemInstance->getHoverName()); + } } void EnchantmentTableTile::registerIcons(IconRegister *iconRegister) |
