mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-20 09:57:10 +00:00
Merge branch 'dev' into dev
This commit is contained in:
commit
293590ef77
|
|
@ -1112,13 +1112,13 @@ std::shared_ptr<Explosion> ServerLevel::explode(std::shared_ptr<Entity> source,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player->distanceToSqr(x, y, z) < 64 * 64) {
|
if (player->distanceToSqr(x, y, z) < 64 * 64) {
|
||||||
Vec3* knockbackVec = explosion->getHitPlayerKnockback(player);
|
Vec3 knockbackVec = explosion->getHitPlayerKnockback(player);
|
||||||
// app.DebugPrintf("Sending %s with knockback (%f,%f,%f)\n",
|
// app.DebugPrintf("Sending %s with knockback (%f,%f,%f)\n",
|
||||||
// knockbackOnly?"knockbackOnly":"allExplosion",knockbackVec->x,knockbackVec->y,knockbackVec->z);
|
// knockbackOnly?"knockbackOnly":"allExplosion",knockbackVec->x,knockbackVec->y,knockbackVec->z);
|
||||||
// If the player is not the primary on the system, then we only
|
// If the player is not the primary on the system, then we only
|
||||||
// want to send info for the knockback
|
// want to send info for the knockback
|
||||||
player->connection->send(std::shared_ptr<ExplodePacket>(
|
player->connection->send(std::shared_ptr<ExplodePacket>(
|
||||||
new ExplodePacket(x, y, z, r, &explosion->toBlow, knockbackVec,
|
new ExplodePacket(x, y, z, r, &explosion->toBlow, &knockbackVec,
|
||||||
knockbackOnly)));
|
knockbackOnly)));
|
||||||
sentTo.push_back(player);
|
sentTo.push_back(player);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -724,7 +724,6 @@ void Minecraft::run()
|
||||||
// try { // 4J - removed try/catch
|
// try { // 4J - removed try/catch
|
||||||
// if (minecraftApplet != null && !minecraftApplet.isActive()) break; // 4J - removed
|
// if (minecraftApplet != null && !minecraftApplet.isActive()) break; // 4J - removed
|
||||||
AABB::resetPool();
|
AABB::resetPool();
|
||||||
Vec3::resetPool();
|
|
||||||
|
|
||||||
// if (parent == NULL && Display.isCloseRequested()) { // 4J - removed
|
// if (parent == NULL && Display.isCloseRequested()) { // 4J - removed
|
||||||
// stop();
|
// stop();
|
||||||
|
|
@ -1281,7 +1280,6 @@ void Minecraft::run_middle() {
|
||||||
// if (minecraftApplet != null &&
|
// if (minecraftApplet != null &&
|
||||||
// !minecraftApplet.isActive()) break; // 4J - removed
|
// !minecraftApplet.isActive()) break; // 4J - removed
|
||||||
AABB::resetPool();
|
AABB::resetPool();
|
||||||
Vec3::resetPool();
|
|
||||||
|
|
||||||
// if (parent == NULL && Display.isCloseRequested()) {
|
// if (parent == NULL && Display.isCloseRequested()) {
|
||||||
// // 4J - removed
|
// // 4J - removed
|
||||||
|
|
@ -2223,7 +2221,6 @@ void Minecraft::emergencySave() {
|
||||||
// 4J - lots of try/catches removed here, and garbage collector things
|
// 4J - lots of try/catches removed here, and garbage collector things
|
||||||
levelRenderer->clear();
|
levelRenderer->clear();
|
||||||
AABB::clearPool();
|
AABB::clearPool();
|
||||||
Vec3::clearPool();
|
|
||||||
setLevel(NULL);
|
setLevel(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2400,7 +2397,6 @@ void Minecraft::levelTickUpdateFunc(void* pParam) {
|
||||||
|
|
||||||
void Minecraft::levelTickThreadInitFunc() {
|
void Minecraft::levelTickThreadInitFunc() {
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
Vec3::CreateNewThreadStorage();
|
|
||||||
Compression::UseDefaultThreadStorage();
|
Compression::UseDefaultThreadStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2750,7 +2746,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) {
|
||||||
// 4J-PB - Call the useItemOn with the TestOnly flag set
|
// 4J-PB - Call the useItemOn with the TestOnly flag set
|
||||||
bool bUseItemOn = gameMode->useItemOn(
|
bool bUseItemOn = gameMode->useItemOn(
|
||||||
player, level, itemInstance, x, y, z, face,
|
player, level, itemInstance, x, y, z, face,
|
||||||
hitResult->pos, true);
|
&hitResult->pos, true);
|
||||||
|
|
||||||
/* 4J-Jev:
|
/* 4J-Jev:
|
||||||
* Moved this here so we have item tooltips to
|
* Moved this here so we have item tooltips to
|
||||||
|
|
@ -3900,7 +3896,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) {
|
||||||
bool usedItem = false;
|
bool usedItem = false;
|
||||||
gameMode->useItemOn(player, level, nullptr, hitResult->x,
|
gameMode->useItemOn(player, level, nullptr, hitResult->x,
|
||||||
hitResult->y, hitResult->z, 0,
|
hitResult->y, hitResult->z, 0,
|
||||||
hitResult->pos, false, &usedItem);
|
&hitResult->pos, false, &usedItem);
|
||||||
} else {
|
} else {
|
||||||
ui.PlayUISFX(eSFX_Press);
|
ui.PlayUISFX(eSFX_Press);
|
||||||
app.LoadCrafting2x2Menu(iPad, player);
|
app.LoadCrafting2x2Menu(iPad, player);
|
||||||
|
|
|
||||||
|
|
@ -315,7 +315,6 @@ int MinecraftServer::runPostUpdate(void* lpParam) {
|
||||||
Entity::useSmallIds(); // This thread can end up spawning entities as
|
Entity::useSmallIds(); // This thread can end up spawning entities as
|
||||||
// resources
|
// resources
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
Vec3::CreateNewThreadStorage();
|
|
||||||
Compression::UseDefaultThreadStorage();
|
Compression::UseDefaultThreadStorage();
|
||||||
Level::enableLightingCache();
|
Level::enableLightingCache();
|
||||||
Tile::CreateNewThreadStorage();
|
Tile::CreateNewThreadStorage();
|
||||||
|
|
@ -365,7 +364,6 @@ int MinecraftServer::runPostUpdate(void* lpParam) {
|
||||||
// #endif //__PS3__
|
// #endif //__PS3__
|
||||||
Tile::ReleaseThreadStorage();
|
Tile::ReleaseThreadStorage();
|
||||||
AABB::ReleaseThreadStorage();
|
AABB::ReleaseThreadStorage();
|
||||||
Vec3::ReleaseThreadStorage();
|
|
||||||
Level::destroyLightingCache();
|
Level::destroyLightingCache();
|
||||||
|
|
||||||
ShutdownManager::HasFinished(ShutdownManager::ePostProcessThread);
|
ShutdownManager::HasFinished(ShutdownManager::ePostProcessThread);
|
||||||
|
|
@ -1651,7 +1649,6 @@ void MinecraftServer::tick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
AABB::resetPool();
|
AABB::resetPool();
|
||||||
Vec3::resetPool();
|
|
||||||
|
|
||||||
tickCount++;
|
tickCount++;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1551,7 +1551,8 @@ void PlayerConnection::handlePlayerAbilities(
|
||||||
// StringBuilder result = new StringBuilder();
|
// StringBuilder result = new StringBuilder();
|
||||||
|
|
||||||
// for (String candidate : server.getAutoCompletions(player,
|
// for (String candidate : server.getAutoCompletions(player,
|
||||||
//packet.getMessage())) { if (result.length() > 0) result.append("\0");
|
// packet.getMessage())) { if (result.length() > 0)
|
||||||
|
// result.append("\0");
|
||||||
|
|
||||||
// result.append(candidate);
|
// result.append(candidate);
|
||||||
// }
|
// }
|
||||||
|
|
|
||||||
|
|
@ -4706,7 +4706,6 @@ int CMinecraftApp::SignoutExitWorldThreadProc(void* lpParameter) {
|
||||||
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
||||||
// as we don't tick the main thread whilst this thread is running
|
// as we don't tick the main thread whilst this thread is running
|
||||||
AABB::UseDefaultThreadStorage();
|
AABB::UseDefaultThreadStorage();
|
||||||
Vec3::UseDefaultThreadStorage();
|
|
||||||
Compression::UseDefaultThreadStorage();
|
Compression::UseDefaultThreadStorage();
|
||||||
|
|
||||||
// app.SetGameStarted(false);
|
// app.SetGameStarted(false);
|
||||||
|
|
@ -7698,7 +7697,6 @@ int CMinecraftApp::RemoteSaveThreadProc(void* lpParameter) {
|
||||||
// The game should be stopped while we are doing this, but the connections
|
// The game should be stopped while we are doing this, but the connections
|
||||||
// ticks may try to create some AABB's or Vec3's
|
// ticks may try to create some AABB's or Vec3's
|
||||||
AABB::UseDefaultThreadStorage();
|
AABB::UseDefaultThreadStorage();
|
||||||
Vec3::UseDefaultThreadStorage();
|
|
||||||
Compression::UseDefaultThreadStorage();
|
Compression::UseDefaultThreadStorage();
|
||||||
|
|
||||||
// 4J-PB - Xbox 360 - 163153 - [CRASH] TU17: Code: Multiplayer: During the
|
// 4J-PB - Xbox 360 - 163153 - [CRASH] TU17: Code: Multiplayer: During the
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
ApplySchematicRuleDefinition::ApplySchematicRuleDefinition(
|
ApplySchematicRuleDefinition::ApplySchematicRuleDefinition(
|
||||||
LevelGenerationOptions* levelGenOptions) {
|
LevelGenerationOptions* levelGenOptions) {
|
||||||
m_levelGenOptions = levelGenOptions;
|
m_levelGenOptions = levelGenOptions;
|
||||||
m_location = Vec3::newPermanent(0, 0, 0);
|
m_location = Vec3(0, 0, 0);
|
||||||
m_locationBox = NULL;
|
m_locationBox = NULL;
|
||||||
m_totalBlocksChanged = 0;
|
m_totalBlocksChanged = 0;
|
||||||
m_totalBlocksChangedLighting = 0;
|
m_totalBlocksChangedLighting = 0;
|
||||||
|
|
@ -26,7 +26,6 @@ ApplySchematicRuleDefinition::~ApplySchematicRuleDefinition() {
|
||||||
app.DebugPrintf("Deleting ApplySchematicRuleDefinition.\n");
|
app.DebugPrintf("Deleting ApplySchematicRuleDefinition.\n");
|
||||||
if (!m_completed) m_levelGenOptions->releaseSchematicFile(m_schematicName);
|
if (!m_completed) m_levelGenOptions->releaseSchematicFile(m_schematicName);
|
||||||
m_schematic = NULL;
|
m_schematic = NULL;
|
||||||
delete m_location;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplySchematicRuleDefinition::writeAttributes(DataOutputStream* dos,
|
void ApplySchematicRuleDefinition::writeAttributes(DataOutputStream* dos,
|
||||||
|
|
@ -36,11 +35,11 @@ void ApplySchematicRuleDefinition::writeAttributes(DataOutputStream* dos,
|
||||||
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_filename);
|
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_filename);
|
||||||
dos->writeUTF(m_schematicName);
|
dos->writeUTF(m_schematicName);
|
||||||
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x);
|
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x);
|
||||||
dos->writeUTF(_toString(m_location->x));
|
dos->writeUTF(_toString(m_location.x));
|
||||||
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y);
|
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y);
|
||||||
dos->writeUTF(_toString(m_location->y));
|
dos->writeUTF(_toString(m_location.y));
|
||||||
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z);
|
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z);
|
||||||
dos->writeUTF(_toString(m_location->z));
|
dos->writeUTF(_toString(m_location.z));
|
||||||
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_rot);
|
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_rot);
|
||||||
|
|
||||||
switch (m_rotation) {
|
switch (m_rotation) {
|
||||||
|
|
@ -76,19 +75,19 @@ void ApplySchematicRuleDefinition::addAttribute(
|
||||||
m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
|
m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
|
||||||
}
|
}
|
||||||
} else if (attributeName.compare(L"x") == 0) {
|
} else if (attributeName.compare(L"x") == 0) {
|
||||||
m_location->x = _fromString<int>(attributeValue);
|
m_location.x = _fromString<int>(attributeValue);
|
||||||
if (((int)abs(m_location->x)) % 2 != 0) m_location->x -= 1;
|
if (((int)abs(m_location.x)) % 2 != 0) m_location.x -= 1;
|
||||||
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
|
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
|
||||||
// x=%f\n",m_location->x);
|
// x=%f\n",m_location->x);
|
||||||
} else if (attributeName.compare(L"y") == 0) {
|
} else if (attributeName.compare(L"y") == 0) {
|
||||||
m_location->y = _fromString<int>(attributeValue);
|
m_location.y = _fromString<int>(attributeValue);
|
||||||
if (((int)abs(m_location->y)) % 2 != 0) m_location->y -= 1;
|
if (((int)abs(m_location.y)) % 2 != 0) m_location.y -= 1;
|
||||||
if (m_location->y < 0) m_location->y = 0;
|
if (m_location.y < 0) m_location.y = 0;
|
||||||
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
|
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
|
||||||
// y=%f\n",m_location->y);
|
// y=%f\n",m_location->y);
|
||||||
} else if (attributeName.compare(L"z") == 0) {
|
} else if (attributeName.compare(L"z") == 0) {
|
||||||
m_location->z = _fromString<int>(attributeValue);
|
m_location.z = _fromString<int>(attributeValue);
|
||||||
if (((int)abs(m_location->z)) % 2 != 0) m_location->z -= 1;
|
if (((int)abs(m_location.z)) % 2 != 0) m_location.z -= 1;
|
||||||
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
|
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
|
||||||
// z=%f\n",m_location->z);
|
// z=%f\n",m_location->z);
|
||||||
} else if (attributeName.compare(L"rot") == 0) {
|
} else if (attributeName.compare(L"rot") == 0) {
|
||||||
|
|
@ -133,23 +132,23 @@ void ApplySchematicRuleDefinition::updateLocationBox() {
|
||||||
|
|
||||||
m_locationBox = AABB::newPermanent(0, 0, 0, 0, 0, 0);
|
m_locationBox = AABB::newPermanent(0, 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
m_locationBox->x0 = m_location->x;
|
m_locationBox->x0 = m_location.x;
|
||||||
m_locationBox->y0 = m_location->y;
|
m_locationBox->y0 = m_location.y;
|
||||||
m_locationBox->z0 = m_location->z;
|
m_locationBox->z0 = m_location.z;
|
||||||
|
|
||||||
m_locationBox->y1 = m_location->y + m_schematic->getYSize();
|
m_locationBox->y1 = m_location.y + m_schematic->getYSize();
|
||||||
|
|
||||||
switch (m_rotation) {
|
switch (m_rotation) {
|
||||||
case ConsoleSchematicFile::eSchematicRot_90:
|
case ConsoleSchematicFile::eSchematicRot_90:
|
||||||
case ConsoleSchematicFile::eSchematicRot_270:
|
case ConsoleSchematicFile::eSchematicRot_270:
|
||||||
m_locationBox->x1 = m_location->x + m_schematic->getZSize();
|
m_locationBox->x1 = m_location.x + m_schematic->getZSize();
|
||||||
m_locationBox->z1 = m_location->z + m_schematic->getXSize();
|
m_locationBox->z1 = m_location.z + m_schematic->getXSize();
|
||||||
break;
|
break;
|
||||||
case ConsoleSchematicFile::eSchematicRot_0:
|
case ConsoleSchematicFile::eSchematicRot_0:
|
||||||
case ConsoleSchematicFile::eSchematicRot_180:
|
case ConsoleSchematicFile::eSchematicRot_180:
|
||||||
default:
|
default:
|
||||||
m_locationBox->x1 = m_location->x + m_schematic->getXSize();
|
m_locationBox->x1 = m_location.x + m_schematic->getXSize();
|
||||||
m_locationBox->z1 = m_location->z + m_schematic->getZSize();
|
m_locationBox->z1 = m_location.z + m_schematic->getZSize();
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ private:
|
||||||
LevelGenerationOptions* m_levelGenOptions;
|
LevelGenerationOptions* m_levelGenOptions;
|
||||||
std::wstring m_schematicName;
|
std::wstring m_schematicName;
|
||||||
ConsoleSchematicFile* m_schematic;
|
ConsoleSchematicFile* m_schematic;
|
||||||
Vec3* m_location;
|
Vec3 m_location;
|
||||||
AABB* m_locationBox;
|
AABB* m_locationBox;
|
||||||
ConsoleSchematicFile::ESchematicRotation m_rotation;
|
ConsoleSchematicFile::ESchematicRotation m_rotation;
|
||||||
int m_dimension;
|
int m_dimension;
|
||||||
|
|
|
||||||
|
|
@ -155,8 +155,8 @@ void ConsoleSchematicFile::load(DataInputStream* dis) {
|
||||||
// app.DebugPrintf(1,"Loaded entity type %d at
|
// app.DebugPrintf(1,"Loaded entity type %d at
|
||||||
// (%f,%f,%f)\n",(int)type,x,y,z);
|
// (%f,%f,%f)\n",(int)type,x,y,z);
|
||||||
#endif
|
#endif
|
||||||
m_entities.push_back(std::pair<Vec3*, CompoundTag*>(
|
m_entities.push_back(std::pair<Vec3, CompoundTag*>(
|
||||||
Vec3::newPermanent(x, y, z), (CompoundTag*)eTag->copy()));
|
Vec3(x, y, z), (CompoundTag*)eTag->copy()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete tag;
|
delete tag;
|
||||||
|
|
@ -463,8 +463,8 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk* chunk, AABB* chunkBox,
|
||||||
schematicCoordToChunkCoord(destinationBox, te->x, te->z, rot, targetX,
|
schematicCoordToChunkCoord(destinationBox, te->x, te->z, rot, targetX,
|
||||||
targetZ);
|
targetZ);
|
||||||
|
|
||||||
Vec3* pos = Vec3::newTemp(targetX, targetY, targetZ);
|
Vec3 pos(targetX, targetY, targetZ);
|
||||||
if (chunkBox->containsIncludingLowerBound(pos)) {
|
if (chunkBox->containsIncludingLowerBound(&pos)) {
|
||||||
std::shared_ptr<TileEntity> teCopy = chunk->getTileEntity(
|
std::shared_ptr<TileEntity> teCopy = chunk->getTileEntity(
|
||||||
(int)targetX & 15, (int)targetY & 15, (int)targetZ & 15);
|
(int)targetX & 15, (int)targetY & 15, (int)targetZ & 15);
|
||||||
|
|
||||||
|
|
@ -500,19 +500,18 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk* chunk, AABB* chunkBox,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (AUTO_VAR(it, m_entities.begin()); it != m_entities.end();) {
|
for (AUTO_VAR(it, m_entities.begin()); it != m_entities.end();) {
|
||||||
Vec3* source = it->first;
|
Vec3 source = it->first;
|
||||||
|
|
||||||
double targetX = source->x;
|
double targetX = source.x;
|
||||||
double targetY = source->y + destinationBox->y0;
|
double targetY = source.y + destinationBox->y0;
|
||||||
double targetZ = source->z;
|
double targetZ = source.z;
|
||||||
schematicCoordToChunkCoord(destinationBox, source->x, source->z, rot,
|
schematicCoordToChunkCoord(destinationBox, source.x, source.z, rot,
|
||||||
targetX, targetZ);
|
targetX, targetZ);
|
||||||
|
|
||||||
// Add 0.01 as the AABB::contains function returns false if a value is
|
// Add 0.01 as the AABB::contains function returns false if a value is
|
||||||
// <= the lower bound
|
// <= the lower bound
|
||||||
Vec3* pos =
|
Vec3 pos(targetX + 0.01, targetY + 0.01, targetZ + 0.01);
|
||||||
Vec3::newTemp(targetX + 0.01, targetY + 0.01, targetZ + 0.01);
|
if (!chunkBox->containsIncludingLowerBound(&pos)) {
|
||||||
if (!chunkBox->containsIncludingLowerBound(pos)) {
|
|
||||||
++it;
|
++it;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -800,8 +799,8 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, byteArray* data,
|
||||||
// if (xs * ys * zs == LevelChunk::BLOCKS_LENGTH)
|
// if (xs * ys * zs == LevelChunk::BLOCKS_LENGTH)
|
||||||
//{
|
//{
|
||||||
// byteArray blockData = byteArray(data->data + blocksP,
|
// byteArray blockData = byteArray(data->data + blocksP,
|
||||||
//Level::CHUNK_TILE_COUNT); chunk->getBlockData(blockData); blocksP +=
|
// Level::CHUNK_TILE_COUNT); chunk->getBlockData(blockData);
|
||||||
//blockData.length;
|
// blocksP += blockData.length;
|
||||||
|
|
||||||
// byteArray dataData = byteArray(data->data + dataP, 16384);
|
// byteArray dataData = byteArray(data->data + dataP, 16384);
|
||||||
// chunk->getBlockLightData(dataData);
|
// chunk->getBlockLightData(dataData);
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ public:
|
||||||
private:
|
private:
|
||||||
int m_xSize, m_ySize, m_zSize;
|
int m_xSize, m_ySize, m_zSize;
|
||||||
std::vector<std::shared_ptr<TileEntity> > m_tileEntities;
|
std::vector<std::shared_ptr<TileEntity> > m_tileEntities;
|
||||||
std::vector<std::pair<Vec3*, CompoundTag*> > m_entities;
|
std::vector<std::pair<Vec3, CompoundTag*> > m_entities;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
byteArray m_data;
|
byteArray m_data;
|
||||||
|
|
|
||||||
|
|
@ -948,7 +948,6 @@ int CGameNetworkManager::RunNetworkGameThreadProc(void* lpParameter) {
|
||||||
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
||||||
// as we don't tick the main thread whilst this thread is running
|
// as we don't tick the main thread whilst this thread is running
|
||||||
AABB::UseDefaultThreadStorage();
|
AABB::UseDefaultThreadStorage();
|
||||||
Vec3::UseDefaultThreadStorage();
|
|
||||||
Compression::UseDefaultThreadStorage();
|
Compression::UseDefaultThreadStorage();
|
||||||
Tile::CreateNewThreadStorage();
|
Tile::CreateNewThreadStorage();
|
||||||
|
|
||||||
|
|
@ -1008,7 +1007,6 @@ int CGameNetworkManager::ServerThreadProc(void* lpParameter) {
|
||||||
|
|
||||||
SetThreadName(-1, "Minecraft Server thread");
|
SetThreadName(-1, "Minecraft Server thread");
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
Vec3::CreateNewThreadStorage();
|
|
||||||
Compression::UseDefaultThreadStorage();
|
Compression::UseDefaultThreadStorage();
|
||||||
OldChunkStorage::UseDefaultThreadStorage();
|
OldChunkStorage::UseDefaultThreadStorage();
|
||||||
Entity::useSmallIds();
|
Entity::useSmallIds();
|
||||||
|
|
@ -1022,7 +1020,6 @@ int CGameNetworkManager::ServerThreadProc(void* lpParameter) {
|
||||||
|
|
||||||
Tile::ReleaseThreadStorage();
|
Tile::ReleaseThreadStorage();
|
||||||
AABB::ReleaseThreadStorage();
|
AABB::ReleaseThreadStorage();
|
||||||
Vec3::ReleaseThreadStorage();
|
|
||||||
Level::destroyLightingCache();
|
Level::destroyLightingCache();
|
||||||
|
|
||||||
if (lpParameter != NULL) delete (NetworkGameInitData*)lpParameter;
|
if (lpParameter != NULL) delete (NetworkGameInitData*)lpParameter;
|
||||||
|
|
@ -1034,7 +1031,6 @@ int CGameNetworkManager::ExitAndJoinFromInviteThreadProc(void* lpParam) {
|
||||||
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
||||||
// as we don't tick the main thread whilst this thread is running
|
// as we don't tick the main thread whilst this thread is running
|
||||||
AABB::UseDefaultThreadStorage();
|
AABB::UseDefaultThreadStorage();
|
||||||
Vec3::UseDefaultThreadStorage();
|
|
||||||
Compression::UseDefaultThreadStorage();
|
Compression::UseDefaultThreadStorage();
|
||||||
|
|
||||||
// app.SetGameStarted(false);
|
// app.SetGameStarted(false);
|
||||||
|
|
@ -1187,7 +1183,6 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc(void* lpParam) {
|
||||||
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
||||||
// as we don't tick the main thread whilst this thread is running
|
// as we don't tick the main thread whilst this thread is running
|
||||||
AABB::UseDefaultThreadStorage();
|
AABB::UseDefaultThreadStorage();
|
||||||
Vec3::UseDefaultThreadStorage();
|
|
||||||
Compression::UseDefaultThreadStorage();
|
Compression::UseDefaultThreadStorage();
|
||||||
|
|
||||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ AreaConstraint::~AreaConstraint() {
|
||||||
|
|
||||||
bool AreaConstraint::isConstraintSatisfied(int iPad) {
|
bool AreaConstraint::isConstraintSatisfied(int iPad) {
|
||||||
Minecraft* minecraft = Minecraft::GetInstance();
|
Minecraft* minecraft = Minecraft::GetInstance();
|
||||||
return messageArea->contains(minecraft->localplayers[iPad]->getPos(1)) ==
|
Vec3 ipad_player = minecraft->localplayers[iPad]->getPos(1);
|
||||||
contains;
|
return messageArea->contains(&ipad_player) == contains;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AreaConstraint::isConstraintRestrictive(int iPad) {
|
bool AreaConstraint::isConstraintRestrictive(int iPad) {
|
||||||
|
|
@ -37,15 +37,15 @@ bool AreaConstraint::canMoveToPosition(double xo, double yo, double zo,
|
||||||
double xt, double yt, double zt) {
|
double xt, double yt, double zt) {
|
||||||
if (!m_restrictsMovement) return true;
|
if (!m_restrictsMovement) return true;
|
||||||
|
|
||||||
Vec3* targetPos = Vec3::newTemp(xt, yt, zt);
|
Vec3 targetPos(xt, yt, zt);
|
||||||
Minecraft* minecraft = Minecraft::GetInstance();
|
Minecraft* minecraft = Minecraft::GetInstance();
|
||||||
|
|
||||||
if (movementArea->contains(targetPos) == contains) {
|
if (movementArea->contains(&targetPos) == contains) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Vec3* origPos = Vec3::newTemp(xo, yo, zo);
|
Vec3 origPos(xo, yo, zo);
|
||||||
|
|
||||||
double currDist = origPos->distanceTo(movementArea);
|
double currDist = origPos.distanceTo(movementArea);
|
||||||
double targetDist = targetPos->distanceTo(movementArea);
|
double targetDist = targetPos.distanceTo(movementArea);
|
||||||
return targetDist < currDist;
|
return targetDist < currDist;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,11 @@ AreaHint::~AreaHint() { delete area; }
|
||||||
|
|
||||||
int AreaHint::tick() {
|
int AreaHint::tick() {
|
||||||
Minecraft* minecraft = Minecraft::GetInstance();
|
Minecraft* minecraft = Minecraft::GetInstance();
|
||||||
|
Vec3 player_pos = minecraft->player->getPos(1);
|
||||||
|
|
||||||
if ((m_displayState == e_Tutorial_State_Any ||
|
if ((m_displayState == e_Tutorial_State_Any ||
|
||||||
m_tutorial->getCurrentState() == m_displayState) &&
|
m_tutorial->getCurrentState() == m_displayState) &&
|
||||||
m_hintNeeded &&
|
m_hintNeeded && area->contains(&player_pos) == contains) {
|
||||||
area->contains(minecraft->player->getPos(1)) == contains) {
|
|
||||||
if (m_completeState == e_Tutorial_State_None) {
|
if (m_completeState == e_Tutorial_State_None) {
|
||||||
m_hintNeeded = false;
|
m_hintNeeded = false;
|
||||||
} else if (m_tutorial->isStateCompleted(m_completeState)) {
|
} else if (m_tutorial->isStateCompleted(m_completeState)) {
|
||||||
|
|
|
||||||
|
|
@ -85,9 +85,9 @@ void ChangeStateConstraint::tick(int iPad) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Vec3 ipad_player = minecraft->localplayers[iPad]->getPos(1);
|
||||||
if (!m_bHasChanged && inASourceState &&
|
if (!m_bHasChanged && inASourceState &&
|
||||||
movementArea->contains(minecraft->localplayers[iPad]->getPos(1)) ==
|
movementArea->contains(&ipad_player) == contains) {
|
||||||
contains) {
|
|
||||||
m_bHasChanged = true;
|
m_bHasChanged = true;
|
||||||
m_changedFromState = m_tutorial->getCurrentState();
|
m_changedFromState = m_tutorial->getCurrentState();
|
||||||
m_tutorial->changeTutorialState(m_targetState);
|
m_tutorial->changeTutorialState(m_targetState);
|
||||||
|
|
@ -125,8 +125,7 @@ void ChangeStateConstraint::tick(int iPad) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (m_bHasChanged &&
|
} else if (m_bHasChanged &&
|
||||||
movementArea->contains(
|
movementArea->contains(&ipad_player) != contains) {
|
||||||
minecraft->localplayers[iPad]->getPos(1)) != contains) {
|
|
||||||
m_bHasChanged = false;
|
m_bHasChanged = false;
|
||||||
m_tutorial->changeTutorialState(m_changedFromState);
|
m_tutorial->changeTutorialState(m_changedFromState);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -381,7 +381,6 @@ int IUIScene_PauseMenu::SaveWorldThreadProc(void* lpParameter) {
|
||||||
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
||||||
// as we don't tick the main thread whilst this thread is running
|
// as we don't tick the main thread whilst this thread is running
|
||||||
AABB::UseDefaultThreadStorage();
|
AABB::UseDefaultThreadStorage();
|
||||||
Vec3::UseDefaultThreadStorage();
|
|
||||||
Compression::UseDefaultThreadStorage();
|
Compression::UseDefaultThreadStorage();
|
||||||
|
|
||||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||||
|
|
@ -419,7 +418,6 @@ int IUIScene_PauseMenu::ExitWorldThreadProc(void* lpParameter) {
|
||||||
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
||||||
// as we don't tick the main thread whilst this thread is running
|
// as we don't tick the main thread whilst this thread is running
|
||||||
AABB::UseDefaultThreadStorage();
|
AABB::UseDefaultThreadStorage();
|
||||||
Vec3::UseDefaultThreadStorage();
|
|
||||||
Compression::UseDefaultThreadStorage();
|
Compression::UseDefaultThreadStorage();
|
||||||
|
|
||||||
// app.SetGameStarted(false);
|
// app.SetGameStarted(false);
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,13 @@ UIScene_DebugSetCamera::UIScene_DebugSetCamera(int iPad, void* initData,
|
||||||
|
|
||||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||||
if (pMinecraft != NULL) {
|
if (pMinecraft != NULL) {
|
||||||
Vec3* vec = pMinecraft->localplayers[playerNo]->getPos(1.0);
|
Vec3 vec = pMinecraft->localplayers[playerNo]->getPos(1.0);
|
||||||
|
|
||||||
currentPosition->m_camX = vec->x;
|
currentPosition->m_camX = vec.x;
|
||||||
currentPosition->m_camY =
|
currentPosition->m_camY =
|
||||||
vec->y -
|
vec.y -
|
||||||
1.62; // pMinecraft->localplayers[playerNo]->getHeadHeight();
|
1.62; // pMinecraft->localplayers[playerNo]->getHeadHeight();
|
||||||
currentPosition->m_camZ = vec->z;
|
currentPosition->m_camZ = vec.z;
|
||||||
|
|
||||||
currentPosition->m_yRot = pMinecraft->localplayers[playerNo]->yRot;
|
currentPosition->m_yRot = pMinecraft->localplayers[playerNo]->yRot;
|
||||||
currentPosition->m_elev = pMinecraft->localplayers[playerNo]->xRot;
|
currentPosition->m_elev = pMinecraft->localplayers[playerNo]->xRot;
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,6 @@ HRESULT CScene_Death::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled) {
|
||||||
|
|
||||||
int CScene_Death::RespawnThreadProc(void* lpParameter) {
|
int CScene_Death::RespawnThreadProc(void* lpParameter) {
|
||||||
AABB::UseDefaultThreadStorage();
|
AABB::UseDefaultThreadStorage();
|
||||||
Vec3::UseDefaultThreadStorage();
|
|
||||||
Compression::UseDefaultThreadStorage();
|
Compression::UseDefaultThreadStorage();
|
||||||
size_t iPad = (size_t)lpParameter;
|
size_t iPad = (size_t)lpParameter;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1074,7 +1074,6 @@ int UIScene_PauseMenu::SaveWorldThreadProc(LPVOID lpParameter) {
|
||||||
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
||||||
// as we don't tick the main thread whilst this thread is running
|
// as we don't tick the main thread whilst this thread is running
|
||||||
AABB::UseDefaultThreadStorage();
|
AABB::UseDefaultThreadStorage();
|
||||||
Vec3::UseDefaultThreadStorage();
|
|
||||||
Compression::UseDefaultThreadStorage();
|
Compression::UseDefaultThreadStorage();
|
||||||
|
|
||||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||||
|
|
@ -1107,7 +1106,6 @@ int UIScene_PauseMenu::ExitWorldThreadProc(void* lpParameter) {
|
||||||
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
// Share AABB & Vec3 pools with default (main thread) - should be ok as long
|
||||||
// as we don't tick the main thread whilst this thread is running
|
// as we don't tick the main thread whilst this thread is running
|
||||||
AABB::UseDefaultThreadStorage();
|
AABB::UseDefaultThreadStorage();
|
||||||
Vec3::UseDefaultThreadStorage();
|
|
||||||
Compression::UseDefaultThreadStorage();
|
Compression::UseDefaultThreadStorage();
|
||||||
|
|
||||||
// app.SetGameStarted(false);
|
// app.SetGameStarted(false);
|
||||||
|
|
|
||||||
|
|
@ -795,7 +795,6 @@ void oldWinMainInit() {
|
||||||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||||
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
Vec3::CreateNewThreadStorage();
|
|
||||||
OldChunkStorage::CreateNewThreadStorage();
|
OldChunkStorage::CreateNewThreadStorage();
|
||||||
Level::enableLightingCache();
|
Level::enableLightingCache();
|
||||||
Tile::CreateNewThreadStorage();
|
Tile::CreateNewThreadStorage();
|
||||||
|
|
@ -1143,9 +1142,6 @@ void oldWinMainTick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix for #7318 - Title crashes after short soak in the leaderboards menu
|
// Fix for #7318 - Title crashes after short soak in the leaderboards menu
|
||||||
// A memory leak was caused because the icon renderer kept creating new
|
|
||||||
// Vec3's because the pool wasn't reset
|
|
||||||
Vec3::resetPool();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MEMORY_TRACKING
|
#ifdef MEMORY_TRACKING
|
||||||
|
|
|
||||||
|
|
@ -711,7 +711,6 @@ void CleanupDevice() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int StartMinecraftThreadProc(void* lpParameter) {
|
int StartMinecraftThreadProc(void* lpParameter) {
|
||||||
Vec3::UseDefaultThreadStorage();
|
|
||||||
AABB::UseDefaultThreadStorage();
|
AABB::UseDefaultThreadStorage();
|
||||||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||||
RenderManager.InitialiseContext();
|
RenderManager.InitialiseContext();
|
||||||
|
|
@ -868,7 +867,6 @@ return -1;
|
||||||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||||
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
Vec3::CreateNewThreadStorage();
|
|
||||||
Compression::CreateNewThreadStorage();
|
Compression::CreateNewThreadStorage();
|
||||||
OldChunkStorage::CreateNewThreadStorage();
|
OldChunkStorage::CreateNewThreadStorage();
|
||||||
Level::enableLightingCache();
|
Level::enableLightingCache();
|
||||||
|
|
@ -1103,9 +1101,6 @@ PIXEndNamedEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
||||||
// menu A memory leak was caused because the icon renderer kept creating
|
|
||||||
// new Vec3's because the pool wasn't reset
|
|
||||||
Vec3::resetPool();
|
|
||||||
} // end game loop
|
} // end game loop
|
||||||
|
|
||||||
// Graceful shutdown: destroy GL context and GLFW before any C++ dtors run.
|
// Graceful shutdown: destroy GL context and GLFW before any C++ dtors run.
|
||||||
|
|
|
||||||
|
|
@ -1040,7 +1040,6 @@ void RegisterAwardsWithProfileManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int StartMinecraftThreadProc(void* lpParameter) {
|
int StartMinecraftThreadProc(void* lpParameter) {
|
||||||
Vec3::UseDefaultThreadStorage();
|
|
||||||
AABB::UseDefaultThreadStorage();
|
AABB::UseDefaultThreadStorage();
|
||||||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||||
RenderManager.InitialiseContext();
|
RenderManager.InitialiseContext();
|
||||||
|
|
@ -1378,7 +1377,6 @@ int main(int argc, const char* argv[]) {
|
||||||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||||
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
Vec3::CreateNewThreadStorage();
|
|
||||||
Compression::CreateNewThreadStorage();
|
Compression::CreateNewThreadStorage();
|
||||||
OldChunkStorage::CreateNewThreadStorage();
|
OldChunkStorage::CreateNewThreadStorage();
|
||||||
Level::enableLightingCache();
|
Level::enableLightingCache();
|
||||||
|
|
@ -1737,9 +1735,6 @@ int main(int argc, const char* argv[]) {
|
||||||
app.PatchAvailableDialogTick();
|
app.PatchAvailableDialogTick();
|
||||||
|
|
||||||
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
||||||
// menu A memory leak was caused because the icon renderer kept creating
|
|
||||||
// new Vec3's because the pool wasn't reset
|
|
||||||
Vec3::resetPool();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free resources, unregister custom classes, and exit.
|
// Free resources, unregister custom classes, and exit.
|
||||||
|
|
|
||||||
|
|
@ -27,373 +27,359 @@
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
namespace boost { namespace spirit { namespace lex { namespace lexertl
|
namespace boost {
|
||||||
{
|
namespace spirit {
|
||||||
///////////////////////////////////////////////////////////////////////////
|
namespace lex {
|
||||||
namespace detail
|
namespace lexertl {
|
||||||
{
|
///////////////////////////////////////////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////////////////
|
namespace detail {
|
||||||
// The must_escape function checks if the given character value needs
|
///////////////////////////////////////////////////////////////////////
|
||||||
// to be preceded by a backslash character to disable its special
|
// The must_escape function checks if the given character value needs
|
||||||
// meaning in the context of a regular expression
|
// to be preceded by a backslash character to disable its special
|
||||||
///////////////////////////////////////////////////////////////////////
|
// meaning in the context of a regular expression
|
||||||
template <typename Char>
|
///////////////////////////////////////////////////////////////////////
|
||||||
inline bool must_escape(Char c)
|
template <typename Char>
|
||||||
{
|
inline bool must_escape(Char c) {
|
||||||
// FIXME: more needed?
|
// FIXME: more needed?
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '+': case '/': case '*': case '?':
|
case '+':
|
||||||
case '|':
|
case '/':
|
||||||
case '(': case ')':
|
case '*':
|
||||||
case '[': case ']':
|
case '?':
|
||||||
case '{': case '}':
|
case '|':
|
||||||
case '.':
|
case '(':
|
||||||
case '^': case '$':
|
case ')':
|
||||||
case '\\':
|
case '[':
|
||||||
case '"':
|
case ']':
|
||||||
return true;
|
case '{':
|
||||||
|
case '}':
|
||||||
|
case '.':
|
||||||
|
case '^':
|
||||||
|
case '$':
|
||||||
|
case '\\':
|
||||||
|
case '"':
|
||||||
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
// The escape function returns the string representation of the given
|
// The escape function returns the string representation of the given
|
||||||
// character value, possibly escaped with a backslash character, to
|
// character value, possibly escaped with a backslash character, to
|
||||||
// allow it being safely used in a regular expression definition.
|
// allow it being safely used in a regular expression definition.
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
inline std::basic_string<Char> escape(Char ch)
|
inline std::basic_string<Char> escape(Char ch) {
|
||||||
{
|
std::basic_string<Char> result(1, ch);
|
||||||
std::basic_string<Char> result(1, ch);
|
if (detail::must_escape(ch)) {
|
||||||
if (detail::must_escape(ch))
|
typedef typename std::basic_string<Char>::size_type size_type;
|
||||||
{
|
result.insert((size_type)0, 1, '\\');
|
||||||
typedef typename std::basic_string<Char>::size_type size_type;
|
}
|
||||||
result.insert((size_type)0, 1, '\\');
|
return result;
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
inline boost::lexer::regex_flags map_flags(unsigned int flags)
|
inline boost::lexer::regex_flags map_flags(unsigned int flags) {
|
||||||
{
|
unsigned int retval = boost::lexer::none;
|
||||||
unsigned int retval = boost::lexer::none;
|
if (flags & match_flags::match_not_dot_newline)
|
||||||
if (flags & match_flags::match_not_dot_newline)
|
retval |= boost::lexer::dot_not_newline;
|
||||||
retval |= boost::lexer::dot_not_newline;
|
if (flags & match_flags::match_icase) retval |= boost::lexer::icase;
|
||||||
if (flags & match_flags::match_icase)
|
|
||||||
retval |= boost::lexer::icase;
|
|
||||||
|
|
||||||
return boost::lexer::regex_flags(retval);
|
return boost::lexer::regex_flags(retval);
|
||||||
}
|
}
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename Lexer, typename F>
|
||||||
|
bool generate_static(Lexer const&,
|
||||||
|
std::basic_ostream<typename Lexer::char_type>&,
|
||||||
|
typename Lexer::char_type const*, F);
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Every lexer type to be used as a lexer for Spirit has to conform to
|
||||||
|
// the following public interface:
|
||||||
|
//
|
||||||
|
// typedefs:
|
||||||
|
// iterator_type The type of the iterator exposed by this lexer.
|
||||||
|
// token_type The type of the tokens returned from the exposed
|
||||||
|
// iterators.
|
||||||
|
//
|
||||||
|
// functions:
|
||||||
|
// default constructor
|
||||||
|
// Since lexers are instantiated as base classes
|
||||||
|
// only it might be a good idea to make this
|
||||||
|
// constructor protected.
|
||||||
|
// begin, end Return a pair of iterators, when dereferenced
|
||||||
|
// returning the sequence of tokens recognized in
|
||||||
|
// the input stream given as the parameters to the
|
||||||
|
// begin() function.
|
||||||
|
// add_token Should add the definition of a token to be
|
||||||
|
// recognized by this lexer.
|
||||||
|
// clear Should delete all current token definitions
|
||||||
|
// associated with the given state of this lexer
|
||||||
|
// object.
|
||||||
|
//
|
||||||
|
// template parameters:
|
||||||
|
// Iterator The type of the iterator used to access the
|
||||||
|
// underlying character stream.
|
||||||
|
// Token The type of the tokens to be returned from the
|
||||||
|
// exposed token iterator.
|
||||||
|
// Functor The type of the InputPolicy to use to instantiate
|
||||||
|
// the multi_pass iterator type to be used as the
|
||||||
|
// token iterator (returned from begin()/end()).
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// The lexer class is a implementation of a Spirit.Lex lexer on
|
||||||
|
// top of Ben Hanson's lexertl library as outlined above (For more
|
||||||
|
// information about lexertl go here: http://www.benhanson.net/lexertl.html).
|
||||||
|
//
|
||||||
|
// This class is supposed to be used as the first and only template
|
||||||
|
// parameter while instantiating instances of a lex::lexer class.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename Token = token<>,
|
||||||
|
typename Iterator = typename Token::iterator_type,
|
||||||
|
typename Functor = functor<Token, lexertl::detail::data, Iterator> >
|
||||||
|
class lexer {
|
||||||
|
private:
|
||||||
|
struct dummy {
|
||||||
|
void true_() {}
|
||||||
|
};
|
||||||
|
typedef void (dummy::*safe_bool)();
|
||||||
|
|
||||||
|
static std::size_t const all_states_id = static_cast<std::size_t>(-2);
|
||||||
|
|
||||||
|
public:
|
||||||
|
operator safe_bool() const { return initialized_dfa_ ? &dummy::true_ : 0; }
|
||||||
|
|
||||||
|
typedef
|
||||||
|
typename boost::detail::iterator_traits<Iterator>::value_type char_type;
|
||||||
|
typedef std::basic_string<char_type> string_type;
|
||||||
|
|
||||||
|
typedef boost::lexer::basic_rules<char_type> basic_rules_type;
|
||||||
|
|
||||||
|
// Every lexer type to be used as a lexer for Spirit has to conform to
|
||||||
|
// a public interface .
|
||||||
|
typedef Token token_type;
|
||||||
|
typedef typename Token::id_type id_type;
|
||||||
|
typedef iterator<Functor> iterator_type;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// this type is purely used for the iterator_type construction below
|
||||||
|
struct iterator_data_type {
|
||||||
|
typedef typename Functor::semantic_actions_type semantic_actions_type;
|
||||||
|
|
||||||
|
iterator_data_type(
|
||||||
|
boost::lexer::basic_state_machine<char_type> const& sm,
|
||||||
|
boost::lexer::basic_rules<char_type> const& rules,
|
||||||
|
semantic_actions_type const& actions)
|
||||||
|
: state_machine_(sm), rules_(rules), actions_(actions) {}
|
||||||
|
|
||||||
|
boost::lexer::basic_state_machine<char_type> const& state_machine_;
|
||||||
|
boost::lexer::basic_rules<char_type> const& rules_;
|
||||||
|
semantic_actions_type const& actions_;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// silence MSVC warning C4512: assignment operator could not be
|
||||||
|
// generated
|
||||||
|
iterator_data_type& operator=(iterator_data_type const&);
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Return the start iterator usable for iterating over the generated
|
||||||
|
// tokens.
|
||||||
|
iterator_type begin(Iterator& first, Iterator const& last,
|
||||||
|
char_type const* initial_state = 0) const {
|
||||||
|
if (!init_dfa()) // never minimize DFA for dynamic lexers
|
||||||
|
return iterator_type();
|
||||||
|
|
||||||
|
iterator_data_type iterator_data(state_machine_, rules_, actions_);
|
||||||
|
return iterator_type(iterator_data, first, last, initial_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
// Return the end iterator usable to stop iterating over the generated
|
||||||
template <typename Lexer, typename F>
|
// tokens.
|
||||||
bool generate_static(Lexer const&
|
iterator_type end() const { return iterator_type(); }
|
||||||
, std::basic_ostream<typename Lexer::char_type>&
|
|
||||||
, typename Lexer::char_type const*, F);
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
protected:
|
||||||
//
|
// Lexer instances can be created by means of a derived class only.
|
||||||
// Every lexer type to be used as a lexer for Spirit has to conform to
|
lexer(unsigned int flags)
|
||||||
// the following public interface:
|
: flags_(detail::map_flags(flags)),
|
||||||
//
|
rules_(flags_),
|
||||||
// typedefs:
|
initialized_dfa_(false) {}
|
||||||
// iterator_type The type of the iterator exposed by this lexer.
|
|
||||||
// token_type The type of the tokens returned from the exposed
|
|
||||||
// iterators.
|
|
||||||
//
|
|
||||||
// functions:
|
|
||||||
// default constructor
|
|
||||||
// Since lexers are instantiated as base classes
|
|
||||||
// only it might be a good idea to make this
|
|
||||||
// constructor protected.
|
|
||||||
// begin, end Return a pair of iterators, when dereferenced
|
|
||||||
// returning the sequence of tokens recognized in
|
|
||||||
// the input stream given as the parameters to the
|
|
||||||
// begin() function.
|
|
||||||
// add_token Should add the definition of a token to be
|
|
||||||
// recognized by this lexer.
|
|
||||||
// clear Should delete all current token definitions
|
|
||||||
// associated with the given state of this lexer
|
|
||||||
// object.
|
|
||||||
//
|
|
||||||
// template parameters:
|
|
||||||
// Iterator The type of the iterator used to access the
|
|
||||||
// underlying character stream.
|
|
||||||
// Token The type of the tokens to be returned from the
|
|
||||||
// exposed token iterator.
|
|
||||||
// Functor The type of the InputPolicy to use to instantiate
|
|
||||||
// the multi_pass iterator type to be used as the
|
|
||||||
// token iterator (returned from begin()/end()).
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
public:
|
||||||
//
|
// interface for token definition management
|
||||||
// The lexer class is a implementation of a Spirit.Lex lexer on
|
std::size_t add_token(char_type const* state, char_type tokendef,
|
||||||
// top of Ben Hanson's lexertl library as outlined above (For more
|
std::size_t token_id, char_type const* targetstate) {
|
||||||
// information about lexertl go here: http://www.benhanson.net/lexertl.html).
|
add_state(state);
|
||||||
//
|
initialized_dfa_ = false;
|
||||||
// This class is supposed to be used as the first and only template
|
if (state == all_states())
|
||||||
// parameter while instantiating instances of a lex::lexer class.
|
return rules_.add(state, detail::escape(tokendef), token_id,
|
||||||
//
|
rules_.dot());
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
template <typename Token = token<>
|
|
||||||
, typename Iterator = typename Token::iterator_type
|
|
||||||
, typename Functor = functor<Token, lexertl::detail::data, Iterator> >
|
|
||||||
class lexer
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
struct dummy { void true_() {} };
|
|
||||||
typedef void (dummy::*safe_bool)();
|
|
||||||
|
|
||||||
static std::size_t const all_states_id = static_cast<std::size_t>(-2);
|
if (0 == targetstate)
|
||||||
|
targetstate = state;
|
||||||
|
else
|
||||||
|
add_state(targetstate);
|
||||||
|
return rules_.add(state, detail::escape(tokendef), token_id,
|
||||||
|
targetstate);
|
||||||
|
}
|
||||||
|
std::size_t add_token(char_type const* state, string_type const& tokendef,
|
||||||
|
std::size_t token_id, char_type const* targetstate) {
|
||||||
|
add_state(state);
|
||||||
|
initialized_dfa_ = false;
|
||||||
|
if (state == all_states())
|
||||||
|
return rules_.add(state, tokendef, token_id, rules_.dot());
|
||||||
|
|
||||||
public:
|
if (0 == targetstate)
|
||||||
operator safe_bool() const
|
targetstate = state;
|
||||||
{ return initialized_dfa_ ? &dummy::true_ : 0; }
|
else
|
||||||
|
add_state(targetstate);
|
||||||
|
return rules_.add(state, tokendef, token_id, targetstate);
|
||||||
|
}
|
||||||
|
|
||||||
typedef typename boost::detail::iterator_traits<Iterator>::value_type
|
// interface for pattern definition management
|
||||||
char_type;
|
void add_pattern(char_type const* state, string_type const& name,
|
||||||
typedef std::basic_string<char_type> string_type;
|
string_type const& patterndef) {
|
||||||
|
add_state(state);
|
||||||
|
rules_.add_macro(name.c_str(), patterndef);
|
||||||
|
initialized_dfa_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
typedef boost::lexer::basic_rules<char_type> basic_rules_type;
|
boost::lexer::rules const& get_rules() const { return rules_; }
|
||||||
|
|
||||||
// Every lexer type to be used as a lexer for Spirit has to conform to
|
void clear(char_type const* state) {
|
||||||
// a public interface .
|
std::size_t s = rules_.state(state);
|
||||||
typedef Token token_type;
|
if (boost::lexer::npos != s) rules_.clear(state);
|
||||||
typedef typename Token::id_type id_type;
|
initialized_dfa_ = false;
|
||||||
typedef iterator<Functor> iterator_type;
|
}
|
||||||
|
std::size_t add_state(char_type const* state) {
|
||||||
|
if (state == all_states()) return all_states_id;
|
||||||
|
|
||||||
private:
|
std::size_t stateid = rules_.state(state);
|
||||||
// this type is purely used for the iterator_type construction below
|
if (boost::lexer::npos == stateid) {
|
||||||
struct iterator_data_type
|
stateid = rules_.add_state(state);
|
||||||
{
|
|
||||||
typedef typename Functor::semantic_actions_type semantic_actions_type;
|
|
||||||
|
|
||||||
iterator_data_type(
|
|
||||||
boost::lexer::basic_state_machine<char_type> const& sm
|
|
||||||
, boost::lexer::basic_rules<char_type> const& rules
|
|
||||||
, semantic_actions_type const& actions)
|
|
||||||
: state_machine_(sm), rules_(rules), actions_(actions)
|
|
||||||
{}
|
|
||||||
|
|
||||||
boost::lexer::basic_state_machine<char_type> const& state_machine_;
|
|
||||||
boost::lexer::basic_rules<char_type> const& rules_;
|
|
||||||
semantic_actions_type const& actions_;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// silence MSVC warning C4512: assignment operator could not be generated
|
|
||||||
iterator_data_type& operator= (iterator_data_type const&);
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Return the start iterator usable for iterating over the generated
|
|
||||||
// tokens.
|
|
||||||
iterator_type begin(Iterator& first, Iterator const& last
|
|
||||||
, char_type const* initial_state = 0) const
|
|
||||||
{
|
|
||||||
if (!init_dfa()) // never minimize DFA for dynamic lexers
|
|
||||||
return iterator_type();
|
|
||||||
|
|
||||||
iterator_data_type iterator_data(state_machine_, rules_, actions_);
|
|
||||||
return iterator_type(iterator_data, first, last, initial_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the end iterator usable to stop iterating over the generated
|
|
||||||
// tokens.
|
|
||||||
iterator_type end() const
|
|
||||||
{
|
|
||||||
return iterator_type();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// Lexer instances can be created by means of a derived class only.
|
|
||||||
lexer(unsigned int flags)
|
|
||||||
: flags_(detail::map_flags(flags))
|
|
||||||
, rules_(flags_)
|
|
||||||
, initialized_dfa_(false)
|
|
||||||
{}
|
|
||||||
|
|
||||||
public:
|
|
||||||
// interface for token definition management
|
|
||||||
std::size_t add_token(char_type const* state, char_type tokendef,
|
|
||||||
std::size_t token_id, char_type const* targetstate)
|
|
||||||
{
|
|
||||||
add_state(state);
|
|
||||||
initialized_dfa_ = false;
|
|
||||||
if (state == all_states())
|
|
||||||
return rules_.add(state, detail::escape(tokendef), token_id, rules_.dot());
|
|
||||||
|
|
||||||
if (0 == targetstate)
|
|
||||||
targetstate = state;
|
|
||||||
else
|
|
||||||
add_state(targetstate);
|
|
||||||
return rules_.add(state, detail::escape(tokendef), token_id, targetstate);
|
|
||||||
}
|
|
||||||
std::size_t add_token(char_type const* state, string_type const& tokendef,
|
|
||||||
std::size_t token_id, char_type const* targetstate)
|
|
||||||
{
|
|
||||||
add_state(state);
|
|
||||||
initialized_dfa_ = false;
|
|
||||||
if (state == all_states())
|
|
||||||
return rules_.add(state, tokendef, token_id, rules_.dot());
|
|
||||||
|
|
||||||
if (0 == targetstate)
|
|
||||||
targetstate = state;
|
|
||||||
else
|
|
||||||
add_state(targetstate);
|
|
||||||
return rules_.add(state, tokendef, token_id, targetstate);
|
|
||||||
}
|
|
||||||
|
|
||||||
// interface for pattern definition management
|
|
||||||
void add_pattern (char_type const* state, string_type const& name,
|
|
||||||
string_type const& patterndef)
|
|
||||||
{
|
|
||||||
add_state(state);
|
|
||||||
rules_.add_macro(name.c_str(), patterndef);
|
|
||||||
initialized_dfa_ = false;
|
initialized_dfa_ = false;
|
||||||
}
|
}
|
||||||
|
return stateid;
|
||||||
|
}
|
||||||
|
string_type initial_state() const { return string_type(rules_.initial()); }
|
||||||
|
string_type all_states() const { return string_type(rules_.all_states()); }
|
||||||
|
|
||||||
boost::lexer::rules const& get_rules() const { return rules_; }
|
// Register a semantic action with the given id
|
||||||
|
template <typename F>
|
||||||
void clear(char_type const* state)
|
void add_action(std::size_t unique_id, std::size_t state, F act) {
|
||||||
{
|
// If you see an error here stating add_action is not a member of
|
||||||
std::size_t s = rules_.state(state);
|
// fusion::unused_type then you are probably having semantic actions
|
||||||
if (boost::lexer::npos != s)
|
// attached to at least one token in the lexer definition without
|
||||||
rules_.clear(state);
|
// using the lex::lexertl::actor_lexer<> as its base class.
|
||||||
initialized_dfa_ = false;
|
typedef typename Functor::wrap_action_type wrapper_type;
|
||||||
}
|
if (state == all_states_id) {
|
||||||
std::size_t add_state(char_type const* state)
|
// add the action to all known states
|
||||||
{
|
typedef typename basic_rules_type::string_size_t_map::value_type
|
||||||
if (state == all_states())
|
|
||||||
return all_states_id;
|
|
||||||
|
|
||||||
std::size_t stateid = rules_.state(state);
|
|
||||||
if (boost::lexer::npos == stateid) {
|
|
||||||
stateid = rules_.add_state(state);
|
|
||||||
initialized_dfa_ = false;
|
|
||||||
}
|
|
||||||
return stateid;
|
|
||||||
}
|
|
||||||
string_type initial_state() const
|
|
||||||
{
|
|
||||||
return string_type(rules_.initial());
|
|
||||||
}
|
|
||||||
string_type all_states() const
|
|
||||||
{
|
|
||||||
return string_type(rules_.all_states());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register a semantic action with the given id
|
|
||||||
template <typename F>
|
|
||||||
void add_action(std::size_t unique_id, std::size_t state, F act)
|
|
||||||
{
|
|
||||||
// If you see an error here stating add_action is not a member of
|
|
||||||
// fusion::unused_type then you are probably having semantic actions
|
|
||||||
// attached to at least one token in the lexer definition without
|
|
||||||
// using the lex::lexertl::actor_lexer<> as its base class.
|
|
||||||
typedef typename Functor::wrap_action_type wrapper_type;
|
|
||||||
if (state == all_states_id) {
|
|
||||||
// add the action to all known states
|
|
||||||
typedef typename
|
|
||||||
basic_rules_type::string_size_t_map::value_type
|
|
||||||
state_type;
|
state_type;
|
||||||
|
|
||||||
std::size_t states = rules_.statemap().size();
|
std::size_t states = rules_.statemap().size();
|
||||||
BOOST_FOREACH(state_type const& s, rules_.statemap()) {
|
BOOST_FOREACH (state_type const& s, rules_.statemap()) {
|
||||||
for (std::size_t j = 0; j < states; ++j)
|
for (std::size_t j = 0; j < states; ++j)
|
||||||
actions_.add_action(unique_id + j, s.second, wrapper_type::call(act));
|
actions_.add_action(unique_id + j, s.second,
|
||||||
}
|
wrapper_type::call(act));
|
||||||
}
|
|
||||||
else {
|
|
||||||
actions_.add_action(unique_id, state, wrapper_type::call(act));
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
actions_.add_action(unique_id, state, wrapper_type::call(act));
|
||||||
}
|
}
|
||||||
// template <typename F>
|
}
|
||||||
// void add_action(std::size_t unique_id, char_type const* state, F act)
|
// template <typename F>
|
||||||
// {
|
// void add_action(std::size_t unique_id, char_type const* state, F
|
||||||
// typedef typename Functor::wrap_action_type wrapper_type;
|
// act)
|
||||||
// actions_.add_action(unique_id, add_state(state), wrapper_type::call(act));
|
// {
|
||||||
// }
|
// typedef typename Functor::wrap_action_type wrapper_type;
|
||||||
|
// actions_.add_action(unique_id, add_state(state),
|
||||||
|
// wrapper_type::call(act));
|
||||||
|
// }
|
||||||
|
|
||||||
// We do not minimize the state machine by default anymore because
|
// We do not minimize the state machine by default anymore because
|
||||||
// Ben said: "If you can afford to generate a lexer at runtime, there
|
// Ben said: "If you can afford to generate a lexer at runtime, there
|
||||||
// is little point in calling minimise."
|
// is little point in calling minimise."
|
||||||
// Go figure.
|
// Go figure.
|
||||||
bool init_dfa(bool minimize = false) const
|
bool init_dfa(bool minimize = false) const {
|
||||||
{
|
if (!initialized_dfa_) {
|
||||||
if (!initialized_dfa_) {
|
state_machine_.clear();
|
||||||
state_machine_.clear();
|
typedef boost::lexer::basic_generator<char_type> generator;
|
||||||
typedef boost::lexer::basic_generator<char_type> generator;
|
generator::build(rules_, state_machine_);
|
||||||
generator::build (rules_, state_machine_);
|
if (minimize) generator::minimise(state_machine_);
|
||||||
if (minimize)
|
|
||||||
generator::minimise (state_machine_);
|
|
||||||
|
|
||||||
#if defined(BOOST_SPIRIT_LEXERTL_DEBUG)
|
#if defined(BOOST_SPIRIT_LEXERTL_DEBUG)
|
||||||
boost::lexer::debug::dump(state_machine_, std::cerr);
|
boost::lexer::debug::dump(state_machine_, std::cerr);
|
||||||
#endif
|
#endif
|
||||||
initialized_dfa_ = true;
|
initialized_dfa_ = true;
|
||||||
|
|
||||||
// // release memory held by rules description
|
// // release memory held by rules description
|
||||||
// basic_rules_type rules;
|
// basic_rules_type rules;
|
||||||
// rules.init_state_info(rules_); // preserve states
|
// rules.init_state_info(rules_); // preserve
|
||||||
// std::swap(rules, rules_);
|
// states std::swap(rules, rules_);
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// lexertl specific data
|
// lexertl specific data
|
||||||
mutable boost::lexer::basic_state_machine<char_type> state_machine_;
|
mutable boost::lexer::basic_state_machine<char_type> state_machine_;
|
||||||
boost::lexer::regex_flags flags_;
|
boost::lexer::regex_flags flags_;
|
||||||
/*mutable*/ basic_rules_type rules_;
|
/*mutable*/ basic_rules_type rules_;
|
||||||
|
|
||||||
typename Functor::semantic_actions_type actions_;
|
typename Functor::semantic_actions_type actions_;
|
||||||
mutable bool initialized_dfa_;
|
mutable bool initialized_dfa_;
|
||||||
|
|
||||||
// generator functions must be able to access members directly
|
// generator functions must be able to access members directly
|
||||||
template <typename Lexer, typename F>
|
template <typename Lexer, typename F>
|
||||||
friend bool generate_static(Lexer const&
|
friend bool generate_static(Lexer const&,
|
||||||
, std::basic_ostream<typename Lexer::char_type>&
|
std::basic_ostream<typename Lexer::char_type>&,
|
||||||
, typename Lexer::char_type const*, F);
|
typename Lexer::char_type const*, F);
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// The actor_lexer class is another implementation of a Spirit.Lex
|
// The actor_lexer class is another implementation of a Spirit.Lex
|
||||||
// lexer on top of Ben Hanson's lexertl library as outlined above (For
|
// lexer on top of Ben Hanson's lexertl library as outlined above (For
|
||||||
// more information about lexertl go here:
|
// more information about lexertl go here:
|
||||||
// http://www.benhanson.net/lexertl.html).
|
// http://www.benhanson.net/lexertl.html).
|
||||||
//
|
//
|
||||||
// The only difference to the lexer class above is that token_def
|
// The only difference to the lexer class above is that token_def
|
||||||
// definitions may have semantic (lexer) actions attached while being
|
// definitions may have semantic (lexer) actions attached while being
|
||||||
// defined:
|
// defined:
|
||||||
//
|
//
|
||||||
// int w;
|
// int w;
|
||||||
// token_def word = "[^ \t\n]+";
|
// token_def word = "[^ \t\n]+";
|
||||||
// self = word[++ref(w)]; // see example: word_count_lexer
|
// self = word[++ref(w)]; // see example: word_count_lexer
|
||||||
//
|
//
|
||||||
// This class is supposed to be used as the first and only template
|
// This class is supposed to be used as the first and only template
|
||||||
// parameter while instantiating instances of a lex::lexer class.
|
// parameter while instantiating instances of a lex::lexer class.
|
||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
template <typename Token = token<>
|
template <typename Token = token<>,
|
||||||
, typename Iterator = typename Token::iterator_type
|
typename Iterator = typename Token::iterator_type,
|
||||||
, typename Functor = functor<Token, lexertl::detail::data, Iterator, mpl::true_> >
|
typename Functor =
|
||||||
class actor_lexer : public lexer<Token, Iterator, Functor>
|
functor<Token, lexertl::detail::data, Iterator, mpl::true_> >
|
||||||
{
|
class actor_lexer : public lexer<Token, Iterator, Functor> {
|
||||||
protected:
|
protected:
|
||||||
// Lexer instances can be created by means of a derived class only.
|
// Lexer instances can be created by means of a derived class only.
|
||||||
actor_lexer(unsigned int flags)
|
actor_lexer(unsigned int flags) : lexer<Token, Iterator, Functor>(flags) {}
|
||||||
: lexer<Token, Iterator, Functor>(flags) {}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
}}}}
|
} // namespace lexertl
|
||||||
|
} // namespace lex
|
||||||
|
} // namespace spirit
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1211,7 +1211,6 @@ int main() {
|
||||||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||||
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
Vec3::CreateNewThreadStorage();
|
|
||||||
OldChunkStorage::CreateNewThreadStorage();
|
OldChunkStorage::CreateNewThreadStorage();
|
||||||
Level::enableLightingCache();
|
Level::enableLightingCache();
|
||||||
Tile::CreateNewThreadStorage();
|
Tile::CreateNewThreadStorage();
|
||||||
|
|
@ -1547,7 +1546,6 @@ int main() {
|
||||||
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
||||||
// menu A memory leak was caused because the icon renderer kept creating
|
// menu A memory leak was caused because the icon renderer kept creating
|
||||||
// new Vec3's because the pool wasn't reset
|
// new Vec3's because the pool wasn't reset
|
||||||
Vec3::resetPool();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free resources, unregister custom classes, and exit.
|
// Free resources, unregister custom classes, and exit.
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -96,34 +96,26 @@ TileData_SPU* Tile_SPU::ms_pTileData = NULL;
|
||||||
|
|
||||||
Tile_SPU Tile_SPU::m_tiles[256];
|
Tile_SPU Tile_SPU::m_tiles[256];
|
||||||
|
|
||||||
|
int Tile_SPU::getRenderShape() { return SHAPE_BLOCK; }
|
||||||
|
|
||||||
|
void Tile_SPU::setShape(float x0, float y0, float z0, float x1, float y1,
|
||||||
int Tile_SPU::getRenderShape()
|
float z1) {
|
||||||
{
|
ms_pTileData->xx0[id] = x0;
|
||||||
return SHAPE_BLOCK;
|
ms_pTileData->yy0[id] = y0;
|
||||||
|
ms_pTileData->zz0[id] = z0;
|
||||||
|
ms_pTileData->xx1[id] = x1;
|
||||||
|
ms_pTileData->yy1[id] = y1;
|
||||||
|
ms_pTileData->zz1[id] = z1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Tile_SPU::getBrightness(ChunkRebuildData* level, int x, int y, int z) {
|
||||||
void Tile_SPU::setShape(float x0, float y0, float z0, float x1, float y1, float z1)
|
return level->getBrightness(x, y, z, ms_pTileData->lightEmission[id]);
|
||||||
{
|
|
||||||
ms_pTileData->xx0[id] = x0;
|
|
||||||
ms_pTileData->yy0[id] = y0;
|
|
||||||
ms_pTileData->zz0[id] = z0;
|
|
||||||
ms_pTileData->xx1[id] = x1;
|
|
||||||
ms_pTileData->yy1[id] = y1;
|
|
||||||
ms_pTileData->zz1[id] = z1;
|
|
||||||
}
|
|
||||||
|
|
||||||
float Tile_SPU::getBrightness(ChunkRebuildData *level, int x, int y, int z)
|
|
||||||
{
|
|
||||||
return level->getBrightness(x, y, z, ms_pTileData->lightEmission[id]);
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// // 4J - brought forward from 1.8.2
|
// // 4J - brought forward from 1.8.2
|
||||||
int Tile_SPU::getLightColor(ChunkRebuildData *level, int x, int y, int z)
|
int Tile_SPU::getLightColor(ChunkRebuildData* level, int x, int y, int z) {
|
||||||
{
|
int tileID = level->getTile(x, y, z);
|
||||||
int tileID = level->getTile(x, y, z);
|
return level->getLightColor(x, y, z, ms_pTileData->lightEmission[tileID]);
|
||||||
return level->getLightColor(x, y, z, ms_pTileData->lightEmission[tileID]);
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// bool Tile_SPU::isFaceVisible(Level *level, int x, int y, int z, int f)
|
// bool Tile_SPU::isFaceVisible(Level *level, int x, int y, int z, int f)
|
||||||
|
|
@ -137,88 +129,88 @@ int Tile_SPU::getLightColor(ChunkRebuildData *level, int x, int y, int z)
|
||||||
// return !level->isSolidRenderTile(x, y, z);
|
// return !level->isSolidRenderTile(x, y, z);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
bool Tile_SPU::shouldRenderFace(ChunkRebuildData *level, int x, int y, int z, int face)
|
bool Tile_SPU::shouldRenderFace(ChunkRebuildData* level, int x, int y, int z,
|
||||||
{
|
int face) {
|
||||||
if (face == 0 && getShapeY0() > 0) return true;
|
if (face == 0 && getShapeY0() > 0) return true;
|
||||||
if (face == 1 && getShapeY1() < 1) return true;
|
if (face == 1 && getShapeY1() < 1) return true;
|
||||||
if (face == 2 && getShapeZ0() > 0) return true;
|
if (face == 2 && getShapeZ0() > 0) return true;
|
||||||
if (face == 3 && getShapeZ1() < 1) return true;
|
if (face == 3 && getShapeZ1() < 1) return true;
|
||||||
if (face == 4 && getShapeX0() > 0) return true;
|
if (face == 4 && getShapeX0() > 0) return true;
|
||||||
if (face == 5 && getShapeX1() < 1) return true;
|
if (face == 5 && getShapeX1() < 1) return true;
|
||||||
return (!level->isSolidRenderTile(x, y, z));
|
return (!level->isSolidRenderTile(x, y, z));
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
bool Tile_SPU::isSolidFace(ChunkRebuildData *level, int x, int y, int z, int face)
|
bool Tile_SPU::isSolidFace(ChunkRebuildData* level, int x, int y, int z,
|
||||||
{
|
int face) {
|
||||||
return (level->getMaterial(x, y, z)->isSolid());
|
return (level->getMaterial(x, y, z)->isSolid());
|
||||||
}
|
}
|
||||||
|
|
||||||
Icon_SPU *Tile_SPU::getTexture(ChunkRebuildData *level, int x, int y, int z, int face)
|
Icon_SPU* Tile_SPU::getTexture(ChunkRebuildData* level, int x, int y, int z,
|
||||||
{
|
int face) {
|
||||||
// 4J - addition here to make rendering big blocks of leaves more efficient. Normally leaves never consider themselves as solid, so
|
// 4J - addition here to make rendering big blocks of leaves more efficient.
|
||||||
// blocks of leaves will have all sides of each block completely visible. Changing to consider as solid if this block is surrounded by
|
// Normally leaves never consider themselves as solid, so blocks of leaves
|
||||||
// other leaves. This is paired with another change in Level::isSolidRenderTile/Region::isSolidRenderTile which makes things solid
|
// will have all sides of each block completely visible. Changing to
|
||||||
// code-wise (ie for determining visible sides of neighbouring blocks). This change just makes the texture a solid one (tex + 1) which
|
// consider as solid if this block is surrounded by other leaves. This is
|
||||||
// we already have in the texture map for doing non-fancy graphics. Note: this tile-specific code is here rather than making some new virtual
|
// paired with another change in
|
||||||
// method in the tiles, for the sake of efficiency - I don't imagine we'll be doing much more of this sort of thing
|
// Level::isSolidRenderTile/Region::isSolidRenderTile which makes things
|
||||||
|
// solid code-wise (ie for determining visible sides of neighbouring
|
||||||
|
// blocks). This change just makes the texture a solid one (tex + 1) which
|
||||||
|
// we already have in the texture map for doing non-fancy graphics. Note:
|
||||||
|
// this tile-specific code is here rather than making some new virtual
|
||||||
|
// method in the tiles, for the sake of efficiency - I don't imagine we'll
|
||||||
|
// be doing much more of this sort of thing
|
||||||
|
|
||||||
int tileId = level->getTile(x, y, z);
|
int tileId = level->getTile(x, y, z);
|
||||||
int tileData = level->getData(x, y, z);
|
int tileData = level->getData(x, y, z);
|
||||||
|
|
||||||
if( tileId == Tile_SPU::leaves_Id )
|
if (tileId == Tile_SPU::leaves_Id) {
|
||||||
{
|
bool opaque = true;
|
||||||
bool opaque = true;
|
int axo[6] = {1, -1, 0, 0, 0, 0};
|
||||||
int axo[6] = { 1,-1, 0, 0, 0, 0};
|
int ayo[6] = {0, 0, 1, -1, 0, 0};
|
||||||
int ayo[6] = { 0, 0, 1,-1, 0, 0};
|
int azo[6] = {0, 0, 0, 0, 1, -1};
|
||||||
int azo[6] = { 0, 0, 0, 0, 1,-1};
|
for (int i = 0; (i < 6) && opaque; i++) {
|
||||||
for( int i = 0; (i < 6) && opaque; i++ )
|
int t = level->getTile(x + axo[i], y + ayo[i], z + azo[i]);
|
||||||
{
|
if ((t != Tile_SPU::leaves_Id) &&
|
||||||
int t = level->getTile(x + axo[i], y + ayo[i] , z + azo[i]);
|
((Tile_SPU::m_tiles[t].id == -1) ||
|
||||||
if( ( t != Tile_SPU::leaves_Id ) && ( ( Tile_SPU::m_tiles[t].id == -1) || !Tile_SPU::m_tiles[t].isSolidRender() ) )
|
!Tile_SPU::m_tiles[t].isSolidRender())) {
|
||||||
{
|
opaque = false;
|
||||||
opaque = false;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
Icon_SPU* icon = NULL;
|
||||||
Icon_SPU *icon = NULL;
|
if (opaque) {
|
||||||
if(opaque)
|
LeafTile_SPU::setFancy(false);
|
||||||
{
|
icon = getTexture(face, tileData);
|
||||||
LeafTile_SPU::setFancy(false);
|
LeafTile_SPU::setFancy(true);
|
||||||
icon = getTexture(face, tileData);
|
} else {
|
||||||
LeafTile_SPU::setFancy(true);
|
icon = getTexture(face, tileData);
|
||||||
}
|
}
|
||||||
else
|
return icon;
|
||||||
{
|
}
|
||||||
icon = getTexture(face, tileData);
|
return getTexture(face, tileData);
|
||||||
}
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
return getTexture(face, tileData);
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
Icon_SPU *Tile_SPU::getTexture(int face, int data)
|
Icon_SPU* Tile_SPU::getTexture(int face, int data) {
|
||||||
{
|
return &ms_pTileData->iconData[id];
|
||||||
return &ms_pTileData->iconData[id];
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
Icon_SPU *Tile_SPU::getTexture(int face)
|
Icon_SPU* Tile_SPU::getTexture(int face) { return getTexture(face, 0); }
|
||||||
{
|
|
||||||
return getTexture(face, 0);
|
|
||||||
}
|
|
||||||
//
|
//
|
||||||
// AABB *Tile_SPU::getTileAABB(Level *level, int x, int y, int z)
|
// AABB *Tile_SPU::getTileAABB(Level *level, int x, int y, int z)
|
||||||
// {
|
// {
|
||||||
// return AABB::newTemp(x + xx0, y + yy0, z + zz0, x + xx1, y + yy1, z + zz1);
|
// return AABB::newTemp(x + xx0, y + yy0, z + zz0, x + xx1, y + yy1, z +
|
||||||
|
// zz1);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// void Tile_SPU::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes, Entity *source)
|
// void Tile_SPU::addAABBs(Level *level, int x, int y, int z, AABB *box,
|
||||||
|
// AABBList *boxes, Entity *source)
|
||||||
// {
|
// {
|
||||||
// AABB *aabb = getAABB(level, x, y, z);
|
// AABB *aabb = getAABB(level, x, y, z);
|
||||||
// if (aabb != NULL && box->intersects(aabb)) boxes->push_back(aabb);
|
// if (aabb != NULL && box->intersects(aabb)) boxes->push_back(aabb);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// void Tile_SPU::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes)
|
// void Tile_SPU::addAABBs(Level *level, int x, int y, int z, AABB *box,
|
||||||
|
// AABBList *boxes)
|
||||||
// {
|
// {
|
||||||
// AABB *aabb = getAABB(level, x, y, z);
|
// AABB *aabb = getAABB(level, x, y, z);
|
||||||
// if (aabb != NULL && box->intersects(aabb)) boxes->push_back(aabb);
|
// if (aabb != NULL && box->intersects(aabb)) boxes->push_back(aabb);
|
||||||
|
|
@ -226,14 +218,11 @@ Icon_SPU *Tile_SPU::getTexture(int face)
|
||||||
//
|
//
|
||||||
// AABB *Tile_SPU::getAABB(Level *level, int x, int y, int z)
|
// AABB *Tile_SPU::getAABB(Level *level, int x, int y, int z)
|
||||||
// {
|
// {
|
||||||
// return AABB::newTemp(x + xx0, y + yy0, z + zz0, x + xx1, y + yy1, z + zz1);
|
// return AABB::newTemp(x + xx0, y + yy0, z + zz0, x + xx1, y + yy1, z +
|
||||||
|
// zz1);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
bool Tile_SPU::isSolidRender(bool isServerLevel)
|
bool Tile_SPU::isSolidRender(bool isServerLevel) { return true; }
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// bool Tile_SPU::mayPick(int data, bool liquid)
|
// bool Tile_SPU::mayPick(int data, bool liquid)
|
||||||
// {
|
// {
|
||||||
|
|
@ -295,26 +284,30 @@ Icon_SPU *Tile_SPU::getTexture(int face)
|
||||||
// return (player->getDestroySpeed(this) / destroySpeed) / 30;
|
// return (player->getDestroySpeed(this) / destroySpeed) / 30;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// void Tile_SPU::spawnResources(Level *level, int x, int y, int z, int data, int playerBonusLevel)
|
// void Tile_SPU::spawnResources(Level *level, int x, int y, int z, int data,
|
||||||
|
// int playerBonusLevel)
|
||||||
// {
|
// {
|
||||||
// spawnResources(level, x, y, z, data, 1, playerBonusLevel);
|
// spawnResources(level, x, y, z, data, 1, playerBonusLevel);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// void Tile_SPU::spawnResources(Level *level, int x, int y, int z, int data, float odds, int playerBonusLevel)
|
// void Tile_SPU::spawnResources(Level *level, int x, int y, int z, int data,
|
||||||
|
// float odds, int playerBonusLevel)
|
||||||
// {
|
// {
|
||||||
// if (level->isClientSide) return;
|
// if (level->isClientSide) return;
|
||||||
// int count = getResourceCountForLootBonus(playerBonusLevel, level->random);
|
// int count = getResourceCountForLootBonus(playerBonusLevel,
|
||||||
// for (int i = 0; i < count; i++)
|
// level->random); for (int i = 0; i < count; i++)
|
||||||
// {
|
// {
|
||||||
// if (level->random->nextFloat() > odds) continue;
|
// if (level->random->nextFloat() > odds) continue;
|
||||||
// int type = getResource(data, level->random, playerBonusLevel);
|
// int type = getResource(data, level->random, playerBonusLevel);
|
||||||
// if (type <= 0) continue;
|
// if (type <= 0) continue;
|
||||||
//
|
//
|
||||||
// popResource(level, x, y, z, std::shared_ptr<ItemInstance>( new ItemInstance(type, 1, getSpawnResourcesAuxValue(data) ) ) );
|
// popResource(level, x, y, z, std::shared_ptr<ItemInstance>( new
|
||||||
|
// ItemInstance(type, 1, getSpawnResourcesAuxValue(data) ) ) );
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// void Tile_SPU::popResource(Level *level, int x, int y, int z, std::shared_ptr<ItemInstance> itemInstance)
|
// void Tile_SPU::popResource(Level *level, int x, int y, int z,
|
||||||
|
// std::shared_ptr<ItemInstance> itemInstance)
|
||||||
// {
|
// {
|
||||||
// if( level->isClientSide ) return;
|
// if( level->isClientSide ) return;
|
||||||
//
|
//
|
||||||
|
|
@ -322,9 +315,9 @@ Icon_SPU *Tile_SPU::getTexture(int face)
|
||||||
// double xo = level->random->nextFloat() * s + (1 - s) * 0.5;
|
// double xo = level->random->nextFloat() * s + (1 - s) * 0.5;
|
||||||
// double yo = level->random->nextFloat() * s + (1 - s) * 0.5;
|
// double yo = level->random->nextFloat() * s + (1 - s) * 0.5;
|
||||||
// double zo = level->random->nextFloat() * s + (1 - s) * 0.5;
|
// double zo = level->random->nextFloat() * s + (1 - s) * 0.5;
|
||||||
// std::shared_ptr<ItemEntity> item = std::shared_ptr<ItemEntity>( new ItemEntity(level, x + xo, y + yo, z + zo, itemInstance ) );
|
// std::shared_ptr<ItemEntity> item = std::shared_ptr<ItemEntity>( new
|
||||||
// item->throwTime = 10;
|
// ItemEntity(level, x + xo, y + yo, z + zo, itemInstance ) ); item->throwTime
|
||||||
// level->addEntity(item);
|
// = 10; level->addEntity(item);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// // Brought forward for TU7
|
// // Brought forward for TU7
|
||||||
|
|
@ -334,9 +327,10 @@ Icon_SPU *Tile_SPU::getTexture(int face)
|
||||||
// {
|
// {
|
||||||
// while (amount > 0)
|
// while (amount > 0)
|
||||||
// {
|
// {
|
||||||
// int newCount = ExperienceOrb::getExperienceValue(amount);
|
// int newCount =
|
||||||
// amount -= newCount;
|
// ExperienceOrb::getExperienceValue(amount); amount -=
|
||||||
// level->addEntity(std::shared_ptr<ExperienceOrb>( new ExperienceOrb(level, x + .5, y + .5, z + .5, newCount)));
|
// newCount; level->addEntity(std::shared_ptr<ExperienceOrb>( new
|
||||||
|
// ExperienceOrb(level, x + .5, y + .5, z + .5, newCount)));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
@ -351,7 +345,8 @@ Icon_SPU *Tile_SPU::getTexture(int face)
|
||||||
// return explosionResistance / 5.0f;
|
// return explosionResistance / 5.0f;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// HitResult *Tile_SPU::clip(Level *level, int xt, int yt, int zt, Vec3 *a, Vec3 *b)
|
// HitResult *Tile_SPU::clip(Level *level, int xt, int yt, int zt, Vec3 *a, Vec3
|
||||||
|
// *b)
|
||||||
// {
|
// {
|
||||||
// EnterCriticalSection(&m_csShape);
|
// EnterCriticalSection(&m_csShape);
|
||||||
// updateShape(level, xt, yt, zt);
|
// updateShape(level, xt, yt, zt);
|
||||||
|
|
@ -370,12 +365,15 @@ Icon_SPU *Tile_SPU::getTexture(int face)
|
||||||
//
|
//
|
||||||
// Vec3 *closest = NULL;
|
// Vec3 *closest = NULL;
|
||||||
//
|
//
|
||||||
// if (containsX(xh0) && (closest == NULL || a->distanceTo(xh0) < a->distanceTo(closest))) closest = xh0;
|
// if (containsX(xh0) && (closest == NULL || a->distanceTo(xh0) <
|
||||||
// if (containsX(xh1) && (closest == NULL || a->distanceTo(xh1) < a->distanceTo(closest))) closest = xh1;
|
// a->distanceTo(closest))) closest = xh0; if (containsX(xh1) && (closest
|
||||||
// if (containsY(yh0) && (closest == NULL || a->distanceTo(yh0) < a->distanceTo(closest))) closest = yh0;
|
// == NULL || a->distanceTo(xh1) < a->distanceTo(closest))) closest = xh1;
|
||||||
// if (containsY(yh1) && (closest == NULL || a->distanceTo(yh1) < a->distanceTo(closest))) closest = yh1;
|
// if (containsY(yh0) && (closest == NULL || a->distanceTo(yh0) <
|
||||||
// if (containsZ(zh0) && (closest == NULL || a->distanceTo(zh0) < a->distanceTo(closest))) closest = zh0;
|
// a->distanceTo(closest))) closest = yh0; if (containsY(yh1) && (closest
|
||||||
// if (containsZ(zh1) && (closest == NULL || a->distanceTo(zh1) < a->distanceTo(closest))) closest = zh1;
|
// == NULL || a->distanceTo(yh1) < a->distanceTo(closest))) closest = yh1;
|
||||||
|
// if (containsZ(zh0) && (closest == NULL || a->distanceTo(zh0) <
|
||||||
|
// a->distanceTo(closest))) closest = zh0; if (containsZ(zh1) && (closest
|
||||||
|
// == NULL || a->distanceTo(zh1) < a->distanceTo(closest))) closest = zh1;
|
||||||
//
|
//
|
||||||
// LeaveCriticalSection(&m_csShape);
|
// LeaveCriticalSection(&m_csShape);
|
||||||
//
|
//
|
||||||
|
|
@ -415,10 +413,7 @@ Icon_SPU *Tile_SPU::getTexture(int face)
|
||||||
// {
|
// {
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
int Tile_SPU::getRenderLayer()
|
int Tile_SPU::getRenderLayer() { return 0; }
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
//
|
//
|
||||||
// bool Tile_SPU::mayPlace(Level *level, int x, int y, int z, int face)
|
// bool Tile_SPU::mayPlace(Level *level, int x, int y, int z, int face)
|
||||||
// {
|
// {
|
||||||
|
|
@ -437,17 +432,21 @@ int Tile_SPU::getRenderLayer()
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// bool Tile_SPU::TestUse(Level *level, int x, int y, int z, std::shared_ptr<Player> player)
|
// bool Tile_SPU::TestUse(Level *level, int x, int y, int z,
|
||||||
|
// std::shared_ptr<Player> player)
|
||||||
// {
|
// {
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// bool Tile_SPU::use(Level *level, int x, int y, int z, std::shared_ptr<Player> player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly/*=false*/) // 4J added soundOnly param
|
// bool Tile_SPU::use(Level *level, int x, int y, int z, std::shared_ptr<Player>
|
||||||
|
// player, int clickedFace, float clickX, float clickY, float clickZ, bool
|
||||||
|
// soundOnly/*=false*/) // 4J added soundOnly param
|
||||||
// {
|
// {
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// void Tile_SPU::stepOn(Level *level, int x, int y, int z, std::shared_ptr<Entity> entity)
|
// void Tile_SPU::stepOn(Level *level, int x, int y, int z,
|
||||||
|
// std::shared_ptr<Entity> entity)
|
||||||
// {
|
// {
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
|
@ -459,22 +458,24 @@ int Tile_SPU::getRenderLayer()
|
||||||
// {
|
// {
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// void Tile_SPU::attack(Level *level, int x, int y, int z, std::shared_ptr<Player> player)
|
// void Tile_SPU::attack(Level *level, int x, int y, int z,
|
||||||
|
// std::shared_ptr<Player> player)
|
||||||
// {
|
// {
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// void Tile_SPU::handleEntityInside(Level *level, int x, int y, int z, std::shared_ptr<Entity> e, Vec3 *current)
|
// void Tile_SPU::handleEntityInside(Level *level, int x, int y, int z,
|
||||||
|
// std::shared_ptr<Entity> e, Vec3 *current)
|
||||||
// {
|
// {
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
void Tile_SPU::updateShape(ChunkRebuildData *level, int x, int y, int z, int forceData, TileEntity* forceEntity) // 4J added forceData, forceEntity param
|
void Tile_SPU::updateShape(
|
||||||
{
|
ChunkRebuildData* level, int x, int y, int z, int forceData,
|
||||||
}
|
TileEntity* forceEntity) // 4J added forceData, forceEntity param
|
||||||
|
{}
|
||||||
//
|
//
|
||||||
|
|
||||||
int Tile_SPU::getColor(ChunkRebuildData *level, int x, int y, int z)
|
int Tile_SPU::getColor(ChunkRebuildData* level, int x, int y, int z) {
|
||||||
{
|
return 0xffffff;
|
||||||
return 0xffffff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -498,7 +499,8 @@ int Tile_SPU::getColor(ChunkRebuildData *level, int x, int y, int z)
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// void Tile_SPU::entityInside(Level *level, int x, int y, int z, std::shared_ptr<Entity> entity)
|
// void Tile_SPU::entityInside(Level *level, int x, int y, int z,
|
||||||
|
// std::shared_ptr<Entity> entity)
|
||||||
// {
|
// {
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
|
@ -507,11 +509,10 @@ int Tile_SPU::getColor(ChunkRebuildData *level, int x, int y, int z)
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
void Tile_SPU::updateDefaultShape()
|
void Tile_SPU::updateDefaultShape() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
//
|
//
|
||||||
// void Tile_SPU::playerDestroy(Level *level, std::shared_ptr<Player> player, int x, int y, int z, int data)
|
// void Tile_SPU::playerDestroy(Level *level, std::shared_ptr<Player> player,
|
||||||
|
// int x, int y, int z, int data)
|
||||||
// {
|
// {
|
||||||
// // 4J Stu - Special case - only record a crop destroy if is fully grown
|
// // 4J Stu - Special case - only record a crop destroy if is fully grown
|
||||||
// if(id==Tile_SPU::crops_Id)
|
// if(id==Tile_SPU::crops_Id)
|
||||||
|
|
@ -523,14 +524,16 @@ void Tile_SPU::updateDefaultShape()
|
||||||
// {
|
// {
|
||||||
// player->awardStat(Stats::blocksMined[id], 1);
|
// player->awardStat(Stats::blocksMined[id], 1);
|
||||||
// }
|
// }
|
||||||
// player->awardStat(Stats::totalBlocksMined, 1); // 4J : WESTY : Added for other award.
|
// player->awardStat(Stats::totalBlocksMined, 1); // 4J : WESTY : Added
|
||||||
// player->causeFoodExhaustion(FoodConstants::EXHAUSTION_MINE);
|
// for other award.
|
||||||
|
// player->causeFoodExhaustion(FoodConstants::EXHAUSTION_MINE);
|
||||||
//
|
//
|
||||||
// if( id == Tile_SPU::treeTrunk_Id )
|
// if( id == Tile_SPU::treeTrunk_Id )
|
||||||
// player->awardStat(Achievements::mineWood);
|
// player->awardStat(Achievements::mineWood);
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// if (isCubeShaped() && !isEntityTile[id] && EnchantmentHelper::hasSilkTouch(player->inventory))
|
// if (isCubeShaped() && !isEntityTile[id] &&
|
||||||
|
// EnchantmentHelper::hasSilkTouch(player->inventory))
|
||||||
// {
|
// {
|
||||||
// std::shared_ptr<ItemInstance> item = getSilkTouchItemInstance(data);
|
// std::shared_ptr<ItemInstance> item = getSilkTouchItemInstance(data);
|
||||||
// if (item != NULL)
|
// if (item != NULL)
|
||||||
|
|
@ -540,7 +543,8 @@ void Tile_SPU::updateDefaultShape()
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
// int playerBonusLevel = EnchantmentHelper::getDiggingLootBonus(player->inventory);
|
// int playerBonusLevel =
|
||||||
|
// EnchantmentHelper::getDiggingLootBonus(player->inventory);
|
||||||
// spawnResources(level, x, y, z, data, playerBonusLevel);
|
// spawnResources(level, x, y, z, data, playerBonusLevel);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
@ -548,7 +552,8 @@ void Tile_SPU::updateDefaultShape()
|
||||||
// std::shared_ptr<ItemInstance> Tile_SPU::getSilkTouchItemInstance(int data)
|
// std::shared_ptr<ItemInstance> Tile_SPU::getSilkTouchItemInstance(int data)
|
||||||
// {
|
// {
|
||||||
// int popData = 0;
|
// int popData = 0;
|
||||||
// if (id >= 0 && id < Item::items.length && Item::items[id]->isStackedByData())
|
// if (id >= 0 && id < Item::items.length &&
|
||||||
|
// Item::items[id]->isStackedByData())
|
||||||
// {
|
// {
|
||||||
// popData = data;
|
// popData = data;
|
||||||
// }
|
// }
|
||||||
|
|
@ -565,7 +570,8 @@ void Tile_SPU::updateDefaultShape()
|
||||||
// return true;
|
// return true;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// void Tile_SPU::setPlacedBy(Level *level, int x, int y, int z, std::shared_ptr<Mob> by)
|
// void Tile_SPU::setPlacedBy(Level *level, int x, int y, int z,
|
||||||
|
// std::shared_ptr<Mob> by)
|
||||||
// {
|
// {
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
|
@ -596,7 +602,8 @@ void Tile_SPU::updateDefaultShape()
|
||||||
// return useDescriptionId;
|
// return useDescriptionId;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// void Tile_SPU::triggerEvent(Level *level, int x, int y, int z, int b0, int b1)
|
// void Tile_SPU::triggerEvent(Level *level, int x, int y, int z, int b0, int
|
||||||
|
// b1)
|
||||||
// {
|
// {
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
|
@ -617,36 +624,32 @@ void Tile_SPU::updateDefaultShape()
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// // 4J - brought forward from 1.8.2
|
// // 4J - brought forward from 1.8.2
|
||||||
float Tile_SPU::getShadeBrightness(ChunkRebuildData *level, int x, int y, int z)
|
float Tile_SPU::getShadeBrightness(ChunkRebuildData* level, int x, int y,
|
||||||
{
|
int z) {
|
||||||
return level->isSolidBlockingTile(x, y, z) ? 0.2f : 1.0f;
|
return level->isSolidBlockingTile(x, y, z) ? 0.2f : 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tile_SPU* Tile_SPU::createFromID( int tileID )
|
Tile_SPU* Tile_SPU::createFromID(int tileID) {
|
||||||
{
|
if (tileID == 0) return NULL;
|
||||||
if(tileID == 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if(m_tiles[tileID].id != -1)
|
if (m_tiles[tileID].id != -1) return &m_tiles[tileID];
|
||||||
return &m_tiles[tileID];
|
|
||||||
|
|
||||||
#ifndef SN_TARGET_PS3_SPU
|
#ifndef SN_TARGET_PS3_SPU
|
||||||
app.DebugPrintf("missing tile ID %d\n", tileID);
|
app.DebugPrintf("missing tile ID %d\n", tileID);
|
||||||
#else
|
#else
|
||||||
spu_print("missing tile ID %d\n", tileID);
|
spu_print("missing tile ID %d\n", tileID);
|
||||||
#endif
|
#endif
|
||||||
return &m_tiles[1];
|
return &m_tiles[1];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Material_SPU* Tile_SPU::getMaterial()
|
Material_SPU* Tile_SPU::getMaterial() {
|
||||||
{
|
int matID = ms_pTileData->materialIDs[id];
|
||||||
int matID = ms_pTileData->materialIDs[id];
|
return &ms_pTileData->materials[matID];
|
||||||
return &ms_pTileData->materials[matID];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// void Tile_SPU::fallOn(Level *level, int x, int y, int z, std::shared_ptr<Entity> entity, float fallDistance)
|
// void Tile_SPU::fallOn(Level *level, int x, int y, int z,
|
||||||
|
// std::shared_ptr<Entity> entity, float fallDistance)
|
||||||
// {
|
// {
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
|
@ -666,234 +669,228 @@ Material_SPU* Tile_SPU::getMaterial()
|
||||||
// return this;
|
// return this;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
void Tile_SPU::initTilePointers() {
|
||||||
|
#define CREATE_TILE_TYPE(index, className) \
|
||||||
|
new (&m_tiles[index]) className(index);
|
||||||
|
|
||||||
|
CREATE_TILE_TYPE(grass_Id, GrassTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(stoneSlab_Id, StoneSlabTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(stoneSlabHalf_Id, StoneSlabTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(woodSlab_Id, WoodSlabTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(woodSlabHalf_Id, WoodSlabTile_SPU);
|
||||||
|
|
||||||
void Tile_SPU::initTilePointers()
|
CREATE_TILE_TYPE(chest_Id, ChestTile_SPU);
|
||||||
{
|
|
||||||
|
|
||||||
#define CREATE_TILE_TYPE(index, className) new (&m_tiles[index]) className(index);
|
CREATE_TILE_TYPE(ironFence_Id, ThinFenceTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(thinGlass_Id, ThinFenceTile_SPU);
|
||||||
|
|
||||||
|
CREATE_TILE_TYPE(fence_Id, FenceTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(netherFence_Id, FenceTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(grass_Id, GrassTile_SPU);
|
CREATE_TILE_TYPE(stairs_wood_Id, StairTile_SPU);
|
||||||
CREATE_TILE_TYPE(stoneSlab_Id, StoneSlabTile_SPU);
|
CREATE_TILE_TYPE(stairs_stone_Id, StairTile_SPU);
|
||||||
CREATE_TILE_TYPE(stoneSlabHalf_Id, StoneSlabTile_SPU);
|
CREATE_TILE_TYPE(stairs_bricks_Id, StairTile_SPU);
|
||||||
CREATE_TILE_TYPE(woodSlab_Id, WoodSlabTile_SPU);
|
CREATE_TILE_TYPE(stairs_stoneBrickSmooth_Id, StairTile_SPU);
|
||||||
CREATE_TILE_TYPE(woodSlabHalf_Id, WoodSlabTile_SPU);
|
CREATE_TILE_TYPE(stairs_netherBricks_Id, StairTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(stairs_sandstone_Id, StairTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(stairs_sprucewood_Id, StairTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(stairs_birchwood_Id, StairTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(stairs_junglewood_Id, StairTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(chest_Id, ChestTile_SPU);
|
CREATE_TILE_TYPE(dirt_Id, DirtTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(ironFence_Id, ThinFenceTile_SPU);
|
CREATE_TILE_TYPE(door_iron_Id, DoorTile_SPU);
|
||||||
CREATE_TILE_TYPE(thinGlass_Id, ThinFenceTile_SPU);
|
CREATE_TILE_TYPE(door_wood_Id, DoorTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(fence_Id, FenceTile_SPU);
|
CREATE_TILE_TYPE(pressurePlate_stone_Id, PressurePlateTile_SPU);
|
||||||
CREATE_TILE_TYPE(netherFence_Id, FenceTile_SPU);
|
CREATE_TILE_TYPE(pressurePlate_wood_Id, PressurePlateTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(stairs_wood_Id, StairTile_SPU);
|
CREATE_TILE_TYPE(farmland_Id, FarmTile_SPU);
|
||||||
CREATE_TILE_TYPE(stairs_stone_Id, StairTile_SPU);
|
|
||||||
CREATE_TILE_TYPE(stairs_bricks_Id, StairTile_SPU);
|
|
||||||
CREATE_TILE_TYPE(stairs_stoneBrickSmooth_Id, StairTile_SPU);
|
|
||||||
CREATE_TILE_TYPE(stairs_netherBricks_Id, StairTile_SPU);
|
|
||||||
CREATE_TILE_TYPE(stairs_sandstone_Id, StairTile_SPU);
|
|
||||||
CREATE_TILE_TYPE(stairs_sprucewood_Id, StairTile_SPU);
|
|
||||||
CREATE_TILE_TYPE(stairs_birchwood_Id, StairTile_SPU);
|
|
||||||
CREATE_TILE_TYPE(stairs_junglewood_Id, StairTile_SPU);
|
|
||||||
|
|
||||||
CREATE_TILE_TYPE(dirt_Id, DirtTile_SPU);
|
CREATE_TILE_TYPE(flower_Id, Bush_SPU);
|
||||||
|
CREATE_TILE_TYPE(rose_Id, Bush_SPU);
|
||||||
|
CREATE_TILE_TYPE(deadBush_Id, Bush_SPU); // DeadBushTile
|
||||||
|
|
||||||
CREATE_TILE_TYPE(door_iron_Id, DoorTile_SPU);
|
CREATE_TILE_TYPE(tallgrass_Id, TallGrass_SPU);
|
||||||
CREATE_TILE_TYPE(door_wood_Id, DoorTile_SPU);
|
|
||||||
|
|
||||||
CREATE_TILE_TYPE(pressurePlate_stone_Id, PressurePlateTile_SPU);
|
CREATE_TILE_TYPE(sandStone_Id, SandStoneTile_SPU);
|
||||||
CREATE_TILE_TYPE(pressurePlate_wood_Id, PressurePlateTile_SPU);
|
|
||||||
|
|
||||||
CREATE_TILE_TYPE(farmland_Id, FarmTile_SPU);
|
CREATE_TILE_TYPE(wood_Id, WoodTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(flower_Id, Bush_SPU);
|
CREATE_TILE_TYPE(treeTrunk_Id, TreeTile_SPU);
|
||||||
CREATE_TILE_TYPE(rose_Id, Bush_SPU);
|
|
||||||
CREATE_TILE_TYPE(deadBush_Id, Bush_SPU); // DeadBushTile
|
|
||||||
|
|
||||||
CREATE_TILE_TYPE(tallgrass_Id, TallGrass_SPU);
|
CREATE_TILE_TYPE(leaves_Id, LeafTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(sandStone_Id, SandStoneTile_SPU);
|
CREATE_TILE_TYPE(crops_Id, CropTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(wood_Id, WoodTile_SPU);
|
CREATE_TILE_TYPE(reeds_Id, ReedTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(treeTrunk_Id, TreeTile_SPU);
|
CREATE_TILE_TYPE(torch_Id, TorchTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(notGate_off_Id, TorchTile_SPU); // TorchTile->NotGateTile
|
||||||
|
CREATE_TILE_TYPE(notGate_on_Id, TorchTile_SPU); // TorchTile->NotGateTile
|
||||||
|
|
||||||
CREATE_TILE_TYPE(leaves_Id, LeafTile_SPU);
|
CREATE_TILE_TYPE(mushroom1_Id, Mushroom_SPU);
|
||||||
|
CREATE_TILE_TYPE(mushroom2_Id, Mushroom_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(crops_Id, CropTile_SPU);
|
CREATE_TILE_TYPE(mobSpawner_Id, MobSpawnerTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(musicBlock_Id, EntityTile_SPU); // MusicTile->EntityTile
|
||||||
|
|
||||||
CREATE_TILE_TYPE(reeds_Id, ReedTile_SPU);
|
CREATE_TILE_TYPE(furnace_Id, FurnaceTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(furnace_lit_Id, FurnaceTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(torch_Id, TorchTile_SPU);
|
CREATE_TILE_TYPE(web_Id, WebTile_SPU);
|
||||||
CREATE_TILE_TYPE(notGate_off_Id, TorchTile_SPU); // TorchTile->NotGateTile
|
|
||||||
CREATE_TILE_TYPE(notGate_on_Id, TorchTile_SPU); // TorchTile->NotGateTile
|
|
||||||
|
|
||||||
CREATE_TILE_TYPE(mushroom1_Id, Mushroom_SPU);
|
CREATE_TILE_TYPE(water_Id, LiquidTile_SPU);
|
||||||
CREATE_TILE_TYPE(mushroom2_Id, Mushroom_SPU);
|
CREATE_TILE_TYPE(lava_Id, LiquidTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(calmLava_Id, LiquidTile_SPU); // LiquidTileStatic
|
||||||
|
CREATE_TILE_TYPE(calmWater_Id, LiquidTile_SPU); // LiquidTileStatic
|
||||||
|
|
||||||
CREATE_TILE_TYPE(mobSpawner_Id, MobSpawnerTile_SPU);
|
CREATE_TILE_TYPE(fire_Id, FireTile_SPU);
|
||||||
CREATE_TILE_TYPE(musicBlock_Id, EntityTile_SPU); // MusicTile->EntityTile
|
|
||||||
|
|
||||||
CREATE_TILE_TYPE(furnace_Id, FurnaceTile_SPU);
|
CREATE_TILE_TYPE(sapling_Id, Sapling_SPU);
|
||||||
CREATE_TILE_TYPE(furnace_lit_Id, FurnaceTile_SPU);
|
|
||||||
|
|
||||||
CREATE_TILE_TYPE(web_Id, WebTile_SPU);
|
CREATE_TILE_TYPE(glass_Id, GlassTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(water_Id, LiquidTile_SPU);
|
CREATE_TILE_TYPE(ice_Id, IceTile_SPU);
|
||||||
CREATE_TILE_TYPE(lava_Id, LiquidTile_SPU);
|
|
||||||
CREATE_TILE_TYPE(calmLava_Id, LiquidTile_SPU); // LiquidTileStatic
|
|
||||||
CREATE_TILE_TYPE(calmWater_Id, LiquidTile_SPU); // LiquidTileStatic
|
|
||||||
|
|
||||||
CREATE_TILE_TYPE(fire_Id, FireTile_SPU);
|
CREATE_TILE_TYPE(portalTile_Id, PortalTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(sapling_Id, Sapling_SPU);
|
CREATE_TILE_TYPE(dispenser_Id, DispenserTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(glass_Id, GlassTile_SPU);
|
CREATE_TILE_TYPE(rail_Id, RailTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(goldenRail_Id, RailTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(ice_Id, IceTile_SPU);
|
CREATE_TILE_TYPE(detectorRail_Id, DetectorRailTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(portalTile_Id, PortalTile_SPU);
|
CREATE_TILE_TYPE(tnt_Id, TntTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(dispenser_Id, DispenserTile_SPU);
|
CREATE_TILE_TYPE(bookshelf_Id, BookshelfTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(rail_Id, RailTile_SPU);
|
CREATE_TILE_TYPE(workBench_Id, WorkbenchTile_SPU);
|
||||||
CREATE_TILE_TYPE(goldenRail_Id, RailTile_SPU);
|
|
||||||
|
|
||||||
CREATE_TILE_TYPE(detectorRail_Id, DetectorRailTile_SPU);
|
CREATE_TILE_TYPE(sign_Id, SignTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(wallSign_Id, SignTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(tnt_Id, TntTile_SPU);
|
CREATE_TILE_TYPE(ladder_Id, LadderTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(bookshelf_Id, BookshelfTile_SPU);
|
CREATE_TILE_TYPE(button_stone_Id, ButtonTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(button_wood_Id, ButtonTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(workBench_Id, WorkbenchTile_SPU);
|
CREATE_TILE_TYPE(topSnow_Id, TopSnowTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(sign_Id, SignTile_SPU);
|
CREATE_TILE_TYPE(cactus_Id, CactusTile_SPU);
|
||||||
CREATE_TILE_TYPE(wallSign_Id, SignTile_SPU);
|
|
||||||
|
|
||||||
CREATE_TILE_TYPE(ladder_Id, LadderTile_SPU);
|
CREATE_TILE_TYPE(recordPlayer_Id, RecordPlayerTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(button_stone_Id, ButtonTile_SPU);
|
CREATE_TILE_TYPE(pumpkin_Id, PumpkinTile_SPU);
|
||||||
CREATE_TILE_TYPE(button_wood_Id, ButtonTile_SPU);
|
CREATE_TILE_TYPE(litPumpkin_Id, PumpkinTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(topSnow_Id, TopSnowTile_SPU);
|
CREATE_TILE_TYPE(cake_Id, CakeTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(cactus_Id, CactusTile_SPU);
|
CREATE_TILE_TYPE(trapdoor_Id, TrapDoorTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(recordPlayer_Id, RecordPlayerTile_SPU);
|
CREATE_TILE_TYPE(monsterStoneEgg_Id, StoneMonsterTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(pumpkin_Id, PumpkinTile_SPU);
|
CREATE_TILE_TYPE(stoneBrickSmooth_Id, SmoothStoneBrickTile_SPU);
|
||||||
CREATE_TILE_TYPE(litPumpkin_Id, PumpkinTile_SPU);
|
|
||||||
|
|
||||||
CREATE_TILE_TYPE(cake_Id, CakeTile_SPU);
|
CREATE_TILE_TYPE(hugeMushroom1_Id, HugeMushroomTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(hugeMushroom2_Id, HugeMushroomTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(trapdoor_Id, TrapDoorTile_SPU);
|
CREATE_TILE_TYPE(melon_Id, MelonTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(monsterStoneEgg_Id, StoneMonsterTile_SPU);
|
CREATE_TILE_TYPE(melonStem_Id, StemTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(pumpkinStem_Id, StemTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(stoneBrickSmooth_Id, SmoothStoneBrickTile_SPU);
|
CREATE_TILE_TYPE(vine_Id, VineTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(hugeMushroom1_Id, HugeMushroomTile_SPU);
|
CREATE_TILE_TYPE(mycel_Id, MycelTile_SPU);
|
||||||
CREATE_TILE_TYPE(hugeMushroom2_Id, HugeMushroomTile_SPU);
|
|
||||||
|
|
||||||
CREATE_TILE_TYPE(melon_Id, MelonTile_SPU);
|
CREATE_TILE_TYPE(waterLily_Id, WaterlilyTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(melonStem_Id, StemTile_SPU);
|
CREATE_TILE_TYPE(netherStalk_Id, NetherStalkTile_SPU);
|
||||||
CREATE_TILE_TYPE(pumpkinStem_Id, StemTile_SPU);
|
|
||||||
|
|
||||||
CREATE_TILE_TYPE(vine_Id, VineTile_SPU);
|
CREATE_TILE_TYPE(enchantTable_Id, EnchantmentTableTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(mycel_Id, MycelTile_SPU);
|
CREATE_TILE_TYPE(brewingStand_Id, BrewingStandTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(waterLily_Id, WaterlilyTile_SPU);
|
CREATE_TILE_TYPE(diode_on_Id, DiodeTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(diode_off_Id, DiodeTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(netherStalk_Id, NetherStalkTile_SPU);
|
CREATE_TILE_TYPE(redStoneDust_Id, RedStoneDustTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(enchantTable_Id, EnchantmentTableTile_SPU);
|
CREATE_TILE_TYPE(fenceGate_Id, FenceGateTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(brewingStand_Id, BrewingStandTile_SPU);
|
CREATE_TILE_TYPE(bed_Id, BedTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(diode_on_Id, DiodeTile_SPU);
|
CREATE_TILE_TYPE(pistonBase_Id, PistonBaseTile_SPU);
|
||||||
CREATE_TILE_TYPE(diode_off_Id, DiodeTile_SPU);
|
CREATE_TILE_TYPE(pistonStickyBase_Id, PistonBaseTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(redStoneDust_Id, RedStoneDustTile_SPU);
|
CREATE_TILE_TYPE(pistonExtensionPiece_Id, PistonExtensionTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(fenceGate_Id, FenceGateTile_SPU);
|
CREATE_TILE_TYPE(pistonMovingPiece_Id, PistonMovingPiece_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(bed_Id, BedTile_SPU);
|
CREATE_TILE_TYPE(lever_Id, LeverTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(pistonBase_Id, PistonBaseTile_SPU);
|
CREATE_TILE_TYPE(cauldron_Id, CauldronTile_SPU);
|
||||||
CREATE_TILE_TYPE(pistonStickyBase_Id, PistonBaseTile_SPU);
|
|
||||||
|
|
||||||
CREATE_TILE_TYPE(pistonExtensionPiece_Id, PistonExtensionTile_SPU);
|
CREATE_TILE_TYPE(endPortalTile_Id, TheEndPortal_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(pistonMovingPiece_Id, PistonMovingPiece_SPU);
|
CREATE_TILE_TYPE(endPortalFrameTile_Id, TheEndPortalFrameTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(lever_Id, LeverTile_SPU);
|
CREATE_TILE_TYPE(dragonEgg_Id, EggTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(cauldron_Id, CauldronTile_SPU);
|
CREATE_TILE_TYPE(cocoa_Id, CocoaTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(endPortalTile_Id, TheEndPortal_SPU);
|
CREATE_TILE_TYPE(redstoneLight_Id, RedlightTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(redstoneLight_lit_Id, RedlightTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(endPortalFrameTile_Id, TheEndPortalFrameTile_SPU);
|
CREATE_TILE_TYPE(skull_Id, SkullTile_SPU);
|
||||||
|
|
||||||
CREATE_TILE_TYPE(dragonEgg_Id, EggTile_SPU);
|
// these tile types don't have any additional code that we need.
|
||||||
|
CREATE_TILE_TYPE(stoneBrick_Id, Tile_SPU); // Tile
|
||||||
|
CREATE_TILE_TYPE(lapisBlock_Id, Tile_SPU);
|
||||||
|
CREATE_TILE_TYPE(redBrick_Id, Tile_SPU);
|
||||||
|
CREATE_TILE_TYPE(mossStone_Id, Tile_SPU);
|
||||||
|
CREATE_TILE_TYPE(netherBrick_Id, Tile_SPU);
|
||||||
|
CREATE_TILE_TYPE(whiteStone_Id, Tile_SPU);
|
||||||
|
CREATE_TILE_TYPE(unbreakable_Id, Tile_SPU);
|
||||||
|
CREATE_TILE_TYPE(sponge_Id, Tile_SPU);
|
||||||
|
CREATE_TILE_TYPE(rock_Id, Tile_SPU); // StoneTile
|
||||||
|
CREATE_TILE_TYPE(obsidian_Id, Tile_SPU); // StoneTile->ObsidianTile
|
||||||
|
CREATE_TILE_TYPE(sand_Id, Tile_SPU); // HeavyTile
|
||||||
|
CREATE_TILE_TYPE(gravel_Id, Tile_SPU); // GravelTile
|
||||||
|
CREATE_TILE_TYPE(goldOre_Id, Tile_SPU); // OreTile
|
||||||
|
CREATE_TILE_TYPE(ironOre_Id, Tile_SPU); // OreTile
|
||||||
|
CREATE_TILE_TYPE(coalOre_Id, Tile_SPU); // OreTile
|
||||||
|
CREATE_TILE_TYPE(lapisOre_Id, Tile_SPU); // OreTile
|
||||||
|
CREATE_TILE_TYPE(diamondOre_Id, Tile_SPU); // OreTile
|
||||||
|
CREATE_TILE_TYPE(clay_Id, Tile_SPU); // ClayTile
|
||||||
|
CREATE_TILE_TYPE(redStoneOre_Id, Tile_SPU); // RedStoneOreTile
|
||||||
|
CREATE_TILE_TYPE(redStoneOre_lit_Id, Tile_SPU); // RedStoneOreTile
|
||||||
|
CREATE_TILE_TYPE(goldBlock_Id, Tile_SPU); // MetalTile
|
||||||
|
CREATE_TILE_TYPE(ironBlock_Id, Tile_SPU); // MetalTile
|
||||||
|
CREATE_TILE_TYPE(diamondBlock_Id, Tile_SPU); // MetalTile
|
||||||
|
CREATE_TILE_TYPE(snow_Id, Tile_SPU); // SnowTile
|
||||||
|
CREATE_TILE_TYPE(hellRock_Id, Tile_SPU); // HellStoneTile
|
||||||
|
CREATE_TILE_TYPE(hellSand_Id, Tile_SPU); // HellSandTile
|
||||||
|
CREATE_TILE_TYPE(lightGem_Id, Tile_SPU); // LightGemTile
|
||||||
|
CREATE_TILE_TYPE(aprilFoolsJoke_Id, Tile_SPU); // LockedChestTile
|
||||||
|
|
||||||
CREATE_TILE_TYPE(cocoa_Id, CocoaTile_SPU);
|
CREATE_TILE_TYPE(cloth_Id, ClothTile_SPU); // wool
|
||||||
|
|
||||||
CREATE_TILE_TYPE(redstoneLight_Id, RedlightTile_SPU);
|
|
||||||
CREATE_TILE_TYPE(redstoneLight_lit_Id, RedlightTile_SPU);
|
|
||||||
|
|
||||||
CREATE_TILE_TYPE(skull_Id, SkullTile_SPU);
|
|
||||||
|
|
||||||
// these tile types don't have any additional code that we need.
|
|
||||||
CREATE_TILE_TYPE(stoneBrick_Id, Tile_SPU); // Tile
|
|
||||||
CREATE_TILE_TYPE(lapisBlock_Id, Tile_SPU);
|
|
||||||
CREATE_TILE_TYPE(redBrick_Id, Tile_SPU);
|
|
||||||
CREATE_TILE_TYPE(mossStone_Id, Tile_SPU);
|
|
||||||
CREATE_TILE_TYPE(netherBrick_Id, Tile_SPU);
|
|
||||||
CREATE_TILE_TYPE(whiteStone_Id, Tile_SPU);
|
|
||||||
CREATE_TILE_TYPE(unbreakable_Id, Tile_SPU);
|
|
||||||
CREATE_TILE_TYPE(sponge_Id, Tile_SPU);
|
|
||||||
CREATE_TILE_TYPE(rock_Id, Tile_SPU); // StoneTile
|
|
||||||
CREATE_TILE_TYPE(obsidian_Id, Tile_SPU); // StoneTile->ObsidianTile
|
|
||||||
CREATE_TILE_TYPE(sand_Id, Tile_SPU); // HeavyTile
|
|
||||||
CREATE_TILE_TYPE(gravel_Id, Tile_SPU); // GravelTile
|
|
||||||
CREATE_TILE_TYPE(goldOre_Id, Tile_SPU); // OreTile
|
|
||||||
CREATE_TILE_TYPE(ironOre_Id, Tile_SPU); // OreTile
|
|
||||||
CREATE_TILE_TYPE(coalOre_Id, Tile_SPU); // OreTile
|
|
||||||
CREATE_TILE_TYPE(lapisOre_Id, Tile_SPU); // OreTile
|
|
||||||
CREATE_TILE_TYPE(diamondOre_Id, Tile_SPU); // OreTile
|
|
||||||
CREATE_TILE_TYPE(clay_Id, Tile_SPU); // ClayTile
|
|
||||||
CREATE_TILE_TYPE(redStoneOre_Id, Tile_SPU); // RedStoneOreTile
|
|
||||||
CREATE_TILE_TYPE(redStoneOre_lit_Id, Tile_SPU); // RedStoneOreTile
|
|
||||||
CREATE_TILE_TYPE(goldBlock_Id, Tile_SPU); // MetalTile
|
|
||||||
CREATE_TILE_TYPE(ironBlock_Id, Tile_SPU); // MetalTile
|
|
||||||
CREATE_TILE_TYPE(diamondBlock_Id, Tile_SPU); // MetalTile
|
|
||||||
CREATE_TILE_TYPE(snow_Id, Tile_SPU); // SnowTile
|
|
||||||
CREATE_TILE_TYPE(hellRock_Id, Tile_SPU); // HellStoneTile
|
|
||||||
CREATE_TILE_TYPE(hellSand_Id, Tile_SPU); // HellSandTile
|
|
||||||
CREATE_TILE_TYPE(lightGem_Id, Tile_SPU); // LightGemTile
|
|
||||||
CREATE_TILE_TYPE(aprilFoolsJoke_Id, Tile_SPU); // LockedChestTile
|
|
||||||
|
|
||||||
CREATE_TILE_TYPE(cloth_Id, ClothTile_SPU); // wool
|
|
||||||
|
|
||||||
|
|
||||||
CREATE_TILE_TYPE(emeraldOre_Id, Tile_SPU); // OreTile
|
|
||||||
CREATE_TILE_TYPE(enderChest_Id, EnderChestTile_SPU);
|
|
||||||
CREATE_TILE_TYPE(tripWireSource_Id, TripWireSourceTile_SPU);
|
|
||||||
CREATE_TILE_TYPE(tripWire_Id, TripWireTile_SPU);
|
|
||||||
//
|
|
||||||
CREATE_TILE_TYPE(emeraldBlock_Id, Tile_SPU); // MetalTile
|
|
||||||
CREATE_TILE_TYPE(cobbleWall_Id, WallTile_SPU);
|
|
||||||
CREATE_TILE_TYPE(flowerPot_Id, FlowerPotTile_SPU);
|
|
||||||
CREATE_TILE_TYPE(carrots_Id, CarrotTile_SPU);
|
|
||||||
CREATE_TILE_TYPE(potatoes_Id, PotatoTile_SPU);
|
|
||||||
CREATE_TILE_TYPE(anvil_Id, AnvilTile_SPU);
|
|
||||||
CREATE_TILE_TYPE(netherQuartz_Id, Tile_SPU); // OreTile
|
|
||||||
CREATE_TILE_TYPE(quartzBlock_Id, QuartzBlockTile_SPU);
|
|
||||||
CREATE_TILE_TYPE(stairs_quartz_Id, StairTile_SPU);
|
|
||||||
CREATE_TILE_TYPE(woolCarpet_Id, WoolCarpetTile_SPU);
|
|
||||||
|
|
||||||
|
CREATE_TILE_TYPE(emeraldOre_Id, Tile_SPU); // OreTile
|
||||||
|
CREATE_TILE_TYPE(enderChest_Id, EnderChestTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(tripWireSource_Id, TripWireSourceTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(tripWire_Id, TripWireTile_SPU);
|
||||||
|
//
|
||||||
|
CREATE_TILE_TYPE(emeraldBlock_Id, Tile_SPU); // MetalTile
|
||||||
|
CREATE_TILE_TYPE(cobbleWall_Id, WallTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(flowerPot_Id, FlowerPotTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(carrots_Id, CarrotTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(potatoes_Id, PotatoTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(anvil_Id, AnvilTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(netherQuartz_Id, Tile_SPU); // OreTile
|
||||||
|
CREATE_TILE_TYPE(quartzBlock_Id, QuartzBlockTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(stairs_quartz_Id, StairTile_SPU);
|
||||||
|
CREATE_TILE_TYPE(woolCarpet_Id, WoolCarpetTile_SPU);
|
||||||
};
|
};
|
||||||
|
|
@ -661,7 +661,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||||
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
Vec3::CreateNewThreadStorage();
|
|
||||||
Level::enableLightingCache();
|
Level::enableLightingCache();
|
||||||
|
|
||||||
Minecraft::main();
|
Minecraft::main();
|
||||||
|
|
@ -961,9 +960,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
||||||
// menu A memory leak was caused because the icon renderer kept creating
|
|
||||||
// new Vec3's because the pool wasn't reset
|
|
||||||
Vec3::resetPool();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free resources, unregister custom classes, and exit.
|
// Free resources, unregister custom classes, and exit.
|
||||||
|
|
|
||||||
|
|
@ -896,7 +896,6 @@ int main() {
|
||||||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||||
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
Vec3::CreateNewThreadStorage();
|
|
||||||
Compression::CreateNewThreadStorage();
|
Compression::CreateNewThreadStorage();
|
||||||
OldChunkStorage::CreateNewThreadStorage();
|
OldChunkStorage::CreateNewThreadStorage();
|
||||||
Level::enableLightingCache();
|
Level::enableLightingCache();
|
||||||
|
|
@ -1250,9 +1249,6 @@ int main() {
|
||||||
app.SaveDataTick();
|
app.SaveDataTick();
|
||||||
|
|
||||||
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
||||||
// menu A memory leak was caused because the icon renderer kept creating
|
|
||||||
// new Vec3's because the pool wasn't reset
|
|
||||||
Vec3::resetPool();
|
|
||||||
|
|
||||||
// sceRazorCpuSync();
|
// sceRazorCpuSync();
|
||||||
#ifndef _CONTENT_PACKAGE
|
#ifndef _CONTENT_PACKAGE
|
||||||
|
|
|
||||||
|
|
@ -941,7 +941,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||||
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
Vec3::CreateNewThreadStorage();
|
|
||||||
Compression::CreateNewThreadStorage();
|
Compression::CreateNewThreadStorage();
|
||||||
OldChunkStorage::CreateNewThreadStorage();
|
OldChunkStorage::CreateNewThreadStorage();
|
||||||
Level::enableLightingCache();
|
Level::enableLightingCache();
|
||||||
|
|
@ -1269,9 +1268,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
||||||
// menu A memory leak was caused because the icon renderer kept creating
|
|
||||||
// new Vec3's because the pool wasn't reset
|
|
||||||
Vec3::resetPool();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free resources, unregister custom classes, and exit.
|
// Free resources, unregister custom classes, and exit.
|
||||||
|
|
|
||||||
|
|
@ -700,7 +700,6 @@ int __cdecl main() {
|
||||||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||||
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
// Initialise TLS for AABB and Vec3 pools, for this main thread
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
Vec3::CreateNewThreadStorage();
|
|
||||||
Compression::CreateNewThreadStorage();
|
Compression::CreateNewThreadStorage();
|
||||||
OldChunkStorage::CreateNewThreadStorage();
|
OldChunkStorage::CreateNewThreadStorage();
|
||||||
Level::enableLightingCache();
|
Level::enableLightingCache();
|
||||||
|
|
@ -1029,9 +1028,6 @@ int __cdecl main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
// Fix for #7318 - Title crashes after short soak in the leaderboards
|
||||||
// menu A memory leak was caused because the icon renderer kept creating
|
|
||||||
// new Vec3's because the pool wasn't reset
|
|
||||||
Vec3::resetPool();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free resources, unregister custom classes, and exit.
|
// Free resources, unregister custom classes, and exit.
|
||||||
|
|
|
||||||
|
|
@ -404,25 +404,25 @@ void LocalPlayer::aiStep() {
|
||||||
|
|
||||||
if (abilities.flying) // minecraft->options->isFlying )
|
if (abilities.flying) // minecraft->options->isFlying )
|
||||||
{
|
{
|
||||||
Vec3* viewVector = getViewVector(1.0f);
|
Vec3 viewVector = getViewVector(1.0f);
|
||||||
|
|
||||||
// 4J-PB - To let the player build easily while flying, we need to
|
// 4J-PB - To let the player build easily while flying, we need to
|
||||||
// change this
|
// change this
|
||||||
|
|
||||||
#ifdef _DEBUG_MENUS_ENABLED
|
#ifdef _DEBUG_MENUS_ENABLED
|
||||||
if (abilities.debugflying) {
|
if (abilities.debugflying) {
|
||||||
flyX = (float)viewVector->x * input->ya;
|
flyX = (float)viewVector.x * input->ya;
|
||||||
flyY = (float)viewVector->y * input->ya;
|
flyY = (float)viewVector.y * input->ya;
|
||||||
flyZ = (float)viewVector->z * input->ya;
|
flyZ = (float)viewVector.z * input->ya;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (isSprinting()) {
|
if (isSprinting()) {
|
||||||
// Accelrate up to full speed if we are sprinting, moving in the
|
// Accelrate up to full speed if we are sprinting, moving in the
|
||||||
// direction of the view vector
|
// direction of the view vector
|
||||||
flyX = (float)viewVector->x * input->ya;
|
flyX = (float)viewVector.x * input->ya;
|
||||||
flyY = (float)viewVector->y * input->ya;
|
flyY = (float)viewVector.y * input->ya;
|
||||||
flyZ = (float)viewVector->z * input->ya;
|
flyZ = (float)viewVector.z * input->ya;
|
||||||
|
|
||||||
float scale = ((float)(SPRINT_DURATION - sprintTime)) / 10.0f;
|
float scale = ((float)(SPRINT_DURATION - sprintTime)) / 10.0f;
|
||||||
scale = scale * scale;
|
scale = scale * scale;
|
||||||
|
|
@ -550,7 +550,8 @@ void LocalPlayer::closeContainer() {
|
||||||
void LocalPlayer::openTextEdit(std::shared_ptr<TileEntity> tileEntity) {
|
void LocalPlayer::openTextEdit(std::shared_ptr<TileEntity> tileEntity) {
|
||||||
#ifdef ENABLE_JAVA_GUIS
|
#ifdef ENABLE_JAVA_GUIS
|
||||||
if (tileEntity->GetType() == eTYPE_SIGNTILEENTITY) {
|
if (tileEntity->GetType() == eTYPE_SIGNTILEENTITY) {
|
||||||
minecraft->setScreen(new TextEditScreen(std::dynamic_pointer_cast<SignTileEntity>(tileEntity)));
|
minecraft->setScreen(new TextEditScreen(
|
||||||
|
std::dynamic_pointer_cast<SignTileEntity>(tileEntity)));
|
||||||
bool success = true;
|
bool success = true;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
@ -782,8 +783,7 @@ void LocalPlayer::awardStat(Stat* stat, byteArray param) {
|
||||||
// storage device, so needs a primary player, and the player may not
|
// storage device, so needs a primary player, and the player may not
|
||||||
// have been a primary player when they first 'got' the award so let the
|
// have been a primary player when they first 'got' the award so let the
|
||||||
// award manager figure it out
|
// award manager figure it out
|
||||||
if (!minecraft->stats[m_iPad]->hasTaken(ach))
|
if (!minecraft->stats[m_iPad]->hasTaken(ach)) {
|
||||||
{
|
|
||||||
// 4J-PB - Don't display the java popup
|
// 4J-PB - Don't display the java popup
|
||||||
#ifdef ENABLE_JAVA_GUIS
|
#ifdef ENABLE_JAVA_GUIS
|
||||||
minecraft->achievementPopup->popup(ach);
|
minecraft->achievementPopup->popup(ach);
|
||||||
|
|
@ -1506,7 +1506,7 @@ bool LocalPlayer::handleMouseClick(int button) {
|
||||||
bool usedItem = false;
|
bool usedItem = false;
|
||||||
if (minecraft->gameMode->useItemOn(
|
if (minecraft->gameMode->useItemOn(
|
||||||
minecraft->localplayers[GetXboxPad()], level, item, x, y, z,
|
minecraft->localplayers[GetXboxPad()], level, item, x, y, z,
|
||||||
face, minecraft->hitResult->pos, false, &usedItem)) {
|
face, &minecraft->hitResult->pos, false, &usedItem)) {
|
||||||
// Presume that if we actually used the held item, then we've
|
// Presume that if we actually used the held item, then we've
|
||||||
// placed it
|
// placed it
|
||||||
if (usedItem) {
|
if (usedItem) {
|
||||||
|
|
|
||||||
|
|
@ -91,10 +91,11 @@ zPlayerOffs = position->get(2);
|
||||||
|
|
||||||
TilePos* Camera::getCameraTilePos(std::shared_ptr<LivingEntity> player,
|
TilePos* Camera::getCameraTilePos(std::shared_ptr<LivingEntity> player,
|
||||||
double alpha) {
|
double alpha) {
|
||||||
return new TilePos(getCameraPos(player, alpha));
|
Vec3 cam_pos = getCameraPos(player, alpha);
|
||||||
|
return new TilePos(&cam_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* Camera::getCameraPos(std::shared_ptr<LivingEntity> player, double alpha) {
|
Vec3 Camera::getCameraPos(std::shared_ptr<LivingEntity> player, double alpha) {
|
||||||
double xx = player->xo + (player->x - player->xo) * alpha;
|
double xx = player->xo + (player->x - player->xo) * alpha;
|
||||||
double yy =
|
double yy =
|
||||||
player->yo + (player->y - player->yo) * alpha + player->getHeadHeight();
|
player->yo + (player->y - player->yo) * alpha + player->getHeadHeight();
|
||||||
|
|
@ -104,19 +105,19 @@ Vec3* Camera::getCameraPos(std::shared_ptr<LivingEntity> player, double alpha) {
|
||||||
double yt = yy + Camera::yPlayerOffs * 1;
|
double yt = yy + Camera::yPlayerOffs * 1;
|
||||||
double zt = zz + Camera::zPlayerOffs * 1;
|
double zt = zz + Camera::zPlayerOffs * 1;
|
||||||
|
|
||||||
return Vec3::newTemp(xt, yt, zt);
|
return Vec3(xt, yt, zt);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Camera::getBlockAt(Level* level, std::shared_ptr<LivingEntity> player,
|
int Camera::getBlockAt(Level* level, std::shared_ptr<LivingEntity> player,
|
||||||
float alpha) {
|
float alpha) {
|
||||||
Vec3* p = Camera::getCameraPos(player, alpha);
|
Vec3 p = Camera::getCameraPos(player, alpha);
|
||||||
TilePos tp = TilePos(p);
|
TilePos tp = TilePos(&p);
|
||||||
int t = level->getTile(tp.x, tp.y, tp.z);
|
int t = level->getTile(tp.x, tp.y, tp.z);
|
||||||
if (t != 0 && Tile::tiles[t]->material->isLiquid()) {
|
if (t != 0 && Tile::tiles[t]->material->isLiquid()) {
|
||||||
float hh =
|
float hh =
|
||||||
LiquidTile::getHeight(level->getData(tp.x, tp.y, tp.z)) - 1 / 9.0f;
|
LiquidTile::getHeight(level->getData(tp.x, tp.y, tp.z)) - 1 / 9.0f;
|
||||||
float h = tp.y + 1 - hh;
|
float h = tp.y + 1 - hh;
|
||||||
if (p->y >= h) {
|
if (p.y >= h) {
|
||||||
t = level->getTile(tp.x, tp.y + 1, tp.z);
|
t = level->getTile(tp.x, tp.y + 1, tp.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ public:
|
||||||
|
|
||||||
static TilePos* getCameraTilePos(std::shared_ptr<LivingEntity> player,
|
static TilePos* getCameraTilePos(std::shared_ptr<LivingEntity> player,
|
||||||
double alpha);
|
double alpha);
|
||||||
static Vec3* getCameraPos(std::shared_ptr<LivingEntity> player,
|
static Vec3 getCameraPos(std::shared_ptr<LivingEntity> player,
|
||||||
double alpha);
|
double alpha);
|
||||||
static int getBlockAt(Level* level, std::shared_ptr<LivingEntity> player,
|
static int getBlockAt(Level* level, std::shared_ptr<LivingEntity> player,
|
||||||
float alpha);
|
float alpha);
|
||||||
};
|
};
|
||||||
|
|
@ -58,22 +58,22 @@ void FishingHookRenderer::render(std::shared_ptr<Entity> _hook, double x,
|
||||||
float swing = hook->owner->getAttackAnim(a);
|
float swing = hook->owner->getAttackAnim(a);
|
||||||
float swing2 = (float)Mth::sin(sqrt(swing) * PI);
|
float swing2 = (float)Mth::sin(sqrt(swing) * PI);
|
||||||
|
|
||||||
Vec3* vv = Vec3::newTemp(-0.5, 0.03, 0.8);
|
Vec3 vv(-0.5, 0.03, 0.8);
|
||||||
vv->xRot(-(hook->owner->xRotO +
|
vv.xRot(-(hook->owner->xRotO +
|
||||||
(hook->owner->xRot - hook->owner->xRotO) * a) *
|
(hook->owner->xRot - hook->owner->xRotO) * a) *
|
||||||
PI / 180);
|
PI / 180);
|
||||||
vv->yRot(-(hook->owner->yRotO +
|
vv.yRot(-(hook->owner->yRotO +
|
||||||
(hook->owner->yRot - hook->owner->yRotO) * a) *
|
(hook->owner->yRot - hook->owner->yRotO) * a) *
|
||||||
PI / 180);
|
PI / 180);
|
||||||
vv->yRot(swing2 * 0.5f);
|
vv.yRot(swing2 * 0.5f);
|
||||||
vv->xRot(-swing2 * 0.7f);
|
vv.xRot(-swing2 * 0.7f);
|
||||||
|
|
||||||
double xp =
|
double xp =
|
||||||
hook->owner->xo + (hook->owner->x - hook->owner->xo) * a + vv->x;
|
hook->owner->xo + (hook->owner->x - hook->owner->xo) * a + vv.x;
|
||||||
double yp =
|
double yp =
|
||||||
hook->owner->yo + (hook->owner->y - hook->owner->yo) * a + vv->y;
|
hook->owner->yo + (hook->owner->y - hook->owner->yo) * a + vv.y;
|
||||||
double zp =
|
double zp =
|
||||||
hook->owner->zo + (hook->owner->z - hook->owner->zo) * a + vv->z;
|
hook->owner->zo + (hook->owner->z - hook->owner->zo) * a + vv.z;
|
||||||
double yOffset = hook->owner == std::dynamic_pointer_cast<Player>(
|
double yOffset = hook->owner == std::dynamic_pointer_cast<Player>(
|
||||||
Minecraft::GetInstance()->player)
|
Minecraft::GetInstance()->player)
|
||||||
? 0
|
? 0
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "../../Platform/stdafx.h"
|
#include "../../Platform/stdafx.h"
|
||||||
#include "MinecartRenderer.h"
|
#include "MinecartRenderer.h"
|
||||||
|
#include <optional>
|
||||||
#include "../Models/MinecartModel.h"
|
#include "../Models/MinecartModel.h"
|
||||||
#include "../../Textures/TextureAtlas.h"
|
#include "../../Textures/TextureAtlas.h"
|
||||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.item.h"
|
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.item.h"
|
||||||
|
|
@ -40,26 +41,27 @@ void MinecartRenderer::render(std::shared_ptr<Entity> _cart, double x, double y,
|
||||||
|
|
||||||
double r = 0.3f;
|
double r = 0.3f;
|
||||||
|
|
||||||
Vec3* p = cart->getPos(xx, yy, zz);
|
std::optional<Vec3> p = cart->getPos(xx, yy, zz);
|
||||||
|
|
||||||
float xRot = cart->xRotO + (cart->xRot - cart->xRotO) * a;
|
float xRot = cart->xRotO + (cart->xRot - cart->xRotO) * a;
|
||||||
|
|
||||||
if (p != NULL) {
|
if (p.has_value()) {
|
||||||
Vec3* p0 = cart->getPosOffs(xx, yy, zz, r);
|
auto p0 = cart->getPosOffs(xx, yy, zz, r);
|
||||||
Vec3* p1 = cart->getPosOffs(xx, yy, zz, -r);
|
auto p1 = cart->getPosOffs(xx, yy, zz, -r);
|
||||||
if (p0 == NULL) p0 = p;
|
if (!p0.has_value()) p0 = p;
|
||||||
if (p1 == NULL) p1 = p;
|
if (!p1.has_value()) p1 = p;
|
||||||
|
|
||||||
x += p->x - xx;
|
x += p->x - xx;
|
||||||
y += (p0->y + p1->y) / 2 - yy;
|
y += (p0->y + p1->y) / 2 - yy;
|
||||||
z += p->z - zz;
|
z += p->z - zz;
|
||||||
|
|
||||||
Vec3* dir = p1->add(-p0->x, -p0->y, -p0->z);
|
Vec3 dir(-p0->x, -p0->y, -p0->z);
|
||||||
if (dir->length() == 0) {
|
dir = dir.add(p1->x, p1->y, p1->z);
|
||||||
|
if (dir.length() == 0) {
|
||||||
} else {
|
} else {
|
||||||
dir = dir->normalize();
|
dir = dir.normalize();
|
||||||
rot = (float)(atan2(dir->z, dir->x) * 180 / PI);
|
rot = (float)(atan2(dir.z, dir.x) * 180 / PI);
|
||||||
xRot = (float)(atan(dir->y) * 73);
|
xRot = (float)(atan(dir.y) * 73);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glTranslatef((float)x, (float)y, (float)z);
|
glTranslatef((float)x, (float)y, (float)z);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "../../Platform/stdafx.h"
|
#include "../../Platform/stdafx.h"
|
||||||
|
|
||||||
#include "TileRenderer.h"
|
#include "TileRenderer.h"
|
||||||
|
#include <array>
|
||||||
#include "../GameRenderer.h"
|
#include "../GameRenderer.h"
|
||||||
#include "../../Minecraft.h"
|
#include "../../Minecraft.h"
|
||||||
#include "../../Textures/Textures.h"
|
#include "../../Textures/Textures.h"
|
||||||
|
|
@ -1045,9 +1046,8 @@ bool TileRenderer::tesselateAnvilInWorld(AnvilTile* tt, int x, int y, int z,
|
||||||
|
|
||||||
float TileRenderer::tesselateAnvilPiece(AnvilTile* tt, int x, int y, int z,
|
float TileRenderer::tesselateAnvilPiece(AnvilTile* tt, int x, int y, int z,
|
||||||
int part, float bottom, float width,
|
int part, float bottom, float width,
|
||||||
float height, float length,
|
float height, float length, bool rotate,
|
||||||
bool rotate, bool render,
|
bool render, int data) {
|
||||||
int data) {
|
|
||||||
if (rotate) {
|
if (rotate) {
|
||||||
float swap = width;
|
float swap = width;
|
||||||
width = length;
|
width = length;
|
||||||
|
|
@ -1818,58 +1818,58 @@ bool TileRenderer::tesselateLeverInWorld(Tile* tt, int x, int y, int z) {
|
||||||
float u1 = tex->getU1(true);
|
float u1 = tex->getU1(true);
|
||||||
float v1 = tex->getV1(true);
|
float v1 = tex->getV1(true);
|
||||||
|
|
||||||
Vec3* corners[8];
|
std::array<Vec3, 8> corners;
|
||||||
float xv = 1.0f / 16.0f;
|
float xv = 1.0f / 16.0f;
|
||||||
float zv = 1.0f / 16.0f;
|
float zv = 1.0f / 16.0f;
|
||||||
float yv = 10.0f / 16.0f;
|
float yv = 10.0f / 16.0f;
|
||||||
corners[0] = Vec3::newTemp(-xv, -0, -zv);
|
corners[0] = Vec3(-xv, -0, -zv);
|
||||||
corners[1] = Vec3::newTemp(+xv, -0, -zv);
|
corners[1] = Vec3(+xv, -0, -zv);
|
||||||
corners[2] = Vec3::newTemp(+xv, -0, +zv);
|
corners[2] = Vec3(+xv, -0, +zv);
|
||||||
corners[3] = Vec3::newTemp(-xv, -0, +zv);
|
corners[3] = Vec3(-xv, -0, +zv);
|
||||||
corners[4] = Vec3::newTemp(-xv, +yv, -zv);
|
corners[4] = Vec3(-xv, +yv, -zv);
|
||||||
corners[5] = Vec3::newTemp(+xv, +yv, -zv);
|
corners[5] = Vec3(+xv, +yv, -zv);
|
||||||
corners[6] = Vec3::newTemp(+xv, +yv, +zv);
|
corners[6] = Vec3(+xv, +yv, +zv);
|
||||||
corners[7] = Vec3::newTemp(-xv, +yv, +zv);
|
corners[7] = Vec3(-xv, +yv, +zv);
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
if (flipped) {
|
if (flipped) {
|
||||||
corners[i]->z -= 1 / 16.0f;
|
corners[i].z -= 1 / 16.0f;
|
||||||
corners[i]->xRot(40 * PI / 180);
|
corners[i].xRot(40 * PI / 180);
|
||||||
} else {
|
} else {
|
||||||
corners[i]->z += 1 / 16.0f;
|
corners[i].z += 1 / 16.0f;
|
||||||
corners[i]->xRot(-40 * PI / 180);
|
corners[i].xRot(-40 * PI / 180);
|
||||||
}
|
}
|
||||||
if (dir == 0 || dir == 7) {
|
if (dir == 0 || dir == 7) {
|
||||||
corners[i]->zRot(180 * PI / 180);
|
corners[i].zRot(180 * PI / 180);
|
||||||
}
|
}
|
||||||
if (dir == 6 || dir == 0) {
|
if (dir == 6 || dir == 0) {
|
||||||
corners[i]->yRot(90 * PI / 180);
|
corners[i].yRot(90 * PI / 180);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dir > 0 && dir < 5) {
|
if (dir > 0 && dir < 5) {
|
||||||
corners[i]->y -= 6 / 16.0f;
|
corners[i].y -= 6 / 16.0f;
|
||||||
corners[i]->xRot(90 * PI / 180);
|
corners[i].xRot(90 * PI / 180);
|
||||||
|
|
||||||
if (dir == 4) corners[i]->yRot(0 * PI / 180);
|
if (dir == 4) corners[i].yRot(0 * PI / 180);
|
||||||
if (dir == 3) corners[i]->yRot(180 * PI / 180);
|
if (dir == 3) corners[i].yRot(180 * PI / 180);
|
||||||
if (dir == 2) corners[i]->yRot(90 * PI / 180);
|
if (dir == 2) corners[i].yRot(90 * PI / 180);
|
||||||
if (dir == 1) corners[i]->yRot(-90 * PI / 180);
|
if (dir == 1) corners[i].yRot(-90 * PI / 180);
|
||||||
|
|
||||||
corners[i]->x += x + 0.5;
|
corners[i].x += x + 0.5;
|
||||||
corners[i]->y += y + 8 / 16.0f;
|
corners[i].y += y + 8 / 16.0f;
|
||||||
corners[i]->z += z + 0.5;
|
corners[i].z += z + 0.5;
|
||||||
} else if (dir == 0 || dir == 7) {
|
} else if (dir == 0 || dir == 7) {
|
||||||
corners[i]->x += x + 0.5;
|
corners[i].x += x + 0.5;
|
||||||
corners[i]->y += y + 14 / 16.0f;
|
corners[i].y += y + 14 / 16.0f;
|
||||||
corners[i]->z += z + 0.5;
|
corners[i].z += z + 0.5;
|
||||||
} else {
|
} else {
|
||||||
corners[i]->x += x + 0.5;
|
corners[i].x += x + 0.5;
|
||||||
corners[i]->y += y + 2 / 16.0f;
|
corners[i].y += y + 2 / 16.0f;
|
||||||
corners[i]->z += z + 0.5;
|
corners[i].z += z + 0.5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3 *c0 = NULL, *c1 = NULL, *c2 = NULL, *c3 = NULL;
|
Vec3 c0, c1, c2, c3;
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
u0 = tex->getU(7, true);
|
u0 = tex->getU(7, true);
|
||||||
|
|
@ -1913,13 +1913,13 @@ bool TileRenderer::tesselateLeverInWorld(Tile* tt, int x, int y, int z) {
|
||||||
c2 = corners[7];
|
c2 = corners[7];
|
||||||
c3 = corners[4];
|
c3 = corners[4];
|
||||||
}
|
}
|
||||||
t->vertexUV((float)(c0->x), (float)(c0->y), (float)(c0->z), (float)(u0),
|
t->vertexUV((float)(c0.x), (float)(c0.y), (float)(c0.z), (float)(u0),
|
||||||
(float)(v1));
|
(float)(v1));
|
||||||
t->vertexUV((float)(c1->x), (float)(c1->y), (float)(c1->z), (float)(u1),
|
t->vertexUV((float)(c1.x), (float)(c1.y), (float)(c1.z), (float)(u1),
|
||||||
(float)(v1));
|
(float)(v1));
|
||||||
t->vertexUV((float)(c2->x), (float)(c2->y), (float)(c2->z), (float)(u1),
|
t->vertexUV((float)(c2.x), (float)(c2.y), (float)(c2.z), (float)(u1),
|
||||||
(float)(v0));
|
(float)(v0));
|
||||||
t->vertexUV((float)(c3->x), (float)(c3->y), (float)(c3->z), (float)(u0),
|
t->vertexUV((float)(c3.x), (float)(c3.y), (float)(c3.z), (float)(u0),
|
||||||
(float)(v0));
|
(float)(v0));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1977,46 +1977,46 @@ bool TileRenderer::tesselateTripwireSourceInWorld(Tile* tt, int x, int y,
|
||||||
double u1 = tex->getU1();
|
double u1 = tex->getU1();
|
||||||
double v1 = tex->getV1();
|
double v1 = tex->getV1();
|
||||||
|
|
||||||
Vec3* corners[8];
|
std::array<Vec3, 8> corners;
|
||||||
float stickWidth = 0.75f / 16.0f;
|
float stickWidth = 0.75f / 16.0f;
|
||||||
float stickHeight = 0.75f / 16.0f;
|
float stickHeight = 0.75f / 16.0f;
|
||||||
float stickLength = 5 / 16.0f;
|
float stickLength = 5 / 16.0f;
|
||||||
corners[0] = Vec3::newTemp(-stickWidth, -0, -stickHeight);
|
corners[0] = Vec3(-stickWidth, -0, -stickHeight);
|
||||||
corners[1] = Vec3::newTemp(+stickWidth, -0, -stickHeight);
|
corners[1] = Vec3(+stickWidth, -0, -stickHeight);
|
||||||
corners[2] = Vec3::newTemp(+stickWidth, -0, +stickHeight);
|
corners[2] = Vec3(+stickWidth, -0, +stickHeight);
|
||||||
corners[3] = Vec3::newTemp(-stickWidth, -0, +stickHeight);
|
corners[3] = Vec3(-stickWidth, -0, +stickHeight);
|
||||||
corners[4] = Vec3::newTemp(-stickWidth, +stickLength, -stickHeight);
|
corners[4] = Vec3(-stickWidth, +stickLength, -stickHeight);
|
||||||
corners[5] = Vec3::newTemp(+stickWidth, +stickLength, -stickHeight);
|
corners[5] = Vec3(+stickWidth, +stickLength, -stickHeight);
|
||||||
corners[6] = Vec3::newTemp(+stickWidth, +stickLength, +stickHeight);
|
corners[6] = Vec3(+stickWidth, +stickLength, +stickHeight);
|
||||||
corners[7] = Vec3::newTemp(-stickWidth, +stickLength, +stickHeight);
|
corners[7] = Vec3(-stickWidth, +stickLength, +stickHeight);
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
corners[i]->z += 1 / 16.0f;
|
corners[i].z += 1 / 16.0f;
|
||||||
|
|
||||||
if (powered) {
|
if (powered) {
|
||||||
corners[i]->xRot(30 * PI / 180);
|
corners[i].xRot(30 * PI / 180);
|
||||||
corners[i]->y -= 7 / 16.0f;
|
corners[i].y -= 7 / 16.0f;
|
||||||
} else if (attached) {
|
} else if (attached) {
|
||||||
corners[i]->xRot(5 * PI / 180);
|
corners[i].xRot(5 * PI / 180);
|
||||||
corners[i]->y -= 7 / 16.0f;
|
corners[i].y -= 7 / 16.0f;
|
||||||
} else {
|
} else {
|
||||||
corners[i]->xRot(-40 * PI / 180);
|
corners[i].xRot(-40 * PI / 180);
|
||||||
corners[i]->y -= 6 / 16.0f;
|
corners[i].y -= 6 / 16.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
corners[i]->xRot(90 * PI / 180);
|
corners[i].xRot(90 * PI / 180);
|
||||||
|
|
||||||
if (dir == Direction::NORTH) corners[i]->yRot(0 * PI / 180);
|
if (dir == Direction::NORTH) corners[i].yRot(0 * PI / 180);
|
||||||
if (dir == Direction::SOUTH) corners[i]->yRot(180 * PI / 180);
|
if (dir == Direction::SOUTH) corners[i].yRot(180 * PI / 180);
|
||||||
if (dir == Direction::WEST) corners[i]->yRot(90 * PI / 180);
|
if (dir == Direction::WEST) corners[i].yRot(90 * PI / 180);
|
||||||
if (dir == Direction::EAST) corners[i]->yRot(-90 * PI / 180);
|
if (dir == Direction::EAST) corners[i].yRot(-90 * PI / 180);
|
||||||
|
|
||||||
corners[i]->x += x + 0.5;
|
corners[i].x += x + 0.5;
|
||||||
corners[i]->y += y + 5 / 16.0f;
|
corners[i].y += y + 5 / 16.0f;
|
||||||
corners[i]->z += z + 0.5;
|
corners[i].z += z + 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3 *c0 = NULL, *c1 = NULL, *c2 = NULL, *c3 = NULL;
|
Vec3 c0, c1, c2, c3;
|
||||||
int stickX0 = 7;
|
int stickX0 = 7;
|
||||||
int stickX1 = 9;
|
int stickX1 = 9;
|
||||||
int stickY0 = 9;
|
int stickY0 = 9;
|
||||||
|
|
@ -2062,47 +2062,47 @@ bool TileRenderer::tesselateTripwireSourceInWorld(Tile* tt, int x, int y,
|
||||||
c2 = corners[7];
|
c2 = corners[7];
|
||||||
c3 = corners[4];
|
c3 = corners[4];
|
||||||
}
|
}
|
||||||
t->vertexUV(c0->x, c0->y, c0->z, u0, v1);
|
t->vertexUV(c0.x, c0.y, c0.z, u0, v1);
|
||||||
t->vertexUV(c1->x, c1->y, c1->z, u1, v1);
|
t->vertexUV(c1.x, c1.y, c1.z, u1, v1);
|
||||||
t->vertexUV(c2->x, c2->y, c2->z, u1, v0);
|
t->vertexUV(c2.x, c2.y, c2.z, u1, v0);
|
||||||
t->vertexUV(c3->x, c3->y, c3->z, u0, v0);
|
t->vertexUV(c3.x, c3.y, c3.z, u0, v0);
|
||||||
}
|
}
|
||||||
|
|
||||||
float hoopWidth = 1.5f / 16.0f;
|
float hoopWidth = 1.5f / 16.0f;
|
||||||
float hoopHeight = 1.5f / 16.0f;
|
float hoopHeight = 1.5f / 16.0f;
|
||||||
float hoopLength = 0.5f / 16.0f;
|
float hoopLength = 0.5f / 16.0f;
|
||||||
corners[0] = Vec3::newTemp(-hoopWidth, -0, -hoopHeight);
|
corners[0] = Vec3(-hoopWidth, -0, -hoopHeight);
|
||||||
corners[1] = Vec3::newTemp(+hoopWidth, -0, -hoopHeight);
|
corners[1] = Vec3(+hoopWidth, -0, -hoopHeight);
|
||||||
corners[2] = Vec3::newTemp(+hoopWidth, -0, +hoopHeight);
|
corners[2] = Vec3(+hoopWidth, -0, +hoopHeight);
|
||||||
corners[3] = Vec3::newTemp(-hoopWidth, -0, +hoopHeight);
|
corners[3] = Vec3(-hoopWidth, -0, +hoopHeight);
|
||||||
corners[4] = Vec3::newTemp(-hoopWidth, +hoopLength, -hoopHeight);
|
corners[4] = Vec3(-hoopWidth, +hoopLength, -hoopHeight);
|
||||||
corners[5] = Vec3::newTemp(+hoopWidth, +hoopLength, -hoopHeight);
|
corners[5] = Vec3(+hoopWidth, +hoopLength, -hoopHeight);
|
||||||
corners[6] = Vec3::newTemp(+hoopWidth, +hoopLength, +hoopHeight);
|
corners[6] = Vec3(+hoopWidth, +hoopLength, +hoopHeight);
|
||||||
corners[7] = Vec3::newTemp(-hoopWidth, +hoopLength, +hoopHeight);
|
corners[7] = Vec3(-hoopWidth, +hoopLength, +hoopHeight);
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
corners[i]->z += 3.5f / 16.0f;
|
corners[i].z += 3.5f / 16.0f;
|
||||||
|
|
||||||
if (powered) {
|
if (powered) {
|
||||||
corners[i]->y -= 1.5 / 16.0f;
|
corners[i].y -= 1.5 / 16.0f;
|
||||||
corners[i]->z -= 2.6 / 16.0f;
|
corners[i].z -= 2.6 / 16.0f;
|
||||||
corners[i]->xRot(0 * PI / 180);
|
corners[i].xRot(0 * PI / 180);
|
||||||
} else if (attached) {
|
} else if (attached) {
|
||||||
corners[i]->y += 0.25 / 16.0f;
|
corners[i].y += 0.25 / 16.0f;
|
||||||
corners[i]->z -= 2.75 / 16.0f;
|
corners[i].z -= 2.75 / 16.0f;
|
||||||
corners[i]->xRot(10 * PI / 180);
|
corners[i].xRot(10 * PI / 180);
|
||||||
} else {
|
} else {
|
||||||
corners[i]->xRot(50 * PI / 180);
|
corners[i].xRot(50 * PI / 180);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dir == Direction::NORTH) corners[i]->yRot(0 * PI / 180);
|
if (dir == Direction::NORTH) corners[i].yRot(0 * PI / 180);
|
||||||
if (dir == Direction::SOUTH) corners[i]->yRot(180 * PI / 180);
|
if (dir == Direction::SOUTH) corners[i].yRot(180 * PI / 180);
|
||||||
if (dir == Direction::WEST) corners[i]->yRot(90 * PI / 180);
|
if (dir == Direction::WEST) corners[i].yRot(90 * PI / 180);
|
||||||
if (dir == Direction::EAST) corners[i]->yRot(-90 * PI / 180);
|
if (dir == Direction::EAST) corners[i].yRot(-90 * PI / 180);
|
||||||
|
|
||||||
corners[i]->x += x + 0.5;
|
corners[i].x += x + 0.5;
|
||||||
corners[i]->y += y + 5 / 16.0f;
|
corners[i].y += y + 5 / 16.0f;
|
||||||
corners[i]->z += z + 0.5;
|
corners[i].z += z + 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hoopX0 = 5;
|
int hoopX0 = 5;
|
||||||
|
|
@ -2150,14 +2150,14 @@ bool TileRenderer::tesselateTripwireSourceInWorld(Tile* tt, int x, int y,
|
||||||
c2 = corners[7];
|
c2 = corners[7];
|
||||||
c3 = corners[4];
|
c3 = corners[4];
|
||||||
}
|
}
|
||||||
t->vertexUV(c0->x, c0->y, c0->z, u0, v1);
|
t->vertexUV(c0.x, c0.y, c0.z, u0, v1);
|
||||||
t->vertexUV(c1->x, c1->y, c1->z, u1, v1);
|
t->vertexUV(c1.x, c1.y, c1.z, u1, v1);
|
||||||
t->vertexUV(c2->x, c2->y, c2->z, u1, v0);
|
t->vertexUV(c2.x, c2.y, c2.z, u1, v0);
|
||||||
t->vertexUV(c3->x, c3->y, c3->z, u0, v0);
|
t->vertexUV(c3.x, c3.y, c3.z, u0, v0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attached) {
|
if (attached) {
|
||||||
double hoopBottomY = corners[0]->y;
|
double hoopBottomY = corners[0].y;
|
||||||
float width = 0.5f / 16.0f;
|
float width = 0.5f / 16.0f;
|
||||||
float top = 0.5f - (width / 2);
|
float top = 0.5f - (width / 2);
|
||||||
float bottom = top + width;
|
float bottom = top + width;
|
||||||
|
|
@ -4068,9 +4068,11 @@ bool TileRenderer::tesselateCrossInWorld(Tile* tt, int x, int y, int z) {
|
||||||
float zt = (float)z;
|
float zt = (float)z;
|
||||||
|
|
||||||
if (tt == Tile::tallgrass) {
|
if (tt == Tile::tallgrass) {
|
||||||
// 4jcraft add a bunch of casts to prevent overflow (i pray to god)
|
// 4jcraft add a bunch of casts to prevent overflow (i pray to god)
|
||||||
int64_t seed = ((int64_t)x * 3129871) ^ ((int64_t)z * 116129781L) ^ ((int64_t)y);
|
int64_t seed =
|
||||||
seed = (int64_t)(((uint64_t)seed * (uint64_t)seed * 42317861ULL) + ((uint64_t)seed * 11ULL));
|
((int64_t)x * 3129871) ^ ((int64_t)z * 116129781L) ^ ((int64_t)y);
|
||||||
|
seed = (int64_t)(((uint64_t)seed * (uint64_t)seed * 42317861ULL) +
|
||||||
|
((uint64_t)seed * 11ULL));
|
||||||
|
|
||||||
xt += ((((seed >> 16) & 0xf) / 15.0f) - 0.5f) * 0.5f;
|
xt += ((((seed >> 16) & 0xf) / 15.0f) - 0.5f) * 0.5f;
|
||||||
yt += ((((seed >> 20) & 0xf) / 15.0f) - 1.0f) * 0.2f;
|
yt += ((((seed >> 20) & 0xf) / 15.0f) - 1.0f) * 0.2f;
|
||||||
|
|
@ -4326,8 +4328,10 @@ bool TileRenderer::tesselateLilypadInWorld(Tile* tt, int x, int y, int z) {
|
||||||
float v1 = tex->getV1(true);
|
float v1 = tex->getV1(true);
|
||||||
|
|
||||||
// 4jcraft add a bunch of casts to prevent overflow (i pray to god)
|
// 4jcraft add a bunch of casts to prevent overflow (i pray to god)
|
||||||
int64_t seed = ((int64_t)x * 3129871) ^ ((int64_t)z * 116129781L) ^ ((int64_t)y);
|
int64_t seed =
|
||||||
seed = (int64_t)(((uint64_t)seed * (uint64_t)seed * 42317861ULL) + ((uint64_t)seed * 11ULL));
|
((int64_t)x * 3129871) ^ ((int64_t)z * 116129781L) ^ ((int64_t)y);
|
||||||
|
seed = (int64_t)(((uint64_t)seed * (uint64_t)seed * 42317861ULL) +
|
||||||
|
((uint64_t)seed * 11ULL));
|
||||||
|
|
||||||
int dir = (int)((seed >> 16) & 0x3);
|
int dir = (int)((seed >> 16) & 0x3);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ GameRenderer::GameRenderer(Minecraft* mc) {
|
||||||
tickSmoothYO = 0;
|
tickSmoothYO = 0;
|
||||||
lastTickA = 0;
|
lastTickA = 0;
|
||||||
|
|
||||||
cameraPos = Vec3::newPermanent(0.0f, 0.0f, 0.0f);
|
cameraPos = Vec3(0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
fovOffset = 0;
|
fovOffset = 0;
|
||||||
fovOffsetO = 0;
|
fovOffsetO = 0;
|
||||||
|
|
@ -291,7 +291,7 @@ void GameRenderer::pick(float a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
double dist = range;
|
double dist = range;
|
||||||
Vec3* from = mc->cameraTargetPlayer->getPos(a);
|
Vec3 from = mc->cameraTargetPlayer->getPos(a);
|
||||||
|
|
||||||
if (mc->gameMode->hasFarPickRange()) {
|
if (mc->gameMode->hasFarPickRange()) {
|
||||||
dist = range = 6;
|
dist = range = 6;
|
||||||
|
|
@ -301,17 +301,18 @@ void GameRenderer::pick(float a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mc->hitResult != NULL) {
|
if (mc->hitResult != NULL) {
|
||||||
dist = mc->hitResult->pos->distanceTo(from);
|
dist = mc->hitResult->pos.distanceTo(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* b = mc->cameraTargetPlayer->getViewVector(a);
|
Vec3 b = mc->cameraTargetPlayer->getViewVector(a);
|
||||||
Vec3* to = from->add(b->x * range, b->y * range, b->z * range);
|
Vec3 to(b.x * range, b.y * range, b.z * range);
|
||||||
|
to = to.add(from.x, from.y, from.z);
|
||||||
hovered = nullptr;
|
hovered = nullptr;
|
||||||
float overlap = 1;
|
float overlap = 1;
|
||||||
std::vector<std::shared_ptr<Entity> >* objects = mc->level->getEntities(
|
std::vector<std::shared_ptr<Entity> >* objects = mc->level->getEntities(
|
||||||
mc->cameraTargetPlayer,
|
mc->cameraTargetPlayer,
|
||||||
mc->cameraTargetPlayer->bb
|
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));
|
->grow(overlap, overlap, overlap));
|
||||||
double nearest = dist;
|
double nearest = dist;
|
||||||
|
|
||||||
|
|
@ -322,14 +323,14 @@ void GameRenderer::pick(float a) {
|
||||||
|
|
||||||
float rr = e->getPickRadius();
|
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);
|
HitResult* p = bb->clip(&from, &to);
|
||||||
if (bb->contains(from)) {
|
if (bb->contains(&from)) {
|
||||||
if (0 < nearest || nearest == 0) {
|
if (0 < nearest || nearest == 0) {
|
||||||
hovered = e;
|
hovered = e;
|
||||||
nearest = 0;
|
nearest = 0;
|
||||||
}
|
}
|
||||||
} else if (p != NULL) {
|
} else if (p != NULL) {
|
||||||
double dd = from->distanceTo(p->pos);
|
double dd = from.distanceTo(p->pos);
|
||||||
std::shared_ptr<Entity> ridingEntity =
|
std::shared_ptr<Entity> ridingEntity =
|
||||||
mc->cameraTargetPlayer->riding;
|
mc->cameraTargetPlayer->riding;
|
||||||
// 4jcraft: compare the mounted entity explicitly so riding the hit
|
// 4jcraft: compare the mounted entity explicitly so riding the hit
|
||||||
|
|
@ -523,11 +524,12 @@ void GameRenderer::moveCameraToPlayer(float a) {
|
||||||
|
|
||||||
// 4J - corrected bug here where zo was also added to x
|
// 4J - corrected bug here where zo was also added to x
|
||||||
// component
|
// component
|
||||||
HitResult* hr = mc->level->clip(
|
Vec3 a(x + xo, y + yo, z + zo);
|
||||||
Vec3::newTemp(x + xo, y + yo, z + zo),
|
Vec3 b(x - xd + xo, y - yd + yo, z - zd + zo);
|
||||||
Vec3::newTemp(x - xd + xo, y - yd + yo, z - zd + zo));
|
HitResult* hr = mc->level->clip(&a, &b);
|
||||||
if (hr != NULL) {
|
if (hr != NULL) {
|
||||||
double dist = hr->pos->distanceTo(Vec3::newTemp(x, y, z));
|
Vec3 p(x, y, z);
|
||||||
|
double dist = hr->pos.distanceTo(p);
|
||||||
if (dist < cameraDist) cameraDist = dist;
|
if (dist < cameraDist) cameraDist = dist;
|
||||||
delete hr;
|
delete hr;
|
||||||
}
|
}
|
||||||
|
|
@ -1113,7 +1115,6 @@ void GameRenderer::FinishedReassigning() {
|
||||||
|
|
||||||
int GameRenderer::runUpdate(void* lpParam) {
|
int GameRenderer::runUpdate(void* lpParam) {
|
||||||
Minecraft* minecraft = Minecraft::GetInstance();
|
Minecraft* minecraft = Minecraft::GetInstance();
|
||||||
Vec3::CreateNewThreadStorage();
|
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||||
Compression::UseDefaultThreadStorage();
|
Compression::UseDefaultThreadStorage();
|
||||||
|
|
@ -1194,7 +1195,6 @@ int GameRenderer::runUpdate(void* lpParam) {
|
||||||
// PIXEndNamedEvent();
|
// PIXEndNamedEvent();
|
||||||
|
|
||||||
AABB::resetPool();
|
AABB::resetPool();
|
||||||
Vec3::resetPool();
|
|
||||||
m_updateEvents->Set(eUpdateEventIsFinished);
|
m_updateEvents->Set(eUpdateEventIsFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1369,11 +1369,11 @@ void GameRenderer::renderLevel(float a, int64_t until) {
|
||||||
// storing the camera position Fix for #77745 - TU9: Content:
|
// storing the camera position Fix for #77745 - TU9: Content:
|
||||||
// Gameplay: Items and mobs not belonging to end world are
|
// Gameplay: Items and mobs not belonging to end world are
|
||||||
// disappearing when Enderdragon is damaged.
|
// disappearing when Enderdragon is damaged.
|
||||||
Vec3* cameraPosTemp = cameraEntity->getPos(a);
|
Vec3 cameraPosTemp = cameraEntity->getPos(a);
|
||||||
cameraPos->x = cameraPosTemp->x;
|
cameraPos.x = cameraPosTemp.x;
|
||||||
cameraPos->y = cameraPosTemp->y;
|
cameraPos.y = cameraPosTemp.y;
|
||||||
cameraPos->z = cameraPosTemp->z;
|
cameraPos.z = cameraPosTemp.z;
|
||||||
levelRenderer->renderEntities(cameraPos, frustum, a);
|
levelRenderer->renderEntities(&cameraPos, frustum, a);
|
||||||
#ifdef __PSVITA__
|
#ifdef __PSVITA__
|
||||||
// AP - make sure we're using the Alpha cut out effect for particles
|
// AP - make sure we're using the Alpha cut out effect for particles
|
||||||
glEnable(GL_ALPHA_TEST);
|
glEnable(GL_ALPHA_TEST);
|
||||||
|
|
@ -1853,21 +1853,20 @@ void GameRenderer::setupClearColor(float a) {
|
||||||
float whiteness = 1.0f / (4 - mc->options->viewDistance);
|
float whiteness = 1.0f / (4 - mc->options->viewDistance);
|
||||||
whiteness = 1 - (float)pow((double)whiteness, 0.25);
|
whiteness = 1 - (float)pow((double)whiteness, 0.25);
|
||||||
|
|
||||||
Vec3* skyColor = level->getSkyColor(mc->cameraTargetPlayer, a);
|
Vec3 skyColor = level->getSkyColor(mc->cameraTargetPlayer, a);
|
||||||
float sr = (float)skyColor->x;
|
float sr = (float)skyColor.x;
|
||||||
float sg = (float)skyColor->y;
|
float sg = (float)skyColor.y;
|
||||||
float sb = (float)skyColor->z;
|
float sb = (float)skyColor.z;
|
||||||
|
|
||||||
Vec3* fogColor = level->getFogColor(a);
|
Vec3 fogColor = level->getFogColor(a);
|
||||||
fr = (float)fogColor->x;
|
fr = (float)fogColor.x;
|
||||||
fg = (float)fogColor->y;
|
fg = (float)fogColor.y;
|
||||||
fb = (float)fogColor->z;
|
fb = (float)fogColor.z;
|
||||||
|
|
||||||
if (mc->options->viewDistance < 2) {
|
if (mc->options->viewDistance < 2) {
|
||||||
Vec3* sunAngle = Mth::sin(level->getSunAngle(a)) > 0
|
Vec3 sunAngle = Mth::sin(level->getSunAngle(a)) > 0 ? Vec3(-1, 0, 0)
|
||||||
? Vec3::newTemp(-1, 0, 0)
|
: Vec3(1, 0, 0);
|
||||||
: Vec3::newTemp(1, 0, 0);
|
float d = (float)player->getViewVector(a).dot(sunAngle);
|
||||||
float d = (float)player->getViewVector(a)->dot(sunAngle);
|
|
||||||
if (d < 0) d = 0;
|
if (d < 0) d = 0;
|
||||||
if (d > 0) {
|
if (d > 0) {
|
||||||
float* c =
|
float* c =
|
||||||
|
|
@ -1903,10 +1902,10 @@ void GameRenderer::setupClearColor(float a) {
|
||||||
|
|
||||||
int t = Camera::getBlockAt(mc->level, player, a);
|
int t = Camera::getBlockAt(mc->level, player, a);
|
||||||
if (isInClouds) {
|
if (isInClouds) {
|
||||||
Vec3* cc = level->getCloudColor(a);
|
Vec3 cc = level->getCloudColor(a);
|
||||||
fr = (float)cc->x;
|
fr = (float)cc.x;
|
||||||
fg = (float)cc->y;
|
fg = (float)cc.y;
|
||||||
fb = (float)cc->z;
|
fb = (float)cc.z;
|
||||||
} else if (t != 0 && Tile::tiles[t]->material == Material::water) {
|
} else if (t != 0 && Tile::tiles[t]->material == Material::water) {
|
||||||
float clearness = EnchantmentHelper::getOxygenBonus(player) * 0.2f;
|
float clearness = EnchantmentHelper::getOxygenBonus(player) * 0.2f;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ private:
|
||||||
float thirdTiltO;
|
float thirdTiltO;
|
||||||
float accumulatedSmoothXO, accumulatedSmoothYO;
|
float accumulatedSmoothXO, accumulatedSmoothYO;
|
||||||
float tickSmoothXO, tickSmoothYO, lastTickA;
|
float tickSmoothXO, tickSmoothYO, lastTickA;
|
||||||
Vec3* cameraPos; // 4J added
|
Vec3 cameraPos; // 4J added
|
||||||
|
|
||||||
// fov modification
|
// fov modification
|
||||||
float fovOffset;
|
float fovOffset;
|
||||||
|
|
|
||||||
|
|
@ -1035,10 +1035,10 @@ void LevelRenderer::renderSky(float alpha) {
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
int playerIndex = mc->player->GetXboxPad();
|
int playerIndex = mc->player->GetXboxPad();
|
||||||
Vec3* sc = level[playerIndex]->getSkyColor(mc->cameraTargetPlayer, alpha);
|
Vec3 sc = level[playerIndex]->getSkyColor(mc->cameraTargetPlayer, alpha);
|
||||||
float sr = (float)sc->x;
|
float sr = (float)sc.x;
|
||||||
float sg = (float)sc->y;
|
float sg = (float)sc.y;
|
||||||
float sb = (float)sc->z;
|
float sb = (float)sc.z;
|
||||||
|
|
||||||
if (mc->options->anaglyph3d) {
|
if (mc->options->anaglyph3d) {
|
||||||
float srr = (sr * 30 + sg * 59 + sb * 11) / 100;
|
float srr = (sr * 30 + sg * 59 + sb * 11) / 100;
|
||||||
|
|
@ -1185,7 +1185,7 @@ void LevelRenderer::renderSky(float alpha) {
|
||||||
glColor3f(0, 0, 0);
|
glColor3f(0, 0, 0);
|
||||||
|
|
||||||
double yy =
|
double yy =
|
||||||
mc->player->getPos(alpha)->y -
|
mc->player->getPos(alpha).y -
|
||||||
level[playerIndex]->getHorizonHeight(); // 4J - getHorizonHeight moved
|
level[playerIndex]->getHorizonHeight(); // 4J - getHorizonHeight moved
|
||||||
// forward from 1.2.3
|
// forward from 1.2.3
|
||||||
if (yy < 0) {
|
if (yy < 0) {
|
||||||
|
|
@ -1259,10 +1259,10 @@ void LevelRenderer::renderHaloRing(float alpha) {
|
||||||
|
|
||||||
int playerIndex = mc->player->GetXboxPad();
|
int playerIndex = mc->player->GetXboxPad();
|
||||||
|
|
||||||
Vec3* sc = level[playerIndex]->getSkyColor(mc->cameraTargetPlayer, alpha);
|
Vec3 sc = level[playerIndex]->getSkyColor(mc->cameraTargetPlayer, alpha);
|
||||||
float sr = (float)sc->x;
|
float sr = (float)sc.x;
|
||||||
float sg = (float)sc->y;
|
float sg = (float)sc.y;
|
||||||
float sb = (float)sc->z;
|
float sb = (float)sc.z;
|
||||||
|
|
||||||
// Rough lumninance calculation
|
// Rough lumninance calculation
|
||||||
float Y = (sr + sr + sb + sg + sg + sg) / 6;
|
float Y = (sr + sr + sb + sg + sg + sg) / 6;
|
||||||
|
|
@ -1335,10 +1335,10 @@ void LevelRenderer::renderClouds(float alpha) {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
Vec3* cc = level[playerIndex]->getCloudColor(alpha);
|
Vec3 cc = level[playerIndex]->getCloudColor(alpha);
|
||||||
float cr = (float)cc->x;
|
float cr = (float)cc.x;
|
||||||
float cg = (float)cc->y;
|
float cg = (float)cc.y;
|
||||||
float cb = (float)cc->z;
|
float cb = (float)cc.z;
|
||||||
|
|
||||||
if (mc->options->anaglyph3d) {
|
if (mc->options->anaglyph3d) {
|
||||||
float crr = (cr * 30 + cg * 59 + cb * 11) / 100;
|
float crr = (cr * 30 + cg * 59 + cb * 11) / 100;
|
||||||
|
|
@ -1632,10 +1632,10 @@ void LevelRenderer::renderAdvancedClouds(float alpha) {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
Vec3* cc = level[playerIndex]->getCloudColor(alpha);
|
Vec3 cc = level[playerIndex]->getCloudColor(alpha);
|
||||||
float cr = (float)cc->x;
|
float cr = (float)cc.x;
|
||||||
float cg = (float)cc->y;
|
float cg = (float)cc.y;
|
||||||
float cb = (float)cc->z;
|
float cb = (float)cc.z;
|
||||||
|
|
||||||
if (mc->options->anaglyph3d) {
|
if (mc->options->anaglyph3d) {
|
||||||
float crr = (cr * 30 + cg * 59 + cb * 11) / 100;
|
float crr = (cr * 30 + cg * 59 + cb * 11) / 100;
|
||||||
|
|
@ -4039,7 +4039,6 @@ void LevelRenderer::staticCtor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int LevelRenderer::rebuildChunkThreadProc(void* lpParam) {
|
int LevelRenderer::rebuildChunkThreadProc(void* lpParam) {
|
||||||
Vec3::CreateNewThreadStorage();
|
|
||||||
AABB::CreateNewThreadStorage();
|
AABB::CreateNewThreadStorage();
|
||||||
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
Tesselator::CreateNewThreadStorage(1024 * 1024);
|
||||||
RenderManager.InitialiseContext();
|
RenderManager.InitialiseContext();
|
||||||
|
|
|
||||||
|
|
@ -22,14 +22,16 @@ void Lighting::turnOn() {
|
||||||
float d = 0.6f;
|
float d = 0.6f;
|
||||||
float s = 0.0f;
|
float s = 0.0f;
|
||||||
|
|
||||||
Vec3* l = Vec3::newTemp(0.2f, 1.0f, -0.7f)->normalize();
|
Vec3 l(0.2f, 1.0f, -0.7f);
|
||||||
glLight(GL_LIGHT0, GL_POSITION, getBuffer(l->x, l->y, l->z, 0));
|
l = l.normalize();
|
||||||
|
glLight(GL_LIGHT0, GL_POSITION, getBuffer(l.x, l.y, l.z, 0));
|
||||||
glLight(GL_LIGHT0, GL_DIFFUSE, getBuffer(d, d, d, 1));
|
glLight(GL_LIGHT0, GL_DIFFUSE, getBuffer(d, d, d, 1));
|
||||||
glLight(GL_LIGHT0, GL_AMBIENT, getBuffer(0.0f, 0.0f, 0.0f, 1.0f));
|
glLight(GL_LIGHT0, GL_AMBIENT, getBuffer(0.0f, 0.0f, 0.0f, 1.0f));
|
||||||
glLight(GL_LIGHT0, GL_SPECULAR, getBuffer(s, s, s, 1.0f));
|
glLight(GL_LIGHT0, GL_SPECULAR, getBuffer(s, s, s, 1.0f));
|
||||||
|
|
||||||
l = Vec3::newTemp(-0.2f, 1.0f, 0.7f)->normalize();
|
l = Vec3(-0.2f, 1.0f, 0.7f);
|
||||||
glLight(GL_LIGHT1, GL_POSITION, getBuffer(l->x, l->y, l->z, 0));
|
l = l.normalize();
|
||||||
|
glLight(GL_LIGHT1, GL_POSITION, getBuffer(l.x, l.y, l.z, 0));
|
||||||
glLight(GL_LIGHT1, GL_DIFFUSE, getBuffer(d, d, d, 1));
|
glLight(GL_LIGHT1, GL_DIFFUSE, getBuffer(d, d, d, 1));
|
||||||
glLight(GL_LIGHT1, GL_AMBIENT, getBuffer(0.0f, 0.0f, 0.0f, 1.0f));
|
glLight(GL_LIGHT1, GL_AMBIENT, getBuffer(0.0f, 0.0f, 0.0f, 1.0f));
|
||||||
glLight(GL_LIGHT1, GL_SPECULAR, getBuffer(s, s, s, 1.0f));
|
glLight(GL_LIGHT1, GL_SPECULAR, getBuffer(s, s, s, 1.0f));
|
||||||
|
|
|
||||||
|
|
@ -45,21 +45,21 @@ void _Polygon::mirror() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _Polygon::render(Tesselator* t, float scale) {
|
void _Polygon::render(Tesselator* t, float scale) {
|
||||||
Vec3* v0 = vertices[1]->pos->vectorTo(vertices[0]->pos);
|
Vec3 v0 = vertices[1]->pos.vectorTo(vertices[0]->pos);
|
||||||
Vec3* v1 = vertices[1]->pos->vectorTo(vertices[2]->pos);
|
Vec3 v1 = vertices[1]->pos.vectorTo(vertices[2]->pos);
|
||||||
Vec3* n = v1->cross(v0)->normalize();
|
Vec3 n = v1.cross(v0).normalize();
|
||||||
|
|
||||||
t->begin();
|
t->begin();
|
||||||
if (_flipNormal) {
|
if (_flipNormal) {
|
||||||
t->normal(-(float)n->x, -(float)n->y, -(float)n->z);
|
t->normal(-(float)n.x, -(float)n.y, -(float)n.z);
|
||||||
} else {
|
} else {
|
||||||
t->normal((float)n->x, (float)n->y, (float)n->z);
|
t->normal((float)n.x, (float)n.y, (float)n.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
Vertex* v = vertices[i];
|
Vertex* v = vertices[i];
|
||||||
t->vertexUV((float)(v->pos->x * scale), (float)(v->pos->y * scale),
|
t->vertexUV((float)(v->pos.x * scale), (float)(v->pos.y * scale),
|
||||||
(float)(v->pos->z * scale), (float)(v->u), (float)(v->v));
|
(float)(v->pos.z * scale), (float)(v->u), (float)(v->v));
|
||||||
}
|
}
|
||||||
t->end();
|
t->end();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#include "Vertex.h"
|
#include "Vertex.h"
|
||||||
|
|
||||||
Vertex::Vertex(float x, float y, float z, float u, float v) {
|
Vertex::Vertex(float x, float y, float z, float u, float v) {
|
||||||
this->pos = Vec3::newPermanent(x, y, z);
|
this->pos = Vec3(x, y, z);
|
||||||
this->u = u;
|
this->u = u;
|
||||||
this->v = v;
|
this->v = v;
|
||||||
}
|
}
|
||||||
|
|
@ -16,7 +16,7 @@ Vertex::Vertex(Vertex* vertex, float u, float v) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Vertex::Vertex(Vec3* pos, float u, float v) {
|
Vertex::Vertex(Vec3* pos, float u, float v) {
|
||||||
this->pos = pos;
|
this->pos = *pos;
|
||||||
this->u = u;
|
this->u = u;
|
||||||
this->v = v;
|
this->v = v;
|
||||||
}
|
}
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
class Vertex {
|
class Vertex {
|
||||||
public:
|
public:
|
||||||
Vec3* pos;
|
Vec3 pos;
|
||||||
float u, v;
|
float u, v;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -64,18 +64,18 @@ bool AvoidPlayerGoal::canUse() {
|
||||||
delete entities;
|
delete entities;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* pos = RandomPos::getPosAvoid(
|
Vec3 avoid_pos(toAvoid.lock()->x, toAvoid.lock()->y, toAvoid.lock()->z);
|
||||||
|
auto pos = RandomPos::getPosAvoid(
|
||||||
std::dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 16,
|
std::dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 16,
|
||||||
7,
|
7, &avoid_pos);
|
||||||
Vec3::newTemp(toAvoid.lock()->x, toAvoid.lock()->y, toAvoid.lock()->z));
|
if (!pos.has_value()) return false;
|
||||||
if (pos == NULL) return false;
|
|
||||||
if (toAvoid.lock()->distanceToSqr(pos->x, pos->y, pos->z) <
|
if (toAvoid.lock()->distanceToSqr(pos->x, pos->y, pos->z) <
|
||||||
toAvoid.lock()->distanceToSqr(mob->shared_from_this()))
|
toAvoid.lock()->distanceToSqr(mob->shared_from_this()))
|
||||||
return false;
|
return false;
|
||||||
delete path;
|
delete path;
|
||||||
path = pathNav->createPath(pos->x, pos->y, pos->z);
|
path = pathNav->createPath(pos->x, pos->y, pos->z);
|
||||||
if (path == NULL) return false;
|
if (path == NULL) return false;
|
||||||
if (!path->endsInXZ(pos)) return false;
|
if (!path->endsInXZ(&*pos)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
#include "../../Headers/net.minecraft.world.level.h"
|
#include "../../Headers/net.minecraft.world.level.h"
|
||||||
#include "../../Headers/net.minecraft.world.phys.h"
|
#include "../../Headers/net.minecraft.world.phys.h"
|
||||||
#include "FleeSunGoal.h"
|
#include "FleeSunGoal.h"
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
FleeSunGoal::FleeSunGoal(PathfinderMob* mob, double speedModifier) {
|
FleeSunGoal::FleeSunGoal(PathfinderMob* mob, double speedModifier) {
|
||||||
this->mob = mob;
|
this->mob = mob;
|
||||||
|
|
@ -20,8 +21,8 @@ bool FleeSunGoal::canUse() {
|
||||||
Mth::floor(mob->z)))
|
Mth::floor(mob->z)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Vec3* pos = getHidePos();
|
auto pos = getHidePos();
|
||||||
if (pos == NULL) return false;
|
if (!pos.has_value()) return false;
|
||||||
wantedX = pos->x;
|
wantedX = pos->x;
|
||||||
wantedY = pos->y;
|
wantedY = pos->y;
|
||||||
wantedZ = pos->z;
|
wantedZ = pos->z;
|
||||||
|
|
@ -34,7 +35,7 @@ void FleeSunGoal::start() {
|
||||||
mob->getNavigation()->moveTo(wantedX, wantedY, wantedZ, speedModifier);
|
mob->getNavigation()->moveTo(wantedX, wantedY, wantedZ, speedModifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* FleeSunGoal::getHidePos() {
|
std::optional<Vec3> FleeSunGoal::getHidePos() {
|
||||||
Random* random = mob->getRandom();
|
Random* random = mob->getRandom();
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
int xt = Mth::floor(mob->x + random->nextInt(20) - 10);
|
int xt = Mth::floor(mob->x + random->nextInt(20) - 10);
|
||||||
|
|
@ -42,7 +43,7 @@ Vec3* FleeSunGoal::getHidePos() {
|
||||||
int zt = Mth::floor(mob->z + random->nextInt(20) - 10);
|
int zt = Mth::floor(mob->z + random->nextInt(20) - 10);
|
||||||
if (!level->canSeeSky(xt, yt, zt) &&
|
if (!level->canSeeSky(xt, yt, zt) &&
|
||||||
mob->getWalkTargetValue(xt, yt, zt) < 0)
|
mob->getWalkTargetValue(xt, yt, zt) < 0)
|
||||||
return Vec3::newTemp(xt, yt, zt);
|
return Vec3(xt, yt, zt);
|
||||||
}
|
}
|
||||||
return NULL;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
#include "../../Util/Vec3.h"
|
||||||
#include "Goal.h"
|
#include "Goal.h"
|
||||||
|
|
||||||
class FleeSunGoal : public Goal {
|
class FleeSunGoal : public Goal {
|
||||||
|
|
@ -17,7 +20,7 @@ public:
|
||||||
virtual void start();
|
virtual void start();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vec3* getHidePos();
|
std::optional<Vec3> getHidePos();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 4J Added override to update ai elements when loading entity from
|
// 4J Added override to update ai elements when loading entity from
|
||||||
|
|
|
||||||
|
|
@ -44,13 +44,12 @@ void MoveIndoorsGoal::start() {
|
||||||
}
|
}
|
||||||
if (mob->distanceToSqr(_doorInfo->getIndoorX(), _doorInfo->y,
|
if (mob->distanceToSqr(_doorInfo->getIndoorX(), _doorInfo->y,
|
||||||
_doorInfo->getIndoorZ()) > 16 * 16) {
|
_doorInfo->getIndoorZ()) > 16 * 16) {
|
||||||
Vec3* pos = RandomPos::getPosTowards(
|
Vec3 towards(_doorInfo->getIndoorX() + 0.5, _doorInfo->getIndoorY(),
|
||||||
|
_doorInfo->getIndoorZ() + 0.5);
|
||||||
|
auto pos = RandomPos::getPosTowards(
|
||||||
std::dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()),
|
std::dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()),
|
||||||
14, 3,
|
14, 3, &towards);
|
||||||
Vec3::newTemp(_doorInfo->getIndoorX() + 0.5,
|
if (pos.has_value())
|
||||||
_doorInfo->getIndoorY(),
|
|
||||||
_doorInfo->getIndoorZ() + 0.5));
|
|
||||||
if (pos != NULL)
|
|
||||||
mob->getNavigation()->moveTo(pos->x, pos->y, pos->z, 1.0f);
|
mob->getNavigation()->moveTo(pos->x, pos->y, pos->z, 1.0f);
|
||||||
} else
|
} else
|
||||||
mob->getNavigation()->moveTo(_doorInfo->getIndoorX() + 0.5,
|
mob->getNavigation()->moveTo(_doorInfo->getIndoorX() + 0.5,
|
||||||
|
|
|
||||||
|
|
@ -47,10 +47,11 @@ bool MoveThroughVillageGoal::canUse() {
|
||||||
mob->getNavigation()->setCanOpenDoors(oldCanOpenDoors);
|
mob->getNavigation()->setCanOpenDoors(oldCanOpenDoors);
|
||||||
if (path != NULL) return true;
|
if (path != NULL) return true;
|
||||||
|
|
||||||
Vec3* pos = RandomPos::getPosTowards(
|
Vec3 towards(_doorInfo->x, _doorInfo->y, _doorInfo->z);
|
||||||
|
auto pos = RandomPos::getPosTowards(
|
||||||
std::dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 10,
|
std::dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 10,
|
||||||
7, Vec3::newTemp(_doorInfo->x, _doorInfo->y, _doorInfo->z));
|
7, &towards);
|
||||||
if (pos == NULL) return false;
|
if (!pos.has_value()) return false;
|
||||||
mob->getNavigation()->setCanOpenDoors(false);
|
mob->getNavigation()->setCanOpenDoors(false);
|
||||||
delete path;
|
delete path;
|
||||||
path = mob->getNavigation()->createPath(pos->x, pos->y, pos->z);
|
path = mob->getNavigation()->createPath(pos->x, pos->y, pos->z);
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,12 @@ MoveTowardsRestrictionGoal::MoveTowardsRestrictionGoal(PathfinderMob* mob,
|
||||||
|
|
||||||
bool MoveTowardsRestrictionGoal::canUse() {
|
bool MoveTowardsRestrictionGoal::canUse() {
|
||||||
if (mob->isWithinRestriction()) return false;
|
if (mob->isWithinRestriction()) return false;
|
||||||
Pos* towards = mob->getRestrictCenter();
|
Pos* toward = mob->getRestrictCenter();
|
||||||
Vec3* pos = RandomPos::getPosTowards(
|
Vec3 towards(toward->x, toward->y, toward->z);
|
||||||
|
auto pos = RandomPos::getPosTowards(
|
||||||
std::dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 16,
|
std::dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 16,
|
||||||
7, Vec3::newTemp(towards->x, towards->y, towards->z));
|
7, &towards);
|
||||||
if (pos == NULL) return false;
|
if (!pos.has_value()) return false;
|
||||||
wantedX = pos->x;
|
wantedX = pos->x;
|
||||||
wantedY = pos->y;
|
wantedY = pos->y;
|
||||||
wantedZ = pos->z;
|
wantedZ = pos->z;
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,11 @@ bool MoveTowardsTargetGoal::canUse() {
|
||||||
if (target.lock() == NULL) return false;
|
if (target.lock() == NULL) return false;
|
||||||
if (target.lock()->distanceToSqr(mob->shared_from_this()) > within * within)
|
if (target.lock()->distanceToSqr(mob->shared_from_this()) > within * within)
|
||||||
return false;
|
return false;
|
||||||
Vec3* pos = RandomPos::getPosTowards(
|
Vec3 towards(target.lock()->x, target.lock()->y, target.lock()->z);
|
||||||
|
auto pos = RandomPos::getPosTowards(
|
||||||
std::dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 16,
|
std::dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 16,
|
||||||
7, Vec3::newTemp(target.lock()->x, target.lock()->y, target.lock()->z));
|
7, &towards);
|
||||||
if (pos == NULL) return false;
|
if (!pos.has_value()) return false;
|
||||||
wantedX = pos->x;
|
wantedX = pos->x;
|
||||||
wantedY = pos->y;
|
wantedY = pos->y;
|
||||||
wantedZ = pos->z;
|
wantedZ = pos->z;
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,10 @@ bool PanicGoal::canUse() {
|
||||||
const int panicDuration = random.nextInt(41) + 60;
|
const int panicDuration = random.nextInt(41) + 60;
|
||||||
if (mob->tickCount - hurtTimeout > panicDuration) return false;
|
if (mob->tickCount - hurtTimeout > panicDuration) return false;
|
||||||
|
|
||||||
Vec3* pos = RandomPos::getPos(
|
auto pos = RandomPos::getPos(
|
||||||
std::dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 5,
|
std::dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 5,
|
||||||
4);
|
4);
|
||||||
if (pos == NULL) return false;
|
if (!pos.has_value()) return false;
|
||||||
posX = pos->x;
|
posX = pos->x;
|
||||||
posY = pos->y;
|
posY = pos->y;
|
||||||
posZ = pos->z;
|
posZ = pos->z;
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,10 @@ bool PlayGoal::canUse() {
|
||||||
delete children;
|
delete children;
|
||||||
|
|
||||||
if (followFriend.lock() == NULL) {
|
if (followFriend.lock() == NULL) {
|
||||||
Vec3* pos = RandomPos::getPos(
|
auto pos = RandomPos::getPos(
|
||||||
std::dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()),
|
std::dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()),
|
||||||
16, 3);
|
16, 3);
|
||||||
if (pos == NULL) return false;
|
if (!pos.has_value()) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -72,11 +72,11 @@ void PlayGoal::tick() {
|
||||||
mob->getNavigation()->moveTo(followFriend.lock(), speedModifier);
|
mob->getNavigation()->moveTo(followFriend.lock(), speedModifier);
|
||||||
} else {
|
} else {
|
||||||
if (mob->getNavigation()->isDone()) {
|
if (mob->getNavigation()->isDone()) {
|
||||||
Vec3* pos =
|
auto pos =
|
||||||
RandomPos::getPos(std::dynamic_pointer_cast<PathfinderMob>(
|
RandomPos::getPos(std::dynamic_pointer_cast<PathfinderMob>(
|
||||||
mob->shared_from_this()),
|
mob->shared_from_this()),
|
||||||
16, 3);
|
16, 3);
|
||||||
if (pos == NULL) return;
|
if (!pos.has_value()) return;
|
||||||
mob->getNavigation()->moveTo(pos->x, pos->y, pos->z, speedModifier);
|
mob->getNavigation()->moveTo(pos->x, pos->y, pos->z, speedModifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,11 @@ bool RandomStrollGoal::canUse() {
|
||||||
// fenced-off region far enough to determine we can despawn them
|
// fenced-off region far enough to determine we can despawn them
|
||||||
if (mob->getNoActionTime() < SharedConstants::TICKS_PER_SECOND * 5) {
|
if (mob->getNoActionTime() < SharedConstants::TICKS_PER_SECOND * 5) {
|
||||||
if (mob->getRandom()->nextInt(120) == 0) {
|
if (mob->getRandom()->nextInt(120) == 0) {
|
||||||
Vec3* pos =
|
auto pos =
|
||||||
RandomPos::getPos(std::dynamic_pointer_cast<PathfinderMob>(
|
RandomPos::getPos(std::dynamic_pointer_cast<PathfinderMob>(
|
||||||
mob->shared_from_this()),
|
mob->shared_from_this()),
|
||||||
10, 7);
|
10, 7);
|
||||||
if (pos == NULL) return false;
|
if (!pos.has_value()) return false;
|
||||||
wantedX = pos->x;
|
wantedX = pos->x;
|
||||||
wantedY = pos->y;
|
wantedY = pos->y;
|
||||||
wantedZ = pos->z;
|
wantedZ = pos->z;
|
||||||
|
|
@ -38,11 +38,11 @@ bool RandomStrollGoal::canUse() {
|
||||||
// a given area and so waiting around is just wasting time
|
// a given area and so waiting around is just wasting time
|
||||||
|
|
||||||
if (mob->isExtraWanderingEnabled()) {
|
if (mob->isExtraWanderingEnabled()) {
|
||||||
Vec3* pos =
|
auto pos =
|
||||||
RandomPos::getPos(std::dynamic_pointer_cast<PathfinderMob>(
|
RandomPos::getPos(std::dynamic_pointer_cast<PathfinderMob>(
|
||||||
mob->shared_from_this()),
|
mob->shared_from_this()),
|
||||||
10, 7, mob->getWanderingQuadrant());
|
10, 7, mob->getWanderingQuadrant());
|
||||||
if (pos == NULL) return false;
|
if (!pos.has_value()) return false;
|
||||||
wantedX = pos->x;
|
wantedX = pos->x;
|
||||||
wantedY = pos->y;
|
wantedY = pos->y;
|
||||||
wantedZ = pos->z;
|
wantedZ = pos->z;
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@ RunAroundLikeCrazyGoal::RunAroundLikeCrazyGoal(EntityHorse* mob,
|
||||||
|
|
||||||
bool RunAroundLikeCrazyGoal::canUse() {
|
bool RunAroundLikeCrazyGoal::canUse() {
|
||||||
if (horse->isTamed() || horse->rider.lock() == NULL) return false;
|
if (horse->isTamed() || horse->rider.lock() == NULL) return false;
|
||||||
Vec3* pos = RandomPos::getPos(
|
auto pos = RandomPos::getPos(
|
||||||
std::dynamic_pointer_cast<PathfinderMob>(horse->shared_from_this()), 5,
|
std::dynamic_pointer_cast<PathfinderMob>(horse->shared_from_this()), 5,
|
||||||
4);
|
4);
|
||||||
if (pos == NULL) return false;
|
if (!pos.has_value()) return false;
|
||||||
posX = pos->x;
|
posX = pos->x;
|
||||||
posY = pos->y;
|
posY = pos->y;
|
||||||
posZ = pos->z;
|
posZ = pos->z;
|
||||||
|
|
|
||||||
|
|
@ -48,17 +48,17 @@ int Path::getIndex() { return index; }
|
||||||
|
|
||||||
void Path::setIndex(int index) { this->index = index; }
|
void Path::setIndex(int index) { this->index = index; }
|
||||||
|
|
||||||
Vec3* Path::getPos(std::shared_ptr<Entity> e, int index) {
|
Vec3 Path::getPos(std::shared_ptr<Entity> e, int index) {
|
||||||
double x = nodes[index]->x + (int)(e->bbWidth + 1) * 0.5;
|
double x = nodes[index]->x + (int)(e->bbWidth + 1) * 0.5;
|
||||||
double y = nodes[index]->y;
|
double y = nodes[index]->y;
|
||||||
double z = nodes[index]->z + (int)(e->bbWidth + 1) * 0.5;
|
double z = nodes[index]->z + (int)(e->bbWidth + 1) * 0.5;
|
||||||
return Vec3::newTemp(x, y, z);
|
return Vec3(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* Path::currentPos(std::shared_ptr<Entity> e) { return getPos(e, index); }
|
Vec3 Path::currentPos(std::shared_ptr<Entity> e) { return getPos(e, index); }
|
||||||
|
|
||||||
Vec3* Path::currentPos() {
|
Vec3 Path::currentPos() {
|
||||||
return Vec3::newTemp(nodes[index]->x, nodes[index]->y, nodes[index]->z);
|
return Vec3(nodes[index]->x, nodes[index]->y, nodes[index]->z);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Path::sameAs(Path* path) {
|
bool Path::sameAs(Path* path) {
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,10 @@ public:
|
||||||
void setSize(int length);
|
void setSize(int length);
|
||||||
int getIndex();
|
int getIndex();
|
||||||
void setIndex(int index);
|
void setIndex(int index);
|
||||||
Vec3* getPos(std::shared_ptr<Entity> e, int index);
|
Vec3 getPos(std::shared_ptr<Entity> e, int index);
|
||||||
NodeArray Getarray();
|
NodeArray Getarray();
|
||||||
Vec3* currentPos(std::shared_ptr<Entity> e);
|
Vec3 currentPos(std::shared_ptr<Entity> e);
|
||||||
Vec3* currentPos();
|
Vec3 currentPos();
|
||||||
bool sameAs(Path* path);
|
bool sameAs(Path* path);
|
||||||
bool endsIn(Vec3* pos);
|
bool endsIn(Vec3* pos);
|
||||||
bool endsInXZ(Vec3* pos);
|
bool endsInXZ(Vec3* pos);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ PathNavigation::PathNavigation(Mob* mob, Level* level) {
|
||||||
avoidSun = false;
|
avoidSun = false;
|
||||||
_tick = 0;
|
_tick = 0;
|
||||||
lastStuckCheck = 0;
|
lastStuckCheck = 0;
|
||||||
lastStuckCheckPos = Vec3::newPermanent(0, 0, 0);
|
lastStuckCheckPos = Vec3(0, 0, 0);
|
||||||
_canPassDoors = true;
|
_canPassDoors = true;
|
||||||
_canOpenDoors = false;
|
_canOpenDoors = false;
|
||||||
avoidWater = false;
|
avoidWater = false;
|
||||||
|
|
@ -29,7 +29,6 @@ PathNavigation::PathNavigation(Mob* mob, Level* level) {
|
||||||
|
|
||||||
PathNavigation::~PathNavigation() {
|
PathNavigation::~PathNavigation() {
|
||||||
if (path != NULL) delete path;
|
if (path != NULL) delete path;
|
||||||
delete lastStuckCheckPos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathNavigation::setAvoidWater(bool avoidWater) {
|
void PathNavigation::setAvoidWater(bool avoidWater) {
|
||||||
|
|
@ -110,11 +109,11 @@ bool PathNavigation::moveTo(Path* newPath, double speedModifier) {
|
||||||
if (path->getSize() == 0) return false;
|
if (path->getSize() == 0) return false;
|
||||||
|
|
||||||
this->speedModifier = speedModifier;
|
this->speedModifier = speedModifier;
|
||||||
Vec3* mobPos = getTempMobPos();
|
Vec3 mobPos = getTempMobPos();
|
||||||
lastStuckCheck = _tick;
|
lastStuckCheck = _tick;
|
||||||
lastStuckCheckPos->x = mobPos->x;
|
lastStuckCheckPos.x = mobPos.x;
|
||||||
lastStuckCheckPos->y = mobPos->y;
|
lastStuckCheckPos.y = mobPos.y;
|
||||||
lastStuckCheckPos->z = mobPos->z;
|
lastStuckCheckPos.z = mobPos.z;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -127,20 +126,19 @@ void PathNavigation::tick() {
|
||||||
if (canUpdatePath()) updatePath();
|
if (canUpdatePath()) updatePath();
|
||||||
|
|
||||||
if (isDone()) return;
|
if (isDone()) return;
|
||||||
Vec3* target = path->currentPos(mob->shared_from_this());
|
Vec3 target = path->currentPos(mob->shared_from_this());
|
||||||
if (target == NULL) return;
|
|
||||||
|
|
||||||
mob->getMoveControl()->setWantedPosition(target->x, target->y, target->z,
|
mob->getMoveControl()->setWantedPosition(target.x, target.y, target.z,
|
||||||
speedModifier);
|
speedModifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathNavigation::updatePath() {
|
void PathNavigation::updatePath() {
|
||||||
Vec3* mobPos = getTempMobPos();
|
Vec3 mobPos = getTempMobPos();
|
||||||
|
|
||||||
// find first elevations in path
|
// find first elevations in path
|
||||||
int firstElevation = path->getSize();
|
int firstElevation = path->getSize();
|
||||||
for (int i = path->getIndex(); path != NULL && i < path->getSize(); ++i) {
|
for (int i = path->getIndex(); path != NULL && i < path->getSize(); ++i) {
|
||||||
if ((int)path->get(i)->y != (int)mobPos->y) {
|
if ((int)path->get(i)->y != (int)mobPos.y) {
|
||||||
firstElevation = i;
|
firstElevation = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -150,8 +148,8 @@ void PathNavigation::updatePath() {
|
||||||
// check canWalkDirectly also) possibly only check next as well
|
// check canWalkDirectly also) possibly only check next as well
|
||||||
float waypointRadiusSqr = mob->bbWidth * mob->bbWidth;
|
float waypointRadiusSqr = mob->bbWidth * mob->bbWidth;
|
||||||
for (int i = path->getIndex(); i < firstElevation; ++i) {
|
for (int i = path->getIndex(); i < firstElevation; ++i) {
|
||||||
Vec3* pathPos = path->getPos(mob->shared_from_this(), i);
|
Vec3 pathPos = path->getPos(mob->shared_from_this(), i);
|
||||||
if (mobPos->distanceToSqr(pathPos) < waypointRadiusSqr) {
|
if (mobPos.distanceToSqr(pathPos) < waypointRadiusSqr) {
|
||||||
path->setIndex(i + 1);
|
path->setIndex(i + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -161,8 +159,8 @@ void PathNavigation::updatePath() {
|
||||||
int sy = (int)mob->bbHeight + 1;
|
int sy = (int)mob->bbHeight + 1;
|
||||||
int sz = sx;
|
int sz = sx;
|
||||||
for (int i = firstElevation - 1; i >= path->getIndex(); --i) {
|
for (int i = firstElevation - 1; i >= path->getIndex(); --i) {
|
||||||
if (canMoveDirectly(mobPos, path->getPos(mob->shared_from_this(), i),
|
Vec3 mob_pos = path->getPos(mob->shared_from_this(), i);
|
||||||
sx, sy, sz)) {
|
if (canMoveDirectly(&mobPos, &mob_pos, sx, sy, sz)) {
|
||||||
path->setIndex(i);
|
path->setIndex(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -170,11 +168,11 @@ void PathNavigation::updatePath() {
|
||||||
|
|
||||||
// stuck detection (probably pushed off path)
|
// stuck detection (probably pushed off path)
|
||||||
if (_tick - lastStuckCheck > 100) {
|
if (_tick - lastStuckCheck > 100) {
|
||||||
if (mobPos->distanceToSqr(lastStuckCheckPos) < 1.5 * 1.5) stop();
|
if (mobPos.distanceToSqr(lastStuckCheckPos) < 1.5 * 1.5) stop();
|
||||||
lastStuckCheck = _tick;
|
lastStuckCheck = _tick;
|
||||||
lastStuckCheckPos->x = mobPos->x;
|
lastStuckCheckPos.x = mobPos.x;
|
||||||
lastStuckCheckPos->y = mobPos->y;
|
lastStuckCheckPos.y = mobPos.y;
|
||||||
lastStuckCheckPos->z = mobPos->z;
|
lastStuckCheckPos.z = mobPos.z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -185,8 +183,8 @@ void PathNavigation::stop() {
|
||||||
path = NULL;
|
path = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* PathNavigation::getTempMobPos() {
|
Vec3 PathNavigation::getTempMobPos() {
|
||||||
return Vec3::newTemp(mob->x, getSurfaceY(), mob->z);
|
return Vec3(mob->x, getSurfaceY(), mob->z);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PathNavigation::getSurfaceY() {
|
int PathNavigation::getSurfaceY() {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ private:
|
||||||
bool avoidSun;
|
bool avoidSun;
|
||||||
int _tick;
|
int _tick;
|
||||||
int lastStuckCheck;
|
int lastStuckCheck;
|
||||||
Vec3* lastStuckCheckPos;
|
Vec3 lastStuckCheckPos;
|
||||||
|
|
||||||
bool _canPassDoors;
|
bool _canPassDoors;
|
||||||
bool _canOpenDoors;
|
bool _canOpenDoors;
|
||||||
|
|
@ -52,7 +52,7 @@ public:
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vec3* getTempMobPos();
|
Vec3 getTempMobPos();
|
||||||
int getSurfaceY();
|
int getSurfaceY();
|
||||||
bool canUpdatePath();
|
bool canUpdatePath();
|
||||||
bool isInLiquid();
|
bool isInLiquid();
|
||||||
|
|
|
||||||
|
|
@ -2,34 +2,38 @@
|
||||||
#include "../../Headers/net.minecraft.world.entity.h"
|
#include "../../Headers/net.minecraft.world.entity.h"
|
||||||
#include "../../Headers/net.minecraft.world.phys.h"
|
#include "../../Headers/net.minecraft.world.phys.h"
|
||||||
#include "RandomPos.h"
|
#include "RandomPos.h"
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
Vec3* RandomPos::tempDir = Vec3::newPermanent(0, 0, 0);
|
Vec3 RandomPos::tempDir = Vec3(0, 0, 0);
|
||||||
|
|
||||||
Vec3* RandomPos::getPos(std::shared_ptr<PathfinderMob> mob, int xzDist,
|
std::optional<Vec3> RandomPos::getPos(
|
||||||
int yDist, int quadrant /*=-1*/) // 4J - added quadrant
|
std::shared_ptr<PathfinderMob> mob, int xzDist, int yDist,
|
||||||
|
int quadrant /*=-1*/) // 4J - added quadrant
|
||||||
{
|
{
|
||||||
return generateRandomPos(mob, xzDist, yDist, NULL, quadrant);
|
return generateRandomPos(mob, xzDist, yDist, NULL, quadrant);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* RandomPos::getPosTowards(std::shared_ptr<PathfinderMob> mob, int xzDist,
|
std::optional<Vec3> RandomPos::getPosTowards(std::shared_ptr<PathfinderMob> mob,
|
||||||
int yDist, Vec3* towardsPos) {
|
int xzDist, int yDist,
|
||||||
tempDir->x = towardsPos->x - mob->x;
|
Vec3* towardsPos) {
|
||||||
tempDir->y = towardsPos->y - mob->y;
|
tempDir.x = towardsPos->x - mob->x;
|
||||||
tempDir->z = towardsPos->z - mob->z;
|
tempDir.y = towardsPos->y - mob->y;
|
||||||
return generateRandomPos(mob, xzDist, yDist, tempDir);
|
tempDir.z = towardsPos->z - mob->z;
|
||||||
|
return generateRandomPos(mob, xzDist, yDist, &tempDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* RandomPos::getPosAvoid(std::shared_ptr<PathfinderMob> mob, int xzDist,
|
std::optional<Vec3> RandomPos::getPosAvoid(std::shared_ptr<PathfinderMob> mob,
|
||||||
int yDist, Vec3* avoidPos) {
|
int xzDist, int yDist,
|
||||||
tempDir->x = mob->x - avoidPos->x;
|
Vec3* avoidPos) {
|
||||||
tempDir->y = mob->y - avoidPos->y;
|
tempDir.x = mob->x - avoidPos->x;
|
||||||
tempDir->z = mob->z - avoidPos->z;
|
tempDir.y = mob->y - avoidPos->y;
|
||||||
return generateRandomPos(mob, xzDist, yDist, tempDir);
|
tempDir.z = mob->z - avoidPos->z;
|
||||||
|
return generateRandomPos(mob, xzDist, yDist, &tempDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* RandomPos::generateRandomPos(std::shared_ptr<PathfinderMob> mob,
|
std::optional<Vec3> RandomPos::generateRandomPos(
|
||||||
int xzDist, int yDist, Vec3* dir,
|
std::shared_ptr<PathfinderMob> mob, int xzDist, int yDist, Vec3* dir,
|
||||||
int quadrant /*=-1*/) // 4J - added quadrant
|
int quadrant /*=-1*/) // 4J - added quadrant
|
||||||
{
|
{
|
||||||
Random* random = mob->getRandom();
|
Random* random = mob->getRandom();
|
||||||
bool hasBest = false;
|
bool hasBest = false;
|
||||||
|
|
@ -81,8 +85,8 @@ Vec3* RandomPos::generateRandomPos(std::shared_ptr<PathfinderMob> mob,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasBest) {
|
if (hasBest) {
|
||||||
return Vec3::newTemp(xBest, yBest, zBest);
|
return Vec3(xBest, yBest, zBest);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
@ -1,21 +1,25 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
class PathfinderMob;
|
class PathfinderMob;
|
||||||
|
|
||||||
class RandomPos {
|
class RandomPos {
|
||||||
private:
|
private:
|
||||||
static Vec3* tempDir;
|
static Vec3 tempDir;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Vec3* getPos(std::shared_ptr<PathfinderMob> mob, int xzDist,
|
static std::optional<Vec3> getPos(std::shared_ptr<PathfinderMob> mob,
|
||||||
int yDist, int quadrant = -1); // 4J added quadrant
|
int xzDist, int yDist,
|
||||||
static Vec3* getPosTowards(std::shared_ptr<PathfinderMob> mob, int xzDist,
|
int quadrant = -1); // 4J added quadrant
|
||||||
int yDist, Vec3* towardsPos);
|
static std::optional<Vec3> getPosTowards(std::shared_ptr<PathfinderMob> mob,
|
||||||
static Vec3* getPosAvoid(std::shared_ptr<PathfinderMob> mob, int xzDist,
|
int xzDist, int yDist,
|
||||||
int yDist, Vec3* avoidPos);
|
Vec3* towardsPos);
|
||||||
|
static std::optional<Vec3> getPosAvoid(std::shared_ptr<PathfinderMob> mob,
|
||||||
|
int xzDist, int yDist,
|
||||||
|
Vec3* avoidPos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Vec3* generateRandomPos(std::shared_ptr<PathfinderMob> mob,
|
static std::optional<Vec3> generateRandomPos(
|
||||||
int xzDist, int yDist, Vec3* dir,
|
std::shared_ptr<PathfinderMob> mob, int xzDist, int yDist, Vec3* dir,
|
||||||
int quadrant = -1); // 4J added quadrant
|
int quadrant = -1); // 4J added quadrant
|
||||||
};
|
};
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include "LiquidTile.h"
|
#include "LiquidTile.h"
|
||||||
#include "../Util/Facing.h"
|
#include "../Util/Facing.h"
|
||||||
#include "../Util/SoundTypes.h"
|
#include "../Util/SoundTypes.h"
|
||||||
|
#include "Blocks/Material.h"
|
||||||
|
|
||||||
const std::wstring LiquidTile::TEXTURE_LAVA_STILL = L"lava";
|
const std::wstring LiquidTile::TEXTURE_LAVA_STILL = L"lava";
|
||||||
const std::wstring LiquidTile::TEXTURE_WATER_STILL = L"water";
|
const std::wstring LiquidTile::TEXTURE_WATER_STILL = L"water";
|
||||||
|
|
@ -116,8 +117,8 @@ int LiquidTile::getResource(int data, Random* random, int playerBonusLevel) {
|
||||||
|
|
||||||
int LiquidTile::getResourceCount(Random* random) { return 0; }
|
int LiquidTile::getResourceCount(Random* random) { return 0; }
|
||||||
|
|
||||||
Vec3* LiquidTile::getFlow(LevelSource* level, int x, int y, int z) {
|
Vec3 LiquidTile::getFlow(LevelSource* level, int x, int y, int z) {
|
||||||
Vec3* flow = Vec3::newTemp(0, 0, 0);
|
Vec3 flow(0, 0, 0);
|
||||||
int mid = getRenderedDepth(level, x, y, z);
|
int mid = getRenderedDepth(level, x, y, z);
|
||||||
for (int d = 0; d < 4; d++) {
|
for (int d = 0; d < 4; d++) {
|
||||||
int xt = x;
|
int xt = x;
|
||||||
|
|
@ -135,15 +136,14 @@ Vec3* LiquidTile::getFlow(LevelSource* level, int x, int y, int z) {
|
||||||
t = getRenderedDepth(level, xt, yt - 1, zt);
|
t = getRenderedDepth(level, xt, yt - 1, zt);
|
||||||
if (t >= 0) {
|
if (t >= 0) {
|
||||||
int dir = t - (mid - 8);
|
int dir = t - (mid - 8);
|
||||||
flow = flow->add((xt - x) * dir, (yt - y) * dir,
|
flow = flow.add((xt - x) * dir, (yt - y) * dir,
|
||||||
(zt - z) * dir);
|
(zt - z) * dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (t >= 0) {
|
if (t >= 0) {
|
||||||
int dir = t - mid;
|
int dir = t - mid;
|
||||||
flow =
|
flow = flow.add((xt - x) * dir, (yt - y) * dir, (zt - z) * dir);
|
||||||
flow->add((xt - x) * dir, (yt - y) * dir, (zt - z) * dir);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -157,18 +157,19 @@ Vec3* LiquidTile::getFlow(LevelSource* level, int x, int y, int z) {
|
||||||
if (ok || isSolidFace(level, x, y + 1, z + 1, 3)) ok = true;
|
if (ok || isSolidFace(level, x, y + 1, z + 1, 3)) ok = true;
|
||||||
if (ok || isSolidFace(level, x - 1, y + 1, z, 4)) ok = true;
|
if (ok || isSolidFace(level, x - 1, y + 1, z, 4)) ok = true;
|
||||||
if (ok || isSolidFace(level, x + 1, y + 1, z, 5)) ok = true;
|
if (ok || isSolidFace(level, x + 1, y + 1, z, 5)) ok = true;
|
||||||
if (ok) flow = flow->normalize()->add(0, -6, 0);
|
if (ok) flow = flow.normalize().add(0, -6, 0);
|
||||||
}
|
}
|
||||||
flow = flow->normalize();
|
flow = flow.normalize();
|
||||||
|
|
||||||
return flow;
|
return flow;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LiquidTile::handleEntityInside(Level* level, int x, int y, int z,
|
void LiquidTile::handleEntityInside(Level* level, int x, int y, int z,
|
||||||
std::shared_ptr<Entity> e, Vec3* current) {
|
std::shared_ptr<Entity> e, Vec3* current) {
|
||||||
Vec3* flow = getFlow(level, x, y, z);
|
Vec3 flow = getFlow(level, x, y, z);
|
||||||
current->x += flow->x;
|
current->x += flow.x;
|
||||||
current->y += flow->y;
|
current->y += flow.y;
|
||||||
current->z += flow->z;
|
current->z += flow.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LiquidTile::getTickDelay(Level* level) {
|
int LiquidTile::getTickDelay(Level* level) {
|
||||||
|
|
@ -305,13 +306,11 @@ void LiquidTile::animateTick(Level* level, int x, int y, int z,
|
||||||
|
|
||||||
double LiquidTile::getSlopeAngle(LevelSource* level, int x, int y, int z,
|
double LiquidTile::getSlopeAngle(LevelSource* level, int x, int y, int z,
|
||||||
Material* m) {
|
Material* m) {
|
||||||
Vec3* flow = NULL;
|
Vec3 flow;
|
||||||
if (m == Material::water)
|
if (m == Material::water) flow = Tile::water->getFlow(level, x, y, z);
|
||||||
flow = ((LiquidTile*)Tile::water)->getFlow(level, x, y, z);
|
if (m == Material::lava) flow = Tile::lava->getFlow(level, x, y, z);
|
||||||
if (m == Material::lava)
|
if (flow.x == 0 && flow.z == 0) return -1000;
|
||||||
flow = ((LiquidTile*)Tile::lava)->getFlow(level, x, y, z);
|
return atan2(flow.z, flow.x) - PI / 2;
|
||||||
if (flow->x == 0 && flow->z == 0) return -1000;
|
|
||||||
return atan2(flow->z, flow->x) - PI / 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LiquidTile::onPlace(Level* level, int x, int y, int z) {
|
void LiquidTile::onPlace(Level* level, int x, int y, int z) {
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ public:
|
||||||
virtual int getResourceCount(Random* random);
|
virtual int getResourceCount(Random* random);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual Vec3* getFlow(LevelSource* level, int x, int y, int z);
|
virtual Vec3 getFlow(LevelSource* level, int x, int y, int z);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void handleEntityInside(Level* level, int x, int y, int z,
|
virtual void handleEntityInside(Level* level, int x, int y, int z,
|
||||||
|
|
|
||||||
|
|
@ -443,7 +443,7 @@ HitResult* StairTile::clip(Level* level, int xt, int yt, int zt, Vec3* a,
|
||||||
for (unsigned int i = 0; i < 8; ++i) {
|
for (unsigned int i = 0; i < 8; ++i) {
|
||||||
HitResult* result = results[i];
|
HitResult* result = results[i];
|
||||||
if (result != NULL) {
|
if (result != NULL) {
|
||||||
double dist = result->pos->distanceToSqr(b);
|
double dist = result->pos.distanceToSqr(*b);
|
||||||
|
|
||||||
if (dist > closestDist) {
|
if (dist > closestDist) {
|
||||||
closest = result;
|
closest = result;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,9 @@
|
||||||
#include "../Headers/net.minecraft.world.food.h"
|
#include "../Headers/net.minecraft.world.food.h"
|
||||||
#include "../Headers/net.minecraft.world.h"
|
#include "../Headers/net.minecraft.world.h"
|
||||||
#include "../Headers/net.minecraft.h"
|
#include "../Headers/net.minecraft.h"
|
||||||
|
#include "Util/Vec3.h"
|
||||||
#include "Tile.h"
|
#include "Tile.h"
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
std::wstring Tile::TILE_DESCRIPTION_PREFIX = L"Tile.";
|
std::wstring Tile::TILE_DESCRIPTION_PREFIX = L"Tile.";
|
||||||
|
|
||||||
|
|
@ -2120,41 +2122,52 @@ float Tile::getExplosionResistance(std::shared_ptr<Entity> source) {
|
||||||
HitResult* Tile::clip(Level* level, int xt, int yt, int zt, Vec3* a, Vec3* b) {
|
HitResult* Tile::clip(Level* level, int xt, int yt, int zt, Vec3* a, Vec3* b) {
|
||||||
updateShape(level, xt, yt, zt);
|
updateShape(level, xt, yt, zt);
|
||||||
|
|
||||||
a = a->add(-xt, -yt, -zt);
|
*a = a->add(-xt, -yt, -zt);
|
||||||
b = b->add(-xt, -yt, -zt);
|
*b = b->add(-xt, -yt, -zt);
|
||||||
|
|
||||||
ThreadStorage* tls = m_tlsShape;
|
ThreadStorage* tls = m_tlsShape;
|
||||||
Vec3* xh0 = a->clipX(b, tls->xx0);
|
auto xh0 = a->clipX(*b, tls->xx0);
|
||||||
Vec3* xh1 = a->clipX(b, tls->xx1);
|
auto xh1 = a->clipX(*b, tls->xx1);
|
||||||
|
|
||||||
Vec3* yh0 = a->clipY(b, tls->yy0);
|
auto yh0 = a->clipY(*b, tls->yy0);
|
||||||
Vec3* yh1 = a->clipY(b, tls->yy1);
|
auto yh1 = a->clipY(*b, tls->yy1);
|
||||||
|
|
||||||
Vec3* zh0 = a->clipZ(b, tls->zz0);
|
auto zh0 = a->clipZ(*b, tls->zz0);
|
||||||
Vec3* zh1 = a->clipZ(b, tls->zz1);
|
auto zh1 = a->clipZ(*b, tls->zz1);
|
||||||
|
|
||||||
Vec3* closest = NULL;
|
std::optional<Vec3> closest = std::nullopt;
|
||||||
|
|
||||||
if (containsX(xh0) &&
|
if (xh0.has_value() and containsX(&*xh0) and
|
||||||
(closest == NULL || a->distanceToSqr(xh0) < a->distanceToSqr(closest)))
|
(!closest.has_value() or
|
||||||
|
a->distanceToSqr(*xh0) < a->distanceToSqr(*closest)))
|
||||||
closest = xh0;
|
closest = xh0;
|
||||||
if (containsX(xh1) &&
|
|
||||||
(closest == NULL || a->distanceToSqr(xh1) < a->distanceToSqr(closest)))
|
if (xh1.has_value() and containsX(&*xh1) and
|
||||||
|
(!closest.has_value() or
|
||||||
|
a->distanceToSqr(*xh1) < a->distanceToSqr(*closest)))
|
||||||
closest = xh1;
|
closest = xh1;
|
||||||
if (containsY(yh0) &&
|
|
||||||
(closest == NULL || a->distanceToSqr(yh0) < a->distanceToSqr(closest)))
|
if (yh0.has_value() and containsY(&*yh0) and
|
||||||
|
(!closest.has_value() or
|
||||||
|
a->distanceToSqr(*yh0) < a->distanceToSqr(*closest)))
|
||||||
closest = yh0;
|
closest = yh0;
|
||||||
if (containsY(yh1) &&
|
|
||||||
(closest == NULL || a->distanceToSqr(yh1) < a->distanceToSqr(closest)))
|
if (yh1.has_value() and containsY(&*yh1) and
|
||||||
|
(!closest.has_value() or
|
||||||
|
a->distanceToSqr(*yh1) < a->distanceToSqr(*closest)))
|
||||||
closest = yh1;
|
closest = yh1;
|
||||||
if (containsZ(zh0) &&
|
|
||||||
(closest == NULL || a->distanceToSqr(zh0) < a->distanceToSqr(closest)))
|
if (zh0.has_value() and containsZ(&*zh0) and
|
||||||
|
(!closest.has_value() or
|
||||||
|
a->distanceToSqr(*zh0) < a->distanceToSqr(*closest)))
|
||||||
closest = zh0;
|
closest = zh0;
|
||||||
if (containsZ(zh1) &&
|
|
||||||
(closest == NULL || a->distanceToSqr(zh1) < a->distanceToSqr(closest)))
|
if (zh1.has_value() and containsZ(&*zh1) and
|
||||||
|
(!closest.has_value() or
|
||||||
|
a->distanceToSqr(*zh1) < a->distanceToSqr(*closest)))
|
||||||
closest = zh1;
|
closest = zh1;
|
||||||
|
|
||||||
if (closest == NULL) return NULL;
|
if (!closest.has_value()) return nullptr;
|
||||||
|
|
||||||
int face = -1;
|
int face = -1;
|
||||||
|
|
||||||
|
|
@ -2165,7 +2178,8 @@ HitResult* Tile::clip(Level* level, int xt, int yt, int zt, Vec3* a, Vec3* b) {
|
||||||
if (closest == zh0) face = Facing::NORTH;
|
if (closest == zh0) face = Facing::NORTH;
|
||||||
if (closest == zh1) face = Facing::SOUTH;
|
if (closest == zh1) face = Facing::SOUTH;
|
||||||
|
|
||||||
return new HitResult(xt, yt, zt, face, closest->add(xt, yt, zt));
|
Vec3 res = closest->add(xt, yt, zt);
|
||||||
|
return new HitResult(xt, yt, zt, face, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Tile::containsX(Vec3* v) {
|
bool Tile::containsX(Vec3* v) {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#include "../../Minecraft.Client/Level/MultiPlayerLevel.h"
|
#include "../../Minecraft.Client/Level/MultiPlayerLevel.h"
|
||||||
#include "../../Minecraft.Client/Player/MultiPlayerLocalPlayer.h"
|
#include "../../Minecraft.Client/Player/MultiPlayerLocalPlayer.h"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <optional>
|
||||||
#include "../../Minecraft.Client/Level/ServerLevel.h"
|
#include "../../Minecraft.Client/Level/ServerLevel.h"
|
||||||
#include "../../Minecraft.Client/Network/PlayerList.h"
|
#include "../../Minecraft.Client/Network/PlayerList.h"
|
||||||
|
|
||||||
|
|
@ -1533,7 +1534,7 @@ void Entity::lerpTo(double x, double y, double z, float yRot, float xRot,
|
||||||
|
|
||||||
float Entity::getPickRadius() { return 0.1f; }
|
float Entity::getPickRadius() { return 0.1f; }
|
||||||
|
|
||||||
Vec3* Entity::getLookAngle() { return NULL; }
|
std::optional<Vec3> Entity::getLookAngle() { return std::nullopt; }
|
||||||
|
|
||||||
void Entity::handleInsidePortal() {
|
void Entity::handleInsidePortal() {
|
||||||
if (changingDimensionDelay > 0) {
|
if (changingDimensionDelay > 0) {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include "../Util/Vec3.h"
|
#include "../Util/Vec3.h"
|
||||||
#include "../Util/Definitions.h"
|
#include "../Util/Definitions.h"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
class LivingEntity;
|
class LivingEntity;
|
||||||
class LightningBolt;
|
class LightningBolt;
|
||||||
|
|
@ -342,7 +343,7 @@ public:
|
||||||
virtual void lerpTo(double x, double y, double z, float yRot, float xRot,
|
virtual void lerpTo(double x, double y, double z, float yRot, float xRot,
|
||||||
int steps);
|
int steps);
|
||||||
virtual float getPickRadius();
|
virtual float getPickRadius();
|
||||||
virtual Vec3* getLookAngle();
|
virtual std::optional<Vec3> getLookAngle();
|
||||||
virtual void handleInsidePortal();
|
virtual void handleInsidePortal();
|
||||||
virtual int getDimensionChangingDelay();
|
virtual int getDimensionChangingDelay();
|
||||||
virtual void lerpMotion(double xd, double yd, double zd);
|
virtual void lerpMotion(double xd, double yd, double zd);
|
||||||
|
|
@ -424,6 +425,7 @@ private:
|
||||||
static int extraWanderTicks;
|
static int extraWanderTicks;
|
||||||
|
|
||||||
static thread_local bool m_tlsUseSmallIds;
|
static thread_local bool m_tlsUseSmallIds;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void tickExtraWandering();
|
static void tickExtraWandering();
|
||||||
static void countFlagsForPIX();
|
static void countFlagsForPIX();
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#include "../Headers/net.minecraft.world.scores.h"
|
#include "../Headers/net.minecraft.world.scores.h"
|
||||||
#include "../Headers/com.mojang.nbt.h"
|
#include "../Headers/com.mojang.nbt.h"
|
||||||
#include "LivingEntity.h"
|
#include "LivingEntity.h"
|
||||||
|
#include <optional>
|
||||||
#include "../../Minecraft.Client/Textures/Textures.h"
|
#include "../../Minecraft.Client/Textures/Textures.h"
|
||||||
#include "../../Minecraft.Client/Level/ServerLevel.h"
|
#include "../../Minecraft.Client/Level/ServerLevel.h"
|
||||||
#include "../../Minecraft.Client/Player/EntityTracker.h"
|
#include "../../Minecraft.Client/Player/EntityTracker.h"
|
||||||
|
|
@ -31,6 +32,7 @@
|
||||||
#include "../Util/ParticleTypes.h"
|
#include "../Util/ParticleTypes.h"
|
||||||
#include "../Stats/GenericStats.h"
|
#include "../Stats/GenericStats.h"
|
||||||
#include "ItemEntity.h"
|
#include "ItemEntity.h"
|
||||||
|
#include "Util/Vec3.h"
|
||||||
|
|
||||||
const double LivingEntity::MIN_MOVEMENT_DISTANCE = 0.005;
|
const double LivingEntity::MIN_MOVEMENT_DISTANCE = 0.005;
|
||||||
|
|
||||||
|
|
@ -791,18 +793,18 @@ void LivingEntity::breakItem(std::shared_ptr<ItemInstance> itemInstance) {
|
||||||
0.8f + level->random->nextFloat() * 0.4f);
|
0.8f + level->random->nextFloat() * 0.4f);
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
Vec3* d = Vec3::newTemp((random->nextFloat() - 0.5) * 0.1,
|
Vec3 d = Vec3((random->nextFloat() - 0.5) * 0.1,
|
||||||
Math::random() * 0.1 + 0.1, 0);
|
Math::random() * 0.1 + 0.1, 0);
|
||||||
d->xRot(-xRot * PI / 180);
|
d.xRot(-xRot * PI / 180);
|
||||||
d->yRot(-yRot * PI / 180);
|
d.yRot(-yRot * PI / 180);
|
||||||
|
|
||||||
Vec3* p = Vec3::newTemp((random->nextFloat() - 0.5) * 0.3,
|
Vec3 p = Vec3((random->nextFloat() - 0.5) * 0.3,
|
||||||
-random->nextFloat() * 0.6 - 0.3, 0.6);
|
-random->nextFloat() * 0.6 - 0.3, 0.6);
|
||||||
p->xRot(-xRot * PI / 180);
|
p.xRot(-xRot * PI / 180);
|
||||||
p->yRot(-yRot * PI / 180);
|
p.yRot(-yRot * PI / 180);
|
||||||
p = p->add(x, y + getHeadHeight(), z);
|
p = p.add(x, y + getHeadHeight(), z);
|
||||||
level->addParticle(PARTICLE_ICONCRACK(itemInstance->getItem()->id, 0),
|
level->addParticle(PARTICLE_ICONCRACK(itemInstance->getItem()->id, 0),
|
||||||
p->x, p->y, p->z, d->x, d->y + 0.05, d->z);
|
p.x, p.y, p.z, d.x, d.y + 0.05, d.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1640,25 +1642,25 @@ void LivingEntity::take(std::shared_ptr<Entity> e, int orgCount) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LivingEntity::canSee(std::shared_ptr<Entity> target) {
|
bool LivingEntity::canSee(std::shared_ptr<Entity> target) {
|
||||||
HitResult* hres = level->clip(
|
Vec3 a{x, y + getHeadHeight(), z};
|
||||||
Vec3::newTemp(x, y + getHeadHeight(), z),
|
Vec3 b{target->x, target->y + target->getHeadHeight(), target->z};
|
||||||
Vec3::newTemp(target->x, target->y + target->getHeadHeight(),
|
|
||||||
target->z));
|
HitResult* hres = level->clip(&a, &b);
|
||||||
bool retVal = (hres == NULL);
|
bool retVal = (hres == NULL);
|
||||||
delete hres;
|
delete hres;
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* LivingEntity::getLookAngle() { return getViewVector(1); }
|
std::optional<Vec3> LivingEntity::getLookAngle() { return getViewVector(1); }
|
||||||
|
|
||||||
Vec3* LivingEntity::getViewVector(float a) {
|
Vec3 LivingEntity::getViewVector(float a) {
|
||||||
if (a == 1) {
|
if (a == 1) {
|
||||||
float yCos = Mth::cos(-yRot * Mth::RAD_TO_GRAD - PI);
|
float yCos = Mth::cos(-yRot * Mth::RAD_TO_GRAD - PI);
|
||||||
float ySin = Mth::sin(-yRot * Mth::RAD_TO_GRAD - PI);
|
float ySin = Mth::sin(-yRot * Mth::RAD_TO_GRAD - PI);
|
||||||
float xCos = -Mth::cos(-xRot * Mth::RAD_TO_GRAD);
|
float xCos = -Mth::cos(-xRot * Mth::RAD_TO_GRAD);
|
||||||
float xSin = Mth::sin(-xRot * Mth::RAD_TO_GRAD);
|
float xSin = Mth::sin(-xRot * Mth::RAD_TO_GRAD);
|
||||||
|
|
||||||
return Vec3::newTemp(ySin * xCos, xSin, yCos * xCos);
|
return Vec3(ySin * xCos, xSin, yCos * xCos);
|
||||||
}
|
}
|
||||||
float xRot = xRotO + (this->xRot - xRotO) * a;
|
float xRot = xRotO + (this->xRot - xRotO) * a;
|
||||||
float yRot = yRotO + (this->yRot - yRotO) * a;
|
float yRot = yRotO + (this->yRot - yRotO) * a;
|
||||||
|
|
@ -1668,7 +1670,7 @@ Vec3* LivingEntity::getViewVector(float a) {
|
||||||
float xCos = -Mth::cos(-xRot * Mth::RAD_TO_GRAD);
|
float xCos = -Mth::cos(-xRot * Mth::RAD_TO_GRAD);
|
||||||
float xSin = Mth::sin(-xRot * Mth::RAD_TO_GRAD);
|
float xSin = Mth::sin(-xRot * Mth::RAD_TO_GRAD);
|
||||||
|
|
||||||
return Vec3::newTemp(ySin * xCos, xSin, yCos * xCos);
|
return Vec3(ySin * xCos, xSin, yCos * xCos);
|
||||||
}
|
}
|
||||||
|
|
||||||
float LivingEntity::getAttackAnim(float a) {
|
float LivingEntity::getAttackAnim(float a) {
|
||||||
|
|
@ -1677,22 +1679,23 @@ float LivingEntity::getAttackAnim(float a) {
|
||||||
return oAttackAnim + diff * a;
|
return oAttackAnim + diff * a;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* LivingEntity::getPos(float a) {
|
Vec3 LivingEntity::getPos(float a) {
|
||||||
if (a == 1) {
|
if (a == 1) {
|
||||||
return Vec3::newTemp(x, y, z);
|
return Vec3(x, y, z);
|
||||||
}
|
}
|
||||||
double x = xo + (this->x - xo) * a;
|
double x = xo + (this->x - xo) * a;
|
||||||
double y = yo + (this->y - yo) * a;
|
double y = yo + (this->y - yo) * a;
|
||||||
double z = zo + (this->z - zo) * a;
|
double z = zo + (this->z - zo) * a;
|
||||||
|
|
||||||
return Vec3::newTemp(x, y, z);
|
return Vec3(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
HitResult* LivingEntity::pick(double range, float a) {
|
HitResult* LivingEntity::pick(double range, float a) {
|
||||||
Vec3* from = getPos(a);
|
Vec3 from = getPos(a);
|
||||||
Vec3* b = getViewVector(a);
|
Vec3 b = getViewVector(a);
|
||||||
Vec3* to = from->add(b->x * range, b->y * range, b->z * range);
|
Vec3 to{b.x * range, b.y * range, b.z * range};
|
||||||
return level->clip(from, to);
|
to = to.add(from.x, from.y, from.z);
|
||||||
|
return level->clip(&from, &to);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LivingEntity::isEffectiveAi() { return !level->isClientSide; }
|
bool LivingEntity::isEffectiveAi() { return !level->isClientSide; }
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
#include "MobType.h"
|
#include "MobType.h"
|
||||||
#include "../AI/Goals/GoalSelector.h"
|
#include "../AI/Goals/GoalSelector.h"
|
||||||
|
|
@ -304,10 +305,10 @@ public:
|
||||||
virtual bool canSee(std::shared_ptr<Entity> target);
|
virtual bool canSee(std::shared_ptr<Entity> target);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual Vec3* getLookAngle();
|
virtual std::optional<Vec3> getLookAngle();
|
||||||
virtual Vec3* getViewVector(float a);
|
virtual Vec3 getViewVector(float a);
|
||||||
virtual float getAttackAnim(float a);
|
virtual float getAttackAnim(float a);
|
||||||
virtual Vec3* getPos(float a);
|
virtual Vec3 getPos(float a);
|
||||||
virtual HitResult* pick(double range, float a);
|
virtual HitResult* pick(double range, float a);
|
||||||
virtual bool isEffectiveAi();
|
virtual bool isEffectiveAi();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,8 @@ void Arrow::tick() {
|
||||||
if (t > 0) {
|
if (t > 0) {
|
||||||
Tile::tiles[t]->updateShape(level, xTile, yTile, zTile);
|
Tile::tiles[t]->updateShape(level, xTile, yTile, zTile);
|
||||||
AABB* aabb = Tile::tiles[t]->getAABB(level, xTile, yTile, zTile);
|
AABB* aabb = Tile::tiles[t]->getAABB(level, xTile, yTile, zTile);
|
||||||
if (aabb != NULL && aabb->contains(Vec3::newTemp(x, y, z))) {
|
Vec3 pos{x, y, z};
|
||||||
|
if (aabb != NULL && aabb->contains(&pos)) {
|
||||||
inGround = true;
|
inGround = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -217,15 +218,17 @@ void Arrow::tick() {
|
||||||
flightTime++;
|
flightTime++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* from = Vec3::newTemp(x, y, z);
|
Vec3 from{x, y, z};
|
||||||
Vec3* to = Vec3::newTemp(x + xd, y + yd, z + zd);
|
Vec3 to{x + xd, y + yd, z + zd};
|
||||||
HitResult* res = level->clip(from, to, false, true);
|
HitResult* res = level->clip(&from, &to, false, true);
|
||||||
|
|
||||||
|
from = Vec3{x, y, z};
|
||||||
|
to = Vec3{x + xd, y + yd, z + zd};
|
||||||
|
|
||||||
from = Vec3::newTemp(x, y, z);
|
|
||||||
to = Vec3::newTemp(x + xd, y + yd, z + zd);
|
|
||||||
if (res != NULL) {
|
if (res != NULL) {
|
||||||
to = Vec3::newTemp(res->pos->x, res->pos->y, res->pos->z);
|
to = Vec3{res->pos.x, res->pos.y, res->pos.z};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Entity> hitEntity = nullptr;
|
std::shared_ptr<Entity> hitEntity = nullptr;
|
||||||
std::vector<std::shared_ptr<Entity> >* objects = level->getEntities(
|
std::vector<std::shared_ptr<Entity> >* objects = level->getEntities(
|
||||||
shared_from_this(), this->bb->expand(xd, yd, zd)->grow(1, 1, 1));
|
shared_from_this(), this->bb->expand(xd, yd, zd)->grow(1, 1, 1));
|
||||||
|
|
@ -237,9 +240,9 @@ void Arrow::tick() {
|
||||||
|
|
||||||
float rr = 0.3f;
|
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);
|
HitResult* p = bb->clip(&from, &to);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
double dd = from->distanceTo(p->pos);
|
double dd = from.distanceTo(p->pos);
|
||||||
if (dd < nearest || nearest == 0) {
|
if (dd < nearest || nearest == 0) {
|
||||||
hitEntity = e;
|
hitEntity = e;
|
||||||
nearest = dd;
|
nearest = dd;
|
||||||
|
|
@ -359,9 +362,9 @@ void Arrow::tick() {
|
||||||
zTile = res->z;
|
zTile = res->z;
|
||||||
lastTile = level->getTile(xTile, yTile, zTile);
|
lastTile = level->getTile(xTile, yTile, zTile);
|
||||||
lastData = level->getData(xTile, yTile, zTile);
|
lastData = level->getData(xTile, yTile, zTile);
|
||||||
xd = (float)(res->pos->x - x);
|
xd = (float)(res->pos.x - x);
|
||||||
yd = (float)(res->pos->y - y);
|
yd = (float)(res->pos.y - y);
|
||||||
zd = (float)(res->pos->z - z);
|
zd = (float)(res->pos.z - z);
|
||||||
float dd = (float)sqrt(xd * xd + yd * yd + zd * zd);
|
float dd = (float)sqrt(xd * xd + yd * yd + zd * zd);
|
||||||
// 4J added check - zero dd here was creating NaNs
|
// 4J added check - zero dd here was creating NaNs
|
||||||
if (dd > 0.0001f) {
|
if (dd > 0.0001f) {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
#include "../../Util/SharedConstants.h"
|
#include "../../Util/SharedConstants.h"
|
||||||
#include "EnderDragon.h"
|
#include "EnderDragon.h"
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
#define PRINT_DRAGON_STATE_CHANGE_MESSAGES 1
|
#define PRINT_DRAGON_STATE_CHANGE_MESSAGES 1
|
||||||
|
|
||||||
|
|
@ -309,13 +310,14 @@ void EnderDragon::aiStep() {
|
||||||
double xP = 0.0;
|
double xP = 0.0;
|
||||||
double yP = 0.0;
|
double yP = 0.0;
|
||||||
double zP = 0.0;
|
double zP = 0.0;
|
||||||
Vec3* v = getHeadLookVector(1); // getViewVector(1);
|
Vec3 v = getHeadLookVector(1); // getViewVector(1);
|
||||||
// app.DebugPrintf("View vector is (%f,%f,%f) - lsteps %d\n", v->x,
|
// app.DebugPrintf("View vector is (%f,%f,%f) - lsteps %d\n", v->x,
|
||||||
// v->y, v->z, lSteps); unsigned int d = 0; for(unsigned int d = 1;
|
// v->y, v->z, lSteps); unsigned int d = 0; for(unsigned int d = 1;
|
||||||
// d < 3; ++d)
|
// d < 3; ++d)
|
||||||
{
|
{
|
||||||
Vec3* vN = v->normalize();
|
Vec3 vN = Vec3{v.x, v.y, v.z}.normalize();
|
||||||
vN->yRot(-PI / 4);
|
vN.yRot(-PI / 4);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < 8; ++i) {
|
for (unsigned int i = 0; i < 8; ++i) {
|
||||||
if (getSynchedAction() == e_EnderdragonAction_Landing) {
|
if (getSynchedAction() == e_EnderdragonAction_Landing) {
|
||||||
// for(unsigned int j = 0; j < 6; ++j)
|
// for(unsigned int j = 0; j < 6; ++j)
|
||||||
|
|
@ -334,9 +336,9 @@ void EnderDragon::aiStep() {
|
||||||
zP += (level->random->nextBoolean() ? 1 : -1) *
|
zP += (level->random->nextBoolean() ? 1 : -1) *
|
||||||
level->random->nextFloat() / 2;
|
level->random->nextFloat() / 2;
|
||||||
level->addParticle(eParticleType_dragonbreath, xP,
|
level->addParticle(eParticleType_dragonbreath, xP,
|
||||||
yP, zP, (-vN->x * 0.08) + xd,
|
yP, zP, (-vN.x * 0.08) + xd,
|
||||||
(-vN->y * 0.3) + yd,
|
(-vN.y * 0.3) + yd,
|
||||||
(-vN->z * 0.08) + zd);
|
(-vN.z * 0.08) + zd);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
double yVelocity = 0.6;
|
double yVelocity = 0.6;
|
||||||
|
|
@ -356,12 +358,12 @@ void EnderDragon::aiStep() {
|
||||||
zP += (level->random->nextBoolean() ? 1 : -1) *
|
zP += (level->random->nextBoolean() ? 1 : -1) *
|
||||||
level->random->nextFloat() / 2;
|
level->random->nextFloat() / 2;
|
||||||
level->addParticle(eParticleType_dragonbreath, xP,
|
level->addParticle(eParticleType_dragonbreath, xP,
|
||||||
yP, zP, -vN->x * xzVelocity * j,
|
yP, zP, -vN.x * xzVelocity * j,
|
||||||
-vN->y * yVelocity,
|
-vN.y * yVelocity,
|
||||||
-vN->z * xzVelocity * j);
|
-vN.z * xzVelocity * j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vN->yRot(PI / (2 * 8));
|
vN.yRot(PI / (2 * 8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (getSynchedAction() ==
|
} else if (getSynchedAction() ==
|
||||||
|
|
@ -477,13 +479,13 @@ void EnderDragon::aiStep() {
|
||||||
// No movement
|
// No movement
|
||||||
} else if (getSynchedAction() == e_EnderdragonAction_Sitting_Scanning) {
|
} else if (getSynchedAction() == e_EnderdragonAction_Sitting_Scanning) {
|
||||||
if (attackTarget != NULL) {
|
if (attackTarget != NULL) {
|
||||||
Vec3* aim = Vec3::newTemp((attackTarget->x - x), 0,
|
Vec3 aim = Vec3((attackTarget->x - x), 0, (attackTarget->z - z))
|
||||||
(attackTarget->z - z))
|
.normalize();
|
||||||
->normalize();
|
|
||||||
Vec3* dir = Vec3::newTemp(sin(yRot * PI / 180), 0,
|
Vec3 dir = Vec3(sin(yRot * PI / 180), 0, -cos(yRot * PI / 180))
|
||||||
-cos(yRot * PI / 180))
|
.normalize();
|
||||||
->normalize();
|
|
||||||
float dot = (float)dir->dot(aim);
|
float dot = (float)dir.dot(aim);
|
||||||
float angleDegs = acos(dot) * 180 / PI;
|
float angleDegs = acos(dot) * 180 / PI;
|
||||||
angleDegs = angleDegs + 0.5f;
|
angleDegs = angleDegs + 0.5f;
|
||||||
|
|
||||||
|
|
@ -561,13 +563,12 @@ void EnderDragon::aiStep() {
|
||||||
if (yRotD > 50) yRotD = 50;
|
if (yRotD > 50) yRotD = 50;
|
||||||
if (yRotD < -50) yRotD = -50;
|
if (yRotD < -50) yRotD = -50;
|
||||||
|
|
||||||
Vec3* aim =
|
Vec3 aim =
|
||||||
Vec3::newTemp((xTarget - x), (yTarget - y), (zTarget - z))
|
Vec3((xTarget - x), (yTarget - y), (zTarget - z)).normalize();
|
||||||
->normalize();
|
|
||||||
Vec3* dir =
|
Vec3 dir = Vec3(sin(yRot * PI / 180), yd, -cos(yRot * PI / 180))
|
||||||
Vec3::newTemp(sin(yRot * PI / 180), yd, -cos(yRot * PI / 180))
|
.normalize();
|
||||||
->normalize();
|
float dot = (float)(dir.dot(aim) + 0.5f) / 1.5f;
|
||||||
float dot = (float)(dir->dot(aim) + 0.5f) / 1.5f;
|
|
||||||
if (dot < 0) dot = 0;
|
if (dot < 0) dot = 0;
|
||||||
|
|
||||||
yRotA *= 0.80f;
|
yRotA *= 0.80f;
|
||||||
|
|
@ -591,8 +592,8 @@ void EnderDragon::aiStep() {
|
||||||
move(xd, yd, zd);
|
move(xd, yd, zd);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* actual = Vec3::newTemp(xd, yd, zd)->normalize();
|
Vec3 actual = Vec3(xd, yd, zd).normalize();
|
||||||
float slide = (float)(actual->dot(dir) + 1) / 2.0f;
|
float slide = (float)(actual.dot(dir) + 1) / 2.0f;
|
||||||
slide = 0.8f + 0.15f * slide;
|
slide = 0.8f + 0.15f * slide;
|
||||||
|
|
||||||
xd *= slide;
|
xd *= slide;
|
||||||
|
|
@ -733,23 +734,23 @@ void EnderDragon::aiStep() {
|
||||||
maxDist * maxDist) {
|
maxDist * maxDist) {
|
||||||
if (this->canSee(attackTarget)) {
|
if (this->canSee(attackTarget)) {
|
||||||
m_fireballCharge++;
|
m_fireballCharge++;
|
||||||
Vec3* aim = Vec3::newTemp((attackTarget->x - x), 0,
|
Vec3 aim = Vec3((attackTarget->x - x), 0, (attackTarget->z - z))
|
||||||
(attackTarget->z - z))
|
.normalize();
|
||||||
->normalize();
|
|
||||||
Vec3* dir = Vec3::newTemp(sin(yRot * PI / 180), 0,
|
Vec3 dir = Vec3(sin(yRot * PI / 180), 0, -cos(yRot * PI / 180))
|
||||||
-cos(yRot * PI / 180))
|
.normalize();
|
||||||
->normalize();
|
|
||||||
float dot = (float)dir->dot(aim);
|
float dot = (float)dir.dot(aim);
|
||||||
float angleDegs = acos(dot) * 180 / PI;
|
float angleDegs = acos(dot) * 180 / PI;
|
||||||
angleDegs = angleDegs + 0.5f;
|
angleDegs = angleDegs + 0.5f;
|
||||||
|
|
||||||
if (m_fireballCharge >= 20 &&
|
if (m_fireballCharge >= 20 &&
|
||||||
(angleDegs >= 0 && angleDegs < 10)) {
|
(angleDegs >= 0 && angleDegs < 10)) {
|
||||||
double d = 1;
|
double d = 1;
|
||||||
Vec3* v = getViewVector(1);
|
Vec3 v = getViewVector(1);
|
||||||
float startingX = head->x - v->x * d;
|
float startingX = head->x - v.x * d;
|
||||||
float startingY = head->y + head->bbHeight / 2 + 0.5f;
|
float startingY = head->y + head->bbHeight / 2 + 0.5f;
|
||||||
float startingZ = head->z - v->z * d;
|
float startingZ = head->z - v.z * d;
|
||||||
|
|
||||||
double xdd = attackTarget->x - startingX;
|
double xdd = attackTarget->x - startingX;
|
||||||
double ydd =
|
double ydd =
|
||||||
|
|
@ -978,13 +979,13 @@ void EnderDragon::findNewTarget() {
|
||||||
|
|
||||||
int targetNodeIndex = 0;
|
int targetNodeIndex = 0;
|
||||||
if (playerNearestToEgg != NULL) {
|
if (playerNearestToEgg != NULL) {
|
||||||
Vec3* aim = Vec3::newTemp(playerNearestToEgg->x, 0,
|
Vec3 aim = Vec3(playerNearestToEgg->x, 0, playerNearestToEgg->z)
|
||||||
playerNearestToEgg->z)
|
.normalize();
|
||||||
->normalize();
|
|
||||||
// app.DebugPrintf("Final marker node near (%f,%d,%f)\n",
|
// app.DebugPrintf("Final marker node near (%f,%d,%f)\n",
|
||||||
// -aim->x*40,105,-aim->z*40 );
|
// -aim->x*40,105,-aim->z*40 );
|
||||||
targetNodeIndex =
|
targetNodeIndex =
|
||||||
findClosestNode(-aim->x * 40, 105.0, -aim->z * 40);
|
findClosestNode(-aim.x * 40, 105.0, -aim.z * 40);
|
||||||
} else {
|
} else {
|
||||||
targetNodeIndex = findClosestNode(40.0, eggHeight, 0.0);
|
targetNodeIndex = findClosestNode(40.0, eggHeight, 0.0);
|
||||||
}
|
}
|
||||||
|
|
@ -1022,9 +1023,8 @@ void EnderDragon::findNewTarget() {
|
||||||
// !m_holdingPatternClockwise;
|
// !m_holdingPatternClockwise;
|
||||||
|
|
||||||
if (getSynchedAction() == e_EnderdragonAction_Takeoff) {
|
if (getSynchedAction() == e_EnderdragonAction_Takeoff) {
|
||||||
Vec3* v = getHeadLookVector(1);
|
Vec3 v = getHeadLookVector(1);
|
||||||
targetNodeIndex =
|
targetNodeIndex = findClosestNode(-v.x * 40, 105.0, -v.z * 40);
|
||||||
findClosestNode(-v->x * 40, 105.0, -v->z * 40);
|
|
||||||
} else {
|
} else {
|
||||||
if (random->nextInt(8) == 0) {
|
if (random->nextInt(8) == 0) {
|
||||||
m_holdingPatternClockwise = !m_holdingPatternClockwise;
|
m_holdingPatternClockwise = !m_holdingPatternClockwise;
|
||||||
|
|
@ -1488,24 +1488,24 @@ void EnderDragon::strafeAttackTarget() {
|
||||||
|
|
||||||
void EnderDragon::navigateToNextPathNode() {
|
void EnderDragon::navigateToNextPathNode() {
|
||||||
if (m_currentPath != NULL && !m_currentPath->isDone()) {
|
if (m_currentPath != NULL && !m_currentPath->isDone()) {
|
||||||
Vec3* curr = m_currentPath->currentPos();
|
Vec3 curr = m_currentPath->currentPos();
|
||||||
|
|
||||||
m_currentPath->next();
|
m_currentPath->next();
|
||||||
xTarget = curr->x;
|
xTarget = curr.x;
|
||||||
|
|
||||||
if (getSynchedAction() == e_EnderdragonAction_LandingApproach &&
|
if (getSynchedAction() == e_EnderdragonAction_LandingApproach &&
|
||||||
m_currentPath->isDone()) {
|
m_currentPath->isDone()) {
|
||||||
// When heading to the last node on the landing approach, we want
|
// When heading to the last node on the landing approach, we want
|
||||||
// the yCoord to be exact
|
// the yCoord to be exact
|
||||||
yTarget = curr->y;
|
yTarget = curr.y;
|
||||||
} else {
|
} else {
|
||||||
do {
|
do {
|
||||||
yTarget = curr->y + random->nextFloat() * 20;
|
yTarget = curr.y + random->nextFloat() * 20;
|
||||||
} while (yTarget < (curr->y));
|
} while (yTarget < (curr.y));
|
||||||
}
|
}
|
||||||
zTarget = curr->z;
|
zTarget = curr.z;
|
||||||
app.DebugPrintf("Path node pos is (%f,%f,%f)\n", curr->x, curr->y,
|
app.DebugPrintf("Path node pos is (%f,%f,%f)\n", curr.x, curr.y,
|
||||||
curr->z);
|
curr.z);
|
||||||
app.DebugPrintf("Setting new target to (%f,%f,%f)\n", xTarget, yTarget,
|
app.DebugPrintf("Setting new target to (%f,%f,%f)\n", xTarget, yTarget,
|
||||||
zTarget);
|
zTarget);
|
||||||
}
|
}
|
||||||
|
|
@ -1846,8 +1846,8 @@ double EnderDragon::getHeadPartYRotDiff(int partIndex, doubleArray bodyPos,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* EnderDragon::getHeadLookVector(float a) {
|
Vec3 EnderDragon::getHeadLookVector(float a) {
|
||||||
Vec3* result = NULL;
|
Vec3 result;
|
||||||
|
|
||||||
if (getSynchedAction() == e_EnderdragonAction_Landing ||
|
if (getSynchedAction() == e_EnderdragonAction_Landing ||
|
||||||
getSynchedAction() == e_EnderdragonAction_Takeoff) {
|
getSynchedAction() == e_EnderdragonAction_Takeoff) {
|
||||||
|
|
@ -1888,5 +1888,6 @@ Vec3* EnderDragon::getHeadLookVector(float a) {
|
||||||
} else {
|
} else {
|
||||||
result = getViewVector(a);
|
result = getViewVector(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,7 @@ public:
|
||||||
doubleArray partPos);
|
doubleArray partPos);
|
||||||
double getHeadPartYRotDiff(int partIndex, doubleArray bodyPos,
|
double getHeadPartYRotDiff(int partIndex, doubleArray bodyPos,
|
||||||
doubleArray partPos);
|
doubleArray partPos);
|
||||||
Vec3* getHeadLookVector(float a);
|
Vec3 getHeadLookVector(float a);
|
||||||
|
|
||||||
virtual std::wstring getAName() { return app.GetString(IDS_ENDERDRAGON); };
|
virtual std::wstring getAName() { return app.GetString(IDS_ENDERDRAGON); };
|
||||||
virtual float getHealth() { return LivingEntity::getHealth(); };
|
virtual float getHealth() { return LivingEntity::getHealth(); };
|
||||||
|
|
|
||||||
|
|
@ -114,14 +114,15 @@ bool EnderMan::isLookingAtMe(std::shared_ptr<Player> player) {
|
||||||
std::shared_ptr<ItemInstance> helmet = player->inventory->armor[3];
|
std::shared_ptr<ItemInstance> helmet = player->inventory->armor[3];
|
||||||
if (helmet != NULL && helmet->id == Tile::pumpkin_Id) return false;
|
if (helmet != NULL && helmet->id == Tile::pumpkin_Id) return false;
|
||||||
|
|
||||||
Vec3* look = player->getViewVector(1)->normalize();
|
Vec3 look = player->getViewVector(1).normalize();
|
||||||
Vec3* dir = Vec3::newTemp(
|
|
||||||
x - player->x,
|
Vec3 dir{x - player->x,
|
||||||
(bb->y0 + bbHeight / 2) - (player->y + player->getHeadHeight()),
|
(bb->y0 + bbHeight / 2) - (player->y + player->getHeadHeight()),
|
||||||
z - player->z);
|
z - player->z};
|
||||||
double dist = dir->length();
|
|
||||||
dir = dir->normalize();
|
double dist = dir.length();
|
||||||
double dot = look->dot(dir);
|
dir = dir.normalize();
|
||||||
|
double dot = look.dot(dir);
|
||||||
if (dot > 1 - 0.025 / dist) {
|
if (dot > 1 - 0.025 / dist) {
|
||||||
return player->canSee(shared_from_this());
|
return player->canSee(shared_from_this());
|
||||||
}
|
}
|
||||||
|
|
@ -249,13 +250,13 @@ bool EnderMan::teleport() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EnderMan::teleportTowards(std::shared_ptr<Entity> e) {
|
bool EnderMan::teleportTowards(std::shared_ptr<Entity> e) {
|
||||||
Vec3* dir = Vec3::newTemp(
|
Vec3 dir{x - e->x, bb->y0 + bbHeight / 2 - e->y + e->getHeadHeight(),
|
||||||
x - e->x, bb->y0 + bbHeight / 2 - e->y + e->getHeadHeight(), z - e->z);
|
z - e->z};
|
||||||
dir = dir->normalize();
|
dir = dir.normalize();
|
||||||
double d = 16;
|
double d = 16;
|
||||||
double xx = x + (random->nextDouble() - 0.5) * 8 - dir->x * d;
|
double xx = x + (random->nextDouble() - 0.5) * 8 - dir.x * d;
|
||||||
double yy = y + (random->nextInt(16) - 8) - dir->y * d;
|
double yy = y + (random->nextInt(16) - 8) - dir.y * d;
|
||||||
double zz = z + (random->nextDouble() - 0.5) * 8 - dir->z * d;
|
double zz = z + (random->nextDouble() - 0.5) * 8 - dir.z * d;
|
||||||
return teleport(xx, yy, zz);
|
return teleport(xx, yy, zz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -166,14 +166,14 @@ void Fireball::tick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
MemSect(41);
|
MemSect(41);
|
||||||
Vec3* from = Vec3::newTemp(x, y, z);
|
Vec3 from(x, y, z);
|
||||||
Vec3* to = Vec3::newTemp(x + xd, y + yd, z + zd);
|
Vec3 to(x + xd, y + yd, z + zd);
|
||||||
HitResult* res = level->clip(from, to);
|
HitResult* res = level->clip(&from, &to);
|
||||||
|
|
||||||
from = Vec3::newTemp(x, y, z);
|
from = Vec3(x, y, z);
|
||||||
to = Vec3::newTemp(x + xd, y + yd, z + zd);
|
to = Vec3(x + xd, y + yd, z + zd);
|
||||||
if (res != NULL) {
|
if (res != NULL) {
|
||||||
to = Vec3::newTemp(res->pos->x, res->pos->y, res->pos->z);
|
to = Vec3{res->pos.x, res->pos.y, res->pos.z};
|
||||||
}
|
}
|
||||||
std::shared_ptr<Entity> hitEntity = nullptr;
|
std::shared_ptr<Entity> hitEntity = nullptr;
|
||||||
std::vector<std::shared_ptr<Entity> >* objects = level->getEntities(
|
std::vector<std::shared_ptr<Entity> >* objects = level->getEntities(
|
||||||
|
|
@ -188,9 +188,9 @@ void Fireball::tick() {
|
||||||
|
|
||||||
float rr = 0.3f;
|
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);
|
HitResult* p = bb->clip(&from, &to);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
double dd = from->distanceTo(p->pos);
|
double dd = from.distanceTo(p->pos);
|
||||||
if (dd < nearest || nearest == 0) {
|
if (dd < nearest || nearest == 0) {
|
||||||
hitEntity = e;
|
hitEntity = e;
|
||||||
nearest = dd;
|
nearest = dd;
|
||||||
|
|
@ -300,8 +300,8 @@ bool Fireball::hurt(DamageSource* source, float damage) {
|
||||||
markHurt();
|
markHurt();
|
||||||
|
|
||||||
if (source->getEntity() != NULL) {
|
if (source->getEntity() != NULL) {
|
||||||
Vec3* lookAngle = source->getEntity()->getLookAngle();
|
auto lookAngle = source->getEntity()->getLookAngle();
|
||||||
if (lookAngle != NULL) {
|
if (lookAngle.has_value()) {
|
||||||
xd = lookAngle->x;
|
xd = lookAngle->x;
|
||||||
yd = lookAngle->y;
|
yd = lookAngle->y;
|
||||||
zd = lookAngle->z;
|
zd = lookAngle->z;
|
||||||
|
|
@ -309,6 +309,7 @@ bool Fireball::hurt(DamageSource* source, float damage) {
|
||||||
yPower = yd * 0.1;
|
yPower = yd * 0.1;
|
||||||
zPower = zd * 0.1;
|
zPower = zd * 0.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source->getEntity()->instanceof(eTYPE_LIVINGENTITY)) {
|
if (source->getEntity()->instanceof(eTYPE_LIVINGENTITY)) {
|
||||||
owner =
|
owner =
|
||||||
std::dynamic_pointer_cast<LivingEntity>(source->getEntity());
|
std::dynamic_pointer_cast<LivingEntity>(source->getEntity());
|
||||||
|
|
|
||||||
|
|
@ -203,14 +203,14 @@ void FishingHook::tick() {
|
||||||
flightTime++;
|
flightTime++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* from = Vec3::newTemp(x, y, z);
|
Vec3 from(x, y, z);
|
||||||
Vec3* to = Vec3::newTemp(x + xd, y + yd, z + zd);
|
Vec3 to(x + xd, y + yd, z + zd);
|
||||||
HitResult* res = level->clip(from, to);
|
HitResult* res = level->clip(&from, &to);
|
||||||
|
|
||||||
from = Vec3::newTemp(x, y, z);
|
from = Vec3(x, y, z);
|
||||||
to = Vec3::newTemp(x + xd, y + yd, z + zd);
|
to = Vec3(x + xd, y + yd, z + zd);
|
||||||
if (res != NULL) {
|
if (res != NULL) {
|
||||||
to = Vec3::newTemp(res->pos->x, res->pos->y, res->pos->z);
|
to = Vec3(res->pos.x, res->pos.y, res->pos.z);
|
||||||
}
|
}
|
||||||
std::shared_ptr<Entity> hitEntity = nullptr;
|
std::shared_ptr<Entity> hitEntity = nullptr;
|
||||||
std::vector<std::shared_ptr<Entity> >* objects = level->getEntities(
|
std::vector<std::shared_ptr<Entity> >* objects = level->getEntities(
|
||||||
|
|
@ -223,9 +223,9 @@ void FishingHook::tick() {
|
||||||
|
|
||||||
float rr = 0.3f;
|
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);
|
HitResult* p = bb->clip(&from, &to);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
double dd = from->distanceTo(p->pos);
|
double dd = from.distanceTo(p->pos);
|
||||||
if (dd < nearest || nearest == 0) {
|
if (dd < nearest || nearest == 0) {
|
||||||
hitEntity = e;
|
hitEntity = e;
|
||||||
nearest = dd;
|
nearest = dd;
|
||||||
|
|
|
||||||
|
|
@ -141,10 +141,10 @@ void Ghast::serverAiStep() {
|
||||||
ydd, zdd));
|
ydd, zdd));
|
||||||
ie->explosionPower = explosionPower;
|
ie->explosionPower = explosionPower;
|
||||||
double d = 4;
|
double d = 4;
|
||||||
Vec3* v = getViewVector(1);
|
Vec3 v = getViewVector(1);
|
||||||
ie->x = x + v->x * d;
|
ie->x = x + v.x * d;
|
||||||
ie->y = y + bbHeight / 2 + 0.5f;
|
ie->y = y + bbHeight / 2 + 0.5f;
|
||||||
ie->z = z + v->z * d;
|
ie->z = z + v.z * d;
|
||||||
level->addEntity(ie);
|
level->addEntity(ie);
|
||||||
charge = -40;
|
charge = -40;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@
|
||||||
#include "../../../Minecraft.Client/Level/ServerLevel.h"
|
#include "../../../Minecraft.Client/Level/ServerLevel.h"
|
||||||
#include "../../Headers/com.mojang.nbt.h"
|
#include "../../Headers/com.mojang.nbt.h"
|
||||||
#include "Minecart.h"
|
#include "Minecart.h"
|
||||||
|
#include <cstddef>
|
||||||
|
#include <optional>
|
||||||
#include "../../Util/SharedConstants.h"
|
#include "../../Util/SharedConstants.h"
|
||||||
|
|
||||||
const int Minecart::EXITS[][2][3] = {
|
const int Minecart::EXITS[][2][3] = {
|
||||||
|
|
@ -129,10 +131,9 @@ bool Minecart::hurt(DamageSource* source, float hurtDamage) {
|
||||||
if (dynamic_cast<EntityDamageSource*>(source) != NULL) {
|
if (dynamic_cast<EntityDamageSource*>(source) != NULL) {
|
||||||
std::shared_ptr<Entity> attacker = source->getDirectEntity();
|
std::shared_ptr<Entity> attacker = source->getDirectEntity();
|
||||||
|
|
||||||
if (attacker->instanceof
|
if (attacker->instanceof(eTYPE_PLAYER) &&
|
||||||
(eTYPE_PLAYER) &&
|
!std::dynamic_pointer_cast<Player>(attacker)->isAllowedToHurtEntity(
|
||||||
!std::dynamic_pointer_cast<Player>(attacker)
|
shared_from_this())) {
|
||||||
->isAllowedToHurtEntity(shared_from_this())) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -149,9 +150,9 @@ bool Minecart::hurt(DamageSource* source, float hurtDamage) {
|
||||||
if (rider.lock() != NULL && rider.lock() == source->getEntity())
|
if (rider.lock() != NULL && rider.lock() == source->getEntity())
|
||||||
hurtDamage += 1;
|
hurtDamage += 1;
|
||||||
|
|
||||||
bool creativePlayer =
|
bool creativePlayer = source->getEntity() != NULL &&
|
||||||
source->getEntity() != NULL && source->getEntity()->instanceof
|
source->getEntity()->instanceof(eTYPE_PLAYER) &&
|
||||||
(eTYPE_PLAYER) && std::dynamic_pointer_cast<Player>(source->getEntity())
|
std::dynamic_pointer_cast<Player>(source->getEntity())
|
||||||
->abilities.instabuild;
|
->abilities.instabuild;
|
||||||
|
|
||||||
if (creativePlayer || getDamage() > 20 * 2) {
|
if (creativePlayer || getDamage() > 20 * 2) {
|
||||||
|
|
@ -310,8 +311,8 @@ void Minecart::tick() {
|
||||||
AUTO_VAR(itEnd, entities->end());
|
AUTO_VAR(itEnd, entities->end());
|
||||||
for (AUTO_VAR(it, entities->begin()); it != itEnd; it++) {
|
for (AUTO_VAR(it, entities->begin()); it != itEnd; it++) {
|
||||||
std::shared_ptr<Entity> e = (*it); // entities->at(i);
|
std::shared_ptr<Entity> e = (*it); // entities->at(i);
|
||||||
if (e != rider.lock() && e->isPushable() && e->instanceof
|
if (e != rider.lock() && e->isPushable() &&
|
||||||
(eTYPE_MINECART)) {
|
e->instanceof(eTYPE_MINECART)) {
|
||||||
std::shared_ptr<Minecart> cart =
|
std::shared_ptr<Minecart> cart =
|
||||||
std::dynamic_pointer_cast<Minecart>(e);
|
std::dynamic_pointer_cast<Minecart>(e);
|
||||||
cart->m_bHasPushedCartThisTick = false;
|
cart->m_bHasPushedCartThisTick = false;
|
||||||
|
|
@ -362,7 +363,7 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed,
|
||||||
double slideSpeed, int tile, int data) {
|
double slideSpeed, int tile, int data) {
|
||||||
fallDistance = 0;
|
fallDistance = 0;
|
||||||
|
|
||||||
Vec3* oldPos = getPos(x, y, z);
|
auto oldPos = getPos(x, y, z);
|
||||||
y = yt;
|
y = yt;
|
||||||
|
|
||||||
bool powerTrack = false;
|
bool powerTrack = false;
|
||||||
|
|
@ -405,7 +406,7 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed,
|
||||||
xd = pow * xD / dd;
|
xd = pow * xD / dd;
|
||||||
zd = pow * zD / dd;
|
zd = pow * zD / dd;
|
||||||
|
|
||||||
if (rider.lock() != NULL && rider.lock()->instanceof (eTYPE_LIVINGENTITY)) {
|
if (rider.lock() != NULL && rider.lock()->instanceof(eTYPE_LIVINGENTITY)) {
|
||||||
std::shared_ptr<LivingEntity> living =
|
std::shared_ptr<LivingEntity> living =
|
||||||
std::dynamic_pointer_cast<LivingEntity>(rider.lock());
|
std::dynamic_pointer_cast<LivingEntity>(rider.lock());
|
||||||
|
|
||||||
|
|
@ -490,8 +491,8 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed,
|
||||||
|
|
||||||
applyNaturalSlowdown();
|
applyNaturalSlowdown();
|
||||||
|
|
||||||
Vec3* newPos = getPos(x, y, z);
|
auto newPos = getPos(x, y, z);
|
||||||
if (newPos != NULL && oldPos != NULL) {
|
if (newPos.has_value() && oldPos.has_value()) {
|
||||||
double speed = (oldPos->y - newPos->y) * 0.05;
|
double speed = (oldPos->y - newPos->y) * 0.05;
|
||||||
|
|
||||||
pow = sqrt(xd * xd + zd * zd);
|
pow = sqrt(xd * xd + zd * zd);
|
||||||
|
|
@ -550,7 +551,8 @@ void Minecart::applyNaturalSlowdown() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* Minecart::getPosOffs(double x, double y, double z, double offs) {
|
std::optional<Vec3> Minecart::getPosOffs(double x, double y, double z,
|
||||||
|
double offs) {
|
||||||
int xt = Mth::floor(x);
|
int xt = Mth::floor(x);
|
||||||
int yt = Mth::floor(y);
|
int yt = Mth::floor(y);
|
||||||
int zt = Mth::floor(z);
|
int zt = Mth::floor(z);
|
||||||
|
|
@ -595,10 +597,11 @@ Vec3* Minecart::getPosOffs(double x, double y, double z, double offs) {
|
||||||
|
|
||||||
return getPos(x, y, z);
|
return getPos(x, y, z);
|
||||||
}
|
}
|
||||||
return NULL;
|
|
||||||
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* Minecart::getPos(double x, double y, double z) {
|
std::optional<Vec3> Minecart::getPos(double x, double y, double z) {
|
||||||
int xt = Mth::floor(x);
|
int xt = Mth::floor(x);
|
||||||
int yt = Mth::floor(y);
|
int yt = Mth::floor(y);
|
||||||
int zt = Mth::floor(z);
|
int zt = Mth::floor(z);
|
||||||
|
|
@ -654,9 +657,10 @@ Vec3* Minecart::getPos(double x, double y, double z) {
|
||||||
z = z0 + zD * progress;
|
z = z0 + zD * progress;
|
||||||
if (yD < 0) y += 1;
|
if (yD < 0) y += 1;
|
||||||
if (yD > 0) y += 0.5;
|
if (yD > 0) y += 0.5;
|
||||||
return Vec3::newTemp(x, y, z);
|
return Vec3(x, y, z);
|
||||||
}
|
}
|
||||||
return NULL;
|
|
||||||
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Minecart::readAdditionalSaveData(CompoundTag* tag) {
|
void Minecart::readAdditionalSaveData(CompoundTag* tag) {
|
||||||
|
|
@ -689,10 +693,9 @@ void Minecart::push(std::shared_ptr<Entity> e) {
|
||||||
if (level->isClientSide) return;
|
if (level->isClientSide) return;
|
||||||
|
|
||||||
if (e == rider.lock()) return;
|
if (e == rider.lock()) return;
|
||||||
if (e->instanceof (eTYPE_LIVINGENTITY) && !e->instanceof
|
if (e->instanceof(eTYPE_LIVINGENTITY) && !e->instanceof(eTYPE_PLAYER) &&
|
||||||
(eTYPE_PLAYER) && !e->instanceof
|
!e->instanceof(eTYPE_VILLAGERGOLEM) && (getType() == TYPE_RIDEABLE) &&
|
||||||
(eTYPE_VILLAGERGOLEM) && (getType() == TYPE_RIDEABLE) &&
|
(xd * xd + zd * zd > 0.01)) {
|
||||||
(xd * xd + zd * zd > 0.01)) {
|
|
||||||
if ((rider.lock() == NULL) && (e->riding == NULL)) {
|
if ((rider.lock() == NULL) && (e->riding == NULL)) {
|
||||||
e->ride(shared_from_this());
|
e->ride(shared_from_this());
|
||||||
}
|
}
|
||||||
|
|
@ -718,7 +721,7 @@ void Minecart::push(std::shared_ptr<Entity> e) {
|
||||||
xa *= 0.5;
|
xa *= 0.5;
|
||||||
za *= 0.5;
|
za *= 0.5;
|
||||||
|
|
||||||
if (e->instanceof (eTYPE_MINECART)) {
|
if (e->instanceof(eTYPE_MINECART)) {
|
||||||
double xo = e->x - x;
|
double xo = e->x - x;
|
||||||
double zo = e->z - z;
|
double zo = e->z - z;
|
||||||
|
|
||||||
|
|
@ -726,12 +729,13 @@ void Minecart::push(std::shared_ptr<Entity> e) {
|
||||||
// other
|
// other
|
||||||
// Fix for #38882 - TU5: Gameplay: Minecart with furnace is not
|
// Fix for #38882 - TU5: Gameplay: Minecart with furnace is not
|
||||||
// able to move another minecart on the rail.
|
// able to move another minecart on the rail.
|
||||||
Vec3* dir = Vec3::newTemp(xo, 0, zo)->normalize();
|
Vec3 dir(xo, 0, zo);
|
||||||
Vec3* facing =
|
dir = dir.normalize();
|
||||||
Vec3::newTemp(cos(yRot * PI / 180), 0, sin(yRot * PI / 180))
|
|
||||||
->normalize();
|
|
||||||
|
|
||||||
double dot = abs(dir->dot(facing));
|
Vec3 facing(cos(yRot * PI / 180), 0, sin(yRot * PI / 180));
|
||||||
|
facing = facing.normalize();
|
||||||
|
|
||||||
|
double dot = abs(dir.dot(facing));
|
||||||
|
|
||||||
if (dot < 0.8f) {
|
if (dot < 0.8f) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <optional>
|
||||||
#include "../Entity.h"
|
#include "../Entity.h"
|
||||||
|
|
||||||
class DamageSource;
|
class DamageSource;
|
||||||
|
|
@ -77,8 +78,9 @@ protected:
|
||||||
virtual void moveAlongTrack(int xt, int yt, int zt, double maxSpeed,
|
virtual void moveAlongTrack(int xt, int yt, int zt, double maxSpeed,
|
||||||
double slideSpeed, int tile, int data);
|
double slideSpeed, int tile, int data);
|
||||||
virtual void applyNaturalSlowdown();
|
virtual void applyNaturalSlowdown();
|
||||||
virtual Vec3* getPosOffs(double x, double y, double z, double offs);
|
virtual std::optional<Vec3> getPosOffs(double x, double y, double z,
|
||||||
virtual Vec3* getPos(double x, double y, double z);
|
double offs);
|
||||||
|
virtual std::optional<Vec3> getPos(double x, double y, double z);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void addAdditonalSaveData(CompoundTag* base);
|
virtual void addAdditonalSaveData(CompoundTag* base);
|
||||||
|
|
|
||||||
|
|
@ -120,18 +120,20 @@ void PathfinderMob::serverAiStep() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* target = path->currentPos(shared_from_this());
|
Vec3 target = path->currentPos(shared_from_this());
|
||||||
double r = bbWidth * 2;
|
double r = bbWidth * 2;
|
||||||
while (target != NULL && target->distanceToSqr(x, target->y, z) < r * r) {
|
while (target.distanceToSqr(x, target.y, z) < r * r) {
|
||||||
path->next();
|
path->next();
|
||||||
if (path->isDone()) {
|
if (path->isDone()) {
|
||||||
target = NULL;
|
|
||||||
setPath(NULL); // 4J - changed to setPath from path =
|
setPath(NULL); // 4J - changed to setPath from path =
|
||||||
|
break;
|
||||||
} else
|
} else
|
||||||
target = path->currentPos(shared_from_this());
|
target = path->currentPos(shared_from_this());
|
||||||
}
|
}
|
||||||
|
|
||||||
jumping = false;
|
jumping = false;
|
||||||
|
// 4jcraft - refactoring Vec3 shows this branch never hits
|
||||||
|
/*
|
||||||
if (target != NULL) {
|
if (target != NULL) {
|
||||||
double xd = target->x - x;
|
double xd = target->x - x;
|
||||||
double zd = target->z - z;
|
double zd = target->z - z;
|
||||||
|
|
@ -165,6 +167,7 @@ void PathfinderMob::serverAiStep() {
|
||||||
jumping = true;
|
jumping = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if (attackTarget != NULL) {
|
if (attackTarget != NULL) {
|
||||||
lookAt(attackTarget, 30, 30);
|
lookAt(attackTarget, 30, 30);
|
||||||
|
|
|
||||||
|
|
@ -135,14 +135,14 @@ void Throwable::tick() {
|
||||||
flightTime++;
|
flightTime++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* from = Vec3::newTemp(x, y, z);
|
Vec3 from(x, y, z);
|
||||||
Vec3* to = Vec3::newTemp(x + xd, y + yd, z + zd);
|
Vec3 to(x + xd, y + yd, z + zd);
|
||||||
HitResult* res = level->clip(from, to);
|
HitResult* res = level->clip(&from, &to);
|
||||||
|
|
||||||
from = Vec3::newTemp(x, y, z);
|
from = Vec3(x, y, z);
|
||||||
to = Vec3::newTemp(x + xd, y + yd, z + zd);
|
to = Vec3(x + xd, y + yd, z + zd);
|
||||||
if (res != NULL) {
|
if (res != NULL) {
|
||||||
to = Vec3::newTemp(res->pos->x, res->pos->y, res->pos->z);
|
to = Vec3(res->pos.x, res->pos.y, res->pos.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!level->isClientSide) {
|
if (!level->isClientSide) {
|
||||||
|
|
@ -157,9 +157,9 @@ void Throwable::tick() {
|
||||||
|
|
||||||
float rr = 0.3f;
|
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);
|
HitResult* p = bb->clip(&from, &to);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
double dd = from->distanceTo(p->pos);
|
double dd = from.distanceTo(p->pos);
|
||||||
delete p;
|
delete p;
|
||||||
if (dd < nearest || nearest == 0) {
|
if (dd < nearest || nearest == 0) {
|
||||||
hitEntity = e;
|
hitEntity = e;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
#include "../Headers/net.minecraft.world.level.tile.h"
|
#include "../Headers/net.minecraft.world.level.tile.h"
|
||||||
#include "../Headers/net.minecraft.world.phys.h"
|
#include "../Headers/net.minecraft.world.phys.h"
|
||||||
#include "ItemInstance.h"
|
#include "ItemInstance.h"
|
||||||
|
#include "Util/Vec3.h"
|
||||||
#include "BoatItem.h"
|
#include "BoatItem.h"
|
||||||
|
|
||||||
BoatItem::BoatItem(int id) : Item(id) { maxStackSize = 1; }
|
BoatItem::BoatItem(int id) : Item(id) { maxStackSize = 1; }
|
||||||
|
|
@ -24,7 +25,7 @@ bool BoatItem::TestUse(std::shared_ptr<ItemInstance> itemInstance, Level* level,
|
||||||
player->yo + (player->y - player->yo) + 1.62 - player->heightOffset;
|
player->yo + (player->y - player->yo) + 1.62 - player->heightOffset;
|
||||||
double z = player->zo + (player->z - player->zo);
|
double z = player->zo + (player->z - player->zo);
|
||||||
|
|
||||||
Vec3* from = Vec3::newTemp(x, y, z);
|
Vec3 from(x, y, z);
|
||||||
|
|
||||||
float yCos = Mth::cos(-yRot * Mth::RAD_TO_GRAD - PI);
|
float yCos = Mth::cos(-yRot * Mth::RAD_TO_GRAD - PI);
|
||||||
float ySin = Mth::sin(-yRot * Mth::RAD_TO_GRAD - PI);
|
float ySin = Mth::sin(-yRot * Mth::RAD_TO_GRAD - PI);
|
||||||
|
|
@ -36,8 +37,9 @@ bool BoatItem::TestUse(std::shared_ptr<ItemInstance> itemInstance, Level* level,
|
||||||
float za = yCos * xCos;
|
float za = yCos * xCos;
|
||||||
|
|
||||||
double range = 5;
|
double range = 5;
|
||||||
Vec3* to = from->add(xa * range, ya * range, za * range);
|
Vec3 to(xa * range, ya * range, za * range);
|
||||||
HitResult* hr = level->clip(from, to, true);
|
to = to.add(from.x, from.y, from.z);
|
||||||
|
HitResult* hr = level->clip(&from, &to, true);
|
||||||
if (hr == NULL) return false;
|
if (hr == NULL) return false;
|
||||||
|
|
||||||
if (hr->type == HitResult::TILE) {
|
if (hr->type == HitResult::TILE) {
|
||||||
|
|
@ -60,7 +62,7 @@ std::shared_ptr<ItemInstance> BoatItem::use(
|
||||||
player->yo + (player->y - player->yo) * a + 1.62 - player->heightOffset;
|
player->yo + (player->y - player->yo) * a + 1.62 - player->heightOffset;
|
||||||
double z = player->zo + (player->z - player->zo) * a;
|
double z = player->zo + (player->z - player->zo) * a;
|
||||||
|
|
||||||
Vec3* from = Vec3::newTemp(x, y, z);
|
Vec3 from(x, y, z);
|
||||||
|
|
||||||
float yCos = Mth::cos(-yRot * Mth::RAD_TO_GRAD - PI);
|
float yCos = Mth::cos(-yRot * Mth::RAD_TO_GRAD - PI);
|
||||||
float ySin = Mth::sin(-yRot * Mth::RAD_TO_GRAD - PI);
|
float ySin = Mth::sin(-yRot * Mth::RAD_TO_GRAD - PI);
|
||||||
|
|
@ -72,18 +74,18 @@ std::shared_ptr<ItemInstance> BoatItem::use(
|
||||||
float za = yCos * xCos;
|
float za = yCos * xCos;
|
||||||
|
|
||||||
double range = 5;
|
double range = 5;
|
||||||
Vec3* to = from->add(xa * range, ya * range, za * range);
|
Vec3 to(xa * range, ya * range, za * range);
|
||||||
HitResult* hr = level->clip(from, to, true);
|
to = to.add(from.x, from.y, from.z);
|
||||||
|
HitResult* hr = level->clip(&from, &to, true);
|
||||||
if (hr == NULL) return itemInstance;
|
if (hr == NULL) return itemInstance;
|
||||||
|
|
||||||
// check entity collision
|
// check entity collision
|
||||||
Vec3* b = player->getViewVector(a);
|
Vec3 b = player->getViewVector(a);
|
||||||
bool hitEntity = false;
|
bool hitEntity = false;
|
||||||
float overlap = 1;
|
float overlap = 1;
|
||||||
std::vector<std::shared_ptr<Entity> >* objects = level->getEntities(
|
std::vector<std::shared_ptr<Entity> >* objects = level->getEntities(
|
||||||
player,
|
player, player->bb->expand(b.x * (range), b.y * (range), b.z * (range))
|
||||||
player->bb->expand(b->x * (range), b->y * (range), b->z * (range))
|
->grow(overlap, overlap, overlap));
|
||||||
->grow(overlap, overlap, overlap));
|
|
||||||
// for (int i = 0; i < objects.size(); i++) {
|
// for (int i = 0; i < objects.size(); i++) {
|
||||||
for (AUTO_VAR(it, objects->begin()); it != objects->end(); ++it) {
|
for (AUTO_VAR(it, objects->begin()); it != objects->end(); ++it) {
|
||||||
std::shared_ptr<Entity> e = *it; // objects.get(i);
|
std::shared_ptr<Entity> e = *it; // objects.get(i);
|
||||||
|
|
@ -91,7 +93,7 @@ std::shared_ptr<ItemInstance> BoatItem::use(
|
||||||
|
|
||||||
float rr = e->getPickRadius();
|
float rr = e->getPickRadius();
|
||||||
AABB* bb = e->bb->grow(rr, rr, rr);
|
AABB* bb = e->bb->grow(rr, rr, rr);
|
||||||
if (bb->contains(from)) {
|
if (bb->contains(&from)) {
|
||||||
hitEntity = true;
|
hitEntity = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
#include "Item.h"
|
#include "Item.h"
|
||||||
#include "HangingEntityItem.h"
|
#include "HangingEntityItem.h"
|
||||||
#include "../Util/HtmlString.h"
|
#include "../Util/HtmlString.h"
|
||||||
|
#include "Util/Vec3.h"
|
||||||
|
|
||||||
typedef Item::Tier _Tier;
|
typedef Item::Tier _Tier;
|
||||||
|
|
||||||
|
|
@ -1602,7 +1603,7 @@ HitResult* Item::getPlayerPOVHitResult(Level* level,
|
||||||
player->yo + (player->y - player->yo) * a + 1.62 - player->heightOffset;
|
player->yo + (player->y - player->yo) * a + 1.62 - player->heightOffset;
|
||||||
double z = player->zo + (player->z - player->zo) * a;
|
double z = player->zo + (player->z - player->zo) * a;
|
||||||
|
|
||||||
Vec3* from = Vec3::newTemp(x, y, z);
|
Vec3 from(x, y, z);
|
||||||
|
|
||||||
float yCos = (float)cos(-yRot * Mth::RAD_TO_GRAD - PI);
|
float yCos = (float)cos(-yRot * Mth::RAD_TO_GRAD - PI);
|
||||||
float ySin = (float)sin(-yRot * Mth::RAD_TO_GRAD - PI);
|
float ySin = (float)sin(-yRot * Mth::RAD_TO_GRAD - PI);
|
||||||
|
|
@ -1614,8 +1615,9 @@ HitResult* Item::getPlayerPOVHitResult(Level* level,
|
||||||
float za = yCos * xCos;
|
float za = yCos * xCos;
|
||||||
|
|
||||||
double range = 5;
|
double range = 5;
|
||||||
Vec3* to = from->add(xa * range, ya * range, za * range);
|
Vec3 to(xa * range, ya * range, za * range);
|
||||||
return level->clip(from, to, alsoPickLiquid, !alsoPickLiquid);
|
to = to.add(from.x, from.y, from.z);
|
||||||
|
return level->clip(&from, &to, alsoPickLiquid, !alsoPickLiquid);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Item::getEnchantmentValue() { return 0; }
|
int Item::getEnchantmentValue() { return 0; }
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ float* Dimension::getSunriseColor(float td, float a) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* Dimension::getFogColor(float td, float a) const {
|
Vec3 Dimension::getFogColor(float td, float a) const {
|
||||||
float br = Mth::cos(td * PI * 2) * 2 + 0.5f;
|
float br = Mth::cos(td * PI * 2) * 2 + 0.5f;
|
||||||
if (br < 0.0f) br = 0.0f;
|
if (br < 0.0f) br = 0.0f;
|
||||||
if (br > 1.0f) br = 1.0f;
|
if (br > 1.0f) br = 1.0f;
|
||||||
|
|
@ -172,7 +172,7 @@ Vec3* Dimension::getFogColor(float td, float a) const {
|
||||||
g *= br * 0.94f + 0.06f;
|
g *= br * 0.94f + 0.06f;
|
||||||
b *= br * 0.91f + 0.09f;
|
b *= br * 0.91f + 0.09f;
|
||||||
|
|
||||||
return Vec3::newTemp(r, g, b);
|
return Vec3(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Dimension::mayRespawn() const { return true; }
|
bool Dimension::mayRespawn() const { return true; }
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual float* getSunriseColor(float td, float a);
|
virtual float* getSunriseColor(float td, float a);
|
||||||
virtual Vec3* getFogColor(float td, float a) const;
|
virtual Vec3 getFogColor(float td, float a) const;
|
||||||
virtual bool mayRespawn() const;
|
virtual bool mayRespawn() const;
|
||||||
static Dimension* getNew(int id);
|
static Dimension* getNew(int id);
|
||||||
virtual float getCloudHeight();
|
virtual float getCloudHeight();
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ void HellDimension::init() {
|
||||||
id = -1;
|
id = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* HellDimension::getFogColor(float td, float a) const {
|
Vec3 HellDimension::getFogColor(float td, float a) const {
|
||||||
int colour = Minecraft::GetInstance()->getColourTable()->getColor(
|
int colour = Minecraft::GetInstance()->getColourTable()->getColor(
|
||||||
eMinecraftColour_Nether_Fog_Colour);
|
eMinecraftColour_Nether_Fog_Colour);
|
||||||
uint8_t redComponent = ((colour >> 16) & 0xFF);
|
uint8_t redComponent = ((colour >> 16) & 0xFF);
|
||||||
|
|
@ -25,7 +25,7 @@ Vec3* HellDimension::getFogColor(float td, float a) const {
|
||||||
float rr = (float)redComponent / 256; // 0.2f;
|
float rr = (float)redComponent / 256; // 0.2f;
|
||||||
float gg = (float)greenComponent / 256; // 0.03f;
|
float gg = (float)greenComponent / 256; // 0.03f;
|
||||||
float bb = (float)blueComponent / 256; // 0.03f;
|
float bb = (float)blueComponent / 256; // 0.03f;
|
||||||
return Vec3::newTemp(rr, gg, bb);
|
return Vec3(rr, gg, bb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HellDimension::updateLightRamp() {
|
void HellDimension::updateLightRamp() {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
class HellDimension : public Dimension {
|
class HellDimension : public Dimension {
|
||||||
public:
|
public:
|
||||||
virtual void init();
|
virtual void init();
|
||||||
virtual Vec3* getFogColor(float td, float a) const;
|
virtual Vec3 getFogColor(float td, float a) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void updateLightRamp();
|
virtual void updateLightRamp();
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ float SkyIslandDimension::getTimeOfDay(int64_t time, float a) const {
|
||||||
|
|
||||||
float* SkyIslandDimension::getSunriseColor(float td, float a) { return NULL; }
|
float* SkyIslandDimension::getSunriseColor(float td, float a) { return NULL; }
|
||||||
|
|
||||||
Vec3* SkyIslandDimension::getFogColor(float td, float a) const {
|
Vec3 SkyIslandDimension::getFogColor(float td, float a) const {
|
||||||
int fogColor = 0x8080a0;
|
int fogColor = 0x8080a0;
|
||||||
float br = Mth::cos(td * PI * 2) * 2 + 0.5f;
|
float br = Mth::cos(td * PI * 2) * 2 + 0.5f;
|
||||||
if (br < 0.0f) br = 0.0f;
|
if (br < 0.0f) br = 0.0f;
|
||||||
|
|
@ -33,7 +33,7 @@ Vec3* SkyIslandDimension::getFogColor(float td, float a) const {
|
||||||
g *= br * 0.94f + 0.06f;
|
g *= br * 0.94f + 0.06f;
|
||||||
b *= br * 0.91f + 0.09f;
|
b *= br * 0.91f + 0.09f;
|
||||||
|
|
||||||
return Vec3::newTemp(r, g, b);
|
return Vec3(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkyIslandDimension::hasGround() { return false; }
|
bool SkyIslandDimension::hasGround() { return false; }
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ float TheEndDimension::getTimeOfDay(int64_t time, float a) const {
|
||||||
|
|
||||||
float* TheEndDimension::getSunriseColor(float td, float a) { return NULL; }
|
float* TheEndDimension::getSunriseColor(float td, float a) { return NULL; }
|
||||||
|
|
||||||
Vec3* TheEndDimension::getFogColor(float td, float a) const {
|
Vec3 TheEndDimension::getFogColor(float td, float a) const {
|
||||||
int fogColor = Minecraft::GetInstance()->getColourTable()->getColor(
|
int fogColor = Minecraft::GetInstance()->getColourTable()->getColor(
|
||||||
eMinecraftColour_End_Fog_Colour); // 0xa080a0;
|
eMinecraftColour_End_Fog_Colour); // 0xa080a0;
|
||||||
float br = Mth::cos(td * PI * 2) * 2 + 0.5f;
|
float br = Mth::cos(td * PI * 2) * 2 + 0.5f;
|
||||||
|
|
@ -37,7 +37,7 @@ Vec3* TheEndDimension::getFogColor(float td, float a) const {
|
||||||
g *= br * 0.0f + 0.15f;
|
g *= br * 0.0f + 0.15f;
|
||||||
b *= br * 0.0f + 0.15f;
|
b *= br * 0.0f + 0.15f;
|
||||||
|
|
||||||
return Vec3::newTemp(r, g, b);
|
return Vec3(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TheEndDimension::hasGround() { return false; }
|
bool TheEndDimension::hasGround() { return false; }
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ public:
|
||||||
virtual ChunkSource* createRandomLevelSource() const;
|
virtual ChunkSource* createRandomLevelSource() const;
|
||||||
virtual float getTimeOfDay(int64_t time, float a) const;
|
virtual float getTimeOfDay(int64_t time, float a) const;
|
||||||
virtual float* getSunriseColor(float td, float a);
|
virtual float* getSunriseColor(float td, float a);
|
||||||
virtual Vec3* getFogColor(float td, float a) const;
|
virtual Vec3 getFogColor(float td, float a) const;
|
||||||
virtual bool hasGround();
|
virtual bool hasGround();
|
||||||
virtual bool mayRespawn() const;
|
virtual bool mayRespawn() const;
|
||||||
virtual bool isNaturalDimension();
|
virtual bool isNaturalDimension();
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include "../../Headers/net.minecraft.world.entity.monster.h"
|
#include "../../Headers/net.minecraft.world.entity.monster.h"
|
||||||
#include "../../Headers/net.minecraft.world.level.h"
|
#include "../../Headers/net.minecraft.world.level.h"
|
||||||
#include "VillageSiege.h"
|
#include "VillageSiege.h"
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
VillageSiege::VillageSiege(Level* level) {
|
VillageSiege::VillageSiege(Level* level) {
|
||||||
hasSetupSiege = false;
|
hasSetupSiege = false;
|
||||||
|
|
@ -108,8 +109,8 @@ bool VillageSiege::tryToSetupSiege() {
|
||||||
}
|
}
|
||||||
if (overlaps) return false;
|
if (overlaps) return false;
|
||||||
|
|
||||||
Vec3* spawnPos = findRandomSpawnPos(spawnX, spawnY, spawnZ);
|
auto spawnPos = findRandomSpawnPos(spawnX, spawnY, spawnZ);
|
||||||
if (spawnPos == NULL) continue;
|
if (!spawnPos.has_value()) continue;
|
||||||
|
|
||||||
nextSpawnTime = 0;
|
nextSpawnTime = 0;
|
||||||
siegeCount = 20;
|
siegeCount = 20;
|
||||||
|
|
@ -119,8 +120,8 @@ bool VillageSiege::tryToSetupSiege() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VillageSiege::trySpawn() {
|
bool VillageSiege::trySpawn() {
|
||||||
Vec3* spawnPos = findRandomSpawnPos(spawnX, spawnY, spawnZ);
|
auto spawnPos = findRandomSpawnPos(spawnX, spawnY, spawnZ);
|
||||||
if (spawnPos == NULL) return false;
|
if (!spawnPos.has_value()) return false;
|
||||||
std::shared_ptr<Zombie> mob;
|
std::shared_ptr<Zombie> mob;
|
||||||
// try
|
// try
|
||||||
{
|
{
|
||||||
|
|
@ -143,9 +144,9 @@ bool VillageSiege::trySpawn() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* VillageSiege::findRandomSpawnPos(int x, int y, int z) {
|
std::optional<Vec3> VillageSiege::findRandomSpawnPos(int x, int y, int z) {
|
||||||
std::shared_ptr<Village> _village = village.lock();
|
std::shared_ptr<Village> _village = village.lock();
|
||||||
if (_village == NULL) return NULL;
|
if (_village == NULL) return std::nullopt;
|
||||||
|
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
int xx = x + level->random->nextInt(16) - 8;
|
int xx = x + level->random->nextInt(16) - 8;
|
||||||
|
|
@ -154,7 +155,8 @@ Vec3* VillageSiege::findRandomSpawnPos(int x, int y, int z) {
|
||||||
if (!_village->isInside(xx, yy, zz)) continue;
|
if (!_village->isInside(xx, yy, zz)) continue;
|
||||||
if (MobSpawner::isSpawnPositionOk(MobCategory::monster, level, xx, yy,
|
if (MobSpawner::isSpawnPositionOk(MobCategory::monster, level, xx, yy,
|
||||||
zz))
|
zz))
|
||||||
return Vec3::newTemp(xx, yy, zz);
|
return Vec3(xx, yy, zz);
|
||||||
}
|
}
|
||||||
return NULL;
|
|
||||||
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
class VillageSiege {
|
class VillageSiege {
|
||||||
private:
|
private:
|
||||||
Level* level;
|
Level* level;
|
||||||
|
|
@ -23,5 +25,5 @@ public:
|
||||||
private:
|
private:
|
||||||
bool tryToSetupSiege();
|
bool tryToSetupSiege();
|
||||||
bool trySpawn();
|
bool trySpawn();
|
||||||
Vec3* findRandomSpawnPos(int x, int y, int z);
|
std::optional<Vec3> findRandomSpawnPos(int x, int y, int z);
|
||||||
};
|
};
|
||||||
|
|
@ -26,12 +26,7 @@ Explosion::Explosion(Level* level, std::shared_ptr<Entity> source, double x,
|
||||||
size = 16;
|
size = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
Explosion::~Explosion() {
|
Explosion::~Explosion() { delete random; }
|
||||||
delete random;
|
|
||||||
for (AUTO_VAR(it, hitPlayers.begin()); it != hitPlayers.end(); ++it) {
|
|
||||||
delete it->second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Explosion::explode() {
|
void Explosion::explode() {
|
||||||
float oR = r;
|
float oR = r;
|
||||||
|
|
@ -108,7 +103,7 @@ void Explosion::explode() {
|
||||||
level->getEntities(source, AABB::newTemp(x0, y0, z0, x1, y1, z1));
|
level->getEntities(source, AABB::newTemp(x0, y0, z0, x1, y1, z1));
|
||||||
std::vector<std::shared_ptr<Entity> > entities(levelEntities->begin(),
|
std::vector<std::shared_ptr<Entity> > entities(levelEntities->begin(),
|
||||||
levelEntities->end());
|
levelEntities->end());
|
||||||
Vec3* center = Vec3::newTemp(x, y, z);
|
Vec3 center(x, y, z);
|
||||||
|
|
||||||
AUTO_VAR(itEnd, entities.end());
|
AUTO_VAR(itEnd, entities.end());
|
||||||
for (AUTO_VAR(it, entities.begin()); it != itEnd; it++) {
|
for (AUTO_VAR(it, entities.begin()); it != itEnd; it++) {
|
||||||
|
|
@ -146,7 +141,7 @@ void Explosion::explode() {
|
||||||
za /= da;
|
za /= da;
|
||||||
}
|
}
|
||||||
|
|
||||||
double sp = level->getSeenPercent(center, e->bb);
|
double sp = level->getSeenPercent(¢er, e->bb);
|
||||||
double pow = (1 - dist) * sp;
|
double pow = (1 - dist) * sp;
|
||||||
if (canDamage)
|
if (canDamage)
|
||||||
e->hurt(DamageSource::explosion(this),
|
e->hurt(DamageSource::explosion(this),
|
||||||
|
|
@ -165,7 +160,7 @@ void Explosion::explode() {
|
||||||
// app.DebugPrintf("Adding player knockback (%f,%f,%f)\n", xa *
|
// app.DebugPrintf("Adding player knockback (%f,%f,%f)\n", xa *
|
||||||
// pow, ya * pow, za * pow);
|
// pow, ya * pow, za * pow);
|
||||||
hitPlayers.insert(playerVec3Map::value_type(
|
hitPlayers.insert(playerVec3Map::value_type(
|
||||||
player, Vec3::newPermanent(xa * pow, ya * pow, za * pow)));
|
player, Vec3(xa * pow, ya * pow, za * pow)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -283,10 +278,10 @@ void Explosion::finalizeExplosion(
|
||||||
|
|
||||||
Explosion::playerVec3Map* Explosion::getHitPlayers() { return &hitPlayers; }
|
Explosion::playerVec3Map* Explosion::getHitPlayers() { return &hitPlayers; }
|
||||||
|
|
||||||
Vec3* Explosion::getHitPlayerKnockback(std::shared_ptr<Player> player) {
|
Vec3 Explosion::getHitPlayerKnockback(std::shared_ptr<Player> player) {
|
||||||
AUTO_VAR(it, hitPlayers.find(player));
|
AUTO_VAR(it, hitPlayers.find(player));
|
||||||
|
|
||||||
if (it == hitPlayers.end()) return Vec3::newTemp(0.0, 0.0, 0.0);
|
if (it == hitPlayers.end()) return Vec3(0.0, 0.0, 0.0);
|
||||||
|
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ public:
|
||||||
std::unordered_set<TilePos, TilePosKeyHash, TilePosKeyEq> toBlow;
|
std::unordered_set<TilePos, TilePosKeyHash, TilePosKeyEq> toBlow;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::unordered_map<std::shared_ptr<Player>, Vec3*, PlayerKeyHash,
|
typedef std::unordered_map<std::shared_ptr<Player>, Vec3, PlayerKeyHash,
|
||||||
PlayerKeyEq>
|
PlayerKeyEq>
|
||||||
playerVec3Map;
|
playerVec3Map;
|
||||||
playerVec3Map hitPlayers;
|
playerVec3Map hitPlayers;
|
||||||
|
|
@ -42,6 +42,6 @@ public:
|
||||||
std::vector<TilePos>* toBlowDirect =
|
std::vector<TilePos>* toBlowDirect =
|
||||||
NULL); // 4J - added toBlow parameter
|
NULL); // 4J - added toBlow parameter
|
||||||
playerVec3Map* getHitPlayers();
|
playerVec3Map* getHitPlayers();
|
||||||
Vec3* getHitPlayerKnockback(std::shared_ptr<Player> player);
|
Vec3 getHitPlayerKnockback(std::shared_ptr<Player> player);
|
||||||
std::shared_ptr<LivingEntity> getSourceMob();
|
std::shared_ptr<LivingEntity> getSourceMob();
|
||||||
};
|
};
|
||||||
|
|
@ -1478,21 +1478,21 @@ HitResult* Level::clip(Vec3* a, Vec3* b, bool liquid, bool solidOnly) {
|
||||||
a->z = zClip;
|
a->z = zClip;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* tPos = Vec3::newTemp(a->x, a->y, a->z);
|
Vec3 tPos(a->x, a->y, a->z);
|
||||||
xTile0 = (int)(tPos->x = floor(a->x));
|
xTile0 = (int)(tPos.x = floor(a->x));
|
||||||
if (face == 5) {
|
if (face == 5) {
|
||||||
xTile0--;
|
xTile0--;
|
||||||
tPos->x++;
|
tPos.x++;
|
||||||
}
|
}
|
||||||
yTile0 = (int)(tPos->y = floor(a->y));
|
yTile0 = (int)(tPos.y = floor(a->y));
|
||||||
if (face == 1) {
|
if (face == 1) {
|
||||||
yTile0--;
|
yTile0--;
|
||||||
tPos->y++;
|
tPos.y++;
|
||||||
}
|
}
|
||||||
zTile0 = (int)(tPos->z = floor(a->z));
|
zTile0 = (int)(tPos.z = floor(a->z));
|
||||||
if (face == 3) {
|
if (face == 3) {
|
||||||
zTile0--;
|
zTile0--;
|
||||||
tPos->z++;
|
tPos.z++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int t = getTile(xTile0, yTile0, zTile0);
|
int t = getTile(xTile0, yTile0, zTile0);
|
||||||
|
|
@ -1884,7 +1884,7 @@ float Level::getSkyDarken(float a) {
|
||||||
return br * 0.8f + 0.2f;
|
return br * 0.8f + 0.2f;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* Level::getSkyColor(std::shared_ptr<Entity> source, float a) {
|
Vec3 Level::getSkyColor(std::shared_ptr<Entity> source, float a) {
|
||||||
float td = getTimeOfDay(a);
|
float td = getTimeOfDay(a);
|
||||||
|
|
||||||
float br = Mth::cos(td * PI * 2) * 2 + 0.5f;
|
float br = Mth::cos(td * PI * 2) * 2 + 0.5f;
|
||||||
|
|
@ -1932,7 +1932,7 @@ Vec3* Level::getSkyColor(std::shared_ptr<Entity> source, float a) {
|
||||||
b = b * (1 - f) + 1 * f;
|
b = b * (1 - f) + 1 * f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Vec3::newTemp(r, g, b);
|
return Vec3(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Level::getTimeOfDay(float a) {
|
float Level::getTimeOfDay(float a) {
|
||||||
|
|
@ -1963,7 +1963,7 @@ float Level::getSunAngle(float a) {
|
||||||
return td * PI * 2;
|
return td * PI * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* Level::getCloudColor(float a) {
|
Vec3 Level::getCloudColor(float a) {
|
||||||
float td = getTimeOfDay(a);
|
float td = getTimeOfDay(a);
|
||||||
|
|
||||||
float br = Mth::cos(td * PI * 2) * 2.0f + 0.5f;
|
float br = Mth::cos(td * PI * 2) * 2.0f + 0.5f;
|
||||||
|
|
@ -2001,10 +2001,10 @@ Vec3* Level::getCloudColor(float a) {
|
||||||
b = b * ba + mid * (1 - ba);
|
b = b * ba + mid * (1 - ba);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Vec3::newTemp(r, g, b);
|
return Vec3(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* Level::getFogColor(float a) {
|
Vec3 Level::getFogColor(float a) {
|
||||||
float td = getTimeOfDay(a);
|
float td = getTimeOfDay(a);
|
||||||
return dimension->getFogColor(td, a);
|
return dimension->getFogColor(td, a);
|
||||||
}
|
}
|
||||||
|
|
@ -2473,7 +2473,7 @@ bool Level::checkAndHandleWater(AABB* box, Material* material,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
Vec3* current = Vec3::newTemp(0, 0, 0);
|
Vec3 current(0, 0, 0);
|
||||||
for (int x = x0; x < x1; x++) {
|
for (int x = x0; x < x1; x++) {
|
||||||
for (int y = y0; y < y1; y++) {
|
for (int y = y0; y < y1; y++) {
|
||||||
for (int z = z0; z < z1; z++) {
|
for (int z = z0; z < z1; z++) {
|
||||||
|
|
@ -2483,18 +2483,18 @@ bool Level::checkAndHandleWater(AABB* box, Material* material,
|
||||||
y + 1 - LiquidTile::getHeight(getData(x, y, z));
|
y + 1 - LiquidTile::getHeight(getData(x, y, z));
|
||||||
if (y1 >= yt0) {
|
if (y1 >= yt0) {
|
||||||
ok = true;
|
ok = true;
|
||||||
tile->handleEntityInside(this, x, y, z, e, current);
|
tile->handleEntityInside(this, x, y, z, e, ¤t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (current->length() > 0 && e->isPushedByWater()) {
|
if (current.length() > 0 && e->isPushedByWater()) {
|
||||||
current = current->normalize();
|
current = current.normalize();
|
||||||
double pow = 0.014;
|
double pow = 0.014;
|
||||||
e->xd += current->x * pow;
|
e->xd += current.x * pow;
|
||||||
e->yd += current->y * pow;
|
e->yd += current.y * pow;
|
||||||
e->zd += current->z * pow;
|
e->zd += current.z * pow;
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
@ -2580,7 +2580,8 @@ float Level::getSeenPercent(Vec3* center, AABB* bb) {
|
||||||
double x = bb->x0 + (bb->x1 - bb->x0) * xx;
|
double x = bb->x0 + (bb->x1 - bb->x0) * xx;
|
||||||
double y = bb->y0 + (bb->y1 - bb->y0) * yy;
|
double y = bb->y0 + (bb->y1 - bb->y0) * yy;
|
||||||
double z = bb->z0 + (bb->z1 - bb->z0) * zz;
|
double z = bb->z0 + (bb->z1 - bb->z0) * zz;
|
||||||
HitResult* res = clip(Vec3::newTemp(x, y, z), center);
|
Vec3 a(x, y, z);
|
||||||
|
HitResult* res = clip(&a, center);
|
||||||
if (res == NULL) hits++;
|
if (res == NULL) hits++;
|
||||||
delete res;
|
delete res;
|
||||||
count++;
|
count++;
|
||||||
|
|
|
||||||
|
|
@ -365,13 +365,13 @@ public:
|
||||||
false); // 4J: Added noEntities & blockAtEdge parameters
|
false); // 4J: Added noEntities & blockAtEdge parameters
|
||||||
int getOldSkyDarken(float a); // 4J - change brought forward from 1.8.2
|
int getOldSkyDarken(float a); // 4J - change brought forward from 1.8.2
|
||||||
float getSkyDarken(float a); // 4J - change brought forward from 1.8.2
|
float getSkyDarken(float a); // 4J - change brought forward from 1.8.2
|
||||||
Vec3* getSkyColor(std::shared_ptr<Entity> source, float a);
|
Vec3 getSkyColor(std::shared_ptr<Entity> source, float a);
|
||||||
float getTimeOfDay(float a);
|
float getTimeOfDay(float a);
|
||||||
int getMoonPhase();
|
int getMoonPhase();
|
||||||
float getMoonBrightness();
|
float getMoonBrightness();
|
||||||
float getSunAngle(float a);
|
float getSunAngle(float a);
|
||||||
Vec3* getCloudColor(float a);
|
Vec3 getCloudColor(float a);
|
||||||
Vec3* getFogColor(float a);
|
Vec3 getFogColor(float a);
|
||||||
int getTopRainBlock(int x, int z);
|
int getTopRainBlock(int x, int z);
|
||||||
int getTopSolidBlock(int x, int z);
|
int getTopSolidBlock(int x, int z);
|
||||||
bool biomeHasRain(int x, int z); // 4J added
|
bool biomeHasRain(int x, int z); // 4J added
|
||||||
|
|
|
||||||
|
|
@ -109,32 +109,34 @@ int RandomLevelSource::getMinDistanceToEdge(int xxx, int zzz, int worldSize,
|
||||||
// // only check if either x or z values are within the falloff
|
// // only check if either x or z values are within the falloff
|
||||||
// if(xxx > (min - falloffStart)
|
// if(xxx > (min - falloffStart)
|
||||||
|
|
||||||
Vec3* topLeft = Vec3::newTemp(min, 0, min);
|
Vec3 topLeft(min, 0, min);
|
||||||
Vec3* topRight = Vec3::newTemp(max, 0, min);
|
Vec3 topRight(max, 0, min);
|
||||||
Vec3* bottomLeft = Vec3::newTemp(min, 0, max);
|
Vec3 bottomLeft(min, 0, max);
|
||||||
Vec3* bottomRight = Vec3::newTemp(max, 0, max);
|
Vec3 bottomRight(max, 0, max);
|
||||||
|
|
||||||
float closest = falloffStart;
|
float closest = falloffStart;
|
||||||
float dist;
|
float dist;
|
||||||
// make sure we're in range of the edges before we do a full distance check
|
// make sure we're in range of the edges before we do a full distance check
|
||||||
if ((xxx > (min - falloffStart) && xxx < (min + falloffStart)) ||
|
if ((xxx > (min - falloffStart) && xxx < (min + falloffStart)) ||
|
||||||
(xxx > (max - falloffStart) && xxx < (max + falloffStart))) {
|
(xxx > (max - falloffStart) && xxx < (max + falloffStart))) {
|
||||||
Vec3* point = Vec3::newTemp(xxx, 0, zzz);
|
Vec3 point(xxx, 0, zzz);
|
||||||
|
|
||||||
if (xxx > 0)
|
if (xxx > 0)
|
||||||
dist = point->distanceFromLine(topRight, bottomRight);
|
dist = point.distanceFromLine(topRight, bottomRight);
|
||||||
else
|
else
|
||||||
dist = point->distanceFromLine(topLeft, bottomLeft);
|
dist = point.distanceFromLine(topLeft, bottomLeft);
|
||||||
closest = dist;
|
closest = dist;
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure we're in range of the edges before we do a full distance check
|
// make sure we're in range of the edges before we do a full distance check
|
||||||
if ((zzz > (min - falloffStart) && zzz < (min + falloffStart)) ||
|
if ((zzz > (min - falloffStart) && zzz < (min + falloffStart)) ||
|
||||||
(zzz > (max - falloffStart) && zzz < (max + falloffStart))) {
|
(zzz > (max - falloffStart) && zzz < (max + falloffStart))) {
|
||||||
Vec3* point = Vec3::newTemp(xxx, 0, zzz);
|
Vec3 point(xxx, 0, zzz);
|
||||||
|
|
||||||
if (zzz > 0)
|
if (zzz > 0)
|
||||||
dist = point->distanceFromLine(bottomLeft, bottomRight);
|
dist = point.distanceFromLine(bottomLeft, bottomRight);
|
||||||
else
|
else
|
||||||
dist = point->distanceFromLine(topLeft, topRight);
|
dist = point.distanceFromLine(topLeft, topRight);
|
||||||
if (dist < closest) closest = dist;
|
if (dist < closest) closest = dist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -527,20 +527,20 @@ void Player::spawnEatParticles(std::shared_ptr<ItemInstance> useItem,
|
||||||
}
|
}
|
||||||
if (useItem->getUseAnimation() == UseAnim_eat) {
|
if (useItem->getUseAnimation() == UseAnim_eat) {
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
Vec3* d = Vec3::newTemp((random->nextFloat() - 0.5) * 0.1,
|
Vec3 d{(random->nextFloat() - 0.5) * 0.1,
|
||||||
Math::random() * 0.1 + 0.1, 0);
|
Math::random() * 0.1 + 0.1, 0};
|
||||||
|
|
||||||
d->xRot(-xRot * PI / 180);
|
d.xRot(-xRot * PI / 180);
|
||||||
d->yRot(-yRot * PI / 180);
|
d.yRot(-yRot * PI / 180);
|
||||||
|
|
||||||
Vec3* p = Vec3::newTemp((random->nextFloat() - 0.5) * 0.3,
|
Vec3 p{(random->nextFloat() - 0.5) * 0.3,
|
||||||
-random->nextFloat() * 0.6 - 0.3, 0.6);
|
-random->nextFloat() * 0.6 - 0.3, 0.6};
|
||||||
p->xRot(-xRot * PI / 180);
|
p.xRot(-xRot * PI / 180);
|
||||||
p->yRot(-yRot * PI / 180);
|
p.yRot(-yRot * PI / 180);
|
||||||
p = p->add(x, y + getHeadHeight(), z);
|
p = p.add(x, y + getHeadHeight(), z);
|
||||||
|
|
||||||
level->addParticle(PARTICLE_ICONCRACK(useItem->getItem()->id, 0),
|
level->addParticle(PARTICLE_ICONCRACK(useItem->getItem()->id, 0),
|
||||||
p->x, p->y, p->z, d->x, d->y + 0.05, d->z);
|
p.x, p.y, p.z, d.x, d.y + 0.05, d.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J Stu - Was L"mob.eat" which doesnt exist
|
// 4J Stu - Was L"mob.eat" which doesnt exist
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,9 @@
|
||||||
|
|
||||||
#include "../Platform/stdafx.h"
|
#include "../Platform/stdafx.h"
|
||||||
#include "AABB.h"
|
#include "AABB.h"
|
||||||
|
#include <optional>
|
||||||
#include "HitResult.h"
|
#include "HitResult.h"
|
||||||
|
#include "Util/Vec3.h"
|
||||||
|
|
||||||
unsigned int AABB::tlsIdx = 0;
|
unsigned int AABB::tlsIdx = 0;
|
||||||
AABB::ThreadStorage* AABB::tlsDefault = NULL;
|
AABB::ThreadStorage* AABB::tlsDefault = NULL;
|
||||||
|
|
@ -238,44 +240,55 @@ AABB* AABB::shrink(double xa, double ya, double za) {
|
||||||
AABB* AABB::copy() { return AABB::newTemp(x0, y0, z0, x1, y1, z1); }
|
AABB* AABB::copy() { return AABB::newTemp(x0, y0, z0, x1, y1, z1); }
|
||||||
|
|
||||||
HitResult* AABB::clip(Vec3* a, Vec3* b) {
|
HitResult* AABB::clip(Vec3* a, Vec3* b) {
|
||||||
Vec3* xh0 = a->clipX(b, x0);
|
auto xh0 = a->clipX(*b, x0);
|
||||||
Vec3* xh1 = a->clipX(b, x1);
|
auto xh1 = a->clipX(*b, x1);
|
||||||
|
|
||||||
Vec3* yh0 = a->clipY(b, y0);
|
auto yh0 = a->clipY(*b, y0);
|
||||||
Vec3* yh1 = a->clipY(b, y1);
|
auto yh1 = a->clipY(*b, y1);
|
||||||
|
|
||||||
Vec3* zh0 = a->clipZ(b, z0);
|
auto zh0 = a->clipZ(*b, z0);
|
||||||
Vec3* zh1 = a->clipZ(b, z1);
|
auto zh1 = a->clipZ(*b, z1);
|
||||||
|
|
||||||
if (!containsX(xh0)) xh0 = NULL;
|
if (!(xh0.has_value() and containsX(&*xh0))) xh0 = std::nullopt;
|
||||||
if (!containsX(xh1)) xh1 = NULL;
|
if (!(xh1.has_value() and containsX(&*xh1))) xh1 = std::nullopt;
|
||||||
if (!containsY(yh0)) yh0 = NULL;
|
if (!(yh0.has_value() and containsY(&*yh0))) yh0 = std::nullopt;
|
||||||
if (!containsY(yh1)) yh1 = NULL;
|
if (!(yh1.has_value() and containsY(&*yh1))) yh1 = std::nullopt;
|
||||||
if (!containsZ(zh0)) zh0 = NULL;
|
if (!(zh0.has_value() and containsZ(&*zh0))) zh0 = std::nullopt;
|
||||||
if (!containsZ(zh1)) zh1 = NULL;
|
if (!(zh1.has_value() and containsZ(&*zh1))) zh1 = std::nullopt;
|
||||||
|
|
||||||
Vec3* closest = NULL;
|
std::optional<Vec3> closest = std::nullopt;
|
||||||
|
|
||||||
if (xh0 != NULL &&
|
if (xh0.has_value() and
|
||||||
(closest == NULL || a->distanceToSqr(xh0) < a->distanceToSqr(closest)))
|
(!closest.has_value() or
|
||||||
|
a->distanceToSqr(*xh0) < a->distanceToSqr(*closest)))
|
||||||
closest = xh0;
|
closest = xh0;
|
||||||
if (xh1 != NULL &&
|
|
||||||
(closest == NULL || a->distanceToSqr(xh1) < a->distanceToSqr(closest)))
|
if (xh1.has_value() and
|
||||||
|
(!closest.has_value() or
|
||||||
|
a->distanceToSqr(*xh1) < a->distanceToSqr(*closest)))
|
||||||
closest = xh1;
|
closest = xh1;
|
||||||
if (yh0 != NULL &&
|
|
||||||
(closest == NULL || a->distanceToSqr(yh0) < a->distanceToSqr(closest)))
|
if (yh0.has_value() and
|
||||||
|
(!closest.has_value() or
|
||||||
|
a->distanceToSqr(*yh0) < a->distanceToSqr(*closest)))
|
||||||
closest = yh0;
|
closest = yh0;
|
||||||
if (yh1 != NULL &&
|
|
||||||
(closest == NULL || a->distanceToSqr(yh1) < a->distanceToSqr(closest)))
|
if (yh1.has_value() and
|
||||||
|
(!closest.has_value() or
|
||||||
|
a->distanceToSqr(*yh1) < a->distanceToSqr(*closest)))
|
||||||
closest = yh1;
|
closest = yh1;
|
||||||
if (zh0 != NULL &&
|
|
||||||
(closest == NULL || a->distanceToSqr(zh0) < a->distanceToSqr(closest)))
|
if (zh0.has_value() and
|
||||||
|
(!closest.has_value() or
|
||||||
|
a->distanceToSqr(*zh0) < a->distanceToSqr(*closest)))
|
||||||
closest = zh0;
|
closest = zh0;
|
||||||
if (zh1 != NULL &&
|
|
||||||
(closest == NULL || a->distanceToSqr(zh1) < a->distanceToSqr(closest)))
|
if (zh1.has_value() and
|
||||||
|
(!closest.has_value() or
|
||||||
|
a->distanceToSqr(*zh1) < a->distanceToSqr(*closest)))
|
||||||
closest = zh1;
|
closest = zh1;
|
||||||
|
|
||||||
if (closest == NULL) return NULL;
|
if (!closest.has_value()) return nullptr;
|
||||||
|
|
||||||
int face = -1;
|
int face = -1;
|
||||||
|
|
||||||
|
|
@ -286,7 +299,7 @@ HitResult* AABB::clip(Vec3* a, Vec3* b) {
|
||||||
if (closest == zh0) face = 2;
|
if (closest == zh0) face = 2;
|
||||||
if (closest == zh1) face = 3;
|
if (closest == zh1) face = 3;
|
||||||
|
|
||||||
return new HitResult(0, 0, 0, face, closest);
|
return new HitResult(0, 0, 0, face, *closest);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AABB::containsX(Vec3* v) {
|
bool AABB::containsX(Vec3* v) {
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@
|
||||||
#include "../Headers/net.minecraft.world.entity.h"
|
#include "../Headers/net.minecraft.world.entity.h"
|
||||||
#include "HitResult.h"
|
#include "HitResult.h"
|
||||||
|
|
||||||
HitResult::HitResult(int x, int y, int z, int f, Vec3* pos) {
|
HitResult::HitResult(int x, int y, int z, int f, const Vec3& pos) {
|
||||||
type = TILE;
|
type = TILE;
|
||||||
this->x = x;
|
this->x = x;
|
||||||
this->y = y;
|
this->y = y;
|
||||||
this->z = z;
|
this->z = z;
|
||||||
this->f = f;
|
this->f = f;
|
||||||
this->pos = Vec3::newTemp(pos->x, pos->y, pos->z);
|
this->pos = pos;
|
||||||
|
|
||||||
this->entity = nullptr;
|
this->entity = nullptr;
|
||||||
}
|
}
|
||||||
|
|
@ -17,14 +17,14 @@ HitResult::HitResult(int x, int y, int z, int f, Vec3* pos) {
|
||||||
HitResult::HitResult(std::shared_ptr<Entity> entity) {
|
HitResult::HitResult(std::shared_ptr<Entity> entity) {
|
||||||
type = ENTITY;
|
type = ENTITY;
|
||||||
this->entity = entity;
|
this->entity = entity;
|
||||||
pos = Vec3::newTemp(entity->x, entity->y, entity->z);
|
pos = {entity->x, entity->y, entity->z};
|
||||||
|
|
||||||
x = y = z = f = 0;
|
x = y = z = f = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double HitResult::distanceTo(std::shared_ptr<Entity> e) {
|
double HitResult::distanceTo(std::shared_ptr<Entity> e) {
|
||||||
double xd = pos->x - e->x;
|
double xd = pos.x - e->x;
|
||||||
double yd = pos->y - e->y;
|
double yd = pos.y - e->y;
|
||||||
double zd = pos->z - e->z;
|
double zd = pos.z - e->z;
|
||||||
return xd * xd + yd * yd + zd * zd;
|
return xd * xd + yd * yd + zd * zd;
|
||||||
}
|
}
|
||||||
|
|
@ -7,10 +7,10 @@ public:
|
||||||
|
|
||||||
Type type;
|
Type type;
|
||||||
int x, y, z, f;
|
int x, y, z, f;
|
||||||
Vec3* pos;
|
Vec3 pos;
|
||||||
std::shared_ptr<Entity> entity;
|
std::shared_ptr<Entity> entity;
|
||||||
|
|
||||||
HitResult(int x, int y, int z, int f, Vec3* pos);
|
HitResult(int x, int y, int z, int f, const Vec3& pos);
|
||||||
|
|
||||||
HitResult(std::shared_ptr<Entity> entity);
|
HitResult(std::shared_ptr<Entity> entity);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,51 +1,10 @@
|
||||||
#include "../Platform/stdafx.h"
|
|
||||||
#include "Vec3.h"
|
#include "Vec3.h"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
#include "AABB.h"
|
#include "AABB.h"
|
||||||
|
|
||||||
unsigned int Vec3::tlsIdx = 0;
|
|
||||||
Vec3::ThreadStorage* Vec3::tlsDefault = NULL;
|
|
||||||
|
|
||||||
Vec3::ThreadStorage::ThreadStorage() {
|
|
||||||
pool = new Vec3[POOL_SIZE];
|
|
||||||
poolPointer = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vec3::ThreadStorage::~ThreadStorage() { delete[] pool; }
|
|
||||||
|
|
||||||
void Vec3::CreateNewThreadStorage() {
|
|
||||||
ThreadStorage* tls = new ThreadStorage();
|
|
||||||
if (tlsDefault == NULL) {
|
|
||||||
tlsIdx = TlsAlloc();
|
|
||||||
tlsDefault = tls;
|
|
||||||
}
|
|
||||||
TlsSetValue(tlsIdx, tls);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Vec3::UseDefaultThreadStorage() { TlsSetValue(tlsIdx, tlsDefault); }
|
|
||||||
|
|
||||||
void Vec3::ReleaseThreadStorage() {
|
|
||||||
ThreadStorage* tls = (ThreadStorage*)TlsGetValue(tlsIdx);
|
|
||||||
if (tls == tlsDefault) return;
|
|
||||||
|
|
||||||
delete tls;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vec3* Vec3::newPermanent(double x, double y, double z) {
|
|
||||||
return new Vec3(x, y, z);
|
|
||||||
};
|
|
||||||
|
|
||||||
void Vec3::clearPool() {}
|
|
||||||
|
|
||||||
void Vec3::resetPool() {}
|
|
||||||
|
|
||||||
Vec3* Vec3::newTemp(double x, double y, double z) {
|
|
||||||
ThreadStorage* tls = (ThreadStorage*)TlsGetValue(tlsIdx);
|
|
||||||
Vec3* thisVec = &tls->pool[tls->poolPointer];
|
|
||||||
thisVec->set(x, y, z);
|
|
||||||
tls->poolPointer = (tls->poolPointer + 1) % ThreadStorage::POOL_SIZE;
|
|
||||||
return thisVec;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vec3::Vec3(double x, double y, double z) {
|
Vec3::Vec3(double x, double y, double z) {
|
||||||
if (x == -0.0) x = 0.0;
|
if (x == -0.0) x = 0.0;
|
||||||
if (y == -0.0) y = 0.0;
|
if (y == -0.0) y = 0.0;
|
||||||
|
|
@ -55,115 +14,99 @@ Vec3::Vec3(double x, double y, double z) {
|
||||||
this->z = z;
|
this->z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* Vec3::set(double x, double y, double z) {
|
Vec3 Vec3::vectorTo(const Vec3& p) const { return {p.x - x, p.y - y, p.z - z}; }
|
||||||
this->x = x;
|
|
||||||
this->y = y;
|
Vec3 Vec3::normalize() const {
|
||||||
this->z = z;
|
double dist = std::sqrt(x * x + y * y + z * z);
|
||||||
return this;
|
if (dist < 0.0001) return {0, 0, 0};
|
||||||
|
|
||||||
|
return {x / dist, y / dist, z / dist};
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* Vec3::interpolateTo(Vec3* t, double p) {
|
double Vec3::dot(const Vec3& p) const { return x * p.x + y * p.y + z * p.z; }
|
||||||
double xt = x + (t->x - x) * p;
|
|
||||||
double yt = y + (t->y - y) * p;
|
|
||||||
double zt = z + (t->z - z) * p;
|
|
||||||
|
|
||||||
return Vec3::newTemp(xt, yt, zt);
|
Vec3 Vec3::cross(const Vec3& p) const {
|
||||||
|
return {y * p.z - z * p.y, z * p.x - x * p.z, x * p.y - y * p.x};
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* Vec3::vectorTo(Vec3* p) {
|
Vec3 Vec3::add(double x, double y, double z) const {
|
||||||
return Vec3::newTemp(p->x - x, p->y - y, p->z - z);
|
return {this->x + x, this->y + y, this->z + z};
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* Vec3::normalize() {
|
double Vec3::distanceTo(const Vec3& p) const {
|
||||||
double dist = (double)(sqrt(x * x + y * y + z * z));
|
double xd = p.x - x;
|
||||||
if (dist < 0.0001) return Vec3::newTemp(0, 0, 0);
|
double yd = p.y - y;
|
||||||
return Vec3::newTemp(x / dist, y / dist, z / dist);
|
double zd = p.z - z;
|
||||||
|
return std::sqrt(xd * xd + yd * yd + zd * zd);
|
||||||
}
|
}
|
||||||
|
|
||||||
double Vec3::dot(Vec3* p) { return x * p->x + y * p->y + z * p->z; }
|
double Vec3::distanceToSqr(const Vec3& p) const {
|
||||||
|
double xd = p.x - x;
|
||||||
Vec3* Vec3::cross(Vec3* p) {
|
double yd = p.y - y;
|
||||||
return Vec3::newTemp(y * p->z - z * p->y, z * p->x - x * p->z,
|
double zd = p.z - z;
|
||||||
x * p->y - y * p->x);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vec3* Vec3::add(double x, double y, double z) {
|
|
||||||
return Vec3::newTemp(this->x + x, this->y + y, this->z + z);
|
|
||||||
}
|
|
||||||
|
|
||||||
double Vec3::distanceTo(Vec3* p) {
|
|
||||||
double xd = p->x - x;
|
|
||||||
double yd = p->y - y;
|
|
||||||
double zd = p->z - z;
|
|
||||||
return (double)sqrt(xd * xd + yd * yd + zd * zd);
|
|
||||||
}
|
|
||||||
|
|
||||||
double Vec3::distanceToSqr(Vec3* p) {
|
|
||||||
double xd = p->x - x;
|
|
||||||
double yd = p->y - y;
|
|
||||||
double zd = p->z - z;
|
|
||||||
return xd * xd + yd * yd + zd * zd;
|
return xd * xd + yd * yd + zd * zd;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Vec3::distanceToSqr(double x2, double y2, double z2) {
|
double Vec3::distanceToSqr(const double x2, const double y2,
|
||||||
|
const double z2) const {
|
||||||
double xd = x2 - x;
|
double xd = x2 - x;
|
||||||
double yd = y2 - y;
|
double yd = y2 - y;
|
||||||
double zd = z2 - z;
|
double zd = z2 - z;
|
||||||
return xd * xd + yd * yd + zd * zd;
|
return xd * xd + yd * yd + zd * zd;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* Vec3::scale(double l) { return Vec3::newTemp(x * l, y * l, z * l); }
|
Vec3 Vec3::scale(const double l) const { return {x * l, y * l, z * l}; }
|
||||||
|
|
||||||
double Vec3::length() { return sqrt(x * x + y * y + z * z); }
|
double Vec3::length() const { return sqrt(x * x + y * y + z * z); }
|
||||||
|
|
||||||
Vec3* Vec3::clipX(Vec3* b, double xt) {
|
std::optional<Vec3> Vec3::clipX(const Vec3& b, const double xt) const {
|
||||||
double xd = b->x - x;
|
double xd = b.x - x;
|
||||||
double yd = b->y - y;
|
double yd = b.y - y;
|
||||||
double zd = b->z - z;
|
double zd = b.z - z;
|
||||||
|
|
||||||
if (xd * xd < 0.0000001f) return NULL;
|
if (xd * xd < 0.0000001f) return std::nullopt;
|
||||||
|
|
||||||
double d = (xt - x) / xd;
|
double d = (xt - x) / xd;
|
||||||
if (d < 0 || d > 1) return NULL;
|
if (d < 0 || d > 1) return std::nullopt;
|
||||||
return Vec3::newTemp(x + xd * d, y + yd * d, z + zd * d);
|
|
||||||
|
return Vec3{x + xd * d, y + yd * d, z + zd * d};
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* Vec3::clipY(Vec3* b, double yt) {
|
std::optional<Vec3> Vec3::clipY(const Vec3& b, const double yt) const {
|
||||||
double xd = b->x - x;
|
double xd = b.x - x;
|
||||||
double yd = b->y - y;
|
double yd = b.y - y;
|
||||||
double zd = b->z - z;
|
double zd = b.z - z;
|
||||||
|
|
||||||
if (yd * yd < 0.0000001f) return NULL;
|
if (yd * yd < 0.0000001f) return std::nullopt;
|
||||||
|
|
||||||
double d = (yt - y) / yd;
|
double d = (yt - y) / yd;
|
||||||
if (d < 0 || d > 1) return NULL;
|
if (d < 0 || d > 1) return std::nullopt;
|
||||||
return Vec3::newTemp(x + xd * d, y + yd * d, z + zd * d);
|
|
||||||
|
return Vec3{x + xd * d, y + yd * d, z + zd * d};
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* Vec3::clipZ(Vec3* b, double zt) {
|
std::optional<Vec3> Vec3::clipZ(const Vec3& b, const double zt) const {
|
||||||
double xd = b->x - x;
|
double xd = b.x - x;
|
||||||
double yd = b->y - y;
|
double yd = b.y - y;
|
||||||
double zd = b->z - z;
|
double zd = b.z - z;
|
||||||
|
|
||||||
if (zd * zd < 0.0000001f) return NULL;
|
if (zd * zd < 0.0000001f) return std::nullopt;
|
||||||
|
|
||||||
double d = (zt - z) / zd;
|
double d = (zt - z) / zd;
|
||||||
if (d < 0 || d > 1) return NULL;
|
if (d < 0 || d > 1) return std::nullopt;
|
||||||
return Vec3::newTemp(x + xd * d, y + yd * d, z + zd * d);
|
|
||||||
|
return Vec3{x + xd * d, y + yd * d, z + zd * d};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring Vec3::toString() {
|
std::wstring Vec3::toString() const {
|
||||||
static wchar_t buf[128];
|
return std::format(L"({},{},{})", x, y, z);
|
||||||
swprintf(buf, 128, L"(%f,%f,%f)", x, y, z);
|
|
||||||
return std::wstring(buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* Vec3::lerp(Vec3* v, double a) {
|
Vec3 Vec3::lerp(const Vec3& v, const double a) const {
|
||||||
return Vec3::newTemp(x + (v->x - x) * a, y + (v->y - y) * a,
|
return {x + (v.x - x) * a, y + (v.y - y) * a, z + (v.z - z) * a};
|
||||||
z + (v->z - z) * a);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vec3::xRot(float degs) {
|
void Vec3::xRot(const float degs) {
|
||||||
double _cos = cos(degs); // 4J - cos/sin were floats but seems pointless
|
double _cos = cos(degs); // 4J - cos/sin were floats but seems pointless
|
||||||
// wasting precision here
|
// wasting precision here
|
||||||
double _sin = sin(degs);
|
double _sin = sin(degs);
|
||||||
|
|
@ -177,7 +120,7 @@ void Vec3::xRot(float degs) {
|
||||||
z = zz;
|
z = zz;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vec3::yRot(float degs) {
|
void Vec3::yRot(const float degs) {
|
||||||
double _cos = cos(degs); // 4J - cos/sin were floats but seems pointless
|
double _cos = cos(degs); // 4J - cos/sin were floats but seems pointless
|
||||||
// wasting precision here
|
// wasting precision here
|
||||||
double _sin = sin(degs);
|
double _sin = sin(degs);
|
||||||
|
|
@ -191,7 +134,7 @@ void Vec3::yRot(float degs) {
|
||||||
z = zz;
|
z = zz;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vec3::zRot(float degs) {
|
void Vec3::zRot(const float degs) {
|
||||||
double _cos = cos(degs); // 4J - cos/sin were floats but seems pointless
|
double _cos = cos(degs); // 4J - cos/sin were floats but seems pointless
|
||||||
// wasting precision here
|
// wasting precision here
|
||||||
double _sin = sin(degs);
|
double _sin = sin(degs);
|
||||||
|
|
@ -230,23 +173,24 @@ double Vec3::distanceTo(AABB* box) {
|
||||||
return sqrt(xd * xd + yd * yd + zd * zd);
|
return sqrt(xd * xd + yd * yd + zd * zd);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* Vec3::closestPointOnLine(Vec3* p1, Vec3* p2) {
|
Vec3 Vec3::closestPointOnLine(const Vec3& p1, const Vec3& p2) const {
|
||||||
Vec3* diff = newTemp(x - p1->x, y - p1->y, z - p1->z);
|
Vec3 diff = {x - p1.x, y - p1.y, z - p1.z};
|
||||||
Vec3* dir = newTemp(p2->x - p1->x, p2->y - p1->y, p2->z - p1->z);
|
Vec3 dir = {p2.x - p1.x, p2.y - p1.y, p2.z - p1.z};
|
||||||
float dot1 = diff->dot(dir);
|
float dot1 = diff.dot(dir);
|
||||||
|
|
||||||
if (dot1 <= 0.0f) return p1;
|
if (dot1 <= 0.0f) return p1;
|
||||||
|
|
||||||
float dot2 = dir->dot(dir);
|
float dot2 = dir.dot(dir);
|
||||||
|
|
||||||
if (dot2 <= dot1) return p2;
|
if (dot2 <= dot1) return p2;
|
||||||
|
|
||||||
float t = dot1 / dot2;
|
float t = dot1 / dot2;
|
||||||
return newTemp(p1->x + t * dir->x, p1->y + t * dir->y, p1->z + t * dir->z);
|
|
||||||
|
return {p1.x + t * dir.x, p1.y + t * dir.y, p1.z + t * dir.z};
|
||||||
}
|
}
|
||||||
|
|
||||||
double Vec3::distanceFromLine(Vec3* p1, Vec3* p2) {
|
double Vec3::distanceFromLine(const Vec3& p1, const Vec3& p2) const {
|
||||||
Vec3* closestPoint = closestPointOnLine(p1, p2);
|
Vec3 closestPoint = closestPointOnLine(p1, p2);
|
||||||
Vec3* diff =
|
Vec3 diff{x - closestPoint.x, y - closestPoint.y, z - closestPoint.z};
|
||||||
newTemp(x - closestPoint->x, y - closestPoint->y, z - closestPoint->z);
|
return diff.length();
|
||||||
return diff->length();
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,56 +1,32 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class AABB;
|
class AABB;
|
||||||
|
|
||||||
class Vec3 {
|
class Vec3 {
|
||||||
// 4J added so we can have separate pools for different threads
|
|
||||||
class ThreadStorage {
|
|
||||||
public:
|
|
||||||
static const int POOL_SIZE = 1024;
|
|
||||||
Vec3* pool;
|
|
||||||
unsigned int poolPointer;
|
|
||||||
ThreadStorage();
|
|
||||||
~ThreadStorage();
|
|
||||||
};
|
|
||||||
static unsigned int tlsIdx;
|
|
||||||
static ThreadStorage* tlsDefault;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Each new thread that needs to use Vec3 pools will need to call one of the
|
|
||||||
// following 2 functions, to either create its own local storage, or share
|
|
||||||
// the default storage already allocated by the main thread
|
|
||||||
static void CreateNewThreadStorage();
|
|
||||||
static void UseDefaultThreadStorage();
|
|
||||||
static void ReleaseThreadStorage();
|
|
||||||
|
|
||||||
static Vec3* newPermanent(double x, double y, double z);
|
|
||||||
static void clearPool();
|
|
||||||
static void resetPool();
|
|
||||||
static Vec3* newTemp(double x, double y, double z);
|
|
||||||
double x, y, z;
|
double x, y, z;
|
||||||
|
|
||||||
private:
|
|
||||||
Vec3() {}
|
Vec3() {}
|
||||||
Vec3(double x, double y, double z);
|
Vec3(double x, double y, double z);
|
||||||
Vec3* set(double x, double y, double z);
|
|
||||||
|
|
||||||
public:
|
Vec3 vectorTo(const Vec3& p) const;
|
||||||
Vec3* interpolateTo(Vec3* t, double p);
|
Vec3 normalize() const;
|
||||||
Vec3* vectorTo(Vec3* p);
|
double dot(const Vec3& p) const;
|
||||||
Vec3* normalize();
|
Vec3 cross(const Vec3& p) const;
|
||||||
double dot(Vec3* p);
|
Vec3 add(double x, double y, double z) const;
|
||||||
Vec3* cross(Vec3* p);
|
double distanceTo(const Vec3& p) const;
|
||||||
Vec3* add(double x, double y, double z);
|
double distanceToSqr(const Vec3& p) const;
|
||||||
double distanceTo(Vec3* p);
|
double distanceToSqr(double x2, double y2, double z2) const;
|
||||||
double distanceToSqr(Vec3* p);
|
Vec3 scale(double l) const;
|
||||||
double distanceToSqr(double x2, double y2, double z2);
|
double length() const;
|
||||||
Vec3* scale(double l);
|
std::optional<Vec3> clipX(const Vec3& b, double xt) const;
|
||||||
double length();
|
std::optional<Vec3> clipY(const Vec3& b, double yt) const;
|
||||||
Vec3* clipX(Vec3* b, double xt);
|
std::optional<Vec3> clipZ(const Vec3& b, double zt) const;
|
||||||
Vec3* clipY(Vec3* b, double yt);
|
std::wstring toString() const;
|
||||||
Vec3* clipZ(Vec3* b, double zt);
|
Vec3 lerp(const Vec3& v, double a) const;
|
||||||
std::wstring toString();
|
|
||||||
Vec3* lerp(Vec3* v, double a);
|
|
||||||
void xRot(float degs);
|
void xRot(float degs);
|
||||||
void yRot(float degs);
|
void yRot(float degs);
|
||||||
void zRot(float degs);
|
void zRot(float degs);
|
||||||
|
|
@ -58,6 +34,10 @@ public:
|
||||||
// 4J Added
|
// 4J Added
|
||||||
double distanceTo(AABB* box);
|
double distanceTo(AABB* box);
|
||||||
|
|
||||||
Vec3* closestPointOnLine(Vec3* p1, Vec3* p2);
|
Vec3 closestPointOnLine(const Vec3& p1, const Vec3& p2) const;
|
||||||
double distanceFromLine(Vec3* p1, Vec3* p2);
|
double distanceFromLine(const Vec3& p1, const Vec3& p2) const;
|
||||||
|
|
||||||
|
constexpr bool operator==(const Vec3& rhs) const {
|
||||||
|
return x == rhs.x and y == rhs.y and z == rhs.z;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include "../../Headers/net.minecraft.world.phys.h"
|
#include "../../Headers/net.minecraft.world.phys.h"
|
||||||
#include "Village.h"
|
#include "Village.h"
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
Village::Aggressor::Aggressor(std::shared_ptr<LivingEntity> mob,
|
Village::Aggressor::Aggressor(std::shared_ptr<LivingEntity> mob,
|
||||||
int timeStamp) {
|
int timeStamp) {
|
||||||
|
|
@ -60,9 +61,9 @@ void Village::tick(int tick) {
|
||||||
int idealGolemCount = populationSize / 10;
|
int idealGolemCount = populationSize / 10;
|
||||||
if (golemCount < idealGolemCount && doorInfos.size() > 20 &&
|
if (golemCount < idealGolemCount && doorInfos.size() > 20 &&
|
||||||
level->random->nextInt(7000) == 0) {
|
level->random->nextInt(7000) == 0) {
|
||||||
Vec3* spawnPos =
|
auto spawnPos =
|
||||||
findRandomSpawnPos(center->x, center->y, center->z, 2, 4, 2);
|
findRandomSpawnPos(center->x, center->y, center->z, 2, 4, 2);
|
||||||
if (spawnPos != NULL) {
|
if (spawnPos.has_value()) {
|
||||||
std::shared_ptr<VillagerGolem> vg =
|
std::shared_ptr<VillagerGolem> vg =
|
||||||
std::shared_ptr<VillagerGolem>(new VillagerGolem(level));
|
std::shared_ptr<VillagerGolem>(new VillagerGolem(level));
|
||||||
vg->setPos(spawnPos->x, spawnPos->y, spawnPos->z);
|
vg->setPos(spawnPos->x, spawnPos->y, spawnPos->z);
|
||||||
|
|
@ -88,16 +89,17 @@ void Village::tick(int tick) {
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3* Village::findRandomSpawnPos(int x, int y, int z, int sx, int sy, int sz) {
|
std::optional<Vec3> Village::findRandomSpawnPos(int x, int y, int z, int sx,
|
||||||
|
int sy, int sz) {
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
int xx = x + level->random->nextInt(16) - 8;
|
int xx = x + level->random->nextInt(16) - 8;
|
||||||
int yy = y + level->random->nextInt(6) - 3;
|
int yy = y + level->random->nextInt(6) - 3;
|
||||||
int zz = z + level->random->nextInt(16) - 8;
|
int zz = z + level->random->nextInt(16) - 8;
|
||||||
if (!isInside(xx, yy, zz)) continue;
|
if (!isInside(xx, yy, zz)) continue;
|
||||||
if (canSpawnAt(xx, yy, zz, sx, sy, sz))
|
if (canSpawnAt(xx, yy, zz, sx, sy, sz)) return Vec3(xx, yy, zz);
|
||||||
return Vec3::newTemp(xx, yy, zz);
|
|
||||||
}
|
}
|
||||||
return NULL;
|
|
||||||
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Village::canSpawnAt(int x, int y, int z, int sx, int sy, int sz) {
|
bool Village::canSpawnAt(int x, int y, int z, int sx, int sy, int sz) {
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue