const DB::BlockPosList &DBRedis::getBlockPosList() { redisReply *reply; reply = (redisReply*) redisCommand(ctx, "HKEYS %s", hash.c_str()); if(!reply) throw std::runtime_error(std::string("redis command 'HKEYS %s' failed: ") + ctx->errstr); if(reply->type != REDIS_REPLY_ARRAY) throw std::runtime_error("Failed to get keys from database"); for(size_t i = 0; i < reply->elements; i++) { if(reply->element[i]->type != REDIS_REPLY_STRING) throw std::runtime_error("Got wrong response to 'HKEYS %s' command"); m_blockPosList.push_back(BlockPos(reply->element[i]->str)); } freeReplyObject(reply); return m_blockPosList; }
virtual bool Item(cEntity * a_Entity) override { ASSERT(a_Entity != NULL); if (!a_Entity->IsPickup() || a_Entity->IsDestroyed()) { return false; } Vector3f EntityPos = a_Entity->GetPosition(); Vector3f BlockPos(m_Pos.x + 0.5f, (float)m_Pos.y + 1, m_Pos.z + 0.5f); // One block above hopper, and search from center outwards double Distance = (EntityPos - BlockPos).Length(); if (Distance < 0.5) { if (TrySuckPickupIn((cPickup *)a_Entity)) { return false; } } return false; }
FullBlock Location::getBlockAndData() { return region->getHandle()->getBlockAndData(BlockPos(position)); }
BlockPos LocalBlockPos::toGlobalPos(const ChunkPos& chunk) const { return BlockPos(x + chunk.x * 16, z + chunk.z * 16, y); }