mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-08 15:18:26 +00:00
refactor: remove heap-allocated AABBs
This commit is contained in:
parent
e48a05bb8f
commit
7101d03c6a
|
|
@ -1010,7 +1010,7 @@ void ClientConnection::handleMovePlayer(
|
|||
player->xd = player->yd = player->zd = 0;
|
||||
player->absMoveTo(x, y, z, yRot, xRot);
|
||||
packet->x = player->x;
|
||||
packet->y = player->bb->y0;
|
||||
packet->y = player->bb.y0;
|
||||
packet->z = player->z;
|
||||
packet->yView = player->y;
|
||||
connection->send(packet);
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ void PlayerConnection::handleMovePlayer(
|
|||
*/
|
||||
|
||||
float r = 1 / 16.0f;
|
||||
AABB shrunk = player->bb->shrink(r, r, r);
|
||||
AABB shrunk = player->bb.shrink(r, r, r);
|
||||
bool oldOk =
|
||||
level->getCubes(player, &shrunk)
|
||||
->empty();
|
||||
|
|
@ -326,7 +326,7 @@ void PlayerConnection::handleMovePlayer(
|
|||
player->absMoveTo(xt, yt, zt, yRotT, xRotT);
|
||||
|
||||
// TODO: check if this can be elided
|
||||
shrunk = player->bb->shrink(r, r, r);
|
||||
shrunk = player->bb.shrink(r, r, r);
|
||||
bool newOk =
|
||||
level->getCubes(player, &shrunk)
|
||||
->empty();
|
||||
|
|
@ -334,7 +334,7 @@ void PlayerConnection::handleMovePlayer(
|
|||
teleport(xLastOk, yLastOk, zLastOk, yRotT, xRotT);
|
||||
return;
|
||||
}
|
||||
AABB testBox = (*player->bb).grow(r, r, r).expand(0, -0.55, 0);
|
||||
AABB testBox = player->bb.grow(r, r, r).expand(0, -0.55, 0);
|
||||
// && server.level.getCubes(player, testBox).size() == 0
|
||||
if (!server->isFlightAllowed() && !player->gameMode->isCreative() &&
|
||||
!level->containsAnyBlocks(&testBox) && !player->isAllowedToFly()) {
|
||||
|
|
|
|||
|
|
@ -416,7 +416,7 @@ void PlayerList::validatePlayerSpawnPosition(
|
|||
player->y, player->z, player->dimension);
|
||||
|
||||
ServerLevel* level = server->getLevel(player->dimension);
|
||||
while (level->getCubes(player, player->bb)->size() != 0) {
|
||||
while (level->getCubes(player, &player->bb)->size() != 0) {
|
||||
player->setPos(player->x, player->y + 1, player->z);
|
||||
}
|
||||
app.DebugPrintf("Final pos is %f, %f, %f in dimension %d\n", player->x,
|
||||
|
|
@ -456,7 +456,7 @@ void PlayerList::validatePlayerSpawnPosition(
|
|||
}
|
||||
delete bedPosition;
|
||||
}
|
||||
while (level->getCubes(player, player->bb)->size() != 0) {
|
||||
while (level->getCubes(player, &player->bb)->size() != 0) {
|
||||
player->setPos(player->x, player->y + 1, player->z);
|
||||
}
|
||||
|
||||
|
|
@ -749,7 +749,7 @@ std::shared_ptr<ServerPlayer> PlayerList::respawn(
|
|||
// Ensure the area the player is spawning in is loaded!
|
||||
level->cache->create(((int)player->x) >> 4, ((int)player->z) >> 4);
|
||||
|
||||
while (!level->getCubes(player, player->bb)->empty()) {
|
||||
while (!level->getCubes(player, &player->bb)->empty()) {
|
||||
player->setPos(player->x, player->y + 1, player->z);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,12 +8,13 @@
|
|||
#include "ApplySchematicRuleDefinition.h"
|
||||
#include "LevelGenerationOptions.h"
|
||||
#include "ConsoleSchematicFile.h"
|
||||
#include "../../Minecraft.World/Util/AABB.h"
|
||||
|
||||
ApplySchematicRuleDefinition::ApplySchematicRuleDefinition(
|
||||
LevelGenerationOptions* levelGenOptions) {
|
||||
m_levelGenOptions = levelGenOptions;
|
||||
m_location = Vec3(0, 0, 0);
|
||||
m_locationBox = NULL;
|
||||
m_locationBox = std::nullopt;
|
||||
m_totalBlocksChanged = 0;
|
||||
m_totalBlocksChangedLighting = 0;
|
||||
m_rotation = ConsoleSchematicFile::eSchematicRot_0;
|
||||
|
|
@ -130,7 +131,7 @@ void ApplySchematicRuleDefinition::updateLocationBox() {
|
|||
if (m_schematic == NULL)
|
||||
m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
|
||||
|
||||
m_locationBox = new AABB(0, 0, 0, 0, 0, 0);
|
||||
m_locationBox = AABB(0, 0, 0, 0, 0, 0);
|
||||
|
||||
m_locationBox->x0 = m_location.x;
|
||||
m_locationBox->y0 = m_location.y;
|
||||
|
|
@ -162,7 +163,7 @@ void ApplySchematicRuleDefinition::processSchematic(AABB* chunkBox,
|
|||
if (m_schematic == NULL)
|
||||
m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
|
||||
|
||||
if (m_locationBox == NULL) updateLocationBox();
|
||||
if (!m_locationBox.has_value()) updateLocationBox();
|
||||
if (chunkBox->intersects(*m_locationBox)) {
|
||||
m_locationBox->y1 =
|
||||
std::min((double)Level::maxBuildHeight, m_locationBox->y1);
|
||||
|
|
@ -173,12 +174,12 @@ void ApplySchematicRuleDefinition::processSchematic(AABB* chunkBox,
|
|||
#endif
|
||||
PIXBeginNamedEvent(0, "Applying blocks and data");
|
||||
m_totalBlocksChanged += m_schematic->applyBlocksAndData(
|
||||
chunk, chunkBox, m_locationBox, m_rotation);
|
||||
chunk, chunkBox, &*m_locationBox, m_rotation);
|
||||
PIXEndNamedEvent();
|
||||
|
||||
// Add the tileEntities
|
||||
PIXBeginNamedEvent(0, "Applying tile entities");
|
||||
m_schematic->applyTileEntities(chunk, chunkBox, m_locationBox,
|
||||
m_schematic->applyTileEntities(chunk, chunkBox, &*m_locationBox,
|
||||
m_rotation);
|
||||
PIXEndNamedEvent();
|
||||
|
||||
|
|
@ -206,7 +207,7 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB* chunkBox,
|
|||
if (m_schematic == NULL)
|
||||
m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
|
||||
|
||||
if (m_locationBox == NULL) updateLocationBox();
|
||||
if (!m_locationBox.has_value()) updateLocationBox();
|
||||
if (chunkBox->intersects(*m_locationBox)) {
|
||||
m_locationBox->y1 =
|
||||
std::min((double)Level::maxBuildHeight, m_locationBox->y1);
|
||||
|
|
@ -217,7 +218,7 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB* chunkBox,
|
|||
#endif
|
||||
PIXBeginNamedEvent(0, "Patching lighting");
|
||||
m_totalBlocksChangedLighting += m_schematic->applyLighting(
|
||||
chunk, chunkBox, m_locationBox, m_rotation);
|
||||
chunk, chunkBox, &*m_locationBox, m_rotation);
|
||||
PIXEndNamedEvent();
|
||||
|
||||
// TODO This does not take into account things that go outside the
|
||||
|
|
@ -237,12 +238,12 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB* chunkBox,
|
|||
|
||||
bool ApplySchematicRuleDefinition::checkIntersects(int x0, int y0, int z0,
|
||||
int x1, int y1, int z1) {
|
||||
if (m_locationBox == NULL) updateLocationBox();
|
||||
if (!m_locationBox.has_value()) updateLocationBox();
|
||||
return m_locationBox->intersects(x0, y0, z0, x1, y1, z1);
|
||||
}
|
||||
|
||||
int ApplySchematicRuleDefinition::getMinY() {
|
||||
if (m_locationBox == NULL) updateLocationBox();
|
||||
if (!m_locationBox.has_value()) updateLocationBox();
|
||||
return m_locationBox->y0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#pragma once
|
||||
#include <optional>
|
||||
#include "GameRuleDefinition.h"
|
||||
#include "ConsoleSchematicFile.h"
|
||||
#include "../../Minecraft.World/Util/AABB.h"
|
||||
|
||||
class AABB;
|
||||
class Vec3;
|
||||
|
|
@ -14,7 +16,7 @@ private:
|
|||
std::wstring m_schematicName;
|
||||
ConsoleSchematicFile* m_schematic;
|
||||
Vec3 m_location;
|
||||
AABB* m_locationBox;
|
||||
std::optional<AABB> m_locationBox;
|
||||
ConsoleSchematicFile::ESchematicRotation m_rotation;
|
||||
int m_dimension;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,9 @@
|
|||
|
||||
NamedAreaRuleDefinition::NamedAreaRuleDefinition() {
|
||||
m_name = L"";
|
||||
m_area = new AABB(0, 0, 0, 0, 0, 0);
|
||||
m_area = AABB(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
NamedAreaRuleDefinition::~NamedAreaRuleDefinition() { delete m_area; }
|
||||
|
||||
void NamedAreaRuleDefinition::writeAttributes(DataOutputStream* dos,
|
||||
unsigned int numAttributes) {
|
||||
GameRuleDefinition::writeAttributes(dos, numAttributes + 7);
|
||||
|
|
@ -18,18 +16,18 @@ void NamedAreaRuleDefinition::writeAttributes(DataOutputStream* dos,
|
|||
dos->writeUTF(m_name);
|
||||
|
||||
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x0);
|
||||
dos->writeUTF(_toString(m_area->x0));
|
||||
dos->writeUTF(_toString(m_area.x0));
|
||||
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y0);
|
||||
dos->writeUTF(_toString(m_area->y0));
|
||||
dos->writeUTF(_toString(m_area.y0));
|
||||
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z0);
|
||||
dos->writeUTF(_toString(m_area->z0));
|
||||
dos->writeUTF(_toString(m_area.z0));
|
||||
|
||||
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x1);
|
||||
dos->writeUTF(_toString(m_area->x1));
|
||||
dos->writeUTF(_toString(m_area.x1));
|
||||
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y1);
|
||||
dos->writeUTF(_toString(m_area->y1));
|
||||
dos->writeUTF(_toString(m_area.y1));
|
||||
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z1);
|
||||
dos->writeUTF(_toString(m_area->z1));
|
||||
dos->writeUTF(_toString(m_area.z1));
|
||||
}
|
||||
|
||||
void NamedAreaRuleDefinition::addAttribute(const std::wstring& attributeName,
|
||||
|
|
@ -41,31 +39,31 @@ void NamedAreaRuleDefinition::addAttribute(const std::wstring& attributeName,
|
|||
m_name.c_str());
|
||||
#endif
|
||||
} else if (attributeName.compare(L"x0") == 0) {
|
||||
m_area->x0 = _fromString<int>(attributeValue);
|
||||
m_area.x0 = _fromString<int>(attributeValue);
|
||||
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter x0=%f\n",
|
||||
m_area->x0);
|
||||
m_area.x0);
|
||||
} else if (attributeName.compare(L"y0") == 0) {
|
||||
m_area->y0 = _fromString<int>(attributeValue);
|
||||
if (m_area->y0 < 0) m_area->y0 = 0;
|
||||
m_area.y0 = _fromString<int>(attributeValue);
|
||||
if (m_area.y0 < 0) m_area.y0 = 0;
|
||||
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter y0=%f\n",
|
||||
m_area->y0);
|
||||
m_area.y0);
|
||||
} else if (attributeName.compare(L"z0") == 0) {
|
||||
m_area->z0 = _fromString<int>(attributeValue);
|
||||
m_area.z0 = _fromString<int>(attributeValue);
|
||||
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter z0=%f\n",
|
||||
m_area->z0);
|
||||
m_area.z0);
|
||||
} else if (attributeName.compare(L"x1") == 0) {
|
||||
m_area->x1 = _fromString<int>(attributeValue);
|
||||
m_area.x1 = _fromString<int>(attributeValue);
|
||||
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter x1=%f\n",
|
||||
m_area->x1);
|
||||
m_area.x1);
|
||||
} else if (attributeName.compare(L"y1") == 0) {
|
||||
m_area->y1 = _fromString<int>(attributeValue);
|
||||
if (m_area->y1 < 0) m_area->y1 = 0;
|
||||
m_area.y1 = _fromString<int>(attributeValue);
|
||||
if (m_area.y1 < 0) m_area.y1 = 0;
|
||||
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter y1=%f\n",
|
||||
m_area->y1);
|
||||
m_area.y1);
|
||||
} else if (attributeName.compare(L"z1") == 0) {
|
||||
m_area->z1 = _fromString<int>(attributeValue);
|
||||
m_area.z1 = _fromString<int>(attributeValue);
|
||||
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter z1=%f\n",
|
||||
m_area->z1);
|
||||
m_area.z1);
|
||||
} else {
|
||||
GameRuleDefinition::addAttribute(attributeName, attributeValue);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#include "GameRuleDefinition.h"
|
||||
#include "../../Minecraft.World/Util/AABB.h"
|
||||
|
||||
class NamedAreaRuleDefinition : public GameRuleDefinition {
|
||||
private:
|
||||
std::wstring m_name;
|
||||
AABB* m_area;
|
||||
AABB m_area;
|
||||
|
||||
public:
|
||||
NamedAreaRuleDefinition();
|
||||
~NamedAreaRuleDefinition();
|
||||
|
||||
virtual void writeAttributes(DataOutputStream* dos,
|
||||
unsigned int numAttributes);
|
||||
|
|
@ -21,6 +21,6 @@ public:
|
|||
virtual void addAttribute(const std::wstring& attributeName,
|
||||
const std::wstring& attributeValue);
|
||||
|
||||
AABB* getArea() { return m_area; }
|
||||
AABB* getArea() { return &m_area; }
|
||||
std::wstring getName() { return m_name; }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,25 +10,19 @@ AreaConstraint::AreaConstraint(int descriptionId, double x0, double y0,
|
|||
bool contains /*= true*/,
|
||||
bool restrictsMovement /*=true*/)
|
||||
: TutorialConstraint(descriptionId) {
|
||||
messageArea =
|
||||
new AABB(x0 + 2, y0 + 2, z0 + 2, x1 - 2, y1 - 2, z1 - 2);
|
||||
movementArea = new AABB(x0, y0, z0, x1, y1, z1);
|
||||
messageArea = AABB(x0 + 2, y0 + 2, z0 + 2, x1 - 2, y1 - 2, z1 - 2);
|
||||
movementArea = AABB(x0, y0, z0, x1, y1, z1);
|
||||
|
||||
this->contains = contains;
|
||||
m_restrictsMovement = restrictsMovement;
|
||||
}
|
||||
|
||||
AreaConstraint::~AreaConstraint() {
|
||||
delete messageArea;
|
||||
delete movementArea;
|
||||
}
|
||||
|
||||
bool AreaConstraint::isConstraintSatisfied(int iPad) {
|
||||
Minecraft* minecraft = Minecraft::GetInstance();
|
||||
|
||||
// TODO: check if this can be elided
|
||||
Vec3 ipad_player = minecraft->localplayers[iPad]->getPos(1);
|
||||
return messageArea->contains(ipad_player) == contains;
|
||||
return messageArea.contains(ipad_player) == contains;
|
||||
}
|
||||
|
||||
bool AreaConstraint::isConstraintRestrictive(int iPad) {
|
||||
|
|
@ -42,12 +36,12 @@ bool AreaConstraint::canMoveToPosition(double xo, double yo, double zo,
|
|||
Vec3 targetPos(xt, yt, zt);
|
||||
Minecraft* minecraft = Minecraft::GetInstance();
|
||||
|
||||
if (movementArea->contains(targetPos) == contains) {
|
||||
if (movementArea.contains(targetPos) == contains) {
|
||||
return true;
|
||||
}
|
||||
Vec3 origPos(xo, yo, zo);
|
||||
|
||||
double currDist = origPos.distanceTo(movementArea);
|
||||
double targetDist = targetPos.distanceTo(movementArea);
|
||||
double currDist = origPos.distanceTo(&movementArea);
|
||||
double targetDist = targetPos.distanceTo(&movementArea);
|
||||
return targetDist < currDist;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ class AABB;
|
|||
|
||||
class AreaConstraint : public TutorialConstraint {
|
||||
private:
|
||||
AABB* movementArea;
|
||||
AABB* messageArea;
|
||||
AABB movementArea;
|
||||
AABB messageArea;
|
||||
bool contains; // If true we must stay in this area, if false must stay out
|
||||
// of this area
|
||||
bool m_restrictsMovement;
|
||||
|
|
@ -18,10 +18,9 @@ public:
|
|||
AreaConstraint(int descriptionId, double x0, double y0, double z0,
|
||||
double x1, double y1, double z1, bool contains = true,
|
||||
bool restrictsMovement = true);
|
||||
~AreaConstraint();
|
||||
|
||||
virtual bool isConstraintSatisfied(int iPad);
|
||||
virtual bool isConstraintRestrictive(int iPad);
|
||||
virtual bool canMoveToPosition(double xo, double yo, double zo, double xt,
|
||||
double yt, double zt);
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ AreaHint::AreaHint(eTutorial_Hint id, Tutorial* tutorial,
|
|||
double x1, double y1, double z1, bool allowFade /*= false*/,
|
||||
bool contains /*= true*/)
|
||||
: TutorialHint(id, tutorial, descriptionId, e_Hint_Area, allowFade) {
|
||||
area = new AABB(x0, y0, z0, x1, y1, z1);
|
||||
area = AABB(x0, y0, z0, x1, y1, z1);
|
||||
|
||||
this->contains = contains;
|
||||
|
||||
|
|
@ -20,15 +20,13 @@ AreaHint::AreaHint(eTutorial_Hint id, Tutorial* tutorial,
|
|||
m_completeState = completeState;
|
||||
}
|
||||
|
||||
AreaHint::~AreaHint() { delete area; }
|
||||
|
||||
int AreaHint::tick() {
|
||||
Minecraft* minecraft = Minecraft::GetInstance();
|
||||
Vec3 player_pos = minecraft->player->getPos(1);
|
||||
|
||||
if ((m_displayState == e_Tutorial_State_Any ||
|
||||
m_tutorial->getCurrentState() == m_displayState) &&
|
||||
m_hintNeeded && area->contains(player_pos) == contains) {
|
||||
m_hintNeeded && area.contains(player_pos) == contains) {
|
||||
if (m_completeState == e_Tutorial_State_None) {
|
||||
m_hintNeeded = false;
|
||||
} else if (m_tutorial->isStateCompleted(m_completeState)) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class AABB;
|
|||
|
||||
class AreaHint : public TutorialHint {
|
||||
private:
|
||||
AABB* area;
|
||||
AABB area;
|
||||
bool contains; // If true we must stay in this area, if false must stay out
|
||||
// of this area
|
||||
|
||||
|
|
@ -21,7 +21,6 @@ public:
|
|||
eTutorial_State displayState, eTutorial_State completeState,
|
||||
int descriptionId, double x0, double y0, double z0, double x1,
|
||||
double y1, double z1, bool allowFade = true, bool contains = true);
|
||||
~AreaHint();
|
||||
|
||||
virtual int tick();
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ ChangeStateConstraint::ChangeStateConstraint(
|
|||
bool contains /*= true*/, bool changeGameMode /*= false*/,
|
||||
GameType* targetGameMode /*= 0*/)
|
||||
: TutorialConstraint(-1) {
|
||||
movementArea = new AABB(x0, y0, z0, x1, y1, z1);
|
||||
movementArea = AABB(x0, y0, z0, x1, y1, z1);
|
||||
|
||||
this->contains = contains;
|
||||
|
||||
|
|
@ -40,7 +40,6 @@ ChangeStateConstraint::ChangeStateConstraint(
|
|||
}
|
||||
|
||||
ChangeStateConstraint::~ChangeStateConstraint() {
|
||||
delete movementArea;
|
||||
if (m_sourceStatesCount > 0) delete[] m_sourceStates;
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +88,7 @@ void ChangeStateConstraint::tick(int iPad) {
|
|||
// TODO: check if this can be elided
|
||||
Vec3 ipad_player = minecraft->localplayers[iPad]->getPos(1);
|
||||
if (!m_bHasChanged && inASourceState &&
|
||||
movementArea->contains(ipad_player) == contains) {
|
||||
movementArea.contains(ipad_player) == contains) {
|
||||
m_bHasChanged = true;
|
||||
m_changedFromState = m_tutorial->getCurrentState();
|
||||
m_tutorial->changeTutorialState(m_targetState);
|
||||
|
|
@ -127,7 +126,7 @@ void ChangeStateConstraint::tick(int iPad) {
|
|||
}
|
||||
}
|
||||
} else if (m_bHasChanged &&
|
||||
movementArea->contains(ipad_player) != contains) {
|
||||
movementArea.contains(ipad_player) != contains) {
|
||||
m_bHasChanged = false;
|
||||
m_tutorial->changeTutorialState(m_changedFromState);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class GameType;
|
|||
|
||||
class ChangeStateConstraint : public TutorialConstraint {
|
||||
private:
|
||||
AABB* movementArea;
|
||||
AABB movementArea;
|
||||
bool contains; // If true we must stay in this area, if false must stay out
|
||||
// of this area
|
||||
bool m_changeGameMode;
|
||||
|
|
|
|||
|
|
@ -245,10 +245,10 @@ void LocalPlayer::aiStep() {
|
|||
if (ySlideOffset < 0.2f) ySlideOffset = 0.2f;
|
||||
}
|
||||
|
||||
checkInTile(x - bbWidth * 0.35, bb->y0 + 0.5, z + bbWidth * 0.35);
|
||||
checkInTile(x - bbWidth * 0.35, bb->y0 + 0.5, z - bbWidth * 0.35);
|
||||
checkInTile(x + bbWidth * 0.35, bb->y0 + 0.5, z - bbWidth * 0.35);
|
||||
checkInTile(x + bbWidth * 0.35, bb->y0 + 0.5, z + bbWidth * 0.35);
|
||||
checkInTile(x - bbWidth * 0.35, bb.y0 + 0.5, z + bbWidth * 0.35);
|
||||
checkInTile(x - bbWidth * 0.35, bb.y0 + 0.5, z - bbWidth * 0.35);
|
||||
checkInTile(x + bbWidth * 0.35, bb.y0 + 0.5, z - bbWidth * 0.35);
|
||||
checkInTile(x + bbWidth * 0.35, bb.y0 + 0.5, z + bbWidth * 0.35);
|
||||
|
||||
bool enoughFoodToSprint =
|
||||
getFoodData()->getFoodLevel() >
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ void MultiplayerLocalPlayer::sendPosition() {
|
|||
}
|
||||
|
||||
double xdd = x - xLast;
|
||||
double ydd1 = bb->y0 - yLast1;
|
||||
double ydd1 = bb.y0 - yLast1;
|
||||
double zdd = z - zLast;
|
||||
|
||||
double rydd = yRot - yRotLast;
|
||||
|
|
@ -158,11 +158,11 @@ void MultiplayerLocalPlayer::sendPosition() {
|
|||
if (move && rot) {
|
||||
connection->send(
|
||||
std::shared_ptr<MovePlayerPacket>(new MovePlayerPacket::PosRot(
|
||||
x, bb->y0, y, z, yRot, xRot, onGround, abilities.flying)));
|
||||
x, bb.y0, y, z, yRot, xRot, onGround, abilities.flying)));
|
||||
} else if (move) {
|
||||
connection->send(
|
||||
std::shared_ptr<MovePlayerPacket>(new MovePlayerPacket::Pos(
|
||||
x, bb->y0, y, z, onGround, abilities.flying)));
|
||||
x, bb.y0, y, z, onGround, abilities.flying)));
|
||||
} else if (rot) {
|
||||
connection->send(
|
||||
std::shared_ptr<MovePlayerPacket>(new MovePlayerPacket::Rot(
|
||||
|
|
@ -178,7 +178,7 @@ void MultiplayerLocalPlayer::sendPosition() {
|
|||
|
||||
if (move) {
|
||||
xLast = x;
|
||||
yLast1 = bb->y0;
|
||||
yLast1 = bb.y0;
|
||||
yLast2 = y;
|
||||
zLast = z;
|
||||
positionReminder = 0;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,8 @@ Chunk::Chunk(Level* level, LevelRenderer::rteMap& globalRenderableTileEntities,
|
|||
: globalRenderableTileEntities(&globalRenderableTileEntities),
|
||||
globalRenderableTileEntities_cs(&globalRenderableTileEntities_cs) {
|
||||
clipChunk->visible = false;
|
||||
bb = NULL;
|
||||
const double g = 6;
|
||||
bb = AABB(-g, -g, -g, XZSIZE + g, SIZE + g, XZSIZE + g);
|
||||
id = 0;
|
||||
|
||||
this->level = level;
|
||||
|
|
@ -92,21 +93,13 @@ void Chunk::setPos(int x, int y, int z) {
|
|||
#endif
|
||||
|
||||
float g = 6.0f;
|
||||
// 4J - changed to just set the value rather than make a new one, if we've
|
||||
// already created storage
|
||||
if (bb == NULL) {
|
||||
bb = new AABB(-g, -g, -g, XZSIZE + g, SIZE + g, XZSIZE + g);
|
||||
} else {
|
||||
// 4J MGH - bounds are relative to the position now, so the AABB will be
|
||||
// setup already, either above, or from the tesselator bounds.
|
||||
// bb->set(-g, -g, -g, SIZE+g, SIZE+g, SIZE+g);
|
||||
}
|
||||
clipChunk->aabb[0] = bb->x0 + x;
|
||||
clipChunk->aabb[1] = bb->y0 + y;
|
||||
clipChunk->aabb[2] = bb->z0 + z;
|
||||
clipChunk->aabb[3] = bb->x1 + x;
|
||||
clipChunk->aabb[4] = bb->y1 + y;
|
||||
clipChunk->aabb[5] = bb->z1 + z;
|
||||
|
||||
clipChunk->aabb[0] = bb.x0 + x;
|
||||
clipChunk->aabb[1] = bb.y0 + y;
|
||||
clipChunk->aabb[2] = bb.z0 + z;
|
||||
clipChunk->aabb[3] = bb.x1 + x;
|
||||
clipChunk->aabb[4] = bb.y1 + y;
|
||||
clipChunk->aabb[5] = bb.z1 + z;
|
||||
|
||||
assigned = true;
|
||||
|
||||
|
|
@ -508,11 +501,8 @@ void Chunk::rebuild() {
|
|||
|
||||
// 4J MGH - added this to take the bound from the value calc'd in the
|
||||
// tesselator
|
||||
if (bb) {
|
||||
*bb = {bounds.boundingBox[0], bounds.boundingBox[1],
|
||||
bounds.boundingBox[2], bounds.boundingBox[3],
|
||||
bounds.boundingBox[4], bounds.boundingBox[5]};
|
||||
}
|
||||
bb = {bounds.boundingBox[0], bounds.boundingBox[1], bounds.boundingBox[2],
|
||||
bounds.boundingBox[3], bounds.boundingBox[4], bounds.boundingBox[5]};
|
||||
|
||||
delete tileRenderer;
|
||||
delete region;
|
||||
|
|
@ -1033,7 +1023,7 @@ int Chunk::getList(int layer) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
void Chunk::cull(Culler* culler) { clipChunk->visible = culler->isVisible(bb); }
|
||||
void Chunk::cull(Culler* culler) { clipChunk->visible = culler->isVisible(&bb); }
|
||||
|
||||
void Chunk::renderBB() {
|
||||
// glCallList(lists + 2); // 4J - removed - TODO put back in
|
||||
|
|
@ -1064,8 +1054,6 @@ void Chunk::clearDirty() {
|
|||
#endif
|
||||
}
|
||||
|
||||
Chunk::~Chunk() { delete bb; }
|
||||
|
||||
bool Chunk::emptyFlagSet(int layer) {
|
||||
return levelRenderer->getGlobalChunkFlag(
|
||||
x, y, z, level, LevelRenderer::CHUNK_FLAG_EMPTY0, layer);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public:
|
|||
int xRenderOffs, yRenderOffs, zRenderOffs;
|
||||
|
||||
int xm, ym, zm;
|
||||
AABB* bb;
|
||||
AABB bb;
|
||||
ClipChunk* clipChunk;
|
||||
|
||||
int id;
|
||||
|
|
@ -88,5 +88,4 @@ public:
|
|||
void setDirty();
|
||||
void clearDirty(); // 4J added
|
||||
bool emptyFlagSet(int layer);
|
||||
~Chunk();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ void EntityRenderer::renderFlame(std::shared_ptr<Entity> e, double x, double y,
|
|||
float xo = 0.0f;
|
||||
|
||||
float h = e->bbHeight / s;
|
||||
float yo = (float)(e->y - e->bb->y0);
|
||||
float yo = (float)(e->y - e->bb.y0);
|
||||
|
||||
glRotatef(-entityRenderDispatcher->playerRotY, 0, 1, 0);
|
||||
|
||||
|
|
@ -394,4 +394,4 @@ void EntityRenderer::registerTerrainTextures(IconRegister* iconRegister) {}
|
|||
ResourceLocation* EntityRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ void FireballRenderer::renderFlame(std::shared_ptr<Entity> e, double x,
|
|||
// float yo = 0.0f;
|
||||
|
||||
float h = e->bbHeight / s;
|
||||
float yo = (float)(e->y - e->bb->y0);
|
||||
float yo = (float)(e->y - e->bb.y0);
|
||||
|
||||
// glRotatef(-entityRenderDispatcher->playerRotY, 0, 1, 0);
|
||||
|
||||
|
|
@ -118,4 +118,4 @@ void FireballRenderer::renderFlame(std::shared_ptr<Entity> e, double x,
|
|||
ResourceLocation* FireballRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &TextureAtlas::LOCATION_ITEMS;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ void GameRenderer::pick(float a) {
|
|||
hovered = nullptr;
|
||||
float overlap = 1;
|
||||
AABB grown = mc->cameraTargetPlayer->bb
|
||||
->expand(b.x * (range), b.y * (range), b.z * (range))
|
||||
.expand(b.x * (range), b.y * (range), b.z * (range))
|
||||
.grow(overlap, overlap, overlap);
|
||||
|
||||
std::vector<std::shared_ptr<Entity> >* objects =
|
||||
|
|
@ -323,7 +323,7 @@ void GameRenderer::pick(float a) {
|
|||
if (!e->isPickable()) continue;
|
||||
|
||||
float rr = e->getPickRadius();
|
||||
AABB bb = e->bb->grow(rr, rr, rr);
|
||||
AABB bb = e->bb.grow(rr, rr, rr);
|
||||
HitResult* p = bb.clip(from, to);
|
||||
if (bb.contains(from)) {
|
||||
if (0 < nearest || nearest == 0) {
|
||||
|
|
|
|||
|
|
@ -585,14 +585,14 @@ void LevelRenderer::renderEntities(Vec3* cam, Culler* culler, float a) {
|
|||
|
||||
bool shouldRender =
|
||||
(entity->shouldRender(cam) &&
|
||||
(entity->noCulling || culler->isVisible(entity->bb)));
|
||||
(entity->noCulling || culler->isVisible(&entity->bb)));
|
||||
|
||||
// Render the mob if the mob's leash holder is within the culler
|
||||
if (!shouldRender && entity->instanceof(eTYPE_MOB)) {
|
||||
std::shared_ptr<Mob> mob = std::dynamic_pointer_cast<Mob>(entity);
|
||||
if (mob->isLeashed() && (mob->getLeashHolder() != NULL)) {
|
||||
std::shared_ptr<Entity> leashHolder = mob->getLeashHolder();
|
||||
shouldRender = culler->isVisible(leashHolder->bb);
|
||||
shouldRender = culler->isVisible(&leashHolder->bb);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@ void CritParticle::_init(Level* level, std::shared_ptr<Entity> entity,
|
|||
}
|
||||
|
||||
CritParticle::CritParticle(Level* level, std::shared_ptr<Entity> entity)
|
||||
: Particle(level, entity->x, entity->bb->y0 + entity->bbHeight / 2,
|
||||
: Particle(level, entity->x, entity->bb.y0 + entity->bbHeight / 2,
|
||||
entity->z, entity->xd, entity->yd, entity->zd) {
|
||||
_init(level, entity, eParticleType_crit);
|
||||
}
|
||||
|
||||
CritParticle::CritParticle(Level* level, std::shared_ptr<Entity> entity,
|
||||
ePARTICLE_TYPE type)
|
||||
: Particle(level, entity->x, entity->bb->y0 + entity->bbHeight / 2,
|
||||
: Particle(level, entity->x, entity->bb.y0 + entity->bbHeight / 2,
|
||||
entity->z, entity->xd, entity->yd, entity->zd) {
|
||||
_init(level, entity, type);
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ void CritParticle::tick() {
|
|||
if (xa * xa + ya * ya + za * za > 1) continue;
|
||||
double x = entity->x + xa * entity->bbWidth / 4;
|
||||
double y =
|
||||
entity->bb->y0 + entity->bbHeight / 2 + ya * entity->bbHeight / 4;
|
||||
entity->bb.y0 + entity->bbHeight / 2 + ya * entity->bbHeight / 4;
|
||||
double z = entity->z + za * entity->bbWidth / 4;
|
||||
level->addParticle(particleName, x, y, z, xa, ya + 0.2, za);
|
||||
}
|
||||
|
|
@ -55,4 +55,4 @@ void CritParticle::tick() {
|
|||
|
||||
int CritParticle::getParticleTexture() {
|
||||
return ParticleEngine::ENTITY_PARTICLE_TEXTURE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@ void PlayerCloudParticle::tick() {
|
|||
zd *= 0.96f;
|
||||
std::shared_ptr<Player> p = level->getNearestPlayer(shared_from_this(), 2);
|
||||
if (p != NULL) {
|
||||
if (y > p->bb->y0) {
|
||||
y += (p->bb->y0 - y) * 0.2;
|
||||
if (y > p->bb.y0) {
|
||||
y += (p->bb.y0 - y) * 0.2;
|
||||
yd += (p->yd - yd) * 0.2;
|
||||
setPos(x, y, z);
|
||||
}
|
||||
|
|
@ -63,4 +63,4 @@ void PlayerCloudParticle::tick() {
|
|||
xd *= 0.7f;
|
||||
zd *= 0.7f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ void LookControl::setLookAt(std::shared_ptr<Entity> target, float yMax,
|
|||
target->y +
|
||||
std::dynamic_pointer_cast<LivingEntity>(target)->getHeadHeight();
|
||||
else
|
||||
wantedY = (target->bb->y0 + target->bb->y1) / 2;
|
||||
wantedY = (target->bb.y0 + target->bb.y1) / 2;
|
||||
wantedZ = target->z;
|
||||
this->yMax = yMax;
|
||||
this->xMax = xMax;
|
||||
|
|
@ -88,4 +88,4 @@ double LookControl::getWantedX() { return wantedX; }
|
|||
|
||||
double LookControl::getWantedY() { return wantedY; }
|
||||
|
||||
double LookControl::getWantedZ() { return wantedZ; }
|
||||
double LookControl::getWantedZ() { return wantedZ; }
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ void MoveControl::tick() {
|
|||
if (!_hasWanted) return;
|
||||
_hasWanted = false;
|
||||
|
||||
int yFloor = floor(mob->bb->y0 + .5f);
|
||||
int yFloor = floor(mob->bb.y0 + .5f);
|
||||
|
||||
double xd = wantedX - mob->x;
|
||||
double zd = wantedZ - mob->z;
|
||||
|
|
@ -66,4 +66,4 @@ float MoveControl::rotlerp(float a, float b, float max) {
|
|||
diff = -max;
|
||||
}
|
||||
return a + diff;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ bool AvoidPlayerGoal::canUse() {
|
|||
mob->level->getNearestPlayer(mob->shared_from_this(), maxDist));
|
||||
if (toAvoid.lock() == NULL) return false;
|
||||
} else {
|
||||
AABB grown_bb = mob->bb->grow(maxDist, 3, maxDist);
|
||||
AABB grown_bb = mob->bb.grow(maxDist, 3, maxDist);
|
||||
std::vector<std::shared_ptr<Entity> >* entities =
|
||||
mob->level->getEntitiesOfClass(
|
||||
avoidType, &grown_bb, entitySelector);
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ void BreedGoal::tick() {
|
|||
|
||||
std::shared_ptr<Animal> BreedGoal::getFreePartner() {
|
||||
float r = 8;
|
||||
AABB grown_bb = animal->bb->grow(r, r, r);
|
||||
AABB grown_bb = animal->bb.grow(r, r, r);
|
||||
std::vector<std::shared_ptr<Entity> >* others =
|
||||
level->getEntitiesOfClass(typeid(*animal), &grown_bb);
|
||||
double dist = std::numeric_limits<double>::max();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ FleeSunGoal::FleeSunGoal(PathfinderMob* mob, double speedModifier) {
|
|||
bool FleeSunGoal::canUse() {
|
||||
if (!level->isDay()) return false;
|
||||
if (!mob->isOnFire()) return false;
|
||||
if (!level->canSeeSky(Mth::floor(mob->x), (int)mob->bb->y0,
|
||||
if (!level->canSeeSky(Mth::floor(mob->x), (int)mob->bb.y0,
|
||||
Mth::floor(mob->z)))
|
||||
return false;
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ std::optional<Vec3> FleeSunGoal::getHidePos() {
|
|||
Random* random = mob->getRandom();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
int xt = Mth::floor(mob->x + random->nextInt(20) - 10);
|
||||
int yt = Mth::floor(mob->bb->y0 + random->nextInt(6) - 3);
|
||||
int yt = Mth::floor(mob->bb.y0 + random->nextInt(6) - 3);
|
||||
int zt = Mth::floor(mob->z + random->nextInt(20) - 10);
|
||||
if (!level->canSeeSky(xt, yt, zt) &&
|
||||
mob->getWalkTargetValue(xt, yt, zt) < 0)
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ void FollowOwnerGoal::tick() {
|
|||
// find a good spawn position nearby the owner
|
||||
int sx = Mth::floor(owner.lock()->x) - 2;
|
||||
int sz = Mth::floor(owner.lock()->z) - 2;
|
||||
int y = Mth::floor(owner.lock()->bb->y0);
|
||||
int y = Mth::floor(owner.lock()->bb.y0);
|
||||
for (int x = 0; x <= 4; x++) {
|
||||
for (int z = 0; z <= 4; z++) {
|
||||
if (x >= 1 && z >= 1 && x <= 3 && z <= 3) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ FollowParentGoal::FollowParentGoal(Animal* animal, double speedModifier) {
|
|||
bool FollowParentGoal::canUse() {
|
||||
if (animal->getAge() >= 0) return false;
|
||||
|
||||
AABB grown_bb = animal->bb->grow(8, 4, 8);
|
||||
AABB grown_bb = animal->bb.grow(8, 4, 8);
|
||||
std::vector<std::shared_ptr<Entity> >* parents =
|
||||
animal->level->getEntitiesOfClass(typeid(*animal), &grown_bb);
|
||||
|
||||
|
|
|
|||
|
|
@ -37,10 +37,9 @@ bool LookAtPlayerGoal::canUse() {
|
|||
lookAt =
|
||||
mob->level->getNearestPlayer(mob->shared_from_this(), lookDistance);
|
||||
} else {
|
||||
AABB mob_bb = mob->bb->grow(lookDistance, 3, lookDistance);
|
||||
AABB mob_bb = mob->bb.grow(lookDistance, 3, lookDistance);
|
||||
lookAt = std::weak_ptr<Entity>(mob->level->getClosestEntityOfClass(
|
||||
lookAtType, &mob_bb,
|
||||
mob->shared_from_this()));
|
||||
lookAtType, &mob_bb, mob->shared_from_this()));
|
||||
}
|
||||
return lookAt.lock() != NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,10 +29,9 @@ bool MakeLoveGoal::canUse() {
|
|||
if (village.lock() == NULL) return false;
|
||||
if (!villageNeedsMoreVillagers()) return false;
|
||||
|
||||
AABB villager_bb = villager->bb->grow(8, 3, 8);
|
||||
AABB villager_bb = villager->bb.grow(8, 3, 8);
|
||||
std::shared_ptr<Entity> mate = level->getClosestEntityOfClass(
|
||||
typeid(Villager), &villager_bb,
|
||||
villager->shared_from_this());
|
||||
typeid(Villager), &villager_bb, villager->shared_from_this());
|
||||
if (mate == NULL) return false;
|
||||
|
||||
partner =
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ bool MeleeAttackGoal::canUse() {
|
|||
std::shared_ptr<LivingEntity> target = mob->getTarget();
|
||||
if (target == NULL) return false;
|
||||
if (!target->isAlive()) return false;
|
||||
if (attackType != eTYPE_NOTSET && !target->instanceof (attackType))
|
||||
if (attackType != eTYPE_NOTSET && !target->instanceof(attackType))
|
||||
return false;
|
||||
path.reset(mob->getNavigation()->createPath(target));
|
||||
return path != nullptr;
|
||||
|
|
@ -79,7 +79,7 @@ void MeleeAttackGoal::tick() {
|
|||
|
||||
double meleeRadiusSqr =
|
||||
(mob->bbWidth * 2) * (mob->bbWidth * 2) + target->bbWidth;
|
||||
if (mob->distanceToSqr(target->x, target->bb->y0, target->z) >
|
||||
if (mob->distanceToSqr(target->x, target->bb.y0, target->z) >
|
||||
meleeRadiusSqr)
|
||||
return;
|
||||
if (attackTime > 0) return;
|
||||
|
|
|
|||
|
|
@ -55,10 +55,9 @@ bool NearestAttackableTargetGoal::canUse() {
|
|||
return false;
|
||||
double within = getFollowDistance();
|
||||
|
||||
AABB mob_bb = mob->bb->grow(within, 4, within);
|
||||
AABB mob_bb = mob->bb.grow(within, 4, within);
|
||||
std::vector<std::shared_ptr<Entity> >* entities =
|
||||
mob->level->getEntitiesOfClass(
|
||||
targetType, &mob_bb, selector);
|
||||
mob->level->getEntitiesOfClass(targetType, &mob_bb, selector);
|
||||
|
||||
bool result = false;
|
||||
if (entities != NULL && !entities->empty()) {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ void OcelotAttackGoal::tick() {
|
|||
mob->getLookControl()->setLookAt(target.lock(), 30, 30);
|
||||
|
||||
double meleeRadiusSqr = (mob->bbWidth * 2) * (mob->bbWidth * 2);
|
||||
double distSqr = mob->distanceToSqr(target.lock()->x, target.lock()->bb->y0,
|
||||
double distSqr = mob->distanceToSqr(target.lock()->x, target.lock()->bb.y0,
|
||||
target.lock()->z);
|
||||
|
||||
double speedModifier = Ocelot::WALK_SPEED_MOD;
|
||||
|
|
|
|||
|
|
@ -15,10 +15,9 @@ OfferFlowerGoal::OfferFlowerGoal(VillagerGolem* golem) {
|
|||
bool OfferFlowerGoal::canUse() {
|
||||
if (!golem->level->isDay()) return false;
|
||||
if (golem->getRandom()->nextInt(8000) != 0) return false;
|
||||
AABB golem_bb = golem->bb->grow(6, 2, 6);
|
||||
AABB golem_bb = golem->bb.grow(6, 2, 6);
|
||||
villager = std::weak_ptr<Villager>(std::dynamic_pointer_cast<Villager>(
|
||||
golem->level->getClosestEntityOfClass(typeid(Villager),
|
||||
&golem_bb,
|
||||
golem->level->getClosestEntityOfClass(typeid(Villager), &golem_bb,
|
||||
golem->shared_from_this())));
|
||||
return villager.lock() != NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,10 +23,9 @@ bool PlayGoal::canUse() {
|
|||
if (mob->getAge() >= 0) return false;
|
||||
if (mob->getRandom()->nextInt(400) != 0) return false;
|
||||
|
||||
AABB mob_bb = mob->bb->grow(6, 3, 6);
|
||||
AABB mob_bb = mob->bb.grow(6, 3, 6);
|
||||
std::vector<std::shared_ptr<Entity> >* children =
|
||||
mob->level->getEntitiesOfClass(typeid(Villager),
|
||||
&mob_bb);
|
||||
mob->level->getEntitiesOfClass(typeid(Villager), &mob_bb);
|
||||
double closestDistSqr = std::numeric_limits<double>::max();
|
||||
// for (Entity c : children)
|
||||
for (AUTO_VAR(it, children->begin()); it != children->end(); ++it) {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ void RangedAttackGoal::tick() {
|
|||
if (target.lock() == NULL) return;
|
||||
|
||||
double targetDistSqr = mob->distanceToSqr(
|
||||
target.lock()->x, target.lock()->bb->y0, target.lock()->z);
|
||||
target.lock()->x, target.lock()->bb.y0, target.lock()->z);
|
||||
bool canSee = mob->getSensing()->canSee(target.lock());
|
||||
|
||||
if (canSee) {
|
||||
|
|
@ -100,4 +100,4 @@ void RangedAttackGoal::tick() {
|
|||
attackTime = Mth::floor(dist * (attackIntervalMax - attackIntervalMin) +
|
||||
attackIntervalMin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ bool TakeFlowerGoal::canUse() {
|
|||
if (villager->getAge() >= 0) return false;
|
||||
if (!villager->level->isDay()) return false;
|
||||
|
||||
AABB villager_bb = villager->bb->grow(6, 2, 6);
|
||||
AABB villager_bb = villager->bb.grow(6, 2, 6);
|
||||
std::vector<std::shared_ptr<Entity> >* golems =
|
||||
villager->level->getEntitiesOfClass(typeid(VillagerGolem),
|
||||
&villager_bb);
|
||||
&villager_bb);
|
||||
if (golems->size() == 0) {
|
||||
delete golems;
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ PathFinder::~PathFinder() {
|
|||
}
|
||||
|
||||
Path* PathFinder::findPath(Entity* from, Entity* to, float maxDist) {
|
||||
return findPath(from, to->x, to->bb->y0, to->z, maxDist);
|
||||
return findPath(from, to->x, to->bb.y0, to->z, maxDist);
|
||||
}
|
||||
|
||||
Path* PathFinder::findPath(Entity* from, int x, int y, int z, float maxDist) {
|
||||
|
|
@ -46,9 +46,9 @@ Path* PathFinder::findPath(Entity* e, double xt, double yt, double zt,
|
|||
nodes.clear();
|
||||
|
||||
bool resetAvoidWater = avoidWater;
|
||||
int startY = Mth::floor(e->bb->y0 + 0.5f);
|
||||
int startY = Mth::floor(e->bb.y0 + 0.5f);
|
||||
if (canFloat && e->isInWater()) {
|
||||
startY = (int)(e->bb->y0);
|
||||
startY = (int)(e->bb.y0);
|
||||
int tileId = level->getTile((int)Mth::floor(e->x), startY,
|
||||
(int)Mth::floor(e->z));
|
||||
while (tileId == Tile::water_Id || tileId == Tile::calmWater_Id) {
|
||||
|
|
@ -59,9 +59,9 @@ Path* PathFinder::findPath(Entity* e, double xt, double yt, double zt,
|
|||
resetAvoidWater = avoidWater;
|
||||
avoidWater = false;
|
||||
} else
|
||||
startY = Mth::floor(e->bb->y0 + 0.5f);
|
||||
startY = Mth::floor(e->bb.y0 + 0.5f);
|
||||
|
||||
Node* from = getNode((int)floor(e->bb->x0), startY, (int)floor(e->bb->z0));
|
||||
Node* from = getNode((int)floor(e->bb.x0), startY, (int)floor(e->bb.z0));
|
||||
Node* to = getNode((int)floor(xt - e->bbWidth / 2), (int)floor(yt),
|
||||
(int)floor(zt - e->bbWidth / 2));
|
||||
|
||||
|
|
|
|||
|
|
@ -188,9 +188,9 @@ Vec3 PathNavigation::getTempMobPos() {
|
|||
}
|
||||
|
||||
int PathNavigation::getSurfaceY() {
|
||||
if (!mob->isInWater() || !canFloat) return (int)(mob->bb->y0 + 0.5);
|
||||
if (!mob->isInWater() || !canFloat) return (int)(mob->bb.y0 + 0.5);
|
||||
|
||||
int surface = (int)(mob->bb->y0);
|
||||
int surface = (int)(mob->bb.y0);
|
||||
int tileId =
|
||||
level->getTile(Mth::floor(mob->x), surface, Mth::floor(mob->z));
|
||||
int steps = 0;
|
||||
|
|
@ -198,7 +198,7 @@ int PathNavigation::getSurfaceY() {
|
|||
++surface;
|
||||
tileId =
|
||||
level->getTile(Mth::floor(mob->x), surface, Mth::floor(mob->z));
|
||||
if (++steps > 16) return (int)(mob->bb->y0);
|
||||
if (++steps > 16) return (int)(mob->bb.y0);
|
||||
}
|
||||
return surface;
|
||||
}
|
||||
|
|
@ -212,7 +212,7 @@ bool PathNavigation::isInLiquid() {
|
|||
}
|
||||
|
||||
void PathNavigation::trimPathFromSun() {
|
||||
if (level->canSeeSky(Mth::floor(mob->x), (int)(mob->bb->y0 + 0.5),
|
||||
if (level->canSeeSky(Mth::floor(mob->x), (int)(mob->bb.y0 + 0.5),
|
||||
Mth::floor(mob->z)))
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ void FallingTile::causeFallDamage(float distance) {
|
|||
// entities (invalidating our iterator)
|
||||
std::vector<std::shared_ptr<Entity> >* entities =
|
||||
new std::vector<std::shared_ptr<Entity> >(
|
||||
*level->getEntities(shared_from_this(), bb));
|
||||
*level->getEntities(shared_from_this(), &bb));
|
||||
DamageSource* source = tile == Tile::anvil_Id
|
||||
? DamageSource::anvil
|
||||
: DamageSource::fallingBlock;
|
||||
|
|
@ -242,4 +242,4 @@ Level* FallingTile::getLevel() { return level; }
|
|||
|
||||
void FallingTile::setHurtsEntities(bool value) { this->hurtEntities = value; }
|
||||
|
||||
bool FallingTile::displayFireAnimation() { return false; }
|
||||
bool FallingTile::displayFireAnimation() { return false; }
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ void Entity::_init(bool useSmallId, Level* level) {
|
|||
xd = yd = zd = 0.0;
|
||||
yRot = xRot = 0.0f;
|
||||
yRotO = xRotO = 0.0f;
|
||||
bb = new AABB(0, 0, 0, 0, 0, 0); // 4J Was final
|
||||
bb = AABB(0, 0, 0, 0, 0, 0); // 4J Was final
|
||||
onGround = false;
|
||||
horizontalCollision = verticalCollision = false;
|
||||
collision = false;
|
||||
|
|
@ -376,7 +376,6 @@ Entity::Entity(Level* level,
|
|||
Entity::~Entity() {
|
||||
freeSmallId(entityId);
|
||||
delete random;
|
||||
delete bb;
|
||||
}
|
||||
|
||||
std::shared_ptr<SynchedEntityData> Entity::getEntityData() {
|
||||
|
|
@ -402,7 +401,7 @@ void Entity::resetPos() {
|
|||
std::shared_ptr<Entity> sharedThis = shared_from_this();
|
||||
while (true && y > 0) {
|
||||
setPos(x, y, z);
|
||||
if (level->getCubes(sharedThis, bb)->empty()) break;
|
||||
if (level->getCubes(sharedThis, &bb)->empty()) break;
|
||||
y += 1;
|
||||
}
|
||||
|
||||
|
|
@ -419,9 +418,9 @@ void Entity::setSize(float w, float h) {
|
|||
bbWidth = w;
|
||||
bbHeight = h;
|
||||
|
||||
bb->x1 = bb->x0 + bbWidth;
|
||||
bb->z1 = bb->z0 + bbWidth;
|
||||
bb->y1 = bb->y0 + bbHeight;
|
||||
bb.x1 = bb.x0 + bbWidth;
|
||||
bb.z1 = bb.z0 + bbWidth;
|
||||
bb.y1 = bb.y0 + bbHeight;
|
||||
|
||||
if (bbWidth > oldW && !firstTick && !level->isClientSide) {
|
||||
move(oldW - bbWidth, 0, oldW - bbWidth);
|
||||
|
|
@ -463,7 +462,7 @@ void Entity::setPos(double x, double y, double z) {
|
|||
this->z = z;
|
||||
float w = bbWidth / 2;
|
||||
float h = bbHeight;
|
||||
*bb = {x - w, y - heightOffset + ySlideOffset, z - w, x + w,
|
||||
bb = {x - w, y - heightOffset + ySlideOffset, z - w, x + w,
|
||||
y - heightOffset + ySlideOffset + h, z + w};
|
||||
}
|
||||
|
||||
|
|
@ -551,7 +550,7 @@ void Entity::baseTick() {
|
|||
if (t > 0) {
|
||||
level->addParticle(PARTICLE_TILECRACK(t, d),
|
||||
x + (random->nextFloat() - 0.5) * bbWidth,
|
||||
bb->y0 + 0.1,
|
||||
bb.y0 + 0.1,
|
||||
z + (random->nextFloat() - 0.5) * bbWidth,
|
||||
-xd * 4, 1.5, -zd * 4);
|
||||
}
|
||||
|
|
@ -618,7 +617,7 @@ void Entity::clearFire() { onFire = 0; }
|
|||
void Entity::outOfWorld() { remove(); }
|
||||
|
||||
bool Entity::isFree(float xa, float ya, float za, float grow) {
|
||||
AABB box = bb->grow(grow, grow, grow).move(xa, ya, za);
|
||||
AABB box = bb.grow(grow, grow, grow).move(xa, ya, za);
|
||||
AABBList* aABBs = level->getCubes(shared_from_this(), &box);
|
||||
if (!aABBs->empty()) return false;
|
||||
if (level->containsAnyLiquid(&box)) return false;
|
||||
|
|
@ -626,7 +625,7 @@ bool Entity::isFree(float xa, float ya, float za, float grow) {
|
|||
}
|
||||
|
||||
bool Entity::isFree(double xa, double ya, double za) {
|
||||
AABB box = bb->move(xa, ya, za);
|
||||
AABB box = bb.move(xa, ya, za);
|
||||
AABBList* aABBs = level->getCubes(shared_from_this(), &box);
|
||||
if (!aABBs->empty()) return false;
|
||||
if (level->containsAnyLiquid(&box)) return false;
|
||||
|
|
@ -637,10 +636,10 @@ void Entity::move(double xa, double ya, double za,
|
|||
bool noEntityCubes) // 4J - added noEntityCubes parameter
|
||||
{
|
||||
if (noPhysics) {
|
||||
*bb = bb->move(xa, ya, za);
|
||||
x = (bb->x0 + bb->x1) / 2.0f;
|
||||
y = bb->y0 + heightOffset - ySlideOffset;
|
||||
z = (bb->z0 + bb->z1) / 2.0f;
|
||||
bb = bb.move(xa, ya, za);
|
||||
x = (bb.x0 + bb.x1) / 2.0f;
|
||||
y = bb.y0 + heightOffset - ySlideOffset;
|
||||
z = (bb.z0 + bb.z1) / 2.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -665,15 +664,13 @@ void Entity::move(double xa, double ya, double za,
|
|||
double yaOrg = ya;
|
||||
double zaOrg = za;
|
||||
|
||||
AABB bbOrg = *bb;
|
||||
|
||||
bool isPlayerSneaking =
|
||||
onGround && isSneaking() && instanceof(eTYPE_PLAYER);
|
||||
|
||||
if (isPlayerSneaking) {
|
||||
double d = 0.05;
|
||||
|
||||
AABB translated_bb = bb->move(xa, -1.0, 0.0);
|
||||
AABB translated_bb = bb.move(xa, -1.0, 0.0);
|
||||
while (xa != 0 &&
|
||||
level->getCubes(shared_from_this(), &translated_bb)->empty()) {
|
||||
if (xa < d && xa >= -d)
|
||||
|
|
@ -685,7 +682,7 @@ void Entity::move(double xa, double ya, double za,
|
|||
xaOrg = xa;
|
||||
}
|
||||
|
||||
translated_bb = bb->move(0, -1.0, za);
|
||||
translated_bb = bb.move(0, -1.0, za);
|
||||
while (za != 0 &&
|
||||
level->getCubes(shared_from_this(), &translated_bb)->empty()) {
|
||||
if (za < d && za >= -d)
|
||||
|
|
@ -697,7 +694,7 @@ void Entity::move(double xa, double ya, double za,
|
|||
zaOrg = za;
|
||||
}
|
||||
|
||||
translated_bb = bb->move(xa, -1.0, za);
|
||||
translated_bb = bb.move(xa, -1.0, za);
|
||||
while (xa != 0 && za != 0 &&
|
||||
level->getCubes(shared_from_this(), &translated_bb)->empty()) {
|
||||
if (xa < d && xa >= -d)
|
||||
|
|
@ -717,7 +714,7 @@ void Entity::move(double xa, double ya, double za,
|
|||
}
|
||||
}
|
||||
|
||||
AABB expanded = bb->expand(xa, ya, za);
|
||||
AABB expanded = bb.expand(xa, ya, za);
|
||||
AABBList* aABBs =
|
||||
level->getCubes(shared_from_this(), &expanded, noEntityCubes, true);
|
||||
|
||||
|
|
@ -733,8 +730,8 @@ void Entity::move(double xa, double ya, double za,
|
|||
// But if we don't have the chunk data then all the collision info will
|
||||
// be incorrect as well
|
||||
for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++)
|
||||
ya = it->clipYCollide(*bb, ya);
|
||||
*bb = bb->move(0, ya, 0);
|
||||
ya = it->clipYCollide(bb, ya);
|
||||
bb = bb.move(0, ya, 0);
|
||||
}
|
||||
|
||||
if (!slide && yaOrg != ya) {
|
||||
|
|
@ -745,9 +742,9 @@ void Entity::move(double xa, double ya, double za,
|
|||
|
||||
itEndAABB = aABBs->end();
|
||||
for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++)
|
||||
xa = it->clipXCollide(*bb, xa);
|
||||
xa = it->clipXCollide(bb, xa);
|
||||
|
||||
*bb = bb->move(xa, 0, 0);
|
||||
bb = bb.move(xa, 0, 0);
|
||||
|
||||
if (!slide && xaOrg != xa) {
|
||||
xa = ya = za = 0;
|
||||
|
|
@ -755,8 +752,8 @@ void Entity::move(double xa, double ya, double za,
|
|||
|
||||
itEndAABB = aABBs->end();
|
||||
for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++)
|
||||
za = it->clipZCollide(*bb, za);
|
||||
*bb = bb->move(0, 0, za);
|
||||
za = it->clipZCollide(bb, za);
|
||||
bb = bb.move(0, 0, za);
|
||||
|
||||
if (!slide && zaOrg != za) {
|
||||
xa = ya = za = 0;
|
||||
|
|
@ -772,13 +769,11 @@ void Entity::move(double xa, double ya, double za,
|
|||
ya = footSize;
|
||||
za = zaOrg;
|
||||
|
||||
AABB normal = *bb;
|
||||
*bb = bbOrg;
|
||||
// 4J - added extra expand, as if we don't move up by footSize by
|
||||
// hitting a block above us, then overall we could be trying to move as
|
||||
// much as footSize downwards, so we'd better include cubes under our
|
||||
// feet in this list of things we might possibly collide with
|
||||
AABB expanded = bb->expand(xa, ya, za).expand(0, -ya, 0);
|
||||
AABB expanded = bb.expand(xa, ya, za).expand(0, -ya, 0);
|
||||
aABBs = level->getCubes(shared_from_this(), &expanded, false, true);
|
||||
|
||||
// LAND FIRST, then x and z
|
||||
|
|
@ -789,8 +784,8 @@ void Entity::move(double xa, double ya, double za,
|
|||
// all! But if we don't have the chunk data then all the collision
|
||||
// info will be incorrect as well
|
||||
for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++)
|
||||
ya = it->clipYCollide(*bb, ya);
|
||||
*bb = bb->move(0, ya, 0);
|
||||
ya = it->clipYCollide(bb, ya);
|
||||
bb = bb.move(0, ya, 0);
|
||||
}
|
||||
|
||||
if (!slide && yaOrg != ya) {
|
||||
|
|
@ -799,8 +794,8 @@ void Entity::move(double xa, double ya, double za,
|
|||
|
||||
itEndAABB = aABBs->end();
|
||||
for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++)
|
||||
xa = it->clipXCollide(*bb, xa);
|
||||
*bb = bb->move(xa, 0, 0);
|
||||
xa = it->clipXCollide(bb, xa);
|
||||
bb = bb.move(xa, 0, 0);
|
||||
|
||||
if (!slide && xaOrg != xa) {
|
||||
xa = ya = za = 0;
|
||||
|
|
@ -808,8 +803,8 @@ void Entity::move(double xa, double ya, double za,
|
|||
|
||||
itEndAABB = aABBs->end();
|
||||
for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++)
|
||||
za = it->clipZCollide(*bb, za);
|
||||
*bb = bb->move(0, 0, za);
|
||||
za = it->clipZCollide(bb, za);
|
||||
bb = bb.move(0, 0, za);
|
||||
|
||||
if (!slide && zaOrg != za) {
|
||||
xa = ya = za = 0;
|
||||
|
|
@ -822,21 +817,20 @@ void Entity::move(double xa, double ya, double za,
|
|||
// LAND FIRST, then x and z
|
||||
itEndAABB = aABBs->end();
|
||||
for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++)
|
||||
ya = it->clipYCollide(*bb, ya);
|
||||
*bb = bb->move(0, ya, 0);
|
||||
ya = it->clipYCollide(bb, ya);
|
||||
bb = bb.move(0, ya, 0);
|
||||
}
|
||||
|
||||
if (xaN * xaN + zaN * zaN >= xa * xa + za * za) {
|
||||
xa = xaN;
|
||||
ya = yaN;
|
||||
za = zaN;
|
||||
*bb = normal;
|
||||
}
|
||||
}
|
||||
|
||||
x = (bb->x0 + bb->x1) / 2.0f;
|
||||
y = bb->y0 + heightOffset - ySlideOffset;
|
||||
z = (bb->z0 + bb->z1) / 2.0f;
|
||||
x = (bb.x0 + bb.x1) / 2.0f;
|
||||
y = bb.y0 + heightOffset - ySlideOffset;
|
||||
z = (bb.z0 + bb.z1) / 2.0f;
|
||||
|
||||
horizontalCollision = (xaOrg != xa) || (zaOrg != za);
|
||||
verticalCollision = !m_ignoreVerticalCollisions && (yaOrg != ya);
|
||||
|
|
@ -891,8 +885,8 @@ void Entity::move(double xa, double ya, double za,
|
|||
checkInsideTiles();
|
||||
|
||||
bool water = isInWaterOrRain();
|
||||
const AABB& shrunk = bb->shrink(0.001, 0.001, 0.001);
|
||||
if (level->containsFireTile(bb)) {
|
||||
const AABB& shrunk = bb.shrink(0.001, 0.001, 0.001);
|
||||
if (level->containsFireTile(&bb)) {
|
||||
burn(1);
|
||||
if (!water) {
|
||||
onFire++;
|
||||
|
|
@ -912,12 +906,12 @@ void Entity::move(double xa, double ya, double za,
|
|||
}
|
||||
|
||||
void Entity::checkInsideTiles() {
|
||||
int x0 = Mth::floor(bb->x0 + 0.001);
|
||||
int y0 = Mth::floor(bb->y0 + 0.001);
|
||||
int z0 = Mth::floor(bb->z0 + 0.001);
|
||||
int x1 = Mth::floor(bb->x1 - 0.001);
|
||||
int y1 = Mth::floor(bb->y1 - 0.001);
|
||||
int z1 = Mth::floor(bb->z1 - 0.001);
|
||||
int x0 = Mth::floor(bb.x0 + 0.001);
|
||||
int y0 = Mth::floor(bb.y0 + 0.001);
|
||||
int z0 = Mth::floor(bb.z0 + 0.001);
|
||||
int x1 = Mth::floor(bb.x1 - 0.001);
|
||||
int y1 = Mth::floor(bb.y1 - 0.001);
|
||||
int z1 = Mth::floor(bb.z1 - 0.001);
|
||||
|
||||
if (level->hasChunksAt(x0, y0, z0, x1, y1, z1)) {
|
||||
for (int x = x0; x <= x1; x++)
|
||||
|
|
@ -1000,7 +994,7 @@ bool Entity::isInWaterOrRain() {
|
|||
bool Entity::isInWater() { return wasInWater; }
|
||||
|
||||
bool Entity::updateInWaterState() {
|
||||
AABB shrunk = bb->grow(0, -0.4, 0).shrink(0.001, 0.001, 0.001);
|
||||
AABB shrunk = bb.grow(0, -0.4, 0).shrink(0.001, 0.001, 0.001);
|
||||
if (level->checkAndHandleWater(&shrunk, Material::water,
|
||||
shared_from_this())) {
|
||||
if (!wasInWater && !firstTick && canCreateParticles()) {
|
||||
|
|
@ -1011,7 +1005,7 @@ bool Entity::updateInWaterState() {
|
|||
playSound(eSoundType_RANDOM_SPLASH, speed,
|
||||
1 + (random->nextFloat() - random->nextFloat()) * 0.4f);
|
||||
MemSect(0);
|
||||
float yt = (float)Mth::floor(bb->y0);
|
||||
float yt = (float)Mth::floor(bb.y0);
|
||||
for (int i = 0; i < 1 + bbWidth * 20; i++) {
|
||||
float xo = (random->nextFloat() * 2 - 1) * bbWidth;
|
||||
float zo = (random->nextFloat() * 2 - 1) * bbWidth;
|
||||
|
|
@ -1052,7 +1046,7 @@ bool Entity::isUnderLiquid(Material* material) {
|
|||
float Entity::getHeadHeight() { return 0; }
|
||||
|
||||
bool Entity::isInLava() {
|
||||
AABB mat_bounds = bb->grow(-0.1, -0.4, -0.1);
|
||||
AABB mat_bounds = bb.grow(-0.1, -0.4, -0.1);
|
||||
return level->containsMaterial(&mat_bounds, Material::lava);
|
||||
}
|
||||
|
||||
|
|
@ -1079,7 +1073,7 @@ int Entity::getLightColor(float a) {
|
|||
int zTile = Mth::floor(z);
|
||||
|
||||
if (level->hasChunkAt(xTile, 0, zTile)) {
|
||||
double hh = (bb->y1 - bb->y0) * 0.66;
|
||||
double hh = (bb.y1 - bb.y0) * 0.66;
|
||||
int yTile = Mth::floor(y - heightOffset + hh);
|
||||
return level->getLightColor(xTile, yTile, zTile, 0);
|
||||
}
|
||||
|
|
@ -1091,7 +1085,7 @@ float Entity::getBrightness(float a) {
|
|||
int xTile = Mth::floor(x);
|
||||
int zTile = Mth::floor(z);
|
||||
if (level->hasChunkAt(xTile, 0, zTile)) {
|
||||
double hh = (bb->y1 - bb->y0) * 0.66;
|
||||
double hh = (bb.y1 - bb.y0) * 0.66;
|
||||
int yTile = Mth::floor(y - heightOffset + hh);
|
||||
return level->getBrightness(xTile, yTile, zTile);
|
||||
}
|
||||
|
|
@ -1200,7 +1194,7 @@ bool Entity::hurt(DamageSource* source, float damage) {
|
|||
|
||||
bool Entity::intersects(double x0, double y0, double z0, double x1, double y1,
|
||||
double z1) {
|
||||
return bb->intersects(x0, y0, z0, x1, y1, z1);
|
||||
return bb.intersects(x0, y0, z0, x1, y1, z1);
|
||||
}
|
||||
|
||||
bool Entity::isPickable() { return false; }
|
||||
|
|
@ -1220,7 +1214,7 @@ bool Entity::shouldRender(Vec3* c) {
|
|||
}
|
||||
|
||||
bool Entity::shouldRenderAtSqrDistance(double distance) {
|
||||
double size = bb->getSize();
|
||||
double size = bb.getSize();
|
||||
size *= 64.0f * viewScale;
|
||||
return distance < size * size;
|
||||
}
|
||||
|
|
@ -1497,7 +1491,7 @@ void Entity::ride(std::shared_ptr<Entity> e) {
|
|||
// 4J Stu - Position should already be updated before the
|
||||
// SetEntityLinkPacket comes in
|
||||
if (!level->isClientSide)
|
||||
moveTo(riding->x, riding->bb->y0 + riding->bbHeight, riding->z,
|
||||
moveTo(riding->x, riding->bb.y0 + riding->bbHeight, riding->z,
|
||||
yRot, xRot);
|
||||
riding->rider = std::weak_ptr<Entity>();
|
||||
}
|
||||
|
|
@ -1520,7 +1514,7 @@ void Entity::lerpTo(double x, double y, double z, float yRot, float xRot,
|
|||
// its definitely bad news for arrows as they are actually Meant to
|
||||
// intersect the geometry they land in slightly.
|
||||
if (GetType() != eTYPE_ARROW) {
|
||||
AABB shrunk = bb->shrink(1 / 32.0, 0.0, 1 / 32.0);
|
||||
AABB shrunk = bb.shrink(1 / 32.0, 0.0, 1 / 32.0);
|
||||
AABBList* collisions = level->getCubes(shared_from_this(), &shrunk);
|
||||
if (!collisions->empty()) {
|
||||
double yTop = 0;
|
||||
|
|
@ -1529,7 +1523,7 @@ void Entity::lerpTo(double x, double y, double z, float yRot, float xRot,
|
|||
if (it->y1 > yTop) yTop = it->y1;
|
||||
}
|
||||
|
||||
y += yTop - bb->y0;
|
||||
y += yTop - bb.y0;
|
||||
setPos(x, y, z);
|
||||
}
|
||||
}
|
||||
|
|
@ -1667,7 +1661,7 @@ bool Entity::checkInTile(double x, double y, double z) {
|
|||
double yd = y - (yTile);
|
||||
double zd = z - (zTile);
|
||||
|
||||
auto* cubes = level->getTileCubes(bb);
|
||||
auto* cubes = level->getTileCubes(&bb);
|
||||
if ((cubes && !cubes->empty()) ||
|
||||
level->isFullAABBTile(xTile, yTile, zTile)) {
|
||||
bool west = !level->isFullAABBTile(xTile - 1, yTile, zTile);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include "../IO/NBT/FloatTag.h"
|
||||
#include "../Util/Vec3.h"
|
||||
#include "../Util/Definitions.h"
|
||||
#include "../Util/AABB.h"
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
|
||||
|
|
@ -72,7 +73,7 @@ public:
|
|||
double xd, yd, zd;
|
||||
float yRot, xRot;
|
||||
float yRotO, xRotO;
|
||||
/*const*/ AABB* bb; // 4J Was final
|
||||
/*const*/ AABB bb; // 4J Was final
|
||||
bool onGround;
|
||||
bool horizontalCollision, verticalCollision;
|
||||
bool collision;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ void FlyingMob::travel(float xa, float ya) {
|
|||
float friction = 0.91f;
|
||||
if (onGround) {
|
||||
friction = 0.6f * 0.91f;
|
||||
int t = level->getTile(Mth::floor(x), Mth::floor(bb->y0) - 1,
|
||||
int t = level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1,
|
||||
Mth::floor(z));
|
||||
if (t > 0) {
|
||||
friction = Tile::tiles[t]->friction * 0.91f;
|
||||
|
|
@ -48,7 +48,7 @@ void FlyingMob::travel(float xa, float ya) {
|
|||
friction = 0.91f;
|
||||
if (onGround) {
|
||||
friction = 0.6f * 0.91f;
|
||||
int t = level->getTile(Mth::floor(x), Mth::floor(bb->y0) - 1,
|
||||
int t = level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1,
|
||||
Mth::floor(z));
|
||||
if (t > 0) {
|
||||
friction = Tile::tiles[t]->friction * 0.91f;
|
||||
|
|
@ -70,4 +70,4 @@ void FlyingMob::travel(float xa, float ya) {
|
|||
walkAnimPos += walkAnimSpeed;
|
||||
}
|
||||
|
||||
bool FlyingMob::onLadder() { return false; }
|
||||
bool FlyingMob::onLadder() { return false; }
|
||||
|
|
|
|||
|
|
@ -74,8 +74,8 @@ void HangingEntity::setDir(int dir) {
|
|||
float y1 = y + h + ss;
|
||||
float z0 = z - d - ss;
|
||||
float z1 = z + d + ss;
|
||||
*bb = {std::min(x0, x1), std::min(y0, y1), std::min(z0, z1),
|
||||
std::max(x0, x1), std::max(y0, y1), std::max(z0, z1)};
|
||||
bb = {std::min(x0, x1), std::min(y0, y1), std::min(z0, z1),
|
||||
std::max(x0, x1), std::max(y0, y1), std::max(z0, z1)};
|
||||
}
|
||||
|
||||
float HangingEntity::offs(int w) {
|
||||
|
|
@ -98,7 +98,7 @@ void HangingEntity::tick() {
|
|||
}
|
||||
|
||||
bool HangingEntity::survives() {
|
||||
if (level->getCubes(shared_from_this(), bb)->size() != 0) // isEmpty())
|
||||
if (level->getCubes(shared_from_this(), &bb)->size() != 0) // isEmpty())
|
||||
{
|
||||
return false;
|
||||
} else {
|
||||
|
|
@ -128,7 +128,7 @@ bool HangingEntity::survives() {
|
|||
}
|
||||
|
||||
std::vector<std::shared_ptr<Entity> >* entities =
|
||||
level->getEntities(shared_from_this(), bb);
|
||||
level->getEntities(shared_from_this(), &bb);
|
||||
|
||||
if (entities != NULL && entities->size() > 0) {
|
||||
AUTO_VAR(itEnd, entities->end());
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ void ItemEntity::tick() {
|
|||
zo = z;
|
||||
|
||||
yd -= 0.04f;
|
||||
noPhysics = checkInTile(x, (bb->y0 + bb->y1) / 2, z);
|
||||
noPhysics = checkInTile(x, (bb.y0 + bb.y1) / 2, z);
|
||||
|
||||
// 4J - added parameter here so that these don't care about colliding with
|
||||
// other entities
|
||||
|
|
@ -96,7 +96,7 @@ void ItemEntity::tick() {
|
|||
float friction = 0.98f;
|
||||
if (onGround) {
|
||||
friction = 0.6f * 0.98f;
|
||||
int t = level->getTile(Mth::floor(x), Mth::floor(bb->y0) - 1,
|
||||
int t = level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1,
|
||||
Mth::floor(z));
|
||||
if (t > 0) {
|
||||
friction = Tile::tiles[t]->friction * 0.98f;
|
||||
|
|
@ -119,7 +119,7 @@ void ItemEntity::tick() {
|
|||
}
|
||||
|
||||
void ItemEntity::mergeWithNeighbours() {
|
||||
AABB grown = bb->grow(0.5, 0, 0.5);
|
||||
AABB grown = bb.grow(0.5, 0, 0.5);
|
||||
std::vector<std::shared_ptr<Entity> >* neighbours =
|
||||
level->getEntitiesOfClass(typeid(*this), &grown);
|
||||
for (AUTO_VAR(it, neighbours->begin()); it != neighbours->end(); ++it) {
|
||||
|
|
@ -164,7 +164,7 @@ void ItemEntity::setShortLifeTime() {
|
|||
}
|
||||
|
||||
bool ItemEntity::updateInWaterState() {
|
||||
return level->checkAndHandleWater(bb, Material::water, shared_from_this());
|
||||
return level->checkAndHandleWater(&bb, Material::water, shared_from_this());
|
||||
}
|
||||
|
||||
void ItemEntity::burn(int dmg) { hurt(DamageSource::inFire, dmg); }
|
||||
|
|
|
|||
|
|
@ -897,7 +897,7 @@ void LivingEntity::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel) {
|
|||
|
||||
bool LivingEntity::onLadder() {
|
||||
int xt = Mth::floor(x);
|
||||
int yt = Mth::floor(bb->y0);
|
||||
int yt = Mth::floor(bb.y0);
|
||||
int zt = Mth::floor(z);
|
||||
|
||||
// 4J-PB - TU9 - add climbable vines
|
||||
|
|
@ -1166,7 +1166,7 @@ void LivingEntity::teleportTo(double x, double y, double z) {
|
|||
void LivingEntity::findStandUpPosition(std::shared_ptr<Entity> vehicle) {
|
||||
AABB boundingBox;
|
||||
double fallbackX = vehicle->x;
|
||||
double fallbackY = vehicle->bb->y0 + vehicle->bbHeight;
|
||||
double fallbackY = vehicle->bb.y0 + vehicle->bbHeight;
|
||||
double fallbackZ = vehicle->z;
|
||||
|
||||
for (double xDiff = -1.5; xDiff < 2; xDiff += 1.5) {
|
||||
|
|
@ -1177,7 +1177,7 @@ void LivingEntity::findStandUpPosition(std::shared_ptr<Entity> vehicle) {
|
|||
|
||||
int xToInt = (int)(x + xDiff);
|
||||
int zToInt = (int)(z + zDiff);
|
||||
boundingBox = bb->move(xDiff, 1, zDiff);
|
||||
boundingBox = bb.move(xDiff, 1, zDiff);
|
||||
|
||||
if (level->getTileCubes(&boundingBox, true)->empty()) {
|
||||
if (level->isTopSolidBlocking(xToInt, (int)y, zToInt)) {
|
||||
|
|
@ -1259,7 +1259,7 @@ void LivingEntity::travel(float xa, float ya) {
|
|||
float friction = 0.91f;
|
||||
if (onGround) {
|
||||
friction = 0.6f * 0.91f;
|
||||
int t = level->getTile(Mth::floor(x), Mth::floor(bb->y0) - 1,
|
||||
int t = level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1,
|
||||
Mth::floor(z));
|
||||
if (t > 0) {
|
||||
friction = Tile::tiles[t]->friction * 0.91f;
|
||||
|
|
@ -1281,7 +1281,7 @@ void LivingEntity::travel(float xa, float ya) {
|
|||
friction = 0.91f;
|
||||
if (onGround) {
|
||||
friction = 0.6f * 0.91f;
|
||||
int t = level->getTile(Mth::floor(x), Mth::floor(bb->y0) - 1,
|
||||
int t = level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1,
|
||||
Mth::floor(z));
|
||||
if (t > 0) {
|
||||
friction = Tile::tiles[t]->friction * 0.91f;
|
||||
|
|
@ -1337,13 +1337,13 @@ void LivingEntity::travel(float xa, float ya) {
|
|||
// and out of lit areas, for example when bobbing in the water.
|
||||
int LivingEntity::getLightColor(float a) {
|
||||
float accum[2] = {0, 0};
|
||||
float totVol = (bb->x1 - bb->x0) * (bb->y1 - bb->y0) * (bb->z1 - bb->z0);
|
||||
int xmin = Mth::floor(bb->x0);
|
||||
int xmax = Mth::floor(bb->x1);
|
||||
int ymin = Mth::floor(bb->y0);
|
||||
int ymax = Mth::floor(bb->y1);
|
||||
int zmin = Mth::floor(bb->z0);
|
||||
int zmax = Mth::floor(bb->z1);
|
||||
float totVol = (bb.x1 - bb.x0) * (bb.y1 - bb.y0) * (bb.z1 - bb.z0);
|
||||
int xmin = Mth::floor(bb.x0);
|
||||
int xmax = Mth::floor(bb.x1);
|
||||
int ymin = Mth::floor(bb.y0);
|
||||
int ymax = Mth::floor(bb.y1);
|
||||
int zmin = Mth::floor(bb.z0);
|
||||
int zmax = Mth::floor(bb.z1);
|
||||
for (int xt = xmin; xt <= xmax; xt++)
|
||||
for (int yt = ymin; yt <= ymax; yt++)
|
||||
for (int zt = zmin; zt <= zmax; zt++) {
|
||||
|
|
@ -1353,12 +1353,12 @@ int LivingEntity::getLightColor(float a) {
|
|||
float tileymax = (float)(yt + 1);
|
||||
float tilezmin = (float)zt;
|
||||
float tilezmax = (float)(zt + 1);
|
||||
if (tilexmin < bb->x0) tilexmin = bb->x0;
|
||||
if (tilexmax > bb->x1) tilexmax = bb->x1;
|
||||
if (tileymin < bb->y0) tileymin = bb->y0;
|
||||
if (tileymax > bb->y1) tileymax = bb->y1;
|
||||
if (tilezmin < bb->z0) tilezmin = bb->z0;
|
||||
if (tilezmax > bb->z1) tilezmax = bb->z1;
|
||||
if (tilexmin < bb.x0) tilexmin = bb.x0;
|
||||
if (tilexmax > bb.x1) tilexmax = bb.x1;
|
||||
if (tileymin < bb.y0) tileymin = bb.y0;
|
||||
if (tileymax > bb.y1) tileymax = bb.y1;
|
||||
if (tilezmin < bb.z0) tilezmin = bb.z0;
|
||||
if (tilezmax > bb.z1) tilezmax = bb.z1;
|
||||
float tileVol = (tilexmax - tilexmin) * (tileymax - tileymin) *
|
||||
(tilezmax - tilezmin);
|
||||
float frac = tileVol / totVol;
|
||||
|
|
@ -1508,10 +1508,10 @@ void LivingEntity::aiStep() {
|
|||
// 4J - this collision is carried out to try and stop the lerping push
|
||||
// the mob through the floor, in which case gravity can then carry on
|
||||
// moving the mob because the collision just won't work anymore. BB for
|
||||
// collision used to be calculated as: bb->shrink(1 / 32.0, 0, 1 / 32.0)
|
||||
// collision used to be calculated as: bb.shrink(1 / 32.0, 0, 1 / 32.0)
|
||||
// now using a reduced BB to try and get rid of some issues where mobs
|
||||
// pop up the sides of walls, undersides of trees etc.
|
||||
AABB shrinkbb = bb->shrink(0.1, 0, 0.1);
|
||||
AABB shrinkbb = bb.shrink(0.1, 0, 0.1);
|
||||
shrinkbb.y1 = shrinkbb.y0 + 0.1;
|
||||
AABBList* collisions = level->getCubes(shared_from_this(), &shrinkbb);
|
||||
if (collisions->size() > 0) {
|
||||
|
|
@ -1521,7 +1521,7 @@ void LivingEntity::aiStep() {
|
|||
if (it->y1 > yTop) yTop = it->y1;
|
||||
}
|
||||
|
||||
yt += yTop - bb->y0;
|
||||
yt += yTop - bb.y0;
|
||||
setPos(xt, yt, zt);
|
||||
}
|
||||
} else if (!isEffectiveAi()) {
|
||||
|
|
@ -1581,7 +1581,7 @@ void LivingEntity::aiStep() {
|
|||
void LivingEntity::newServerAiStep() {}
|
||||
|
||||
void LivingEntity::pushEntities() {
|
||||
AABB grown = bb->grow(0.2, 0, 0.2);
|
||||
AABB grown = bb.grow(0.2, 0, 0.2);
|
||||
std::vector<std::shared_ptr<Entity> >* entities =
|
||||
level->getEntities(shared_from_this(), &grown);
|
||||
if (entities != NULL && !entities->empty()) {
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ void MinecartHopper::tick() {
|
|||
bool MinecartHopper::suckInItems() {
|
||||
if (HopperTileEntity::suckInItems(this)) return true;
|
||||
|
||||
AABB grown = bb->grow(0.25, 0, 0.25);
|
||||
AABB grown = bb.grow(0.25, 0, 0.25);
|
||||
std::vector<std::shared_ptr<Entity> >* items =
|
||||
level->getEntitiesOfClass(typeid(ItemEntity), &grown,
|
||||
EntitySelector::ENTITY_STILL_ALIVE);
|
||||
|
|
|
|||
|
|
@ -301,7 +301,7 @@ void Mob::aiStep() {
|
|||
|
||||
if (!level->isClientSide && canPickUpLoot() && !dead &&
|
||||
level->getGameRules()->getBoolean(GameRules::RULE_MOBGRIEFING)) {
|
||||
AABB grown = bb->grow(1, 0, 1);
|
||||
AABB grown = bb.grow(1, 0, 1);
|
||||
std::vector<std::shared_ptr<Entity> >* entities =
|
||||
level->getEntitiesOfClass(typeid(ItemEntity), &grown);
|
||||
for (AUTO_VAR(it, entities->begin()); it != entities->end(); ++it) {
|
||||
|
|
@ -499,7 +499,7 @@ void Mob::lookAt(std::shared_ptr<Entity> e, float yMax, float xMax) {
|
|||
std::dynamic_pointer_cast<LivingEntity>(e);
|
||||
yd = (mob->y + mob->getHeadHeight()) - (y + getHeadHeight());
|
||||
} else {
|
||||
yd = (e->bb->y0 + e->bb->y1) / 2 - (y + getHeadHeight());
|
||||
yd = (e->bb.y0 + e->bb.y1) / 2 - (y + getHeadHeight());
|
||||
}
|
||||
|
||||
double sd = Mth::sqrt(xd * xd + zd * zd);
|
||||
|
|
@ -527,9 +527,9 @@ float Mob::rotlerp(float a, float b, float max) {
|
|||
|
||||
bool Mob::canSpawn() {
|
||||
// 4J - altered to use special containsAnyLiquid variant
|
||||
return level->isUnobstructed(bb) &&
|
||||
level->getCubes(shared_from_this(), bb)->empty() &&
|
||||
!level->containsAnyLiquid_NoLoad(bb);
|
||||
return level->isUnobstructed(&bb) &&
|
||||
level->getCubes(shared_from_this(), &bb)->empty() &&
|
||||
!level->containsAnyLiquid_NoLoad(&bb);
|
||||
}
|
||||
|
||||
float Mob::getSizeScale() { return 1.0f; }
|
||||
|
|
@ -848,7 +848,7 @@ void Mob::restoreLeashFromSave() {
|
|||
if (_isLeashed && leashInfoTag != NULL) {
|
||||
if (leashInfoTag->contains(L"UUID")) {
|
||||
std::wstring leashUuid = leashInfoTag->getString(L"UUID");
|
||||
AABB grown = bb->grow(10, 10, 10);
|
||||
AABB grown = bb.grow(10, 10, 10);
|
||||
std::vector<std::shared_ptr<Entity> >* livingEnts =
|
||||
level->getEntitiesOfClass(typeid(LivingEntity),
|
||||
&grown);
|
||||
|
|
@ -889,9 +889,9 @@ void Mob::restoreLeashFromSave() {
|
|||
// resolve bug 10327 :Gameplay: NPCs can spawn over chunks that have not yet
|
||||
// been streamed and display jitter.
|
||||
bool Mob::shouldRender(Vec3* c) {
|
||||
if (!level->reallyHasChunksAt(Mth::floor(bb->x0), Mth::floor(bb->y0),
|
||||
Mth::floor(bb->z0), Mth::floor(bb->x1),
|
||||
Mth::floor(bb->y1), Mth::floor(bb->z1))) {
|
||||
if (!level->reallyHasChunksAt(Mth::floor(bb.x0), Mth::floor(bb.y0),
|
||||
Mth::floor(bb.z0), Mth::floor(bb.x1),
|
||||
Mth::floor(bb.y1), Mth::floor(bb.z1))) {
|
||||
return false;
|
||||
}
|
||||
return Entity::shouldRender(c);
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ std::shared_ptr<Entity> Animal::findAttackTarget() {
|
|||
|
||||
float r = 8;
|
||||
if (getInLoveValue() > 0) {
|
||||
AABB grown = bb->grow(r, r, r);
|
||||
AABB grown = bb.grow(r, r, r);
|
||||
std::vector<std::shared_ptr<Entity> >* others =
|
||||
level->getEntitiesOfClass(typeid(*this), &grown);
|
||||
// for (int i = 0; i < others->size(); i++)
|
||||
|
|
@ -230,7 +230,7 @@ std::shared_ptr<Entity> Animal::findAttackTarget() {
|
|||
delete others;
|
||||
} else {
|
||||
if (getAge() == 0) {
|
||||
AABB grown = bb->grow(r, r, r);
|
||||
AABB grown = bb.grow(r, r, r);
|
||||
std::vector<std::shared_ptr<Entity> >* players =
|
||||
level->getEntitiesOfClass(typeid(Player), &grown);
|
||||
// for (int i = 0; i < players.size(); i++)
|
||||
|
|
@ -247,7 +247,7 @@ std::shared_ptr<Entity> Animal::findAttackTarget() {
|
|||
}
|
||||
delete players;
|
||||
} else if (getAge() > 0) {
|
||||
AABB grown = bb->grow(r, r, r);
|
||||
AABB grown = bb.grow(r, r, r);
|
||||
std::vector<std::shared_ptr<Entity> >* others =
|
||||
level->getEntitiesOfClass(typeid(*this), &grown);
|
||||
// for (int i = 0; i < others.size(); i++)
|
||||
|
|
@ -267,7 +267,7 @@ std::shared_ptr<Entity> Animal::findAttackTarget() {
|
|||
|
||||
bool Animal::canSpawn() {
|
||||
int xt = Mth::floor(x);
|
||||
int yt = Mth::floor(bb->y0);
|
||||
int yt = Mth::floor(bb.y0);
|
||||
int zt = Mth::floor(z);
|
||||
return level->getTile(xt, yt - 1, zt) == Tile::grass_Id &&
|
||||
level->getDaytimeRawBrightness(xt, yt, zt) > 8 &&
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ void Arrow::tick() {
|
|||
}
|
||||
|
||||
std::shared_ptr<Entity> hitEntity = nullptr;
|
||||
AABB grown = bb->expand(xd, yd, zd).grow(1, 1, 1);
|
||||
AABB grown = bb.expand(xd, yd, zd).grow(1, 1, 1);
|
||||
std::vector<std::shared_ptr<Entity> >* objects =
|
||||
level->getEntities(shared_from_this(), &grown);
|
||||
double nearest = 0;
|
||||
|
|
@ -240,7 +240,7 @@ void Arrow::tick() {
|
|||
if (!e->isPickable() || (e == owner && flightTime < 5)) continue;
|
||||
|
||||
float rr = 0.3f;
|
||||
AABB bb = e->bb->grow(rr, rr, rr);
|
||||
AABB bb = e->bb.grow(rr, rr, rr);
|
||||
HitResult* p = bb.clip(from, to);
|
||||
if (p != NULL) {
|
||||
double dd = from.distanceTo(p->pos);
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ void Bat::addAdditonalSaveData(CompoundTag* entityTag) {
|
|||
}
|
||||
|
||||
bool Bat::canSpawn() {
|
||||
int yt = Mth::floor(bb->y0);
|
||||
int yt = Mth::floor(bb.y0);
|
||||
if (yt >= level->seaLevel) return false;
|
||||
|
||||
int xt = Mth::floor(x);
|
||||
|
|
@ -205,4 +205,4 @@ bool Bat::canSpawn() {
|
|||
if (br > random->nextInt(maxLight)) return false;
|
||||
|
||||
return AmbientCreature::canSpawn();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,14 +93,14 @@ void Blaze::aiStep() {
|
|||
}
|
||||
|
||||
void Blaze::checkHurtTarget(std::shared_ptr<Entity> target, float d) {
|
||||
if (attackTime <= 0 && d < 2.0f && target->bb->y1 > bb->y0 &&
|
||||
target->bb->y0 < bb->y1) {
|
||||
if (attackTime <= 0 && d < 2.0f && target->bb.y1 > bb.y0 &&
|
||||
target->bb.y0 < bb.y1) {
|
||||
attackTime = 20;
|
||||
doHurtTarget(target);
|
||||
} else if (d < 30) {
|
||||
double xd = target->x - x;
|
||||
double yd =
|
||||
(target->bb->y0 + target->bbHeight / 2) - (y + bbHeight / 2);
|
||||
(target->bb.y0 + target->bbHeight / 2) - (y + bbHeight / 2);
|
||||
double zd = target->z - z;
|
||||
|
||||
if (attackTime == 0) {
|
||||
|
|
@ -181,4 +181,4 @@ void Blaze::setCharged(bool value) {
|
|||
entityData->set(DATA_FLAGS_ID, flags);
|
||||
}
|
||||
|
||||
bool Blaze::isDarkEnoughToSpawn() { return true; }
|
||||
bool Blaze::isDarkEnoughToSpawn() { return true; }
|
||||
|
|
|
|||
|
|
@ -44,10 +44,10 @@ void Boat::defineSynchedData() {
|
|||
}
|
||||
|
||||
AABB* Boat::getCollideAgainstBox(std::shared_ptr<Entity> entity) {
|
||||
return entity->bb;
|
||||
return &entity->bb;
|
||||
}
|
||||
|
||||
AABB* Boat::getCollideBox() { return bb; }
|
||||
AABB* Boat::getCollideBox() { return &bb; }
|
||||
|
||||
bool Boat::isPushable() { return true; }
|
||||
|
||||
|
|
@ -165,9 +165,9 @@ void Boat::tick() {
|
|||
int steps = 5;
|
||||
double waterPercentage = 0;
|
||||
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(bb->x0, y0, bb->z0, bb->x1, y1, bb->z1);
|
||||
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(bb.x0, y0, bb.z0, bb.x1, y1, bb.z1);
|
||||
if (level->containsLiquid(&bb2, Material::water)) {
|
||||
waterPercentage += 1.0 / steps;
|
||||
}
|
||||
|
|
@ -345,7 +345,7 @@ void Boat::tick() {
|
|||
|
||||
if (level->isClientSide) return;
|
||||
|
||||
AABB grown = bb->grow(0.2, 0, 0.2);
|
||||
AABB grown = bb.grow(0.2, 0, 0.2);
|
||||
std::vector<std::shared_ptr<Entity> >* entities =
|
||||
level->getEntities(shared_from_this(), &grown);
|
||||
if (entities != NULL && !entities->empty()) {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ DragonFireball::DragonFireball(Level* level, double x, double y, double z,
|
|||
|
||||
void DragonFireball::onHit(HitResult* res) {
|
||||
if (!level->isClientSide) {
|
||||
AABB aoe = bb->grow(SPLASH_RANGE, SPLASH_RANGE / 2, SPLASH_RANGE);
|
||||
AABB aoe = bb.grow(SPLASH_RANGE, SPLASH_RANGE / 2, SPLASH_RANGE);
|
||||
std::vector<std::shared_ptr<Entity> >* entitiesOfClass =
|
||||
level->getEntitiesOfClass(typeid(LivingEntity), &aoe);
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ void EnderDragon::_init() {
|
|||
m_actionTicks = 0;
|
||||
m_sittingDamageReceived = 0;
|
||||
m_headYRot = 0.0;
|
||||
m_acidArea = new AABB(-4, -10, -3, 6, 3, 3);
|
||||
m_acidArea = AABB(-4, -10, -3, 6, 3, 3);
|
||||
m_flameAttacks = 0;
|
||||
|
||||
for (int i = 0; i < positionsLength; i++) {
|
||||
|
|
@ -324,7 +324,7 @@ void EnderDragon::aiStep() {
|
|||
{
|
||||
xP = head->x; // - vN->x * d;
|
||||
yP =
|
||||
head->bb->y0 +
|
||||
head->bb.y0 +
|
||||
head->bbHeight /
|
||||
2; // - vN->y * d; //head->y +
|
||||
// head->bbHeight / 2 + 0.5f - v->y * d;
|
||||
|
|
@ -346,7 +346,7 @@ void EnderDragon::aiStep() {
|
|||
for (unsigned int j = 0; j < 6; ++j) {
|
||||
xP = head->x; // - vN->x * d;
|
||||
yP =
|
||||
head->bb->y0 +
|
||||
head->bb.y0 +
|
||||
head->bbHeight /
|
||||
2; // - vN->y * d; //head->y +
|
||||
// head->bbHeight / 2 + 0.5f - v->y * d;
|
||||
|
|
@ -462,7 +462,7 @@ void EnderDragon::aiStep() {
|
|||
getSynchedAction() == e_EnderdragonAction_Landing) {
|
||||
if (m_actionTicks < (FLAME_TICKS - 10)) {
|
||||
std::vector<std::shared_ptr<Entity> >* targets =
|
||||
level->getEntities(shared_from_this(), m_acidArea);
|
||||
level->getEntities(shared_from_this(), &m_acidArea);
|
||||
|
||||
for (AUTO_VAR(it, targets->begin()); it != targets->end();
|
||||
++it) {
|
||||
|
|
@ -491,7 +491,7 @@ void EnderDragon::aiStep() {
|
|||
|
||||
if (angleDegs < 0 || angleDegs > 10) {
|
||||
double xdd = attackTarget->x - head->x;
|
||||
// double ydd = (attackTarget->bb->y0 +
|
||||
// double ydd = (attackTarget->bb.y0 +
|
||||
// attackTarget->bbHeight / 2) - (head->y + head->bbHeight /
|
||||
// 2);
|
||||
double zdd = attackTarget->z - head->z;
|
||||
|
|
@ -541,7 +541,7 @@ void EnderDragon::aiStep() {
|
|||
double sd = sqrt(xd * xd + zd * zd);
|
||||
double ho = 0.4f + sd / 80.0f - 1;
|
||||
if (ho > 10) ho = 10;
|
||||
yTarget = attackTarget->bb->y0 + ho;
|
||||
yTarget = attackTarget->bb.y0 + ho;
|
||||
} else {
|
||||
// xTarget += random->nextGaussian() * 2;
|
||||
// zTarget += random->nextGaussian() * 2;
|
||||
|
|
@ -646,13 +646,13 @@ 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);
|
||||
AABB wing_mov = wing1->bb.grow(4, 2, 4).move(0, -2, 0);
|
||||
knockBack(level->getEntities(shared_from_this(), &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(), &wing_mov));
|
||||
|
||||
AABB neck_bb = neck->bb->grow(1, 1, 1);
|
||||
AABB head_bb = head->bb->grow(1, 1, 1);
|
||||
AABB neck_bb = neck->bb.grow(1, 1, 1);
|
||||
AABB head_bb = head->bb.grow(1, 1, 1);
|
||||
hurt(level->getEntities(shared_from_this(), &neck_bb));
|
||||
hurt(level->getEntities(shared_from_this(), &head_bb));
|
||||
}
|
||||
|
|
@ -687,19 +687,19 @@ 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,
|
||||
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,
|
||||
// yRotA, ss, cc, ccTilt); app.DebugPrintf("Body (%f,%f,%f) to
|
||||
// (%f,%f,%f)\n", body->bb->x0, body->bb->y0, body->bb->z0,
|
||||
// body->bb->x1, body->bb->y1, body->bb->z1); app.DebugPrintf("Neck
|
||||
// (%f,%f,%f) to (%f,%f,%f)\n", neck->bb->x0, neck->bb->y0,
|
||||
// neck->bb->z0, neck->bb->x1, neck->bb->y1, neck->bb->z1);
|
||||
// app.DebugPrintf("Head (%f,%f,%f) to (%f,%f,%f)\n", head->bb->x0,
|
||||
// head->bb->y0, head->bb->z0, head->bb->x1, head->bb->y1,
|
||||
// head->bb->z1); app.DebugPrintf("Acid (%f,%f,%f) to (%f,%f,%f)\n\n",
|
||||
// (%f,%f,%f)\n", body->bb.x0, body->bb.y0, body->bb.z0,
|
||||
// body->bb.x1, body->bb.y1, body->bb.z1); app.DebugPrintf("Neck
|
||||
// (%f,%f,%f) to (%f,%f,%f)\n", neck->bb.x0, neck->bb.y0,
|
||||
// neck->bb.z0, neck->bb.x1, neck->bb.y1, neck->bb.z1);
|
||||
// app.DebugPrintf("Head (%f,%f,%f) to (%f,%f,%f)\n", head->bb.x0,
|
||||
// head->bb.y0, head->bb.z0, head->bb.x1, head->bb.y1,
|
||||
// head->bb.z1); app.DebugPrintf("Acid (%f,%f,%f) to (%f,%f,%f)\n\n",
|
||||
// m_acidArea->x0, m_acidArea->y0, m_acidArea->z0, m_acidArea->x1,
|
||||
// m_acidArea->y1, m_acidArea->z1);
|
||||
}
|
||||
|
|
@ -757,7 +757,7 @@ void EnderDragon::aiStep() {
|
|||
|
||||
double xdd = attackTarget->x - startingX;
|
||||
double ydd =
|
||||
(attackTarget->bb->y0 + attackTarget->bbHeight / 2) -
|
||||
(attackTarget->bb.y0 + attackTarget->bbHeight / 2) -
|
||||
(startingY + head->bbHeight / 2);
|
||||
double zdd = attackTarget->z - startingZ;
|
||||
|
||||
|
|
@ -795,7 +795,7 @@ void EnderDragon::aiStep() {
|
|||
|
||||
if (!level->isClientSide) {
|
||||
inWall =
|
||||
checkWalls(head->bb) | checkWalls(neck->bb) | checkWalls(body->bb);
|
||||
checkWalls(&head->bb) | checkWalls(&neck->bb) | checkWalls(&body->bb);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -814,7 +814,7 @@ 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<std::shared_ptr<Entity> >* crystals =
|
||||
level->getEntitiesOfClass(typeid(EnderCrystal), &grown);
|
||||
|
||||
|
|
@ -851,9 +851,9 @@ void EnderDragon::checkAttack() {
|
|||
}
|
||||
|
||||
void EnderDragon::knockBack(std::vector<std::shared_ptr<Entity> >* entities) {
|
||||
double xm = (body->bb->x0 + body->bb->x1) / 2;
|
||||
double xm = (body->bb.x0 + body->bb.x1) / 2;
|
||||
// double ym = (body.bb.y0 + body.bb.y1) / 2;
|
||||
double zm = (body->bb->z0 + body->bb->z1) / 2;
|
||||
double zm = (body->bb.z0 + body->bb.z1) / 2;
|
||||
|
||||
// for (Entity e : entities)
|
||||
for (AUTO_VAR(it, entities->begin()); it != entities->end(); ++it) {
|
||||
|
|
@ -1475,7 +1475,7 @@ void EnderDragon::strafeAttackTarget() {
|
|||
double sd = sqrt(xd * xd + zd * zd);
|
||||
double ho = 0.4f + sd / 80.0f - 1;
|
||||
if (ho > 10) ho = 10;
|
||||
int finalYTarget = attackTarget->bb->y0 + ho;
|
||||
int finalYTarget = attackTarget->bb.y0 + ho;
|
||||
|
||||
Node finalNode(finalXTarget, finalYTarget, finalZTarget);
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ private:
|
|||
int m_iGrowlTimer;
|
||||
|
||||
double m_headYRot;
|
||||
AABB* m_acidArea;
|
||||
AABB m_acidArea;
|
||||
|
||||
NodeArray* m_nodes;
|
||||
int m_nodeAdjacency[24];
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ bool EnderMan::isLookingAtMe(std::shared_ptr<Player> player) {
|
|||
Vec3 look = player->getViewVector(1).normalize();
|
||||
|
||||
Vec3 dir{x - player->x,
|
||||
(bb->y0 + bbHeight / 2) - (player->y + player->getHeadHeight()),
|
||||
(bb.y0 + bbHeight / 2) - (player->y + player->getHeadHeight()),
|
||||
z - player->z};
|
||||
|
||||
double dist = dir.length();
|
||||
|
|
@ -250,7 +250,7 @@ bool EnderMan::teleport() {
|
|||
}
|
||||
|
||||
bool EnderMan::teleportTowards(std::shared_ptr<Entity> e) {
|
||||
Vec3 dir{x - e->x, bb->y0 + bbHeight / 2 - e->y + e->getHeadHeight(),
|
||||
Vec3 dir{x - e->x, bb.y0 + bbHeight / 2 - e->y + e->getHeadHeight(),
|
||||
z - e->z};
|
||||
dir = dir.normalize();
|
||||
double d = 16;
|
||||
|
|
@ -286,8 +286,8 @@ bool EnderMan::teleport(double xx, double yy, double zz) {
|
|||
}
|
||||
if (landed) {
|
||||
setPos(x, y, z);
|
||||
if (level->getCubes(shared_from_this(), bb)->empty() &&
|
||||
!level->containsAnyLiquid(bb)) {
|
||||
if (level->getCubes(shared_from_this(), &bb)->empty() &&
|
||||
!level->containsAnyLiquid(&bb)) {
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -420,7 +420,7 @@ std::shared_ptr<EntityHorse> EntityHorse::getClosestMommy(
|
|||
double closestDistance = std::numeric_limits<double>::max();
|
||||
|
||||
std::shared_ptr<Entity> mommy = nullptr;
|
||||
AABB expanded = baby->bb->expand(searchRadius, searchRadius, searchRadius);
|
||||
AABB expanded = baby->bb.expand(searchRadius, searchRadius, searchRadius);
|
||||
std::vector<std::shared_ptr<Entity> >* list =
|
||||
level->getEntities(baby, &expanded, PARENT_HORSE_SELECTOR);
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ void ExperienceOrb::tick() {
|
|||
playSound(eSoundType_RANDOM_FIZZ, 0.4f,
|
||||
2.0f + random->nextFloat() * 0.4f);
|
||||
}
|
||||
checkInTile(x, (bb->y0 + bb->y1) / 2, z);
|
||||
checkInTile(x, (bb.y0 + bb.y1) / 2, z);
|
||||
|
||||
double maxDist = 8;
|
||||
// 4J - PC Comment
|
||||
|
|
@ -121,7 +121,7 @@ void ExperienceOrb::tick() {
|
|||
float friction = 0.98f;
|
||||
if (onGround) {
|
||||
friction = 0.6f * 0.98f;
|
||||
int t = level->getTile(Mth::floor(x), Mth::floor(bb->y0) - 1,
|
||||
int t = level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1,
|
||||
Mth::floor(z));
|
||||
if (t > 0) {
|
||||
friction = Tile::tiles[t]->friction * 0.98f;
|
||||
|
|
@ -145,7 +145,7 @@ void ExperienceOrb::tick() {
|
|||
}
|
||||
|
||||
bool ExperienceOrb::updateInWaterState() {
|
||||
return level->checkAndHandleWater(bb, Material::water, shared_from_this());
|
||||
return level->checkAndHandleWater(&bb, Material::water, shared_from_this());
|
||||
}
|
||||
|
||||
void ExperienceOrb::burn(int dmg) { hurt(DamageSource::inFire, dmg); }
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ EyeOfEnderSignal::EyeOfEnderSignal(Level* level) : Entity(level) {
|
|||
void EyeOfEnderSignal::defineSynchedData() {}
|
||||
|
||||
bool EyeOfEnderSignal::shouldRenderAtSqrDistance(double distance) {
|
||||
double size = bb->getSize() * 4;
|
||||
double size = bb.getSize() * 4;
|
||||
size *= 64.0f;
|
||||
return distance < size * size;
|
||||
}
|
||||
|
|
@ -159,4 +159,4 @@ float EyeOfEnderSignal::getBrightness(float a) { return 1.0f; }
|
|||
|
||||
int EyeOfEnderSignal::getLightColor(float a) { return 15 << 20 | 15 << 4; }
|
||||
|
||||
bool EyeOfEnderSignal::isAttackable() { return false; }
|
||||
bool EyeOfEnderSignal::isAttackable() { return false; }
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ Fireball::Fireball(Level* level) : Entity(level) {
|
|||
void Fireball::defineSynchedData() {}
|
||||
|
||||
bool Fireball::shouldRenderAtSqrDistance(double distance) {
|
||||
double size = bb->getSize() * 4;
|
||||
double size = bb.getSize() * 4;
|
||||
size *= 64.0f;
|
||||
return distance < size * size;
|
||||
}
|
||||
|
|
@ -176,7 +176,7 @@ void Fireball::tick() {
|
|||
to = Vec3{res->pos.x, res->pos.y, res->pos.z};
|
||||
}
|
||||
std::shared_ptr<Entity> hitEntity = nullptr;
|
||||
AABB grown = bb->expand(xd, yd, zd).grow(1, 1, 1);
|
||||
AABB grown = bb.expand(xd, yd, zd).grow(1, 1, 1);
|
||||
std::vector<std::shared_ptr<Entity> >* objects =
|
||||
level->getEntities(shared_from_this(), &grown);
|
||||
double nearest = 0;
|
||||
|
|
@ -188,7 +188,7 @@ void Fireball::tick() {
|
|||
// && flightTime < 25)) continue;
|
||||
|
||||
float rr = 0.3f;
|
||||
AABB bb = e->bb->grow(rr, rr, rr);
|
||||
AABB bb = e->bb.grow(rr, rr, rr);
|
||||
HitResult* p = bb.clip(from, to);
|
||||
if (p != NULL) {
|
||||
double dd = from.distanceTo(p->pos);
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ FishingHook::FishingHook(Level* level, std::shared_ptr<Player> mob)
|
|||
void FishingHook::defineSynchedData() {}
|
||||
|
||||
bool FishingHook::shouldRenderAtSqrDistance(double distance) {
|
||||
double size = bb->getSize() * 4;
|
||||
double size = bb.getSize() * 4;
|
||||
size *= 64.0f;
|
||||
return distance < size * size;
|
||||
}
|
||||
|
|
@ -175,7 +175,7 @@ void FishingHook::tick() {
|
|||
hookedIn = nullptr;
|
||||
else {
|
||||
x = hookedIn->x;
|
||||
y = hookedIn->bb->y0 + hookedIn->bbHeight * 0.8;
|
||||
y = hookedIn->bb.y0 + hookedIn->bbHeight * 0.8;
|
||||
z = hookedIn->z;
|
||||
return;
|
||||
}
|
||||
|
|
@ -213,7 +213,7 @@ void FishingHook::tick() {
|
|||
to = Vec3(res->pos.x, res->pos.y, res->pos.z);
|
||||
}
|
||||
std::shared_ptr<Entity> hitEntity = nullptr;
|
||||
AABB grown = bb->expand(xd, yd, zd).grow(1, 1, 1);
|
||||
AABB grown = bb.expand(xd, yd, zd).grow(1, 1, 1);
|
||||
std::vector<std::shared_ptr<Entity> >* objects =
|
||||
level->getEntities(shared_from_this(), &grown);
|
||||
double nearest = 0;
|
||||
|
|
@ -223,7 +223,7 @@ void FishingHook::tick() {
|
|||
if (!e->isPickable() || (e == owner && flightTime < 5)) continue;
|
||||
|
||||
float rr = 0.3f;
|
||||
AABB bb = e->bb->grow(rr, rr, rr);
|
||||
AABB bb = e->bb.grow(rr, rr, rr);
|
||||
HitResult* p = bb.clip(from, to);
|
||||
if (p != NULL) {
|
||||
double dd = from.distanceTo(p->pos);
|
||||
|
|
@ -284,11 +284,11 @@ void FishingHook::tick() {
|
|||
int steps = 5;
|
||||
double waterPercentage = 0;
|
||||
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 +
|
||||
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;
|
||||
AABB bb2(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)) {
|
||||
waterPercentage += 1.0 / steps;
|
||||
}
|
||||
|
|
@ -309,7 +309,7 @@ void FishingHook::tick() {
|
|||
playSound(
|
||||
eSoundType_RANDOM_SPLASH, 0.25f,
|
||||
1 + (random->nextFloat() - random->nextFloat()) * 0.4f);
|
||||
float yt = (float)Mth::floor(bb->y0);
|
||||
float yt = (float)Mth::floor(bb.y0);
|
||||
for (int i = 0; i < 1 + bbWidth * 20; i++) {
|
||||
float xo = (random->nextFloat() * 2 - 1) * bbWidth;
|
||||
float zo = (random->nextFloat() * 2 - 1) * bbWidth;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ void Ghast::serverAiStep() {
|
|||
target->distanceToSqr(shared_from_this()) < maxDist * maxDist) {
|
||||
double xdd = target->x - x;
|
||||
double ydd =
|
||||
(target->bb->y0 + target->bbHeight / 2) - (y + bbHeight / 2);
|
||||
(target->bb.y0 + target->bbHeight / 2) - (y + bbHeight / 2);
|
||||
double zdd = target->z - z;
|
||||
yBodyRot = yRot = -(float)atan2(xdd, zdd) * 180 / PI;
|
||||
|
||||
|
|
@ -170,7 +170,6 @@ bool Ghast::canReach(double xt, double yt, double zt, double dist) {
|
|||
double yd = (yTarget - y) / dist;
|
||||
double zd = (zTarget - z) / dist;
|
||||
|
||||
AABB bb = *this->bb;
|
||||
for (int d = 1; d < dist; d++) {
|
||||
bb.move(xd, yd, zd);
|
||||
if (!level->getCubes(shared_from_this(), &bb)->empty()) return false;
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ void LavaSlime::registerAttributes() {
|
|||
|
||||
bool LavaSlime::canSpawn() {
|
||||
return level->difficulty > Difficulty::PEACEFUL &&
|
||||
level->isUnobstructed(bb) &&
|
||||
level->getCubes(shared_from_this(), bb)->empty() &&
|
||||
!level->containsAnyLiquid(bb);
|
||||
level->isUnobstructed(&bb) &&
|
||||
level->getCubes(shared_from_this(), &bb)->empty() &&
|
||||
!level->containsAnyLiquid(&bb);
|
||||
}
|
||||
|
||||
int LavaSlime::getArmorValue() { return getSize() * 3; }
|
||||
|
|
@ -102,4 +102,4 @@ bool LavaSlime::isInLava() {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool LavaSlime::doPlayLandSound() { return true; }
|
||||
bool LavaSlime::doPlayLandSound() { return true; }
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ void Minecart::defineSynchedData() {
|
|||
|
||||
AABB* Minecart::getCollideAgainstBox(std::shared_ptr<Entity> entity) {
|
||||
if (entity->isPushable()) {
|
||||
return entity->bb;
|
||||
return &entity->bb;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -305,7 +305,7 @@ void Minecart::tick() {
|
|||
}
|
||||
setRot(yRot, xRot);
|
||||
|
||||
AABB grown = bb->grow(0.2, 0, 0.2);
|
||||
AABB grown = bb.grow(0.2, 0, 0.2);
|
||||
std::vector<std::shared_ptr<Entity> >* entities =
|
||||
level->getEntities(shared_from_this(), &grown);
|
||||
if (entities != NULL && !entities->empty()) {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ bool MushroomCow::mobInteract(std::shared_ptr<Player> player) {
|
|||
// already really
|
||||
bool MushroomCow::canSpawn() {
|
||||
int xt = Mth::floor(x);
|
||||
int yt = Mth::floor(bb->y0);
|
||||
int yt = Mth::floor(bb.y0);
|
||||
int zt = Mth::floor(z);
|
||||
return (level->getTile(xt, yt - 1, zt) == Tile::grass_Id ||
|
||||
level->getTile(xt, yt - 1, zt) == Tile::mycel_Id) &&
|
||||
|
|
|
|||
|
|
@ -240,11 +240,11 @@ bool Ocelot::canSpawn() {
|
|||
if (level->random->nextInt(3) == 0) {
|
||||
return false;
|
||||
}
|
||||
if (level->isUnobstructed(bb) &&
|
||||
level->getCubes(shared_from_this(), bb)->empty() &&
|
||||
!level->containsAnyLiquid(bb)) {
|
||||
if (level->isUnobstructed(&bb) &&
|
||||
level->getCubes(shared_from_this(), &bb)->empty() &&
|
||||
!level->containsAnyLiquid(&bb)) {
|
||||
int xt = Mth::floor(x);
|
||||
int yt = Mth::floor(bb->y0);
|
||||
int yt = Mth::floor(bb.y0);
|
||||
int zt = Mth::floor(z);
|
||||
if (yt < level->seaLevel) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -69,9 +69,9 @@ void PigZombie::tick() {
|
|||
|
||||
bool PigZombie::canSpawn() {
|
||||
return level->difficulty > Difficulty::PEACEFUL &&
|
||||
level->isUnobstructed(bb) &&
|
||||
level->getCubes(shared_from_this(), bb)->empty() &&
|
||||
!level->containsAnyLiquid(bb);
|
||||
level->isUnobstructed(&bb) &&
|
||||
level->getCubes(shared_from_this(), &bb)->empty() &&
|
||||
!level->containsAnyLiquid(&bb);
|
||||
}
|
||||
|
||||
void PigZombie::addAdditonalSaveData(CompoundTag* tag) {
|
||||
|
|
@ -100,7 +100,7 @@ std::shared_ptr<Entity> PigZombie::findAttackTarget() {
|
|||
bool PigZombie::hurt(DamageSource* source, float dmg) {
|
||||
std::shared_ptr<Entity> sourceEntity = source->getEntity();
|
||||
if (sourceEntity != NULL && sourceEntity->instanceof(eTYPE_PLAYER)) {
|
||||
AABB grown = bb->grow(32, 32, 32);
|
||||
AABB grown = bb.grow(32, 32, 32);
|
||||
std::vector<std::shared_ptr<Entity> >* nearby =
|
||||
level->getEntities(shared_from_this(), &grown);
|
||||
AUTO_VAR(itEnd, nearby->end());
|
||||
|
|
|
|||
|
|
@ -69,8 +69,8 @@ bool Silverfish::hurt(DamageSource* source, float dmg) {
|
|||
|
||||
void Silverfish::checkHurtTarget(std::shared_ptr<Entity> target, float d) {
|
||||
// super.checkHurtTarget(target, d);
|
||||
if (attackTime <= 0 && d < 1.2f && target->bb->y1 > bb->y0 &&
|
||||
target->bb->y0 < bb->y1) {
|
||||
if (attackTime <= 0 && d < 1.2f && target->bb.y1 > bb.y0 &&
|
||||
target->bb.y0 < bb.y1) {
|
||||
attackTime = 20;
|
||||
doHurtTarget(target);
|
||||
}
|
||||
|
|
@ -192,4 +192,4 @@ bool Silverfish::canSpawn() {
|
|||
return false;
|
||||
}
|
||||
|
||||
MobType Silverfish::getMobType() { return ARTHROPOD; }
|
||||
MobType Silverfish::getMobType() { return ARTHROPOD; }
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ void Slime::tick() {
|
|||
float d = random->nextFloat() * 0.5f + 0.5f;
|
||||
float xd = Mth::sin(dir) * size * 0.5f * d;
|
||||
float zd = Mth::cos(dir) * size * 0.5f * d;
|
||||
level->addParticle(getParticleName(), x + xd, bb->y0, z + zd, 0, 0,
|
||||
level->addParticle(getParticleName(), x + xd, bb.y0, z + zd, 0, 0,
|
||||
0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ void Squid::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel) {
|
|||
}
|
||||
|
||||
bool Squid::isInWater() {
|
||||
AABB grown = bb->grow(0, -0.6, 0);
|
||||
AABB grown = bb.grow(0, -0.6, 0);
|
||||
return level->checkAndHandleWater(&grown, Material::water,
|
||||
shared_from_this());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ void ThrownPotion::onHit(HitResult* res) {
|
|||
Item::potion->getMobEffects(potionItem);
|
||||
|
||||
if (mobEffects != NULL && !mobEffects->empty()) {
|
||||
AABB aoe = bb->grow(SPLASH_RANGE, SPLASH_RANGE / 2, SPLASH_RANGE);
|
||||
AABB aoe = bb.grow(SPLASH_RANGE, SPLASH_RANGE / 2, SPLASH_RANGE);
|
||||
std::vector<std::shared_ptr<Entity> >* entitiesOfClass =
|
||||
level->getEntitiesOfClass(typeid(LivingEntity), &aoe);
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ void VillagerGolem::aiStep() {
|
|||
if (t > 0) {
|
||||
level->addParticle(PARTICLE_TILECRACK(t, d),
|
||||
x + (random->nextFloat() - 0.5) * bbWidth,
|
||||
bb->y0 + 0.1,
|
||||
bb.y0 + 0.1,
|
||||
z + (random->nextFloat() - 0.5) * bbWidth,
|
||||
4 * (random->nextFloat() - 0.5), .5,
|
||||
(random->nextFloat() - 0.5) * 4);
|
||||
|
|
@ -226,4 +226,4 @@ bool VillagerGolem::hurt(DamageSource* source, float dmg) {
|
|||
}
|
||||
|
||||
return Golem::hurt(source, dmg);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ void Witch::handleEntityEvent(uint8_t id) {
|
|||
for (int i = 0; i < random->nextInt(35) + 10; i++) {
|
||||
level->addParticle(eParticleType_witchMagic,
|
||||
x + random->nextGaussian() * .13f,
|
||||
bb->y1 + 0.5f + random->nextGaussian() * .13f,
|
||||
bb.y1 + 0.5f + random->nextGaussian() * .13f,
|
||||
z + random->nextGaussian() * .13f, 0, 0, 0);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ void WitherBoss::newServerAiStep() {
|
|||
idleHeadUpdates[i - 1] = 0;
|
||||
}
|
||||
} else {
|
||||
AABB grown = bb->grow(20, 8, 20);
|
||||
AABB grown = bb.grow(20, 8, 20);
|
||||
std::vector<std::shared_ptr<Entity> >* entities =
|
||||
level->getEntitiesOfClass(typeid(LivingEntity), &grown,
|
||||
livingEntitySelector);
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ void Wolf::tick() {
|
|||
}
|
||||
|
||||
if (shakeAnim > 0.4f) {
|
||||
float yt = (float)bb->y0;
|
||||
float yt = (float)bb.y0;
|
||||
int shakeCount =
|
||||
(int)(Mth::sin((shakeAnim - 0.4f) * PI) * 7.0f);
|
||||
for (int i = 0; i < shakeCount; i++) {
|
||||
|
|
@ -503,4 +503,4 @@ bool Wolf::wantsToAttack(std::shared_ptr<LivingEntity> target,
|
|||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,10 +176,10 @@ bool Zombie::hurt(DamageSource* source, float dmg) {
|
|||
level->getRawBrightness(xt, yt, zt) < 10) {
|
||||
reinforcement->setPos(xt, yt, zt);
|
||||
|
||||
if (level->isUnobstructed(reinforcement->bb) &&
|
||||
level->getCubes(reinforcement, reinforcement->bb)
|
||||
if (level->isUnobstructed(&reinforcement->bb) &&
|
||||
level->getCubes(reinforcement, &reinforcement->bb)
|
||||
->empty() &&
|
||||
!level->containsAnyLiquid(reinforcement->bb)) {
|
||||
!level->containsAnyLiquid(&reinforcement->bb)) {
|
||||
level->addEntity(reinforcement);
|
||||
reinforcement->setTarget(target);
|
||||
reinforcement->finalizeMobSpawn(NULL);
|
||||
|
|
@ -492,4 +492,4 @@ int Zombie::getConversionProgress() {
|
|||
Zombie::ZombieGroupData::ZombieGroupData(bool baby, bool villager) {
|
||||
isBaby = baby;
|
||||
isVillager = villager;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,8 +113,8 @@ bool Monster::doHurtTarget(std::shared_ptr<Entity> target) {
|
|||
}
|
||||
|
||||
void Monster::checkHurtTarget(std::shared_ptr<Entity> target, float distance) {
|
||||
if (attackTime <= 0 && distance < 2.0f && target->bb->y1 > bb->y0 &&
|
||||
target->bb->y0 < bb->y1) {
|
||||
if (attackTime <= 0 && distance < 2.0f && target->bb.y1 > bb.y0 &&
|
||||
target->bb.y0 < bb.y1) {
|
||||
attackTime = 20;
|
||||
doHurtTarget(target);
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ float Monster::getWalkTargetValue(int x, int y, int z) {
|
|||
|
||||
bool Monster::isDarkEnoughToSpawn() {
|
||||
int xt = Mth::floor(x);
|
||||
int yt = Mth::floor(bb->y0);
|
||||
int yt = Mth::floor(bb.y0);
|
||||
int zt = Mth::floor(z);
|
||||
if (level->getBrightness(LightLayer::Sky, xt, yt, zt) > random->nextInt(32))
|
||||
return false;
|
||||
|
|
@ -152,4 +152,4 @@ void Monster::registerAttributes() {
|
|||
PathfinderMob::registerAttributes();
|
||||
|
||||
getAttributes()->registerAttribute(SharedMonsterAttributes::ATTACK_DAMAGE);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ void PathfinderMob::serverAiStep() {
|
|||
// protected.
|
||||
considerForExtraWandering(isDespawnProtected());
|
||||
|
||||
int yFloor = Mth::floor(bb->y0 + 0.5f);
|
||||
int yFloor = Mth::floor(bb.y0 + 0.5f);
|
||||
|
||||
bool inWater = isInWater();
|
||||
bool inLava = isInLava();
|
||||
|
|
@ -226,7 +226,7 @@ std::shared_ptr<Entity> PathfinderMob::findAttackTarget() {
|
|||
|
||||
bool PathfinderMob::canSpawn() {
|
||||
int xt = Mth::floor(x);
|
||||
int yt = Mth::floor(bb->y0);
|
||||
int yt = Mth::floor(bb.y0);
|
||||
int zt = Mth::floor(z);
|
||||
return this->Mob::canSpawn() && getWalkTargetValue(xt, yt, zt) >= 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ Throwable::Throwable(Level* level) : Entity(level) {
|
|||
void Throwable::defineSynchedData() {}
|
||||
|
||||
bool Throwable::shouldRenderAtSqrDistance(double distance) {
|
||||
double size = bb->getSize() * 4;
|
||||
double size = bb.getSize() * 4;
|
||||
size *= 64.0f;
|
||||
return distance < size * size;
|
||||
}
|
||||
|
|
@ -147,7 +147,7 @@ void Throwable::tick() {
|
|||
|
||||
if (!level->isClientSide) {
|
||||
std::shared_ptr<Entity> hitEntity = nullptr;
|
||||
AABB grown = bb->expand(xd, yd, zd).grow(1, 1, 1);
|
||||
AABB grown = bb.expand(xd, yd, zd).grow(1, 1, 1);
|
||||
std::vector<std::shared_ptr<Entity> >* objects =
|
||||
level->getEntities(shared_from_this(), &grown);
|
||||
double nearest = 0;
|
||||
|
|
@ -157,7 +157,7 @@ void Throwable::tick() {
|
|||
if (!e->isPickable() || (e == owner && flightTime < 5)) continue;
|
||||
|
||||
float rr = 0.3f;
|
||||
AABB bb = e->bb->grow(rr, rr, rr);
|
||||
AABB bb = e->bb.grow(rr, rr, rr);
|
||||
HitResult* p = bb.clip(from, to);
|
||||
if (p != NULL) {
|
||||
double dd = from.distanceTo(p->pos);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ bool WaterAnimal::isWaterMob() {
|
|||
return true; // prevent drowning
|
||||
}
|
||||
|
||||
bool WaterAnimal::canSpawn() { return level->isUnobstructed(bb); }
|
||||
bool WaterAnimal::canSpawn() { return level->isUnobstructed(&bb); }
|
||||
|
||||
int WaterAnimal::getAmbientSoundInterval() { return 20 * 6; }
|
||||
|
||||
|
|
@ -42,4 +42,4 @@ void WaterAnimal::baseTick() {
|
|||
} else {
|
||||
setAirSupply(TOTAL_AIR_SUPPLY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ std::shared_ptr<ItemInstance> BoatItem::use(
|
|||
Vec3 b = player->getViewVector(a);
|
||||
bool hitEntity = false;
|
||||
float overlap = 1;
|
||||
AABB grown = player->bb->expand(b.x * (range), b.y * (range), b.z * (range))
|
||||
AABB grown = player->bb.expand(b.x * (range), b.y * (range), b.z * (range))
|
||||
.grow(overlap, overlap, overlap);
|
||||
std::vector<std::shared_ptr<Entity> >* objects =
|
||||
level->getEntities(player, &grown);
|
||||
|
|
@ -93,7 +93,7 @@ std::shared_ptr<ItemInstance> BoatItem::use(
|
|||
if (!e->isPickable()) continue;
|
||||
|
||||
float rr = e->getPickRadius();
|
||||
AABB bb = e->bb->grow(rr, rr, rr);
|
||||
AABB bb = e->bb.grow(rr, rr, rr);
|
||||
if (bb.contains(from)) {
|
||||
hitEntity = true;
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ std::shared_ptr<ItemInstance> BoatItem::use(
|
|||
boat->yRot =
|
||||
((Mth::floor(player->yRot * 4.0F / 360.0F + 0.5) & 0x3) - 1) *
|
||||
90;
|
||||
AABB grown = boat->bb->grow(-0.1, -0.1, -0.1);
|
||||
AABB grown = boat->bb.grow(-0.1, -0.1, -0.1);
|
||||
if (!level->getCubes(boat, &grown)->empty()) {
|
||||
return itemInstance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ void Explosion::explode() {
|
|||
// walls
|
||||
bool canDamage = false;
|
||||
for (AUTO_VAR(it2, toBlow.begin()); it2 != toBlow.end(); ++it2) {
|
||||
if (e->bb->intersects(it2->x, it2->y, it2->z, it2->x + 1,
|
||||
if (e->bb.intersects(it2->x, it2->y, it2->z, it2->x + 1,
|
||||
it2->y + 1, it2->z + 1)) {
|
||||
canDamage = true;
|
||||
break;
|
||||
|
|
@ -144,7 +144,7 @@ void Explosion::explode() {
|
|||
za /= da;
|
||||
}
|
||||
|
||||
double sp = level->getSeenPercent(¢er, e->bb);
|
||||
double sp = level->getSeenPercent(¢er, &e->bb);
|
||||
double pow = (1 - dist) * sp;
|
||||
if (canDamage)
|
||||
e->hurt(DamageSource::explosion(this),
|
||||
|
|
|
|||
|
|
@ -1691,7 +1691,7 @@ void LevelChunk::getEntities(std::shared_ptr<Entity> except, AABB* bb,
|
|||
AUTO_VAR(itEnd, entities->end());
|
||||
for (AUTO_VAR(it, entities->begin()); it != itEnd; it++) {
|
||||
std::shared_ptr<Entity> e = *it; // entities->at(i);
|
||||
if (e != except && e->bb->intersects(*bb) &&
|
||||
if (e != except && e->bb.intersects(*bb) &&
|
||||
(selector == NULL || selector->matches(e))) {
|
||||
es.push_back(e);
|
||||
std::vector<std::shared_ptr<Entity> >* subs =
|
||||
|
|
@ -1699,7 +1699,7 @@ void LevelChunk::getEntities(std::shared_ptr<Entity> except, AABB* bb,
|
|||
if (subs != NULL) {
|
||||
for (int j = 0; j < subs->size(); j++) {
|
||||
e = subs->at(j);
|
||||
if (e != except && e->bb->intersects(*bb) &&
|
||||
if (e != except && e->bb.intersects(*bb) &&
|
||||
(selector == NULL || selector->matches(e))) {
|
||||
es.push_back(e);
|
||||
}
|
||||
|
|
@ -1765,7 +1765,7 @@ void LevelChunk::getEntitiesOfClass(const std::type_info& ec, AABB* bb,
|
|||
else if (Entity* entity = e.get();
|
||||
entity != NULL && ec == typeid(*entity))
|
||||
isAssignableFrom = true;
|
||||
if (isAssignableFrom && e->bb->intersects(*bb)) {
|
||||
if (isAssignableFrom && e->bb.intersects(*bb)) {
|
||||
if (selector == NULL || selector->matches(e)) {
|
||||
es.push_back(e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -965,9 +965,9 @@ void Player::aiStep() {
|
|||
if (riding != NULL && !riding->removed) {
|
||||
// if the player is riding, also touch entities under the
|
||||
// pig/horse
|
||||
pickupArea = bb->minmax(*riding->bb).grow(1, 0, 1);
|
||||
pickupArea = bb.minmax(riding->bb).grow(1, 0, 1);
|
||||
} else {
|
||||
pickupArea = bb->grow(1, .5, 1);
|
||||
pickupArea = bb.grow(1, .5, 1);
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Entity> >* entities =
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ void CombatTracker::prepareForDamage() {
|
|||
|
||||
if (mob->onLadder()) {
|
||||
int type = mob->level->getTile(
|
||||
Mth::floor(mob->x), Mth::floor(mob->bb->y0), Mth::floor(mob->z));
|
||||
Mth::floor(mob->x), Mth::floor(mob->bb.y0), Mth::floor(mob->z));
|
||||
|
||||
if (type == Tile::ladder->id) {
|
||||
nextLocation = eLocation_LADDER;
|
||||
|
|
|
|||
Loading…
Reference in a new issue