diff --git a/Minecraft.Client/Platform/Common/GameRules/ConsoleSchematicFile.cpp b/Minecraft.Client/Platform/Common/GameRules/ConsoleSchematicFile.cpp index 2409b12c9..3ba460f65 100644 --- a/Minecraft.Client/Platform/Common/GameRules/ConsoleSchematicFile.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/ConsoleSchematicFile.cpp @@ -733,9 +733,9 @@ void ConsoleSchematicFile::generateSchematicFile( } tag.put(L"TileEntities", tileEntitiesTag); - AABB* bb = AABB::newTemp(xStart, yStart, zStart, xEnd, yEnd, zEnd); + AABB bb(xStart, yStart, zStart, xEnd, yEnd, zEnd); std::vector >* entities = - level->getEntities(nullptr, bb); + level->getEntities(nullptr, &bb); ListTag* entitiesTag = new ListTag(L"entities"); for (AUTO_VAR(it, entities->begin()); it != entities->end(); ++it) { diff --git a/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp b/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp index 8e2260a11..5e65c983f 100644 --- a/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp @@ -253,13 +253,12 @@ void LevelGenerationOptions::addAttribute(const std::wstring& attributeName, void LevelGenerationOptions::processSchematics(LevelChunk* chunk) { PIXBeginNamedEvent(0, "Processing schematics for chunk (%d,%d)", chunk->x, chunk->z); - AABB* chunkBox = - AABB::newTemp(chunk->x * 16, 0, chunk->z * 16, chunk->x * 16 + 16, - Level::maxBuildHeight, chunk->z * 16 + 16); + AABB chunkBox(chunk->x * 16, 0, chunk->z * 16, chunk->x * 16 + 16, + Level::maxBuildHeight, chunk->z * 16 + 16); for (AUTO_VAR(it, m_schematicRules.begin()); it != m_schematicRules.end(); ++it) { ApplySchematicRuleDefinition* rule = *it; - rule->processSchematic(chunkBox, chunk); + rule->processSchematic(&chunkBox, chunk); } int cx = (chunk->x << 4); @@ -282,13 +281,12 @@ void LevelGenerationOptions::processSchematics(LevelChunk* chunk) { void LevelGenerationOptions::processSchematicsLighting(LevelChunk* chunk) { PIXBeginNamedEvent(0, "Processing schematics (lighting) for chunk (%d,%d)", chunk->x, chunk->z); - AABB* chunkBox = - AABB::newTemp(chunk->x * 16, 0, chunk->z * 16, chunk->x * 16 + 16, - Level::maxBuildHeight, chunk->z * 16 + 16); + AABB chunkBox(chunk->x * 16, 0, chunk->z * 16, chunk->x * 16 + 16, + Level::maxBuildHeight, chunk->z * 16 + 16); for (AUTO_VAR(it, m_schematicRules.begin()); it != m_schematicRules.end(); ++it) { ApplySchematicRuleDefinition* rule = *it; - rule->processSchematicLighting(chunkBox, chunk); + rule->processSchematicLighting(&chunkBox, chunk); } PIXEndNamedEvent(); } diff --git a/Minecraft.Client/Platform/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.cpp b/Minecraft.Client/Platform/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.cpp index c12e1def6..8e7a0af90 100644 --- a/Minecraft.Client/Platform/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.cpp +++ b/Minecraft.Client/Platform/PS3/SPU_Tasks/ChunkUpdate/Tile_SPU.cpp @@ -329,8 +329,8 @@ bool Tile_SPU::isSolidRender(bool isServerLevel) { return true; } // { // int newCount = // ExperienceOrb::getExperienceValue(amount); amount -= -// newCount; level->addEntity(std::shared_ptr( new -// ExperienceOrb(level, x + .5, y + .5, z + .5, newCount))); +// newCount; level->addEntity(std::shared_ptr( +// new ExperienceOrb(level, x + .5, y + .5, z + .5, newCount))); // } // } // } diff --git a/Minecraft.Client/Rendering/LevelRenderer.cpp b/Minecraft.Client/Rendering/LevelRenderer.cpp index 84f11665f..76138cf23 100644 --- a/Minecraft.Client/Rendering/LevelRenderer.cpp +++ b/Minecraft.Client/Rendering/LevelRenderer.cpp @@ -2481,9 +2481,9 @@ void LevelRenderer::renderHitOutline(std::shared_ptr player, double zo = player->zOld + (player->z - player->zOld) * a; AABB bb = Tile::tiles[tileId] - ->getTileAABB(level[iPad], h->x, h->y, h->z) - ->grow(ss, ss, ss) - .move(-xo, -yo, -zo); + ->getTileAABB(level[iPad], h->x, h->y, h->z) + ->grow(ss, ss, ss) + .move(-xo, -yo, -zo); render(&bb); } @@ -3891,20 +3891,20 @@ void LevelRenderer::DestroyedTileManager::destroyingTileAt(Level* level, int x, // ones, so make a temporary list and then copy over RecentTile* recentTile = new RecentTile(x, y, z, level); - AABB* box = AABB::newTemp((float)x, (float)y, (float)z, (float)(x + 1), - (float)(y + 1), (float)(z + 1)); + AABB box((float)x, (float)y, (float)z, (float)(x + 1), (float)(y + 1), + (float)(z + 1)); Tile* tile = Tile::tiles[level->getTile(x, y, z)]; if (tile != NULL) { - tile->addAABBs(level, x, y, z, box, &recentTile->boxes, nullptr); + tile->addAABBs(level, x, y, z, &box, &recentTile->boxes, nullptr); } // Make these temporary AABBs into permanently allocated AABBs for (unsigned int i = 0; i < recentTile->boxes.size(); i++) { - recentTile->boxes[i] = new AABB( - recentTile->boxes[i]->x0, recentTile->boxes[i]->y0, - recentTile->boxes[i]->z0, recentTile->boxes[i]->x1, - recentTile->boxes[i]->y1, recentTile->boxes[i]->z1); + recentTile->boxes[i] = + new AABB(recentTile->boxes[i]->x0, recentTile->boxes[i]->y0, + recentTile->boxes[i]->z0, recentTile->boxes[i]->x1, + recentTile->boxes[i]->y1, recentTile->boxes[i]->z1); } m_destroyedTiles.push_back(recentTile); @@ -3978,13 +3978,13 @@ void LevelRenderer::DestroyedTileManager::addAABBs(Level* level, AABB* box, // AABB copy so that we can destroy our own copy without // worrying about the lifespan of the copy we've passed out if (m_destroyedTiles[i]->boxes[j]->intersects(*box)) { - boxes->push_back( - AABB::newTemp(m_destroyedTiles[i]->boxes[j]->x0, - m_destroyedTiles[i]->boxes[j]->y0, - m_destroyedTiles[i]->boxes[j]->z0, - m_destroyedTiles[i]->boxes[j]->x1, - m_destroyedTiles[i]->boxes[j]->y1, - m_destroyedTiles[i]->boxes[j]->z1)); + AABB bb(m_destroyedTiles[i]->boxes[j]->x0, + m_destroyedTiles[i]->boxes[j]->y0, + m_destroyedTiles[i]->boxes[j]->z0, + m_destroyedTiles[i]->boxes[j]->x1, + m_destroyedTiles[i]->boxes[j]->y1, + m_destroyedTiles[i]->boxes[j]->z1); + boxes->push_back(&bb); } } } diff --git a/Minecraft.World/Blocks/BasePressurePlateTile.cpp b/Minecraft.World/Blocks/BasePressurePlateTile.cpp index 740e0a871..d6fb7e697 100644 --- a/Minecraft.World/Blocks/BasePressurePlateTile.cpp +++ b/Minecraft.World/Blocks/BasePressurePlateTile.cpp @@ -160,4 +160,4 @@ int BasePressurePlateTile::getPistonPushReaction() { void BasePressurePlateTile::registerIcons(IconRegister* iconRegister) { icon = iconRegister->registerIcon(texture); -} \ No newline at end of file +} diff --git a/Minecraft.World/Blocks/ButtonTile.cpp b/Minecraft.World/Blocks/ButtonTile.cpp index 73ac3122a..550805d9d 100644 --- a/Minecraft.World/Blocks/ButtonTile.cpp +++ b/Minecraft.World/Blocks/ButtonTile.cpp @@ -261,9 +261,12 @@ void ButtonTile::checkPressed(Level* level, int x, int y, int z) { updateShape(data); Tile::ThreadStorage* tls = m_tlsShape; - std::vector >* entities = level->getEntitiesOfClass( - typeid(Arrow), AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, - x + tls->xx1, y + tls->yy1, z + tls->zz1)); + AABB arrow_aabb{ + x + tls->xx0, y + tls->yy0, z + tls->zz0, + x + tls->xx1, y + tls->yy1, z + tls->zz1, + }; + std::vector >* entities = + level->getEntitiesOfClass(typeid(Arrow), &arrow_aabb); shouldBePressed = !entities->empty(); delete entities; diff --git a/Minecraft.World/Blocks/CakeTile.cpp b/Minecraft.World/Blocks/CakeTile.cpp index b0d8d8ee9..437438c48 100644 --- a/Minecraft.World/Blocks/CakeTile.cpp +++ b/Minecraft.World/Blocks/CakeTile.cpp @@ -124,4 +124,4 @@ int CakeTile::getResource(int data, Random* random, int playerBonusLevel) { int CakeTile::cloneTileId(Level* level, int x, int y, int z) { return Item::cake_Id; -} \ No newline at end of file +} diff --git a/Minecraft.World/Blocks/ChestTile.cpp b/Minecraft.World/Blocks/ChestTile.cpp index 9ac3c5364..4a866151c 100644 --- a/Minecraft.World/Blocks/ChestTile.cpp +++ b/Minecraft.World/Blocks/ChestTile.cpp @@ -345,8 +345,9 @@ int ChestTile::getDirectSignal(LevelSource* level, int x, int y, int z, } bool ChestTile::isCatSittingOnChest(Level* level, int x, int y, int z) { - std::vector >* entities = level->getEntitiesOfClass( - typeid(Ocelot), AABB::newTemp(x, y + 1, z, x + 1, y + 2, z + 1)); + AABB ocelot_aabb(x, y + 1, z, x + 1, y + 2, z + 1); + std::vector >* entities = + level->getEntitiesOfClass(typeid(Ocelot), &ocelot_aabb); for (AUTO_VAR(it, entities->begin()); it != entities->end(); ++it) { std::shared_ptr ocelot = std::dynamic_pointer_cast(*it); if (ocelot->isSitting()) { diff --git a/Minecraft.World/Blocks/DetectorRailTile.cpp b/Minecraft.World/Blocks/DetectorRailTile.cpp index dacc5f51b..b7bd2d4e5 100644 --- a/Minecraft.World/Blocks/DetectorRailTile.cpp +++ b/Minecraft.World/Blocks/DetectorRailTile.cpp @@ -64,9 +64,9 @@ void DetectorRailTile::checkPressed(Level* level, int x, int y, int z, bool shouldBePressed = false; float b = 2 / 16.0f; - std::vector >* entities = level->getEntitiesOfClass( - typeid(Minecart), - AABB::newTemp(x + b, y, z + b, x + 1 - b, y + 1 - b, z + 1 - b)); + AABB minecart_aabb(x + b, y, z + b, x + b - b, y + b - b, z + 1 - b); + std::vector >* entities = + level->getEntitiesOfClass(typeid(Minecart), &minecart_aabb); if (!entities->empty()) { shouldBePressed = true; } @@ -105,10 +105,10 @@ int DetectorRailTile::getAnalogOutputSignal(Level* level, int x, int y, int z, int dir) { if ((level->getData(x, y, z) & RAIL_DATA_BIT) > 0) { float b = 2 / 16.0f; + AABB minecart_bb(x + b, y, z + b, x + 1 - b, y + 1 - b, z + 1 - b); std::vector >* entities = level->getEntitiesOfClass( - typeid(Minecart), - AABB::newTemp(x + b, y, z + b, x + 1 - b, y + 1 - b, z + 1 - b), + typeid(Minecart), &minecart_bb, EntitySelector::CONTAINER_ENTITY_SELECTOR); if (entities->size() > 0) { @@ -133,4 +133,4 @@ Icon* DetectorRailTile::getTexture(int face, int data) { return icons[1]; } return icons[0]; -} \ No newline at end of file +} diff --git a/Minecraft.World/Blocks/FenceGateTile.cpp b/Minecraft.World/Blocks/FenceGateTile.cpp index 4a9a11268..44ee44135 100644 --- a/Minecraft.World/Blocks/FenceGateTile.cpp +++ b/Minecraft.World/Blocks/FenceGateTile.cpp @@ -123,4 +123,4 @@ void FenceGateTile::registerIcons(IconRegister* iconRegister) { bool FenceGateTile::shouldRenderFace(LevelSource* level, int x, int y, int z, int face) { return true; -} \ No newline at end of file +} diff --git a/Minecraft.World/Blocks/SoulSandTile.cpp b/Minecraft.World/Blocks/SoulSandTile.cpp index fe240022f..22b4f8509 100644 --- a/Minecraft.World/Blocks/SoulSandTile.cpp +++ b/Minecraft.World/Blocks/SoulSandTile.cpp @@ -14,4 +14,4 @@ void SoulSandTile::entityInside(Level* level, int x, int y, int z, std::shared_ptr entity) { entity->xd *= 0.4; entity->zd *= 0.4; -} \ No newline at end of file +} diff --git a/Minecraft.World/Blocks/TileEntities/ChestTileEntity.cpp b/Minecraft.World/Blocks/TileEntities/ChestTileEntity.cpp index d1cbd500b..d66c15c24 100644 --- a/Minecraft.World/Blocks/TileEntities/ChestTileEntity.cpp +++ b/Minecraft.World/Blocks/TileEntities/ChestTileEntity.cpp @@ -242,11 +242,10 @@ void ChestTileEntity::tick() { openCount = 0; float range = 5; + AABB player_aabb(x - range, y - range, z - range, x + 1 + range, + y + 1 + range, z + 1 + range); std::vector >* players = - level->getEntitiesOfClass( - typeid(Player), - AABB::newTemp(x - range, y - range, z - range, x + 1 + range, - y + 1 + range, z + 1 + range)); + level->getEntitiesOfClass(typeid(Player), &player_aabb); for (AUTO_VAR(it, players->begin()); it != players->end(); ++it) { std::shared_ptr player = std::dynamic_pointer_cast(*it); @@ -383,4 +382,4 @@ std::shared_ptr ChestTileEntity::clone() { } } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/Blocks/TileEntities/HopperTileEntity.cpp b/Minecraft.World/Blocks/TileEntities/HopperTileEntity.cpp index 36da69010..26ed8f516 100644 --- a/Minecraft.World/Blocks/TileEntities/HopperTileEntity.cpp +++ b/Minecraft.World/Blocks/TileEntities/HopperTileEntity.cpp @@ -345,9 +345,10 @@ std::shared_ptr HopperTileEntity::getSourceContainer( std::shared_ptr HopperTileEntity::getItemAt(Level* level, double xt, double yt, double zt) { - std::vector >* entities = level->getEntitiesOfClass( - typeid(ItemEntity), AABB::newTemp(xt, yt, zt, xt + 1, yt + 1, zt + 1), - EntitySelector::ENTITY_STILL_ALIVE); + AABB item_entity_aabb{xt, yt, zt, xt + 1, yt + 1, zt + 1}; + std::vector >* entities = + level->getEntitiesOfClass(typeid(ItemEntity), &item_entity_aabb, + EntitySelector::ENTITY_STILL_ALIVE); if (entities->size() > 0) { std::shared_ptr out = @@ -384,9 +385,9 @@ std::shared_ptr HopperTileEntity::getContainerAt(Level* level, } if (result == NULL) { + AABB block_above{x, y, z, x + 1, y + 1, z + 1}; std::vector >* entities = level->getEntities( - nullptr, AABB::newTemp(x, y, z, x + 1, y + 1, z + 1), - EntitySelector::CONTAINER_ENTITY_SELECTOR); + nullptr, &block_above, EntitySelector::CONTAINER_ENTITY_SELECTOR); if ((entities != NULL) && (entities->size() > 0)) { result = std::dynamic_pointer_cast( @@ -432,4 +433,4 @@ std::shared_ptr HopperTileEntity::clone() { } } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/Blocks/TripWireTile.cpp b/Minecraft.World/Blocks/TripWireTile.cpp index 0118aa0a1..0e5755e47 100644 --- a/Minecraft.World/Blocks/TripWireTile.cpp +++ b/Minecraft.World/Blocks/TripWireTile.cpp @@ -132,9 +132,10 @@ void TripWireTile::checkPressed(Level* level, int x, int y, int z) { bool shouldBePressed = false; ThreadStorage* tls = m_tlsShape; - std::vector >* entities = level->getEntities( - nullptr, AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, - x + tls->xx1, y + tls->yy1, z + tls->zz1)); + AABB offs_aabb(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, + y + tls->yy1, z + tls->zz1); + std::vector >* entities = + level->getEntities(nullptr, &offs_aabb); if (!entities->empty()) { for (AUTO_VAR(it, entities->begin()); it != entities->end(); ++it) { std::shared_ptr e = *it; diff --git a/Minecraft.World/Entities/LeashFenceKnotEntity.cpp b/Minecraft.World/Entities/LeashFenceKnotEntity.cpp index 5a4ccd45f..d86972cad 100644 --- a/Minecraft.World/Entities/LeashFenceKnotEntity.cpp +++ b/Minecraft.World/Entities/LeashFenceKnotEntity.cpp @@ -54,11 +54,10 @@ bool LeashFenceKnotEntity::interact(std::shared_ptr player) { if (!level->isClientSide) { // look for entities that can be attached to the fence double range = 7; + AABB mob_aabb{x - range, y - range, z - range, + x + range, y + range, z + range}; std::vector >* mobs = - level->getEntitiesOfClass( - typeid(Mob), - AABB::newTemp(x - range, y - range, z - range, x + range, - y + range, z + range)); + level->getEntitiesOfClass(typeid(Mob), &mob_aabb); if (mobs != NULL) { for (AUTO_VAR(it, mobs->begin()); it != mobs->end(); ++it) { std::shared_ptr mob = @@ -79,11 +78,10 @@ bool LeashFenceKnotEntity::interact(std::shared_ptr player) { // if the player is in creative mode, attempt to remove all leashed // mobs without dropping additional items double range = 7; + AABB mob_aabb{x - range, y - range, z - range, + x + range, y + range, z + range}; std::vector >* mobs = - level->getEntitiesOfClass( - typeid(Mob), - AABB::newTemp(x - range, y - range, z - range, x + range, - y + range, z + range)); + level->getEntitiesOfClass(typeid(Mob), &mob_aabb); if (mobs != NULL) { for (AUTO_VAR(it, mobs->begin()); it != mobs->end(); ++it) { std::shared_ptr mob = @@ -122,9 +120,10 @@ std::shared_ptr LeashFenceKnotEntity::createAndAddKnot( std::shared_ptr LeashFenceKnotEntity::findKnotAt( Level* level, int x, int y, int z) { + AABB leash_fence_knot_entity_aabb{x - 1.0, y - 1.0, z - 1.0, + x + 1.0, y + 1.0, z + 1.0}; std::vector >* knots = level->getEntitiesOfClass( - typeid(LeashFenceKnotEntity), - AABB::newTemp(x - 1.0, y - 1.0, z - 1.0, x + 1.0, y + 1.0, z + 1.0)); + typeid(LeashFenceKnotEntity), &leash_fence_knot_entity_aabb); if (knots != NULL) { for (AUTO_VAR(it, knots->begin()); it != knots->end(); ++it) { std::shared_ptr knot = @@ -137,4 +136,4 @@ std::shared_ptr LeashFenceKnotEntity::findKnotAt( delete knots; } return nullptr; -} \ No newline at end of file +} diff --git a/Minecraft.World/Entities/Mobs/Boat.cpp b/Minecraft.World/Entities/Mobs/Boat.cpp index f379b068e..d04c7f33e 100644 --- a/Minecraft.World/Entities/Mobs/Boat.cpp +++ b/Minecraft.World/Entities/Mobs/Boat.cpp @@ -167,8 +167,8 @@ void Boat::tick() { for (int i = 0; i < steps; i++) { double y0 = bb->y0 + (bb->y1 - bb->y0) * (i + 0) / steps - 2 / 16.0f; double y1 = bb->y0 + (bb->y1 - bb->y0) * (i + 1) / steps - 2 / 16.0f; - AABB* bb2 = AABB::newTemp(bb->x0, y0, bb->z0, bb->x1, y1, bb->z1); - if (level->containsLiquid(bb2, Material::water)) { + AABB bb2(bb->x0, y0, bb->z0, bb->x1, y1, bb->z1); + if (level->containsLiquid(&bb2, Material::water)) { waterPercentage += 1.0 / steps; } } diff --git a/Minecraft.World/Entities/Mobs/EnderDragon.cpp b/Minecraft.World/Entities/Mobs/EnderDragon.cpp index 2cb92716b..abcab5c46 100644 --- a/Minecraft.World/Entities/Mobs/EnderDragon.cpp +++ b/Minecraft.World/Entities/Mobs/EnderDragon.cpp @@ -647,11 +647,9 @@ void EnderDragon::aiStep() { if (!level->isClientSide) checkAttack(); if (!level->isClientSide && hurtDuration == 0) { AABB wing_mov = wing1->bb->grow(4, 2, 4).move(0, -2, 0); - knockBack(level->getEntities(shared_from_this(), - &wing_mov)); + knockBack(level->getEntities(shared_from_this(), &wing_mov)); wing_mov = wing2->bb->grow(4, 2, 4).move(0, -2, 0); - knockBack(level->getEntities(shared_from_this(), - &wing_mov)); + knockBack(level->getEntities(shared_from_this(), &wing_mov)); AABB neck_bb = neck->bb->grow(1, 1, 1); AABB head_bb = head->bb->grow(1, 1, 1); @@ -689,8 +687,8 @@ void EnderDragon::aiStep() { double acidX = x + ss * 9.5f * ccTilt; double acidY = y + yOffset + ssTilt * 10.5f; double acidZ = z - cc * 9.5f * ccTilt; - *m_acidArea = {acidX - 5, acidY - 17, acidZ - 5, acidX + 5, acidY + 4, - acidZ + 5}; + *m_acidArea = {acidX - 5, acidY - 17, acidZ - 5, + acidX + 5, acidY + 4, acidZ + 5}; // app.DebugPrintf("\nDragon is %s, yRot = %f, yRotA = %f, ss = %f, cc = // %f, ccTilt = %f\n",level->isClientSide?"client":"server", yRot, @@ -816,11 +814,9 @@ void EnderDragon::checkCrystals() { if (random->nextInt(10) == 0) { float maxDist = 32; - AABB grown = -bb->grow(maxDist, maxDist, maxDist); + AABB grown = bb->grow(maxDist, maxDist, maxDist); std::vector >* crystals = - level->getEntitiesOfClass(typeid(EnderCrystal), - &grown); + level->getEntitiesOfClass(typeid(EnderCrystal), &grown); std::shared_ptr crystal = nullptr; double nearest = std::numeric_limits::max(); @@ -1427,11 +1423,11 @@ EnderDragon::EEnderdragonAction EnderDragon::getSynchedAction() { } void EnderDragon::handleCrystalDestroyed(DamageSource* source) { - AABB* tempBB = AABB::newTemp(PODIUM_X_POS, 84.0, PODIUM_Z_POS, - PODIUM_X_POS + 1.0, 85.0, PODIUM_Z_POS + 1.0); - AABB grown = tempBB->grow(48, 40, 48); - std::vector >* crystals = level->getEntitiesOfClass( - typeid(EnderCrystal), &grown); + AABB tempBB(PODIUM_X_POS, 84.0, PODIUM_Z_POS, PODIUM_X_POS + 1.0, 85.0, + PODIUM_Z_POS + 1.0); + AABB grown = tempBB.grow(48, 40, 48); + std::vector >* crystals = + level->getEntitiesOfClass(typeid(EnderCrystal), &grown); m_remainingCrystalsCount = (int)crystals->size() - 1; if (m_remainingCrystalsCount < 0) m_remainingCrystalsCount = 0; delete crystals; diff --git a/Minecraft.World/Entities/Mobs/FishingHook.cpp b/Minecraft.World/Entities/Mobs/FishingHook.cpp index 76a4d5b07..fe8ff9b8b 100644 --- a/Minecraft.World/Entities/Mobs/FishingHook.cpp +++ b/Minecraft.World/Entities/Mobs/FishingHook.cpp @@ -288,8 +288,8 @@ void FishingHook::tick() { 2 / 16.0f; double y1 = bb->y0 + (bb->y1 - bb->y0) * (i + 1) / steps - 2 / 16.0f + 2 / 16.0f; - AABB* bb2 = AABB::newTemp(bb->x0, y0, bb->z0, bb->x1, y1, bb->z1); - if (level->containsLiquid(bb2, Material::water)) { + AABB bb2(bb->x0, y0, bb->z0, bb->x1, y1, bb->z1); + if (level->containsLiquid(&bb2, Material::water)) { waterPercentage += 1.0 / steps; } } diff --git a/Minecraft.World/Entities/Mobs/LightningBolt.cpp b/Minecraft.World/Entities/Mobs/LightningBolt.cpp index fe864cb07..24bd495dd 100644 --- a/Minecraft.World/Entities/Mobs/LightningBolt.cpp +++ b/Minecraft.World/Entities/Mobs/LightningBolt.cpp @@ -105,10 +105,9 @@ void LightningBolt::tick() { level->skyFlashTime = 2; } else { double r = 3; + AABB aoe_bb = AABB(x, y, z, x, y + 6, z).grow(r, r, r); std::vector >* entities = - level->getEntities(shared_from_this(), - AABB::newTemp(x - r, y - r, z - r, x + r, - y + 6 + r, z + r)); + level->getEntities(shared_from_this(), &aoe_bb); AUTO_VAR(itEnd, entities->end()); for (AUTO_VAR(it, entities->begin()); it != itEnd; it++) { std::shared_ptr e = (*it); // entities->at(i); diff --git a/Minecraft.World/Items/ArmorItem.cpp b/Minecraft.World/Items/ArmorItem.cpp index 3feb87e07..2f4173530 100644 --- a/Minecraft.World/Items/ArmorItem.cpp +++ b/Minecraft.World/Items/ArmorItem.cpp @@ -26,10 +26,10 @@ std::shared_ptr ArmorItem::ArmorDispenseItemBehavior::execute( int x = source->getBlockX() + facing->getStepX(); int y = source->getBlockY() + facing->getStepY(); int z = source->getBlockZ() + facing->getStepZ(); - AABB* bb = AABB::newTemp(x, y, z, x + 1, y + 1, z + 1); + AABB bb = AABB(x, y, z, x + 1, y + 1, z + 1); EntitySelector* selector = new MobCanWearArmourEntitySelector(dispensed); std::vector >* entities = - source->getWorld()->getEntitiesOfClass(typeid(LivingEntity), bb, + source->getWorld()->getEntitiesOfClass(typeid(LivingEntity), &bb, selector); delete selector; @@ -237,4 +237,4 @@ Icon* ArmorItem::getEmptyIcon(int slot) { } return NULL; -} \ No newline at end of file +} diff --git a/Minecraft.World/Items/LeashItem.cpp b/Minecraft.World/Items/LeashItem.cpp index a00d296a1..1139a5d86 100644 --- a/Minecraft.World/Items/LeashItem.cpp +++ b/Minecraft.World/Items/LeashItem.cpp @@ -3,6 +3,7 @@ #include "../Headers/net.minecraft.world.level.h" #include "../Headers/net.minecraft.world.entity.h" #include "../Headers/net.minecraft.world.phys.h" +#include "Util/AABB.h" #include "LeashItem.h" LeashItem::LeashItem(int id) : Item(id) {} @@ -35,9 +36,9 @@ bool LeashItem::bindPlayerMobs(std::shared_ptr player, Level* level, // look for entities that can be attached to the fence bool foundMobs = false; double range = 7; - std::vector >* mobs = level->getEntitiesOfClass( - typeid(Mob), AABB::newTemp(x - range, y - range, z - range, x + range, - y + range, z + range)); + AABB mob_bb = AABB(x, y, z, x, y, z).grow(range, range, range); + std::vector >* mobs = + level->getEntitiesOfClass(typeid(Mob), &mob_bb); if (mobs != NULL) { for (AUTO_VAR(it, mobs->begin()); it != mobs->end(); ++it) { std::shared_ptr mob = std::dynamic_pointer_cast(*it); @@ -59,9 +60,9 @@ bool LeashItem::bindPlayerMobsTest(std::shared_ptr player, Level* level, int x, int y, int z) { // look for entities that can be attached to the fence double range = 7; - std::vector >* mobs = level->getEntitiesOfClass( - typeid(Mob), AABB::newTemp(x - range, y - range, z - range, x + range, - y + range, z + range)); + AABB mob_bb = AABB(x, y, z, x, y, z).grow(range, range, range); + std::vector >* mobs = + level->getEntitiesOfClass(typeid(Mob), &mob_bb); if (mobs != NULL) { for (AUTO_VAR(it, mobs->begin()); it != mobs->end(); ++it) { @@ -71,4 +72,4 @@ bool LeashItem::bindPlayerMobsTest(std::shared_ptr player, Level* level, } } return false; -} \ No newline at end of file +} diff --git a/Minecraft.World/Level/Explosion.cpp b/Minecraft.World/Level/Explosion.cpp index a82786ebe..bdc17689d 100644 --- a/Minecraft.World/Level/Explosion.cpp +++ b/Minecraft.World/Level/Explosion.cpp @@ -9,6 +9,7 @@ #include "TilePos.h" #include "Explosion.h" #include "../Util/SoundTypes.h" +#include "Util/AABB.h" Explosion::Explosion(Level* level, std::shared_ptr source, double x, double y, double z, float r) { @@ -99,8 +100,10 @@ void Explosion::explode() { // time. If we explode something next to an EnderCrystal then it creates a // new explosion that overwrites the shared vector in the level So copy it // here instead of directly using the shared one + + AABB source_bb(x0, y0, z0, x1, y1, z1); std::vector >* levelEntities = - level->getEntities(source, AABB::newTemp(x0, y0, z0, x1, y1, z1)); + level->getEntities(source, &source_bb); std::vector > entities(levelEntities->begin(), levelEntities->end()); Vec3 center(x, y, z); diff --git a/Minecraft.World/Player/Player.cpp b/Minecraft.World/Player/Player.cpp index fff23c15e..f36caeefa 100644 --- a/Minecraft.World/Player/Player.cpp +++ b/Minecraft.World/Player/Player.cpp @@ -1596,11 +1596,10 @@ Player::BedSleepingResult Player::startSleepInBed(int x, int y, int z, double hRange = 8; double vRange = 5; + AABB monster_bb = + AABB(x, y, z, x, y, z).grow(hRange, vRange, hRange); std::vector >* monsters = - level->getEntitiesOfClass( - typeid(Monster), - AABB::newTemp(x - hRange, y - vRange, z - hRange, - x + hRange, y + vRange, z + hRange)); + level->getEntitiesOfClass(typeid(Monster), &monster_bb); if (!monsters->empty()) { delete monsters; return NOT_SAFE; diff --git a/Minecraft.World/WorldGen/Structures/Village.cpp b/Minecraft.World/WorldGen/Structures/Village.cpp index 16a6a2283..03a079387 100644 --- a/Minecraft.World/WorldGen/Structures/Village.cpp +++ b/Minecraft.World/WorldGen/Structures/Village.cpp @@ -117,21 +117,22 @@ bool Village::canSpawnAt(int x, int y, int z, int sx, int sy, int sz) { void Village::countGolem() { // Fix - let bots report themselves? + AABB village_golem_bb = + AABB(center->x, center->y, center->z, center->x, center->y, center->z) + .grow(radius, 4, radius); std::vector >* golems = level->getEntitiesOfClass( typeid(VillagerGolem), - AABB::newTemp(center->x - radius, center->y - 4, center->z - radius, - center->x + radius, center->y + 4, center->z + radius)); + &village_golem_bb); golemCount = golems->size(); delete golems; } void Village::countPopulation() { + AABB villager_bb = AABB(center->x, center->y, center->z, center->x, center->y, center->z).grow(radius, 4, radius); std::vector >* villagers = level->getEntitiesOfClass( typeid(Villager), - AABB::newTemp(center->x - radius, center->y - 4, center->z - radius, - center->x + radius, center->y + 4, - center->z + radius)); + &villager_bb); populationSize = villagers->size(); delete villagers;