mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-20 09:57:10 +00:00
refactor: remove AABB::newTemp when not returned
This commit is contained in:
parent
534879e2e7
commit
d7d99db4c5
|
|
@ -733,9 +733,9 @@ void ConsoleSchematicFile::generateSchematicFile(
|
||||||
}
|
}
|
||||||
tag.put(L"TileEntities", tileEntitiesTag);
|
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<std::shared_ptr<Entity> >* entities =
|
std::vector<std::shared_ptr<Entity> >* entities =
|
||||||
level->getEntities(nullptr, bb);
|
level->getEntities(nullptr, &bb);
|
||||||
ListTag<CompoundTag>* entitiesTag = new ListTag<CompoundTag>(L"entities");
|
ListTag<CompoundTag>* entitiesTag = new ListTag<CompoundTag>(L"entities");
|
||||||
|
|
||||||
for (AUTO_VAR(it, entities->begin()); it != entities->end(); ++it) {
|
for (AUTO_VAR(it, entities->begin()); it != entities->end(); ++it) {
|
||||||
|
|
|
||||||
|
|
@ -253,13 +253,12 @@ void LevelGenerationOptions::addAttribute(const std::wstring& attributeName,
|
||||||
void LevelGenerationOptions::processSchematics(LevelChunk* chunk) {
|
void LevelGenerationOptions::processSchematics(LevelChunk* chunk) {
|
||||||
PIXBeginNamedEvent(0, "Processing schematics for chunk (%d,%d)", chunk->x,
|
PIXBeginNamedEvent(0, "Processing schematics for chunk (%d,%d)", chunk->x,
|
||||||
chunk->z);
|
chunk->z);
|
||||||
AABB* chunkBox =
|
AABB chunkBox(chunk->x * 16, 0, chunk->z * 16, chunk->x * 16 + 16,
|
||||||
AABB::newTemp(chunk->x * 16, 0, chunk->z * 16, chunk->x * 16 + 16,
|
Level::maxBuildHeight, chunk->z * 16 + 16);
|
||||||
Level::maxBuildHeight, chunk->z * 16 + 16);
|
|
||||||
for (AUTO_VAR(it, m_schematicRules.begin()); it != m_schematicRules.end();
|
for (AUTO_VAR(it, m_schematicRules.begin()); it != m_schematicRules.end();
|
||||||
++it) {
|
++it) {
|
||||||
ApplySchematicRuleDefinition* rule = *it;
|
ApplySchematicRuleDefinition* rule = *it;
|
||||||
rule->processSchematic(chunkBox, chunk);
|
rule->processSchematic(&chunkBox, chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cx = (chunk->x << 4);
|
int cx = (chunk->x << 4);
|
||||||
|
|
@ -282,13 +281,12 @@ void LevelGenerationOptions::processSchematics(LevelChunk* chunk) {
|
||||||
void LevelGenerationOptions::processSchematicsLighting(LevelChunk* chunk) {
|
void LevelGenerationOptions::processSchematicsLighting(LevelChunk* chunk) {
|
||||||
PIXBeginNamedEvent(0, "Processing schematics (lighting) for chunk (%d,%d)",
|
PIXBeginNamedEvent(0, "Processing schematics (lighting) for chunk (%d,%d)",
|
||||||
chunk->x, chunk->z);
|
chunk->x, chunk->z);
|
||||||
AABB* chunkBox =
|
AABB chunkBox(chunk->x * 16, 0, chunk->z * 16, chunk->x * 16 + 16,
|
||||||
AABB::newTemp(chunk->x * 16, 0, chunk->z * 16, chunk->x * 16 + 16,
|
Level::maxBuildHeight, chunk->z * 16 + 16);
|
||||||
Level::maxBuildHeight, chunk->z * 16 + 16);
|
|
||||||
for (AUTO_VAR(it, m_schematicRules.begin()); it != m_schematicRules.end();
|
for (AUTO_VAR(it, m_schematicRules.begin()); it != m_schematicRules.end();
|
||||||
++it) {
|
++it) {
|
||||||
ApplySchematicRuleDefinition* rule = *it;
|
ApplySchematicRuleDefinition* rule = *it;
|
||||||
rule->processSchematicLighting(chunkBox, chunk);
|
rule->processSchematicLighting(&chunkBox, chunk);
|
||||||
}
|
}
|
||||||
PIXEndNamedEvent();
|
PIXEndNamedEvent();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -329,8 +329,8 @@ bool Tile_SPU::isSolidRender(bool isServerLevel) { return true; }
|
||||||
// {
|
// {
|
||||||
// int newCount =
|
// int newCount =
|
||||||
// ExperienceOrb::getExperienceValue(amount); amount -=
|
// ExperienceOrb::getExperienceValue(amount); amount -=
|
||||||
// newCount; level->addEntity(std::shared_ptr<ExperienceOrb>( new
|
// newCount; level->addEntity(std::shared_ptr<ExperienceOrb>(
|
||||||
// ExperienceOrb(level, x + .5, y + .5, z + .5, newCount)));
|
// new ExperienceOrb(level, x + .5, y + .5, z + .5, newCount)));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
|
||||||
|
|
@ -2481,9 +2481,9 @@ void LevelRenderer::renderHitOutline(std::shared_ptr<Player> player,
|
||||||
double zo = player->zOld + (player->z - player->zOld) * a;
|
double zo = player->zOld + (player->z - player->zOld) * a;
|
||||||
|
|
||||||
AABB bb = Tile::tiles[tileId]
|
AABB bb = Tile::tiles[tileId]
|
||||||
->getTileAABB(level[iPad], h->x, h->y, h->z)
|
->getTileAABB(level[iPad], h->x, h->y, h->z)
|
||||||
->grow(ss, ss, ss)
|
->grow(ss, ss, ss)
|
||||||
.move(-xo, -yo, -zo);
|
.move(-xo, -yo, -zo);
|
||||||
|
|
||||||
render(&bb);
|
render(&bb);
|
||||||
}
|
}
|
||||||
|
|
@ -3891,20 +3891,20 @@ void LevelRenderer::DestroyedTileManager::destroyingTileAt(Level* level, int x,
|
||||||
// ones, so make a temporary list and then copy over
|
// ones, so make a temporary list and then copy over
|
||||||
|
|
||||||
RecentTile* recentTile = new RecentTile(x, y, z, level);
|
RecentTile* recentTile = new RecentTile(x, y, z, level);
|
||||||
AABB* box = AABB::newTemp((float)x, (float)y, (float)z, (float)(x + 1),
|
AABB box((float)x, (float)y, (float)z, (float)(x + 1), (float)(y + 1),
|
||||||
(float)(y + 1), (float)(z + 1));
|
(float)(z + 1));
|
||||||
Tile* tile = Tile::tiles[level->getTile(x, y, z)];
|
Tile* tile = Tile::tiles[level->getTile(x, y, z)];
|
||||||
|
|
||||||
if (tile != NULL) {
|
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
|
// Make these temporary AABBs into permanently allocated AABBs
|
||||||
for (unsigned int i = 0; i < recentTile->boxes.size(); i++) {
|
for (unsigned int i = 0; i < recentTile->boxes.size(); i++) {
|
||||||
recentTile->boxes[i] = new AABB(
|
recentTile->boxes[i] =
|
||||||
recentTile->boxes[i]->x0, recentTile->boxes[i]->y0,
|
new AABB(recentTile->boxes[i]->x0, recentTile->boxes[i]->y0,
|
||||||
recentTile->boxes[i]->z0, recentTile->boxes[i]->x1,
|
recentTile->boxes[i]->z0, recentTile->boxes[i]->x1,
|
||||||
recentTile->boxes[i]->y1, recentTile->boxes[i]->z1);
|
recentTile->boxes[i]->y1, recentTile->boxes[i]->z1);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_destroyedTiles.push_back(recentTile);
|
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
|
// AABB copy so that we can destroy our own copy without
|
||||||
// worrying about the lifespan of the copy we've passed out
|
// worrying about the lifespan of the copy we've passed out
|
||||||
if (m_destroyedTiles[i]->boxes[j]->intersects(*box)) {
|
if (m_destroyedTiles[i]->boxes[j]->intersects(*box)) {
|
||||||
boxes->push_back(
|
AABB bb(m_destroyedTiles[i]->boxes[j]->x0,
|
||||||
AABB::newTemp(m_destroyedTiles[i]->boxes[j]->x0,
|
m_destroyedTiles[i]->boxes[j]->y0,
|
||||||
m_destroyedTiles[i]->boxes[j]->y0,
|
m_destroyedTiles[i]->boxes[j]->z0,
|
||||||
m_destroyedTiles[i]->boxes[j]->z0,
|
m_destroyedTiles[i]->boxes[j]->x1,
|
||||||
m_destroyedTiles[i]->boxes[j]->x1,
|
m_destroyedTiles[i]->boxes[j]->y1,
|
||||||
m_destroyedTiles[i]->boxes[j]->y1,
|
m_destroyedTiles[i]->boxes[j]->z1);
|
||||||
m_destroyedTiles[i]->boxes[j]->z1));
|
boxes->push_back(&bb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -261,9 +261,12 @@ void ButtonTile::checkPressed(Level* level, int x, int y, int z) {
|
||||||
|
|
||||||
updateShape(data);
|
updateShape(data);
|
||||||
Tile::ThreadStorage* tls = m_tlsShape;
|
Tile::ThreadStorage* tls = m_tlsShape;
|
||||||
std::vector<std::shared_ptr<Entity> >* entities = level->getEntitiesOfClass(
|
AABB arrow_aabb{
|
||||||
typeid(Arrow), AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0,
|
x + tls->xx0, y + tls->yy0, z + tls->zz0,
|
||||||
x + tls->xx1, y + tls->yy1, z + tls->zz1));
|
x + tls->xx1, y + tls->yy1, z + tls->zz1,
|
||||||
|
};
|
||||||
|
std::vector<std::shared_ptr<Entity> >* entities =
|
||||||
|
level->getEntitiesOfClass(typeid(Arrow), &arrow_aabb);
|
||||||
shouldBePressed = !entities->empty();
|
shouldBePressed = !entities->empty();
|
||||||
delete entities;
|
delete entities;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
bool ChestTile::isCatSittingOnChest(Level* level, int x, int y, int z) {
|
||||||
std::vector<std::shared_ptr<Entity> >* entities = level->getEntitiesOfClass(
|
AABB ocelot_aabb(x, y + 1, z, x + 1, y + 2, z + 1);
|
||||||
typeid(Ocelot), AABB::newTemp(x, y + 1, z, x + 1, y + 2, z + 1));
|
std::vector<std::shared_ptr<Entity> >* entities =
|
||||||
|
level->getEntitiesOfClass(typeid(Ocelot), &ocelot_aabb);
|
||||||
for (AUTO_VAR(it, entities->begin()); it != entities->end(); ++it) {
|
for (AUTO_VAR(it, entities->begin()); it != entities->end(); ++it) {
|
||||||
std::shared_ptr<Ocelot> ocelot = std::dynamic_pointer_cast<Ocelot>(*it);
|
std::shared_ptr<Ocelot> ocelot = std::dynamic_pointer_cast<Ocelot>(*it);
|
||||||
if (ocelot->isSitting()) {
|
if (ocelot->isSitting()) {
|
||||||
|
|
|
||||||
|
|
@ -64,9 +64,9 @@ void DetectorRailTile::checkPressed(Level* level, int x, int y, int z,
|
||||||
bool shouldBePressed = false;
|
bool shouldBePressed = false;
|
||||||
|
|
||||||
float b = 2 / 16.0f;
|
float b = 2 / 16.0f;
|
||||||
std::vector<std::shared_ptr<Entity> >* entities = level->getEntitiesOfClass(
|
AABB minecart_aabb(x + b, y, z + b, x + b - b, y + b - b, z + 1 - b);
|
||||||
typeid(Minecart),
|
std::vector<std::shared_ptr<Entity> >* entities =
|
||||||
AABB::newTemp(x + b, y, z + b, x + 1 - b, y + 1 - b, z + 1 - b));
|
level->getEntitiesOfClass(typeid(Minecart), &minecart_aabb);
|
||||||
if (!entities->empty()) {
|
if (!entities->empty()) {
|
||||||
shouldBePressed = true;
|
shouldBePressed = true;
|
||||||
}
|
}
|
||||||
|
|
@ -105,10 +105,10 @@ int DetectorRailTile::getAnalogOutputSignal(Level* level, int x, int y, int z,
|
||||||
int dir) {
|
int dir) {
|
||||||
if ((level->getData(x, y, z) & RAIL_DATA_BIT) > 0) {
|
if ((level->getData(x, y, z) & RAIL_DATA_BIT) > 0) {
|
||||||
float b = 2 / 16.0f;
|
float b = 2 / 16.0f;
|
||||||
|
AABB minecart_bb(x + b, y, z + b, x + 1 - b, y + 1 - b, z + 1 - b);
|
||||||
std::vector<std::shared_ptr<Entity> >* entities =
|
std::vector<std::shared_ptr<Entity> >* entities =
|
||||||
level->getEntitiesOfClass(
|
level->getEntitiesOfClass(
|
||||||
typeid(Minecart),
|
typeid(Minecart), &minecart_bb,
|
||||||
AABB::newTemp(x + b, y, z + b, x + 1 - b, y + 1 - b, z + 1 - b),
|
|
||||||
EntitySelector::CONTAINER_ENTITY_SELECTOR);
|
EntitySelector::CONTAINER_ENTITY_SELECTOR);
|
||||||
|
|
||||||
if (entities->size() > 0) {
|
if (entities->size() > 0) {
|
||||||
|
|
|
||||||
|
|
@ -242,11 +242,10 @@ void ChestTileEntity::tick() {
|
||||||
openCount = 0;
|
openCount = 0;
|
||||||
|
|
||||||
float range = 5;
|
float range = 5;
|
||||||
|
AABB player_aabb(x - range, y - range, z - range, x + 1 + range,
|
||||||
|
y + 1 + range, z + 1 + range);
|
||||||
std::vector<std::shared_ptr<Entity> >* players =
|
std::vector<std::shared_ptr<Entity> >* players =
|
||||||
level->getEntitiesOfClass(
|
level->getEntitiesOfClass(typeid(Player), &player_aabb);
|
||||||
typeid(Player),
|
|
||||||
AABB::newTemp(x - range, y - range, z - range, x + 1 + range,
|
|
||||||
y + 1 + range, z + 1 + range));
|
|
||||||
for (AUTO_VAR(it, players->begin()); it != players->end(); ++it) {
|
for (AUTO_VAR(it, players->begin()); it != players->end(); ++it) {
|
||||||
std::shared_ptr<Player> player =
|
std::shared_ptr<Player> player =
|
||||||
std::dynamic_pointer_cast<Player>(*it);
|
std::dynamic_pointer_cast<Player>(*it);
|
||||||
|
|
|
||||||
|
|
@ -345,9 +345,10 @@ std::shared_ptr<Container> HopperTileEntity::getSourceContainer(
|
||||||
|
|
||||||
std::shared_ptr<ItemEntity> HopperTileEntity::getItemAt(Level* level, double xt,
|
std::shared_ptr<ItemEntity> HopperTileEntity::getItemAt(Level* level, double xt,
|
||||||
double yt, double zt) {
|
double yt, double zt) {
|
||||||
std::vector<std::shared_ptr<Entity> >* entities = level->getEntitiesOfClass(
|
AABB item_entity_aabb{xt, yt, zt, xt + 1, yt + 1, zt + 1};
|
||||||
typeid(ItemEntity), AABB::newTemp(xt, yt, zt, xt + 1, yt + 1, zt + 1),
|
std::vector<std::shared_ptr<Entity> >* entities =
|
||||||
EntitySelector::ENTITY_STILL_ALIVE);
|
level->getEntitiesOfClass(typeid(ItemEntity), &item_entity_aabb,
|
||||||
|
EntitySelector::ENTITY_STILL_ALIVE);
|
||||||
|
|
||||||
if (entities->size() > 0) {
|
if (entities->size() > 0) {
|
||||||
std::shared_ptr<ItemEntity> out =
|
std::shared_ptr<ItemEntity> out =
|
||||||
|
|
@ -384,9 +385,9 @@ std::shared_ptr<Container> HopperTileEntity::getContainerAt(Level* level,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
|
AABB block_above{x, y, z, x + 1, y + 1, z + 1};
|
||||||
std::vector<std::shared_ptr<Entity> >* entities = level->getEntities(
|
std::vector<std::shared_ptr<Entity> >* entities = level->getEntities(
|
||||||
nullptr, AABB::newTemp(x, y, z, x + 1, y + 1, z + 1),
|
nullptr, &block_above, EntitySelector::CONTAINER_ENTITY_SELECTOR);
|
||||||
EntitySelector::CONTAINER_ENTITY_SELECTOR);
|
|
||||||
|
|
||||||
if ((entities != NULL) && (entities->size() > 0)) {
|
if ((entities != NULL) && (entities->size() > 0)) {
|
||||||
result = std::dynamic_pointer_cast<Container>(
|
result = std::dynamic_pointer_cast<Container>(
|
||||||
|
|
|
||||||
|
|
@ -132,9 +132,10 @@ void TripWireTile::checkPressed(Level* level, int x, int y, int z) {
|
||||||
bool shouldBePressed = false;
|
bool shouldBePressed = false;
|
||||||
|
|
||||||
ThreadStorage* tls = m_tlsShape;
|
ThreadStorage* tls = m_tlsShape;
|
||||||
std::vector<std::shared_ptr<Entity> >* entities = level->getEntities(
|
AABB offs_aabb(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1,
|
||||||
nullptr, AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0,
|
y + tls->yy1, z + tls->zz1);
|
||||||
x + tls->xx1, y + tls->yy1, z + tls->zz1));
|
std::vector<std::shared_ptr<Entity> >* entities =
|
||||||
|
level->getEntities(nullptr, &offs_aabb);
|
||||||
if (!entities->empty()) {
|
if (!entities->empty()) {
|
||||||
for (AUTO_VAR(it, entities->begin()); it != entities->end(); ++it) {
|
for (AUTO_VAR(it, entities->begin()); it != entities->end(); ++it) {
|
||||||
std::shared_ptr<Entity> e = *it;
|
std::shared_ptr<Entity> e = *it;
|
||||||
|
|
|
||||||
|
|
@ -54,11 +54,10 @@ bool LeashFenceKnotEntity::interact(std::shared_ptr<Player> player) {
|
||||||
if (!level->isClientSide) {
|
if (!level->isClientSide) {
|
||||||
// look for entities that can be attached to the fence
|
// look for entities that can be attached to the fence
|
||||||
double range = 7;
|
double range = 7;
|
||||||
|
AABB mob_aabb{x - range, y - range, z - range,
|
||||||
|
x + range, y + range, z + range};
|
||||||
std::vector<std::shared_ptr<Entity> >* mobs =
|
std::vector<std::shared_ptr<Entity> >* mobs =
|
||||||
level->getEntitiesOfClass(
|
level->getEntitiesOfClass(typeid(Mob), &mob_aabb);
|
||||||
typeid(Mob),
|
|
||||||
AABB::newTemp(x - range, y - range, z - range, x + range,
|
|
||||||
y + range, z + range));
|
|
||||||
if (mobs != NULL) {
|
if (mobs != NULL) {
|
||||||
for (AUTO_VAR(it, mobs->begin()); it != mobs->end(); ++it) {
|
for (AUTO_VAR(it, mobs->begin()); it != mobs->end(); ++it) {
|
||||||
std::shared_ptr<Mob> mob =
|
std::shared_ptr<Mob> mob =
|
||||||
|
|
@ -79,11 +78,10 @@ bool LeashFenceKnotEntity::interact(std::shared_ptr<Player> player) {
|
||||||
// if the player is in creative mode, attempt to remove all leashed
|
// if the player is in creative mode, attempt to remove all leashed
|
||||||
// mobs without dropping additional items
|
// mobs without dropping additional items
|
||||||
double range = 7;
|
double range = 7;
|
||||||
|
AABB mob_aabb{x - range, y - range, z - range,
|
||||||
|
x + range, y + range, z + range};
|
||||||
std::vector<std::shared_ptr<Entity> >* mobs =
|
std::vector<std::shared_ptr<Entity> >* mobs =
|
||||||
level->getEntitiesOfClass(
|
level->getEntitiesOfClass(typeid(Mob), &mob_aabb);
|
||||||
typeid(Mob),
|
|
||||||
AABB::newTemp(x - range, y - range, z - range, x + range,
|
|
||||||
y + range, z + range));
|
|
||||||
if (mobs != NULL) {
|
if (mobs != NULL) {
|
||||||
for (AUTO_VAR(it, mobs->begin()); it != mobs->end(); ++it) {
|
for (AUTO_VAR(it, mobs->begin()); it != mobs->end(); ++it) {
|
||||||
std::shared_ptr<Mob> mob =
|
std::shared_ptr<Mob> mob =
|
||||||
|
|
@ -122,9 +120,10 @@ std::shared_ptr<LeashFenceKnotEntity> LeashFenceKnotEntity::createAndAddKnot(
|
||||||
|
|
||||||
std::shared_ptr<LeashFenceKnotEntity> LeashFenceKnotEntity::findKnotAt(
|
std::shared_ptr<LeashFenceKnotEntity> LeashFenceKnotEntity::findKnotAt(
|
||||||
Level* level, int x, int y, int z) {
|
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<std::shared_ptr<Entity> >* knots = level->getEntitiesOfClass(
|
std::vector<std::shared_ptr<Entity> >* knots = level->getEntitiesOfClass(
|
||||||
typeid(LeashFenceKnotEntity),
|
typeid(LeashFenceKnotEntity), &leash_fence_knot_entity_aabb);
|
||||||
AABB::newTemp(x - 1.0, y - 1.0, z - 1.0, x + 1.0, y + 1.0, z + 1.0));
|
|
||||||
if (knots != NULL) {
|
if (knots != NULL) {
|
||||||
for (AUTO_VAR(it, knots->begin()); it != knots->end(); ++it) {
|
for (AUTO_VAR(it, knots->begin()); it != knots->end(); ++it) {
|
||||||
std::shared_ptr<LeashFenceKnotEntity> knot =
|
std::shared_ptr<LeashFenceKnotEntity> knot =
|
||||||
|
|
|
||||||
|
|
@ -167,8 +167,8 @@ void Boat::tick() {
|
||||||
for (int i = 0; i < steps; i++) {
|
for (int i = 0; i < steps; i++) {
|
||||||
double y0 = bb->y0 + (bb->y1 - bb->y0) * (i + 0) / steps - 2 / 16.0f;
|
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;
|
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);
|
AABB bb2(bb->x0, y0, bb->z0, bb->x1, y1, bb->z1);
|
||||||
if (level->containsLiquid(bb2, Material::water)) {
|
if (level->containsLiquid(&bb2, Material::water)) {
|
||||||
waterPercentage += 1.0 / steps;
|
waterPercentage += 1.0 / steps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -647,11 +647,9 @@ void EnderDragon::aiStep() {
|
||||||
if (!level->isClientSide) checkAttack();
|
if (!level->isClientSide) checkAttack();
|
||||||
if (!level->isClientSide && hurtDuration == 0) {
|
if (!level->isClientSide && hurtDuration == 0) {
|
||||||
AABB wing_mov = wing1->bb->grow(4, 2, 4).move(0, -2, 0);
|
AABB wing_mov = wing1->bb->grow(4, 2, 4).move(0, -2, 0);
|
||||||
knockBack(level->getEntities(shared_from_this(),
|
knockBack(level->getEntities(shared_from_this(), &wing_mov));
|
||||||
&wing_mov));
|
|
||||||
wing_mov = wing2->bb->grow(4, 2, 4).move(0, -2, 0);
|
wing_mov = wing2->bb->grow(4, 2, 4).move(0, -2, 0);
|
||||||
knockBack(level->getEntities(shared_from_this(),
|
knockBack(level->getEntities(shared_from_this(), &wing_mov));
|
||||||
&wing_mov));
|
|
||||||
|
|
||||||
AABB neck_bb = neck->bb->grow(1, 1, 1);
|
AABB neck_bb = neck->bb->grow(1, 1, 1);
|
||||||
AABB head_bb = head->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 acidX = x + ss * 9.5f * ccTilt;
|
||||||
double acidY = y + yOffset + ssTilt * 10.5f;
|
double acidY = y + yOffset + ssTilt * 10.5f;
|
||||||
double acidZ = z - cc * 9.5f * ccTilt;
|
double acidZ = z - cc * 9.5f * ccTilt;
|
||||||
*m_acidArea = {acidX - 5, acidY - 17, acidZ - 5, acidX + 5, acidY + 4,
|
*m_acidArea = {acidX - 5, acidY - 17, acidZ - 5,
|
||||||
acidZ + 5};
|
acidX + 5, acidY + 4, acidZ + 5};
|
||||||
|
|
||||||
// app.DebugPrintf("\nDragon is %s, yRot = %f, yRotA = %f, ss = %f, cc =
|
// app.DebugPrintf("\nDragon is %s, yRot = %f, yRotA = %f, ss = %f, cc =
|
||||||
// %f, ccTilt = %f\n",level->isClientSide?"client":"server", yRot,
|
// %f, ccTilt = %f\n",level->isClientSide?"client":"server", yRot,
|
||||||
|
|
@ -816,11 +814,9 @@ void EnderDragon::checkCrystals() {
|
||||||
|
|
||||||
if (random->nextInt(10) == 0) {
|
if (random->nextInt(10) == 0) {
|
||||||
float maxDist = 32;
|
float maxDist = 32;
|
||||||
AABB grown =
|
AABB grown = bb->grow(maxDist, maxDist, maxDist);
|
||||||
bb->grow(maxDist, maxDist, maxDist);
|
|
||||||
std::vector<std::shared_ptr<Entity> >* crystals =
|
std::vector<std::shared_ptr<Entity> >* crystals =
|
||||||
level->getEntitiesOfClass(typeid(EnderCrystal),
|
level->getEntitiesOfClass(typeid(EnderCrystal), &grown);
|
||||||
&grown);
|
|
||||||
|
|
||||||
std::shared_ptr<EnderCrystal> crystal = nullptr;
|
std::shared_ptr<EnderCrystal> crystal = nullptr;
|
||||||
double nearest = std::numeric_limits<double>::max();
|
double nearest = std::numeric_limits<double>::max();
|
||||||
|
|
@ -1427,11 +1423,11 @@ EnderDragon::EEnderdragonAction EnderDragon::getSynchedAction() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnderDragon::handleCrystalDestroyed(DamageSource* source) {
|
void EnderDragon::handleCrystalDestroyed(DamageSource* source) {
|
||||||
AABB* tempBB = AABB::newTemp(PODIUM_X_POS, 84.0, PODIUM_Z_POS,
|
AABB tempBB(PODIUM_X_POS, 84.0, PODIUM_Z_POS, PODIUM_X_POS + 1.0, 85.0,
|
||||||
PODIUM_X_POS + 1.0, 85.0, PODIUM_Z_POS + 1.0);
|
PODIUM_Z_POS + 1.0);
|
||||||
AABB grown = tempBB->grow(48, 40, 48);
|
AABB grown = tempBB.grow(48, 40, 48);
|
||||||
std::vector<std::shared_ptr<Entity> >* crystals = level->getEntitiesOfClass(
|
std::vector<std::shared_ptr<Entity> >* crystals =
|
||||||
typeid(EnderCrystal), &grown);
|
level->getEntitiesOfClass(typeid(EnderCrystal), &grown);
|
||||||
m_remainingCrystalsCount = (int)crystals->size() - 1;
|
m_remainingCrystalsCount = (int)crystals->size() - 1;
|
||||||
if (m_remainingCrystalsCount < 0) m_remainingCrystalsCount = 0;
|
if (m_remainingCrystalsCount < 0) m_remainingCrystalsCount = 0;
|
||||||
delete crystals;
|
delete crystals;
|
||||||
|
|
|
||||||
|
|
@ -288,8 +288,8 @@ void FishingHook::tick() {
|
||||||
2 / 16.0f;
|
2 / 16.0f;
|
||||||
double y1 = bb->y0 + (bb->y1 - bb->y0) * (i + 1) / steps - 2 / 16.0f +
|
double y1 = bb->y0 + (bb->y1 - bb->y0) * (i + 1) / steps - 2 / 16.0f +
|
||||||
2 / 16.0f;
|
2 / 16.0f;
|
||||||
AABB* bb2 = AABB::newTemp(bb->x0, y0, bb->z0, bb->x1, y1, bb->z1);
|
AABB bb2(bb->x0, y0, bb->z0, bb->x1, y1, bb->z1);
|
||||||
if (level->containsLiquid(bb2, Material::water)) {
|
if (level->containsLiquid(&bb2, Material::water)) {
|
||||||
waterPercentage += 1.0 / steps;
|
waterPercentage += 1.0 / steps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -105,10 +105,9 @@ void LightningBolt::tick() {
|
||||||
level->skyFlashTime = 2;
|
level->skyFlashTime = 2;
|
||||||
} else {
|
} else {
|
||||||
double r = 3;
|
double r = 3;
|
||||||
|
AABB aoe_bb = AABB(x, y, z, x, y + 6, z).grow(r, r, r);
|
||||||
std::vector<std::shared_ptr<Entity> >* entities =
|
std::vector<std::shared_ptr<Entity> >* entities =
|
||||||
level->getEntities(shared_from_this(),
|
level->getEntities(shared_from_this(), &aoe_bb);
|
||||||
AABB::newTemp(x - r, y - r, z - r, x + r,
|
|
||||||
y + 6 + r, z + r));
|
|
||||||
AUTO_VAR(itEnd, entities->end());
|
AUTO_VAR(itEnd, entities->end());
|
||||||
for (AUTO_VAR(it, entities->begin()); it != itEnd; it++) {
|
for (AUTO_VAR(it, entities->begin()); it != itEnd; it++) {
|
||||||
std::shared_ptr<Entity> e = (*it); // entities->at(i);
|
std::shared_ptr<Entity> e = (*it); // entities->at(i);
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,10 @@ std::shared_ptr<ItemInstance> ArmorItem::ArmorDispenseItemBehavior::execute(
|
||||||
int x = source->getBlockX() + facing->getStepX();
|
int x = source->getBlockX() + facing->getStepX();
|
||||||
int y = source->getBlockY() + facing->getStepY();
|
int y = source->getBlockY() + facing->getStepY();
|
||||||
int z = source->getBlockZ() + facing->getStepZ();
|
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);
|
EntitySelector* selector = new MobCanWearArmourEntitySelector(dispensed);
|
||||||
std::vector<std::shared_ptr<Entity> >* entities =
|
std::vector<std::shared_ptr<Entity> >* entities =
|
||||||
source->getWorld()->getEntitiesOfClass(typeid(LivingEntity), bb,
|
source->getWorld()->getEntitiesOfClass(typeid(LivingEntity), &bb,
|
||||||
selector);
|
selector);
|
||||||
delete selector;
|
delete selector;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include "../Headers/net.minecraft.world.level.h"
|
#include "../Headers/net.minecraft.world.level.h"
|
||||||
#include "../Headers/net.minecraft.world.entity.h"
|
#include "../Headers/net.minecraft.world.entity.h"
|
||||||
#include "../Headers/net.minecraft.world.phys.h"
|
#include "../Headers/net.minecraft.world.phys.h"
|
||||||
|
#include "Util/AABB.h"
|
||||||
#include "LeashItem.h"
|
#include "LeashItem.h"
|
||||||
|
|
||||||
LeashItem::LeashItem(int id) : Item(id) {}
|
LeashItem::LeashItem(int id) : Item(id) {}
|
||||||
|
|
@ -35,9 +36,9 @@ bool LeashItem::bindPlayerMobs(std::shared_ptr<Player> player, Level* level,
|
||||||
// look for entities that can be attached to the fence
|
// look for entities that can be attached to the fence
|
||||||
bool foundMobs = false;
|
bool foundMobs = false;
|
||||||
double range = 7;
|
double range = 7;
|
||||||
std::vector<std::shared_ptr<Entity> >* mobs = level->getEntitiesOfClass(
|
AABB mob_bb = AABB(x, y, z, x, y, z).grow(range, range, range);
|
||||||
typeid(Mob), AABB::newTemp(x - range, y - range, z - range, x + range,
|
std::vector<std::shared_ptr<Entity> >* mobs =
|
||||||
y + range, z + range));
|
level->getEntitiesOfClass(typeid(Mob), &mob_bb);
|
||||||
if (mobs != NULL) {
|
if (mobs != NULL) {
|
||||||
for (AUTO_VAR(it, mobs->begin()); it != mobs->end(); ++it) {
|
for (AUTO_VAR(it, mobs->begin()); it != mobs->end(); ++it) {
|
||||||
std::shared_ptr<Mob> mob = std::dynamic_pointer_cast<Mob>(*it);
|
std::shared_ptr<Mob> mob = std::dynamic_pointer_cast<Mob>(*it);
|
||||||
|
|
@ -59,9 +60,9 @@ bool LeashItem::bindPlayerMobsTest(std::shared_ptr<Player> player, Level* level,
|
||||||
int x, int y, int z) {
|
int x, int y, int z) {
|
||||||
// look for entities that can be attached to the fence
|
// look for entities that can be attached to the fence
|
||||||
double range = 7;
|
double range = 7;
|
||||||
std::vector<std::shared_ptr<Entity> >* mobs = level->getEntitiesOfClass(
|
AABB mob_bb = AABB(x, y, z, x, y, z).grow(range, range, range);
|
||||||
typeid(Mob), AABB::newTemp(x - range, y - range, z - range, x + range,
|
std::vector<std::shared_ptr<Entity> >* mobs =
|
||||||
y + range, z + range));
|
level->getEntitiesOfClass(typeid(Mob), &mob_bb);
|
||||||
|
|
||||||
if (mobs != NULL) {
|
if (mobs != NULL) {
|
||||||
for (AUTO_VAR(it, mobs->begin()); it != mobs->end(); ++it) {
|
for (AUTO_VAR(it, mobs->begin()); it != mobs->end(); ++it) {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
#include "TilePos.h"
|
#include "TilePos.h"
|
||||||
#include "Explosion.h"
|
#include "Explosion.h"
|
||||||
#include "../Util/SoundTypes.h"
|
#include "../Util/SoundTypes.h"
|
||||||
|
#include "Util/AABB.h"
|
||||||
|
|
||||||
Explosion::Explosion(Level* level, std::shared_ptr<Entity> source, double x,
|
Explosion::Explosion(Level* level, std::shared_ptr<Entity> source, double x,
|
||||||
double y, double z, float r) {
|
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
|
// 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
|
// new explosion that overwrites the shared vector in the level So copy it
|
||||||
// here instead of directly using the shared one
|
// here instead of directly using the shared one
|
||||||
|
|
||||||
|
AABB source_bb(x0, y0, z0, x1, y1, z1);
|
||||||
std::vector<std::shared_ptr<Entity> >* levelEntities =
|
std::vector<std::shared_ptr<Entity> >* levelEntities =
|
||||||
level->getEntities(source, AABB::newTemp(x0, y0, z0, x1, y1, z1));
|
level->getEntities(source, &source_bb);
|
||||||
std::vector<std::shared_ptr<Entity> > entities(levelEntities->begin(),
|
std::vector<std::shared_ptr<Entity> > entities(levelEntities->begin(),
|
||||||
levelEntities->end());
|
levelEntities->end());
|
||||||
Vec3 center(x, y, z);
|
Vec3 center(x, y, z);
|
||||||
|
|
|
||||||
|
|
@ -1596,11 +1596,10 @@ Player::BedSleepingResult Player::startSleepInBed(int x, int y, int z,
|
||||||
|
|
||||||
double hRange = 8;
|
double hRange = 8;
|
||||||
double vRange = 5;
|
double vRange = 5;
|
||||||
|
AABB monster_bb =
|
||||||
|
AABB(x, y, z, x, y, z).grow(hRange, vRange, hRange);
|
||||||
std::vector<std::shared_ptr<Entity> >* monsters =
|
std::vector<std::shared_ptr<Entity> >* monsters =
|
||||||
level->getEntitiesOfClass(
|
level->getEntitiesOfClass(typeid(Monster), &monster_bb);
|
||||||
typeid(Monster),
|
|
||||||
AABB::newTemp(x - hRange, y - vRange, z - hRange,
|
|
||||||
x + hRange, y + vRange, z + hRange));
|
|
||||||
if (!monsters->empty()) {
|
if (!monsters->empty()) {
|
||||||
delete monsters;
|
delete monsters;
|
||||||
return NOT_SAFE;
|
return NOT_SAFE;
|
||||||
|
|
|
||||||
|
|
@ -117,21 +117,22 @@ bool Village::canSpawnAt(int x, int y, int z, int sx, int sy, int sz) {
|
||||||
|
|
||||||
void Village::countGolem() {
|
void Village::countGolem() {
|
||||||
// Fix - let bots report themselves?
|
// 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<std::shared_ptr<Entity> >* golems = level->getEntitiesOfClass(
|
std::vector<std::shared_ptr<Entity> >* golems = level->getEntitiesOfClass(
|
||||||
typeid(VillagerGolem),
|
typeid(VillagerGolem),
|
||||||
AABB::newTemp(center->x - radius, center->y - 4, center->z - radius,
|
&village_golem_bb);
|
||||||
center->x + radius, center->y + 4, center->z + radius));
|
|
||||||
golemCount = golems->size();
|
golemCount = golems->size();
|
||||||
delete golems;
|
delete golems;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Village::countPopulation() {
|
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<std::shared_ptr<Entity> >* villagers =
|
std::vector<std::shared_ptr<Entity> >* villagers =
|
||||||
level->getEntitiesOfClass(
|
level->getEntitiesOfClass(
|
||||||
typeid(Villager),
|
typeid(Villager),
|
||||||
AABB::newTemp(center->x - radius, center->y - 4, center->z - radius,
|
&villager_bb);
|
||||||
center->x + radius, center->y + 4,
|
|
||||||
center->z + radius));
|
|
||||||
populationSize = villagers->size();
|
populationSize = villagers->size();
|
||||||
delete villagers;
|
delete villagers;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue