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/BrewingStandTile.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/BrewingStandTile.cpp')
| -rw-r--r-- | Minecraft.World/BrewingStandTile.cpp | 109 |
1 files changed, 63 insertions, 46 deletions
diff --git a/Minecraft.World/BrewingStandTile.cpp b/Minecraft.World/BrewingStandTile.cpp index 5f09ba02..1aeb52d8 100644 --- a/Minecraft.World/BrewingStandTile.cpp +++ b/Minecraft.World/BrewingStandTile.cpp @@ -5,10 +5,9 @@ #include "net.minecraft.world.item.h" #include "net.minecraft.world.entity.item.h" #include "net.minecraft.world.h" +#include "net.minecraft.world.inventory.h" -const wstring BrewingStandTile::TEXTURE_BASE = L"brewingStand_base"; - -BrewingStandTile::BrewingStandTile(int id) : EntityTile(id, Material::metal, isSolidRender()) +BrewingStandTile::BrewingStandTile(int id) : BaseEntityTile(id, Material::metal, isSolidRender()) { random = new Random(); iconBase = NULL; @@ -41,10 +40,10 @@ bool BrewingStandTile::isCubeShaped() void BrewingStandTile::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes, shared_ptr<Entity> source) { - setShape(7.0f / 16.0f, 0, 7.0f / 16.0f, 9.0f / 16.0f, 14.0f / 16.0f, 9.0f / 16.0f); - EntityTile::addAABBs(level, x, y, z, box, boxes, source); - updateDefaultShape(); - EntityTile::addAABBs(level, x, y, z, box, boxes, source); + setShape(7.0f / 16.0f, 0, 7.0f / 16.0f, 9.0f / 16.0f, 14.0f / 16.0f, 9.0f / 16.0f); + BaseEntityTile::addAABBs(level, x, y, z, box, boxes, source); + updateDefaultShape(); + BaseEntityTile::addAABBs(level, x, y, z, box, boxes, source); } void BrewingStandTile::updateDefaultShape() @@ -56,62 +55,70 @@ bool BrewingStandTile::use(Level *level, int x, int y, int z, shared_ptr<Player> { if(soundOnly) return false; - if (level->isClientSide) + if (level->isClientSide) { - return true; - } - shared_ptr<BrewingStandTileEntity> brewingStand = dynamic_pointer_cast<BrewingStandTileEntity>(level->getTileEntity(x, y, z)); - if (brewingStand != NULL) player->openBrewingStand(brewingStand); + return true; + } + shared_ptr<BrewingStandTileEntity> brewingStand = dynamic_pointer_cast<BrewingStandTileEntity>(level->getTileEntity(x, y, z)); + if (brewingStand != NULL) player->openBrewingStand(brewingStand); return true; } +void BrewingStandTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr<LivingEntity> by, shared_ptr<ItemInstance> itemInstance) +{ + if (itemInstance->hasCustomHoverName()) + { + dynamic_pointer_cast<BrewingStandTileEntity>( level->getTileEntity(x, y, z))->setCustomName(itemInstance->getHoverName()); + } +} + void BrewingStandTile::animateTick(Level *level, int xt, int yt, int zt, Random *random) { - double x = xt + 0.4f + random->nextFloat() * 0.2f; - double y = yt + 0.7f + random->nextFloat() * 0.3f; - double z = zt + 0.4f + random->nextFloat() * 0.2f; + double x = xt + 0.4f + random->nextFloat() * 0.2f; + double y = yt + 0.7f + random->nextFloat() * 0.3f; + double z = zt + 0.4f + random->nextFloat() * 0.2f; - level->addParticle(eParticleType_smoke, x, y, z, 0, 0, 0); + level->addParticle(eParticleType_smoke, x, y, z, 0, 0, 0); } void BrewingStandTile::onRemove(Level *level, int x, int y, int z, int id, int data) { - shared_ptr<TileEntity> tileEntity = level->getTileEntity(x, y, z); - if (tileEntity != NULL && ( dynamic_pointer_cast<BrewingStandTileEntity>(tileEntity) != NULL) ) + shared_ptr<TileEntity> tileEntity = level->getTileEntity(x, y, z); + if (tileEntity != NULL && ( dynamic_pointer_cast<BrewingStandTileEntity>(tileEntity) != NULL) ) { - shared_ptr<BrewingStandTileEntity> container = dynamic_pointer_cast<BrewingStandTileEntity>(tileEntity); - for (int i = 0; i < container->getContainerSize(); i++) + shared_ptr<BrewingStandTileEntity> container = dynamic_pointer_cast<BrewingStandTileEntity>(tileEntity); + for (int i = 0; i < container->getContainerSize(); i++) { - shared_ptr<ItemInstance> item = container->getItem(i); - if (item != NULL) + shared_ptr<ItemInstance> item = container->getItem(i); + if (item != NULL) { - float xo = random->nextFloat() * 0.8f + 0.1f; - float yo = random->nextFloat() * 0.8f + 0.1f; - float zo = random->nextFloat() * 0.8f + 0.1f; + float xo = random->nextFloat() * 0.8f + 0.1f; + float yo = random->nextFloat() * 0.8f + 0.1f; + float zo = random->nextFloat() * 0.8f + 0.1f; - while (item->count > 0) + while (item->count > 0) { - int count = random->nextInt(21) + 10; - if (count > item->count) count = item->count; - item->count -= count; - - shared_ptr<ItemEntity> itemEntity = shared_ptr<ItemEntity>(new ItemEntity(level, x + xo, y + yo, z + zo, shared_ptr<ItemInstance>( new ItemInstance(item->id, count, item->getAuxValue())))); - float pow = 0.05f; - itemEntity->xd = (float) random->nextGaussian() * pow; - itemEntity->yd = (float) random->nextGaussian() * pow + 0.2f; - itemEntity->zd = (float) random->nextGaussian() * pow; - if (item->hasTag()) + int count = random->nextInt(21) + 10; + if (count > item->count) count = item->count; + item->count -= count; + + shared_ptr<ItemEntity> itemEntity = shared_ptr<ItemEntity>(new ItemEntity(level, x + xo, y + yo, z + zo, shared_ptr<ItemInstance>( new ItemInstance(item->id, count, item->getAuxValue())))); + float pow = 0.05f; + itemEntity->xd = (float) random->nextGaussian() * pow; + itemEntity->yd = (float) random->nextGaussian() * pow + 0.2f; + itemEntity->zd = (float) random->nextGaussian() * pow; + if (item->hasTag()) { - itemEntity->getItem()->setTag((CompoundTag *) item->getTag()->copy()); - } - level->addEntity(itemEntity); - } - } - } - } - EntityTile::onRemove(level, x, y, z, id, data); + itemEntity->getItem()->setTag((CompoundTag *) item->getTag()->copy()); + } + level->addEntity(itemEntity); + } + } + } + } + BaseEntityTile::onRemove(level, x, y, z, id, data); } int BrewingStandTile::getResource(int data, Random *random, int playerBonusLevel) @@ -124,10 +131,20 @@ int BrewingStandTile::cloneTileId(Level *level, int x, int y, int z) return Item::brewingStand_Id; } +bool BrewingStandTile::hasAnalogOutputSignal() +{ + return true; +} + +int BrewingStandTile::getAnalogOutputSignal(Level *level, int x, int y, int z, int dir) +{ + return AbstractContainerMenu::getRedstoneSignalFromContainer(dynamic_pointer_cast<Container>(level->getTileEntity(x, y, z))); +} + void BrewingStandTile::registerIcons(IconRegister *iconRegister) { - EntityTile::registerIcons(iconRegister); - iconBase = iconRegister->registerIcon(TEXTURE_BASE); + BaseEntityTile::registerIcons(iconRegister); + iconBase = iconRegister->registerIcon(getIconName() + L"_base"); } Icon *BrewingStandTile::getBaseTexture() |
