Skip to content

Commit

Permalink
build: correct .clangd and fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
futrime committed Jan 22, 2024
1 parent 54ec0c6 commit e894fa1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 174 deletions.
145 changes: 0 additions & 145 deletions .clang-tidy

This file was deleted.

5 changes: 0 additions & 5 deletions .clangd
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,3 @@ CompileFlags:
Add:
- "-ferror-limit=0"
- '-D__FUNCTION__="dummy"'
- "-Yusrc/ll/api/Global.h"
- "-FIsrc/ll/api/Global.h" # clangd bug can't find pch file
Remove:
- "/YuGlobal.h"
- "/FIGlobal.h"
27 changes: 15 additions & 12 deletions src/api/EntityAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1422,16 +1422,19 @@ Local<Value> EntityClass::getBlockFromViewVector(const Arguments& args) {
fullOnly = args[3].asBoolean().value();
}
HitResult res = actor->traceRay(maxDistance, false, true);
Block bl;
BlockPos bp;
if (includeLiquid && res.mIsHitLiquid) {
bp = res.mLiquidPos;
} else {
bp = res.mBlockPos;
}
actor->getDimensionBlockSource().getBlock(bp);
if (bl.isEmpty()) return Local<Value>();
return BlockClass::newBlock(std::move(&bl), &bp, actor->getDimensionId().id);

return Local<Value>(); // Temporary solution
// TODO: Fix this, block cannot be constructed.
// Block bl;
// BlockPos bp;
// if (includeLiquid && res.mIsHitLiquid) {
// bp = res.mLiquidPos;
// } else {
// bp = res.mBlockPos;
// }
// actor->getDimensionBlockSource().getBlock(bp);
// if (bl.isEmpty()) return Local<Value>();
// return BlockClass::newBlock(std::move(&bl), &bp, actor->getDimensionId().id);
}
CATCH("Fail in getBlockFromViewVector!");
}
Expand All @@ -1451,7 +1454,7 @@ Local<Value> EntityClass::getBiomeId() {
try {
Actor* actor = get();
if (!actor) return Local<Value>();
auto bio = actor->getDimensionBlockSource().getBiome(actor->getFeetBlockPos());
auto& bio = actor->getDimensionBlockSource().getBiome(actor->getFeetBlockPos());
return Number::newNumber(bio.getId());
}
CATCH("Fail in getBiomeId!");
Expand All @@ -1461,7 +1464,7 @@ Local<Value> EntityClass::getBiomeName() {
try {
Actor* actor = get();
if (!actor) return Local<Value>();
auto bio = actor->getDimensionBlockSource().getBiome(actor->getFeetBlockPos());
auto& bio = actor->getDimensionBlockSource().getBiome(actor->getFeetBlockPos());
return String::newString(bio.getName());
}
CATCH("Fail in getBiomeName!");
Expand Down
27 changes: 15 additions & 12 deletions src/api/PlayerAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2972,16 +2972,19 @@ Local<Value> PlayerClass::getBlockFromViewVector(const Arguments& args) {
fullOnly = args[3].asBoolean().value();
}
HitResult res = player->traceRay(maxDistance, false, true);
Block bl;
BlockPos bp;
if (includeLiquid && res.mIsHitLiquid) {
bp = res.mLiquidPos;
} else {
bp = res.mBlockPos;
}
player->getDimensionBlockSource().getBlock(bp);
if (bl.isEmpty()) return Local<Value>();
return BlockClass::newBlock(std::move(&bl), &bp, player->getDimensionId().id);

return Local<Value>();
// TODO
// Block bl;
// BlockPos bp;
// if (includeLiquid && res.mIsHitLiquid) {
// bp = res.mLiquidPos;
// } else {
// bp = res.mBlockPos;
// }
// player->getDimensionBlockSource().getBlock(bp);
// if (bl.isEmpty()) return Local<Value>();
// return BlockClass::newBlock(std::move(&bl), &bp, player->getDimensionId().id);
}
CATCH("Fail in getBlockFromViewVector!");
}
Expand Down Expand Up @@ -3354,7 +3357,7 @@ Local<Value> PlayerClass::getBiomeId() {
try {
Player* player = get();
if (!player) return Local<Value>();
Biome bio = player->getDimensionBlockSource().getBiome(player->getFeetBlockPos());
Biome& bio = player->getDimensionBlockSource().getBiome(player->getFeetBlockPos());
return Number::newNumber(bio.getId());
}
CATCH("Fail in getBiomeId!");
Expand All @@ -3364,7 +3367,7 @@ Local<Value> PlayerClass::getBiomeName() {
try {
Player* player = get();
if (!player) return Local<Value>();
Biome bio = player->getDimensionBlockSource().getBiome(player->getFeetBlockPos());
Biome& bio = player->getDimensionBlockSource().getBiome(player->getFeetBlockPos());
return String::newString(bio.getName());
}
CATCH("Fail in getBiomeName!");
Expand Down
2 changes: 2 additions & 0 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ add_requires(
"legacyparticleapi 0.1.1",
"levilamina 0.5.1",
"lightwebsocketclient 1.0.0",
"magic_enum v0.9.0",
"mariadb-connector-c 3.3.4",
"simpleini v4.19",
"sqlite3 3.43.0+200",
Expand Down Expand Up @@ -86,6 +87,7 @@ target("legacy-script-engine")
"legacyparticleapi",
"levilamina",
"lightwebsocketclient",
"magic_enum",
"mariadb-connector-c",
"scriptx",
"simpleini",
Expand Down

0 comments on commit e894fa1

Please sign in to comment.