Skip to content

Commit 54ec0c6

Browse files
committed
fix: avoid constructing Block
1 parent a6f3e22 commit 54ec0c6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/api/BlockAPI.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Local<Object> BlockClass::newBlock(Block const* p, BlockPos const* pos, int dim)
8585
}
8686

8787
Local<Object> BlockClass::newBlock(BlockPos const* pos, int dim) {
88-
Block bl = ll::service::getLevel()->getDimension(dim)->getBlockSourceFromMainChunkSource().getBlock(*pos);
88+
auto& bl = ll::service::getLevel()->getDimension(dim)->getBlockSourceFromMainChunkSource().getBlock(*pos);
8989
return BlockClass::newBlock(&bl, pos, dim);
9090
}
9191

@@ -98,7 +98,7 @@ Local<Object> BlockClass::newBlock(Block const* p, BlockPos const* pos, BlockSou
9898

9999
Local<Object> BlockClass::newBlock(IntVec4 pos) {
100100
BlockPos bp = {(float)pos.x, (float)pos.y, (float)pos.z};
101-
Block bl = ll::service::getLevel()->getDimension(pos.dim)->getBlockSourceFromMainChunkSource().getBlock(bp);
101+
auto& bl = ll::service::getLevel()->getDimension(pos.dim)->getBlockSourceFromMainChunkSource().getBlock(bp);
102102
return BlockClass::newBlock(&bl, &bp, pos.dim);
103103
}
104104

@@ -337,7 +337,7 @@ Local<Value> BlockClass::getBlockState(const Arguments& args) {
337337

338338
Local<Value> BlockClass::hasContainer(const Arguments& args) {
339339
try {
340-
Block bl = ll::service::getLevel()->getDimension(pos.dim)->getBlockSourceFromMainChunkSource().getBlock(
340+
auto& bl = ll::service::getLevel()->getDimension(pos.dim)->getBlockSourceFromMainChunkSource().getBlock(
341341
pos.getBlockPos()
342342
);
343343
return Boolean::newBoolean(bl.isContainerBlock());

src/api/BlockEntityAPI.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Local<Value> BlockEntityClass::setNbt(const Arguments& args) {
103103
Local<Value> BlockEntityClass::getBlock(const Arguments& args) {
104104
try {
105105
BlockPos bp = blockEntity->getPosition();
106-
Block bl = ll::service::getLevel()->getDimension(dim)->getBlockSourceFromMainChunkSource().getBlock(bp);
106+
auto& bl = ll::service::getLevel()->getDimension(dim)->getBlockSourceFromMainChunkSource().getBlock(bp);
107107
return BlockClass::newBlock(&bl, &bp, dim);
108108
}
109109
CATCH("Fail in getBlock!")

0 commit comments

Comments
 (0)